@rexfng/jwt

1.7.0 • Public • Published

Jwt

Description

Jwt is a provides helpers for signing and verifying token, based on various settings, it provides helpful defaults to simplify the overhead of such implementation.

Define Environment Variables

Define the follow environment variable. They are all required.

Variable Name Description
APP_NAME App name for 2fa issuer
APP_URL The website of the project
AUTH_SECRET Server side static salts
JWT_ISSUER Value will be signed together with the Token

Initialize Express Middleware

const Jwt = require('@rexfng/jwt')

let sign = Token.sign({
	ati: "refresh_token", // "access_token" || "refresh_token" || "id_token"
	user_id: "Bob123",
	udid: "28a208ee248d562d0751868281ba1a20", // providing udid and ati = "refresh_token" makes token expired in 60 days
	privateKey: pair.private, //if not provided, process.env.AUTH_SECRET will be used
	client_id: "abc",
	payload: {} //additional object to add to the token
}) //returns a string

Token.verify({
	token: sign,
	publicKey: pair.public
}) // returns promise

Readme

Keywords

none

Package Sidebar

Install

npm i @rexfng/jwt

Weekly Downloads

1

Version

1.7.0

License

ISC

Unpacked Size

3.35 kB

Total Files

3

Last publish

Collaborators

  • rexfng