-
-
Notifications
You must be signed in to change notification settings - Fork 363
Description
What happened?
Summary
While starting a react project the Babel Loader fails to Parse: ./node_modules/jose/dist/browser/runtime/jwk_to_key.js
Issue is an unexpected token which is most likely the usage of ??.
Detailled Error
/node_modules/jose/dist/browser/runtime/jwk_to_key.js 121:36
Module parse failed: Unexpected token (121:36)
File was processed with these loaders:
- ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| keyUsages
| } = subtleMapping(jwk);const rest = [algorithm, jwk.ext ?? false, jwk.key_ops ?? keyUsages];
| const keyData = {
| ...jwk
I suspect the issue resides purely in the babel version, and i would be grateful if someone can say which babel-loader version is compatibel. Right now its.
"babel-loader": "^9.2.1",
Technical Details
Implementation of jose is as follows:
const publicKey = await jose.importSPKI(spki, 'RS512');
//behold the empty object in the third parameter. This is where you would put the issuer and audience if you wanted to check them.
// if its removed it doesnt complie. so lets keep it in for now.
const { payload } = await jose.jwtVerify(token, publicKey,{}); '
Relevant npm packages used:
"@types/node-jose": "^1.1.13",
"jose": "^5.9.6",
"babel-loader": "^9.2.1",
"@babel/plugin-proposal-nullish-coalescing-operator@7.18.6",
"@babel/core": "^7.21.3"
Personal Note
Thanks in advance for any tipps. I know this is really not the problem of jose, but asking in babel will not yield any help. So all I can is asking here. Thank you very much in advance. :)
Version
5.9.6
Runtime
Node.js
Runtime Details
node v22.12.0, npm 10.9.0
Code to reproduce
See Ticket Description.
const publicKey = await jose.importSPKI(spki, 'RS512');
//behold the empty object in the third parameter. This is where you would put the issuer and audience if you wanted to check them.
// if its removed it doesnt complie. so lets keep it in for now.
const { payload } = await jose.jwtVerify(token, publicKey,{});
This code is used in an React App in a JWTDecoderClass.Required
- I have searched the issues tracker and discussions for similar topics and couldn't find anything related.
- I agree to follow this project's Code of Conduct