Skip to main content
Introducing packages.sweber.dev
Integral overview

IntegralLive demo.

Integral signs licenses with Ed25519 or ECDSA P-256 and checks them offline in your app. This page runs the same code as the npm package: it creates a key pair, issues licenses, verifies them and applies your plans.

Everything runs in this page. Keys and licenses never leave your browser.

Keys

One key pair per productThe private key signs, the public key only checks.

In a real project the private key stays on your server or in CI secrets. The public key ships with your app: it cannot create licenses, so it does not need to be secret.

Public key (ships with the app)

…

Private key (stays on the server)

…

Same with the CLI

npx integral keygen

Issue

Issue a licenseWhat a payment webhook or the CLI does.

Pick a plan and optional extras. The license is a signed string you can email, store in a file or paste into a text field.

Verify

Check it offlineChange anything and the signature breaks.

Edit the license, tamper with the plan or sign it with a stranger's key. Move the date to see expiry and update periods at work, revoke the license with a signed revocation list or check a device-bound license on another laptop.

Entitlements

What the app unlocksPlans, features and limits from one definition.

Without a valid license the app falls back to the free plan. With one, it applies the plan plus the extras signed into the license.

Current plan: Free

  • Editorincluded
  • Export to PDFin Pro
  • Cloud syncin Pro
  • Single sign-onin Team
  • Beta featuresnot in any plan

Projects

1 of 1

Limit of your plan reached.

plans.ts

import { definePlans } from "@sweberdev/integral"

export const plans = definePlans({
  free: {
    label: "Free",
    features: ["editor"],
    limits: { projects: 1 },
  },
  pro: {
    extends: "free",
    label: "Pro",
    features: ["export", "sync"],
    limits: { projects: 10 },
  },
  team: {
    extends: "pro",
    label: "Team",
    features: ["sso"],
    limits: { projects: null }, // unlimited
  },
})

Pro

Integral Pro: licenses from Polar, automaticallySimulated subscription, real signatures.

The license server of Integral Pro listens to Polar webhooks and keeps one license per subscription. Play through a subscription below. Each step re-signs the license the way the server does: renewals extend the update period, a cancellation keeps the installed version working, a refund revokes the license.

Devices

Activate a license on devicesA device limit per license, also offline.

The customer buys once and activates the license on their own devices. Each activation signs a copy of the license that only works on that device. Integral Pro counts the devices per license (here: two) and frees a place when a device is removed. Computers without internet send an activation request as a file instead.

Code

Three lines in your appOffline, no server, no dependencies.

import { createEntitlements, verifyLicense } from "@sweberdev/integral"

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")

Free 2.0

License format int2, P-256 keys and KMS signingIntegral, free.

Integral 2.0 adds the int2 license format with algorithm choice (Ed25519 or ECDSA P-256) and key ids, signer objects for KMS and HSM keys, and a migrate command for existing licenses. int1 licenses stay readable.

ECDSA P-256 keys and int2 licenses

Licenses now carry their algorithm in the header, so you can sign with Ed25519 or with ECDSA P-256, the curve KMS and HSM services support. Everything below runs offline.

Generate a P-256 key, issue, inspect and verify

npx integral keygen --alg es256
npx integral issue --product my-app --plan pro --feature beta \
  --limit projects=100 --email kunde@example.ch --kid kms-2027 \
  --updates-until 2027-10-05 > license.txt
npx integral inspect "$(cat license.txt)"
npx integral verify "$(cat license.txt)" --public-key "$INTEGRAL_PUBLIC_KEY" --product my-app

Real output (throwaway key)

{
  "product": "my-app",
  "plan": "pro",
  "features": [
    "beta"
  ],
  "limits": {
    "projects": 100
  },
  "customer": {
    "email": "kunde@example.ch"
  },
  "updatesUntil": "2027-10-05T00:00:00.000Z",
  "id": "lic_mcEXuvtW0Gcpc7kv",
  "kid": "kms-2027",
  "v": 2,
  "iat": "2026-10-13T16:02:28.241Z"
}
(signature not checked)
valid: my-app / pro (lic_mcEXuvtW0Gcpc7kv)

Convert old licenses with integral migrate

