-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Native crypto module could not be used to get secure random number. #7098
Comments
@Benzer1406 Are you still experiencing this issue after using the |
@amhinson No, that solved it for me. If you want to you can close the issue when you released the fix on the stable version, leaving a comment here to let everybody know. |
Ok will do. Thanks for the follow up! I will update the issue once it is released to For anyone seeing the same issue using Node, you can get around it by using |
@amhinson I used unstable tag for Error: Native crypto module could not be used to get secure random number. |
@manojkumarg16 Could you provide some more details so I can try to reproduce the issue you're seeing? A code snippet of the file you're working with would help. |
@amhinson Here is the code, a simple function const login = (email_id, pass) => { } |
Can you try assigning |
Also, what version of Node are you using? |
@amhinson I'm using typescript , so type need to be denoted, that's the reason I used it as globalAny:any = global. I'm using node v12.18.3 |
Could you try doing that anyway, perhaps just with a Also, can you also delete your |
@amhinson tried as you said, but nothing turned up. Still issue remains |
Can you share your |
{ |
I'm having some trouble trying to replicate the issue you're seeing unfortunately 😕 . I just created a new Serverless framework Express app using some of the same code snippets you provided and I am able to successfully authenticate a user. Would you be able to look into creating a basic Express app that you could share with me to show the behavior you're seeing, and then provide some reproduction steps? |
Week back I wrote a rough code snippet of same which was working fine. Now I just reused the snippet which is throwing error, quite strange :( |
@Benzer1406 This fix is now available with @manojkumarg16 Can you try with the latest version to see if any behavior changes? |
@amhinson tried with latest version of crypto , still issue persists |
@manojkumarg16 can you try with |
@amhinson I tried with "amazon-cognito-identity-js": "4.5.3" I am still getting the same issue . |
@pathiyilnaveen Could you share your code or a small reproducible example so we can try to replicate the issue you are seeing? |
I am using amplify on my unit tests
Below is my dependencies in package.json "dependencies": { here is the error i get
0 passing (13ms)
npm ERR! code ELIFECYCLE |
@pathiyilnaveen Can you add |
I already have |
@Ladvace Would you be able to share a small example repo that shows the behavior you're seeing? I've really been trying hard to replicate the issues you are seeing, but there are just just many different factors that might be contributing to the problem. |
I hope this will be fine: https://pastebin.com/MYxyuMHk |
@Ladvace Thank you, that will help a lot! Is this just a standard Express app? |
yes. the
|
Thanks again for the reproduction sample @Ladvace! I have made a small adjustment in this PR that should fix the behavior you're seeing. It is available to use now with the Can you verify that Also, with that fix, it is no longer required to add |
ok, fixed!, thanks so much |
@amhinson - I too can confirm "unstable" with no additional |
Here works too. |
Use aws-amplify@unstable, and include global.crypto = require('crypto') at the top of signin modules. aws-amplify/amplify-js#7098
How to add global.crypto = require('crypto') in build file? i mean after bundling we can do it manually, how to do before bundle starts ? |
Please use the package This ^ sysmbol will always find latest version of the package and it will break if any unstable version released or any errors. |
I was facing this issue when I was working with amazon cognito in nodejs. After so many hit and trial i found the solution, just change the amazon-cognito-identity-js version to : "amazon-cognito-identity-js": "^4.5.4-unstable.6" and now it is working for me, hope it will save your time and will work for you all who is facing this issue. |
Update: |
I am still experiencing this error with Angular 11 when running
I have tried installing
and installing latest ampliy/core, auth and pubsub. Nothing works. I can't use require, TS compiler is freaking out. |
+1 for mattiLeBlanc - starting a new vanilla Angular 11 project, installing Amplify and Auth |
@mjpaton I fixed/hacked it by doing the following:
Adding the following packages to my package.json:
and added to tsconfig:
I am still getting warnings: but Auth seems to be working. |
@mattiLeBlanc do you mind posting your full tsconfig. I'm hoping something within that is a clue to get this working. Also using Angular 11, |
Pretty much standard generated by angular, except for the paths.
|
@mattiLeBlanc Are you seeing an Error that crashes your app, or are you just seeing the warning in the console? I think that the warning might just be coming from this amplify-js/packages/amazon-cognito-identity-js/src/utils/cryptoSecureRandomInt.js Lines 18 to 23 in e98217c
With that said, I don't think it should impact your app in any way besides the warning showing. I am going to look into what it would take to suppress that warning. |
@amhinson I am currently seeing errors during build and
If I leave that out the app crashes. |
Yep confirmed I'm still getting about a dozen warnings in the console - @amhinson any update on how they can be suppressed if they truly are spurious for web? I've not noticed an impact aside from them blowing up the console - auth works, refreshing tokens work, API calls work to cognito secured endpoints. |
@mjpaton This appears to just be limited to Angular apps from my testing. As you mentioned, there should be no effect on the functionality here. I'll look into what we can do on our side to suppress and superficial warnings. |
It appears that there may not be much we can do on our side with this. The implementation we have is similar to Here is one potential solution you can add in your app to suppress the warning: https://stackoverflow.com/a/54162447 |
In `
` |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Describe the bug
I'm using the serverless.com framework together with:
"amazon-cognito-identity-js": "^4.5.2"
and I still get the error:Error: Native crypto module could not be used to get secure random number.
even though it was supposed to be fixed in version3.2.0
.It happens when I use the
CognitoUser.authenticateUser
method. Any updates on this issue?The text was updated successfully, but these errors were encountered: