ku4es-security
v2.1.2
Published
kodmunki Utilities for ECMAScript Security
Downloads
5
Maintainers
Readme
ku4es-security
kodmunki Utilities for ECMA Script Security
Installation
npm i -S ku4es-security
JSON Web Token Usage
const { Token } = require('ku4es-kernel');
or
import { Token } from 'ku4es-kernel';
Create Token
const token = new Token({ my: "payload" });
Sign Token
const token = new Token({ my: "payload" });
const signedToken = token.sign(secret.jwt.key);
Sign Token with signature
You can generate a signature value and store it in a secure location, e.g. HttpOnly cookie. Then, read that cookie and pass the value to confirm the origin of the signedToken. See Verify Token with signature for more information.
const token = new Token({ my: "payload" }, 'signature');
const signedToken = token.sign(secret.jwt.key);
Verify Token (Secure)
const token = new Token({ my: "payload" });
const signedToken = token.sign(secret.jwt.key);
Token.verify(signedToken, secret.jwt.crt);
Verify Token with signature (Secure)
You can generate a signature value and store it in a secure location, e.g. HttpOnly cookie. Then, read that cookie and pass the value to confirm the origin of the signedToken. See Sign Token with signature for more information.
const token = new Token({ my: "payload" }, 'signature');
const signedToken = token.sign(secret.jwt.key);
Token.verify(signedToken, secret.jwt.crt, 'signature');
More kodmunki™ libraries
Checkout these other kodmunki™ libraries for more awesome capabilities:
Appendix
- https://tools.ietf.org/html/rfc7519#page-19