MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / wouldLoseAuthState

Function wouldLoseAuthState

src/utils/config.ts:791–803  ·  view source on GitHub ↗

* Detect whether writing `fresh` would lose auth/onboarding state that the * in-memory cache still has. This happens when `getConfig` hits a corrupted * or truncated file mid-write (from another process or a non-atomic fallback) * and returns DEFAULT_GLOBAL_CONFIG. Writing that back would permane

(fresh: {
  oauthAccount?: unknown
  hasCompletedOnboarding?: boolean
})

Source from the content-addressed store, hash-verified

789 * wipe auth. See GH #3117.
790 */
791function wouldLoseAuthState(fresh: {
792 oauthAccount?: unknown
793 hasCompletedOnboarding?: boolean
794}): boolean {
795 const cached = globalConfigCache.config
796 if (!cached) return false
797 const lostOauth =
798 cached.oauthAccount !== undefined && fresh.oauthAccount === undefined
799 const lostOnboarding =
800 cached.hasCompletedOnboarding === true &&
801 fresh.hasCompletedOnboarding !== true
802 return lostOauth || lostOnboarding
803}
804
805export function saveGlobalConfig(
806 updater: (currentConfig: GlobalConfig) => GlobalConfig,

Callers 3

saveGlobalConfigFunction · 0.85
saveConfigWithLockFunction · 0.85
saveCurrentProjectConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected