()
| 2140 | } |
| 2141 | |
| 2142 | export function getAccountInformation() { |
| 2143 | const apiProvider = getAPIProvider() |
| 2144 | // Only provide account info for first-party Anthropic API |
| 2145 | if (apiProvider !== 'firstParty') { |
| 2146 | return undefined |
| 2147 | } |
| 2148 | const { source: authTokenSource } = getAuthTokenSource() |
| 2149 | const managedOAuthState = getManagedOAuthState() |
| 2150 | const accountInfo: UserAccountInfo = {} |
| 2151 | if ( |
| 2152 | authTokenSource === 'NCODE_OAUTH_TOKEN' || |
| 2153 | authTokenSource === 'CLAUDE_CODE_OAUTH_TOKEN' || |
| 2154 | authTokenSource === 'NCODE_OAUTH_TOKEN_FILE_DESCRIPTOR' || |
| 2155 | authTokenSource === 'CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR' |
| 2156 | ) { |
| 2157 | accountInfo.tokenSource = authTokenSource |
| 2158 | } else if (isClaudeAISubscriber()) { |
| 2159 | accountInfo.subscription = getSubscriptionName() |
| 2160 | } else { |
| 2161 | accountInfo.tokenSource = authTokenSource |
| 2162 | } |
| 2163 | const { key: apiKey, source: apiKeySource } = getAnthropicApiKeyWithSource() |
| 2164 | const hasManagedAccountContext = |
| 2165 | authTokenSource === 'noumena.com' || apiKeySource === '/login managed key' |
| 2166 | if (apiKey) { |
| 2167 | accountInfo.apiKeySource = apiKeySource |
| 2168 | } |
| 2169 | if (managedOAuthState === 'expired') { |
| 2170 | accountInfo.authTokenExpired = true |
| 2171 | } |
| 2172 | |
| 2173 | // We don't know the organization if we're relying on an external API key or auth token |
| 2174 | if (hasManagedAccountContext) { |
| 2175 | // Get organization name from OAuth account info |
| 2176 | const orgName = getOauthAccountInfo()?.organizationName |
| 2177 | if (orgName) { |
| 2178 | accountInfo.organization = orgName |
| 2179 | } |
| 2180 | } |
| 2181 | const email = getOauthAccountInfo()?.emailAddress |
| 2182 | if (hasManagedAccountContext && email) { |
| 2183 | accountInfo.email = email |
| 2184 | } |
| 2185 | return accountInfo |
| 2186 | } |
| 2187 | |
| 2188 | /** |
| 2189 | * Result of org validation — either success or a descriptive error. |
nothing calls this directly
no test coverage detected