feat: release authentication laboratories 0.3.0
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
authenticationExtensions,
|
||||
extensionOutputToJson,
|
||||
registrationExtensions,
|
||||
} from "../../src/webauthn/extensions";
|
||||
|
||||
describe("WebAuthn extension inputs", () => {
|
||||
it("builds registration inputs without silently changing binary values", () => {
|
||||
const result = registrationExtensions({
|
||||
credProps: true,
|
||||
appidExclude: "https://legacy.example.test/app-id.json",
|
||||
prf: { enabled: true, first: "base64url:AQID", second: "label" },
|
||||
largeBlob: { registrationSupport: "required" },
|
||||
}) as AuthenticationExtensionsClientInputs & { appidExclude: string };
|
||||
expect(result.credProps).toBe(true);
|
||||
expect(result.appidExclude).toBe("https://legacy.example.test/app-id.json");
|
||||
expect(new Uint8Array(result.prf!.eval!.first as ArrayBuffer)).toEqual(
|
||||
Uint8Array.of(1, 2, 3),
|
||||
);
|
||||
expect(result.largeBlob).toEqual({ support: "required" });
|
||||
});
|
||||
|
||||
it("rejects invalid AppID and conflicting largeBlob operations", () => {
|
||||
expect(() =>
|
||||
registrationExtensions({ appidExclude: "http://unsafe" }),
|
||||
).toThrow(/HTTPS/u);
|
||||
expect(() =>
|
||||
authenticationExtensions({
|
||||
largeBlob: { read: true, write: "payload" },
|
||||
}),
|
||||
).toThrow(/cannot be requested together/u);
|
||||
});
|
||||
|
||||
it("serializes extension buffers for inspection", () => {
|
||||
expect(extensionOutputToJson({ result: Uint8Array.of(1, 2, 3) })).toEqual({
|
||||
result: { base64url: "AQID", bytes: 3 },
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user