release: WRNexusJS 0.5.0
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { publicKeyCreationOptions, publicKeyRequestOptions } from "../src/passkeys/index.ts";
|
||||
|
||||
test("passkey option conversion accepts canonical Base64URL values", () => {
|
||||
const creation = publicKeyCreationOptions({
|
||||
challenge: "AQID",
|
||||
rp: { id: "example.test", name: "Example" },
|
||||
user: { id: "BAUG", name: "user", displayName: "User" },
|
||||
timeout: 60_000,
|
||||
attestation: "none",
|
||||
});
|
||||
expect(Array.from(creation.challenge as Uint8Array)).toEqual([1, 2, 3]);
|
||||
|
||||
const request = publicKeyRequestOptions({
|
||||
challenge: "BAUG",
|
||||
rpId: "example.test",
|
||||
timeout: 60_000,
|
||||
userVerification: "preferred",
|
||||
});
|
||||
expect(Array.from(request.challenge as Uint8Array)).toEqual([4, 5, 6]);
|
||||
});
|
||||
|
||||
test("passkey option conversion rejects malformed Base64URL values", () => {
|
||||
expect(() =>
|
||||
publicKeyRequestOptions({
|
||||
challenge: "AQID=",
|
||||
rpId: "example.test",
|
||||
timeout: 60_000,
|
||||
userVerification: "required",
|
||||
}),
|
||||
).toThrow("canonical Base64URL");
|
||||
});
|
||||
Reference in New Issue
Block a user