-
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
Auth: Native crypto module could not be used to get secure random number. #4886
Comments
Also getting this error when calling signIn api inside jest: const user = await Auth.signIn(username, pass); win10 reverted to v1 as a temporary workaround
|
Getting same error
@tommy-dev Thanks for sharing your workaround |
this is due to crypto-js/core.js doing this @tommy-dev |
@vichoconejeros should be the latest auth and core modules, since I installed them in a fresh project today "@aws-amplify/auth":"^2.1.5",
"@aws-amplify/core": "^2.2.4", |
I am getting this same error using the |
Get the same error when use And I cannot signin and get cognito token any more, is there any work around? Error: Native crypto module could not be used to get secure random number. |
So as @vichoconejeros pointed out. This is a There is an open issue at |
Another easy solution is Add resolution in your package.json remove
|
Just a reminder. A new crypto-js version 3.2.1. has been released just 2 hours ago. All working on my side. |
You may need to clear your cache before running install again! |
Just for others who chance across this, it does appear that the fix with 3.2.1 makes it so that crypto-js isn't usage with ReactNative, however the resolutions solution appear to work at this time. The error you get when trying to use 3.2.1 with RN/expo
|
it works! |
@mdshaner you are right,"resolutions": { The package at "node_modules/crypto-js/core.js" attempted to import the Node standard library module "crypto". It failed because React Native does not include the Node standard library. Read more at https://docs.expo.io/versions/latest/introduction/faq/#can-i-use-nodejs-packages-with-expo whats is the solution |
@ptrobert I'm getting the exact same error. Because of it, I'm unable to use Amplify in my expo project. |
crypto-js released 3.3.0 which solves |
use this resolution for react native, expo "resolutions": { |
This is the solution. you can close this issue |
There have been several issues with
Closing since upgrading to the latest versions of Amplify or specifying |
I'm seeing this error again in the latest release of Adding
to my package.json and removing EDIT: forgot I was using NPM instead of Yarn. But it sounds like based on a comment below that this would still happen if I used yarn. |
Yeah I was playing around with [email protected] and got this error today. I searched the error and finally got here. I tried resolutions with yarn and even with npm-force-resolutions as npm doesn't support resolutions. it's very frustrating. |
Dang, I was just about to try changing my package manager to yarn. :( If it's any help, I'm running a typescript file using |
@tqhoughton I just downgraded to 4.5.1 and seems start working again |
@bidva do you know what version of |
@tqhoughton no, sorry but you can try to test decrementally |
Downgraded to |
Can you share the call stack of the error you're receiving? And can you also share details of your operating environment? Sounds like @tqhoughton you're running under node - what version? |
@tqhoughton @bidva we just merged a fix that should address the issue you're having in Node. Can you try installing all Amplify packages you are using again with the You will also need to set the |
I'm running |
@Benzer1406 could you try using the |
@amhinson I just tried using the I'm using a serverless.com framework app, that uses the aws-nodejs-typescript template. So it is basically implementing the authentication in a nodejs app that I want to deploy in a serverless architecture (API Gateway, Lambda, ...). I'm not sure if it's helpful, but I run into the error when invoking the lambda function locally, I haven't deployed the app to AWS yet, but I guess that shouldn't make a difference. Trying to set crypto to global results in the following error: |
@amhinson Thanks for your help. Indeed, I had to install the unstable tag on the project root and the service root folder. And as you pointed out, I had not put that line at the very top of the files that imported |
@Benzer1406 ok great! We should be getting a release out in the next day or two. |
I tried doing this, and I'm still getting the same error. This is my call stack:
I'm using node 12.13.1, running on an Ubuntu distribution accessed via bash.exe on my Windows 10 PC. |
@tqhoughton Do you have |
🤦 I did not have that. Looks like it's working now with the unstable build. Here is my file for those who want to see what I had to add:
|
Ok great! Here is an open issue you can track to see when it gets released to |
"amazon-cognito-identity-js": "^4.4.0", and adding global.crypto = require('crypto') on top of my main.ts worked for me |
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: |
My Auth.SignIn() works fine in my react app however when I want to test it with react-testing-library and Jest, using Auth.SignIn() in the test I am still getting |
Seem to be having a similar issue when attempting to use amplify from AWS. It keeps failing on the "import { API, graphqlOperation } from "aws-amplify";" line with error "The package at "node_modules/@aws-amplify/auth/node_modules/crypto-js/core.js" attempted to import the Node standard library module "crypto"". I know that the crypto module is deprecated, but I';m not sure why AWS amplify is trying to access it. Any ideas? |
@StephenA1 use the solution proposed by @ptrobert above: "scripts": {
"preinstall": "npx npm-force-resolutions",
} |
As @bunatl, signin works well in my react app but when i try to call it in a test file I get this error. Is there some news about it ? |
Using Finally got passed this by adding this to my package.json and then running
|
I'm getting
Native crypto module could not be used to get secure random number.
call
Auth.signIn
sample code
let user = await Auth.signIn({username:email, password:password})
Expected behavior
cognitoUser should be returned
Callstack
Native crypto module could not be used to get secure random number.
...
The text was updated successfully, but these errors were encountered: