question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Native crypto module could not be used to get secure random number.

See original GitHub issue

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 version 3.2.0.

It happens when I use the CognitoUser.authenticateUser method. Any updates on this issue?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:18
  • Comments:64 (25 by maintainers)

github_iconTop GitHub Comments

8reactions
mattiLeBlanccommented, Nov 26, 2020

I am still experiencing this error with Angular 11 when running ng-serve, and @aws-amplify/auth.

Warning: ./node_modules/amazon-cognito-identity-js/es/utils/cryptoSecureRandomInt.js
Module not found: Error: Can't resolve 'crypto' in '/Users/mattijs/www/earnr/earnr-dashboard/node_modules/amazon-cognito-identity-js/es/utils'

I have tried installing "amazon-cognito-identity-js": "^4.5.4-unstable.6",

"compilerOptions": {
    "baseUrl": "./",
    "paths": {
      "crypto": [
        "../../node_modules/crypto-js"
      ]
    },

and installing latest ampliy/core, auth and pubsub. Nothing works.

I can’t use require, TS compiler is freaking out.

4reactions
amhinsoncommented, Nov 6, 2020

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 unstable tag, and we will likely have a release to latest next week.

Can you verify that unstable works for you?

Also, with that fix, it is no longer required to add global.crypto = require('crypto') in your code, as this will handle that automatically.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Native crypto module could not be used to get secure random ...
Seems like the error was thrown from below code lines (which were added on v3.2.0 ) in core.js . /* * Cryptographically secure...
Read more >
Node.js: Native crypto module could not be used to get secure ...
3" for auth and stumbled over the error: Error: Native crypto module could not be used to get secure random number. when using...
Read more >
Defender-relay-client - Error: Native crypto module could not ...
Environment $ node -v v10.15.0. $ npm -v 6.14.5. :memo: Details Error: Native crypto module could not be used to get secure random...
Read more >
Crypto module breaking - Questions - n8n community
I'm trying to create a credential and getting the following error. ... "stack": "Error: Native crypto module could not be used to get...
Read more >
Crypto.getRandomValues() - Web APIs | MDN
The pseudo-random number generator algorithm (PRNG) may vary ... getRandomValues() is not guaranteed to be running in a secure context.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found