1.7.0 • Published 4 years ago

@rexfng/jwt v1.7.0

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

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
1.7.0

4 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago