awslabs / aws-jwt-verify

JS library for verifying JWTs signed by Amazon Cognito, and any OIDC-compatible IDP that signs JWTs with RS256, RS384, RS512, ES256, ES384, and ES512
Apache License 2.0
621 stars 44 forks source link

[BUG] Cannot find module '#node-web-compat' after upgrading from 2.1.3 to 3.0.0 #67

Closed WtfJoke closed 2 years ago

WtfJoke commented 2 years ago

Describe the bug After upgrading from aws-jwt-verify from 2.1.3 to 3.0.0 I receive following stacktrace when executing a sample jest test:

jwtVerifier.spec.ts
  ● Test suite failed to run

    Cannot find module '#node-web-compat' from '../../node_modules/aws-jwt-verify/dist/cjs/https.js'

    Require stack:
      ..../node_modules/aws-jwt-verify/dist/cjs/https.js
      ..../node_modules/aws-jwt-verify/dist/cjs/jwk.js
      ..../node_modules/aws-jwt-verify/dist/cjs/jwt-rsa.js
      ..../node_modules/aws-jwt-verify/dist/cjs/index.js

Versions Which version of aws-jwt-verify are you using? 3.0.0 Are you using the library in Node.js or in the Web browser? Node.js If Node.js, which version of Node.js are you using? (Should be at least 14) 14 / 17 If Web browser, which web browser and which version of it are you using? If using TypeScript, which version of TypeScript are you using? (Should be at least 4) 4.6.3

To Reproduce If you can, please provide a minimal code example that reproduces the bug.

Currently I dont have a minimal code example.

ottokruse commented 2 years ago

This is an issue in Jest, see #66 on how to work around it.

Your +1 against the Jest issue would be appreciated, to (hopefully) get it prioritized: https://github.com/facebook/jest/issues/12270

WtfJoke commented 2 years ago

Thanks for your fast response! I've gave the jest issue a thumbs up and going to try the solution with the moduleNameMapper.