feat: release OTP and Passkey Tools 0.1.0

This commit is contained in:
2026-08-19 12:19:35 +02:00
commit f1cb2d7151
67 changed files with 12802 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
import { describe, expect, it } from "vitest";
import {
base32ToBytes,
base64UrlToBytes,
bytesToBase32,
bytesToBase64Url,
bytesToHex,
hexToBytes,
utf8ToBytes,
} from "../../src/crypto/encoding";
describe("encoding", () => {
it("round-trips RFC 4648-style encodings", () => {
const bytes = utf8ToBytes("Hello!\u{1f512}");
expect([...base32ToBytes(bytesToBase32(bytes))]).toEqual([...bytes]);
expect([...base64UrlToBytes(bytesToBase64Url(bytes))]).toEqual([...bytes]);
expect([...hexToBytes(bytesToHex(bytes))]).toEqual([...bytes]);
});
it("rejects non-zero trailing Base32 bits", () => {
expect(() => base32ToBytes("AB")).toThrow(/trailing bits/iu);
});
it("accepts deliberate manual separators only when enabled", () => {
expect(() => base32ToBytes("JBSW Y3DP")).toThrow();
expect([...base32ToBytes("JBSW-Y3DP", { allowSeparators: true })]).toEqual([
...utf8ToBytes("Hello"),
]);
});
});