@cfworker/jwt 4.0.4 → 4.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/parse.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import { DecodedJwt, JwtParseResult } from './types.js';
2
- export declare function parseJwt(encodedToken: string, issuer: string, audience: string, resolveKey?: (decoded: DecodedJwt) => Promise<CryptoKey | null>): Promise<JwtParseResult>;
2
+ export declare function parseJwt(encodedToken: string, issuer: string | string[], audience: string, resolveKey?: (decoded: DecodedJwt) => Promise<CryptoKey | null>): Promise<JwtParseResult>;
package/dist/parse.js CHANGED
@@ -55,10 +55,10 @@ export async function parseJwt(encodedToken, issuer, audience, resolveKey = getK
55
55
  reason: `Invalid JWT audience claim (aud) ${JSON.stringify(aud)}. Expected a string or a non-empty array of strings.`
56
56
  };
57
57
  }
58
- if (iss !== issuer) {
58
+ if (!(iss === issuer || (Array.isArray(issuer) && issuer.includes(iss)))) {
59
59
  return {
60
60
  valid: false,
61
- reason: `Invalid JWT issuer claim (iss) ${JSON.stringify(decoded.payload.iss)}. Expected "${issuer}".`
61
+ reason: `Invalid JWT issuer claim (iss) ${JSON.stringify(decoded.payload.iss)}. Expected ${JSON.stringify(issuer)}.`
62
62
  };
63
63
  }
64
64
  if (typeof exp !== 'number') {
package/dist/types.d.ts CHANGED
@@ -11,6 +11,7 @@ export interface JwtHeader {
11
11
  typ?: string;
12
12
  alg: string;
13
13
  kid: string;
14
+ jku?: string;
14
15
  }
15
16
  export interface RawJwt {
16
17
  header: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfworker/jwt",
3
- "version": "4.0.4",
3
+ "version": "4.0.6",
4
4
  "description": "Tiny lib for decoding JWTs and verifying signatures, using native crypto APIs",
5
5
  "keywords": [
6
6
  "jwt",
package/src/parse.ts CHANGED
@@ -11,7 +11,7 @@ const skewMs = 30 * 1000;
11
11
  */
12
12
  export async function parseJwt(
13
13
  encodedToken: string,
14
- issuer: string,
14
+ issuer: string | string[],
15
15
  audience: string,
16
16
  resolveKey: (decoded: DecodedJwt) => Promise<CryptoKey | null> = getKey
17
17
  ): Promise<JwtParseResult> {
@@ -78,12 +78,12 @@ export async function parseJwt(
78
78
  };
79
79
  }
80
80
 
81
- if (iss !== issuer) {
81
+ if (!(iss === issuer || (Array.isArray(issuer) && issuer.includes(iss)))) {
82
82
  return {
83
83
  valid: false,
84
84
  reason: `Invalid JWT issuer claim (iss) ${JSON.stringify(
85
85
  decoded.payload.iss
86
- )}. Expected "${issuer}".`
86
+ )}. Expected ${JSON.stringify(issuer)}.`
87
87
  };
88
88
  }
89
89
 
package/src/types.ts CHANGED
@@ -12,6 +12,7 @@ export interface JwtHeader {
12
12
  typ?: string;
13
13
  alg: string;
14
14
  kid: string;
15
+ jku?: string;
15
16
  }
16
17
 
17
18
  export interface RawJwt {