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

Function _executeApiKeyHelper

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

Source from the content-addressed store, hash-verified

538}
539
540async function _executeApiKeyHelper(
541 isNonInteractiveSession: boolean,
542): Promise<string | null> {
543 const apiKeyHelper = getConfiguredApiKeyHelper()
544 if (!apiKeyHelper) {
545 return null
546 }
547
548 if (isApiKeyHelperFromProjectOrLocalSettings()) {
549 const hasTrust = checkHasTrustDialogAccepted()
550 if (!hasTrust && !isNonInteractiveSession) {
551 const error = new Error(
552 `Security: apiKeyHelper executed before workspace trust is confirmed. If you see this message, post in ${MACRO.FEEDBACK_CHANNEL}.`,
553 )
554 logAntError('apiKeyHelper invoked before trust check', error)
555 logEvent('tengu_apiKeyHelper_missing_trust11', {})
556 return null
557 }
558 }
559
560 const result = await execa(apiKeyHelper, {
561 shell: true,
562 timeout: 10 * 60 * 1000,
563 reject: false,
564 })
565 if (result.failed) {
566 // reject:false — execa resolves on exit≠0/timeout, stderr is on result
567 const why = result.timedOut ? 'timed out' : `exited ${result.exitCode}`
568 const stderr = result.stderr?.trim()
569 throw new Error(stderr ? `${why}: ${stderr}` : why)
570 }
571 const stdout = result.stdout?.trim()
572 if (!stdout) {
573 throw new Error('did not return a value')
574 }
575 return stdout
576}
577
578/**
579 * Sync cache reader — returns the last fetched apiKeyHelper value without executing.

Callers 1

_runAndCacheFunction · 0.85

Calls 5

logAntErrorFunction · 0.85
logEventFunction · 0.85

Tested by

no test coverage detected