panva / jose

JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes
MIT License
5.62k stars 315 forks source link

Reference error: Key is not defined #676

Closed karannakraTR closed 5 months ago

karannakraTR commented 5 months ago

What happened?

I am trying to verify my JWT token using the method jose.jwtVerify which expects token as first argument and key as a second argument. But this function throws the error Reference error: key is not defined.

Possible reason of the bug:

SCREEN SHOTS FROM V5.3.0

image

When jose is compiled, The function falttenVerify changes the argument name of key to z but on line no.84 code is still trying to find the variable named key which is now changed to z Due to which it throws the error key is not found.

image

image

I don't see the re-assignment of variable z to key anywhere before it's usage.

But when I downgrade the version from 5.3.0 to 5.2.4. It works just fine and the argument is now not changed to z and when requested in the code expression below it is able to find that variable.

image

Version

v5.3.0

Runtime

Node.js

Runtime Details

Node: V18.20.2, NPM: V10.5.0, PNPM: V9.1.0, MacOS: 13.6.7 (22G720)

Code to reproduce

const JWKS = jose.createRemoteJWKSet(new URL('https://www.googleapis.com/oauth2/v3/certs'))

const { payload, protectedHeader } = await jose.jwtVerify(jwt, JWKS, {
  issuer: 'urn:example:issuer',
  audience: 'urn:example:audience',
})
console.log(protectedHeader);
console.log(payload);

Required

panva commented 5 months ago

Hello @karannakraTR

please provide a reproduction sample project repo where this can be reproduced with steps on how to build your minified bundle etc.