@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 +1 -1
- package/dist/parse.js +2 -2
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/parse.ts +3 -3
- package/src/types.ts +1 -0
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
|
|
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
|
|
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
package/package.json
CHANGED
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
|
|
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
|
|
86
|
+
)}. Expected ${JSON.stringify(issuer)}.`
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
|