Socket
Socket
Sign inDemoInstall

@types/jsonwebtoken

Package Overview
Dependencies
2
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @types/jsonwebtoken

TypeScript definitions for jsonwebtoken


Version published
Weekly downloads
6.6M
decreased by-15.73%
Maintainers
1
Install size
3.90 MB
Created
Weekly downloads
 

Package description

What is @types/jsonwebtoken?

The @types/jsonwebtoken package provides TypeScript type definitions for the jsonwebtoken package, which is a popular library for working with JSON Web Tokens (JWTs) in Node.js applications. These type definitions allow developers to use jsonwebtoken in TypeScript projects with type checking, enabling better development experience and error handling.

What are @types/jsonwebtoken's main functionalities?

Signing Tokens

This feature allows you to create a JWT by encoding a payload and a secret. The `sign` method takes the payload and the secret key, then returns a token string.

import jwt from 'jsonwebtoken';

const token = jwt.sign({ foo: 'bar' }, 'shhhhh');

Verifying Tokens

This feature enables the verification of a JWT's signature and the extraction of the token's payload. The `verify` method takes the token and the secret key, and either returns the decoded payload or throws an error if the token is invalid.

import jwt from 'jsonwebtoken';

try {
  const decoded = jwt.verify(token, 'shhhhh');
  console.log(decoded);
} catch(err) {
  // handle token verification error
}

Decoding Tokens

This feature allows for the decoding of a JWT without verifying its signature. The `decode` method returns the payload of the token. This is useful for cases where you just need to read the token's payload without needing to validate it.

import jwt from 'jsonwebtoken';

const decoded = jwt.decode(token, { complete: true });
console.log(decoded);

Other packages similar to @types/jsonwebtoken

Readme

Source

Installation

npm install --save @types/jsonwebtoken

Summary

This package contains type definitions for jsonwebtoken (https://github.com/auth0/node-jsonwebtoken).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jsonwebtoken.

Additional Details

  • Last updated: Mon, 26 Feb 2024 18:35:29 GMT
  • Dependencies: @types/node

Credits

These definitions were written by Maxime LUCE, Daniel Heim, Brice BERNARD, Veli-Pekka Kestilä, Daniel Parker, Kjell Dießel, Robert Gajda, Nico Flaig, Linus Unnebäck, Ivan Sieder, Piotr Błażejewicz, and Nandor Kraszlan.

FAQs

Last updated on 26 Feb 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc