@sweberdev/integral
v2.0.0
Published
Signed offline license keys, plans and feature entitlements, and Polar.sh license key validation. Zero dependencies, runs in Node, browsers and edge runtimes.
Maintainers
Readme
Integral
Licenses, plans and feature entitlements for developers who sell software. Signed offline license keys (Ed25519 and ECDSA P-256), plans with features and limits, Polar.sh license key validation and React feature gates. Zero dependencies; runs in Node 22+, browsers, Bun, Deno and edge runtimes.
| Package | What it does |
|---|---|
| @sweberdev/integral | Sign and verify licenses, plans and entitlements, Polar license keys, offline grace, revocation lists, device binding, CLI |
| @sweberdev/integral-react | IntegralProvider, <Feature>, <Limit>, useFeature, useLicenseCheck |
npm i @sweberdev/integral
npx integral keygen
npx integral issue --product my-app --plan pro --email [email protected]import { createEntitlements, definePlans, verifyLicense } from "@sweberdev/integral";
const plans = definePlans({
free: { features: ["editor"], limits: { projects: 1 } },
pro: { extends: "free", features: ["export"], limits: { projects: 50 } },
});
const result = await verifyLicense(license, { publicKey: INTEGRAL_PUBLIC_KEY, product: "my-app" });
const entitlements = createEntitlements({ plans, license: result.valid ? result.license : null });
entitlements.has("export");
entitlements.check("projects", projects.length).allowed;Polar license keys
import { createPolarClient } from "@sweberdev/integral/polar";
const polar = createPolarClient({ organizationId: POLAR_ORG_ID });
const result = await polar.validate(key); // no access token neededLicenses that end updates, not usage
await signLicense({ product: "my-app", plan: "pro", updatesUntil: "2027-10-05" }, privateKey);
coversRelease(license, BUILD_DATE); // false for versions released after the update periodRevocation lists, device binding and trials
const list = await verifyRevocationList(downloaded, { publicKey }); // signed, works offline
await verifyLicense(key, { publicKey, revocations: list, machine: await machineId(hostId) });
licenseStatus(license); // { state: "expiring", trial: true, daysLeft: 6, ... }Device activation, also offline
const result = await bindLicense(license, machine, privateKey); // copy bound to one device
const request = createActivationRequest({ license, machine }); // as a file, for offline PCsDocumentation and live demo: packages.sweber.dev/integral
Integral Pro adds a license server that turns Polar orders and subscriptions into signed licenses, and a React activation view: packages.sweber.dev/integral/docs/pro/overview.
Integral is not copy protection: anyone who can change your app can remove a check. It makes honest use easy.
MIT © Seya Weber
