# strong-license

> Simple license generator/validator using JWT.

Latest version **1.2.3** (published 2017-08-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install strong-license
pnpm add strong-license
yarn add strong-license
bun add strong-license
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.3 |
| Published | 2017-08-01 |
| First published | 2014-08-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ryan Graham |
| Maintainers | rmg, strongloop, octet, rfeng, kraman, kjdelisle, tonyf-ibm, thegman, qpresley, loay, jannyhou2016, hacksparrow, davidcheung, b-admike, amir-61, 0candy, superkhau, setogit, bajtos, ibmcloud-admin, ritch |

## Links

- npm: https://www.npmjs.com/package/strong-license
- Repository: https://github.com/strongloop/strong-license
- Issues: https://github.com/strongloop/strong-license/issues
- npm.io page: https://npm.io/package/strong-license

## Dependencies (1)

- [jwt-simple](https://npm.io/package/jwt-simple.md) ^0.5.1

## Recent versions

- 1.2.3 (latest) — 2017-08-01
- 1.2.2 — 2016-04-11
- 1.2.1 — 2015-10-01
- 1.2.0 — 2015-06-08
- 1.1.0 — 2015-05-13
- 1.0.2 — 2015-01-13
- 1.0.1 — 2014-11-15
- 1.0.0 — 2014-08-25

## README

strong-license
==============

Simple license generator/validator using JWT with the pre-defined claim names
(fields) and validation semantics.

 * `product` - a string identifying the product the license applies to
 * `features` - an array of strings identifying features of the product
 * `activationDate` - a Date indicating when the license period starts
 * `expirationDate` - a Date indicating when the license period ends
 * `email` - a string identifing who the license is for (primarily used for
   logging and identification for support purposes)

Both the `product` and `features` fields support `*` as a wildcard to indicate
that all products or features are covered by the license. When the product
field is a wildcard, any product check matches but it does not imply that all
features are covered. When the features list contains a wildcard as one of its
entries, any feature check matches.

## Usage

The strong-license module defines the License class, which can be used for
generating, parsing, and validating a license key.

### Generating a License Key

```js
var License = require('strong-license').License;
var details = {
  email: 'user@example.com',
  product: 'enterprise-node',
  features: ['foo', 'bar', 'baz'],
  activationDate: new Date(),
  expirationDate: new Date(Date.now() + 1000*60*60*24*365),
};
var lic = new License(details, 'super secret key!');

process.env.LICENSE_KEY = lic.key;
```

It is also possible to generate a null license, which does not cover any
products or features and is perpetually expired. It does, however, cover the
null query scenario.

```js
var License = require('strong-license').License;
var nullLicense = new License();

nullLicense.covers(); // => true! Can't do anything, but can do nothing!
```

### Parsing/Validating a License Key

If a license coverage query omits a field, that field is considered a match.

```js
var License = require('strong-license').License;
var now = new Date();
var yesterday = new Date(Date.now() - 1000*60*60*24);
var lic = new License(process.env.LICENSE_KEY, 'super secret key!');

lic.covers('enterprise-node', 'foo', now); // => true
lic.covers('myProduct', 'featurex', now); // => false
```

If a parameter is omitted, is considered a match.

```js
lic.covers('enterprise-node', 'bar', null); // => true
lic.covers('enterprise-node', null, now); // => true
lic.cocers(null, 'baz', yesterday); // => false
lic.covers(); // => true! any license covers "nothing"
```

---
_Source: https://npm.io/package/strong-license · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
