1import { describe, expect, it } from "vite-plus/test";
2import * as Schema from "effect/Schema";
3
4import { ProviderAuthState } from "./providerSetup.ts";
5
6const decodeState = Schema.decodeUnknownSync(ProviderAuthState);
7
8describe("provider auth state", () => {
9 it("drops auth variants from newer servers instead of rejecting the state", () => {
10 const method = { id: "browser", name: "Browser", description: null, type: "agent" };
11 expect(
12 decodeState({
13 instanceId: "cursor",
14 phase: "waiting",
15 flowId: null,
16 authorizationUrl: null,
17 expiresAt: null,
18 message: null,
19 methods: [method, { ...method, id: "passkey", type: "passkey" }],
20 interaction: { type: "passkey", id: "passkey" },
21 credentialOwner: "keychain",
22 }),
23 ).toEqual({
24 instanceId: "cursor",
25 phase: "waiting",
26 flowId: null,
27 authorizationUrl: null,
28 expiresAt: null,
29 message: null,
30 methods: [method],
31 });
32 });
33});