cognito-jwt-verifier
cognito-jwt-verifier copied to clipboard
TypeError: getCurves is not a function
Description
I just installed this package and starting my app. Before it could invoke the method it fails at import statement I think. It fails to start the app. I tried via import
and require
both but made no difference.
[Description of the bug or feature]
Could not find any solution for this seems I am first to encounter this.
Hey @mauryakrishna
Are you trying to run it in a browser? This library uses https://github.com/panva/jose which in turn uses node's crypto
module. It may not be available in the browser. It's been reported here https://github.com/panva/jose/issues/72.
New version of jose
was released recently and it no longer has any dependencies. I will update cognito-jwt-verifier
to use jose
v3 which should resolve the issue.
@maximivanov Thanks a lot for quick response.
Yes, I was running it in browser in React application. In the mean time you update the jose
to v3
can I do some work around to try out for my purpose? Just checking I could save some time and when it updated with new version I can directly use it.
Unfortunately I don't think there's a quick workaround. If you want to play with it, you'd need to
- upgrade
jose
to the latest version and make sure its breaking changes are not affectingcognito-jwt-verifier
- update
fetchKeyStore
function to work in both node and browser environments (currently it useshttps
core node module). In the browser env it probably should usefetch
instead.
I've started working on the new version but I can't tell when it's going to be ready.
@mauryakrishna if it's still relevant, I've just published a new version (beta tag for now).
You can try it with npm i @southlane/cognito-jwt-verifier@beta
Note if your React app is built with create-react-app
it won't work unfortunately, since CRA is still using webpack v4 and in order to bundle underlying jose
library webpack v5 is required.
I managed to test it with React though (not using CRA): https://github.com/maximivanov/cognito-jwt-verifier/tree/feat/upgradeToJoseV3/example/react
Let me know how it goes (or if you found another solution!).
Cheers.
@maximivanov Thanks for taking it so quick. I needed some solution urgently so I went ahead with other solution. But yes we are using CRA v4 so again I wont be able to use this one.