MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / getApiKeyFromApiKeyHelper

Function getApiKeyFromApiKeyHelper

src/utils/auth.ts:470–500  ·  view source on GitHub ↗
(
  isNonInteractiveSession: boolean,
)

Source from the content-addressed store, hash-verified

468}
469
470export async function getApiKeyFromApiKeyHelper(
471 isNonInteractiveSession: boolean,
472): Promise<string | null> {
473 if (!getConfiguredApiKeyHelper()) return null
474 const ttl = calculateApiKeyHelperTTL()
475 if (_apiKeyHelperCache) {
476 if (Date.now() - _apiKeyHelperCache.timestamp < ttl) {
477 return _apiKeyHelperCache.value
478 }
479 // Stale — return stale value now, refresh in the background.
480 // `??=` banned here by eslint no-nullish-assign-object-call (bun bug).
481 if (!_apiKeyHelperInflight) {
482 _apiKeyHelperInflight = {
483 promise: _runAndCache(
484 isNonInteractiveSession,
485 false,
486 _apiKeyHelperEpoch,
487 ),
488 startedAt: null,
489 }
490 }
491 return _apiKeyHelperCache.value
492 }
493 // Cold cache — deduplicate concurrent calls
494 if (_apiKeyHelperInflight) return _apiKeyHelperInflight.promise
495 _apiKeyHelperInflight = {
496 promise: _runAndCache(isNonInteractiveSession, true, _apiKeyHelperEpoch),
497 startedAt: Date.now(),
498 }
499 return _apiKeyHelperInflight.promise
500}
501
502async function _runAndCache(
503 isNonInteractiveSession: boolean,

Callers 3

configureApiKeyHeadersFunction · 0.85
useApiKeyVerificationFunction · 0.85

Calls 4

calculateApiKeyHelperTTLFunction · 0.85
_runAndCacheFunction · 0.85
nowMethod · 0.80

Tested by

no test coverage detected