Skip to content
LICENTIVO / INTEGRATION

JavaScript licensing SDK for Node.js and Electron desktop apps

Activate customer licenses and protect real operations in Node.js or Electron. Keep the SDK client outside browser page code to manage device-bound credentials, feature permissions and heartbeats.

Node.js 20+ / ElectronUpdated

1. Prepare the product and license

Start with a node-locked license and an ordinary export feature. Add metered usage only after the basic authorization flow works.

Device quota counts current activations and is returned on release. Ordinary licenses remain counted while offline; floating licenses also return quota when their leases expire.

  1. Copy the Product ID from Console > Products. Open that product’s Signing public keys and paste every key ID/public key pair into the initialization code, replacing YOUR_PRODUCT_ID, YOUR_KEY_ID and YOUR_PUBLIC_KEY. Quick integration can generate these public code constants. No product configuration file is required; the SDK defaults to https://www.licentivo.com.
  2. In Quick integration, create or select a product. Enable a feature named export in its policy and prepare a test license.

2. Install the SDK

Run the command below in your application project, or add the build dependency, to install SDK 0.11.6. The package manager retrieves the SDK; no source ZIP, manual extraction or local source path is required.

Terminal
npm install @licentivo/sdk@0.11.6

3. Protect a real export

Move SDK startup into your application’s startup or activation handler. Read the customer key from your activation form, pass your own product ID and trusted keys, and keep the client alive until shutdown. Put RunFeature at the actual business entry point; replace the report writer with your own operation.

Node.js 20+ / Electron · main.mjs
import {writeFile} from 'node:fs/promises';
import {Client} from '@licentivo/sdk'; // Installed package: import from '@licentivo/sdk'.

// BEGIN LICENTIVO PRODUCT
// Copy Product ID and all key ID/public key pairs from Console > Products > Signing public keys.
const PRODUCT_ID = 'YOUR_PRODUCT_ID';
const TRUSTED_KEYS = {'YOUR_KEY_ID': 'YOUR_PUBLIC_KEY'};
// END LICENTIVO PRODUCT

export async function exportReport(path) {
  // Replace this write with your existing, non-metered export operation.
  await writeFile(path, 'A report generated by the licensed application.\n', {mode: 0o600});
}

async function main() {
  // In Electron, create this in the main process, using customer activation input.
  const client = await Client.openProduct(
    PRODUCT_ID, TRUSTED_KEYS,
    process.env.LICENTIVO_LICENSE_KEY ?? '',
    error => console.error('Background verification:', error.message),
  );
  try {
    const feature = process.env.LICENTIVO_FEATURE ?? 'export';
    const path = process.env.LICENTIVO_OUTPUT ?? 'licensed-report.txt';
    const action = () => exportReport(path);
    if (process.env.LICENTIVO_METERED === '1') {
      await client.runMeteredFeature(feature, 1, process.env.LICENTIVO_OPERATION_ID ?? '', action);
    } else {
      await client.runFeature(feature, action);
    }
    console.log(`License OK: ${feature} is available\nExport completed: ${path}`);
  } finally {
    await client.close(); // In your application, close only when the app exits.
  }
}

main().catch(error => {console.error(error.message); process.exitCode = 2;});

4. Keep the client alive until shutdown

This command-line example performs one operation and exits. In a desktop application, open one client at startup, invoke the feature callback from the export action, and close the client only when the application exits.

After activation, later starts can leave LICENTIVO_LICENSE_KEY empty and restore the private credential under the same user and cache location. Keep that credential in the user application-data directory. Closing stops heartbeats and returns floating seats; normal exit should not deactivate a node-locked device.

Offline access is available only when the policy permits it and the signed grant remains valid. An expired or denied feature must remain blocked. Metered operations require a network connection.

In Electron, own the Client in the main process and expose only the required protected actions through a narrow IPC interface. Await runFeature and close; keep the client alive for the application lifetime. An async callback must finish before it reports success.

5. Run and verify the result

Copy the Product ID from Console > Products. Open that product’s Signing public keys and paste every key ID/public key pair into the initialization code, replacing YOUR_PRODUCT_ID, YOUR_KEY_ID and YOUR_PUBLIC_KEY. Quick integration can generate these public code constants. No product configuration file is required; the SDK defaults to https://www.licentivo.com.

  1. Confirm that a valid license with export access creates licensed-report.txt.
  2. Clear LICENTIVO_LICENSE_KEY and run again using the same user account: the saved credential should restore.
  3. Set LICENTIVO_FEATURE to a feature absent from the license and LICENTIVO_OUTPUT to a fresh filename. The program must report a denial without creating that file.
  4. Test an offline restart only with a permitted, unexpired signed grant. Do not bypass a failed feature check after a background refresh error.
Windows · PowerShell
$env:LICENTIVO_LICENSE_KEY = 'YOUR_LICENSE_KEY'
node main.mjs
Linux / macOS · Bash
LICENTIVO_LICENSE_KEY=YOUR_LICENSE_KEY node main.mjs

Common integration problems

Check the product ID, every key ID/public key pair and the customer’s license input. Public verification keys belong to a product; customer licenses and saved device credentials are separate. Do not distribute development test keys or vendor management API keys.

Feature denied, device limit reached or license expired: inspect the license and policy in the console, then show the SDK error to the customer. A failed authorization must not call the export function.

RunFeature checks feature access; the metered variant reserves and settles configured usage. Use a stable operation ID per real business job and inspect its durable result before recovering an interrupted job.

Module not found: install @licentivo/sdk in the same project that contains main.mjs. A configured proxy_url additionally needs the optional undici package compatible with your Node.js version.