New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

jwt-check-time

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jwt-check-time

des

latest
Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

jwt-check-time

Simple JWT Decoder
This function can determine if the token expiration time & custom time(for reissue tokens) have been exceeded.

How to use

import checkJWT from 'jwt-check-time'

const [isNotExpired, isNotOverTime] = checkJWT
      .create({ time: '10m' }) // set config value
      .check(jwt)

Return value

  • isNotExpired
    Check if the token exp time is overed than Date now.
  • isNotOverTime
    Check if the time to reissue the refresh token has overed.
    Criteria time is (token's exp - config time)

Config Object Property

// This is the default config value that used if you don't set value
const defaultConfig: config = {
  time: '5m', //  number + unit
  expUnit: 's', // JWT standard time units is second
                // You can set token's time units as  s | m | h | d (regardless of case)
  expName: 'exp', // JWT standard's Expiration Time property name is "exp"
                  // You can customize it to fit your token.
};

Set Default Config

import checkJWT from 'jwt-check-time'

checkJwt.defaultConfig.time = "5m"
// or 
checkJwt.setConfig = { time: "5m", expUnit: "M" }

// ... in any file
checkJwt.check(jwt) // You can overwrite config with create method

The config of create method takes precedence.
The above setting way affects globally.

Keywords

jwt

FAQs

Package last updated on 12 Aug 2021

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