@clientsdemo/license-client
v3.1.0
Published
TypeScript client SDK for the ClientsDemo License Server. Validate licenses, manage seats, renew, activate/deactivate machines, send heartbeats, and verify offline.
Downloads
372
Maintainers
Readme
@clientsdemo/license-client
TypeScript client SDK for the ClientsDemo License Server. Validate licenses, activate/deactivate machines, send heartbeats, and verify offline with Ed25519 signatures.
Installation
npm install @clientsdemo/license-client
# or
pnpm add @clientsdemo/license-clientQuick Start
import { LicenseClient } from "@clientsdemo/license-client";
const client = new LicenseClient({
serverUrl: "https://licenses.yourdomain.com",
apiKey: "lsk_...",
appId: "ehs",
});
// Validate a license
const result = await client.validate("XXXX-XXXX-XXXX-XXXX-XXXX");
if (result.valid) {
console.log("Features:", result.license?.features);
}
// Activate on this machine
const machineId = await LicenseClient.generateMachineId();
await client.activate("XXXX-XXXX-XXXX-XXXX-XXXX", machineId, {
machineName: "prod-server-01",
appVersion: "2.1.0",
});
// Start auto-heartbeat (every hour)
const stopHeartbeat = client.startHeartbeat("XXXX-XXXX-XXXX-XXXX-XXXX", machineId);
// Later: stopHeartbeat();Offline Verification
import { LicenseClient, verifyOffline } from "@clientsdemo/license-client";
// Download and cache the license file
const licenseFile = await client.downloadLicenseFile("XXXX-XXXX-XXXX-XXXX-XXXX");
// Store licenseFile in localStorage, a file, etc.
// Later, verify offline (no network needed)
const result = await verifyOffline(licenseFile);
if (result.valid) {
console.log("License valid offline");
}
// Or use validateWithFallback for automatic offline fallback
const result2 = await client.validateWithFallback(
"XXXX-XXXX-XXXX-XXXX-XXXX",
cachedLicenseFile,
machineId,
);Configuration
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| serverUrl | string | required | Base URL of the license server |
| apiKey | string | required | API key for authentication |
| appId | "ehs" \| "ehr" \| "ksdb" \| "isms" | required | Application identifier |
| timeout | number | 10000 | Request timeout in ms |
| maxRetries | number | 3 | Max retry attempts for failed requests |
| retryBaseDelay | number | 1000 | Base delay in ms for exponential backoff |
API Reference
client.validate(licenseKey, machineId?)
Validate a license key. Returns { valid, reason?, license? }.
client.activate(licenseKey, machineId, options?)
Activate a license on a machine. Returns { success, reason?, activationId? }.
client.deactivate(licenseKey, machineId)
Deactivate a license from a machine. Returns { success, reason? }.
client.heartbeat(licenseKey, machineId)
Send a heartbeat for an active license. Returns { success, reason? }.
client.status(licenseKey)
Get full license status including activations.
client.downloadLicenseFile(licenseKey)
Download a signed offline license file.
client.startHeartbeat(licenseKey, machineId, intervalMs?)
Start automatic heartbeat. Returns a stop function.
client.validateWithFallback(licenseKey, cachedFile, machineId?)
Validate with automatic offline fallback.
LicenseClient.generateMachineId() (static)
Generate a machine ID from hostname/OS info (Node.js).
LicenseClient.generateBrowserMachineId() (static)
Generate a machine ID from browser navigator data.
verifyOffline(licenseFile)
Verify a license file offline using Ed25519 Web Crypto API.
License
MIT
