Skip to content

Commit

Permalink
fix: add missing jwt exception
Browse files Browse the repository at this point in the history
  • Loading branch information
cptchloroplast committed Nov 21, 2024
1 parent 0d1ca73 commit 95c27f5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@okkema/worker",
"version": "3.6.0",
"version": "3.6.1",
"description": "Cloudflare Workers Toolkit",
"files": [
"dist",
Expand Down
5 changes: 3 additions & 2 deletions src/auth/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type ValidateOptions = {
jwkUrl?: string
skipAppendIssuer?: boolean
skipPrependAudience?: boolean
ignoreHeaderType?: boolean
}

async function validateSignature(
Expand Down Expand Up @@ -118,13 +119,13 @@ function validatePayload(
validateExpiration(exp)
}

function validateHeader(jwt: DecodedJsonWebToken) {
function validateHeader(jwt: DecodedJsonWebToken, options?: ValidateOptions) {
const {
decoded: {
header: { typ, alg, kid },
},
} = jwt
if (typ !== "JWT")
if (typ !== "JWT" && !options?.ignoreHeaderType)
throw new Problem({
title: "JWT Header Validation Error",
detail: `Invalid JWT type: ${typ}`,
Expand Down

0 comments on commit 95c27f5

Please sign in to comment.