MCPcopy
hub / github.com/panva/jose / jwtVerify

Function jwtVerify

src/jwt/verify.ts:144–159  ·  view source on GitHub ↗
(
  jwt: string | Uint8Array,
  key: types.CryptoKey | types.KeyObject | types.JWK | Uint8Array | JWTVerifyGetKey,
  options?: JWTVerifyOptions,
)

Source from the content-addressed store, hash-verified

142): Promise<types.JWTVerifyResult<PayloadType> & types.ResolvedKey>
143
144export 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}

Callers 5

remote.test.tsFile · 0.85
sign.test.tsFile · 0.85
verify.test.tsFile · 0.85
numericDateNumberFunction · 0.85
failingNumericDateFunction · 0.85

Calls 2

compactVerifyFunction · 0.85
validateClaimsSetFunction · 0.85

Tested by 2

numericDateNumberFunction · 0.68
failingNumericDateFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…