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

Function wouldLoseAuthState

src/utils/config.ts:783–795  ·  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

781 * wipe auth. See GH #3117.
782 */
783function wouldLoseAuthState(fresh: {
784 oauthAccount?: unknown
785 hasCompletedOnboarding?: boolean
786}): boolean {
787 const cached = globalConfigCache.config
788 if (!cached) return false
789 const lostOauth =
790 cached.oauthAccount !== undefined && fresh.oauthAccount === undefined
791 const lostOnboarding =
792 cached.hasCompletedOnboarding === true &&
793 fresh.hasCompletedOnboarding !== true
794 return lostOauth || lostOnboarding
795}
796
797export function saveGlobalConfig(
798 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