Hi,
I'm trying to change a user password when they login for the first time and receive the challengeName: NEW_PASSWORD_REQUIRED
and in the console their Confirmation Status is Force change password
. I'm using the adminRespondToAuthChallenge
function and I'm passing the parameters:
{
ChallengeName: "NEW_PASSWORD_REQUIRED",
ClientId: process.env.AWS_CLIENT_ID,
UserPoolId: process.env.AWS_IDENTITY_POOL_ID,
ChallengeResponses: {
USERNAME: USER_ID_FOR_SRP,
NEW_PASSWORD: proposedPassword,
},
Session: session,
}
and my function looks like:
const response =
await CognitoIdentityServiceProvider.adminRespondToAuthChallenge(parameters).promise();
res.status(200).json({ status: "success", data: response });
When I post a request I get the error:
TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type string or an instance of ArrayBuffer, Buffer, TypedArray, DataView, KeyObject, or CryptoKey. Received undefined
at new NodeError (node:internal/errors:371:5)
at prepareSecretKey (node:internal/crypto/keys:570:11)
at new Hmac (node:internal/crypto/hash:132:9)
at Object.createHmac (node:crypto:162:10)
at Object.hmac (C:\Users\joshh\coding_bootcamp\projects\palace-drum-clinic-server\node_modules\aws-sdk\lib\util.js:436:30)
at Object.getSigningKey (C:\Users\joshh\coding_bootcamp\projects\palace-drum-clinic-server\node_modules\aws-sdk\lib\signers\v4_credentials.js:62:8)
at V4.signature (C:\Users\joshh\coding_bootcamp\projects\palace-drum-clinic-server\node_modules\aws-sdk\lib\signers\v4.js:98:36)
at V4.authorization (C:\Users\joshh\coding_bootcamp\projects\palace-drum-clinic-server\node_modules\aws-sdk\lib\signers\v4.js:93:36)
at V4.addAuthorization (C:\Users\joshh\coding_bootcamp\projects\palace-drum-clinic-server\node_modules\aws-sdk\lib\signers\v4.js:35:12)
at C:\Users\joshh\coding_bootcamp\projects\palace-drum-clinic-server\node_modules\aws-sdk\lib\event_listeners.js:333:20 {
code: 'ERR_INVALID_ARG_TYPE',
retryDelay: 58.59727940103505
The user is able to login so I can get the session
and USER_ID_FOR_SRP
variables and my AWS variables are correct since I'm using them in other functions with no issues. I'm not sure what the "key" argument is or how to fix this
Thanks