@licenso/client
v1.2.0
Published
TypeScript client for verifying Licenso tokens (Ed25519).
Readme
@licenso/client
TypeScript client for verifying Licenso tokens (Ed25519).
Install
pnpm add @licenso/clientUsage
import { verifyLicense, base64urlDecode } from '@licenso/client';
const PUBLIC_KEY_B64URL = process.env.LICENSE_PUBLIC_KEY_B64URL!; // store in env
const publicKeyBytes = base64urlDecode(PUBLIC_KEY_B64URL);
const result = await verifyLicense(token, publicKeyBytes, /* optional */ expectedDeviceId);
if (!result.valid) throw new Error(`Invalid license: ${result.reason}`);
// Use the payload
const { cfg } = result.payload!;
console.log(cfg.deviceIdentifier, cfg.modules, cfg.usageLimits);API
verifyLicense(token, publicKeyBytes, expectedDeviceIdentifier?)→{ valid, reason?, payload?, header? }- Verifies prefix, structure, signature, expiration.
- If
expectedDeviceIdentifieris provided (including empty string), it must exactly matchpayload.cfg.deviceIdentifier.
base64urlDecode(input)→Uint8Array
Types
type UsageLimits = Record<string, number | undefined>;
type Modules = Record<string, boolean>;
type LicenseConfig = {
deviceIdentifier: string;
usageLimits?: UsageLimits;
modules: Modules;
};
type LicensePayload = {
cfg: LicenseConfig;
iat: number; // issued at
exp: number; // expires at
};Build & test
pnpm nx build @licenso/client
pnpm nx test @licenso/client