Skip to content

Install

View on GitHub

The JavaScript SDK is one fully-typed package that runs the same way in the browser, Node, Deno, Bun, and edge/Workers. It does online activation and offline Ed25519 lease verification — and verifies licenses identically to the Swift and Rust SDKs (proven by cross-SDK conformance vectors).

Terminal window
npm install @keylight-dev/js

Fetch the tenant’s trusted keyset once so leases verify offline, then construct the client:

import { Keylight, fetchKeyset, FetchTransport } from "@keylight-dev/js";
const ks = await fetchKeyset(new FetchTransport(), "https://api.keylight.dev", "your-tenant");
const kl = new Keylight({
tenantId: "your-tenant",
productId: "your-product",
sdkKey: "<your SDK key>", // from your Keylight dashboard
appVersion: "1.0.0",
maxOfflineDays: 7, // optional offline grace window
trustedKeys: ks?.keys ?? {}, // enables offline lease verification
});
// Hydrate the cache that backs the synchronous reads. Call once at startup.
await kl.load();
const res = await kl.activate("USER-LICENSE-KEY");
if (!res.activated) console.error(res.error);
// Synchronous, from the cached (signature-verified) lease:
if (kl.hasEntitlement("pro")) {
// unlock pro features
}
// Release the seat when uninstalling / switching devices:
await kl.deactivate();

In a plain browser <script> tag, the IIFE bundle exposes the namespace as window.KeylightSDK (new KeylightSDK.Keylight({ … })).