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

推荐订阅源

D
Docker
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
A
About on SuperTechFans
博客园 - 【当耐特】
Microsoft Security Blog
Microsoft Security Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The GitHub Blog
The GitHub Blog
雷峰网
雷峰网
博客园_首页
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
IT之家
IT之家
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
aimingoo的专栏
aimingoo的专栏
博客园 - 聂微东
B
Blog RSS Feed
H
Help Net Security
Recent Announcements
Recent Announcements
阮一峰的网络日志
阮一峰的网络日志
D
DataBreaches.Net
L
LangChain Blog
Vercel News
Vercel News

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
Keep legacy Codex OAuth sidecar profiles usable (#83312) ...
joshavant · 2026-05-18 · via Recent Commits to openclaw:main

@@ -2,6 +2,8 @@ import fs from "node:fs/promises";

22

import os from "node:os";

33

import path from "node:path";

44

import { describe, expect, it, vi } from "vitest";

5+

import { resolveOAuthDir } from "../config/paths.js";

6+

import { legacyOAuthSidecarTestUtils } from "./auth-profiles/legacy-oauth-sidecar.js";

57

import { resolveAuthStatePath, resolveAuthStorePath } from "./auth-profiles/paths.js";

68

import {

79

clearRuntimeAuthProfileStoreSnapshots,

@@ -169,6 +171,174 @@ describe("saveAuthProfileStore", () => {

169171

}

170172

});

171173174+

it("keeps rehydrated legacy oauthRef sidecar tokens runtime-only during ordinary saves", async () => {

175+

const agentDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-auth-save-oauth-ref-"));

176+

const authPath = resolveAuthStorePath(agentDir);

177+

const previousOAuthDir = process.env.OPENCLAW_OAUTH_DIR;

178+

const previousSecretKey = process.env.OPENCLAW_AUTH_PROFILE_SECRET_KEY;

179+

process.env.OPENCLAW_OAUTH_DIR = path.join(agentDir, "credentials");

180+

process.env.OPENCLAW_AUTH_PROFILE_SECRET_KEY = "legacy-seed";

181+

const oauthRef = {

182+

source: "openclaw-credentials" as const,

183+

provider: "openai-codex" as const,

184+

id: "0123456789abcdef0123456789abcdef",

185+

};

186+

try {

187+

await fs.mkdir(agentDir, { recursive: true });

188+

await fs.writeFile(

189+

authPath,

190+

`${JSON.stringify(

191+

{

192+

version: 1,

193+

profiles: {

194+

"openai-codex:default": {

195+

type: "oauth",

196+

provider: "openai-codex",

197+

expires: Date.now() + 60_000,

198+

oauthRef,

199+

},

200+

},

201+

},

202+

null,

203+

2,

204+

)}\n`,

205+

);

206+

const sidecarPath = path.join(resolveOAuthDir(), "auth-profiles", `${oauthRef.id}.json`);

207+

await fs.mkdir(path.dirname(sidecarPath), { recursive: true });

208+

await fs.writeFile(

209+

sidecarPath,

210+

`${JSON.stringify(

211+

{

212+

version: 1,

213+

profileId: "openai-codex:default",

214+

provider: "openai-codex",

215+

encrypted: legacyOAuthSidecarTestUtils.encryptLegacyOAuthMaterial({

216+

ref: oauthRef,

217+

profileId: "openai-codex:default",

218+

provider: "openai-codex",

219+

seed: "legacy-seed",

220+

material: {

221+

access: "legacy-access-token",

222+

refresh: "legacy-refresh-token",

223+

},

224+

}),

225+

},

226+

null,

227+

2,

228+

)}\n`,

229+

);

230+231+

const runtimeStore = ensureAuthProfileStore(agentDir);

232+

expectProfileFields(runtimeStore.profiles["openai-codex:default"], {

233+

access: "legacy-access-token",

234+

refresh: "legacy-refresh-token",

235+

});

236+237+

delete process.env.OPENCLAW_AUTH_PROFILE_SECRET_KEY;

238+

const clonedRuntimeStore = JSON.parse(JSON.stringify(runtimeStore)) as AuthProfileStore;

239+

saveAuthProfileStore(clonedRuntimeStore, agentDir);

240+241+

const parsed = JSON.parse(await fs.readFile(authPath, "utf8")) as {

242+

profiles: Record<string, Record<string, unknown>>;

243+

};

244+

expect(parsed.profiles["openai-codex:default"]?.oauthRef).toEqual(oauthRef);

245+

expect(parsed.profiles["openai-codex:default"]).not.toHaveProperty("access");

246+

expect(parsed.profiles["openai-codex:default"]).not.toHaveProperty("refresh");

247+

} finally {

248+

if (previousOAuthDir === undefined) {

249+

delete process.env.OPENCLAW_OAUTH_DIR;

250+

} else {

251+

process.env.OPENCLAW_OAUTH_DIR = previousOAuthDir;

252+

}

253+

if (previousSecretKey === undefined) {

254+

delete process.env.OPENCLAW_AUTH_PROFILE_SECRET_KEY;

255+

} else {

256+

process.env.OPENCLAW_AUTH_PROFILE_SECRET_KEY = previousSecretKey;

257+

}

258+

clearRuntimeAuthProfileStoreSnapshots();

259+

await fs.rm(agentDir, { recursive: true, force: true });

260+

}

261+

});

262+263+

it("writes refreshed legacy sidecar tokens inline when they replace runtime sidecar material", async () => {

264+

const agentDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-auth-save-oauth-ref-"));

265+

const authPath = resolveAuthStorePath(agentDir);

266+

const previousOAuthDir = process.env.OPENCLAW_OAUTH_DIR;

267+

process.env.OPENCLAW_OAUTH_DIR = path.join(agentDir, "credentials");

268+

const profileId = "openai-codex:default";

269+

const oauthRef = {

270+

source: "openclaw-credentials",

271+

provider: "openai-codex",

272+

id: "0123456789abcdef0123456789abcdef",

273+

};

274+

try {

275+

await fs.mkdir(agentDir, { recursive: true });

276+

await fs.writeFile(

277+

authPath,

278+

`${JSON.stringify(

279+

{

280+

version: 1,

281+

profiles: {

282+

[profileId]: {

283+

type: "oauth",

284+

provider: "openai-codex",

285+

expires: Date.now() + 60_000,

286+

oauthRef,

287+

},

288+

},

289+

},

290+

null,

291+

2,

292+

)}\n`,

293+

);

294+

const sidecarPath = path.join(resolveOAuthDir(), "auth-profiles", `${oauthRef.id}.json`);

295+

await fs.mkdir(path.dirname(sidecarPath), { recursive: true });

296+

await fs.writeFile(

297+

sidecarPath,

298+

`${JSON.stringify(

299+

{

300+

version: 1,

301+

profileId,

302+

provider: "openai-codex",

303+

access: "legacy-access-token",

304+

refresh: "legacy-refresh-token",

305+

},

306+

null,

307+

2,

308+

)}\n`,

309+

);

310+311+

const runtimeStore = ensureAuthProfileStore(agentDir);

312+

const refreshedStore: AuthProfileStore = {

313+

...runtimeStore,

314+

profiles: {

315+

...runtimeStore.profiles,

316+

[profileId]: {

317+

...runtimeStore.profiles[profileId],

318+

access: "refreshed-access-token",

319+

refresh: "refreshed-refresh-token",

320+

} as AuthProfileStore["profiles"][string],

321+

},

322+

};

323+

saveAuthProfileStore(refreshedStore, agentDir);

324+325+

const parsed = JSON.parse(await fs.readFile(authPath, "utf8")) as {

326+

profiles: Record<string, Record<string, unknown>>;

327+

};

328+

expect(parsed.profiles[profileId]).not.toHaveProperty("oauthRef");

329+

expect(parsed.profiles[profileId]?.access).toBe("refreshed-access-token");

330+

expect(parsed.profiles[profileId]?.refresh).toBe("refreshed-refresh-token");

331+

} finally {

332+

if (previousOAuthDir === undefined) {

333+

delete process.env.OPENCLAW_OAUTH_DIR;

334+

} else {

335+

process.env.OPENCLAW_OAUTH_DIR = previousOAuthDir;

336+

}

337+

clearRuntimeAuthProfileStoreSnapshots();

338+

await fs.rm(agentDir, { recursive: true, force: true });

339+

}

340+

});

341+172342

it("refreshes the runtime snapshot when a saved store rotates oauth tokens", async () => {

173343

const agentDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-auth-save-runtime-"));

174344

try {