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
+15 -1
View File
@@ -1,6 +1,6 @@
import { test, expect } from "bun:test";
import { createContext } from "@wrnexus/core";
import { signJwt, verifyJwt, jwtAuth, JwtError } from "../src/index.ts";
import { createJwtKeyring, signJwt, verifyJwt, jwtAuth, JwtError } from "../src/index.ts";
const SECRET = "test-secret-key";
@@ -63,3 +63,17 @@ test("jwtAuth optional mode passes through anonymously", async () => {
expect(res.status).toBe(200);
expect(ctx.user).toBeUndefined();
});
test("JWT keyrings reject duplicates and return defensive copies", () => {
expect(() =>
createJwtKeyring([
{ id: "one", secret: "secret-one" },
{ id: "one", secret: "secret-two" },
]),
).toThrow("DUPLICATE");
const keyring = createJwtKeyring([{ id: "one", secret: "secret-one", active: true }]);
const key = keyring.active();
key.secret = "changed";
expect(keyring.active().secret).toBe("secret-one");
});