export interface KeyfernOptions { /** Product id from the dashboard (prod_...). */ product: string; /** Public key (base64url) from the dashboard. Safe to embed in your app. */ publicKey: string; /** Your Keyfern server, e.g. https://keyfern.com */ url?: string; timeoutMs?: number; /** Where the last signed license is kept for offline use: fileStorage(path), webStorage() or your own. */ storage?: LicenseStorage | null; /** * Ed25519 check for runtimes without crypto.subtle Ed25519 (React Native / Hermes), e.g. * `(pub, sig, msg) => ed25519.verify(sig, msg, pub)` from @noble/curves. Default: crypto.subtle. */ verifyEd25519?: ((publicKey: Uint8Array, signature: Uint8Array, message: Uint8Array) => boolean | Promise) | null; } export interface LicenseStorage { get(): string | null | Promise; set(value: string): void | Promise; remove(): void | Promise; } export interface LicensePayload { v: number; product: string; key: string; machine: string | null; nonce: string | null; /** Server time the answer was issued (unix seconds). */ iat: number; status: 'active' | 'expired' | 'blocked'; /** Unix seconds, or null for a license that never expires. */ expires: number | null; /** Offline use is allowed until this moment (unix seconds, null = unlimited). */ lease_until: number | null; /** Set while the key was never activated: it expires this many days after its first activation. */ start_days: number | null; features: number[]; max_machines: number; machines_used: number; customer: { name: string | null; email: string | null }; meta: Record; usage: { count: number; limit: number | null }; machine_registered?: boolean | null; } export interface SignedLicense { payload: string; sig: string; } /** A verified payload plus the signed envelope, which you can store and pass to `checkCached` later. */ export type VerifiedLicense = LicensePayload & { _signed: SignedLicense }; export class KeyfernError extends Error { code: string; constructor(code: string, message?: string); } export class KeyfernNetworkError extends Error {} export class Keyfern { constructor(options: KeyfernOptions); verify(resp: SignedLicense, nonce?: string | null): Promise; /** Registers this machine. Rejects unless the license is active. */ activate(key: string, machine: string, name?: string): Promise; /** Read-only info; also works for expired keys. */ validate(key: string, machine?: string): Promise; deactivate(key: string, machine: string): Promise; trial(machine: string): Promise; /** Check a license cached earlier without the network: signature, expiry, lease. */ checkCached(signed: SignedLicense, machine?: string, lastSeen?: number): Promise; /** The license kept in `storage`, checked offline (signature, machine, expiry, lease, clock rollback). */ cached(machine?: string): Promise; /** Normal start-up call: online activation when possible, the cached license when offline. */ activateOrCached(key: string, machine: string, name?: string): Promise; } /** Node/Electron: keep the signed license in a file. */ export function fileStorage(path: string): LicenseStorage; /** Browsers: keep the signed license in localStorage. */ export function webStorage(name?: string): LicenseStorage; /** Node/Electron main process: stable hashed id of this computer (same value as the Python SDK's machine_code()). */ export function machineId(salt?: string): Promise;