Socket
Book a DemoInstallSign in
Socket

@dalisoft/jwt

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dalisoft/jwt

JWT Helper for Auth building from scratch

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

JWT

JWT Helper for Auth building from scratch

Note: Minimum Node.js version is v10.5 for working properly

Features

  • Fast
  • Almost zero-config
  • Auto-refresh token
  • Auto-normalisation of period/expiration
  • Types declaration for IDE/Editor
  • Well tested

Import

// ES6
import {
  sign,
  verify,
  decode,
  generateToken,
  refreshToken
} from '@dalisoft/jwt';

// or

// CommonJS
const JWT = require('@dalisoft/jwt');

Example

const { sign, verify, decode, generateToken, refreshToken } = JWT;

const token = await sign(payload: object, secret: string | any, options: object, isSecure: boolean): string;

For more info see tests.

Methods

#sign(payload: object, secret: string | any, options: object, isSecure: boolean): string

Returns value of signed (+ maybe secured) token

#verify(token: string, secret: string | any, options: object): object | null

Returns value of signed (+ maybe secured) token

#decode(token: string, secret: string | any, options: object): object | null

Decodes value of signed (+ maybe secured) token without needing verifying signature

#generateToken(payload: string | object, secretOrPrivate: string | any, options?: object, secure?: boolean, salt?: string)

Generates token and returns accessToken and refreshToken

#refreshToken({ accessToken, publicKey, salt refreshToken, privateKey,}: OKS)

Generates new token by refreshing token and returns accessToken and refreshToken

License

MIT

Keywords

auth

FAQs

Package last updated on 16 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts