MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / update

Function update

source code/utils/secureStorage/fallbackStorage.ts:29–64  ·  view source on GitHub ↗
(data: SecureStorageData)

Source from the content-addressed store, hash-verified

27 return (await secondary.readAsync()) || {}
28 },
29 update(data: SecureStorageData): { success: boolean; warning?: string } {
30 // Capture state before update
31 const primaryDataBefore = primary.read()
32
33 const result = primary.update(data)
34
35 if (result.success) {
36 // Delete secondary when migrating to primary for the first time
37 // This preserves credentials when sharing .claude between host and containers
38 // See: https://github.com/anthropics/claude-code/issues/1414
39 if (primaryDataBefore === null) {
40 secondary.delete()
41 }
42 return result
43 }
44
45 const fallbackResult = secondary.update(data)
46
47 if (fallbackResult.success) {
48 // Primary write failed but primary may still hold an *older* valid
49 // entry. read() prefers primary whenever it returns non-null, so that
50 // stale entry would shadow the fresh data we just wrote to secondary —
51 // e.g. a refresh token the server has already rotated away, causing a
52 // /login loop (#30337). Best-effort delete; if this also fails the
53 // user's keychain is in a bad state we can't fix from here.
54 if (primaryDataBefore !== null) {
55 primary.delete()
56 }
57 return {
58 success: true,
59 warning: fallbackResult.warning,
60 }
61 }
62
63 return { success: false }
64 },
65 delete(): boolean {
66 const primarySuccess = primary.delete()
67 const secondarySuccess = secondary.delete()

Callers

nothing calls this directly

Calls 2

deleteMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected