Node.js (NPM) License Key Encoder and Validator for the weweave Commerce platform
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

weweave Commerce License Key Encoder and Validator for Node.js

This Node.js library allows for encoding and validating license keys and building domain lists for the weweave Commerce platform.

Install with:

npm install --save commerce-key

Checking a license key

To check the validity of a provided license key, use a code block like this:

let publicKey: string = fs.readFileSync("./rsa-public-key.pem", "utf8").toString();
let s = "<License Key goes here>";
let key: LicenseKeyEncoder = LicenseKeyEncoder.factory(s, publicKey);
console.log("Product: %s", key.product);
console.log("Subject (i.e. Domain Regex): %s", key.subject);
console.log("Licensee: %s", key.owner);
console.log("License Type: %s", key.type);
console.log("Issue Date: %s", key.issueDate);
console.log("Expiry Date: %s", key.expiryDate);

Encoding a license key

let dl: DomainList = new DomainList();
dl.addDomain("localhost", false, false);
dl.addDomain("local", false, false);
let regex: RegExp = dl.getRegex();
let key: LicenseKeyEncoder = new LicenseKeyEncoder();
key.product = "ProductIdentifier";
key.description = "Some readable text";
key.owner = "Name of licensee";
key.subject = regex.source;
key.issueDate = moment().toDate();
key.expiryDate = moment().add(1, 'months').toDate();
key.type = LicenseKeyEncoder.TYPE_TRIAL;
key.uuid = uuid();
key.onlineVerification = false;
let privateKey: string = fs.readFileSync("./rsa-private-key.pem", "utf8").toString();
let keyString: string = key.toString(privateKey);

License types

weweave Commerce supports three types of license keys:

  • trial: A trial/evaluation license with limited functionality.
  • limited: A full-features license which is limited in time.
  • lifetime: A lifetime license which will never expire.

Advanced features

You can use the online verification feature to perform a live-validation of a license key via your servers using the UUID which can be included in the license keys optionally:

console.log("Online verification: %s", key.onlineVerification);
console.log("UUID: %s", key.uuid);


Please read the documentation and the JavaDoc for more information.