https://github.com/cryptolens/cryptolens-nodejs
Client API to access the functionality of Cryptolens Software Licensing API
https://github.com/cryptolens/cryptolens-nodejs
licensing licensing-as-a-service licensing-library nodejs
Last synced: about 1 year ago
JSON representation
Client API to access the functionality of Cryptolens Software Licensing API
- Host: GitHub
- URL: https://github.com/cryptolens/cryptolens-nodejs
- Owner: Cryptolens
- License: mit
- Created: 2019-03-28T08:40:53.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-07-22T18:18:18.000Z (almost 2 years ago)
- Last Synced: 2025-04-13T17:18:50.898Z (about 1 year ago)
- Topics: licensing, licensing-as-a-service, licensing-library, nodejs
- Language: JavaScript
- Homepage: https://cryptolens.io/
- Size: 77.1 KB
- Stars: 18
- Watchers: 2
- Forks: 15
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cryptolens Client API for NodeJS
This library contains helper methods to verify licenses in NodeJS.
## Installation
```bash
npm add cryptolens
```
## Example
### Key Verification
To verify a license key, you can use the code below. The RSAPublicKey, token and the product id can be found on [this page](https://help.cryptolens.io/examples/key-verification).
```js
const key = require('cryptolens').Key;
const Helpers = require('cryptolens').Helpers;
var RSAPubKey = "Your RSA Public key, which can be found here: https://app.cryptolens.io/User/Security";
var result = key.Activate(token="Access token with with Activate permission", RSAPubKey, ProductId=3349, Key="GEBNC-WZZJD-VJIHG-GCMVD", MachineCode=Helpers.GetMachineCode());
result.then(function(license) {
// success
// Please see https://app.cryptolens.io/docs/api/v3/model/LicenseKey for a complete list of parameters.
console.log(license.Created);
}).catch(function(error) {
// in case of an error, an Error object is returned.
console.log(error.message);
});
```
### Offline activation (saving/loading licenses)
Assuming the license key verification was successful, we can save the result in a file so that we can use it instead of contacting Cryptolens.
First, we need to add the reference to the helper methods:
```js
const Helpers = require('cryptolens').Helpers;
```
We can now proceed and save it as a string.
```js
var licenseString = Helpers.SaveAsString(license);
```
When loading it back, we can use the code below:
```js
var license = Helpers.LoadFromString(RSAPubKey, licenseString);
```
If you want to make sure that the license file is not too old, you can specify the maximum number of days as shown below (after 30 days, this method will return null).
```js
var license = Helpers.LoadFromString(RSAPubKey, licenseString, 30);
```