AWS Cognito support within Expo SDK without ejecting

#1

When attempting to use the Cognito Identity SDK for JS [github:aws/amazon-cognito-identity-js] inside an Expo/CRNA app, you’ll soon find out that if calls to Cognito functions like authenticateUser are very slow, and may not work at all, or cause exp publish errors (like in my case).

This is due to the fact that Cognito uses slow, expense BigInteger functions and they happen very slowly or not at all when run in JavascriptCore.

(Please note, it’s not letting me add more than 2 links, so I had to format my URLs a bit oddly.)

There exist projects like this one that allow you to use Cognito more efficiently after ejecting (github:AirLabsTeam/react-native-aws-cognito-js). And it seems like the Expo team are aware of this issue because (a) an Expo fork of the amazon-cognito-identity-js repo exists at github:expo/amazon-cognito-identity-js, and (b) the expo-starter-aws app [which may have been abandoned] seems to use Cognito, too (https://github.com/expo/expo-starter-aws/blob/master/cognito-helper.js)

Of course, I’d prefer not to eject at all, but we are locked in to using Cognito for this application since it’s already used by our API and web app. Is it possible at all to either:

  1. Circumvent the slowness of the BigInteger processing in pure JS
  2. Create bindings to the device implementations of the BigInteger.nativeModPow functions in the Expo SDK so the fork of cognito-identity-js could use it (something like this):
const { computeModPow } = require('expo').Util.BigInteger

Thanks for your time. If this is something Expo accepts pull requests for, I’d be interested in submitting one. Incidentally, there’s a matching feature request for this here, created by another user: https://expo.canny.io/feature-requests/p/aws-cognito-biginteger

2 Likes

#2

:raised_hands: moreover I think that not only cognito user will benefit of this feature, I have found other complains : https://github.com/orhan/react-native-openpgp/issues/7

0 Likes

#3

Hey there! Good news - we have this feature almost ready to go, and it should be rolled out sometime in the middle of next week.

3 Likes

#4

Wonderful! Thank you!

0 Likes

#5

Hi guys, is there an update on this? Thx

0 Likes

#6

AWS Cognito support will be included with Expo SDK 25. We don’t have a time frame for it, but when SDK 25 is released we will announce it on https://blog.expo.io and on Twitter.

2 Likes

#7

Thanks a million, expo guys, for getting this out in SDK25! I made so much progress today and was able to implement most of my user management with Cognito and avoid ejecting my app!

The only aspect I am still scratching my head on is how to handle users updating their attributes. I don’t see any methods in the aws-amplify-react-native library that deals with this. It has everything for signup, sign in, forgot password, etc. but nothing to handle changing, say, a typo in your name.

1 Like

#8

Found the answer to my question in case someone looks for this:

This is not supported with aws-amplify as of yet, but they’re planning on adding it in the next release.

0 Likes

closed #9

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

0 Likes