Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@abskmj/jwt-utility

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@abskmj/jwt-utility

JWT Utility for Node.js

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

JWT Utility for Node.js

This utility can be used to generate and parse JWTs (JSON Web Tokens).

Supported Algorithms

  • HS256
  • HS384
  • HS512

Utlity Methods

MethodArgumentsDescription
getFactoryStringSet algorithm to be used to generate the JWT and returns an instance of Factory
getParserReturns an instance of Parser which can be used to parse and verify a JWT

Generating a Token

const JWTUtility = require('@abskmj/jwt-utility');

let jwt = JWTUtility.getFactory('HS256')
    .setIssuer('AuthServer')
    .setSubject('Login')
    .setExpiry(10)
    .setClaims({
        user: 'testUser',
        name: 'Test User'
    })
    .sign('secret key');

Factory Instance Methods

MethodArgumentsDescription
setIssuerStringSet iss claim value.
setSubjectStringSet sub claim value.
setAudienceStringSet aud claim value.
setExpiryNumberSet exp claim value, value will be current epoch time in seconds + seconds passed as argument.
setClaimsJSONSet the custom data that will be part of the JWT.
signStringGenerate the JWT using the secret key passed

Parsing a Token

const JWTUtility = require('@abskmj/jwt-utility');

let data = JWTUtility.getParser()
    .validateIssuer('AuthServer')
    .validateSubject('Login')
    .parse(jwt, 'secret key');

Factory Instance Methods

MethodArgumentsDescription
validateIssuerStringValidate iss claim value.
validateSubjectStringValidate sub claim value.
validateAudienceStringValidate aud claim value.
validateExpiryNumberValidate exp claim value, value validated against current epoch time in seconds + seconds passed as argument.
parseString, StringSet JWT token and key used to verify the token

Keywords

FAQs

Package last updated on 22 Nov 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc