()
| 1861 | } |
| 1862 | |
| 1863 | export function getAccountInformation() { |
| 1864 | const apiProvider = getAPIProvider() |
| 1865 | // Only provide account info for first-party Anthropic API |
| 1866 | if (apiProvider !== 'firstParty') { |
| 1867 | return undefined |
| 1868 | } |
| 1869 | const { source: authTokenSource } = getAuthTokenSource() |
| 1870 | const accountInfo: UserAccountInfo = {} |
| 1871 | if ( |
| 1872 | authTokenSource === 'CLAUDE_CODE_OAUTH_TOKEN' || |
| 1873 | authTokenSource === 'CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR' |
| 1874 | ) { |
| 1875 | accountInfo.tokenSource = authTokenSource |
| 1876 | } else if (isClaudeAISubscriber()) { |
| 1877 | accountInfo.subscription = getSubscriptionName() |
| 1878 | } else { |
| 1879 | accountInfo.tokenSource = authTokenSource |
| 1880 | } |
| 1881 | const { key: apiKey, source: apiKeySource } = getAnthropicApiKeyWithSource() |
| 1882 | if (apiKey) { |
| 1883 | accountInfo.apiKeySource = apiKeySource |
| 1884 | } |
| 1885 | |
| 1886 | // We don't know the organization if we're relying on an external API key or auth token |
| 1887 | if ( |
| 1888 | authTokenSource === 'claude.ai' || |
| 1889 | apiKeySource === '/login managed key' |
| 1890 | ) { |
| 1891 | // Get organization name from OAuth account info |
| 1892 | const orgName = getOauthAccountInfo()?.organizationName |
| 1893 | if (orgName) { |
| 1894 | accountInfo.organization = orgName |
| 1895 | } |
| 1896 | } |
| 1897 | const email = getOauthAccountInfo()?.emailAddress |
| 1898 | if ( |
| 1899 | (authTokenSource === 'claude.ai' || |
| 1900 | apiKeySource === '/login managed key') && |
| 1901 | |
| 1902 | ) { |
| 1903 | accountInfo.email = email |
| 1904 | } |
| 1905 | return accountInfo |
| 1906 | } |
| 1907 | |
| 1908 | /** |
| 1909 | * Result of org validation — either success or a descriptive error. |
no test coverage detected