> ## Documentation Index
> Fetch the complete documentation index at: https://docs.leverine.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Leverine Licensing

> Leverine Licensing — licence keys, activation, and verification for Leverine products, signed with ML-DSA.

# Leverine Licensing

A hosted licensing service for indie developers: licence keys, activation and device binding, signed offline licences, and admin issue/revoke — sold as a small, focused service for solo and small-team makers of desktop apps, plugins, extensions, and downloadable tools.

**Status: building — L0 (foundations) + L1 (issuance core) + L2 (Paddle webhook receiver, code side) + L3 (lifecycle API + operator tooling) + L4 prep (hardening groundwork: observability, rate limiting, ceremony runbook rehearsed) complete 2026-12-03. L4 itself completes at the production go-live — the key ceremony and the real-money acceptance purchase, both Kev’s gates.** The plan of record is [docs/PLAN.md](https://docs.leverine.com/licensing/plan.md): Part 1 builds the engine in phases L0–L4; Part 2 gives it predictable, modular hooks (a versioned integration contract, a reference client library, per-product registration) so future apps plug in the way the first one does. First consumer is PVEZ-v2 (PowerDesk); Hoistmark follows if its validation gate passes (its licensing deployment may be built first — it does not count toward the kill gate below). The dev deployment is live at [https://leverine-licensing-dev.leverine.workers.dev](https://leverine-licensing-dev.leverine.workers.dev) (`GET /health`); it serves the public signing keys at `/v1/keys` and operator-only issuance, proven end to end in the L1 journal. The Paddle webhook receiver (`POST /v1/webhooks/paddle`) is deployed and fails closed until the Paddle account’s endpoint secret is set — see the L2 journal. The lifecycle API (`/v1/activate`, `/v1/deactivate`, `/v1/refresh`, `/v1/status`, key-authenticated, hard-refuse activation cap) and the operator tooling (comp, revoke, licence inspection, forced state) are live on dev — see the L3 journal.

## Layout

* `src/` — the Worker: `index.ts` router, `env.ts` bindings, `routes/` (one module per route).
* `migrations/` — numbered D1 migrations, applied by wrangler.
* `test/` — vitest + Miniflare against the real built bundle.
* `packages/` — `licence-verify`, the standalone client verification library (Part 2’s reference client); conformance vectors in `test/`.
* `docs/` — the plan of record, the Ferret audit, and per-phase journals.

## Approach

The service is a **port, not a rewrite**. The Ferret-era licensing core was audited end to end on 2026-11-27 (verdict: **ADAPT**) — roughly 700 dedicated lines of tested TypeScript implementing signed licence tokens, HMAC-derived keys, device binding, revocation, and Paddle fulfilment, with its unit and smoke suites carried over as the regression net. The port parameterises the Ferret-specific constants (issuer, key prefix, plan set, brand), leaves the second product fused into the donor (Leverine Cloud) and its master-key backdoor behind, and builds the missing pieces fresh. One deliberate swap: the donor’s Ed25519 token signing is replaced by **ML-DSA** (FIPS 204, ML-DSA-65, via @noble/post-quantum) — decided 2026-12-03, recorded in docs/PLAN.md.

* **Stack:** TypeScript on Cloudflare Workers + D1.
* **Shape:** one deployment per customer for V1 — each vendor gets their own Worker, D1 database, secrets, and issuer. No tenancy layer in the engine.
* **Issuer:** `licence.leverine.com` · **Key prefix:** `LVN-`

## Settled decisions (2026-11-27)

* **No master key.** The donor’s MASTER\_KEY is removed; its legitimate uses (operator testing, support reproduction) are served by admin-issued, short-TTL trial licences — real rows: visible, revocable, capped.
* **Per-customer deployments** for V1 (see above); a tenancy layer is only revisited if deployment count, not features, becomes the bottleneck.
* **Paddle-only billing** — Paddle is the merchant of record, for customer checkouts and for this service’s own tiers.
* **Tiers:** Free ≤ 100 active licences · Indie \$19/mo · Studio \$49/mo · Publisher \$99/mo.
* **Kill gate:** 10 paying customers within 90 days of beta, or the service stops.
* Contract upgrades that land **before** the first external customer bakes in a key: `kid` + dual-key verification (signing-key rotation without a flag day), `ent`/`feats` grant minting, a real trial licence type, per-plan device-cap policy and token TTL, versioned schema migrations, and secrets hygiene (no key material in logs or in the repo tree — ever).

## Documents

* [Plan of record](https://docs.leverine.com/licensing/plan.md) — the two-part goal, phases L0–L4, the Part 2 integration hooks, the sequence, and both locked decision sets.
* [L0 journal](https://github.com/Leverine/Leverine-Licensing/blob/7ac3cc9b01e22b73b5c4be8ce1976c11c6391dd1/docs/journal-l0.md) — how the foundations were built, including the failures.
* [L1 journal](https://github.com/Leverine/Leverine-Licensing/blob/7ac3cc9b01e22b73b5c4be8ce1976c11c6391dd1/docs/journal-l1.md) — the ML-DSA issuance core: key handling, the donor bug it caught, and the live end-to-end proof.
* [L2 journal](https://github.com/Leverine/Leverine-Licensing/blob/7ac3cc9b01e22b73b5c4be8ce1976c11c6391dd1/docs/journal-l2.md) — the Paddle webhook receiver: signature verification, idempotent events, price mapping, and the grace/cancel semantics that L3 refresh will enforce.
* [L3 journal](https://github.com/Leverine/Leverine-Licensing/blob/7ac3cc9b01e22b73b5c4be8ce1976c11c6391dd1/docs/journal-l3.md) — the lifecycle API and operator tooling: key-authenticated activation with the hard-refuse cap, refresh semantics over the L2 flags, renewal reconciliation, and the client library’s conservative state merge.
* [L4 prep journal](https://github.com/Leverine/Leverine-Licensing/blob/7ac3cc9b01e22b73b5c4be8ce1976c11c6391dd1/docs/journal-l4-prep.md) — the hardening groundwork: Workers Logs + structured errors, the uptime probe, rate limiting, the ops inventory, and the L4 readiness report.
* [Key ceremony runbook](https://github.com/Leverine/Leverine-Licensing/blob/7ac3cc9b01e22b73b5c4be8ce1976c11c6391dd1/docs/runbook-key-ceremony.md) — production ML-DSA-65 key generation, backup, rotation, and compromise procedure; rehearsed by scripts/rehearse-key-ceremony.mjs.
* [Ops inventory](https://github.com/Leverine/Leverine-Licensing/blob/7ac3cc9b01e22b73b5c4be8ce1976c11c6391dd1/docs/ops-inventory.md) — secrets by name, rotation procedures, D1 backup/restore, and the licence.leverine.com go-live checklist.
* [Licensing service plan](https://github.com/Leverine/Leverine-Licensing/blob/7ac3cc9b01e22b73b5c4be8ce1976c11c6391dd1/docs/leverine-licensing-service-plan.pdf) — the monetization plan: market, product shape, pricing, the gated build phases.
* [Plan outline](https://github.com/Leverine/Leverine-Licensing/blob/7ac3cc9b01e22b73b5c4be8ce1976c11c6391dd1/docs/plan-outline.md) — the plan’s section-by-section outline and sources.
* [Ferret audit](https://github.com/Leverine/Leverine-Licensing/blob/7ac3cc9b01e22b73b5c4be8ce1976c11c6391dd1/docs/ferret-audit-2026-11-27.md) — the full audit of the donor system: deployment truth, the porting blueprint, key-material risk assessment, and the decisions it fed.

## Notes

* This repo is private and the service is not a public offer yet — per the plan, it is not listed publicly as a product until the beta gate passes.
* No LVN- licensing exists in the File Handler mobile app (store policy); LVN- keys are for this service’s customers and the post-launch desktop/web tier.

***

*Source: Leverine/Leverine-Licensing\@7ac3cc9 — `README.md`.*


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.