From 64da4c625f55f97cf164029a2e29c667667c645d Mon Sep 17 00:00:00 2001 From: Tobias Schneider Date: Sat, 4 Jun 2022 14:53:59 +0200 Subject: [PATCH] `.verify()` bugfix --- index.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 0d3d8b2..bec9fc7 100644 --- a/index.js +++ b/index.js @@ -113,7 +113,7 @@ class JWT { } else keyData = this._utf8ToUint8Array(secret) const key = await crypto.subtle.importKey(keyFormat, keyData, importAlgorithm, false, ['verify']) - return await crypto.subtle.verify(importAlgorithm, key, Base64URL.parse(tokenParts[2]), `${tokenParts[0]}.${tokenParts[1]}`) + return await crypto.subtle.verify(importAlgorithm, key, Base64URL.parse(tokenParts[2]), this._utf8ToUint8Array(`${tokenParts[0]}.${tokenParts[1]}`)) } decode(token) { return this._decodePayload(token.split('.')[1].replace(/-/g, '+').replace(/_/g, '/')) diff --git a/package.json b/package.json index e008f15..e18c3d9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tsndr/cloudflare-worker-jwt", - "version": "1.3.0", + "version": "1.3.1", "description": "A lightweight JWT implementation with ZERO dependencies for Cloudflare Worker", "main": "index.js", "scripts": {