Install
View on GitHub
Terminal window
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).
Install
Section titled “Install”npm install @keylight-dev/jsInitialise
Section titled “Initialise”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();Activate and gate features
Section titled “Activate and gate features”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({ … })).
- Try the live demo — activate a real license key in your browser and watch entitlements flip.
- Offline verification — verify a signed lease with no network round-trip.
@keylight-dev/json npm · GitHub