Giter VIP home page Giter VIP logo

cryptolens-nodejs's Introduction

Cryptolens Client API for NodeJS

This library contains helper methods to verify licenses in NodeJS.

Installation

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.

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:

const Helpers = require('cryptolens').Helpers;

We can now proceed and save it as a string.

var licenseString = Helpers.SaveAsString(license);

When loading it back, we can use the code below:

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).

var license = Helpers.LoadFromString(RSAPubKey, licenseString, 30);

cryptolens-nodejs's People

Contributors

artemlos avatar jeffreydavidsz avatar alaminopu avatar thomaskoscheck avatar dependabot[bot] avatar ponsoc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.