Node.js SDK

Official SDKs

Node.js SDK

TypeScript-first. Works in a Node.js runtime with native fetch (Node.js 18+; use a supported LTS release). Uses the native fetch API — no dependencies.

Installation

npm
npm install @permitcore/permitcore

Quick start

TypeScript
import { PermitCoreClient } from '@permitcore/permitcore';

const client = new PermitCoreClient('https://api.permitcore.dev');
const result = await client.validate(
  'PERMIT-XXXX-XXXX-XXXX-XXXX',
  undefined, // version
  '7f3e9a2b-1c4d-4e8f-9a6b-3d2c1e0f5a8b' // expectedProductId — optional, reject a key issued for a different product
);

if (result.errorCode === 'WrongProduct') {
  console.error(`Wrong product: ${result.productId}`);
  process.exit(1);
}
if (!result.isValid) {
  console.error(`License invalid: ${result.message}`);
  process.exit(1);
}

// Feature flags
const features = new Set(result.features ?? []);
if (features.has('export')) enableExport();
if (features.has('api'))    enableApiAccess();

// Or use the static helper:
if (PermitCoreClient.hasFeature(result, 'export')) enableExport();

Activation

TypeScript
// Auto-collects HWID when deviceId is omitted
const result = await client.activate(
    'PERMIT-XXXX-XXXX-XXXX-XXXX',
    PermitCoreClient.getHardwareId(), // optional — auto-used if omitted
    'My workstation',                     // optional display name
    undefined,                             // version
    '7f3e9a2b-1c4d-4e8f-9a6b-3d2c1e0f5a8b' // expectedProductId — optional
);

if (result.errorCode === 'WrongProduct') {
  console.error(`Wrong product: ${result.productId}`);
}

Product scoping: by default, any active key belonging to your tenant validates/activates successfully regardless of which product it was issued for. If you sell more than one product, either check result.productId yourself, or pass the optional expectedProductId parameter and let the server reject a mismatch (result.errorCode === 'WrongProduct'). Find a product's ID in the Admin panel under Products.

Floating licenses

Check out a seat when the session starts. While running, heartbeat about every four minutes and handle failed heartbeats. Stop using a rejected session. Cancel the heartbeat loop and await checkin during normal shutdown; process-exit callbacks may not finish network calls. See floating-session lifecycle.

Hardware ID

TypeScript
import { PermitCoreClient } from '@permitcore/permitcore';

const hwid = PermitCoreClient.getHardwareId();
// "a3f82c91b44e..." — stable SHA-256 of machine identifiers