cognito-jwt-verifier icon indicating copy to clipboard operation
cognito-jwt-verifier copied to clipboard

TypeError: getCurves is not a function

Open mauryakrishna opened this issue 4 years ago • 5 comments

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] image

Could not find any solution for this seems I am first to encounter this.

mauryakrishna avatar Dec 20 '20 10:12 mauryakrishna

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 avatar Dec 20 '20 11:12 maximivanov

@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.

mauryakrishna avatar Dec 20 '20 13:12 mauryakrishna

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 affecting cognito-jwt-verifier
  • update fetchKeyStore function to work in both node and browser environments (currently it uses https core node module). In the browser env it probably should use fetch instead.

I've started working on the new version but I can't tell when it's going to be ready.

maximivanov avatar Dec 21 '20 02:12 maximivanov

@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 avatar Dec 23 '20 01:12 maximivanov

@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.

mauryakrishna avatar Dec 28 '20 17:12 mauryakrishna