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

@tsndr/cloudflare-worker-jwt

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tsndr/cloudflare-worker-jwt

A lightweight JWT implementation with ZERO dependencies for Cloudflare Worker

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
38K
increased by8.85%
Maintainers
1
Weekly downloads
 
Created
Source

Cloudflare Worker JWT

A lightweight JWT implementation with ZERO dependencies for Cloudflare Workers.

Contents

  • Usage
  • Install

Usage

Simple Example

const jwt = require('@tsndr/cloudflare-worker-jwt')

// Creating a token
const token = jwt.sign({ name: 'John Doe', email: 'john.doe@gmail.com' }, 'secret')

// Verifing token
const isValid = jwt.verify(token, secret)

// Decoding token
const payload = jwt.decode(token)

jwt.sign(payload, secret, [algorithm])

Signs a payload and returns the token.

payload Can be an object, buffer or a string.

secret A string which is used to sign the payload.

algorithm (optional, default: HS256) The algorithm used to sign the payload, possible values: HS256(default) or HS512

jwt.verify(token, secret, [algorithm])

Verifies the integrity of the token and returns a boolean value.

token The token string generated by jwt.sign().

secret A string which is used to sign the payload.

algorithm (optional, default: HS256) The algorithm used to sign the payload, possible values: HS256(default) or HS512

jwt.decode(token)

Returns the payload without verifying the integrity of the token.

token The token string generated by jwt.sign().

Install

npm i @tsndr/cloudflare-worker-jwt

Keywords

FAQs

Package last updated on 04 Feb 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

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