Home Automation - JSON Web Token (JWT) Generator
This package is being used by the home automation project.
The package generates 'JSON Web Token' (JWT) by using the API of the authentication server.
![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)
Installation (via npm)
$ npm install --save jwt-generator
Usage
The package supports ES5 or later. The example below is using ES6 features.
Here you can find instructions on how to generate private & public keys.
const JWTGenerator = require('jwt-generator')
const jwtGenerator = new JWTGenerator('https://auth.domain.com', <privateKey>, true, 'urn:home-automation/garage-door-raspberry-client')
jwtGenerator.makeNewToken('report garage door state', 'urn:home-automation/garage-door-api', {"name": "John Doe", "admin": true}, 60)
.then((token) => {
})
jwtGenerator.makeToken('report garage door state', 'urn:home-automation/garage-door-api', {"name": "John Doe", "admin": true}, 60)
.then((token) => {
})
The difference between makeToken
and makeNewToken
is that the former may re-use existing token that has been stored in the cached,
while the latter will always generate new token by calling the authentication server.
License
AGPL-3.0
Author
Oron Nadiv (oron@nadiv.us)