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

Function getApiKeyFromApiKeyHelper

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

Source from the content-addressed store, hash-verified

517}
518
519export async function getApiKeyFromApiKeyHelper(
520 isNonInteractiveSession: boolean,
521): Promise<string | null> {
522 if (!getConfiguredApiKeyHelper()) return null
523 const ttl = calculateApiKeyHelperTTL()
524 if (_apiKeyHelperCache) {
525 if (Date.now() - _apiKeyHelperCache.timestamp < ttl) {
526 return _apiKeyHelperCache.value
527 }
528 // Stale — return stale value now, refresh in the background.
529 // `??=` banned here by eslint no-nullish-assign-object-call (bun bug).
530 if (!_apiKeyHelperInflight) {
531 _apiKeyHelperInflight = {
532 promise: _runAndCache(
533 isNonInteractiveSession,
534 false,
535 _apiKeyHelperEpoch,
536 ),
537 startedAt: null,
538 }
539 }
540 return _apiKeyHelperCache.value
541 }
542 // Cold cache — deduplicate concurrent calls
543 if (_apiKeyHelperInflight) return _apiKeyHelperInflight.promise
544 _apiKeyHelperInflight = {
545 promise: _runAndCache(isNonInteractiveSession, true, _apiKeyHelperEpoch),
546 startedAt: Date.now(),
547 }
548 return _apiKeyHelperInflight.promise
549}
550
551async function _runAndCache(
552 isNonInteractiveSession: boolean,

Callers 3

configureApiKeyHeadersFunction · 0.85
useApiKeyVerificationFunction · 0.85

Calls 3

calculateApiKeyHelperTTLFunction · 0.85
_runAndCacheFunction · 0.85

Tested by

no test coverage detected