我收到以下错误:
TypeError: __WEBPACK_IMPORTED_MODULE_0_aws_sdk_global__.util.crypto.lib.
randomBytes is not a function
当我尝试使用我编写的以下代码对用户进行身份验证时:
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);
}
});
这可能是什么原因?我错过了什么?