| 107 | }) |
| 108 | |
| 109 | function buildSession( |
| 110 | overrides: Partial<ResolvedAuthSession> = {}, |
| 111 | ): ResolvedAuthSession { |
| 112 | return { |
| 113 | principalKind: 'noumena_account', |
| 114 | principalSource: 'managed_oauth', |
| 115 | sessionState: 'usable', |
| 116 | headersKind: 'bearer', |
| 117 | providerAuthKind: 'noumena_first_party', |
| 118 | providerPlan: { |
| 119 | mode: 'noumena_managed', |
| 120 | source: 'managed_principal', |
| 121 | staticKeyEnvVarName: null, |
| 122 | }, |
| 123 | isInteractive: true, |
| 124 | canRefresh: true, |
| 125 | canReauthenticateInteractively: true, |
| 126 | identity: { |
| 127 | email: 'dev@noumena.com', |
| 128 | accountUuid: 'acct-1', |
| 129 | organizationUuid: 'org-1', |
| 130 | organizationName: 'Acme', |
| 131 | }, |
| 132 | subscription: { |
| 133 | subscriptionName: 'Noumena Pro', |
| 134 | subscriptionType: 'pro', |
| 135 | rateLimitTier: 'tier-1', |
| 136 | }, |
| 137 | scopes: ['user:inference', 'user:profile'], |
| 138 | hasUsableToken: true, |
| 139 | hasUsableApiKey: false, |
| 140 | accessToken: 'managed-token', |
| 141 | accessTokenExpiresAt: 1_700_000_900_000, |
| 142 | refreshTokenPresent: true, |
| 143 | apiKey: null, |
| 144 | rawAuthTokenSource: 'noumena.com', |
| 145 | rawApiKeySource: null, |
| 146 | recoveryAction: 'none', |
| 147 | recoveryMessage: null, |
| 148 | sourceDetails: { |
| 149 | usedLegacyCompat: false, |
| 150 | usedEnvVar: false, |
| 151 | usedFileDescriptor: false, |
| 152 | usedHelper: false, |
| 153 | }, |
| 154 | ...overrides, |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | describe('runtime lease adapters', () => { |
| 159 | it('builds a renewable local first-party lease from a managed session', () => { |