ku4es-security
TypeScript icon, indicating that this package has built-in type declarations

2.1.2 • Public • Published

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

Package Sidebar

Install

npm i ku4es-security

Weekly Downloads

1

Version

2.1.2

License

kodmunki

Unpacked Size

37.1 kB

Total Files

6

Last publish

Collaborators

  • kodmunki