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

Function _executeApiKeyHelper

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

Source from the content-addressed store, hash-verified

586}
587
588async function _executeApiKeyHelper(
589 isNonInteractiveSession: boolean,
590): Promise<string | null> {
591 const apiKeyHelper = getConfiguredApiKeyHelper()
592 if (!apiKeyHelper) {
593 return null
594 }
595
596 if (isApiKeyHelperFromProjectOrLocalSettings()) {
597 const hasTrust = checkHasTrustDialogAccepted()
598 if (!hasTrust && !isNonInteractiveSession) {
599 const error = new Error(
600 `Security: apiKeyHelper executed before workspace trust is confirmed. If you see this message, post in ${MACRO.FEEDBACK_CHANNEL}.`,
601 )
602 logAntError('apiKeyHelper invoked before trust check', error)
603 logEvent('tengu_apiKeyHelper_missing_trust11', {})
604 return null
605 }
606 }
607
608 const result = await execa(apiKeyHelper, {
609 shell: true,
610 timeout: 10 * 60 * 1000,
611 reject: false,
612 })
613 if (result.failed) {
614 // reject:false — execa resolves on exit≠0/timeout, stderr is on result
615 const why = result.timedOut ? 'timed out' : `exited ${result.exitCode}`
616 const stderr = result.stderr?.trim()
617 throw new Error(stderr ? `${why}: ${stderr}` : why)
618 }
619 const stdout = result.stdout?.trim()
620 if (!stdout) {
621 throw new Error('did not return a value')
622 }
623 return stdout
624}
625
626/**
627 * 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