@permitplane/client
v0.1.0
Published
PermitPlane licensing client for Electron, React Native and Node: offline grant verification, DPoP device proofs, licence key activation.
Maintainers
Readme
@permitplane/client (TypeScript SDK, phase 1)
PermitPlane licensing client for Electron, React Native and Node. Zero runtime dependencies. It does offline RS256 grant verification, ES256 DPoP proofs, licence key activation, hosted approval, vendor-owned enrollment, refresh and release, and passes the 66 shared PermitPlane conformance vectors.
Install
npm install @permitplane/clientLicensed under Apache-2.0. Homepage: https://permitplane.com
Supported runtimes
- Node 22 or newer
- Electron 28 or newer (run
LicenseClientin the main process; exposestatus,hasFeatureandgetLimitto the renderer throughcontextBridge) - React Native 0.79 or newer (Hermes)
The package is ESM only and uses an exports map (., ./protocol and ./testing). Metro honours
exports from React Native 0.79. A CommonJS Electron main process must use dynamic import()
unless its Node version supports require(esm) (Node 22.12 or newer).
Platform capabilities you inject
Everything platform specific sits behind an interface, so the same code runs everywhere:
| Interface | Purpose | Phase 1 implementation |
| --- | --- | --- |
| CryptoProvider | SHA-256, RS256/ES256 verify, random bytes | webCryptoProvider() (Node, Electron). React Native must inject one (phase 2). |
| KeyStore | Protected P-256 installation key, signs messages | MemoryKeyStore from /testing (tests only) |
| StateStore | Persists credentials and the clock anchor | MemoryStateStore from /testing (tests only) |
| PlatformClock | Boot id and suspend-inclusive monotonic time | processClock() from /testing (tests only: a random boot id per process, so each restart is treated as a reboot) |
| TimeSource | Synchronous wall and monotonic clocks | systemTimeSource |
| fetch | HTTP | globalThis.fetch |
keyStore, stateStore and clock are required so a production app can never silently fall
back to an in-memory key. Electron and React Native adapters are phase 2.
Production PlatformClock. processClock is for tests only. A production clock must report the operating system's real boot id (for example Linux /proc/sys/kernel/random/boot_id, Windows boot GUID) and a suspend-inclusive monotonic time, and set confident: false when it cannot. Never derive the boot id from Date.now() - os.uptime(): it changes with every clock change and defeats the reboot check.
The memory stores and processClock are exported from @permitplane/client/testing, not from the main entry point.
The persisted state holds a bearer installation_token and the signed grant. Implement StateStore on protected storage (Keychain, Android Keystore, Electron safeStorage), never a plain file, and never log it. LicenseClient keeps credentials out of its own properties, JSON.stringify and util.inspect.
Usage
import { LicenseClient } from '@permitplane/client';
const client = new LicenseClient({
config: { baseUrl, issuer, audience, vendorId, productId, environment: 'production', keys },
keyStore, stateStore, clock,
});
await client.initialize();
await client.activateWithKey('PP-7KQ4M-X9T2H-B6WRN-3FJ8D');
if (client.hasFeature('export')) { /* ... */ }hasFeature and getLimit are synchronous and never touch the network.
Threat model notes
- The clock anchor in the state store is not authenticated. Someone who can write the store can move the anchor, which can extend offline use only up to the signed grant
exp(at most 21 days after issue), and cannot extend rights past what the server signed. Protect the store so only the app can write it. - The installation private key must be non-exportable where the platform allows it. Possession is proven at
initialize()with a local DPoP proof. - API responses are capped at 1 MiB, the verification URI must be https, and the hosted poll interval is clamped to 5-300 seconds.
Behaviour notes
- A hosted approval that is denied or expired clears the pending request, as vendor enrollment does.
- Polling and redemption share one rate gate (minimum 5 seconds), so a failing redemption cannot be retried in a tight loop.
