release: WRNexusJS 0.4.0

This commit is contained in:
2026-07-27 12:42:18 +05:30
parent 8b728a3e5d
commit 30e5721e84
250 changed files with 10065 additions and 3923 deletions
@@ -7,6 +7,7 @@ import {
sha256,
hmacSign,
hmacVerify,
createKeyring,
} from "../src/index.ts";
test("sha256 is stable and hex-encoded", async () => {
@@ -56,3 +57,20 @@ test("deriveKey is deterministic for the same password+salt", async () => {
// usable as an encryption key
expect(await decrypt(await encrypt("x", k1), k1)).toBe("x");
});
test("keyrings reject duplicate keys and return defensive copies", () => {
expect(() =>
createKeyring([
{ id: "one", secret: "secret-one", active: true },
{ id: "one", secret: "secret-two" },
]),
).toThrow("DUPLICATE");
const keyring = createKeyring([
{ id: "one", secret: "secret-one", active: true },
{ id: "two", secret: "secret-two" },
]);
const active = keyring.active();
active.secret = "changed";
expect(keyring.active().secret).toBe("secret-one");
});