MCPcopy Create free account
hub / github.com/oboard/claude-code-rev / authStatus

Function authStatus

src/cli/handlers/auth.ts:236–331  ·  view source on GitHub ↗
(opts: {
  json?: boolean
  text?: boolean
})

Source from the content-addressed store, hash-verified

234}
235
236export async function authStatus(opts: {
237 json?: boolean
238 text?: boolean
239}): Promise<void> {
240 const { source: authTokenSource, hasToken } = getAuthTokenSource()
241 const { source: apiKeySource } = getAnthropicApiKeyWithSource()
242 const hasApiKeyEnvVar =
243 !!process.env.ANTHROPIC_API_KEY && !isRunningOnHomespace()
244 const oauthAccount = getOauthAccountInfo()
245 const subscriptionType = getSubscriptionType()
246 const using3P = isUsing3PServices()
247 const loggedIn =
248 hasToken || apiKeySource !== 'none' || hasApiKeyEnvVar || using3P
249
250 // Determine auth method
251 let authMethod: string = 'none'
252 if (using3P) {
253 authMethod = 'third_party'
254 } else if (authTokenSource === 'claude.ai') {
255 authMethod = 'claude.ai'
256 } else if (authTokenSource === 'providerAuthToken') {
257 authMethod = 'provider_token'
258 } else if (authTokenSource === 'apiKeyHelper') {
259 authMethod = 'api_key_helper'
260 } else if (authTokenSource !== 'none') {
261 authMethod = 'oauth_token'
262 } else if (apiKeySource === 'ANTHROPIC_API_KEY' || hasApiKeyEnvVar) {
263 authMethod = 'api_key'
264 } else if (apiKeySource === '/login managed key') {
265 authMethod = 'claude.ai'
266 }
267
268 if (opts.text) {
269 const properties = [
270 ...buildAccountProperties(),
271 ...buildAPIProviderProperties(),
272 ]
273 let hasAuthProperty = false
274 for (const prop of properties) {
275 const value =
276 typeof prop.value === 'string'
277 ? prop.value
278 : Array.isArray(prop.value)
279 ? prop.value.join(', ')
280 : null
281 if (value === null || value === 'none') {
282 continue
283 }
284 hasAuthProperty = true
285 if (prop.label) {
286 process.stdout.write(`${prop.label}: ${value}\n`)
287 } else {
288 process.stdout.write(`${value}\n`)
289 }
290 }
291 if (!hasAuthProperty && hasApiKeyEnvVar) {
292 process.stdout.write('API key: ANTHROPIC_API_KEY\n')
293 }

Callers 1

runFunction · 0.85

Calls 13

getAuthTokenSourceFunction · 0.85
isRunningOnHomespaceFunction · 0.85
getSubscriptionTypeFunction · 0.85
isUsing3PServicesFunction · 0.85
buildAccountPropertiesFunction · 0.85
getAPIProviderFunction · 0.85
getActiveProviderConfigFunction · 0.85
getProviderDisplayNameFunction · 0.85
jsonStringifyFunction · 0.85
getOauthAccountInfoFunction · 0.50

Tested by

no test coverage detected