【以下的问题经过翻译处理】 在 AuthenticatorForm() 中点击 signUpButton() 时出现标题为“Getting the captioned error message”的错误消息。看起来是一个非常简单直观的错误消息,但似乎无法确定问题出在哪里。
以下是我的 createAuthChallenge.js
const digitGenerator = require('crypto-secure-random-digit');
function sendSMS(phone, code) {
const params = {
Message: code,
PhoneNumber: phone,
};
return new AWS.SNS({apiVersion: '2010-03-31'}).publish(params).promise();
}
async function createAuthChallenge(event) {
if (event.request.challengeName === 'CUSTOM_CHALLENGE') {
const randomDigits = digitGenerator.randomDigits(6).join('');
const challengeCode = String(randomDigits).join('');
await sendSMS(event.request.userAttributes.phone_number, challengeCode);
event.response.privateChallengeParameters = {};
event.response.privateChallengeParameters.answer = challengeCode;
}
}
exports.handler = async (event) => {
createAuthChallenge(event);
};
这是相同项目的 package.json
{
"name": "XYZ",
"version": "2.0.0",
"description": "Lambda function generated by Amplify",
"main": "index.js",
"license": "Apache-2.0",
"devDependencies": {
"@types/aws-lambda": "^8.10.92"
},
"dependencies": {
"crypto-secure-random-digit": "^1.0.9"
}
}
我似乎找不到正确的解决方案,请问有人可以帮忙吗?