feat(auth): add browser cookie login fallback

This commit is contained in:
Ivan Pereira
2026-06-24 17:19:38 +01:00
parent 388235c602
commit d01cfc86bc
13 changed files with 716 additions and 45 deletions
+20
View File
@@ -120,6 +120,26 @@ describe("searchPerplexity", () => {
expect(body.params.is_incognito).toBe(false);
});
test("uses Cookie header for browser-cookie credentials", async () => {
let capturedInit: RequestInit | undefined;
globalThis.fetch = (async (_url: RequestInfo | URL, init?: RequestInit) => {
capturedInit = init;
return createSseResponse([
{ status: "COMPLETED", final: true, text: "answer", blocks: [] },
]);
}) as unknown as typeof fetch;
await searchPerplexity(
{ query: "q", model: "pplx_pro_upgraded", incognito: true },
{ type: "oauth", cookies: "__Secure-next-auth.session-token=session; cf_clearance=clearance" },
);
const headers = new Headers(capturedInit?.headers);
expect(headers.get("Cookie")).toBe("__Secure-next-auth.session-token=session; cf_clearance=clearance");
expect(headers.get("Authorization")).toBeNull();
});
test("passes incognito true through to request body", async () => {
let capturedInit: RequestInit | undefined;