I understand that you have created a custom authentication flow using AWS Cognito authenticateUser() method to send a MFA code via email through the cognito triggers. Further, you would like to perform a setState operation, where you can get to customChallenge callback to get the MFA input from the end user via a textbox, and then submit the MFA code using sendCustomChallengeAnswer() without exiting the authenticateUser block.
I would also like to add here that, the above solution has been a popular ask. More information on the same can be found in the below shared link:
However, as this functionality is not supported directly by the "amazon-cognito-identity-js" SDK, hence, in order to implement this using this SDK you would have to write a lot of boilerplate code over the available SDK APIs to mimic the behavior.
Moving ahead, the functionality required by you has been implemented using AWS Amplify library. It has added a lot of code on top of the existing functionality to provide all the features which you require. Furthermore, the possible options for you here would be to use the AWS Amplify library or write custom logic/code over the existing SDK functionalities to mimic the required behavior. Please refer the below shared links, to get more information on the AWS Amplify library implementation:
Cognito Custom authentication flow - getting user input mid-flowasked 2 months ago
Cognito - using Cognito for server to server authenticationAccepted Answerasked 3 years ago
Cognito custom authentication flow - initiateAuth giving errorAccepted Answerasked 9 months ago
How can I restrict certain topics when not using AWS Cognito?asked 2 years ago
REST API for authentication with Cognito User Poolasked 3 months ago
Custom User Authentication through SOAP Call from Cognitoasked 4 months ago
Using same authentication with cognito and amazon connect in a app-webasked 2 months ago
Authorization code flow with custom UI and Cognitoasked 4 months ago
UserLambdaValidationException : Trying to integrate Passwordless Authentication using AWS Cognito and Amplify library in Android Appasked 2 months ago
Using PKCE flow with @aws-sdk/client-cognito-identity-providerasked 6 months ago