( jwt: string | Uint8Array, key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array | JWTVerifyGetKey, options?: JWTVerifyOptions, )
| 142 | ): Promise<types.JWTVerifyResult<PayloadType> & types.ResolvedKey> |
| 143 | |
| 144 | export async function jwtVerify( |
| 145 | jwt: string | Uint8Array, |
| 146 | key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array | JWTVerifyGetKey, |
| 147 | options?: JWTVerifyOptions, |
| 148 | ) { |
| 149 | const verified = await compactVerify(jwt, key as Parameters<typeof compactVerify>[1], options) |
| 150 | if (verified.protectedHeader.crit?.includes('b64') && verified.protectedHeader.b64 === false) { |
| 151 | throw new JWTInvalid('JWTs MUST NOT use unencoded payload') |
| 152 | } |
| 153 | const payload = validateClaimsSet(verified.protectedHeader, verified.payload, options) |
| 154 | const result = { payload, protectedHeader: verified.protectedHeader } |
| 155 | if (typeof key === 'function') { |
| 156 | return { ...result, key: verified.key } |
| 157 | } |
| 158 | return result |
| 159 | } |
searching dependent graphs…