New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jwt-generator

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jwt-generator

Generates 'json web token' (JWT) by using the API of the authentication server.

  • 3.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16
increased by300%
Maintainers
1
Weekly downloads
 
Created
Source

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.

NPM version Build Status Test Coverage Dependencies DevDependencies JavaScript Style Guide

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({loginUrl: <url>, privateKey: <privateKey>, useRetry: <use retry>, issuer: <issuer>})
const jwtGenerator = new JWTGenerator({loginUrl: 'https://auth.domain.com', privateKey: '<privateKey>', useRetry: true, issuer: 'urn:home-automation/garage-door-raspberry-client'})

// jwtGenerator.makeNewToken({subject: <subject>, audience: <audience>, payload: <payload>, expiresIn: <expires (seconds)>})
jwtGenerator.makeNewToken({subject: 'report garage door state', audience: 'urn:home-automation/garage-door-api', payload: {"name": "John Doe", "admin": true}, expiresIn: 60})
  .then((token) => {
    // JWT generated by the authentication server.
  })

// jwtGenerator.makeToken({subject: <subject>, audience: <audience>, payload: <payload>, expiresIn: <expires (seconds)>})
jwtGenerator.makeToken({subject: 'report garage door state', audience: 'urn:home-automation/garage-door-api', payload: {"name": "John Doe", "admin": true}, expiresIn: 60})
.then((token) => {
  // JWT generated by the authentication server.
})

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)

FAQs

Package last updated on 02 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc