()
| 5 | import { getGlobalConfig } from 'src/utils/config.js' |
| 6 | import { logError } from 'src/utils/log.js' |
| 7 | export async function getOauthProfileFromApiKey(): Promise< |
| 8 | OAuthProfileResponse | undefined |
| 9 | > { |
| 10 | // Assumes interactive session |
| 11 | const config = getGlobalConfig() |
| 12 | const accountUuid = config.oauthAccount?.accountUuid |
| 13 | const apiKey = getAnthropicApiKey() |
| 14 | |
| 15 | // Need both account UUID and API key to check |
| 16 | if (!accountUuid || !apiKey) { |
| 17 | return |
| 18 | } |
| 19 | const endpoint = `${getOauthConfig().BASE_API_URL}/api/claude_cli_profile` |
| 20 | try { |
| 21 | const response = await axios.get<OAuthProfileResponse>(endpoint, { |
| 22 | headers: { |
| 23 | 'x-api-key': apiKey, |
| 24 | 'anthropic-beta': OAUTH_BETA_HEADER, |
| 25 | }, |
| 26 | params: { |
| 27 | account_uuid: accountUuid, |
| 28 | }, |
| 29 | timeout: 10000, |
| 30 | }) |
| 31 | return response.data |
| 32 | } catch (error) { |
| 33 | logError(error as Error) |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | export async function getOauthProfileFromOauthToken( |
| 38 | accessToken: string, |
no test coverage detected