Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(auth): persist rotated sessions before use
xd-bobo3e03f9643ab5
diff --git a/apps/mobile/src/__tests__/mobileAuthServerLogin.test.ts b/apps/mobile/src/__tests__/mobileAuthServerLogin.test.tsindex 2ebad4c675..bbc5532139 100644--- a/apps/mobile/src/__tests__/mobileAuthServerLogin.test.ts+++ b/apps/mobile/src/__tests__/mobileAuthServerLogin.test.ts@@ -308,6 +308,18 @@ describe('mobile auth-server login', () => {const refreshStart = authSource.indexOf('const refresh = useCallback');const refreshEnd = authSource.indexOf('\n useEffect(() => {', refreshStart);const refreshBody = authSource.slice(refreshStart, refreshEnd);+ const resourceVaultWrite = refreshBody.indexOf(+ 'await rememberMobileResourceSession(',+ );+ const publishAccessToken = refreshBody.indexOf(+ 'setToken(pair.accessToken);',+ resourceVaultWrite,+ );+ expect(resourceVaultWrite).toBeGreaterThan(-1);+ expect(publishAccessToken).toBeGreaterThan(resourceVaultWrite);+ expect(refreshBody.slice(resourceVaultWrite, publishAccessToken)).not.toContain(+ '.catch(',+ );expect(refreshBody).toMatch(/if \(authGenerationRef\.current !== generation\) return null;\s+const passportId =[\s\S]*?setToken\(pair\.accessToken\);/,);diff --git a/apps/mobile/src/auth/AuthContext.tsx b/apps/mobile/src/auth/AuthContext.tsxindex fd0d2b450a..bd1f43d516 100644--- a/apps/mobile/src/auth/AuthContext.tsx+++ b/apps/mobile/src/auth/AuthContext.tsx@@ -1050,7 +1050,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {pair,session.realm,passportId,- ).catch(() => null);+ );setToken(pair.accessToken);applyUser(mergeMembershipWithExisting(diff --git a/packages/auth-client/src/__tests__/client.test.ts b/packages/auth-client/src/__tests__/client.test.tsindex 86b42aed18..52bd4c3c0c 100644--- a/packages/auth-client/src/__tests__/client.test.ts+++ b/packages/auth-client/src/__tests__/client.test.ts@@ -366,6 +366,10 @@ describe("CindyAuthClient", () => {expect(fetch.mock.calls[3]?.[1]?.headers).toMatchObject({Authorization: "Bearer rotated-account-access",});+ expect(fetch.mock.calls[3]?.[1]).toMatchObject({+ method: "POST",+ body: "{}",+ });});it("maps server errors without leaking malformed responses", async () => {diff --git a/packages/auth-client/src/client.ts b/packages/auth-client/src/client.tsindex f11794c803..32aaa64432 100644--- a/packages/auth-client/src/client.ts+++ b/packages/auth-client/src/client.ts@@ -336,7 +336,7 @@ export class CindyAuthClient {await this.request("/api/auth/account/logout",z.object({ status: z.literal("ok") }),- undefined,+ {},{ token: accountToken },);}