(options?: {
requireProfileScope?: boolean
})
| 1832 | } |
| 1833 | |
| 1834 | export function getUsableClaudeAiAccessToken(options?: { |
| 1835 | requireProfileScope?: boolean |
| 1836 | }): string | null { |
| 1837 | if (!isAnthropicAuthEnabled()) { |
| 1838 | return null |
| 1839 | } |
| 1840 | |
| 1841 | const oauthTokens = getClaudeAIOAuthTokens() |
| 1842 | if (!oauthTokens?.accessToken) { |
| 1843 | return null |
| 1844 | } |
| 1845 | |
| 1846 | if (!shouldUseClaudeAIAuth(oauthTokens.scopes)) { |
| 1847 | return null |
| 1848 | } |
| 1849 | |
| 1850 | if (options?.requireProfileScope && !hasProfileScope()) { |
| 1851 | return null |
| 1852 | } |
| 1853 | |
| 1854 | if (isOAuthTokenExpired(oauthTokens.expiresAt)) { |
| 1855 | return null |
| 1856 | } |
| 1857 | |
| 1858 | return oauthTokens.accessToken |
| 1859 | } |
| 1860 | |
| 1861 | export function is1PApiCustomer(): boolean { |
| 1862 | // 1P API customers are users who are NOT: |
no test coverage detected