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 - npm Package Compare versions

Comparing version 2.2.2 to 2.2.3

.editorconfig

4

index.d.ts

@@ -75,2 +75,6 @@ /// <reference types="@cloudflare/workers-types" />

/**
* If `true` all expiry checks will be skipped
*/
skipValidation?: boolean;
/**
* If `true` throw error if checks fail. (default: `false`)

@@ -77,0 +81,0 @@ *

10

index.js

@@ -111,6 +111,6 @@ "use strict";

*/
async function verify(token, secret, options = { algorithm: 'HS256', throwError: false }) {
async function verify(token, secret, options = { algorithm: 'HS256', skipValidation: false, throwError: false }) {
if (typeof options === 'string')
options = { algorithm: options, throwError: false };
options = { algorithm: 'HS256', throwError: false, ...options };
options = { algorithm: 'HS256', skipValidation: false, throwError: false, ...options };
if (typeof token !== 'string')

@@ -129,3 +129,3 @@ throw new Error('token must be a string');

const { payload } = decode(token);
if (!payload) {
if (!options.skipValidation && !payload) {
if (options.throwError)

@@ -135,3 +135,3 @@ throw 'PARSE_ERROR';

}
if (payload.nbf && payload.nbf > Math.floor(Date.now() / 1000)) {
if (!options.skipValidation && payload.nbf && payload.nbf > Math.floor(Date.now() / 1000)) {
if (options.throwError)

@@ -141,3 +141,3 @@ throw 'NOT_YET_VALID';

}
if (payload.exp && payload.exp <= Math.floor(Date.now() / 1000)) {
if (!options.skipValidation && payload.exp && payload.exp <= Math.floor(Date.now() / 1000)) {
if (options.throwError)

@@ -144,0 +144,0 @@ throw 'EXPIRED';

{
"name": "@tsndr/cloudflare-worker-jwt",
"version": "2.2.2",
"version": "2.2.3",
"description": "A lightweight JWT implementation with ZERO dependencies for Cloudflare Worker",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -107,3 +107,3 @@ # Cloudflare Worker JWT

`secret` | `string` | required | - | The string which was used to sign the payload.
`options` | `object` | optional | `{ algorithm: 'HS256', throwError: false }` | The options object supporting `algorithm` and `throwError`. (See [Available Algorithms](#available-algorithms))
`options` | `object` | optional | `{ algorithm: 'HS256', skipValidation: false, throwError: false }` | The options object supporting `algorithm`, `skipValidation` and `throwError`. (See [Available Algorithms](#available-algorithms))

@@ -110,0 +110,0 @@ #### `throws`

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