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

Function wouldLoseAuthState

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

830 * wipe auth. See GH #3117.
831 */
832function wouldLoseAuthState(fresh: {
833 oauthAccount?: unknown
834 hasCompletedOnboarding?: boolean
835}): boolean {
836 const cached = globalConfigCache.config
837 if (!cached) return false
838 const lostOauth =
839 cached.oauthAccount !== undefined && fresh.oauthAccount === undefined
840 const lostOnboarding =
841 cached.hasCompletedOnboarding === true &&
842 fresh.hasCompletedOnboarding !== true
843 return lostOauth || lostOnboarding
844}
845
846export function saveGlobalConfig(
847 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