惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
H
Help Net Security
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
P
Proofpoint News Feed
A
About on SuperTechFans
V
V2EX
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
宝玉的分享
宝玉的分享
aimingoo的专栏
aimingoo的专栏
F
Fortinet All Blogs
博客园 - 【当耐特】
Microsoft Security Blog
Microsoft Security Blog
Martin Fowler
Martin Fowler
I
InfoQ
Google DeepMind News
Google DeepMind News
人人都是产品经理
人人都是产品经理
Engineering at Meta
Engineering at Meta
腾讯CDC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
U
Unit 42
The Cloudflare Blog
Y
Y Combinator Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(cli): stabilize claude auth epochs on token rotation ...
stainlu · 2026-05-31 · via Recent Commits to openclaw:main

@@ -30,7 +30,12 @@ describe("resolveCliAuthEpoch", () => {

3030

}),

3131

});

323233-

await expect(resolveCliAuthEpoch({ provider: "claude-cli" })).resolves.toBeUndefined();

33+

await expect(

34+

resolveCliAuthEpoch({

35+

provider: "claude-cli",

36+

authProfileId: "anthropic:work",

37+

}),

38+

).resolves.toBeUndefined();

3439

await expect(

3540

resolveCliAuthEpoch({

3641

provider: "google-gemini-cli",

@@ -63,7 +68,7 @@ describe("resolveCliAuthEpoch", () => {

6368

expect(second).toBe(first);

6469

});

657066-

it("changes claude cli token epochs when the static token changes", async () => {

71+

it("keeps claude cli token epochs stable across token rotation", async () => {

6772

let token = "token-a";

6873

setCliAuthEpochTestDeps({

6974

readClaudeCliCredentialsCached: () => ({

@@ -79,8 +84,65 @@ describe("resolveCliAuthEpoch", () => {

7984

const second = await resolveCliAuthEpoch({ provider: "claude-cli" });

80858186

expectCliAuthEpoch(first);

82-

expectCliAuthEpoch(second);

83-

expect(second).not.toBe(first);

87+

// Static-token rotation is an authorized credential refresh, not an

88+

// identity change. After #74312 the hash is identity-only for both

89+

// OAuth and token branches, so rotation does not invalidate the epoch.

90+

expect(second).toBe(first);

91+

});

92+93+

it("matches claude cli token and oauth epochs so partial keychain reads do not flip", async () => {

94+

setCliAuthEpochTestDeps({

95+

readClaudeCliCredentialsCached: () => ({

96+

type: "oauth",

97+

provider: "anthropic",

98+

access: "access",

99+

refresh: "refresh",

100+

expires: 1,

101+

}),

102+

});

103+

const oauthEpoch = await resolveCliAuthEpoch({ provider: "claude-cli" });

104+105+

setCliAuthEpochTestDeps({

106+

readClaudeCliCredentialsCached: () => ({

107+

type: "token",

108+

provider: "anthropic",

109+

token: "access",

110+

expires: 1,

111+

}),

112+

});

113+

const tokenEpoch = await resolveCliAuthEpoch({ provider: "claude-cli" });

114+115+

expectCliAuthEpoch(oauthEpoch);

116+

expectCliAuthEpoch(tokenEpoch);

117+

// The macOS Claude keychain rewrite is not atomic. A transient read with

118+

// `refreshToken` missing falls into the parser's token branch; the OAuth

119+

// and token encodings must produce the same hash so the auth-epoch does

120+

// not flip during a token rotation. Regression for #74312.

121+

expect(tokenEpoch).toBe(oauthEpoch);

122+

});

123+124+

it("drops the claude cli epoch when the credential read is absent", async () => {

125+

setCliAuthEpochTestDeps({

126+

readClaudeCliCredentialsCached: () => ({

127+

type: "oauth",

128+

provider: "anthropic",

129+

access: "access",

130+

refresh: "refresh",

131+

expires: 1,

132+

}),

133+

});

134+

const successfulRead = await resolveCliAuthEpoch({ provider: "claude-cli" });

135+136+

// A null read can mean the credential was removed or logout left no

137+

// readable auth state. Keep that absence visible so reusable sessions do

138+

// not survive a true auth-state loss.

139+

setCliAuthEpochTestDeps({

140+

readClaudeCliCredentialsCached: () => null,

141+

});

142+

const nullRead = await resolveCliAuthEpoch({ provider: "claude-cli" });

143+144+

expectCliAuthEpoch(successfulRead);

145+

expect(nullRead).toBeUndefined();

84146

});

8514786148

it("keeps gemini cli oauth epochs stable through token rotation and flips on account change", async () => {

@@ -271,6 +333,143 @@ describe("resolveCliAuthEpoch", () => {

271333

expect(second).not.toBe(first);

272334

});

273335336+

it("keeps token auth-profile epochs stable across credential.token rotation when identity is present", async () => {

337+

let store: AuthProfileStore = {

338+

version: 1,

339+

profiles: {

340+

"anthropic:work": {

341+

type: "token",

342+

provider: "anthropic",

343+

token: "token-a",

344+

tokenRef: { source: "env", provider: "default", id: "ANTHROPIC_TOKEN" },

345+

email: "user@example.com",

346+

displayName: "Work",

347+

},

348+

},

349+

};

350+

setCliAuthEpochTestDeps({

351+

readGeminiCliCredentialsCached: () => null,

352+

loadAuthProfileStoreForRuntime: () => store,

353+

});

354+355+

const first = await resolveCliAuthEpoch({

356+

provider: "google-gemini-cli",

357+

authProfileId: "anthropic:work",

358+

});

359+

store = {

360+

version: 1,

361+

profiles: {

362+

"anthropic:work": {

363+

type: "token",

364+

provider: "anthropic",

365+

token: "token-b",

366+

tokenRef: { source: "env", provider: "default", id: "ANTHROPIC_TOKEN" },

367+

email: "user@example.com",

368+

displayName: "Work",

369+

},

370+

},

371+

};

372+

const second = await resolveCliAuthEpoch({

373+

provider: "google-gemini-cli",

374+

authProfileId: "anthropic:work",

375+

});

376+377+

expectCliAuthEpoch(first);

378+

// Ref-backed token rotation must not flip the epoch; the token material is

379+

// only a refreshable secret when the profile has a stable secret owner.

380+

expect(second).toBe(first);

381+

});

382+383+

it("changes token auth-profile epochs when token-only credentials change", async () => {

384+

let store: AuthProfileStore = {

385+

version: 1,

386+

profiles: {

387+

"anthropic:token-only": {

388+

type: "token",

389+

provider: "anthropic",

390+

token: "token-a",

391+

displayName: "Manual token",

392+

},

393+

},

394+

};

395+

setCliAuthEpochTestDeps({

396+

readGeminiCliCredentialsCached: () => null,

397+

loadAuthProfileStoreForRuntime: () => store,

398+

});

399+400+

const first = await resolveCliAuthEpoch({

401+

provider: "google-gemini-cli",

402+

authProfileId: "anthropic:token-only",

403+

});

404+

store = {

405+

version: 1,

406+

profiles: {

407+

"anthropic:token-only": {

408+

type: "token",

409+

provider: "anthropic",

410+

token: "token-b",

411+

displayName: "Manual token",

412+

},

413+

},

414+

};

415+

const second = await resolveCliAuthEpoch({

416+

provider: "google-gemini-cli",

417+

authProfileId: "anthropic:token-only",

418+

});

419+420+

expectCliAuthEpoch(first);

421+

expectCliAuthEpoch(second);

422+

// Token-only profiles have no stable account/ref identity, so the token

423+

// remains the session owner and manual replacement still invalidates.

424+

expect(second).not.toBe(first);

425+

});

426+427+

it("changes token auth-profile epochs when the email identity changes", async () => {

428+

let store: AuthProfileStore = {

429+

version: 1,

430+

profiles: {

431+

"anthropic:work": {

432+

type: "token",

433+

provider: "anthropic",

434+

token: "token",

435+

email: "user-a@example.com",

436+

displayName: "Work",

437+

},

438+

},

439+

};

440+

setCliAuthEpochTestDeps({

441+

readGeminiCliCredentialsCached: () => null,

442+

loadAuthProfileStoreForRuntime: () => store,

443+

});

444+445+

const first = await resolveCliAuthEpoch({

446+

provider: "google-gemini-cli",

447+

authProfileId: "anthropic:work",

448+

});

449+

store = {

450+

version: 1,

451+

profiles: {

452+

"anthropic:work": {

453+

type: "token",

454+

provider: "anthropic",

455+

token: "token",

456+

email: "user-b@example.com",

457+

displayName: "Work",

458+

},

459+

},

460+

};

461+

const second = await resolveCliAuthEpoch({

462+

provider: "google-gemini-cli",

463+

authProfileId: "anthropic:work",

464+

});

465+466+

expectCliAuthEpoch(first);

467+

expectCliAuthEpoch(second);

468+

// A real account switch on a static-token profile must still invalidate

469+

// the epoch so reusable CLI sessions don't outlive the identity change.

470+

expect(second).not.toBe(first);

471+

});

472+274473

it("changes oauth auth-profile epochs when the account identity changes", async () => {

275474

let store: AuthProfileStore = {

276475

version: 1,