awslabs / aws-jwt-verify

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

Browser support #145

Closed leenabora closed 8 months ago

leenabora commented 8 months ago

Question Hi. I want to use this lib as pure js to be used in browser. As documented, it support browser. But I didn't get a luck with it. I also tried browersify, esbuild but no luck.

Versions Which version of aws-jwt-verify are you using? I tried 4.0.0, it gave some error. Hence downgraded to "aws-jwt-verify": "^2.1.3",

Are you using the library in Node.js or in the Web browser? Web browser

If Web browser, which web browser and which version of it are you using? Chrome, Firefox

leenabora commented 8 months ago

when i user browserify, i get following error: TypeError: The "listener" argument must be of type Function. Received type object

leenabora commented 8 months ago

when i upgrade the library version to 4.0.0, i get a error during browsification:

Error: Can't walk dependency graph: Cannot find module '#node-web-compat' from '/node_modules/aws-jwt-verify/dist/cjs/jwt-rsa.js'

ottokruse commented 8 months ago

Hi @leenabora !

Best use esbuild or webpack they should both work with the latest version of this lib out of the box. rollup needs a bit of extra config. Here is a Vite example showing how to use the lib in web, with the additional rollup config: https://github.com/awslabs/aws-jwt-verify/tree/main/tests/vite-app

If that doesn't help you please provide us steps to reproduce, showing exactly what you are trying.

leenabora commented 8 months ago

you are right. It worked with esbuild. Thanks for your help.

ottokruse commented 8 months ago

Awesome! You're welcome