Guide
Step 3 — verify offline
The reference library is @leverine/licence-verify. It verifies ML-DSA-65 tokens against the deployment’s public keys — fetched from GET /v1/keys, cached, with a pinned fallback set in the app build — and derives state on every call:
import { verifyLicence } from "@leverine/licence-verify";
const result = verifyLicence(token, {
keys, // from GET /v1/keys (cache it; pin a fallback set)
product: "pvez-v2", // the product this app is
lastSeenAt, // the value the previous call returned (persist it)
});
persist(result.lastSeenAt);
switch (result.state) {
case "licensed": /* full function */ break;
case "grace": /* full function, warn: renewal overdue */ break;
case "read-only": /* data stays readable/exportable, writes off */ break;
case "unlicensed":/* no valid token (see result.failure) */ break;
}
result.failure explains an unlicensed verdict: malformed, wrong_alg, unknown_kid, bad_signature, wrong_product — or revoked, which only a refresh can learn (below). result.claims carries the verified token claims (tier, cap, feats, exp, …) when the signature verified and the product matched.
The clock-rollback guard: pass back the lastSeenAt each result returns. Effective time is max(now, lastSeenAt) — it never goes backwards, so winding the system clock cannot extend a licence. result.clockRollback tells you when a rollback was detected.
The library’s behaviour is pinned by conformance vectors exercised against the issuer — valid, grace, read-only, forged, tampered, wrong-product, unknown-kid, wrong-alg, and clock-rollback cases — so a port to another language has an exact target to match.