| 76 | } |
| 77 | |
| 78 | function makeSession( |
| 79 | overrides: Partial<ResolvedAuthSession> = {}, |
| 80 | ): ResolvedAuthSession { |
| 81 | return { |
| 82 | principalKind: 'noumena_account', |
| 83 | principalSource: 'managed_oauth', |
| 84 | sessionState: 'usable', |
| 85 | headersKind: 'bearer', |
| 86 | providerAuthKind: 'noumena_first_party', |
| 87 | providerPlan: { |
| 88 | mode: 'noumena_managed', |
| 89 | source: 'managed_principal', |
| 90 | staticKeyEnvVarName: null, |
| 91 | }, |
| 92 | isInteractive: true, |
| 93 | canRefresh: true, |
| 94 | canReauthenticateInteractively: true, |
| 95 | identity: { |
| 96 | email: 'user@example.com', |
| 97 | accountUuid: 'acct-123', |
| 98 | organizationUuid: 'org-123', |
| 99 | organizationName: 'Test Org', |
| 100 | }, |
| 101 | subscription: { |
| 102 | subscriptionName: 'Noumena Max', |
| 103 | subscriptionType: 'max', |
| 104 | rateLimitTier: 'tier-1', |
| 105 | }, |
| 106 | scopes: ['user:profile', 'user:inference'], |
| 107 | hasUsableToken: true, |
| 108 | hasUsableApiKey: false, |
| 109 | accessToken: 'oauth-token', |
| 110 | accessTokenExpiresAt: Date.now() + 10 * 60 * 1_000, |
| 111 | refreshTokenPresent: true, |
| 112 | apiKey: null, |
| 113 | rawAuthTokenSource: 'noumena.com', |
| 114 | rawApiKeySource: null, |
| 115 | recoveryAction: 'none', |
| 116 | recoveryMessage: null, |
| 117 | sourceDetails: { |
| 118 | usedLegacyCompat: false, |
| 119 | usedEnvVar: false, |
| 120 | usedFileDescriptor: false, |
| 121 | usedHelper: false, |
| 122 | }, |
| 123 | ...overrides, |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | function withMockCurrentSession<T>( |
| 128 | session: ResolvedAuthSession, |