Skip to main content

@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.
State machine (decided 2026-12-03): a token is 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 a POST /v1/refresh body 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. A revoked response derives unlicensed with failure revoked, even if the token in hand is unexpired. A response claiming active with no token derives unlicensed / malformed: a claim without a token proves nothing.
  • parseActivateResponse(status, body) classifies a POST /v1/activate outcome. device_cap_reached is a first-class cap_reached result 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.