问题描述
我将定制挑战身份验证与AWS Amplify,Cognito和React Native结合使用,实现了无密码身份验证流程。该应用程序运行正常,但是由于某些原因,在添加了两个新库后,身份验证部分停止工作。
当我尝试运行此部分时:
import {Auth} from 'aws-amplify';
const user = await Auth.signIn(username); // This part its OK
const signedUser = await Auth.sendCustomChallengeAnswer(user,confirmationCode); // This one breaks
我收到的消息是这样的:
TypeError: (0,_getRandomBase.default) is not a function
有关该项目的更多信息:
- “ aws-amplify”:“ 3.0.21”,
- “ aws-amplify-react-native”:“ 4.2.2”,
- “ amazon-cognito-identity-js”:“ 4.3.3”,
- “ @ react-native-community / netinfo”:“ 5.9.5”,
我的index.js文件:
import Amplify from 'aws-amplify';
Amplify.configure({
Auth: {...},API: {...},PushNotification: {...},})
在Cognito中,我设置了所有必需的触发器,例如:
- CreateAuthChallenge,=>已达到
- DefineAuthChallenge,=>这也是
- VerifyAuthChallenge,=>从来没有达到过!
解决方法
最后,我不确定这里出了什么问题,但是在将AWS Amplify更新到最新版本以及其余库之后,它们开始工作了。
,我遇到了同样的错误,并通过更新amazon-cognito-identity-js依赖关系解决了该问题。