- Added native Deno WebCrypto Ed25519 signature verification middleware for headless edge workloads. - Integrated dual authentication path to `/api/forward-auth` processing signatures and session cookies. - Added dual storage Admin Management routes (`/api/admin/hwk`) securely inserting directly to PostgreSQL and pushing to $O(1)$ Valkey verification set. - Completed all quality gates checks and hermetic mocked tests successfully. Co-authored-by: mrteye <1945243+mrteye@users.noreply.github.com>
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { assertEquals, assertRejects } from "jsr:@std/assert@1";
|
|
import {
|
|
computeJwkThumbprint,
|
|
verifyHttpSignature,
|
|
} from "./http_signatures.ts";
|
|
|
|
Deno.test("computeJwkThumbprint generates correct RFC 7638 thumbprint", async () => {
|
|
const jwk = {
|
|
kty: "OKP",
|
|
crv: "Ed25519",
|
|
x: "11qYAYKxCrfVS_7TyWQHOg7hcvPapiMlrwIaaPcHURo",
|
|
};
|
|
const fingerprint = await computeJwkThumbprint(jwk);
|
|
// Hash of {"crv":"Ed25519","kty":"OKP","x":"11qYAYKxCrfVS_7TyWQHOg7hcvPapiMlrwIaaPcHURo"}
|
|
assertEquals(fingerprint.length, 64);
|
|
assertEquals(typeof fingerprint, "string");
|
|
assertEquals(
|
|
fingerprint,
|
|
"90facafea9b1556698540f70c0117a22ea37bd5cf3ed3c47093c1707282b4b89",
|
|
);
|
|
});
|
|
|
|
Deno.test("verifyHttpSignature mock test - invalid headers", async () => {
|
|
const req = new Request("http://localhost/api/test");
|
|
await assertRejects(
|
|
() => verifyHttpSignature(req),
|
|
Error,
|
|
"Missing HTTP Message Signature headers",
|
|
);
|
|
});
|
|
|
|
Deno.test("verifyHttpSignature mock test - bad Signature-Input format", async () => {
|
|
const req = new Request("http://localhost/api/test", {
|
|
headers: {
|
|
"Signature-Input": "bad format",
|
|
"Signature": "sig1=:base64:",
|
|
},
|
|
});
|
|
await assertRejects(
|
|
() => verifyHttpSignature(req),
|
|
Error,
|
|
"Invalid Signature-Input format",
|
|
);
|
|
});
|