0

I have a problem integrating library "amazon-cognito-identity-js" into react native. The authenticateUser function is too slow depending on the device:
Iphone XS: 40 seconds
Samsung galaxy A11: 70 seconds
The problem is probably in the post-processing in the library because the image below shows the api response time is only about 200 milliseconds.
I've been searching for a solution for weeks, please can anyone come across this situation and can post solution.

"react-native": "0.66.3",
"@react-native-async-storage/async-storage": "^1.17.10",
"aws-amplify": "^4.3.34",
"aws-amplify-react-native": "^6.0.5",
"amazon-cognito-identity-js": "^5.2.10",

This is response time

Hai Quan Le
  • 396
  • 6
  • 11
  • 1
    Did you check github issues for this repo? I see a bunch of "authenticateUser is very slow" topics from several years ago. https://github.com/amazon-archives/amazon-cognito-identity-js/issues/411 – James Sep 30 '22 at 19:30
  • i found it and understand that this is likely to be a modpow computability issue. But I can't find any specific solution for react native, do you have any suggestions – Hai Quan Le Oct 03 '22 at 11:19

1 Answers1

0

After searching for few day, finally I found the solution simply change:
import {CognitoUser} from "amazon-cognito-identity-js"
to:
import {CognitoUser} from "amazon-cognito-identity-js/enhance-rn.js"
Because the entry point of lib is js module instead of native module. So the time to compute some functions like modpow with BigInteger by js is much larger than native module => slow

Hai Quan Le
  • 396
  • 6
  • 11