Leverine · Licensing · Documentation

Worked example: a PVEZ-v2 licence, end to end

Leverine Licensing in action — one purchase, one licence, one app, followed through its whole life: issued, activated, refreshed, capped, graced, and revoked. Every ID and timestamp below is real, from a run on 2026-12-04. Nothing here is a mock-up.

Product: PVEZ-v2 · Shop Mode: dark — enforces nothing Run: 2026-12-04

The run

What this run was (and was not)

PVEZ-v2 — the shop-management app Leverine built for PowerDesk dealers — is the first product integrating Leverine Licensing. The integration follows the plan in its repo (docs/LICENSING-INTEGRATION-PLAN.md): dark mode first. The app resolves its licence against the licensing service, verifies every token offline, and logs what the licence state would do — and enforces nothing yet. Enforcement arrives in a later rollout step, after observe mode on a real deployment.

The run had two legs:

  • Leg A pointed the real PVEZ-v2 demo deployment at the real, deployed licensing dev Worker, using a published throwaway test licence. Result below — including the one thing that didn’t work, and why.
  • Leg B ran the identical licensing Worker code (v0.4.3) locally with a throwaway signing key, and drove the full money path through it: a Paddle purchase webhook in, a licence out, and the app living on that licence.

One honest limitation: a Paddle sandbox checkout is completed with a test card in Paddle’s hosted checkout, which is a browser step. That step was proven end-to-end on 2026-12-03 against this same webhook receiver (sandbox checkout → webhooks delivered → licence issued), so this run did not repeat the card entry. Instead, Leg B delivered the purchase to the local Worker as a signed transaction.completed webhook in Paddle’s documented payload shape, carrying the real sandbox catalogue price ID — the same bytes the receiver verifies in production, checked against a local destination secret. Everything downstream of the webhook is the production code path, unmodified.

No live account, live money, or production data was touched. The production licensing service was not involved.

The cast

Who’s who

BuyerA PowerDesk dealer buying PVEZ-v2 Shop, monthly
PaddleMerchant of record; sells the subscription, sends webhooks (sandbox)
Licensing WorkerLeverine Licensing v0.4.3 — issues licences, signs tokens (ML-DSA-65)
PVEZ-v2The app; holds a licence file (the key), derives its state
Licence keyLVN-… — the buyer’s credential; shown once at delivery, re-derivable by the operator from the licence ID, never stored in a database

Step 0

The catalogue already knows the product

The Paddle sandbox catalogue carries the PVEZ-v2 plans (created 2026-12-03), and the licensing service maps Paddle price IDs to (product, tier) pairs. This run used:

  • Product: PVEZ-v2 Shop (pro_01m8yj4pxdnf0jzmjf7f2ykba2 in the sandbox catalogue)
  • Price: monthly, pri_01m8yj7p9xrrnmyxqg6jrvw3at
  • Plan terms on the issuer: Shop = 3 deployments max, features [core, terminal], 30-day tokens

Step 1

The buyer buys; Paddle tells the Worker; a licence exists

At 2026-12-04T06:36:20Z the Worker received:

POST /v1/webhooks/paddle
Paddle-Signature: ts=…;h1=…        (HMAC-SHA256 over "ts:rawBody")

{
  "event_id": "evt_01p69qex582t2tdmfq7a178q8d",
  "event_type": "transaction.completed",
  "occurred_at": "2026-12-04T06:36:20.000Z",
  "data": {
    "id": "txn_0170c7qwtkx2455jspaqayckga",
    "status": "completed",
    "customer_id": "ctm_016n7eb1fz3cs1pjgcb6sggfbf",
    "subscription_id": "sub_01aqgvvs5ajw1jh10grp0hc4k3",
    "currency_code": "USD",
    "items": [{ "price": { "id": "pri_01m8yj7p9xrrnmyxqg6jrvw3at" }, "quantity": 1 }]
  }
}

The signature verified, the price mapped to exactly one (product, tier), and no licence existed yet for that subscription, so the Worker issued one and answered:

{ "received": true, "outcome": "licence_issued" }

The licence, as the operator sees it:

Licence ID4f10c147-1e76-470d-9470-4d81b3920af3
Product / tierpvez-v2 / shop
Kindpaid
Stateactive
Key lookupN0WA (the key’s last group — the only part stored)
Deployment cap3
Issued2026-12-04T06:36:37Z
Expires2027-01-04T06:36:37Z — one calendar month, because the price bought is monthly
Grace until2027-01-11T06:36:37Z (expiry + 7 days)
Paddlecustomer ctm_016n7eb1fz3cs1pjgcb6sggfbf · subscription sub_01aqgvvs5ajw1jh10grp0hc4k3 · order txn_0170c7qwtkx2455jspaqayckga

