This package is a node.js implementation of Licensespring SDK. For more information and tutorials, see: https://docs.licensespring.com/sdk
To install the SDK in your nodejs or typescript project run:
npm i --save @licensespring/node-sdk
Provides a direct interface to the LicenseSpring API. The LicenseAPI
class encapsulates API calls, input checks, authentication and signature verification. Typescript definitions are provided for the arguments and return types of the class methods.
To import the LicenseAPI class use:
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',
/** NOTE: the following properties are set to their default values by the SDK and can be overriden manually: */
// apiPath: 'http://api.dev.licensespring.com/api/v4',
// publicKey: '...',
});
The constructor takes the a single argument of the following type:
{
/** your Licensespring API key */
apiKey: string,
/** your Licensespring API Shared key **/
sharedKey: string,
/** custom name for your application */
appName: string,
/** custom version string for your application */
appVersion: string,
/** your Air Gap Activation key (optional) */
airGapKey?: string,
/** override for License API url (default is https://api.licensespring.com/api/v4/) **/
apiPath?: string,
/** override for License API public key (default is pub key for api.licensespring.com) **/
publicKey?: string,
/** override for License File filename (default is "License") */
filename?: string,
/** override for License File path (default is current directory) */
filePath?: string,
/** override for License File encryption key */
fileKey?: string,
/** override for license grace period duration in hours (default is 24) */
gracePeriod?: number,
/** override for License File guard file (default is false) */
isGuardFileEnabled?: boolean,
/** override for Hardware ID calculation method (default is 0, for more info see "Hardware ID" section) */
hardwareIDMethod?: number,
}
For more information on API functionality, see our LicenseSpring API docs.
For type definitions see Types.
Generates a Hardware ID. This value is required for various API method calls.
If the optional argument is not provided, it defaults to the value set in the configuration object provided when instantiating the LicensespringAPI object. If no value was provided in the config object, it defaults to 0 (the default Hardware ID method).
getHardwareID(algorithm?: HardwareIdAlgorithm): string
https://docs.licensespring.com/license-api/check
checkLicense(payload: LicenseIdentificator, includeExpiredFeatures: boolean = false): Promise<LicenseResponse>
https://docs.licensespring.com/license-api/activation-deactivation/activation
activateLicense(payload: LicenseActivationIdentificatorWithVariables): Promise<LicenseResponse>
https://docs.licensespring.com/license-api/activation-deactivation/deactivation
deactivateLicense(payload: LicenseIdentificator): Promise<boolean>
https://docs.licensespring.com/license-api/activation-deactivation/offline-activation
activateOffline(payload: LicenseActivationIdentificatorOfflineWithVariables): Promise<LicenseResponseOffline>
https://docs.licensespring.com/license-api/activation-deactivation/offline-deactivation
deactivateOffline(payload: LicenseIdentificator): Promise<boolean>
https://docs.licensespring.com/license-api/trial-key
getTrialKey(payload: TrialKeyPayload): Promise<LicenseTrialResponse>
https://docs.licensespring.com/license-api/user-licenses
getUserLicenses(payload: GetUserLicensesPayload): Promise<LicenseResponse[]>
https://docs.licensespring.com/license-api/customer-license-users
getCustomerLicenseUsers(payload: GetCustomerLicensesPayload): Promise<CustomerLicenseUsersResponse>
https://docs.licensespring.com/license-api/license-feature-check
checkLicenseFeature(payload: LicenseIdentificatorAndFeature): Promise<LicenseFeatureResponse>
https://docs.licensespring.com/license-api/consumption/add
addConsumption(payload: LicenseIdentificatorAddConsumptions): Promise<LicenseConsumptionsResponse>
https://docs.licensespring.com/license-api/consumption/add-feature
addFeatureConsumption(payload: LicenseIdentificatorAddFeatureConsumptions): Promise<LicenseFeatureConsumptionResponse>
https://docs.licensespring.com/license-api/product-details
getProductDetails(payload: ProductDetailsPayload): Promise<ProductDetailsResponse>
https://docs.licensespring.com/license-api/device-variables/get
getDeviceVariables(payload: LicenseIdentificator): Promise<DeviceVariable[]>
https://docs.licensespring.com/license-api/device-variables/track
trackDeviceVariables(payload: LicenseIdentificatorWithVariables): Promise<DeviceVariable[]>
https://docs.licensespring.com/license-api/floating/license/borrow
floatingBorrow(payload: LicenseIdentificatorWithBorrowedUntil): Promise<LicenseBorrowResponse>
https://docs.licensespring.com/license-api/floating/license/release
floatingRelease(payload: LicenseIdentificator): Promise<boolean>
https://docs.licensespring.com/license-api/floating/feature/release
featureRelease(payload: LicenseIdentificatorAndFeature): Promise<boolean>
https://docs.licensespring.com/license-api/change-password
changePassword(payload: PasswordChangePayload): Promise<boolean>
https://docs.licensespring.com/license-api/versions
getVersions(payload: LicenseIdentificator): Promise<VersionsResponse>
https://docs.licensespring.com/license-api/installation-file
getInstallationFile(payload: LicenseIdentificatorWithInstallation): Promise<InstallationFileResponse>
https://docs.licensespring.com/license-api/sso-url
getSSOUrl(payload: SSOURLParams): Promise<{ url: string }>
https://docs.licensespring.com/license-entitlements/activation-types/air-gapped
getAirGapActivationCode(initializationCode: string, licenseKey: string): string
verifyConfirmationCode(confirmationCode: string, licenseKey: string, policyId?: string): boolean
https://docs.licensespring.com/license-entitlements/activation-types/air-gapped
activateAirgappedLicense(activationPayload: OfflineActivation, licenseKey: string, policyId: string): LicenseResponse
Provides a high-level interface for managing licenses, including local licenses. The LicenseManager is required to work with local license files. Typescript definitions are provided for the arguments and return types of the class methods.
To import the LicenseManager class use:
const { LicenseManager } = require('@licensespring/node-sdk');
To create an instance:
const licenseManager = new LicenseManager({
apiKey: '12345678-4bfe-4e3a-8737-757004d6294c',
sharedKey: 'eYuHrlajvIVTiSFIXpxpKhw78f4Ewy-00-12345678',
appName: 'js-sdk-test-1',
appVersion: '0.0.1',
productCode: 'lkp',
/** NOTE: the following properties are set to their default values by the SDK and can be overriden manually: */
// apiPath: 'http://api.dev.licensespring.com/api/v4',
// publicKey: '...',
});
The constructor takes the a single argument of the following type:
{
/** your Licensespring API key */
apiKey: string,
/** your Licensespring API Shared key **/
sharedKey: string,
/** custom name for your application */
appName: string,
/** custom version string for your application */
appVersion: string,
/** your product short code */
productCode: string,
/** your Air Gap Activation key (optional) */
airGapKey?: string,
/** override for License API url (default is https://api.licensespring.com/api/v4/) **/
apiPath?: string,
/** override for License API public key (default is pub key for api.licensespring.com) **/
publicKey?: string,
/** override for License File filename (default is "License") */
filename?: string,
/** override for License File path (default is current directory) */
filePath?: string,
/** override for License File encryption key */
fileKey?: string,
/** override for license grace period duration in hours (default is 24) */
gracePeriod?: number,
/** override for License File guard file (default is false) */
isGuardFileEnabled?: boolean,
/** override for Hardware ID calculation method (default is 0, for more info see "Hardware ID" section) */
hardwareIDMethod?: number,
}
Methods that take a Managed
License identificator are the same as in License API, except that product
and hardware_id
do not have to be specified in the payload as they are provided by the License Manager object.
https://docs.licensespring.com/license-api/check
checkLicense(payload: Managed<LicenseIdentificator>): Promise<LicenseResponse>
https://docs.licensespring.com/license-api/activation-deactivation/activation
activateLicense(payload: Managed<LicenseIdentificatorWithVariables>): Promise<LicenseResponse>
https://docs.licensespring.com/license-api/activation-deactivation/deactivation
deactivateLicense(payload: Managed<LicenseIdentificator>): Promise<boolean>
https://docs.licensespring.com/license-api/activation-deactivation/offline-activation
activateOffline(payload: Managed<LicenseIdentificatorOfflineWithVariables>): Promise<LicenseResponseOffline>
https://docs.licensespring.com/license-api/activation-deactivation/offline-deactivation
deactivateOffline(payload: Managed<LicenseIdentificator>): Promise<boolean>
https://docs.licensespring.com/license-api/trial-key
getTrialKey(payload: Managed<TrialKeyPayload>): Promise<LicenseTrialResponse>
https://docs.licensespring.com/license-api/user-licenses
getUserLicenses(payload: Managed<GetUserLicensesPayload>): Promise<LicenseResponse[]>
https://docs.licensespring.com/license-api/customer-license-users
getCustomerLicenseUsers(payload: Managed<GetCustomerLicensesPayload>): Promise<CustomerLicenseUsersResponse>
https://docs.licensespring.com/license-api/license-feature-check
checkLicenseFeature(payload: Managed<LicenseIdentificatorAndFeature>): Promise<LicenseFeatureResponse>
https://docs.licensespring.com/license-api/consumption/add
addConsumption(payload: Managed<LicenseIdentificatorAddConsumptions>): Promise<LicenseConsumptionsResponse>
https://docs.licensespring.com/license-api/consumption/add-feature
addFeatureConsumption(payload: Managed<LicenseIdentificatorAddFeatureConsumptions>): Promise<LicenseFeatureConsumptionResponse>
https://docs.licensespring.com/license-api/product-details
getProductDetails(payload: Managed<ProductDetailsPayload>): Promise<ProductDetailsResponse>
https://docs.licensespring.com/license-api/device-variables/get
getDeviceVariables(payload: Managed<LicenseIdentificator>): Promise<DeviceVariable[]>
https://docs.licensespring.com/license-api/device-variables/track
trackDeviceVariables(payload: Managed<LicenseIdentificatorWithVariables>): Promise<DeviceVariable[]>
https://docs.licensespring.com/license-api/floating/license/borrow
floatingBorrow(payload: Managed<LicenseIdentificatorWithBorrowedUntil>): Promise<LicenseBorrowResponse>
https://docs.licensespring.com/license-api/floating/license/release
floatingRelease(payload: Managed<LicenseIdentificator>): Promise<boolean>
https://docs.licensespring.com/license-api/floating/feature/release
featureRelease(payload: Managed<LicenseIdentificatorAndFeature>): Promise<boolean>
https://docs.licensespring.com/license-api/change-password
changePassword(payload: PasswordChangePayload): Promise<boolean>
https://docs.licensespring.com/license-api/versions
getVersions(payload: Managed<LicenseIdentificator>): Promise<VersionsResponse>
https://docs.licensespring.com/license-api/installation-file
getInstallationFile(payload: Managed<LicenseIdentificatorWithInstallation>): Promise<InstallationFileResponse>
https://docs.licensespring.com/license-api/sso-url
getSSOUrl(payload: SSOURLParams): Promise<{ url: string }>
https://docs.licensespring.com/license-entitlements/activation-types/air-gapped
getAirGapActivationCode(initializationCode: string, licenseKey: string)
Performs verifyConfirmationCode
and activates Air-Gapped License:
activateAirGapLicense(confirmationCode: string, licenseKey: string, policyFilePath: string, policyID: string)
Checks if License is enabled, active and not expired:
isValid(license: LicenseResponse): boolean
Returns days remaining in maintenance period:
maintenanceDaysRemaining(license: LicenseResponse): number
Returns days remaining in license validity period:
daysRemaining(license: LicenseResponse): number
See License File
loadLicense(): License
isLicenseFileCorrupted(): boolean
clearLocalStorage(): void
For more info see our docs: https://docs.licensespring.com/sdks/tutorials/best-practices/local-license-file and https://docs.licensespring.com/sdks/python/licensefile
To load a local license file, create an instance of LicenseManager
and call the method loadLicense
:
const licenseFile = licenseManager.loadLicense();
The License class provides an interface for working with the License File.
public featureData(featureCode: string): ProductFeature
Throws an exception if the license is disabled, inactive or expired
checkLicenseStatus(): void
Checks License status and saves to local license file
check(includeExpiredFeatures: boolean = false): Promise<LicenseResponse>
getDeactivationCode(initializationCode: string): string
deactivateAirGap(confirmationCode: string): void
Deactivates a License, updates local license file. Optionally deletes license file
deactivate(deleteLicense: boolean = false): Promise<boolean>
Performs a local check using the local license file. Throws an exception if license is not valid
localCheck(): Promise<true>
Performs password change for user associated to License
changePassword(oldPassword: string, newPassword: string): Promise<boolean>
Adds a License consumption to the local license data
addLocalConsumption(consumptions: number = 1)
Adds a License feature consumption to the local license data
addLocalFeatureConsumption(featureCode: string, consumptions: number = 1)
Sends a feature consumption request to the server and updates local data
syncFeatureConsumption(feature: { code: string, local_consumption: number }): Promise<boolean>
Syncs local consumptions to server
syncConsumption(overages: number = -1): Promise<boolean>
floatingBorrow(borrowUntil: string, password?: string): Promise<boolean>
floatingRelease(): Promise<boolean>
Checks License Feature status, throws exception if not active
checkFeature(featureCode: string): Promise<void>
releaseFeature(featureCode: string): Promise<void>
Update local cache from Offline License File (at given `path`). Optionally reset local consumption value.
public updateOffline(path: string, resetConsumption: boolean): boolean
deactivateOffline(offlinePath: string): Promise<void>
Retrieves Product Details from server
productDetails(includeLatestVersion: boolean = false, includeCustomFields: boolean = false, includeExpiredFeatures: boolean = false): Promise<ProductDetailsResponse>
Retrieves Product Details from local data
get productDetailsLocal()
Set custom variables to local data
setDeviceVariablesLocal(variables: { [key: string]: string|number }, save: boolean = true): void
Send locally stored variables to server. Optionally save to license file
setDeviceVariables(save: boolean = false): Promise<void>
Get the value of a variable from local data
getDeviceVariableLocal(variable: string)
Get all variables from local data
getDeviceVariablesLocal()
getDeviceVariables(): Promise<DeviceVariable[]>
get allowGraceSubscriptionPeriod()
get allowOverages()
get allowUnlimitedActivations()
get allowUnlimitedConsumptions()
get borrowUntil()
get consumptionPeriod()
get consumptionReset()
get customerInformation()
get customFields()
get daysRemaining()
get daysSinceLastCheck()
get expiryDate()
get features()
get floatingClientId()
get floatingEndDate()
get floatingInUseDevices()
get floatingTimeout()
get gracePeriod()
get gracePeriodHoursRemaining()
get id()
get isAirGapped()
get isBorrowed()
get isControlledByFloatingServer()
get isDeviceTransferAllowed()
get isDeviceTransferLimited()
get isExpired()
get isFloating()
get isFloatingExpired()
get isGracePeriod()
get isGracePeriodStarted()
get isMaintenancePeriodExpired()
get isSubcriptionGracePeriodStarted()
get isTrial()
get isValid()
get isValidityPeriodExpired()
get lastCheck()
get lastUsage()
get licenseActive()
get licenseEnabled()
get licenseKey()
get licenseType()
get licenseUser()
get localConsumptions()
get maintenanceDaysRemaining()
get maintenancePeriod()
get maxActivations()
get maxConsumptions()
get maxFloatingUsers()
get maxOverages()
get maxTransfers()
get metadata()
get policyID()
get preventVm()
get startDate()
get subscriptionGracePeriod()
get totalConsumptions()
get transferCount()
get validityPeriod()
get validityWithGracePeriod()
Both LicenseAPI and LicenseManager use the Hardware ID module to calculate a unique fingerprint for the local machine. The module provides multiple methods of determining the ID:
export enum HardwareIdAlgorithm {
Default = 0,
WindowsHardwareFingerprintId = 1,
WindowsComputerSystemProductId = 2,
WindowsCryptographyId = 3,
LinuxMachineId = 4,
CloudPlatformsId = 5,
};
The default method (0) covers all cases and fallbacks. If you override the default method, the method used should be consistent accross your project. For both LicenseAPI and LicenseManager, this can be overriden globally by setting the required value in the config object when initializing the LicenseAPI/LicenseManager, e.g.:
const licenseAPI = new LicenseAPI({
apiKey: '12345678-4bfe-4e3a-8737-757004d6294c',
sharedKey: 'eYuHrlajvIVTiSFIXpxpKhw78f4Ewy-00-12345678',
appName: 'js-sdk-test-1',
appVersion: '0.0.1',
hardwareIDMethod: 5,
});
All calls to the server can be proxied by providing a proxy definition in either of the following two ways:
A. By providing a proxy definition in the initialization config argument for LicenseAPI
, LicenseManager
and FloatingAPI
, e.g.:
const licenseAPI = new LicenseAPI({
apiKey: '12345678-4bfe-4e3a-8737-757004d6294c',
sharedKey: 'eYuHrlajvIVTiSFIXpxpKhw78f4Ewy-00-12345678',
appName: 'js-sdk-test-1',
appVersion: '0.0.1',
proxy: {
host: '127.0.0.1',
port: 9000,
},
});
B. or by calling the setProxy
method on an initialized LicenseAPI
, LicenseManager
or FloatingAPI
object, e.g.:
licenseAPI.setProxy({
host: '127.0.0.1',
port: 9000,
});
For the type declaration of the proxy definition object, see AxiosProxyConfig
in the following Types section.
The following are typescript definitions for all the types used in the SDK:
/** Date string in ISO 8601 format (always in UTC timezone) with optional separators and optional time component, e.g.:
*
* "2024-09-27T23:30:48.016Z"
*
* "2024-09-27 23:30:48.016"
*
* "2024-09-27 23:30:48"
*
* "2024-09-27 23:30"
*
* "2024-09-27"
*
*/
export type DateInputString = string;
/** Date string in full ISO 8601 format, e.g. "2024-09-27T23:30:48.016Z". Note: this is always in UTC timezone */
export type DateISO8601UTC = string;
/** Date string in RFC 7231 format, e.g. "Fri, 27 Sep 2024 23:30:48 GMT". Note: this is always in GMT timezone */
export type DateRFC7231 = string;
/** Length of time expressed in days, months or years, e.g. 5d, 2m, 3y */
export type TimeLength = string;
export type LicensespringConfig = {
apiKey: string,
sharedKey: string,
apiPath: string,
publicKey: string,
productCode: string,
appName: string,
appVersion: string,
filePath: string,
filename: string,
gracePeriod: number,
fileKey: string,
airGapKey?: string,
isGuardFileEnabled: boolean,
hardwareIDMethod: number,
sdkVersion: string,
proxy?: AxiosProxyConfig,
};
interface AxiosProxyConfig {
host: string,
port: number,
protocol?: string,
auth?: {
username: string,
password: string,
}
}
export type LicensespringAPIConfig = Omit<LicensespringConfig, 'productCode'>;
export type LicensespringConfigDef = Omit<LicensespringConfig, 'apiPath'|'publicKey'|'filename'|'filePath'|'gracePeriod'|'fileKey'|'isGuardFileEnabled'|'hardwareIDMethod'|'sdkVersion'> & {
apiPath?: string,
publicKey?: string,
filename?: string,
filePath?: string,
gracePeriod?: number,
fileKey?: string,
isGuardFileEnabled?: boolean,
hardwareIDMethod?: number,
proxy?: AxiosProxyConfig,
};
export type LicensespringAPIConfigDef = Omit<LicensespringAPIConfig, 'apiPath'|'publicKey'|'filename'|'filePath'|'gracePeriod'|'fileKey'|'isGuardFileEnabled'|'hardwareIDMethod'|'sdkVersion'> & {
apiPath?: string,
publicKey?: string,
filename?: string,
filePath?: string,
gracePeriod?: number,
fileKey?: string,
isGuardFileEnabled?: boolean,
hardwareIDMethod?: number,
proxy?: AxiosProxyConfig,
};
export type LicensespringFloatingConfig = {
apiPath: string,
appVersion: string,
hardwareIDMethod: number,
sdkVersion: string,
proxy?: AxiosProxyConfig,
};
export type LicensespringFloatingConfigDef = Omit<LicensespringFloatingConfig, 'hardwareIDMethod'|'sdkVersion'> & {
hardwareIDMethod?: number,
};
type LicenseIdentificatorKeyBased = {
license_key: string,
};
type LicenseIdentificatorUserBased = {
username: string,
};
type LicenseActivationIdentificatorUserBased = {
username: string,
password: string,
};
type LicenseIdentificatorUserSSOBased = ({
id_token: string,
} | {
code: string,
}) & {
customer_account_code: string,
};
export type SSOURLParams = {
product: string,
type: 'token'|'code',
};
type LicenseIdentificatiorRequired = {
hardware_id: string,
product: string,
bundle_code?: string,
license_id?: number,
};
export type LicenseActivationIdentificatorWithVariables = LicenseActivationIdentificator & { variables?: Dictionary<string> };
export type LicenseActivationIdentificatorOfflineWithVariables = LicenseActivationIdentificator & OfflineActivationRequest & { variables?: Dictionary<string> };
export type LicenseIdentificatorWithVariables = LicenseIdentificator & { variables?: Dictionary<string> };
export type LicenseIdentificatorOfflineWithVariables = LicenseIdentificator & OfflineActivationRequest & { variables?: Dictionary<string> };
export type TrialKeyPayload = { email: string, product: string, hardware_id: string };
export type GetUserLicensesPayload = { username: string, password: string, product: string };
export type GetCustomerLicensesPayload = { customer: string, product: string };
export type LicenseIdentificatorAndFeature = LicenseIdentificator & { feature: string };
export type LicenseIdentificatorAddConsumptions = LicenseIdentificator & { consumptions: number };
export type LicenseIdentificatorAddFeatureConsumptions = LicenseIdentificator & { feature: string, consumptions: number };
export type ProductDetailsPayload = {
product: string,
/** @defaultValue false */
include_expired_features?: boolean,
/** @defaultValue false */
include_latest_version?: boolean,
/** @defaultValue false */
include_custom_fields?: boolean,
}
export type LicenseIdentificatorWithBorrowedUntil = LicenseIdentificator & { borrowed_until: DateInputString };
export type PasswordChangePayload = { username: string, password: string, new_password: string };
export type LicenseIdentificatorWithInstallation = LicenseIdentificator & { env: string, channel: string, version: string };
export type Managed<T> = Omit<T, 'product' | 'hardware_id'>;
/**
* @type {LicenseIdentificator}
*
* An object that identifies a License using either a license-key, user credentials or single sign-on credentials.
* Optionally can include a `license_id` property to force a specific license is being selected.
*/
export type LicenseIdentificator = (
XOR<LicenseIdentificatorKeyBased, LicenseIdentificatorUserBased>
) & LicenseIdentificatiorRequired;
export type LicenseActivationIdentificator = (
XOR<LicenseIdentificatorKeyBased, LicenseActivationIdentificatorUserBased, LicenseIdentificatorUserSSOBased>
) & LicenseIdentificatiorRequired;
/**
* @type {LicenseUser}
*
* An object describing a User associated to a specific license
*/
export type LicenseUser = {
id: number,
email: string,
first_name: string,
last_name: string,
phone_number: string,
is_initial_password: boolean,
allow_unlimited_activations: boolean,
max_activations: number,
total_activations: number,
};
/**
* @type {ProductDetails}
*
* An object describing the basic properties of a Product
*/
export type ProductDetails = {
product_id: number,
product_name: string,
short_code: string,
authorization_method: 'license-key' | 'user',
metadata: JSON,
};
/**
* @type {Customer}
*
* An object describing a Customer
*/
export type Customer = {
email: string,
company_name: string,
reference: string,
phone: string,
first_name: string,
last_name: string,
city: string,
postcode: string,
state: string,
country: string,
address: string,
customer_account: string|null,
metadata: JSON,
};
/**
* @type {CustomField}
*
* An object describing a Custom Field. These are key-value pairs assigned to a Product and inherited by that product's Licenses. They can be overriden on the License level
*/
export type CustomField = {
name: string,
data_type: 'numer' | 'text' | 'date/time',
value: string,
};
/**
* @type {ProductFeature}
*
* An object describing a Product Feature. These are custom attributes assigned to a Product and inherited by that product's Licenses
*/
export type ProductFeature = {
id: number,
code: string,
name: string,
expiry_date: string,
metadata: JSON,
is_floating_cloud: boolean,
} & XOR<{
feature_type: 'activation',
}, {
feature_type: 'consumption',
max_consumption: number,
allow_unlimited_consumptions: boolean,
total_consumptions: number,
allow_overages: number,
max_overages: number,
reset_consumption: boolean,
consumption_period: 'daily' | 'weekly' | 'monthly' | 'annualy' | null,
}> & XOR<{
is_floating: false
}, {
is_floating: true,
floating_users: number,
floating_timeout?: number,
}>;
/**
* @type {LicenseType}
*
* Declares the type of License which is always one of the following:
*
* - *perpetual*: A perpetual license does not expire. The `is_expired` field on such a license will always be `false`.
* Note that a perpetual *trial* license (`is_trial` flag is set to `true`) does have an `validity_period`, which refers to the end of the trial period.
*
* - *time-limited*: Has a `validity_period` set as a calendar date. After the date has passed, the `is_expired` flag will be set to `true`.
*
* - *subscription*: Uses an external source of truth such as a 3rd party service to determine the state of the License.
*
* - *consumption*: Permits usage metering. These licenses set a value the vendor wishes to meter, and then record the times that resource has been used.
* Includes the following properties: `max_consumptions`, `total_consumptions`, `allow_unlimited_consumptions`, `allow_overages`, `max_overages`, `reset_consumption` and `consumption_period`.
*
*/
export type LicenseType = 'perpetual' | 'time-limited' | 'consumption' | 'subscription';
/**
* @type {LicenseResponse}
*
* The License object received as a response when checking or activating a License. Includes a set of common properties and additional ones which may or may not appear depending on `license_type`, `is_trial`, `is_floating`/`is_floating_cloud` and Product `authorization_method` (key-based vs. user based).
*/
export type LicenseResponse = {
id: number;
allow_grace_period: boolean,
allow_overages: boolean,
allow_unlimited_activations: boolean,
borrowed_until: string | null,
can_borrow: boolean,
channel: string,
device_id: number,
enable_maintenance_period: boolean
environment: string,
eula_link: string,
floating_timeout: number,
grace_period: number,
hash_md5: string,
installation_file: string,
is_air_gapped: boolean,
is_borrowed: boolean,
is_expired: boolean,
is_hardware_key_auth: boolean,
license_active: boolean,
license_enabled: boolean,
license_signature: string,
license_type: LicenseType,
maintenance_period: string | null,
max_activations: number,
max_borrow_time: number,
max_license_users: number,
max_overages: number,
max_transfers: number,
order_store_id: string,
prevent_vm: boolean,
release_date: string,
release_notes_link: string,
requires_version: string,
size: string,
start_date: string | null,
times_activated: number,
transfer_count: number,
validity_period: DateISO8601UTC | null,
version: string,
product_features: ProductFeature[],
custom_fields: CustomField[],
customer: Customer,
product_details: ProductDetails,
metadata: JSON,
}
& XOR<{
license_key: string,
}, {
user: LicenseUser,
}>
& XOR<({
is_floating: true,
is_floating_cloud: boolean,
floating_in_use_devices: number,
} | {
is_floating: boolean,
is_floating_cloud: true,
floating_in_use_devices: number,
}) & {
floating_users: number,
},
{
is_floating_cloud: false,
is_floating: false,
}>
& XOR<{
is_trial: false,
}, {
is_trial: true,
trial_days: number,
}>
& XOR<{
license_type: 'consumption',
max_consumptions: number,
total_consumptions: number,
allow_unlimited_consumptions: boolean,
allow_overages: boolean,
max_overages: number,
reset_consumption: boolean,
consumption_period: 'daily' | 'weekly' | 'monthly' | 'annually' | null,
},
{}
>;
/**
* @type {LicenseResponseOffline}
*
* The License object received as a response when activating a License using the Offline method.
* This type is equal to LicenseResponse with the addition of the `license_signature_v2` property.
*/
export type LicenseResponseOffline = LicenseResponse & {
license_signature_v2: string,
};
export type LicenseFilePayload = LicenseResponseOffline & {
offline_signature: string,
};
export type OfflineActivationRequest = {
prefix?: string;
os_ver?: string;
sdk_build_version?: string;
hostname?: string;
ip?: string;
external_ip?: string;
app_ver?: string;
mac_address?: string;
};
export type DeviceVariable = {
id: number,
device_id: number,
created_at: DateISO8601UTC,
variable: string,
value: string,
};
type LicenseTrialExisting = {
};
type LicenseTrialNewCommon = {
license_key: string,
id: number,
order_id: number,
product_id: number,
max_license_users: number,
max_activations: number,
times_activated: number,
is_trial: true,
active: boolean,
enabled: boolean,
max_transfers: number,
trial_days: number,
maintenance_duration: TimeLength | null,
validity_period: DateISO8601UTC | null,
enable_maintenance_period: boolean,
prevent_vm: boolean,
is_hardware_key_auth: boolean,
license_user: string,
initial_password: string,
metadata: JSON,
created_at: number,
updated_at: number,
LicenseProductFeatures: LicenseProductFeature[],
LicenseCustomFields: {
product_custom_field_id: number,
value: string
}[],
};
type LicenseTrialNew = LicenseTrialNewCommon
& (XOR<
{
is_floating_cloud: true,
floating_users: number,
floating_timeout: number,
},
{}
>)
& (XOR<
{
license_type: 'consumption',
allow_overages: boolean,
max_overages: number,
max_consumptions: number,
valid_duration: null,
consumption_period: 'daily' | 'weekly' | 'monthly' | 'annually' | null,
reset_consumption: boolean,
},
XOR<
{
license_type: 'subscription',
grace_period: number,
allow_grace_period: boolean,
},
{
license_type: 'perpetual' | 'time-limited',
}
>
>
);
export type LicenseTrialResponse = (LicenseTrialNew | LicenseTrialExisting) & {
license_type: LicenseType,
is_trial: boolean,
/** Username */
license_user: string,
};
type CustomerLicenseUser = {
email: string,
is_active: boolean,
first_name: string,
last_name: string,
phone_number: string,
is_initial_password: boolean,
initial_password: string,
max_activations: number,
total_activations: number,
license_id: number,
order_id: number,
order_store_id: string,
};
export type CustomerLicenseUsersResponse = {
customer: {
email: string | null,
first_name: string | null,
last_name: string | null,
company_name: string | null,
phone: string | null,
reference: string | null,
address: string | null,
postcode: string | null,
city: string | null,
country: string | null,
state: string | null,
customer_account: null | {
id: string,
name: string,
code: string,
},
metadata: JSON,
},
users: CustomerLicenseUser[]
};
export type LicenseFeatureResponse = {
id: number,
code: string,
name: string,
floating_timeout: number | null,
floating_users: number | null,
feature_type: 'activation' | 'consumption'
expiry_date: DateISO8601UTC | null,
metadata: JSON,
is_floating: boolean,
is_floating_cloud: boolean,
floating_in_use_devices: number,
license_id: number,
};
export type LicenseProductFeature = {
id: number,
product_feature_id: number,
max_consumption: number,
allow_overages: boolean,
max_overages: number,
reset_consumption: number,
consumption_period: 'daily' | 'weekly' | 'monthly' | 'annually' | null,
expiry_date: DateISO8601UTC | null,
is_floating: boolean,
is_floating_cloud: boolean,
metadata: JSON,
} & XOR<({ is_floating: true } | { is_floating_cloud: true }) & {
floating_timeout: number,
floating_users: number,
},
{}>;
export type LicenseConsumptionsResponse = {
id: number,
max_consumptions: number,
total_consumptions: number,
allow_unlimited_consumptions: boolean,
allow_negative_consumptions: boolean,
allow_overages: boolean,
max_overages: number,
reset_consumption: boolean,
consumption_period: 'daily' | 'weekly' | 'monthly' | 'annually' | null,
};
export type LicenseFeatureConsumptionResponse = {
allow_negative_consumptions: boolean,
allow_overages: boolean,
allow_unlimited_consumptions: boolean,
consumption_period: 'daily' | 'weekly' | 'monthly' | 'annually' | null,
is_floating_cloud: boolean,
is_floating: boolean,
max_consumptions: number,
max_overages: number,
reset_consumption: boolean,
total_consumptions: number,
// the following properties are only present on floating and floating cloud features:
floating_timeout?: number | null,
floating_users?: number,
};
export type ProductDetailsResponse = ProductDetails & {
floating_timeout: number,
max_overages: number,
trial_days: number,
allow_overages: boolean,
allow_trial: boolean,
prevent_vm: boolean,
custom_fields: {
id: number,
name: string,
default_value: string,
}[],
latest_version: null | (InstallationFileBase & {
id: number,
product_id: number,
enabled: boolean,
created_at: DateISO8601UTC,
updated_at: DateISO8601UTC,
full_link: string | null,
filename: string | null,
})
};
export type LicenseBorrowResponse = {
license_id: number,
device_id: number,
borrowed_until: DateInputString,
max_borrow_time: number,
};
type InstallationFileBase = {
version: string | null,
environment: string | null,
hash_md5: string | null,
eula_link: string | null,
release_notes_link: string | null,
size: string | null,
requires_version: string | null,
channel: string | null,
release_date: DateISO8601UTC | null,
};
export type InstallationFileResponse = InstallationFileBase & {
installation_file: string | null
};
export type VersionsResponse = {
version: string,
release_date: DateISO8601UTC,
}[];
export type LicenseDataMethod = 'check_license'
|'activate_license'
|'activate_license_offline'
|'activate_air_gap'
|'update_license_offline'
|'product_details'
|'device_variables'
|'normal'
|'license_consumption'
|'feature_consumption'
|'register_feature'
|'floating_server_register'
;
export enum HardwareIdAlgorithm {
Default = 0,
WindowsHardwareFingerprintId = 1,
WindowsComputerSystemProductId = 2,
WindowsCryptographyId = 3,
LinuxMachineId = 4,
CloudPlatformsId = 5,
};
-
node.js SDK license: LicenseSpring SDK Source Code License
-
Included 3rd-part library licenses: https://docs.licensespring.com/sdk-licensing