MCPcopy Create free account
hub / github.com/Noumena-Network/code / maybePersistTokenForSubprocesses

Function maybePersistTokenForSubprocesses

src/utils/authFileDescriptor.ts:35–55  ·  view source on GitHub ↗
(
  path: string,
  token: string,
  tokenName: string,
)

Source from the content-addressed store, hash-verified

33 * put a token on disk that the FD was meant to keep off disk.
34 */
35export function maybePersistTokenForSubprocesses(
36 path: string,
37 token: string,
38 tokenName: string,
39): void {
40 if (!isEnvTruthy(process.env.CLAUDE_CODE_REMOTE)) {
41 return
42 }
43 try {
44 // eslint-disable-next-line custom-rules/no-sync-fs -- one-shot startup write in CCR, caller is sync
45 mkdirSync(CCR_TOKEN_DIR, { recursive: true, mode: 0o700 })
46 // eslint-disable-next-line custom-rules/no-sync-fs -- one-shot startup write in CCR, caller is sync
47 writeFileSync(path, token, { encoding: 'utf8', mode: 0o600 })
48 logForDebugging(`Persisted ${tokenName} to ${path} for subprocess access`)
49 } catch (error) {
50 logForDebugging(
51 `Failed to persist ${tokenName} to disk (non-fatal): ${errorMessage(error)}`,
52 { level: 'error' },
53 )
54 }
55}
56
57/**
58 * Fallback read from a well-known file. The path only exists in CCR (env-manager

Callers 2

getCredentialFromFdFunction · 0.85

Calls 4

isEnvTruthyFunction · 0.90
mkdirSyncFunction · 0.90
logForDebuggingFunction · 0.70
errorMessageFunction · 0.70

Tested by

no test coverage detected