Note the term: monthly prices issue one-month licences, annual prices one-year. That distinction is the billing-period support that landed in licensing v0.4.3.

Step 2

The buyer gets a key (and the key is never stored)

The licence key for this licence is:

LVN-7XM7R-EFACG-59J9T-1N0WA

(Printed here because this licence belongs to a throwaway local deployment whose signing key and pepper were destroyed after the run. A real customer’s key is never published.)

The key is not stored anywhere — not in the database (only its HMAC lookup hash and the last group, N0WA), not in a file on the server. It is derived: HMAC-SHA256(pepper, licence ID), formatted with a CRC check group. The operator re-derived it from the licence ID at 06:36Z for this run, and the lookup group matched the licence record. That is what makes delivery flexible: the licence can be delivered by webhook to the vendor’s own system, or re-issued to a buyer who proves a purchase, without anyone keeping a key database to steal.

The buyer installs it as a licence file on their deployment — a small JSON file, mode 600, outside the web root:

{
  "key": "LVN-7XM7R-EFACG-59J9T-1N0WA",
  "summary": { "product": "pvez-v2", "tier": "shop", "licenceId": "4f10c147-…" }
}

Step 3

The app asks: activation, and a state it derives itself

The demo deployment restarted at 2026-12-04T06:36:56Z with licensing switched to dark mode (LICENCE_MODE=dark). On boot, the licence module:

  1. Read the licence file.
  2. Generated (once) and persisted its deployment ID: 7afee694-0091-424f-aa23-335fb57550b5 — a random UUID, not a hardware fingerprint.
  3. Called POST /v1/activate with the key and deployment ID. The issuer bound the deployment and returned a signed token.
  4. Called POST /v1/refresh and POST /v1/status for the issuer’s current word.
  5. Verified the token offline — ML-DSA-65 signature against the issuer’s published keys (GET /v1/keys, with a pinned copy in the app as fallback) — and merged the result conservatively: the derived state is the more restrictive of what the token proves and what the server says.

The app’s public status endpoint then read:

{ "mode": "dark", "state": "licensed", "tier": "shop",
  "licenceExpiresAt": "2027-01-04T06:36:37.000Z",
  "graceUntil": "2027-01-11T06:36:37.000Z" }

— and the web app’s footer, which renders from exactly that payload, shows SHOP · DARK instead of its unlicensed marker. The admin licence panel showed the full resolution: state licensed, server state active, features [core, terminal], cap 3, 1 active deployment, and the dark-mode audit line:

would: enforce mode would: allow all writes; feature ceiling = licence feats; deployments capped at cap

The boot log carried the same record:

[licence] mode=dark reason=boot state=licensed server=active | would: …

Step 4

Refresh is the heartbeat

POST /admin/licence/refresh (admin-only) forces a resolve at any time; the module also refreshes on its own schedule. A refresh authenticates with the licence key (never the token), returns a fresh token reflecting current state, and re-derives. If the issuer is unreachable, nothing happens: the cached token governs, and the state derives offline. Occasional connectivity is a condition of sale; permanent connectivity is not required.

Step 5

The deployment cap refuses, hard

Shop allows 3 deployments. With the demo deployment holding one slot, two probe activations succeeded:

POST /v1/activate { key, instanceId: "cap-probe-1" } → 200, deployment 9360a901-…
POST /v1/activate { key, instanceId: "cap-probe-2" } → 200, deployment ec78638f-…

The fourth did not:

POST /v1/activate { key, instanceId: "cap-probe-3" } → 409

{ "error": "device_cap_reached",
  "message": "the licence's deployment cap is reached; deactivate a deployment before activating a new one",
  "cap": 3, "activeDeployments": 3 }

No partial state, no soft warning: the cap is a hard refuse, decided in advance with the vendor. The probes were deactivated afterwards (POST /v1/deactivate), returning the licence to 1 active deployment.

Step 6

A payment fails: grace, not a guillotine

At 2026-12-04T06:37:29Z a signed transaction.past_due webhook for subscription sub_01aqgvvs5ajw1jh10grp0hc4k3 arrived. The Worker answered licence_marked_grace and set grace to seven days from the failure (graceUntil 2026-12-11T06:37:29.000Z).

The app’s next refresh (06:37:35Z) derived:

{ "mode": "dark", "state": "grace", "tier": "shop",
  "licenceExpiresAt": "2027-01-04T06:36:37.000Z",
  "graceUntil": "2026-12-11T06:37:29.000Z" }

