amplify-js: Unable to use signIn - Cannot read property 'computeModPow' of undefined
Do you want to request a feature or report a bug? Report a Bug
What is the current behavior?
Unable to use signIn, fails with the error: Cannot read property 'computeModPow' of undefined
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn’t have dependencies other than AWS Amplify.
I have read other issues regarding this that discuss linking amazon-cognito-identity-js. I have linked the library using react-native link amazon-cognito-identity-js, and it appears successful. However, when I try and use the signIn function, I still receive the error. Here are the logs from the link.
rnpm-install info Linking amazon-cognito-identity-js ios dependency
rnpm-install info Platform 'ios' module amazon-cognito-identity-js has been successfully linked
rnpm-install info Linking amazon-cognito-identity-js android dependency
rnpm-install info Platform 'android' module amazon-cognito-identity-js has been successfully linked
Tried uninstalling the app, restarting packagers and debugger, etc.
What is the expected behavior?
I expect the signIn function to work.
Which versions of Amplify, and which browser / OS are affected by this issue? Did this work in previous versions?
These are the aws plugins that I currently have installed:
"aws-amplify": "0.2.14",
"aws-amplify-react-native": "0.2.7",
"aws-appsync": "^1.0.3",
"aws-appsync-react": "^1.0.2",
"aws-sdk": "^2.173.0",
Here is my RN info:
Environment:
OS: macOS High Sierra 10.13.3
Node: 8.10.0
Yarn: 1.5.1
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed)
react: 16.3.0-alpha.1 => 16.3.0-alpha.1
react-native: 0.54.2 => 0.54.2
Full logs with log level set to DEBUG
[DEBUG] 00:36.981 SignIn - Sign In for testuser
ConsoleLogger.js:84
TypeError: Cannot read property 'computeModPow' of undefined
YellowBox.js:82
at BigInteger.nativeModPow [as modPow] (/Users/justin/VSCodeProjects/MissionaryTrainingApp/.vscode/.react/index.bundle:143326:18)
at AuthenticationHelper.calculateA (/Users/justin/VSCodeProjects/MissionaryTrainingApp/.vscode/.react/index.bundle:143634:16)
at AuthenticationHelper.getLargeAValue (/Users/justin/VSCodeProjects/MissionaryTrainingApp/.vscode/.react/index.bundle:143572:16)
at new AuthenticationHelper (/Users/justin/VSCodeProjects/MissionaryTrainingApp/.vscode/.react/index.bundle:143554:12)
at CognitoUser.authenticateUserDefaultAuth (/Users/justin/VSCodeProjects/MissionaryTrainingApp/.vscode/.react/index.bundle:145268:36)
at CognitoUser.authenticateUser (/Users/justin/VSCodeProjects/MissionaryTrainingApp/.vscode/.react/index.bundle:145258:23)
at /Users/justin/VSCodeProjects/MissionaryTrainingApp/.vscode/.react/index.bundle:153869:22
at tryCallTwo (/Users/justin/VSCodeProjects/MissionaryTrainingApp/.vscode/.react/index.bundle:14110:7)
at doResolve (/Users/justin/VSCodeProjects/MissionaryTrainingApp/.vscode/.react/index.bundle:14274:15)
at new Promise (/Users/justin/VSCodeProjects/MissionaryTrainingApp/.vscode/.react/index.bundle:14133:5)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 31 (4 by maintainers)
For RN 0.60.4 for iOS using Cocoa Pods with a Podfile containing:
if
amazon-cognito-identity-idis not installed as a direct dependency of the npm project, it is not included independenciesin the output ofreact-native-configwhich is the basis for inclusion viause_native_modules.Just running
react-native link amazon-cognito-identity-jsresults in:The following:
resolved the issue for me.
Okay so that was the problem: even though RN says it linked
amazon-cognito-identity-jscorrectly, it did not link iOS correctly. To fix I did the following:node_modules/amazon-cognito-identity-js/ios/RNAWSCognito.xcodeprojto theLibrariesfolder in the XCode project.Build Phasesand draggedlibRNAWSCognito.ato theLink Binary with Librariessection. This is found in XCode when you expandLibraries > RNAWSCognito.xcodeproj > Products.My next question would be: is this a React Native problem or potentially a problem with the
amazon-cognito-identity-jslibrary? I don’t personally know much about how linking is done. I haven’t had many issues with other libraries in this regard.@BenjaminWatts after you link using
react-native link amazon-cognito-identity-jstry uninstalling your app in android andreact-native run-androidagain.For anybody running into this error using both, react-native-navigation and aws-amplify, you need to manually link the
RNAWSCognitoPackage()in the MainApplication.java file:I spent countless hours fixing this, so I hope it helps someone.
Thanks @MikaelStenstrand . You saved my day.
@brickmaker17 I think you are using cocoa pods.
It works for me.
@grifotv No,
@aws-amplify/authhasamazon-cognito-identity-jsas a dependency; you just need to runreact-native link amazon-cognito-identity-js.react-native linkdid not solve the problem, but runningreact-native link amazon-cognito-identity-jsfixed it. Thx!@jdeanwaite this is often caused by some react-native link issues. One of the things you need to check is that whether this module is correctly linked in to the android/ios native module. For example, you can check the
MainApplication.javaunderandroid/app/src/.../to see there is oneRNAWSCognitoPackage()underMainReactPackage. Hope that could help you.did you try
react-native link amazon-cognito-identity-jsinstead ofnpm link amazon-cognito-identity-js?It’s related to #194 , did u check this?
After a very frustrating afternoon following everyone’s suggestions, the only fix I found was to add the following lines to my app’s MainApplication.java. I don’t know why linking didn’t automatically generate these lines properly, but I’m excited to move on to other bugs 😃
import com.amazonaws.RNAWSCognitoPackage; … new RNAWSCognitoPackage()
The first line obviously goes along with other imports, and the second gets included within: protected List<ReactPackage> getPackages() { return Arrays.<ReactPackage>asList( HERE ) }
@MikaelStenstrand life saver!
Both
amazon-cognito-identity-jsandaws-amplifypackages need to be installed?