@leverine/licence-verify
The reference validation library for Leverine Licensing (docs/PLAN.md, Part 2). Apps import it to verify licence tokens offline and derive licence state — there is no stored “licensed” flag anywhere; state is a function of the token’s ML-DSA-65 signature, its claims, and the clock.licensed until its exp, then grace for 7 days, then read-only — never dead. Structural failures (bad signature, wrong product, unknown kid, wrong alg, malformed) are unlicensed with a failure reason.
The clock-rollback guard: pass back the lastSeenAt each result returns. Effective time never goes backwards, so winding the system clock cannot extend a licence.
Conformance: the vectors in the repo’s test/conformance.test.ts exercise this library against the issuer — valid, grace, read-only, forged, tampered, wrong-product, unknown-kid, wrong-alg, and clock-rollback cases all pinned.
Lifecycle responses (0.2.0)
When the app can reach the issuer, two more helpers consume the lifecycle API (docs/PLAN.md, L3):applyRefreshResponse(resp, opts)folds aPOST /v1/refreshbody into a state. It merges CONSERVATIVELY — the effective state is the more restrictive of the state derived from the returned token and the state the server reported — because each side knows something the other doesn’t: the token knows the term, the server knows revocations and Paddle payment state. Arevokedresponse derivesunlicensedwith failurerevoked, even if the token in hand is unexpired. A response claimingactivewith no token derivesunlicensed/malformed: a claim without a token proves nothing.parseActivateResponse(status, body)classifies aPOST /v1/activateoutcome.device_cap_reachedis a first-classcap_reachedresult carrying the cap and the live count, so the app can explain the hard refusal and offer deactivation — never a silent displacement.
Source: Leverine/Leverine-Licensing@7ac3cc9 —
packages/licence-verify/README.md.