()
| 1911 | } |
| 1912 | |
| 1913 | export function getAccountInformation() { |
| 1914 | const apiProvider = getAPIProvider() |
| 1915 | // Only provide account info for first-party Anthropic API |
| 1916 | if (apiProvider !== 'firstParty') { |
| 1917 | return undefined |
| 1918 | } |
| 1919 | const { source: authTokenSource } = getAuthTokenSource() |
| 1920 | const accountInfo: UserAccountInfo = {} |
| 1921 | if ( |
| 1922 | authTokenSource === 'CLAUDE_CODE_OAUTH_TOKEN' || |
| 1923 | authTokenSource === 'CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR' |
| 1924 | ) { |
| 1925 | accountInfo.tokenSource = authTokenSource |
| 1926 | } else if (isClaudeAISubscriber()) { |
| 1927 | accountInfo.subscription = getSubscriptionName() |
| 1928 | } else { |
| 1929 | accountInfo.tokenSource = authTokenSource |
| 1930 | } |
| 1931 | const { key: apiKey, source: apiKeySource } = getAnthropicApiKeyWithSource() |
| 1932 | if (apiKey) { |
| 1933 | accountInfo.apiKeySource = apiKeySource |
| 1934 | } |
| 1935 | |
| 1936 | // We don't know the organization if we're relying on an external API key or auth token |
| 1937 | if ( |
| 1938 | authTokenSource === 'claude.ai' || |
| 1939 | apiKeySource === '/login managed key' |
| 1940 | ) { |
| 1941 | // Get organization name from OAuth account info |
| 1942 | const orgName = getOauthAccountInfo()?.organizationName |
| 1943 | if (orgName) { |
| 1944 | accountInfo.organization = orgName |
| 1945 | } |
| 1946 | } |
| 1947 | const email = getOauthAccountInfo()?.emailAddress |
| 1948 | if ( |
| 1949 | (authTokenSource === 'claude.ai' || |
| 1950 | apiKeySource === '/login managed key') && |
| 1951 | |
| 1952 | ) { |
| 1953 | accountInfo.email = email |
| 1954 | } |
| 1955 | return accountInfo |
| 1956 | } |
| 1957 | |
| 1958 | /** |
| 1959 | * Result of org validation — either success or a descriptive error. |
no test coverage detected