leverine-licensing-client
The reusable client library for the Leverine licensing system (issuer:Leverine/Leverine-Licensing, live at licence.leverine.com). BunnyBridge is its first consumer (v0.5.0); it is not the owner — every Leverine app that needs licence unlocking uses this library instead of re-implementing token verification.
There are no user accounts in this system. The licence key is the handle; the issuer returns a signed token (ML-DSA-65, FIPS 204); the client verifies it offline and refreshes it when online.
Modules
The core’s only runtime dependency is BouncyCastle (
bcprov-jdk18on) — the JVM/Android platform has no ML-DSA verifier for raw external keys, and the issuer signs with ML-DSA-65. Interop with the issuer’s @noble/post-quantum signatures is pinned by golden-vector tests in licensing-core (tokens minted by the issuer’s own TypeScript code).
Semantics (identical to the issuer’s reference client)
- Token states:
licensed→grace(7 days past expiry, full function, refresh overdue) →read-only(evidence of a lapsed licence, grants nothing). Anything else isunlicensedwith a failure:malformed/wrong_alg/unknown_kid/bad_signature/wrong_product/revoked. - Expiry is judged against max(now, lastSeenAt): rolling the device clock back cannot extend a licence. Persist the
lastSeenAtthe verifier returns (LicenceManager does this for you). - Refresh merges conservatively: the more restrictive of (verified token state, server state) wins; a server
revokedwins over everything, including a still-valid token. - Activation is hard-refuse at the device cap:
CapReachedis a first-class outcome, never a silent displacement of another device.
Adding the library to an app
-
Declare your product in the Licensing repo’s catalogue (
docs/catalogue-<product>.mdthere): product id, tiers, feat strings, device cap. Feat names are yours — the library treats them as opaque strings. -
Consume the build. During development, as a composite build:
(Published coordinates
com.leverine:licensing-*are the plan once a Leverine maven repo exists; the composite build is the supported route today.) -
Create the manager once, at app start:
-
Gate features on the entitlement, with your own feat constants:
-
Render activation. Compose apps drop in
LicenceActivationSection(state, onActivate, onDeactivate). Other UIs renderLicencePresentation.describe(state, markerFeat)— headline, detail, which actions make sense — or build their own model onEntitlementState. -
Wire the lifecycle off the main thread:
licences.activate(key, label, appVersion),licences.refresh()(on launch / on reconnect),licences.deactivate(). All outcomes are sealed types; the cap refusal and revocation are values, not exceptions.
Rules for consumers
- Never log or persist a licence key anywhere but the library’s own encrypted store.
- The DIRECT_CHANNEL question is the host app’s own build decision; the library knows nothing about channels.
- If you change verification semantics, you change them here, for every app, with the golden vectors still green.
Source: Leverine/leverine-licensing-client@e078fc4 —
README.md.