Note what happened here: the app’s token was still cryptographically valid — but the server’s word (grace) is more restrictive, so the conservative merge reported grace. The footer would render SHOP · GRACE (DARK). A customer write during grace returned 201 Created: grace is full function, with a warning — read-only only begins when grace ends without payment.

Step 7

Revocation: the app believes the cryptography, not the hope

At 2026-12-04T06:37:44Z the operator revoked the licence (POST /v1/revoke, with a recorded reason). The app’s next refresh returned no token and a revoked server state, and the derived state became:

state: unlicensed · serverState: revoked · failure: revoked
would: enforce mode would: write guard ON; reason shown in the admin licence panel

And then the dark-mode proof: a customer write after revocation still returned 201 Created. The app knew the licence was revoked, logged exactly what enforcement would do — and blocked nothing, because this rollout step enforces nothing. That gap is deliberate and temporary; it is what observe mode (step 4 of the rollout) exists to close safely.

Step 8

The founding dealer: a comp, issued the same way

PowerDesk’s founding dealer (Matt) runs on a comped annual Pro licence — a decision recorded in the integration plan, not an afterthought. The tooling for it is the admin comp endpoint:

POST /v1/admin/comp
{ "productId": "pvez-v2", "tier": "pro", "licenceDays": 365,
  "customerRef": "powerdesk-founding-dealer-matt",
  "reason": "Founding dealer comp — plan decision 5 (2026-12-03)" }

Issued at 2026-12-04T06:37:50Z:

Licence ID290b60f8-eb3d-4381-8d71-3e9698564c0d
KeyLVN-ZFMVF-CGJHF-5ME25-CYKAS (lookup YKAS)
Tier / cappro / 5 deployments
Features[core, terminal, sync]
Expires2027-12-04T06:37:51Z (365 days)

Pointing the demo deployment at this licence file and restarting produced state: licensed, tier: pro — the footer state PRO · DARK. (The comp of record for Matt’s real deployment is issued by the operator against the deployed service at rollout step 4; this run proves the tooling and records the exact shape.)

Leg A

The same app against the deployed dev Worker

Before the local run, the demo deployment was pointed at the real deployed dev Worker with the licensing project’s published throwaway test licence (LVN-R3YME-…-2S5R4, lookup S5R4, Shop, cap 3, issued during licensing’s own L1 testing).

What worked: the deployment activated — deployment 7afee694-0091-424f-aa23-335fb57550b5 bound at ~06:33Z, the issuer reported the licence active with the right tier, cap and expiry, and the app recorded all of it. The deployment was deactivated afterwards, leaving the licence as it was found.

What did not: the derived state came out unlicensed, failure bad_signature — and the app was right to say so. The deployed dev Worker currently mints tokens labelled with the production key ID (2026-12-prod) while signing with the dev seed, so no token it issues can verify against the published key registry. The conservative merge did its one job: when the server says “active” but the cryptography says “no”, the app believes the cryptography. The fix is known (make the current key ID a per-deployment setting, so dev signs as dev) and is queued with the licensing service — it changes nothing about the design this example demonstrates, and the local leg above ran the same code with a correctly configured key.

Fixed since this run — 2026-12-04: the per-deployment key ID has landed. The dev Worker now mints under its own key ID (2026-12-dev), and replaying this leg’s activation against the deployed dev Worker derives licensed. Production was unchanged by the fix.

What remains

What was dark-mode-only, and what remains

Dark mode (this run) means: the app resolves, verifies, derives, persists, displays, and logs — and enforces nothing. No write guard, no feature ceiling, no seat refusal was applied by the app at any point, including after revocation. The cap refusal in step 5 happened at the issuer, which is already live behaviour.

Before enforce mode, the rollout still owes:

  1. Observe mode on the founding dealer’s real deployment — the same resolution records, compared against reality over time (rollout step 4).
  2. The production money-path proof — a real purchase through the live catalogue into the production service (step 5), which is also where the dev Worker’s key-ID fix lands.
  3. Enforcement itself (step 6): the write guard (reads, sign-in, licence screens and data export always stay open), the feature ceiling, and the admin licence panel as the reason-giving surface — each switched on per deployment, with dark mode’s logs as the rehearsal record.

Prefer the reference form? The integration guide covers this same flow as a how-to, and the API reference documents every endpoint used above.

Run and documented 2026-12-04. Environments: PVEZ-v2 demo deployment (imac2), Leverine Licensing v0.4.3 local instance + deployed dev Worker. Sandbox catalogue IDs are Paddle sandbox IDs; local-run IDs were generated in Paddle’s formats for a local deployment whose keys were destroyed after the run.