Initial Commit

This commit is contained in:
2026-05-27 23:47:53 +01:00
parent fbc70f96e6
commit 9b28db724f
18103 changed files with 1600554 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
/**
* DTP-05 step 2 — TEMPLATE_EXPIRED rejection.
*/
import { describe, expect, it } from "@suaveplan/testing/runner";
import {
type DriveTemplateError,
DTP_CODES,
TemplateNonceLru,
validateTemplate,
} from "../src/index.js";
import { makeKeys, signed } from "./_helpers.js";
describe("DTP-05 step 2 — expired templates", () => {
it("template past expiresAt rejected with TEMPLATE_EXPIRED", {
timeout: 5000,
}, () => {
const keys = makeKeys();
const NOW = 2_000_000_000;
const tpl = signed(
{
issuer: keys.publicHex,
issuedAt: NOW - 1_000,
expiresAt: NOW - 1, // already expired
},
keys
);
const ctx = {
clock: () => NOW,
nonceLru: new TemplateNonceLru(),
};
try {
validateTemplate(tpl, ctx);
throw new Error("expected EXPIRED");
} catch (err) {
expect((err as DriveTemplateError).code).toBe(
DTP_CODES.TEMPLATE_EXPIRED
);
}
});
it("template at exactly expiresAt rejected (>=)", { timeout: 5000 }, () => {
const keys = makeKeys();
const NOW = 2_000_000_000;
const tpl = signed(
{
issuer: keys.publicHex,
issuedAt: NOW - 1_000,
expiresAt: NOW,
},
keys
);
const ctx = {
clock: () => NOW,
nonceLru: new TemplateNonceLru(),
};
try {
validateTemplate(tpl, ctx);
throw new Error("expected EXPIRED");
} catch (err) {
expect((err as DriveTemplateError).code).toBe(
DTP_CODES.TEMPLATE_EXPIRED
);
}
});
});