securejwt

1.1.1 • Public • Published

SECURE JSON WEB TOKEN LIBRARY

Secure your payloads by adding an extra layer of encryption to your applications, especially when sending data across the internet.

Install

npm install securejwt

Usage

sjwt.setKeyPath(_path_)

Sets the locationt o store sjwt key and (re)generates key.

  • _path_: <string>

sjwt.generateJWT(payload,fingerprint)

Returns JsonWebToken with aes256 encrypted payload. See JsonWebToken

  • payload: <Object>|<Primitive>|<\Buffer>
  • fingerprint: <string>

sjwt.retrieveJWT(JWTString,fingerprint)

Returns decrypted payload of JWTString

  • JWTString: <string>
  • fingerprint: <string>

Full Example

var sjwt = require("securejwt"); // require module
 
/* Variables */
var keyPath = "~/jwtkeys"; // define keypath
var payload = { "message" : "hello" }; // define payload
var fingerprint = "myFingerPrint"; // define fingerprint
 
/* Methods */
sjwt.setKeyPath(keyPath); // set key path
var secureToken = sjwt.generateJWT(payload, fingerprint); // generate secureToken
var payload = sjwt.retrieveJWT(secureToken,fingerprint); // decrypt payload
 
/* Inspection */
console.log(secureToken); // output secureToken to inspect payload
console.log(payload); // output payload to inspect

Readme

Keywords

Package Sidebar

Install

npm i securejwt

Weekly Downloads

2

Version

1.1.1

License

BSD-3-Clause

Last publish

Collaborators

  • siraglovale