MCPcopy
hub / github.com/codeaashu/claude-code / startKeychainPrefetch

Function startKeychainPrefetch

src/utils/secureStorage/keychainPrefetch.ts:69–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

67 * immediately after startMdmRawRead(). Non-darwin is a no-op.
68 */
69export function startKeychainPrefetch(): void {
70 if (process.platform !== 'darwin' || prefetchPromise || isBareMode()) return
71
72 // Fire both subprocesses immediately (non-blocking). They run in parallel
73 // with each other AND with main.tsx imports. The await in Promise.all
74 // happens later via ensureKeychainPrefetchCompleted().
75 const oauthSpawn = spawnSecurity(
76 getMacOsKeychainStorageServiceName(CREDENTIALS_SERVICE_SUFFIX),
77 )
78 const legacySpawn = spawnSecurity(getMacOsKeychainStorageServiceName())
79
80 prefetchPromise = Promise.all([oauthSpawn, legacySpawn]).then(
81 ([oauth, legacy]) => {
82 // Timed-out prefetch: don't prime. Sync read/spawn will retry with its
83 // own (longer) timeout. Priming null here would shadow a key that the
84 // sync path might successfully fetch.
85 if (!oauth.timedOut) primeKeychainCacheFromPrefetch(oauth.stdout)
86 if (!legacy.timedOut) legacyApiKeyPrefetch = { stdout: legacy.stdout }
87 },
88 )
89}
90
91/**
92 * Await prefetch completion. Called in main.tsx preAction alongside

Callers 1

main.tsxFile · 0.85

Calls 4

isBareModeFunction · 0.85
spawnSecurityFunction · 0.85

Tested by

no test coverage detected