AirLabsTeam / react-native-aws-cognito-js

React Native AWS Cognito JS SDK
Other
134 stars 19 forks source link

_awsSdkReactNative.util.crypto.lib.randomBytes is not a function #21

Closed snowsea-dev closed 6 years ago

snowsea-dev commented 6 years ago

I am developing React Native Expo app and tried to use authenticate. And I got the error as follow. _awsSdkReactNative.util.crypto.lib.randomBytes is not a function. (In '_awsSdkReactNative.util.crypto.lib.randomBytes(128)', '_awsSdkReactNative.util.crypto.lib.randomBytes' is undefined)

tobiastornros commented 6 years ago

There is a problem with amazon-cognito-identity-js lib. Workaround and more info here: https://github.com/aws/amazon-cognito-identity-js/issues/646

dannyshisler commented 6 years ago

I've just had this problem after upgrading a few libraries.

I've fixed it by deleting the aws-sdk folders from both my node_modules folder and the node_modules folder under the react-native-aws-cognito-js package (I had it in both places for some reason).

I've added aws-sdk@2.177.0 which seems to be the latest working package identified in the issue (https://github.com/aws/amazon-cognito-identity-js/issues/6460) that @tobiastornros referenced.

FWIW I've also added the following section to my package.json file to avoid unintentional upgrade of the aws-sdk package until this issue is fixed.

"resolutions": {
    "aws-sdk": "2.177.0"
  }

I've never used this before but according to https://yarnpkg.com/lang/en/docs/cli/install/#toc-yarn-install-flat this should force a single specific version of a package to always been installed (when using yarn) rather than multiple potentially conflicting versions.

snowsea-dev commented 6 years ago

On Mon, Jan 22, 2018 at 4:53 AM Danny Shisler notifications@github.com wrote:

I've just had this problem after upgrading a few libraries.

I've fixed it by deleting the aws-sdk folders from both my node_modules folder and the node_modules folder under the react-native-aws-cognito-js package (I had it in both places for some reason).

I've added aws-sdk@2.177.0 which seems to be the latest working package identified in the issue ( https://github.com/aws/amazon-cognito-identity-js/issues/6460) that @tobiastornros https://github.com/tobiastornros referenced.

FWIW I've also added the following section to my package.json file to avoid unintentional upgrade of the aws-sdk package until this issue is fixed.

"resolutions": { "aws-sdk": "2.177.0" }

I've never used this before but according to https://yarnpkg.com/lang/en/docs/cli/install/#toc-yarn-install-flat this should force a single specific version of a package to always been installed (when using yarn) rather than multiple potentially conflicting versions.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AirLabsTeam/react-native-aws-cognito-js/issues/21#issuecomment-359297834, or mute the thread https://github.com/notifications/unsubscribe-auth/AYhYsbCGsb7OE1Z1a9vROrVQUrRbGBf9ks5tM9v5gaJpZM4RYlqt .

Thanks. It works now.

anbublacky commented 6 years ago

It worked for me by removing aws-sdk folder from node_modules. Then installed aws-sdk version 2.177.0 (npm install aws-sdk@2.177.0)

Thanks @SnowSea-Dream

panuhorsmalahti commented 6 years ago

This error has been fixed in amazon-cognito-identity-js@2.0.0, which is available from npm.

https://github.com/aws/amazon-cognito-identity-js/issues/646#issuecomment-365139644 https://www.npmjs.com/package/amazon-cognito-identity-js

snowsea-dev commented 6 years ago

Close

panuhorsmalahti commented 6 years ago

Why was this issue closed? As far as I know, the fix from amazon-cognito-identity-js@2.0.0 has not been ported to react-native-aws-cognito-js yet.

ephor commented 6 years ago

I have aws-sdk@2.224.1 installed, but error is not gone. Maybe @panuhorsmalahti is right?

rahulbhankar786 commented 6 years ago

thanks @anbublacky you save my day.

NavneetSandhu commented 5 years ago

Getting the same issue from past few days and badly stuck with this issue, please help me out.

ISSUE: _awsSdkReactNative.util.crypto.lib.randomBytes is not a function

React Native version is 0.59.5

Solutions will be highly appreciated.

"aws-amplify": "^1.0.4", "aws-sdk": "^2.513.0", "jetifier": "^1.6.4", "react": "16.8.3", "react-native": "0.59.5", "react-native-aws-cognito-js": "0.0.7",

Thanks

NavneetSandhu commented 5 years ago

Can anyone let me know how to make aws-sdk working with react-native 0.59.5 version? @SnowSea-Dream @tobiastornros @dannyshisler @anbublacky @panuhorsmalahti

Thanks