int1 licenses stay valid in 2.x, and one command re-signs a whole file of them as int2 with the same id, plan and dates, so revocation lists and renewals still match.

Migrate a file of int1 licenses

npx integral migrate --file licenses.txt --private-key-file integral-private.key > migrated.txt
npx integral inspect "$(cat migrated.txt)"
npx integral verify "$(cat migrated.txt)" --public-key "$(cat integral-public.key)"

Real output (licenses.txt held one int1 license, id lic_old1)

{
  "product": "my-app",
  "plan": "pro",
  "id": "lic_old1",
  "iat": "2026-10-13T16:02:36.885Z",
  "v": 2
}
(signature not checked)
valid: my-app / pro (lic_old1)

Key rotation with a key ring

Pass several public keys by key id and mix Ed25519 with P-256. Apps keep accepting old licenses while you issue new ones with the new key.

Verify against a mixed key ring

await verifyLicense(license, {
  publicKey: { "2026-a": ed25519Key, "2027-a": p256Key },
});

Real output (ES256 license from item 1, ring of one Ed25519 and one P-256 key)

{"valid":true,"plan":"pro","id":"lic_mcEXuvtW0Gcpc7kv"}

Sign with a KMS or HSM through a Signer

signLicense accepts a signer object instead of a private key string, so the key can stay inside your KMS. ecdsaDerToRaw converts the DER signatures that AWS KMS, Google KMS and similar services return.

Signer with a local P-256 key standing in for the KMS

import { signLicense, verifyLicense, ecdsaDerToRaw } from "@sweberdev/integral";
import { generateKeyPairSync, sign } from "node:crypto";

const { privateKey } = generateKeyPairSync("ec", { namedCurve: "P-256" });
const kmsSignSha256 = async (data) => sign("sha256", data, privateKey);

const signer = {
  alg: "ES256",
  kid: "kms-2027",
  sign: async (data) => ecdsaDerToRaw(await kmsSignSha256(data)),
};
const license = await signLicense({ product: "app", plan: "pro" }, signer);
// then: verifyLicense(license, { publicKey: "p256.<uncompressed point>" })

Real output (header alg and kid, then verification)

int2 ES256 kms-2027
valid: true

Outputs were captured from the published @sweberdev/integral 2.0.0 on Node 22 with throwaway keys. Ready-made KMS adapters belong to Integral Pro and are not covered here.

Read the docs

Pro 2.1.0

Let customers see their own licenseIntegral Pro.

Pro 2.1.0 adds a customer overview, so buyers of your app can see plan, usage, seats and devices without a support ticket. Stripe and Paddle purchases now also handle refunds and cancellations.

Customer overview from the server

One call returns plan, status, dates, features, limits, usage per period, seats in use and devices for a license key. The same data is served on POST /overview, and expired licenses are included so customers can see they need to renew.

server.overview()

const result = await server.overview(licenseKey, { periods: 2 });

if (result.ok) {
  console.log(result.license.plan, result.license.status);
  console.log(result.seatsInUse.active);
  console.log(result.usage[0].metrics);
}

Ready-made customer portal

Drop the React component into your account page. It shows the overview and includes the device list, so customers can manage their devices themselves.

React

import { CustomerPortal } from "@weber-development/integral-portal";

<CustomerPortal endpoint="/api/integral" periods={3} />

Stripe and Paddle refunds and cancellationsBeta

Next to Polar, you can take payments through Stripe or Paddle. A Stripe refund (charge.refunded) or an approved Paddle refund now revokes the license, and a Stripe subscription with cancel_at is treated as cancelled at the period end.

Payment sources

const handler = createLicenseHandler(server, {
  basePath: "/api/integral",
  sources: [
    stripeSource({ secret: process.env.STRIPE_WEBHOOK_SECRET!, apiKey: process.env.STRIPE_API_KEY }),
    paddleSource({ secret: process.env.PADDLE_WEBHOOK_SECRET!, apiKey: process.env.PADDLE_API_KEY }),
  ],
});
// webhooks: POST /api/integral/webhook/stripe and /webhook/paddle

The demo cannot show Stripe or Paddle: they need your own accounts and webhooks, and they are tested with documented payloads, not yet with real accounts.

Read the docs