mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 06:13:38 +00:00
* feat: add tests for guidToRawFormat * feat: add support for parsing b64 credential ids * refactor: change interface to use Uint8Array for simplification Technically this deviates from the specification, but nobody is going to be using the authenticator directly but us so it shouldn't matter. We're gonna switch to `passkey-rs` anyways so * feat: change how the authenticator parses credential ids to support b64
29 lines
877 B
TypeScript
29 lines
877 B
TypeScript
import { guidToRawFormat } from "./guid-utils";
|
|
|
|
describe("guid-utils", () => {
|
|
describe("guidToRawFormat", () => {
|
|
it.each([
|
|
[
|
|
"00000000-0000-0000-0000-000000000000",
|
|
[
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00,
|
|
],
|
|
"08d70b74-e9f5-4522-a425-e5dcd40107e7",
|
|
[
|
|
0x08, 0xd7, 0x0b, 0x74, 0xe9, 0xf5, 0x45, 0x22, 0xa4, 0x25, 0xe5, 0xdc, 0xd4, 0x01, 0x07,
|
|
0xe7,
|
|
],
|
|
],
|
|
])("returns UUID in binary format when given a valid UUID string", (input, expected) => {
|
|
const result = guidToRawFormat(input);
|
|
|
|
expect(result).toEqual(new Uint8Array(expected));
|
|
});
|
|
|
|
it("throws an error when given an invalid UUID string", () => {
|
|
expect(() => guidToRawFormat("invalid")).toThrow(TypeError);
|
|
});
|
|
});
|
|
});
|