nodeJS SDK

About

This package implements LicenseSpring SDK functionality for Javascript and Typescript.

Installation

The package is published on npmjs.com and can be installed as follows:

Install
npm i --save @licensespring/node-sdk

Interface

The SDK provides several classes which are used to interface with LicensenSpring services as well as functionality for local license files:

LicenseAPI

This is a wrapper class for interacting with the License API. It provides all the API endpoints as class methods, provides input validation and response signature checks. If you prefer to implement your own logic for working with LicenseSpring data, this class contains all the necessary functionality.

LicenseAPI usage
const { LicenseAPI } = require('@licensespring/node-sdk');

const licenseAPI = new LicenseAPI({
  apiKey: '12345678-4bfe-4e3a-8737-757004d6294c',
  sharedKey: 'eYuHrlajvIVTiSFIXpxpKhw78f4Ewy-00-12345678',
  appName: 'js-sdk-test-1',
  appVersion: '0.0.1',
});

const licenseActivation = await licenseAPI.activateLicense({ license_key: 'string', product: 'string', hardware_id: 'string' });

const bundleActivation = await licenseAPI.activateBundle({ license_key: 'string', product: 'string', hardware_id: 'string' });

const licenseCheck = await licenseAPI.checkLicense({ license_key: 'string', product: 'string', hardware_id: 'string' });

const bundleCheck = await licenseAPI.checkBundle({ license_key: 'string', product: 'string', hardware_id: 'string' });

const addConsumption = await licenseAPI.addConsumption({ license_key: 'string', product: 'string', hardware_id: 'string', consumptions: 10 });

const addFeatureConsumption = await licenseAPI.addFeatureConsumption({ license_key: 'string', product: 'string', hardware_id: 'string', feature: 'string', consumptions: 10 });

const licenseFeatureCheck = await licenseAPI.checkLicenseFeature({ license_key: 'string', product: 'string', hardware_id: 'string', feature: 'string' });

const trackDeviceVariables = await licenseAPI.trackDeviceVariables({ license_key: 'string', product: 'string', hardware_id: 'string', variables: { key1: 'value1' } });

const getDeviceVariables = await licenseAPI.getDeviceVariables({ license_key: 'string', product: 'string', hardware_id: 'string' });

const licenseDeactivation = await licenseAPI.deactivateLicense({ license_key: 'string', product: 'string', hardware_id: 'string' });

const bundleDeactivation = await licenseAPI.deactivateBundle({ license_key: 'string', product: 'string', hardware_id: 'string' });

/* NOTE: the hardware_id value can be either generated by your app 
 * (eg. using custom-made hardware fingerprinting logic) or you
 * can use the hardware ID module exposed by this class: 
 */
 const hardwareID = licenseAPI.getHardwareID();

For a more detailed overview of this class see: License API

circle-info

The hardware_id value can be either generated by your app (for example using custom-made hardware fingerprinting logic) or you can use the hardware ID module exposed by this class: licenseAPI.getHardwareID()

LicenseManager

This class extends the functionality provided by the LicenseAPI class and provides methods for managing licenses. In addition to encapsulating API calls, this class reads and writes local license files and handles hardware ID generation internally.

For a more detailed overview of this class see: License Manager

circle-info

Each LicenseManager instance is attached to a specific product via the productCode option.

BundleManager

This class extends the functionality provided by the LicenseAPI class and provides methods for managing license bundles. The behaviour of this class is similar to LicenseManager, the only difference being that this class is used for license bundles, as opposed to single licenses.

For a more detailed overview of this class see: Bundle Manager

LicenseFile

This class encapsulates the local license file produced by the LicenseManager or BundleManager. This file is used by client applications to track the license state on local storage.

For a more detailed overview of this class see: License File

Was this helpful?