feat(FN-3434): add Claude OAuth credential interop with verification and st
This merge lands four major features: the desktop app gains shell onboarding with remote mode support via a new `DesktopModeChooser` and `shell-settings` module (FN-3399); the dashboard gains full archived insights support with the `InsightsView` redesign and `useInsights` hook overhaul (FN-3315); C Fusion-Task-Id: FN-3434
This commit is contained in:
@@ -4,7 +4,9 @@ import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import {
|
||||
choosePreferredStoredCredential,
|
||||
extractClaudeCliStoredCredential,
|
||||
extractCodexCliStoredCredential,
|
||||
getClaudeCodeCredentialPaths,
|
||||
readStoredCredentialsFromAuthFile,
|
||||
shouldHydrateStoredCredential,
|
||||
} from "../oauth-credential-interop.js";
|
||||
@@ -86,6 +88,59 @@ describe("oauth credential interop", () => {
|
||||
expect(shouldHydrateStoredCredential({ type: "api_key", key: "sk-live" }, valid)).toBe(false);
|
||||
});
|
||||
|
||||
it("extracts Claude OAuth credentials from .credentials.json payload", () => {
|
||||
const credential = extractClaudeCliStoredCredential({
|
||||
claudeAiOauth: {
|
||||
accessToken: "claude-access",
|
||||
refreshToken: "claude-refresh",
|
||||
expiresAt: Date.now() + 3600_000,
|
||||
},
|
||||
});
|
||||
|
||||
expect(credential).toEqual({
|
||||
type: "oauth",
|
||||
access: "claude-access",
|
||||
refresh: "claude-refresh",
|
||||
expires: expect.any(Number),
|
||||
});
|
||||
});
|
||||
|
||||
it("reads Claude credentials from auth file as anthropic OAuth", () => {
|
||||
const tempDir = mkdtempSync(join(tmpdir(), "fusion-oauth-interop-"));
|
||||
|
||||
try {
|
||||
const authPath = join(tempDir, ".credentials.json");
|
||||
writeFileSync(
|
||||
authPath,
|
||||
JSON.stringify({
|
||||
claudeAiOauth: {
|
||||
accessToken: "claude-access",
|
||||
refreshToken: "claude-refresh",
|
||||
expiresAt: Date.now() + 3_600_000,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
expect(readStoredCredentialsFromAuthFile(authPath)).toEqual({
|
||||
anthropic: {
|
||||
type: "oauth",
|
||||
access: "claude-access",
|
||||
refresh: "claude-refresh",
|
||||
expires: expect.any(Number),
|
||||
},
|
||||
});
|
||||
} finally {
|
||||
rmSync(tempDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("returns both supported Claude credential paths", () => {
|
||||
expect(getClaudeCodeCredentialPaths("/tmp/home")).toEqual([
|
||||
"/tmp/home/.claude/.credentials.json",
|
||||
"/tmp/home/.config/claude/.credentials.json",
|
||||
]);
|
||||
});
|
||||
|
||||
it("gracefully ignores malformed auth files", () => {
|
||||
const tempDir = mkdtempSync(join(tmpdir(), "fusion-oauth-interop-"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user