MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getApiKeyFromApiKeyHelper

Function getApiKeyFromApiKeyHelper

source code/utils/auth.ts:471–501  ·  view source on GitHub ↗
(
  isNonInteractiveSession: boolean,
)

Source from the content-addressed store, hash-verified

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

Callers 3

configureApiKeyHeadersFunction · 0.85
useApiKeyVerificationFunction · 0.85

Calls 3

calculateApiKeyHelperTTLFunction · 0.85
_runAndCacheFunction · 0.85

Tested by

no test coverage detected