user-keyJWT

JWT utils

Creating the instance

import { JWT } from '@arcend/auth';

const jwt: JWT = new JWT({secret: "SECRETKEY"});

Creating token types

// jwt.createType(name: string, exp: string)
jwt.createType('session', '12h');
jwt.createType('action', '5m');

Creating key

// jwt.sign(type: string, user?: string)
let tokenNoUser: string   = jwt.sign('action');
let tokenWithUser: string = jwt.sign('action', 'arcend');

Checking keys

// jwt.check(token: string, type: string, user?: string)
let checkNoUser: boolean   = jwt.check('sometoken', 'action');
let checkWithUser: boolean = jwt.check('sometoken', 'action', 'arcend');

Last updated