()
| 1929 | } |
| 1930 | |
| 1931 | export function getAccountInformation() { |
| 1932 | const apiProvider = getAPIProvider() |
| 1933 | // Only provide account info for first-party Anthropic API |
| 1934 | if (apiProvider !== 'firstParty') { |
| 1935 | return undefined |
| 1936 | } |
| 1937 | const { source: authTokenSource } = getAuthTokenSource() |
| 1938 | const accountInfo: UserAccountInfo = {} |
| 1939 | if ( |
| 1940 | authTokenSource === 'CLAUDE_CODE_OAUTH_TOKEN' || |
| 1941 | authTokenSource === 'CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR' |
| 1942 | ) { |
| 1943 | accountInfo.tokenSource = authTokenSource |
| 1944 | } else if (isClaudeAISubscriber()) { |
| 1945 | accountInfo.subscription = getSubscriptionName() |
| 1946 | } else { |
| 1947 | accountInfo.tokenSource = authTokenSource |
| 1948 | } |
| 1949 | const { key: apiKey, source: apiKeySource } = getAnthropicApiKeyWithSource() |
| 1950 | if (apiKey) { |
| 1951 | accountInfo.apiKeySource = apiKeySource |
| 1952 | } |
| 1953 | |
| 1954 | // We don't know the organization if we're relying on an external API key or auth token |
| 1955 | if ( |
| 1956 | authTokenSource === 'claude.ai' || |
| 1957 | apiKeySource === '/login managed key' |
| 1958 | ) { |
| 1959 | // Get organization name from OAuth account info |
| 1960 | const orgName = getOauthAccountInfo()?.organizationName |
| 1961 | if (orgName) { |
| 1962 | accountInfo.organization = orgName |
| 1963 | } |
| 1964 | } |
| 1965 | const email = getOauthAccountInfo()?.emailAddress |
| 1966 | if ( |
| 1967 | (authTokenSource === 'claude.ai' || |
| 1968 | apiKeySource === '/login managed key') && |
| 1969 | |
| 1970 | ) { |
| 1971 | accountInfo.email = email |
| 1972 | } |
| 1973 | return accountInfo |
| 1974 | } |
| 1975 | |
| 1976 | /** |
| 1977 | * Result of org validation — either success or a descriptive error. |
no test coverage detected