Skip to content

Commit

Permalink
chore: remove trimmed challenge response
Browse files Browse the repository at this point in the history
  • Loading branch information
jjarvisp committed Oct 31, 2024
1 parent d2d4470 commit 8f46f05
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions packages/auth/src/providers/cognito/utils/signInHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ export async function handleMFASetupChallenge({
}: HandleAuthChallengeRequest): Promise<RespondToAuthChallengeCommandOutput> {
const { userPoolId, userPoolClientId, userPoolEndpoint } = config;

const trimmedChallengeResponse = challengeResponse.trim();

if (trimmedChallengeResponse === 'EMAIL') {
if (challengeResponse === 'EMAIL') {
return {
ChallengeName: 'MFA_SETUP',
Session: session,
Expand All @@ -168,7 +166,7 @@ export async function handleMFASetupChallenge({
};
}

if (trimmedChallengeResponse === 'TOTP') {
if (challengeResponse === 'TOTP') {
return {
ChallengeName: 'MFA_SETUP',
Session: session,
Expand All @@ -183,7 +181,7 @@ export async function handleMFASetupChallenge({
USERNAME: username,
};

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

if (isTOTPCode) {
const verifySoftwareToken = createVerifySoftwareTokenClient({
Expand All @@ -198,7 +196,7 @@ export async function handleMFASetupChallenge({
userAgentValue: getAuthUserAgentValue(AuthAction.ConfirmSignIn),
},
{
UserCode: trimmedChallengeResponse,
UserCode: challengeResponse,
Session: session,
FriendlyDeviceName: deviceName,
},
Expand Down Expand Up @@ -232,10 +230,10 @@ export async function handleMFASetupChallenge({
);
}

const isEmail = trimmedChallengeResponse.includes('@');
const isEmail = challengeResponse.includes('@');

if (isEmail) {
challengeResponses.EMAIL = trimmedChallengeResponse;
challengeResponses.EMAIL = challengeResponse;

const jsonReq: RespondToAuthChallengeCommandInput = {
ChallengeName: 'MFA_SETUP',
Expand Down

0 comments on commit 8f46f05

Please sign in to comment.