Suh*_*pta 6 javascript amazon-web-services reactjs amazon-cognito
我收到以下错误:
TypeError: __WEBPACK_IMPORTED_MODULE_0_aws_sdk_global__.util.crypto.lib.
randomBytes is not a function
Run Code Online (Sandbox Code Playgroud)
当我尝试使用以下代码验证用户时,我写道:
import { CognitoUserPool, CognitoUserAttribute, CognitoUser, AuthenticationDetails }
from 'amazon-cognito-identity-js';
let authenticationDetails = new AuthenticationDetails({
Username: username,
Password: password
});
let userPool = new CognitoUserPool({
UserPoolId: 'us-east-1_1TXXXXXXbXX',
ClientId: '4da8hrXXXXXXXXXXXXmj1'
});
let cognitoUser = new CognitoUser({
Username: username,
Pool: userPool
});
// THE ERROR IS THROWN AS SOON AS IT HITS THE BELOW
// STATEMENT
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
console.log('access token + ' + result.getAccessToken().getJwtToken());
},
onFailure: function(err) {
console.log(err);
}
});
Run Code Online (Sandbox Code Playgroud)
这可能是什么原因?我错过了什么?
更新(2018年1月12日):
该amazon-cognito-identity-js开发者已经锁定了aws-sdk在v1.31.0版本,所以你不必降级aws-sdk了,刚刚升级包:
npm install amazon-cognito-identity-js@1.31.0 --save
Run Code Online (Sandbox Code Playgroud)
看起来aws-sdk包装有问题.这amazon-cognito-identity-js是您正在使用的包的依赖关系.
您可以尝试通过运行降级它:
npm install aws-sdk@2.177.0 --save
| 归档时间: |
|
| 查看次数: |
814 次 |
| 最近记录: |