Skip to content

Commit 8f46f05

Browse files
committed
chore: remove trimmed challenge response
1 parent d2d4470 commit 8f46f05

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

packages/auth/src/providers/cognito/utils/signInHelpers.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,7 @@ export async function handleMFASetupChallenge({
155155
}: HandleAuthChallengeRequest): Promise<RespondToAuthChallengeCommandOutput> {
156156
const { userPoolId, userPoolClientId, userPoolEndpoint } = config;
157157

158-
const trimmedChallengeResponse = challengeResponse.trim();
159-
160-
if (trimmedChallengeResponse === 'EMAIL') {
158+
if (challengeResponse === 'EMAIL') {
161159
return {
162160
ChallengeName: 'MFA_SETUP',
163161
Session: session,
@@ -168,7 +166,7 @@ export async function handleMFASetupChallenge({
168166
};
169167
}
170168

171-
if (trimmedChallengeResponse === 'TOTP') {
169+
if (challengeResponse === 'TOTP') {
172170
return {
173171
ChallengeName: 'MFA_SETUP',
174172
Session: session,
@@ -183,7 +181,7 @@ export async function handleMFASetupChallenge({
183181
USERNAME: username,
184182
};
185183

186-
const isTOTPCode = /^\d+$/.test(trimmedChallengeResponse);
184+
const isTOTPCode = /^\d+$/.test(challengeResponse);
187185

188186
if (isTOTPCode) {
189187
const verifySoftwareToken = createVerifySoftwareTokenClient({
@@ -198,7 +196,7 @@ export async function handleMFASetupChallenge({
198196
userAgentValue: getAuthUserAgentValue(AuthAction.ConfirmSignIn),
199197
},
200198
{
201-
UserCode: trimmedChallengeResponse,
199+
UserCode: challengeResponse,
202200
Session: session,
203201
FriendlyDeviceName: deviceName,
204202
},
@@ -232,10 +230,10 @@ export async function handleMFASetupChallenge({
232230
);
233231
}
234232

235-
const isEmail = trimmedChallengeResponse.includes('@');
233+
const isEmail = challengeResponse.includes('@');
236234

237235
if (isEmail) {
238-
challengeResponses.EMAIL = trimmedChallengeResponse;
236+
challengeResponses.EMAIL = challengeResponse;
239237

240238
const jsonReq: RespondToAuthChallengeCommandInput = {
241239
ChallengeName: 'MFA_SETUP',

0 commit comments

Comments
 (0)