1
0

Compare commits

..

4 Commits

Author SHA1 Message Date
a8f95f1c6d 2.2.2 2023-08-25 16:01:57 +02:00
Tom Lokhorst
b2886c0778 Allow array in Audience 2023-08-25 16:00:30 +02:00
76b7fcef27 2.2.1 2023-02-02 16:13:50 +01:00
3b5d8bcde8 hotfix 2023-02-02 16:13:28 +01:00
3 changed files with 6 additions and 6 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "@tsndr/cloudflare-worker-jwt", "name": "@tsndr/cloudflare-worker-jwt",
"version": "2.2.0", "version": "2.2.2",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@tsndr/cloudflare-worker-jwt", "name": "@tsndr/cloudflare-worker-jwt",
"version": "2.2.0", "version": "2.2.2",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@cloudflare/workers-types": "^3.13.0", "@cloudflare/workers-types": "^3.13.0",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@tsndr/cloudflare-worker-jwt", "name": "@tsndr/cloudflare-worker-jwt",
"version": "2.2.0", "version": "2.2.2",
"description": "A lightweight JWT implementation with ZERO dependencies for Cloudflare Worker", "description": "A lightweight JWT implementation with ZERO dependencies for Cloudflare Worker",
"main": "index.js", "main": "index.js",
"types": "index.d.ts", "types": "index.d.ts",

View File

@@ -33,7 +33,7 @@ export interface JwtHeader {
* @typedef JwtPayload * @typedef JwtPayload
* @prop {string} [iss] Issuer * @prop {string} [iss] Issuer
* @prop {string} [sub] Subject * @prop {string} [sub] Subject
* @prop {string} [aud] Audience * @prop {string | string[]} [aud] Audience
* @prop {string} [exp] Expiration Time * @prop {string} [exp] Expiration Time
* @prop {string} [nbf] Not Before * @prop {string} [nbf] Not Before
* @prop {string} [iat] Issued At * @prop {string} [iat] Issued At
@@ -47,7 +47,7 @@ export interface JwtPayload {
sub?: string sub?: string
/** Audience */ /** Audience */
aud?: string aud?: string | string[]
/** Expiration Time */ /** Expiration Time */
exp?: number exp?: number
@@ -283,7 +283,7 @@ export async function verify(token: string, secret: string | JsonWebKey, options
keyFormat = 'jwk'; keyFormat = 'jwk';
keyData = secret; keyData = secret;
} else if (typeof secret === 'string' && secret.startsWith('-----BEGIN')) { } else if (typeof secret === 'string' && secret.startsWith('-----BEGIN')) {
keyFormat = 'pkcs8' keyFormat = 'spki'
keyData = _str2ab(secret.replace(/-----BEGIN.*?-----/g, '').replace(/-----END.*?-----/g, '').replace(/\s/g, '')) keyData = _str2ab(secret.replace(/-----BEGIN.*?-----/g, '').replace(/-----END.*?-----/g, '').replace(/\s/g, ''))
} else } else
keyData = _utf8ToUint8Array(secret) keyData = _utf8ToUint8Array(secret)