release: WRNexusJS 0.5.0

This commit is contained in:
2026-07-29 12:51:10 +05:30
parent 76c768099d
commit 6afe32f63f
456 changed files with 40879 additions and 8850 deletions
+17
View File
@@ -0,0 +1,17 @@
import { expect, test } from "bun:test";
import { base64UrlToBytes, bytesToBase64Url, randomDigits, randomToken } from "../src/crypto.ts";
test("base64url helpers round-trip canonical values and reject malformed input", () => {
const bytes = new Uint8Array([0, 1, 2, 253, 254, 255]);
const encoded = bytesToBase64Url(bytes);
expect(base64UrlToBytes(encoded)).toEqual(bytes);
expect(() => base64UrlToBytes("a===")).toThrow("Invalid base64url value");
expect(() => base64UrlToBytes("a")).toThrow("Invalid base64url value");
});
test("random helpers reject broken random providers instead of looping forever", () => {
expect(() => randomToken(() => new Uint8Array(1), 32)).toThrow("exactly 32 bytes");
expect(() => randomDigits((length) => new Uint8Array(length).fill(255), 6)).toThrow(
"WRN-AUTH-RANDOM-SOURCE-REJECTED",
);
});