From 1b5d2bd63548a9e67515f8afc22af1bf9fcaddb4 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 2 Aug 2024 16:32:25 -0700 Subject: [PATCH 01/91] chore: add mfaType enum values, --- .../lib/src/config/amplify_outputs/auth/mfa.dart | 5 ++++- packages/amplify_core/lib/src/config/auth/cognito/mfa.dart | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/amplify_core/lib/src/config/amplify_outputs/auth/mfa.dart b/packages/amplify_core/lib/src/config/amplify_outputs/auth/mfa.dart index e82d3327d7..92fee3d781 100644 --- a/packages/amplify_core/lib/src/config/amplify_outputs/auth/mfa.dart +++ b/packages/amplify_core/lib/src/config/amplify_outputs/auth/mfa.dart @@ -11,7 +11,10 @@ enum MfaMethod { sms, @JsonValue('TOTP') - totp; + totp, + + @JsonValue('EMAIL') + email; /// The value to pass to `Amplify.Auth.confirmSignIn` when /// selecting an MFA type. diff --git a/packages/amplify_core/lib/src/config/auth/cognito/mfa.dart b/packages/amplify_core/lib/src/config/auth/cognito/mfa.dart index 6d33bd00b3..292c5e184f 100644 --- a/packages/amplify_core/lib/src/config/auth/cognito/mfa.dart +++ b/packages/amplify_core/lib/src/config/auth/cognito/mfa.dart @@ -9,7 +9,10 @@ enum MfaType { sms, @JsonValue('TOTP') - totp; + totp, + + @JsonValue('EMAIL') + email; /// The value to pass to `Amplify.Auth.confirmSignIn` when /// selecting an MFA type. @@ -21,6 +24,7 @@ extension ToMfaMethod on MfaType { return switch (this) { MfaType.sms => MfaMethod.sms, MfaType.totp => MfaMethod.totp, + MfaType.email => MfaMethod.email, }; } } From a6492d7b46c465d3f559ca2198f25d69b886affb Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 2 Aug 2024 16:32:49 -0700 Subject: [PATCH 02/91] chore: add sign in step enums --- .../lib/src/types/auth/sign_in/auth_sign_in_step.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/amplify_core/lib/src/types/auth/sign_in/auth_sign_in_step.dart b/packages/amplify_core/lib/src/types/auth/sign_in/auth_sign_in_step.dart index 7474f4be5e..b0d446dd8e 100644 --- a/packages/amplify_core/lib/src/types/auth/sign_in/auth_sign_in_step.dart +++ b/packages/amplify_core/lib/src/types/auth/sign_in/auth_sign_in_step.dart @@ -10,10 +10,17 @@ enum AuthSignInStep { /// an MFA method. continueSignInWithMfaSelection, + /// The sign-in is not complete and the user must set up and select an MFA method. + continueSignInWithMfaSetupSelection, + /// The sign-in is not complete and a TOTP authenticator app must be /// registered before continuing. continueSignInWithTotpSetup, + /// The sign-in is not complete and an Email MFA must be set up before + /// continuing. + continueSignInWithEmailMfaSetup, + /// The sign-in is not complete and must be confirmed with an SMS code. confirmSignInWithSmsMfaCode, @@ -21,6 +28,9 @@ enum AuthSignInStep { /// from a registered authenticator app. confirmSignInWithTotpMfaCode, + /// The sign-in is not complete and must be confirmed with an email code. + confirmSignInWithEmailMfaCode, + /// The sign-in is not complete and must be confirmed with the user's new /// password. confirmSignInWithNewPassword, From 755f30d6f0d339c945f31e0a2d58062edacaffd0 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 2 Aug 2024 16:33:08 -0700 Subject: [PATCH 03/91] chore: add ChallengeName --- .../model/challenge_name_type.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/challenge_name_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/challenge_name_type.dart index 16183b5270..7b8ba49818 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/challenge_name_type.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/challenge_name_type.dart @@ -74,6 +74,12 @@ class ChallengeNameType extends _i1.SmithyEnum { 'SOFTWARE_TOKEN_MFA', ); + static const emailMfa = ChallengeNameType._( + 10, + 'EMAIL_MFA', + 'EMAIL_MFA', + ); + /// All values of [ChallengeNameType]. static const values = [ ChallengeNameType.adminNoSrpAuth, @@ -86,6 +92,7 @@ class ChallengeNameType extends _i1.SmithyEnum { ChallengeNameType.selectMfaType, ChallengeNameType.smsMfa, ChallengeNameType.softwareTokenMfa, + ChallengeNameType.emailMfa, ]; static const List<_i1.SmithySerializer> serializers = [ From 95f658b55758caf963c2ed35c41f32bf12453cc8 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Mon, 5 Aug 2024 10:46:40 -0700 Subject: [PATCH 04/91] Revert "chore: add ChallengeName" This reverts commit 04fbd0c4ebd073fe291d95abfb5f33aa8bfe1f50. --- .../model/challenge_name_type.dart | 7 ------- 1 file changed, 7 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/challenge_name_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/challenge_name_type.dart index 7b8ba49818..16183b5270 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/challenge_name_type.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/challenge_name_type.dart @@ -74,12 +74,6 @@ class ChallengeNameType extends _i1.SmithyEnum { 'SOFTWARE_TOKEN_MFA', ); - static const emailMfa = ChallengeNameType._( - 10, - 'EMAIL_MFA', - 'EMAIL_MFA', - ); - /// All values of [ChallengeNameType]. static const values = [ ChallengeNameType.adminNoSrpAuth, @@ -92,7 +86,6 @@ class ChallengeNameType extends _i1.SmithyEnum { ChallengeNameType.selectMfaType, ChallengeNameType.smsMfa, ChallengeNameType.softwareTokenMfa, - ChallengeNameType.emailMfa, ]; static const List<_i1.SmithySerializer> serializers = [ From 1f72acaf8cceb5494cd9c425d6fc263b32cd7532 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:19:18 -0700 Subject: [PATCH 05/91] Update packages/amplify_core/lib/src/types/auth/sign_in/auth_sign_in_step.dart Co-authored-by: Elijah Quartey --- .../lib/src/types/auth/sign_in/auth_sign_in_step.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/amplify_core/lib/src/types/auth/sign_in/auth_sign_in_step.dart b/packages/amplify_core/lib/src/types/auth/sign_in/auth_sign_in_step.dart index b0d446dd8e..9631ca1d94 100644 --- a/packages/amplify_core/lib/src/types/auth/sign_in/auth_sign_in_step.dart +++ b/packages/amplify_core/lib/src/types/auth/sign_in/auth_sign_in_step.dart @@ -10,7 +10,7 @@ enum AuthSignInStep { /// an MFA method. continueSignInWithMfaSelection, - /// The sign-in is not complete and the user must set up and select an MFA method. + /// The sign-in is not complete and the user must select an MFA method to setup. continueSignInWithMfaSetupSelection, /// The sign-in is not complete and a TOTP authenticator app must be From a5abb1eb7d0da20093370326ef71de595f3f87e1 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:46:47 -0700 Subject: [PATCH 06/91] chore add email mfa to sdk_bridge and state machine --- .../lib/src/sdk/sdk_bridge.dart | 33 +++++++++++++++---- .../state/machines/sign_in_state_machine.dart | 22 ++++++++++++- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart index 5c81717008..593b38a583 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart @@ -32,6 +32,8 @@ extension ChallengeNameTypeBridge on ChallengeNameType { AuthSignInStep.continueSignInWithTotpSetup, ChallengeNameType.softwareTokenMfa => AuthSignInStep.confirmSignInWithTotpMfaCode, + // TODO(khatruong2009): confirm ChallengeNameType.emailMfa is added to SDK + ChallengeNameType.emailMfa => AuthSignInStep.confirmSignInWithEmailMfaCode, ChallengeNameType.adminNoSrpAuth || ChallengeNameType.passwordVerifier || ChallengeNameType.devicePasswordVerifier || @@ -795,6 +797,7 @@ extension MfaSettings on CognitoIdentityProviderClient { required String accessToken, MfaPreference? sms, MfaPreference? totp, + MfaPreference? email, }) async { final UserMfaPreference( enabled: currentEnabled, @@ -811,6 +814,7 @@ extension MfaSettings on CognitoIdentityProviderClient { final explicitlyDisabled = switch (mfaType) { MfaType.sms => sms == MfaPreference.disabled, MfaType.totp => totp == MfaPreference.disabled, + MfaType.email => email == MfaPreference.disabled, }; if (explicitlyDisabled) { return false; @@ -819,22 +823,25 @@ extension MfaSettings on CognitoIdentityProviderClient { final requestingEnabled = switch (mfaType) { MfaType.sms => enabledValues.contains(sms), MfaType.totp => enabledValues.contains(totp), + MfaType.email => enabledValues.contains(email), }; return currentlyEnabled || requestingEnabled; } - final preferred = switch ((currentPreference, sms: sms, totp: totp)) { + final preferred = switch ((currentPreference, sms: sms, totp: totp, email: email)) { // Prevent an invalid choice. - (_, sms: MfaPreference.preferred, totp: MfaPreference.preferred) => + (_, sms: MfaPreference.preferred, totp: MfaPreference.preferred, email: MfaPreference.preferred) => throw const InvalidParameterException( - 'Cannot assign both SMS and TOTP as preferred', + 'Cannot assign multiple MFA methods as preferred', ), // Setting one or the other as preferred overrides previous value. - (_, sms: MfaPreference.preferred, totp: != MfaPreference.preferred) => + (_, sms: MfaPreference.preferred, totp: != MfaPreference.preferred, email: != MfaPreference.preferred) => MfaType.sms, - (_, sms: != MfaPreference.preferred, totp: MfaPreference.preferred) => + (_, sms: != MfaPreference.preferred, totp: MfaPreference.preferred, email: != MfaPreference.preferred) => MfaType.totp, + (_, sms: != MfaPreference.preferred, totp: != MfaPreference.preferred, email: MfaPreference.preferred) => + MfaType.email, // Setting one or the other as disabled or not preferred removes current // preference if it matches. @@ -842,16 +849,24 @@ extension MfaSettings on CognitoIdentityProviderClient { MfaType.sms, sms: MfaPreference.notPreferred || MfaPreference.disabled, totp: _, + email: _, ) || ( MfaType.totp, sms: _, totp: MfaPreference.notPreferred || MfaPreference.disabled, + email: _, + ) || + ( + MfaType.email, + sms: _, + totp: _, + email: MfaPreference.notPreferred || MfaPreference.disabled, ) => null, // Ignore preference changes which do not affect the current preference. - (final currentPreference, sms: _, totp: _) => currentPreference, + (final currentPreference, sms: _, totp: _, email: _) => currentPreference, }; final smsMfaSettings = SmsMfaSettingsType( enabled: isEnabled(MfaType.sms), @@ -861,6 +876,11 @@ extension MfaSettings on CognitoIdentityProviderClient { enabled: isEnabled(MfaType.totp), preferredMfa: preferred == MfaType.totp, ); + // TODO(khatruong2009): confirm EmailMfaSettingsType is added to SDK + final emailMfaSettings = EmailMfaSettingsType( + enabled: isEnabled(MfaType.email), + preferredMfa: preferred == MfaType.email, + ); await setUserMfaPreference( SetUserMfaPreferenceRequest( accessToken: accessToken, @@ -876,6 +896,7 @@ extension on String { MfaType get mfaType => switch (this) { 'SOFTWARE_TOKEN_MFA' => MfaType.totp, 'SMS_MFA' => MfaType.sms, + 'EMAIL_MFA' => MfaType.email, final invalidType => throw StateError('Invalid MFA type: $invalidType'), }; } diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart index cafeb1d3e7..46666c79fd 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart @@ -211,6 +211,7 @@ final class SignInStateMachine (type) => switch (type) { 'SOFTWARE_TOKEN_MFA' => MfaType.totp, 'SMS_MFA' => MfaType.sms, + 'EMAIL_MFA' => MfaType.email, _ => () { logger.error('Unrecognized MFA type: $type'); return null; @@ -449,6 +450,24 @@ final class SignInStateMachine }); } + /// Creates the response object for an Email MFA challenge. + @protected + Future createEmailMfaRequest( + SignInRespondToChallenge event, + ) async { + _enableMfaType = MfaType.email; + return RespondToAuthChallengeRequest.build((b) { + b + ..clientId = config.appClientId + ..challengeName = _challengeName + ..challengeResponses.addAll({ + CognitoConstants.challengeParamUsername: cognitoUsername, + CognitoConstants.challengeParamEmailMfaCode: event.answer, + }) + ..clientMetadata.addAll(event.clientMetadata); + }); + } + /// Creates the response object for a new password challenge. @protected Future createNewPasswordRequest( @@ -667,7 +686,8 @@ final class SignInStateMachine CognitoConstants.challengeParamAnswer: switch (selection) { 'sms' => 'SMS_MFA', 'totp' => 'SOFTWARE_TOKEN_MFA', - _ => throw ArgumentError('Must be either SMS or TOTP'), + 'email' => 'EMAIL_MFA', + _ => throw ArgumentError('Must be either SMS, Email, or TOTP'), }, }) ..clientId = _authOutputs.userPoolClientId From edaf99947b3c1b3e01849cf52e64c194eacf9156 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:47:52 -0700 Subject: [PATCH 07/91] chore: add email mfa to constants.dart --- .../amplify_auth_cognito_dart/lib/src/flows/constants.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart index 3ab6d376a5..ff49ec7974 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart @@ -57,6 +57,9 @@ abstract class CognitoConstants { /// The `SMS_MFA_CODE` parameter. static const challengeParamSmsMfaCode = 'SMS_MFA_CODE'; + /// The `EMAIL_MFA_CODE` parameter. + static const challengeParamEmailMfaCode = 'EMAIL_MFA_CODE'; + /// The `SOFTWARE_TOKEN_MFA_CODE` parameter. static const challengeParamSoftwareTokenMfaCode = 'SOFTWARE_TOKEN_MFA_CODE'; From 630adad3fc5deac35c9f63b6b12bc8419b191226 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:48:54 -0700 Subject: [PATCH 08/91] chore: add email to updateMfaPreference API --- .../amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart index f458548642..f080f48fc2 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart @@ -892,6 +892,7 @@ class AmplifyAuthCognitoDart extends AuthPluginInterface Future updateMfaPreference({ MfaPreference? sms, MfaPreference? totp, + MfaPreference? email, }) async { final tokens = await _stateMachine.getUserPoolTokens(); final accessToken = tokens.accessToken.raw; @@ -899,6 +900,7 @@ class AmplifyAuthCognitoDart extends AuthPluginInterface accessToken: accessToken, sms: sms, totp: totp, + email: email, ); } From 3f4efce65dcdfc1efb60ec27967b9112eaa14a21 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Tue, 10 Sep 2024 14:49:18 -0700 Subject: [PATCH 09/91] chore: generate code for mfa types/methods and sign in step --- .../lib/src/config/amplify_outputs/auth/auth_outputs.g.dart | 1 + .../amplify_core/lib/src/config/auth/cognito/auth.g.dart | 1 + .../src/types/auth/sign_in/auth_next_sign_in_step.g.dart | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/packages/amplify_core/lib/src/config/amplify_outputs/auth/auth_outputs.g.dart b/packages/amplify_core/lib/src/config/amplify_outputs/auth/auth_outputs.g.dart index f278972143..9c9639f654 100644 --- a/packages/amplify_core/lib/src/config/amplify_outputs/auth/auth_outputs.g.dart +++ b/packages/amplify_core/lib/src/config/amplify_outputs/auth/auth_outputs.g.dart @@ -128,4 +128,5 @@ const _$MfaEnforcementEnumMap = { const _$MfaMethodEnumMap = { MfaMethod.sms: 'SMS', MfaMethod.totp: 'TOTP', + MfaMethod.email: 'EMAIL', }; diff --git a/packages/amplify_core/lib/src/config/auth/cognito/auth.g.dart b/packages/amplify_core/lib/src/config/auth/cognito/auth.g.dart index 51926ead53..6bbb532080 100644 --- a/packages/amplify_core/lib/src/config/auth/cognito/auth.g.dart +++ b/packages/amplify_core/lib/src/config/auth/cognito/auth.g.dart @@ -119,4 +119,5 @@ const _$MfaConfigurationEnumMap = { const _$MfaTypeEnumMap = { MfaType.sms: 'SMS', MfaType.totp: 'TOTP', + MfaType.email: 'EMAIL', }; diff --git a/packages/amplify_core/lib/src/types/auth/sign_in/auth_next_sign_in_step.g.dart b/packages/amplify_core/lib/src/types/auth/sign_in/auth_next_sign_in_step.g.dart index 46d7e2de61..addf8e6b35 100644 --- a/packages/amplify_core/lib/src/types/auth/sign_in/auth_next_sign_in_step.g.dart +++ b/packages/amplify_core/lib/src/types/auth/sign_in/auth_next_sign_in_step.g.dart @@ -75,9 +75,14 @@ Map _$AuthNextSignInStepToJson(AuthNextSignInStep instance) { const _$AuthSignInStepEnumMap = { AuthSignInStep.continueSignInWithMfaSelection: 'continueSignInWithMfaSelection', + AuthSignInStep.continueSignInWithMfaSetupSelection: + 'continueSignInWithMfaSetupSelection', AuthSignInStep.continueSignInWithTotpSetup: 'continueSignInWithTotpSetup', + AuthSignInStep.continueSignInWithEmailMfaSetup: + 'continueSignInWithEmailMfaSetup', AuthSignInStep.confirmSignInWithSmsMfaCode: 'confirmSignInWithSmsMfaCode', AuthSignInStep.confirmSignInWithTotpMfaCode: 'confirmSignInWithTotpMfaCode', + AuthSignInStep.confirmSignInWithEmailMfaCode: 'confirmSignInWithEmailMfaCode', AuthSignInStep.confirmSignInWithNewPassword: 'confirmSignInWithNewPassword', AuthSignInStep.confirmSignInWithCustomChallenge: 'confirmSignInWithCustomChallenge', @@ -89,4 +94,5 @@ const _$AuthSignInStepEnumMap = { const _$MfaTypeEnumMap = { MfaType.sms: 'SMS', MfaType.totp: 'TOTP', + MfaType.email: 'EMAIL', }; From 438f800810f18b04f7b407217a6b67db2da48607 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Thu, 12 Sep 2024 16:45:05 -0700 Subject: [PATCH 10/91] chore: merge main (#5449) * chore(api): update endpoint config to use ApiOutputs instead of AWSApiConfig type (#5193) * feat: bump json_annotation dependency to v4.9 * chore: update actions workflow to run aft link * chore(secure_storage): Plugin Endorsement (#5208) * chore(infra): bump deps (#5221) * chore(test): use Amplify Gen 2 config in unit tests (#5205) * chore: add testUrlScheme back to test (#5223) * chore: add gen2 auth e2e infra (#5179) * chore(infra): Api migrate to Gen 2 E2E * fix: git update-index --chmod=+x * fix: code review * chore: port auth backend * chore: port lambda triggers for create user and custom email sender * chore: move utils to infra-common * chore: compile infra common to js * chore: update utils for js restructure, add missing deps * chore: fix confirmation code infra * chore: update tests to run for gen2 stacks * chore: remove alias from custom sender lambda * chore: fix deliveryMedium in reset password test * chore: add phone sign in infra * chore: rename email-sign-in * chore: add license header * chore: fix formatting in GH workflow * chore: update package-lock * chore: remove deleted file * chore: fix formatting * chore: update package lock * chore: remove dup function * chore: remove changes from merge conflicts * chore: fix build script * chore: fetch auth amplify_outputs * chore: remove libgit2dart * chore: add custom sms sender * chore: add stack name to infra resources * chore: pull gen2 backend for authenticator * chore: update package-lock * chore: move dependencies to dev_dependencies * chore: update fetch auth session tests * chore: separate reset pw and confirmation delivery medium * chore: fix hanging test * chore: rename test group * chore: update comments, remove unused type * chore: update package lock --------- Co-authored-by: Elijah Quartey * chore(auth): sign-up state machine to use AmplifyOutputs instead of AmplifyConfig types (#5230) * chore(auth): sign-in state machine to use AmplifyOutputs instead of AmplifyConfig types (#5231) * chore(auth): fetch auth session state machine to use AmplifyOutputs instead of AmplifyConfig types (#5234) * chore(auth): sign-out state machine to use AmplifyOutputs instead of AmplifConfig types (#5235) * chore(actions): android emulator to start with clear cache and data (#5245) * chore(actions): e2e android tests to run with API 34 (#5247) * chore(infra): bump deps (#5246) Updated @aws-sdk/client-amplify @aws-sdk/client-cognito-identity-provider @aws-crypto/client-node @aws-sdk/client-s3 * chore(auth): cognito keys to not use AmplifyConfig types (#5243) * chore(auth): hosted ui state machine to not use AmplifyConfig types (#5254) * fix(datastore): Clear subscriptions on Stop (#5253) * Chore/goldens flutter lint (#5271) * temp: generate goldens png * test: fixing context mounted issue * chore: add todo comment about deprecated member use --------- Co-authored-by: Andrew Hahn * chore(infra): analytics integ test gen 2 backend (#5104) * chore(auth): device metadata repository to use AuthOutputs instead of CognitoUserPoolConfig (#5289) * feat(Auth): Add fetchCurrentDevice API (#5251) feat(Auth): Add fetchCurrentDevice API (#5251) * chore(dependencies): bump package_info_plus (#5274) chore: bump package_info_plus * chore: migrate sms only MFA infra to Gen 2 (#5291) * chore: add new auth backend * chore: add auth extension * chore: add license headers * chore: add mfa to env * chore: add trigger to enable MFA * chore: add infra for sms required * chore: refactor tests for gen 2 backends * chore: add backends to deploy script * chore: package-lock for mfa-required-sms * chore: remove bundling of @aws-crypto/client-node * chore: fix formatting * fix(datastore): Restart Sync Engine when network on/off (#5218) * chore: update authenticator tests (#5296) * chore(auth): hosted ui platforms to use AmplifyOutputs types instead of AmplifyConfig (#5273) * chore(auth): asf context data provider to use AuthOutputs instead of CognitoUserPoolConfig (#5290) * chore(auth): fix fetch current device test (#5297) * fix: push notification flush events (#5215) fix: push notification flush events (#5215) * chore(dependencies): bump build_runner (#5300) * chore(dependencies): bump build_runner * chore(bump): checks package (#5305) * chore(bump): checks package * chore(version): Bump version chore(): Fixed Version Bumps chore: fixed change log chore: fixed change log chore: fixed change log chore: fixed change log * chore: manually bump amplify_db_common version * chore(infra): Extend API key expiration (#5336) * chore(dev): use ubuntu image from amazon ECR public gallery instead of docket hub (#5341) * fix(api): web socket error handling (#5359) * chore: update issue template (#5369) * fix(datastore): FlutterSerializedModel.extractJsonValue returns `.some(nil)` instead of `nil` (#5370) * chore: add GH actions for issue open, close, comment, label events (#5310) * fix(secure_storage): add missing macOS plugin (#5372) fix(secure_storage): add missing macos plugin it's fixing #5361 * chore: update plugin registrant for example apps that depend on secure storage (#5379) * chore(version): Bump version - fix(secure_storage): add missing macOS plugin ([#5372](https://github.com/aws-amplify/amplify-flutter/pull/5372)) Updated-Components: Secure Storage * chore(deps): Amplify Android 2.21.1 (#5376) * update amplify android to latest * update amplify android to latest in notifications * feat(aws_common): Generated new AWSService constructors (#5378) * chore(infra): regen lock file (#5374) * chore(auth): credential store state machine to use AuthOutputs instead of AmplifyConfig types (#5298) * chore(api): Remove Gen 1 API backend (#5393) * chore(datastore): Add multi auth integration tests (#5204) * feat: move App Sync subscription headers to protocol (#5301) * chore: move subscription headers to protocol * fix: remove `=` from encoded headers * chore: add comment * chore: `aft version-bump` test suite (#5424) * chore: add `--skip-build-version` option * chore: use `base-ref`/`head-ref` over env vars * chore: add new version bump test suite * chore: remove old version bump tests * chore: only include first change log entry * fix: sort change types before writing to the change log * chore: remove non essential info from diffs * chore: generate repo snapshot * chore: generate diff snapshots * chore: clean up tests and test output * chore: update `aft generate workflows`, regenerate dependabot.yaml (#5441) * chore: skip repo snapshot in dependabot generation * chore: regenerate dependabot.yaml * chore: fix `aft version-bump` (#5436) * fix: properly handle component propagation * chore: add test for multi package update with breaking common package --------- Co-authored-by: NikaHsn Co-authored-by: Jordan Nelson Co-authored-by: Elijah Quartey Co-authored-by: Elijah Quartey Co-authored-by: Tyler-Larkin Co-authored-by: Andrew Hahn Co-authored-by: Andrew Hahn <58017052+hahnandrew@users.noreply.github.com> Co-authored-by: Burak Karahan Co-authored-by: Jamil Saadeh --- infra-gen2/package-lock.json | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/infra-gen2/package-lock.json b/infra-gen2/package-lock.json index 806c800dd6..191c337b64 100644 --- a/infra-gen2/package-lock.json +++ b/infra-gen2/package-lock.json @@ -4462,6 +4462,18 @@ "inBundle": true, "license": "Apache-2.0", "dependencies": { + "@aws-crypto/sha256-browser": "5.2.0", + "@aws-crypto/sha256-js": "5.2.0", + "@aws-sdk/client-sso-oidc": "3.624.0", + "@aws-sdk/client-sts": "3.624.0", + "@aws-sdk/core": "3.624.0", + "@aws-sdk/credential-provider-node": "3.624.0", + "@aws-sdk/middleware-host-header": "3.620.0", + "@aws-sdk/middleware-logger": "3.609.0", + "@aws-sdk/middleware-recursion-detection": "3.620.0", + "@aws-sdk/middleware-sdk-ec2": "3.622.0", + "@aws-sdk/middleware-user-agent": "3.620.0", + "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", "bowser": "^2.11.0", @@ -4474,9 +4486,27 @@ "inBundle": true, "license": "Apache-2.0", "dependencies": { + "@aws-crypto/sha256-browser": "5.2.0", + "@aws-crypto/sha256-js": "5.2.0", + "@aws-sdk/core": "3.624.0", + "@aws-sdk/middleware-host-header": "3.620.0", + "@aws-sdk/middleware-logger": "3.609.0", + "@aws-sdk/middleware-recursion-detection": "3.620.0", + "@aws-sdk/middleware-user-agent": "3.620.0", + "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/types": "^3.3.0", + "@smithy/url-parser": "^3.0.3", + "@smithy/util-base64": "^3.0.0", + "@smithy/util-body-length-browser": "^3.0.0", + "@smithy/util-body-length-node": "^3.0.0", + "@smithy/util-defaults-mode-browser": "^3.0.14", + "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-endpoints": "^2.0.5", + "@smithy/util-middleware": "^3.0.3", + "@smithy/util-retry": "^3.0.3", + "@smithy/util-utf8": "^3.0.0", "tslib": "^2.6.2" }, "engines": { @@ -4592,6 +4622,8 @@ "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", + "@smithy/util-middleware": "^3.0.3", + "fast-xml-parser": "4.4.1", "tslib": "^2.6.2" }, "engines": { @@ -4606,6 +4638,7 @@ "dependencies": { "@smithy/eventstream-serde-universal": "^3.0.5", "@smithy/types": "^3.3.0", + "@smithy/util-stream": "^3.1.3", "tslib": "^2.6.2" }, "engines": { From b4a8ceb1c8a1c68044c9f15ceb7d785d1aa113ad Mon Sep 17 00:00:00 2001 From: NikaHsn Date: Fri, 13 Sep 2024 16:17:54 -0700 Subject: [PATCH 11/91] chore(auth): re-generate auth cognito sdk for email mfa (#5455) * chore(api): update endpoint config to use ApiOutputs instead of AWSApiConfig type (#5193) * feat: bump json_annotation dependency to v4.9 * chore: update actions workflow to run aft link * chore(secure_storage): Plugin Endorsement (#5208) * chore(infra): bump deps (#5221) * chore(test): use Amplify Gen 2 config in unit tests (#5205) * chore: add testUrlScheme back to test (#5223) * chore: add gen2 auth e2e infra (#5179) * chore(infra): Api migrate to Gen 2 E2E * fix: git update-index --chmod=+x * fix: code review * chore: port auth backend * chore: port lambda triggers for create user and custom email sender * chore: move utils to infra-common * chore: compile infra common to js * chore: update utils for js restructure, add missing deps * chore: fix confirmation code infra * chore: update tests to run for gen2 stacks * chore: remove alias from custom sender lambda * chore: fix deliveryMedium in reset password test * chore: add phone sign in infra * chore: rename email-sign-in * chore: add license header * chore: fix formatting in GH workflow * chore: update package-lock * chore: remove deleted file * chore: fix formatting * chore: update package lock * chore: remove dup function * chore: remove changes from merge conflicts * chore: fix build script * chore: fetch auth amplify_outputs * chore: remove libgit2dart * chore: add custom sms sender * chore: add stack name to infra resources * chore: pull gen2 backend for authenticator * chore: update package-lock * chore: move dependencies to dev_dependencies * chore: update fetch auth session tests * chore: separate reset pw and confirmation delivery medium * chore: fix hanging test * chore: rename test group * chore: update comments, remove unused type * chore: update package lock --------- Co-authored-by: Elijah Quartey * chore(auth): sign-up state machine to use AmplifyOutputs instead of AmplifyConfig types (#5230) * chore(auth): sign-in state machine to use AmplifyOutputs instead of AmplifyConfig types (#5231) * chore(auth): fetch auth session state machine to use AmplifyOutputs instead of AmplifyConfig types (#5234) * chore(auth): sign-out state machine to use AmplifyOutputs instead of AmplifConfig types (#5235) * chore(actions): android emulator to start with clear cache and data (#5245) * chore(actions): e2e android tests to run with API 34 (#5247) * chore(infra): bump deps (#5246) Updated @aws-sdk/client-amplify @aws-sdk/client-cognito-identity-provider @aws-crypto/client-node @aws-sdk/client-s3 * chore(auth): cognito keys to not use AmplifyConfig types (#5243) * chore(auth): hosted ui state machine to not use AmplifyConfig types (#5254) * fix(datastore): Clear subscriptions on Stop (#5253) * Chore/goldens flutter lint (#5271) * temp: generate goldens png * test: fixing context mounted issue * chore: add todo comment about deprecated member use --------- Co-authored-by: Andrew Hahn * chore(infra): analytics integ test gen 2 backend (#5104) * chore(auth): device metadata repository to use AuthOutputs instead of CognitoUserPoolConfig (#5289) * feat(Auth): Add fetchCurrentDevice API (#5251) feat(Auth): Add fetchCurrentDevice API (#5251) * chore(dependencies): bump package_info_plus (#5274) chore: bump package_info_plus * chore: migrate sms only MFA infra to Gen 2 (#5291) * chore: add new auth backend * chore: add auth extension * chore: add license headers * chore: add mfa to env * chore: add trigger to enable MFA * chore: add infra for sms required * chore: refactor tests for gen 2 backends * chore: add backends to deploy script * chore: package-lock for mfa-required-sms * chore: remove bundling of @aws-crypto/client-node * chore: fix formatting * fix(datastore): Restart Sync Engine when network on/off (#5218) * chore: update authenticator tests (#5296) * chore(auth): hosted ui platforms to use AmplifyOutputs types instead of AmplifyConfig (#5273) * chore(auth): asf context data provider to use AuthOutputs instead of CognitoUserPoolConfig (#5290) * chore(auth): fix fetch current device test (#5297) * fix: push notification flush events (#5215) fix: push notification flush events (#5215) * chore(dependencies): bump build_runner (#5300) * chore(dependencies): bump build_runner * chore(bump): checks package (#5305) * chore(bump): checks package * chore(version): Bump version chore(): Fixed Version Bumps chore: fixed change log chore: fixed change log chore: fixed change log chore: fixed change log * chore: manually bump amplify_db_common version * chore(infra): Extend API key expiration (#5336) * chore(dev): use ubuntu image from amazon ECR public gallery instead of docket hub (#5341) * fix(api): web socket error handling (#5359) * chore: update issue template (#5369) * fix(datastore): FlutterSerializedModel.extractJsonValue returns `.some(nil)` instead of `nil` (#5370) * chore: add GH actions for issue open, close, comment, label events (#5310) * fix(secure_storage): add missing macOS plugin (#5372) fix(secure_storage): add missing macos plugin it's fixing #5361 * chore: update plugin registrant for example apps that depend on secure storage (#5379) * chore(version): Bump version ### Fixes - fix(secure_storage): add missing macOS plugin ([#5372](https://github.com/aws-amplify/amplify-flutter/pull/5372)) Updated-Components: Secure Storage * chore(deps): Amplify Android 2.21.1 (#5376) * update amplify android to latest * update amplify android to latest in notifications * feat(aws_common): Generated new AWSService constructors (#5378) * chore(infra): regen lock file (#5374) * chore(auth): credential store state machine to use AuthOutputs instead of AmplifyConfig types (#5298) * chore(api): Remove Gen 1 API backend (#5393) * chore(datastore): Add multi auth integration tests (#5204) * feat: move App Sync subscription headers to protocol (#5301) * chore: move subscription headers to protocol * fix: remove `=` from encoded headers * chore: add comment * chore: `aft version-bump` test suite (#5424) * chore: add `--skip-build-version` option * chore: use `base-ref`/`head-ref` over env vars * chore: add new version bump test suite * chore: remove old version bump tests * chore: only include first change log entry * fix: sort change types before writing to the change log * chore: remove non essential info from diffs * chore: generate repo snapshot * chore: generate diff snapshots * chore: clean up tests and test output * chore: update `aft generate workflows`, regenerate dependabot.yaml (#5441) * chore: skip repo snapshot in dependabot generation * chore: regenerate dependabot.yaml * chore: fix `aft version-bump` (#5436) * fix: properly handle component propagation * chore: add test for multi package update with breaking common package * chore(auth): re-generate auth cognito sdk for email mfa --------- Co-authored-by: Jordan Nelson Co-authored-by: Elijah Quartey Co-authored-by: Elijah Quartey Co-authored-by: Tyler-Larkin Co-authored-by: Andrew Hahn Co-authored-by: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Co-authored-by: Andrew Hahn <58017052+hahnandrew@users.noreply.github.com> Co-authored-by: Burak Karahan Co-authored-by: Jamil Saadeh Co-authored-by: Nika Hassani --- .../lib/src/sdk/cognito_identity.dart | 2 +- .../src/sdk/cognito_identity_provider.dart | 4 +- .../lib/src/sdk/sdk_exception.dart | 21 +++ .../cognito_identity_client.dart | 2 +- .../common/endpoint_resolver.dart | 2 +- .../cognito_identity/common/serializers.dart | 2 +- .../cognito_identity/model/credentials.dart | 4 +- .../model/external_service_exception.dart | 2 +- .../get_credentials_for_identity_input.dart | 2 +- ...get_credentials_for_identity_response.dart | 2 +- .../cognito_identity/model/get_id_input.dart | 2 +- .../model/get_id_response.dart | 2 +- .../model/internal_error_exception.dart | 2 +- ...identity_pool_configuration_exception.dart | 2 +- .../model/invalid_parameter_exception.dart | 2 +- .../model/limit_exceeded_exception.dart | 2 +- .../model/not_authorized_exception.dart | 2 +- .../model/resource_conflict_exception.dart | 2 +- .../model/resource_not_found_exception.dart | 2 +- .../model/too_many_requests_exception.dart | 2 +- ...et_credentials_for_identity_operation.dart | 4 +- .../operation/get_id_operation.dart | 4 +- .../cognito_identity_provider_client.dart | 18 +-- .../common/endpoint_resolver.dart | 2 +- .../common/serializers.dart | 6 +- .../model/alias_exists_exception.dart | 2 +- .../model/analytics_metadata_type.dart | 2 +- .../associate_software_token_request.dart | 2 +- .../associate_software_token_response.dart | 2 +- .../model/attribute_type.dart | 2 +- .../model/auth_flow_type.dart | 2 +- .../model/authentication_result_type.dart | 2 +- .../model/challenge_name_type.dart | 21 ++- .../model/change_password_request.dart | 2 +- .../model/change_password_response.dart | 2 +- .../model/code_delivery_details_type.dart | 2 +- .../code_delivery_failure_exception.dart | 2 +- .../model/code_mismatch_exception.dart | 2 +- .../concurrent_modification_exception.dart | 2 +- .../model/confirm_device_request.dart | 2 +- .../model/confirm_device_response.dart | 2 +- .../confirm_forgot_password_request.dart | 2 +- .../confirm_forgot_password_response.dart | 2 +- .../model/confirm_sign_up_request.dart | 2 +- .../model/confirm_sign_up_response.dart | 2 +- .../model/delete_user_request.dart | 2 +- .../model/delivery_medium_type.dart | 2 +- .../model/device_remembered_status_type.dart | 2 +- .../device_secret_verifier_config_type.dart | 2 +- .../model/device_type.dart | 2 +- .../model/email_mfa_settings_type.dart | 147 +++++++++++++++++ .../model/email_mfa_settings_type.g.dart | 106 +++++++++++++ .../enable_software_token_mfa_exception.dart | 2 +- .../model/expired_code_exception.dart | 2 +- .../model/forbidden_exception.dart | 2 +- .../model/forget_device_request.dart | 2 +- .../model/forgot_password_request.dart | 2 +- .../model/forgot_password_response.dart | 2 +- .../model/get_device_request.dart | 2 +- .../model/get_device_response.dart | 2 +- ...r_attribute_verification_code_request.dart | 2 +- ..._attribute_verification_code_response.dart | 2 +- .../model/get_user_request.dart | 2 +- .../model/get_user_response.dart | 4 +- .../model/global_sign_out_request.dart | 2 +- .../model/global_sign_out_response.dart | 2 +- .../model/initiate_auth_request.dart | 2 +- .../model/initiate_auth_response.dart | 6 +- .../model/internal_error_exception.dart | 2 +- ...id_email_role_access_policy_exception.dart | 2 +- .../invalid_lambda_response_exception.dart | 2 +- .../model/invalid_parameter_exception.dart | 2 +- .../model/invalid_password_exception.dart | 2 +- ...alid_sms_role_access_policy_exception.dart | 2 +- ...sms_role_trust_relationship_exception.dart | 2 +- ...lid_user_pool_configuration_exception.dart | 2 +- .../model/limit_exceeded_exception.dart | 2 +- .../model/list_devices_request.dart | 2 +- .../model/list_devices_response.dart | 2 +- .../model/mfa_method_not_found_exception.dart | 2 +- .../model/mfa_option_type.dart | 2 +- .../model/new_device_metadata_type.dart | 2 +- .../model/not_authorized_exception.dart | 2 +- ...rd_history_policy_violation_exception.dart | 148 ++++++++++++++++++ ..._history_policy_violation_exception.g.dart | 101 ++++++++++++ .../password_reset_required_exception.dart | 2 +- .../resend_confirmation_code_request.dart | 2 +- .../resend_confirmation_code_response.dart | 2 +- .../model/resource_not_found_exception.dart | 2 +- .../respond_to_auth_challenge_request.dart | 10 +- .../respond_to_auth_challenge_response.dart | 2 +- .../model/revoke_token_request.dart | 2 +- .../model/revoke_token_response.dart | 2 +- .../set_user_mfa_preference_request.dart | 31 +++- .../set_user_mfa_preference_request.g.dart | 15 ++ .../set_user_mfa_preference_response.dart | 2 +- .../model/sign_up_request.dart | 2 +- .../model/sign_up_response.dart | 4 +- .../model/sms_mfa_settings_type.dart | 4 +- ...oftware_token_mfa_not_found_exception.dart | 2 +- .../software_token_mfa_settings_type.dart | 2 +- .../too_many_failed_attempts_exception.dart | 2 +- .../model/too_many_requests_exception.dart | 2 +- .../model/unauthorized_exception.dart | 2 +- .../model/unexpected_lambda_exception.dart | 2 +- .../unsupported_operation_exception.dart | 2 +- .../unsupported_token_type_exception.dart | 2 +- .../model/update_device_status_request.dart | 2 +- .../model/update_device_status_response.dart | 2 +- .../model/update_user_attributes_request.dart | 2 +- .../update_user_attributes_response.dart | 2 +- .../model/user_context_data_type.dart | 2 +- .../user_lambda_validation_exception.dart | 2 +- .../model/user_not_confirmed_exception.dart | 2 +- .../model/user_not_found_exception.dart | 2 +- .../model/username_exists_exception.dart | 2 +- .../model/verify_software_token_request.dart | 2 +- .../model/verify_software_token_response.dart | 2 +- .../verify_software_token_response_type.dart | 2 +- .../model/verify_user_attribute_request.dart | 2 +- .../model/verify_user_attribute_response.dart | 2 +- .../associate_software_token_operation.dart | 8 +- .../operation/change_password_operation.dart | 16 +- .../operation/confirm_device_operation.dart | 4 +- .../confirm_forgot_password_operation.dart | 16 +- .../operation/confirm_sign_up_operation.dart | 4 +- .../operation/delete_user_operation.dart | 4 +- .../operation/forget_device_operation.dart | 4 +- .../operation/forgot_password_operation.dart | 8 +- .../operation/get_device_operation.dart | 4 +- ...attribute_verification_code_operation.dart | 8 +- .../operation/get_user_operation.dart | 4 +- .../operation/global_sign_out_operation.dart | 4 +- .../operation/initiate_auth_operation.dart | 20 ++- .../operation/list_devices_operation.dart | 4 +- .../resend_confirmation_code_operation.dart | 8 +- .../respond_to_auth_challenge_operation.dart | 32 +++- .../operation/revoke_token_operation.dart | 4 +- .../set_user_mfa_preference_operation.dart | 4 +- .../operation/sign_up_operation.dart | 8 +- .../update_device_status_operation.dart | 4 +- .../update_user_attributes_operation.dart | 8 +- .../verify_software_token_operation.dart | 4 +- .../verify_user_attribute_operation.dart | 4 +- 144 files changed, 845 insertions(+), 201 deletions(-) create mode 100644 packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/email_mfa_settings_type.dart create mode 100644 packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/email_mfa_settings_type.g.dart create mode 100644 packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/password_history_policy_violation_exception.dart create mode 100644 packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/password_history_policy_violation_exception.g.dart diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/cognito_identity.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/cognito_identity.dart index bcac91000f..d3b8223bdb 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/cognito_identity.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/cognito_identity.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas /// # Amazon Cognito Identity diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/cognito_identity_provider.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/cognito_identity_provider.dart index 7682084c1c..3bc1811bc4 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/cognito_identity_provider.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/cognito_identity_provider.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas /// # Amazon Cognito Identity Provider @@ -68,6 +68,7 @@ export 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/ export 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/device_remembered_status_type.dart'; export 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/device_secret_verifier_config_type.dart'; export 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/device_type.dart'; +export 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/email_mfa_settings_type.dart'; export 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/enable_software_token_mfa_exception.dart'; export 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/expired_code_exception.dart'; export 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/forbidden_exception.dart'; @@ -99,6 +100,7 @@ export 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/ export 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/mfa_option_type.dart'; export 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/new_device_metadata_type.dart'; export 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/not_authorized_exception.dart'; +export 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/password_history_policy_violation_exception.dart'; export 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/password_reset_required_exception.dart'; export 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/resend_confirmation_code_request.dart'; export 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/resend_confirmation_code_response.dart'; diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_exception.dart index fde039d5f1..78f5d3eaa8 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_exception.dart @@ -356,6 +356,22 @@ final class NotAuthorizedServiceException extends CognitoServiceException String get runtimeTypeName => 'NotAuthorizedServiceException'; } +/// {@template amplify_auth_cognito_dart.sdk_exception.password_history_policy_violation_exception} +/// The message returned when a user's new password matches a previous password and doesn't comply with the password-history policy. +/// {@endtemplate} +final class PasswordHistoryPolicyViolationException + extends CognitoServiceException { + /// {@macro amplify_auth_cognito_dart.sdk_exception.password_history_policy_violation_exception} + const PasswordHistoryPolicyViolationException( + super.message, { + super.recoverySuggestion, + super.underlyingException, + }); + + @override + String get runtimeTypeName => 'PasswordHistoryPolicyViolationException'; +} + /// {@template amplify_auth_cognito_dart.sdk_exception.password_reset_required_exception} /// This exception is thrown when a password reset is required. /// {@endtemplate} @@ -685,6 +701,11 @@ Object transformSdkException(Object e) { message, underlyingException: e, ), + 'PasswordHistoryPolicyViolationException' => + PasswordHistoryPolicyViolationException( + message, + underlyingException: e, + ), 'PasswordResetRequiredException' => PasswordResetRequiredException( message, underlyingException: e, diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/cognito_identity_client.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/cognito_identity_client.dart index 4fce991aac..49472116d5 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/cognito_identity_client.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/cognito_identity_client.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity.cognito_identity_client; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/common/endpoint_resolver.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/common/endpoint_resolver.dart index 7cd37f555f..aabe87df7f 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/common/endpoint_resolver.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/common/endpoint_resolver.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity.common.endpoint_resolver; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/common/serializers.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/common/serializers.dart index 53d9ea9022..13d2996e70 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/common/serializers.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/common/serializers.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity.common.serializers; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/credentials.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/credentials.dart index 4a9768bec5..f907c481b8 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/credentials.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/credentials.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity.model.credentials; // ignore_for_file: no_leading_underscores_for_library_prefixes @@ -67,7 +67,7 @@ abstract class Credentials ) ..add( 'secretKey', - secretKey, + '***SENSITIVE***', ) ..add( 'sessionToken', diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/external_service_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/external_service_exception.dart index 40fea8d03e..9e9500945b 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/external_service_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/external_service_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity.model.external_service_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/get_credentials_for_identity_input.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/get_credentials_for_identity_input.dart index 76881a5f20..1ef8ddd869 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/get_credentials_for_identity_input.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/get_credentials_for_identity_input.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity.model.get_credentials_for_identity_input; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/get_credentials_for_identity_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/get_credentials_for_identity_response.dart index 3bda9069de..6f83f4cf28 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/get_credentials_for_identity_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/get_credentials_for_identity_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity.model.get_credentials_for_identity_response; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/get_id_input.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/get_id_input.dart index 2469ffe450..15ed362231 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/get_id_input.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/get_id_input.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity.model.get_id_input; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/get_id_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/get_id_response.dart index 17f61687d0..dfe391a845 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/get_id_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/get_id_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity.model.get_id_response; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/internal_error_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/internal_error_exception.dart index c3aefa1100..4f5a7455e9 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/internal_error_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/internal_error_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity.model.internal_error_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/invalid_identity_pool_configuration_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/invalid_identity_pool_configuration_exception.dart index 2e2b04cb49..c25b63d9fa 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/invalid_identity_pool_configuration_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/invalid_identity_pool_configuration_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity.model.invalid_identity_pool_configuration_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/invalid_parameter_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/invalid_parameter_exception.dart index dd0e1bb993..881a613f75 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/invalid_parameter_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/invalid_parameter_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity.model.invalid_parameter_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/limit_exceeded_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/limit_exceeded_exception.dart index d12231e2d3..4909ca0b94 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/limit_exceeded_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/limit_exceeded_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity.model.limit_exceeded_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/not_authorized_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/not_authorized_exception.dart index 43841286cb..50add67fb4 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/not_authorized_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/not_authorized_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity.model.not_authorized_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/resource_conflict_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/resource_conflict_exception.dart index 5e5f88ad77..cc4b2f9846 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/resource_conflict_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/resource_conflict_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity.model.resource_conflict_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/resource_not_found_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/resource_not_found_exception.dart index 2061531b78..1ba7efb1b3 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/resource_not_found_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/resource_not_found_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity.model.resource_not_found_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/too_many_requests_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/too_many_requests_exception.dart index 01a910e91a..e005c51ca2 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/too_many_requests_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/model/too_many_requests_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity.model.too_many_requests_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/operation/get_credentials_for_identity_operation.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/operation/get_credentials_for_identity_operation.dart index 0a3319e2d0..a70ab6465f 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/operation/get_credentials_for_identity_operation.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/operation/get_credentials_for_identity_operation.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity.operation.get_credentials_for_identity_operation; // ignore_for_file: no_leading_underscores_for_library_prefixes @@ -69,7 +69,7 @@ class GetCredentialsForIdentityOperation extends _i1.HttpOperation< credentialsProvider: _credentialsProvider, isOptional: true, ), - const _i1.WithUserAgent('aws-sdk-dart/0.3.1'), + const _i1.WithUserAgent('aws-sdk-dart/0.3.2'), const _i3.WithSdkInvocationId(), const _i3.WithSdkRequest(), ] + diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/operation/get_id_operation.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/operation/get_id_operation.dart index c7aa76e5c4..5a9ebaa5b3 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/operation/get_id_operation.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity/operation/get_id_operation.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity.operation.get_id_operation; // ignore_for_file: no_leading_underscores_for_library_prefixes @@ -64,7 +64,7 @@ class GetIdOperation extends _i1 credentialsProvider: _credentialsProvider, isOptional: true, ), - const _i1.WithUserAgent('aws-sdk-dart/0.3.1'), + const _i1.WithUserAgent('aws-sdk-dart/0.3.2'), const _i3.WithSdkInvocationId(), const _i3.WithSdkRequest(), ] + diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/cognito_identity_provider_client.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/cognito_identity_provider_client.dart index 5b504d64fd..77dc73bc98 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/cognito_identity_provider_client.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/cognito_identity_provider_client.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.cognito_identity_provider_client; // ignore_for_file: no_leading_underscores_for_library_prefixes @@ -178,7 +178,7 @@ class CognitoIdentityProviderClient { /// Begins setup of time-based one-time password (TOTP) multi-factor authentication (MFA) for a user, with a unique private key that Amazon Cognito generates and returns in the API response. You can authorize an `AssociateSoftwareToken` request with either the user's access token, or a session string from a challenge response that you received from Amazon Cognito. /// - /// Amazon Cognito disassociates an existing software token when you verify the new token in a [VerifySoftwareToken](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_VerifySoftwareToken.html) API request. If you don't verify the software token and your user pool doesn't require MFA, the user can then authenticate with user name and password credentials alone. If your user pool requires TOTP MFA, Amazon Cognito generates an `MFA_SETUP` or `SOFTWARE\_TOKEN\_SETUP` challenge each time your user signs. Complete setup with `AssociateSoftwareToken` and `VerifySoftwareToken`. + /// Amazon Cognito disassociates an existing software token when you verify the new token in a [VerifySoftwareToken](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_VerifySoftwareToken.html) API request. If you don't verify the software token and your user pool doesn't require MFA, the user can then authenticate with user name and password credentials alone. If your user pool requires TOTP MFA, Amazon Cognito generates an `MFA_SETUP` or `SOFTWARE\_TOKEN\_SETUP` challenge each time your user signs in. Complete setup with `AssociateSoftwareToken` and `VerifySoftwareToken`. /// /// After you set up software token MFA for your user, Amazon Cognito generates a `SOFTWARE\_TOKEN\_MFA` challenge when they authenticate. Respond to this challenge with your user's TOTP. /// @@ -340,7 +340,7 @@ class CognitoIdentityProviderClient { /// /// This action might generate an SMS text message. Starting June 1, 2021, US telecom carriers require you to register an origination phone number before you can send SMS messages to US phone numbers. If you use SMS text messages in Amazon Cognito, you must register a phone number with [Amazon Pinpoint](https://console.aws.amazon.com/pinpoint/home/). Amazon Cognito uses the registered number automatically. Otherwise, Amazon Cognito users who must receive SMS messages might not be able to sign up, activate their accounts, or sign in. /// - /// If you have never used SMS text messages with Amazon Cognito or any other Amazon Web Service, Amazon Simple Notification Service might place your account in the SMS sandbox. In _[sandbox mode](https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html)_ , you can send messages only to verified phone numbers. After you test your app while in the sandbox environment, you can move out of the sandbox and into production. For more information, see [SMS message settings for Amazon Cognito user pools](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-sms-settings.html) in the _Amazon Cognito Developer Guide_. + /// If you have never used SMS text messages with Amazon Cognito or any other Amazon Web Servicesservice, Amazon Simple Notification Service might place your account in the SMS sandbox. In _[sandbox mode](https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html)_ , you can send messages only to verified phone numbers. After you test your app while in the sandbox environment, you can move out of the sandbox and into production. For more information, see [SMS message settings for Amazon Cognito user pools](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-sms-settings.html) in the _Amazon Cognito Developer Guide_. _i3.SmithyOperation forgotPassword( ForgotPasswordRequest input, { _i1.AWSHttpClient? client, @@ -410,7 +410,7 @@ class CognitoIdentityProviderClient { /// /// This action might generate an SMS text message. Starting June 1, 2021, US telecom carriers require you to register an origination phone number before you can send SMS messages to US phone numbers. If you use SMS text messages in Amazon Cognito, you must register a phone number with [Amazon Pinpoint](https://console.aws.amazon.com/pinpoint/home/). Amazon Cognito uses the registered number automatically. Otherwise, Amazon Cognito users who must receive SMS messages might not be able to sign up, activate their accounts, or sign in. /// - /// If you have never used SMS text messages with Amazon Cognito or any other Amazon Web Service, Amazon Simple Notification Service might place your account in the SMS sandbox. In _[sandbox mode](https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html)_ , you can send messages only to verified phone numbers. After you test your app while in the sandbox environment, you can move out of the sandbox and into production. For more information, see [SMS message settings for Amazon Cognito user pools](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-sms-settings.html) in the _Amazon Cognito Developer Guide_. + /// If you have never used SMS text messages with Amazon Cognito or any other Amazon Web Servicesservice, Amazon Simple Notification Service might place your account in the SMS sandbox. In _[sandbox mode](https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html)_ , you can send messages only to verified phone numbers. After you test your app while in the sandbox environment, you can move out of the sandbox and into production. For more information, see [SMS message settings for Amazon Cognito user pools](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-sms-settings.html) in the _Amazon Cognito Developer Guide_. _i3.SmithyOperation getUserAttributeVerificationCode( GetUserAttributeVerificationCodeRequest input, { @@ -468,7 +468,7 @@ class CognitoIdentityProviderClient { /// /// This action might generate an SMS text message. Starting June 1, 2021, US telecom carriers require you to register an origination phone number before you can send SMS messages to US phone numbers. If you use SMS text messages in Amazon Cognito, you must register a phone number with [Amazon Pinpoint](https://console.aws.amazon.com/pinpoint/home/). Amazon Cognito uses the registered number automatically. Otherwise, Amazon Cognito users who must receive SMS messages might not be able to sign up, activate their accounts, or sign in. /// - /// If you have never used SMS text messages with Amazon Cognito or any other Amazon Web Service, Amazon Simple Notification Service might place your account in the SMS sandbox. In _[sandbox mode](https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html)_ , you can send messages only to verified phone numbers. After you test your app while in the sandbox environment, you can move out of the sandbox and into production. For more information, see [SMS message settings for Amazon Cognito user pools](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-sms-settings.html) in the _Amazon Cognito Developer Guide_. + /// If you have never used SMS text messages with Amazon Cognito or any other Amazon Web Servicesservice, Amazon Simple Notification Service might place your account in the SMS sandbox. In _[sandbox mode](https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html)_ , you can send messages only to verified phone numbers. After you test your app while in the sandbox environment, you can move out of the sandbox and into production. For more information, see [SMS message settings for Amazon Cognito user pools](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-sms-settings.html) in the _Amazon Cognito Developer Guide_. _i3.SmithyOperation initiateAuth( InitiateAuthRequest input, { _i1.AWSHttpClient? client, @@ -514,7 +514,7 @@ class CognitoIdentityProviderClient { /// /// This action might generate an SMS text message. Starting June 1, 2021, US telecom carriers require you to register an origination phone number before you can send SMS messages to US phone numbers. If you use SMS text messages in Amazon Cognito, you must register a phone number with [Amazon Pinpoint](https://console.aws.amazon.com/pinpoint/home/). Amazon Cognito uses the registered number automatically. Otherwise, Amazon Cognito users who must receive SMS messages might not be able to sign up, activate their accounts, or sign in. /// - /// If you have never used SMS text messages with Amazon Cognito or any other Amazon Web Service, Amazon Simple Notification Service might place your account in the SMS sandbox. In _[sandbox mode](https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html)_ , you can send messages only to verified phone numbers. After you test your app while in the sandbox environment, you can move out of the sandbox and into production. For more information, see [SMS message settings for Amazon Cognito user pools](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-sms-settings.html) in the _Amazon Cognito Developer Guide_. + /// If you have never used SMS text messages with Amazon Cognito or any other Amazon Web Servicesservice, Amazon Simple Notification Service might place your account in the SMS sandbox. In _[sandbox mode](https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html)_ , you can send messages only to verified phone numbers. After you test your app while in the sandbox environment, you can move out of the sandbox and into production. For more information, see [SMS message settings for Amazon Cognito user pools](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-sms-settings.html) in the _Amazon Cognito Developer Guide_. _i3.SmithyOperation resendConfirmationCode( ResendConfirmationCodeRequest input, { _i1.AWSHttpClient? client, @@ -540,7 +540,7 @@ class CognitoIdentityProviderClient { /// /// This action might generate an SMS text message. Starting June 1, 2021, US telecom carriers require you to register an origination phone number before you can send SMS messages to US phone numbers. If you use SMS text messages in Amazon Cognito, you must register a phone number with [Amazon Pinpoint](https://console.aws.amazon.com/pinpoint/home/). Amazon Cognito uses the registered number automatically. Otherwise, Amazon Cognito users who must receive SMS messages might not be able to sign up, activate their accounts, or sign in. /// - /// If you have never used SMS text messages with Amazon Cognito or any other Amazon Web Service, Amazon Simple Notification Service might place your account in the SMS sandbox. In _[sandbox mode](https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html)_ , you can send messages only to verified phone numbers. After you test your app while in the sandbox environment, you can move out of the sandbox and into production. For more information, see [SMS message settings for Amazon Cognito user pools](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-sms-settings.html) in the _Amazon Cognito Developer Guide_. + /// If you have never used SMS text messages with Amazon Cognito or any other Amazon Web Servicesservice, Amazon Simple Notification Service might place your account in the SMS sandbox. In _[sandbox mode](https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html)_ , you can send messages only to verified phone numbers. After you test your app while in the sandbox environment, you can move out of the sandbox and into production. For more information, see [SMS message settings for Amazon Cognito user pools](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-sms-settings.html) in the _Amazon Cognito Developer Guide_. _i3.SmithyOperation respondToAuthChallenge( RespondToAuthChallengeRequest input, { _i1.AWSHttpClient? client, @@ -606,7 +606,7 @@ class CognitoIdentityProviderClient { /// /// This action might generate an SMS text message. Starting June 1, 2021, US telecom carriers require you to register an origination phone number before you can send SMS messages to US phone numbers. If you use SMS text messages in Amazon Cognito, you must register a phone number with [Amazon Pinpoint](https://console.aws.amazon.com/pinpoint/home/). Amazon Cognito uses the registered number automatically. Otherwise, Amazon Cognito users who must receive SMS messages might not be able to sign up, activate their accounts, or sign in. /// - /// If you have never used SMS text messages with Amazon Cognito or any other Amazon Web Service, Amazon Simple Notification Service might place your account in the SMS sandbox. In _[sandbox mode](https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html)_ , you can send messages only to verified phone numbers. After you test your app while in the sandbox environment, you can move out of the sandbox and into production. For more information, see [SMS message settings for Amazon Cognito user pools](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-sms-settings.html) in the _Amazon Cognito Developer Guide_. + /// If you have never used SMS text messages with Amazon Cognito or any other Amazon Web Servicesservice, Amazon Simple Notification Service might place your account in the SMS sandbox. In _[sandbox mode](https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html)_ , you can send messages only to verified phone numbers. After you test your app while in the sandbox environment, you can move out of the sandbox and into production. For more information, see [SMS message settings for Amazon Cognito user pools](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-sms-settings.html) in the _Amazon Cognito Developer Guide_. _i3.SmithyOperation signUp( SignUpRequest input, { _i1.AWSHttpClient? client, @@ -654,7 +654,7 @@ class CognitoIdentityProviderClient { /// /// This action might generate an SMS text message. Starting June 1, 2021, US telecom carriers require you to register an origination phone number before you can send SMS messages to US phone numbers. If you use SMS text messages in Amazon Cognito, you must register a phone number with [Amazon Pinpoint](https://console.aws.amazon.com/pinpoint/home/). Amazon Cognito uses the registered number automatically. Otherwise, Amazon Cognito users who must receive SMS messages might not be able to sign up, activate their accounts, or sign in. /// - /// If you have never used SMS text messages with Amazon Cognito or any other Amazon Web Service, Amazon Simple Notification Service might place your account in the SMS sandbox. In _[sandbox mode](https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html)_ , you can send messages only to verified phone numbers. After you test your app while in the sandbox environment, you can move out of the sandbox and into production. For more information, see [SMS message settings for Amazon Cognito user pools](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-sms-settings.html) in the _Amazon Cognito Developer Guide_. + /// If you have never used SMS text messages with Amazon Cognito or any other Amazon Web Servicesservice, Amazon Simple Notification Service might place your account in the SMS sandbox. In _[sandbox mode](https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html)_ , you can send messages only to verified phone numbers. After you test your app while in the sandbox environment, you can move out of the sandbox and into production. For more information, see [SMS message settings for Amazon Cognito user pools](https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-sms-settings.html) in the _Amazon Cognito Developer Guide_. _i3.SmithyOperation updateUserAttributes( UpdateUserAttributesRequest input, { _i1.AWSHttpClient? client, diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/common/endpoint_resolver.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/common/endpoint_resolver.dart index aa6948f01b..87bbaf7dc7 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/common/endpoint_resolver.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/common/endpoint_resolver.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.common.endpoint_resolver; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/common/serializers.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/common/serializers.dart index 4bd6e82ab8..45d3210bcb 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/common/serializers.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/common/serializers.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.common.serializers; // ignore_for_file: no_leading_underscores_for_library_prefixes @@ -28,6 +28,7 @@ import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/ import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/device_remembered_status_type.dart'; import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/device_secret_verifier_config_type.dart'; import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/device_type.dart'; +import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/email_mfa_settings_type.dart'; import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/enable_software_token_mfa_exception.dart'; import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/expired_code_exception.dart'; import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/forbidden_exception.dart'; @@ -59,6 +60,7 @@ import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/ import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/mfa_option_type.dart'; import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/new_device_metadata_type.dart'; import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/not_authorized_exception.dart'; +import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/password_history_policy_violation_exception.dart'; import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/password_reset_required_exception.dart'; import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/resend_confirmation_code_request.dart'; import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/resend_confirmation_code_response.dart'; @@ -112,6 +114,7 @@ const List<_i1.SmithySerializer> serializers = [ ...ChangePasswordResponse.serializers, ...InvalidPasswordException.serializers, ...LimitExceededException.serializers, + ...PasswordHistoryPolicyViolationException.serializers, ...PasswordResetRequiredException.serializers, ...TooManyRequestsException.serializers, ...UserNotConfirmedException.serializers, @@ -175,6 +178,7 @@ const List<_i1.SmithySerializer> serializers = [ ...UnsupportedTokenTypeException.serializers, ...SmsMfaSettingsType.serializers, ...SoftwareTokenMfaSettingsType.serializers, + ...EmailMfaSettingsType.serializers, ...SetUserMfaPreferenceRequest.serializers, ...SetUserMfaPreferenceResponse.serializers, ...SignUpRequest.serializers, diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/alias_exists_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/alias_exists_exception.dart index 6fe989ea5a..92daad3986 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/alias_exists_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/alias_exists_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.alias_exists_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/analytics_metadata_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/analytics_metadata_type.dart index 0c3b5e5cb1..3ce0fd64f0 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/analytics_metadata_type.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/analytics_metadata_type.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.analytics_metadata_type; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/associate_software_token_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/associate_software_token_request.dart index e85c27e777..68a490b537 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/associate_software_token_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/associate_software_token_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.associate_software_token_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/associate_software_token_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/associate_software_token_response.dart index 5d95699e30..c65a519903 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/associate_software_token_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/associate_software_token_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.associate_software_token_response; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/attribute_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/attribute_type.dart index c05750b94f..d6e81f84e6 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/attribute_type.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/attribute_type.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.attribute_type; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/auth_flow_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/auth_flow_type.dart index b72dedfb0e..63ef0d3e8b 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/auth_flow_type.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/auth_flow_type.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.auth_flow_type; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/authentication_result_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/authentication_result_type.dart index e28c05e8f8..fe4c1436b2 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/authentication_result_type.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/authentication_result_type.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.authentication_result_type; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/challenge_name_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/challenge_name_type.dart index 16183b5270..245f07151e 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/challenge_name_type.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/challenge_name_type.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.challenge_name_type; // ignore_for_file: no_leading_underscores_for_library_prefixes @@ -38,38 +38,44 @@ class ChallengeNameType extends _i1.SmithyEnum { 'DEVICE_SRP_AUTH', ); - static const mfaSetup = ChallengeNameType._( + static const emailOtp = ChallengeNameType._( 4, + 'EMAIL_OTP', + 'EMAIL_OTP', + ); + + static const mfaSetup = ChallengeNameType._( + 5, 'MFA_SETUP', 'MFA_SETUP', ); static const newPasswordRequired = ChallengeNameType._( - 5, + 6, 'NEW_PASSWORD_REQUIRED', 'NEW_PASSWORD_REQUIRED', ); static const passwordVerifier = ChallengeNameType._( - 6, + 7, 'PASSWORD_VERIFIER', 'PASSWORD_VERIFIER', ); static const selectMfaType = ChallengeNameType._( - 7, + 8, 'SELECT_MFA_TYPE', 'SELECT_MFA_TYPE', ); static const smsMfa = ChallengeNameType._( - 8, + 9, 'SMS_MFA', 'SMS_MFA', ); static const softwareTokenMfa = ChallengeNameType._( - 9, + 10, 'SOFTWARE_TOKEN_MFA', 'SOFTWARE_TOKEN_MFA', ); @@ -80,6 +86,7 @@ class ChallengeNameType extends _i1.SmithyEnum { ChallengeNameType.customChallenge, ChallengeNameType.devicePasswordVerifier, ChallengeNameType.deviceSrpAuth, + ChallengeNameType.emailOtp, ChallengeNameType.mfaSetup, ChallengeNameType.newPasswordRequired, ChallengeNameType.passwordVerifier, diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/change_password_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/change_password_request.dart index 1bee4684cf..aca8f246fd 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/change_password_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/change_password_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.change_password_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/change_password_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/change_password_response.dart index 6d32ca2ee8..4dfb38ac75 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/change_password_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/change_password_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.change_password_response; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/code_delivery_details_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/code_delivery_details_type.dart index 34f7889f1f..2017a74f76 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/code_delivery_details_type.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/code_delivery_details_type.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.code_delivery_details_type; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/code_delivery_failure_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/code_delivery_failure_exception.dart index ce4d865c5c..f3a73bfb96 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/code_delivery_failure_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/code_delivery_failure_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.code_delivery_failure_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/code_mismatch_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/code_mismatch_exception.dart index 470c29a6b7..40d59d121e 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/code_mismatch_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/code_mismatch_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.code_mismatch_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/concurrent_modification_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/concurrent_modification_exception.dart index af4d648e10..a93d170315 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/concurrent_modification_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/concurrent_modification_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.concurrent_modification_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_device_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_device_request.dart index c9a359ad63..36ec585c57 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_device_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_device_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.confirm_device_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_device_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_device_response.dart index c4a56e3d20..742d7b7880 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_device_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_device_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.confirm_device_response; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_forgot_password_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_forgot_password_request.dart index 5ee0b35e9a..7d2eae3eb4 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_forgot_password_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_forgot_password_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.confirm_forgot_password_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_forgot_password_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_forgot_password_response.dart index 428faabe8b..a4bd14e09b 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_forgot_password_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_forgot_password_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.confirm_forgot_password_response; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_sign_up_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_sign_up_request.dart index 674e4bf602..a3d08239b0 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_sign_up_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_sign_up_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.confirm_sign_up_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_sign_up_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_sign_up_response.dart index eb41e869cb..caba28a5c6 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_sign_up_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/confirm_sign_up_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.confirm_sign_up_response; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/delete_user_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/delete_user_request.dart index a1945ea8b1..6da56f6fad 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/delete_user_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/delete_user_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.delete_user_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/delivery_medium_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/delivery_medium_type.dart index 157cc2712f..f2d8b3b06b 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/delivery_medium_type.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/delivery_medium_type.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.delivery_medium_type; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/device_remembered_status_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/device_remembered_status_type.dart index b7ec625425..6ea59d3c6e 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/device_remembered_status_type.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/device_remembered_status_type.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.device_remembered_status_type; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/device_secret_verifier_config_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/device_secret_verifier_config_type.dart index 69f90feee7..b001642117 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/device_secret_verifier_config_type.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/device_secret_verifier_config_type.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.device_secret_verifier_config_type; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/device_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/device_type.dart index f909f5c4cc..b48c396c5a 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/device_type.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/device_type.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.device_type; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/email_mfa_settings_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/email_mfa_settings_type.dart new file mode 100644 index 0000000000..f5871bb77d --- /dev/null +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/email_mfa_settings_type.dart @@ -0,0 +1,147 @@ +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. +// ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas + +library amplify_auth_cognito_dart.cognito_identity_provider.model.email_mfa_settings_type; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'package:aws_common/aws_common.dart' as _i1; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:smithy/smithy.dart' as _i2; + +part 'email_mfa_settings_type.g.dart'; + +/// User preferences for multi-factor authentication with email messages. Activates or deactivates email MFA and sets it as the preferred MFA method when multiple methods are available. To activate this setting, [advanced security features](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pool-settings-advanced-security.html) must be active in your user pool. +abstract class EmailMfaSettingsType + with _i1.AWSEquatable + implements Built { + /// User preferences for multi-factor authentication with email messages. Activates or deactivates email MFA and sets it as the preferred MFA method when multiple methods are available. To activate this setting, [advanced security features](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pool-settings-advanced-security.html) must be active in your user pool. + factory EmailMfaSettingsType({ + bool? enabled, + bool? preferredMfa, + }) { + enabled ??= false; + preferredMfa ??= false; + return _$EmailMfaSettingsType._( + enabled: enabled, + preferredMfa: preferredMfa, + ); + } + + /// User preferences for multi-factor authentication with email messages. Activates or deactivates email MFA and sets it as the preferred MFA method when multiple methods are available. To activate this setting, [advanced security features](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pool-settings-advanced-security.html) must be active in your user pool. + factory EmailMfaSettingsType.build( + [void Function(EmailMfaSettingsTypeBuilder) updates]) = + _$EmailMfaSettingsType; + + const EmailMfaSettingsType._(); + + static const List<_i2.SmithySerializer> serializers = [ + EmailMfaSettingsTypeAwsJson11Serializer() + ]; + + @BuiltValueHook(initializeBuilder: true) + static void _init(EmailMfaSettingsTypeBuilder b) { + b + ..enabled = false + ..preferredMfa = false; + } + + /// Specifies whether email message MFA is active for a user. When the value of this parameter is `Enabled`, the user will be prompted for MFA during all sign-in attempts, unless device tracking is turned on and the device has been trusted. + bool get enabled; + + /// Specifies whether email message MFA is the user's preferred method. + bool get preferredMfa; + @override + List get props => [ + enabled, + preferredMfa, + ]; + + @override + String toString() { + final helper = newBuiltValueToStringHelper('EmailMfaSettingsType') + ..add( + 'enabled', + enabled, + ) + ..add( + 'preferredMfa', + preferredMfa, + ); + return helper.toString(); + } +} + +class EmailMfaSettingsTypeAwsJson11Serializer + extends _i2.StructuredSmithySerializer { + const EmailMfaSettingsTypeAwsJson11Serializer() + : super('EmailMfaSettingsType'); + + @override + Iterable get types => const [ + EmailMfaSettingsType, + _$EmailMfaSettingsType, + ]; + + @override + Iterable<_i2.ShapeId> get supportedProtocols => const [ + _i2.ShapeId( + namespace: 'aws.protocols', + shape: 'awsJson1_1', + ) + ]; + + @override + EmailMfaSettingsType deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = EmailMfaSettingsTypeBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final value = iterator.current; + if (value == null) { + continue; + } + switch (key) { + case 'Enabled': + result.enabled = (serializers.deserialize( + value, + specifiedType: const FullType(bool), + ) as bool); + case 'PreferredMfa': + result.preferredMfa = (serializers.deserialize( + value, + specifiedType: const FullType(bool), + ) as bool); + } + } + + return result.build(); + } + + @override + Iterable serialize( + Serializers serializers, + EmailMfaSettingsType object, { + FullType specifiedType = FullType.unspecified, + }) { + final result$ = []; + final EmailMfaSettingsType(:enabled, :preferredMfa) = object; + result$.addAll([ + 'Enabled', + serializers.serialize( + enabled, + specifiedType: const FullType(bool), + ), + 'PreferredMfa', + serializers.serialize( + preferredMfa, + specifiedType: const FullType(bool), + ), + ]); + return result$; + } +} diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/email_mfa_settings_type.g.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/email_mfa_settings_type.g.dart new file mode 100644 index 0000000000..9be203c737 --- /dev/null +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/email_mfa_settings_type.g.dart @@ -0,0 +1,106 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'email_mfa_settings_type.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$EmailMfaSettingsType extends EmailMfaSettingsType { + @override + final bool enabled; + @override + final bool preferredMfa; + + factory _$EmailMfaSettingsType( + [void Function(EmailMfaSettingsTypeBuilder)? updates]) => + (new EmailMfaSettingsTypeBuilder()..update(updates))._build(); + + _$EmailMfaSettingsType._({required this.enabled, required this.preferredMfa}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + enabled, r'EmailMfaSettingsType', 'enabled'); + BuiltValueNullFieldError.checkNotNull( + preferredMfa, r'EmailMfaSettingsType', 'preferredMfa'); + } + + @override + EmailMfaSettingsType rebuild( + void Function(EmailMfaSettingsTypeBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + EmailMfaSettingsTypeBuilder toBuilder() => + new EmailMfaSettingsTypeBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is EmailMfaSettingsType && + enabled == other.enabled && + preferredMfa == other.preferredMfa; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, enabled.hashCode); + _$hash = $jc(_$hash, preferredMfa.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } +} + +class EmailMfaSettingsTypeBuilder + implements Builder { + _$EmailMfaSettingsType? _$v; + + bool? _enabled; + bool? get enabled => _$this._enabled; + set enabled(bool? enabled) => _$this._enabled = enabled; + + bool? _preferredMfa; + bool? get preferredMfa => _$this._preferredMfa; + set preferredMfa(bool? preferredMfa) => _$this._preferredMfa = preferredMfa; + + EmailMfaSettingsTypeBuilder() { + EmailMfaSettingsType._init(this); + } + + EmailMfaSettingsTypeBuilder get _$this { + final $v = _$v; + if ($v != null) { + _enabled = $v.enabled; + _preferredMfa = $v.preferredMfa; + _$v = null; + } + return this; + } + + @override + void replace(EmailMfaSettingsType other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$EmailMfaSettingsType; + } + + @override + void update(void Function(EmailMfaSettingsTypeBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + EmailMfaSettingsType build() => _build(); + + _$EmailMfaSettingsType _build() { + final _$result = _$v ?? + new _$EmailMfaSettingsType._( + enabled: BuiltValueNullFieldError.checkNotNull( + enabled, r'EmailMfaSettingsType', 'enabled'), + preferredMfa: BuiltValueNullFieldError.checkNotNull( + preferredMfa, r'EmailMfaSettingsType', 'preferredMfa')); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/enable_software_token_mfa_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/enable_software_token_mfa_exception.dart index ebfbade44b..dfbd457723 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/enable_software_token_mfa_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/enable_software_token_mfa_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.enable_software_token_mfa_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/expired_code_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/expired_code_exception.dart index 29f4dc36e5..f6ab049ad0 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/expired_code_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/expired_code_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.expired_code_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/forbidden_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/forbidden_exception.dart index 37ccbc6dcd..b97418f44b 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/forbidden_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/forbidden_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.forbidden_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/forget_device_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/forget_device_request.dart index 57fa4dfe45..f716905bf4 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/forget_device_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/forget_device_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.forget_device_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/forgot_password_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/forgot_password_request.dart index 206bf31593..de772a3506 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/forgot_password_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/forgot_password_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.forgot_password_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/forgot_password_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/forgot_password_response.dart index 92fe7f3db7..2d77bdb4ac 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/forgot_password_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/forgot_password_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.forgot_password_response; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_device_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_device_request.dart index 6f949ad858..d6068a3e65 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_device_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_device_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.get_device_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_device_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_device_response.dart index 62edc0d585..33bf747c39 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_device_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_device_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.get_device_response; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_user_attribute_verification_code_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_user_attribute_verification_code_request.dart index 183f2e2cb8..bc9f259d32 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_user_attribute_verification_code_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_user_attribute_verification_code_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.get_user_attribute_verification_code_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_user_attribute_verification_code_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_user_attribute_verification_code_response.dart index ab94635e1a..92e05abeac 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_user_attribute_verification_code_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_user_attribute_verification_code_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.get_user_attribute_verification_code_response; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_user_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_user_request.dart index eea378cd8a..61c037aa61 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_user_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_user_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.get_user_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_user_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_user_response.dart index eb690fbcbf..249a5a3fdf 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_user_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/get_user_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.get_user_response; // ignore_for_file: no_leading_underscores_for_library_prefixes @@ -66,7 +66,7 @@ abstract class GetUserResponse /// The user's preferred MFA setting. String? get preferredMfaSetting; - /// The MFA options that are activated for the user. The possible values in this list are `SMS_MFA` and `SOFTWARE\_TOKEN\_MFA`. + /// The MFA options that are activated for the user. The possible values in this list are `SMS_MFA`, `EMAIL_OTP`, and `SOFTWARE\_TOKEN\_MFA`. _i2.BuiltList? get userMfaSettingList; @override List get props => [ diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/global_sign_out_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/global_sign_out_request.dart index 924d17c3d0..a19ee40a56 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/global_sign_out_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/global_sign_out_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.global_sign_out_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/global_sign_out_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/global_sign_out_response.dart index 2941bae7c3..0cd0cad3ba 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/global_sign_out_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/global_sign_out_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.global_sign_out_response; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/initiate_auth_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/initiate_auth_request.dart index 299a26378f..d950158c01 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/initiate_auth_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/initiate_auth_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.initiate_auth_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/initiate_auth_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/initiate_auth_response.dart index b0d075afe3..b4d2d39b01 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/initiate_auth_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/initiate_auth_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.initiate_auth_response; // ignore_for_file: no_leading_underscores_for_library_prefixes @@ -58,7 +58,9 @@ abstract class InitiateAuthResponse /// /// All of the following challenges require `USERNAME` and `SECRET_HASH` (if applicable) in the parameters. /// - /// * `SMS_MFA`: Next challenge is to supply an `SMS\_MFA\_CODE`, delivered via SMS. + /// * `SMS_MFA`: Next challenge is to supply an `SMS\_MFA\_CODE`that your user pool delivered in an SMS message. + /// + /// * `EMAIL_OTP`: Next challenge is to supply an `EMAIL\_OTP\_CODE` that your user pool delivered in an email message. /// /// * `PASSWORD_VERIFIER`: Next challenge is to supply `PASSWORD\_CLAIM\_SIGNATURE`, `PASSWORD\_CLAIM\_SECRET_BLOCK`, and `TIMESTAMP` after the client-side SRP calculations. /// diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/internal_error_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/internal_error_exception.dart index deacb16eb0..ba19414e69 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/internal_error_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/internal_error_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.internal_error_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_email_role_access_policy_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_email_role_access_policy_exception.dart index f5c51b1a95..9593759c9c 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_email_role_access_policy_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_email_role_access_policy_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.invalid_email_role_access_policy_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_lambda_response_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_lambda_response_exception.dart index 265347fda5..dcfeb43424 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_lambda_response_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_lambda_response_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.invalid_lambda_response_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_parameter_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_parameter_exception.dart index ba0823619b..daed39aae1 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_parameter_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_parameter_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.invalid_parameter_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_password_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_password_exception.dart index 52c7699f17..e4f651a82b 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_password_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_password_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.invalid_password_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_sms_role_access_policy_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_sms_role_access_policy_exception.dart index 15e2e29d4d..857cce6009 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_sms_role_access_policy_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_sms_role_access_policy_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.invalid_sms_role_access_policy_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_sms_role_trust_relationship_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_sms_role_trust_relationship_exception.dart index 515fc9d07d..cf52736fff 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_sms_role_trust_relationship_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_sms_role_trust_relationship_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.invalid_sms_role_trust_relationship_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_user_pool_configuration_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_user_pool_configuration_exception.dart index dbf2b347dc..62d8b0cec2 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_user_pool_configuration_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/invalid_user_pool_configuration_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.invalid_user_pool_configuration_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/limit_exceeded_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/limit_exceeded_exception.dart index c4ded607b3..fc3900ee8d 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/limit_exceeded_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/limit_exceeded_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.limit_exceeded_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/list_devices_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/list_devices_request.dart index 07201dab3d..3b2a6f0834 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/list_devices_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/list_devices_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.list_devices_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/list_devices_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/list_devices_response.dart index 50771c2b25..8de544538a 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/list_devices_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/list_devices_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.list_devices_response; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/mfa_method_not_found_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/mfa_method_not_found_exception.dart index d159df70a6..f223bc69b0 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/mfa_method_not_found_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/mfa_method_not_found_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.mfa_method_not_found_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/mfa_option_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/mfa_option_type.dart index c880f267c7..e6d103c6da 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/mfa_option_type.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/mfa_option_type.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.mfa_option_type; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/new_device_metadata_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/new_device_metadata_type.dart index 69a24a5ad4..56c8dc4549 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/new_device_metadata_type.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/new_device_metadata_type.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.new_device_metadata_type; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/not_authorized_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/not_authorized_exception.dart index 8b8c71a14f..667a4e4e7e 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/not_authorized_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/not_authorized_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.not_authorized_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/password_history_policy_violation_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/password_history_policy_violation_exception.dart new file mode 100644 index 0000000000..8558e99e29 --- /dev/null +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/password_history_policy_violation_exception.dart @@ -0,0 +1,148 @@ +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. +// ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas + +library amplify_auth_cognito_dart.cognito_identity_provider.model.password_history_policy_violation_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes + +import 'package:aws_common/aws_common.dart' as _i1; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:smithy/smithy.dart' as _i2; + +part 'password_history_policy_violation_exception.g.dart'; + +/// The message returned when a user's new password matches a previous password and doesn't comply with the password-history policy. +abstract class PasswordHistoryPolicyViolationException + with + _i1.AWSEquatable + implements + Built, + _i2.SmithyHttpException { + /// The message returned when a user's new password matches a previous password and doesn't comply with the password-history policy. + factory PasswordHistoryPolicyViolationException({String? message}) { + return _$PasswordHistoryPolicyViolationException._(message: message); + } + + /// The message returned when a user's new password matches a previous password and doesn't comply with the password-history policy. + factory PasswordHistoryPolicyViolationException.build( + [void Function(PasswordHistoryPolicyViolationExceptionBuilder) + updates]) = _$PasswordHistoryPolicyViolationException; + + const PasswordHistoryPolicyViolationException._(); + + /// Constructs a [PasswordHistoryPolicyViolationException] from a [payload] and [response]. + factory PasswordHistoryPolicyViolationException.fromResponse( + PasswordHistoryPolicyViolationException payload, + _i1.AWSBaseHttpResponse response, + ) => + payload.rebuild((b) { + b.headers = response.headers; + }); + + static const List< + _i2.SmithySerializer> + serializers = [ + PasswordHistoryPolicyViolationExceptionAwsJson11Serializer() + ]; + + @override + String? get message; + @override + _i2.ShapeId get shapeId => const _i2.ShapeId( + namespace: 'com.amazonaws.cognitoidentityprovider', + shape: 'PasswordHistoryPolicyViolationException', + ); + + @override + _i2.RetryConfig? get retryConfig => null; + + @override + @BuiltValueField(compare: false) + int get statusCode => 400; + + @override + @BuiltValueField(compare: false) + Map? get headers; + @override + Exception? get underlyingException => null; + + @override + List get props => [message]; + + @override + String toString() { + final helper = + newBuiltValueToStringHelper('PasswordHistoryPolicyViolationException') + ..add( + 'message', + message, + ); + return helper.toString(); + } +} + +class PasswordHistoryPolicyViolationExceptionAwsJson11Serializer extends _i2 + .StructuredSmithySerializer { + const PasswordHistoryPolicyViolationExceptionAwsJson11Serializer() + : super('PasswordHistoryPolicyViolationException'); + + @override + Iterable get types => const [ + PasswordHistoryPolicyViolationException, + _$PasswordHistoryPolicyViolationException, + ]; + + @override + Iterable<_i2.ShapeId> get supportedProtocols => const [ + _i2.ShapeId( + namespace: 'aws.protocols', + shape: 'awsJson1_1', + ) + ]; + + @override + PasswordHistoryPolicyViolationException deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final result = PasswordHistoryPolicyViolationExceptionBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final value = iterator.current; + if (value == null) { + continue; + } + switch (key) { + case 'message': + result.message = (serializers.deserialize( + value, + specifiedType: const FullType(String), + ) as String); + } + } + + return result.build(); + } + + @override + Iterable serialize( + Serializers serializers, + PasswordHistoryPolicyViolationException object, { + FullType specifiedType = FullType.unspecified, + }) { + final result$ = []; + final PasswordHistoryPolicyViolationException(:message) = object; + if (message != null) { + result$ + ..add('message') + ..add(serializers.serialize( + message, + specifiedType: const FullType(String), + )); + } + return result$; + } +} diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/password_history_policy_violation_exception.g.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/password_history_policy_violation_exception.g.dart new file mode 100644 index 0000000000..14462c7c57 --- /dev/null +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/password_history_policy_violation_exception.g.dart @@ -0,0 +1,101 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'password_history_policy_violation_exception.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$PasswordHistoryPolicyViolationException + extends PasswordHistoryPolicyViolationException { + @override + final String? message; + @override + final Map? headers; + + factory _$PasswordHistoryPolicyViolationException( + [void Function(PasswordHistoryPolicyViolationExceptionBuilder)? + updates]) => + (new PasswordHistoryPolicyViolationExceptionBuilder()..update(updates)) + ._build(); + + _$PasswordHistoryPolicyViolationException._({this.message, this.headers}) + : super._(); + + @override + PasswordHistoryPolicyViolationException rebuild( + void Function(PasswordHistoryPolicyViolationExceptionBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + PasswordHistoryPolicyViolationExceptionBuilder toBuilder() => + new PasswordHistoryPolicyViolationExceptionBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is PasswordHistoryPolicyViolationException && + message == other.message; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, message.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } +} + +class PasswordHistoryPolicyViolationExceptionBuilder + implements + Builder { + _$PasswordHistoryPolicyViolationException? _$v; + + String? _message; + String? get message => _$this._message; + set message(String? message) => _$this._message = message; + + Map? _headers; + Map? get headers => _$this._headers; + set headers(Map? headers) => _$this._headers = headers; + + PasswordHistoryPolicyViolationExceptionBuilder(); + + PasswordHistoryPolicyViolationExceptionBuilder get _$this { + final $v = _$v; + if ($v != null) { + _message = $v.message; + _headers = $v.headers; + _$v = null; + } + return this; + } + + @override + void replace(PasswordHistoryPolicyViolationException other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$PasswordHistoryPolicyViolationException; + } + + @override + void update( + void Function(PasswordHistoryPolicyViolationExceptionBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + PasswordHistoryPolicyViolationException build() => _build(); + + _$PasswordHistoryPolicyViolationException _build() { + final _$result = _$v ?? + new _$PasswordHistoryPolicyViolationException._( + message: message, headers: headers); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/password_reset_required_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/password_reset_required_exception.dart index 3d93fd22a1..0e4500dc25 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/password_reset_required_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/password_reset_required_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.password_reset_required_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/resend_confirmation_code_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/resend_confirmation_code_request.dart index 4cf8678d2d..94ad518a90 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/resend_confirmation_code_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/resend_confirmation_code_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.resend_confirmation_code_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/resend_confirmation_code_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/resend_confirmation_code_response.dart index 808df308e4..6a214d00dc 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/resend_confirmation_code_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/resend_confirmation_code_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.resend_confirmation_code_response; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/resource_not_found_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/resource_not_found_exception.dart index d54f471e9e..925645afe5 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/resource_not_found_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/resource_not_found_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.resource_not_found_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/respond_to_auth_challenge_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/respond_to_auth_challenge_request.dart index 6d45689bc9..06ac52c376 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/respond_to_auth_challenge_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/respond_to_auth_challenge_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.respond_to_auth_challenge_request; // ignore_for_file: no_leading_underscores_for_library_prefixes @@ -79,10 +79,16 @@ abstract class RespondToAuthChallengeRequest /// /// SMS_MFA /// - /// `"ChallengeName": "SMS\_MFA", "ChallengeResponses": {"SMS\_MFA\_CODE": "\[SMS\_code\]", "USERNAME": "\[username\]"}` + /// `"ChallengeName": "SMS\_MFA", "ChallengeResponses": {"SMS\_MFA_CODE": "\[code\]", "USERNAME": "\[username\]"}` + /// + /// EMAIL_OTP + /// + /// `"ChallengeName": "EMAIL\_OTP", "ChallengeResponses": {"EMAIL\_OTP_CODE": "\[code\]", "USERNAME": "\[username\]"}` /// /// PASSWORD_VERIFIER /// + /// This challenge response is part of the SRP flow. Amazon Cognito requires that your application respond to this challenge within a few seconds. When the response time exceeds this period, your user pool returns a `NotAuthorizedException` error. + /// /// `"ChallengeName": "PASSWORD\_VERIFIER", "ChallengeResponses": {"PASSWORD\_CLAIM\_SIGNATURE": "\[claim\_signature\]", "PASSWORD\_CLAIM\_SECRET\_BLOCK": "\[secret\_block\]", "TIMESTAMP": \[timestamp\], "USERNAME": "\[username\]"}` /// /// Add `"DEVICE_KEY"` when you sign in with a remembered device. diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/respond_to_auth_challenge_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/respond_to_auth_challenge_response.dart index d2cef93d19..8ea2f06cec 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/respond_to_auth_challenge_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/respond_to_auth_challenge_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.respond_to_auth_challenge_response; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/revoke_token_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/revoke_token_request.dart index 7a46034d7d..423af9fabe 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/revoke_token_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/revoke_token_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.revoke_token_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/revoke_token_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/revoke_token_response.dart index 566e257c2a..d9e99039d3 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/revoke_token_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/revoke_token_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.revoke_token_response; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/set_user_mfa_preference_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/set_user_mfa_preference_request.dart index 6a541e339c..04bb1ad29b 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/set_user_mfa_preference_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/set_user_mfa_preference_request.dart @@ -1,8 +1,9 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.set_user_mfa_preference_request; // ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/email_mfa_settings_type.dart'; import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/sms_mfa_settings_type.dart'; import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/software_token_mfa_settings_type.dart'; import 'package:aws_common/aws_common.dart' as _i2; @@ -21,11 +22,13 @@ abstract class SetUserMfaPreferenceRequest factory SetUserMfaPreferenceRequest({ SmsMfaSettingsType? smsMfaSettings, SoftwareTokenMfaSettingsType? softwareTokenMfaSettings, + EmailMfaSettingsType? emailMfaSettings, required String accessToken, }) { return _$SetUserMfaPreferenceRequest._( smsMfaSettings: smsMfaSettings, softwareTokenMfaSettings: softwareTokenMfaSettings, + emailMfaSettings: emailMfaSettings, accessToken: accessToken, ); } @@ -46,12 +49,15 @@ abstract class SetUserMfaPreferenceRequest static const List<_i1.SmithySerializer> serializers = [SetUserMfaPreferenceRequestAwsJson11Serializer()]; - /// The SMS text message multi-factor authentication (MFA) settings. + /// User preferences for SMS message MFA. Activates or deactivates SMS MFA and sets it as the preferred MFA method when multiple methods are available. SmsMfaSettingsType? get smsMfaSettings; - /// The time-based one-time password (TOTP) software token MFA settings. + /// User preferences for time-based one-time password (TOTP) MFA. Activates or deactivates TOTP MFA and sets it as the preferred MFA method when multiple methods are available. SoftwareTokenMfaSettingsType? get softwareTokenMfaSettings; + /// User preferences for email message MFA. Activates or deactivates email MFA and sets it as the preferred MFA method when multiple methods are available. To activate this setting, [advanced security features](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pool-settings-advanced-security.html) must be active in your user pool. + EmailMfaSettingsType? get emailMfaSettings; + /// A valid access token that Amazon Cognito issued to the user whose MFA preference you want to set. String get accessToken; @override @@ -61,6 +67,7 @@ abstract class SetUserMfaPreferenceRequest List get props => [ smsMfaSettings, softwareTokenMfaSettings, + emailMfaSettings, accessToken, ]; @@ -75,6 +82,10 @@ abstract class SetUserMfaPreferenceRequest 'softwareTokenMfaSettings', softwareTokenMfaSettings, ) + ..add( + 'emailMfaSettings', + emailMfaSettings, + ) ..add( 'accessToken', '***SENSITIVE***', @@ -128,6 +139,11 @@ class SetUserMfaPreferenceRequestAwsJson11Serializer value, specifiedType: const FullType(SoftwareTokenMfaSettingsType), ) as SoftwareTokenMfaSettingsType)); + case 'EmailMfaSettings': + result.emailMfaSettings.replace((serializers.deserialize( + value, + specifiedType: const FullType(EmailMfaSettingsType), + ) as EmailMfaSettingsType)); case 'AccessToken': result.accessToken = (serializers.deserialize( value, @@ -149,6 +165,7 @@ class SetUserMfaPreferenceRequestAwsJson11Serializer final SetUserMfaPreferenceRequest( :smsMfaSettings, :softwareTokenMfaSettings, + :emailMfaSettings, :accessToken ) = object; result$.addAll([ @@ -174,6 +191,14 @@ class SetUserMfaPreferenceRequestAwsJson11Serializer specifiedType: const FullType(SoftwareTokenMfaSettingsType), )); } + if (emailMfaSettings != null) { + result$ + ..add('EmailMfaSettings') + ..add(serializers.serialize( + emailMfaSettings, + specifiedType: const FullType(EmailMfaSettingsType), + )); + } return result$; } } diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/set_user_mfa_preference_request.g.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/set_user_mfa_preference_request.g.dart index ca68a57587..fec5ce2c1e 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/set_user_mfa_preference_request.g.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/set_user_mfa_preference_request.g.dart @@ -12,6 +12,8 @@ class _$SetUserMfaPreferenceRequest extends SetUserMfaPreferenceRequest { @override final SoftwareTokenMfaSettingsType? softwareTokenMfaSettings; @override + final EmailMfaSettingsType? emailMfaSettings; + @override final String accessToken; factory _$SetUserMfaPreferenceRequest( @@ -21,6 +23,7 @@ class _$SetUserMfaPreferenceRequest extends SetUserMfaPreferenceRequest { _$SetUserMfaPreferenceRequest._( {this.smsMfaSettings, this.softwareTokenMfaSettings, + this.emailMfaSettings, required this.accessToken}) : super._() { BuiltValueNullFieldError.checkNotNull( @@ -42,6 +45,7 @@ class _$SetUserMfaPreferenceRequest extends SetUserMfaPreferenceRequest { return other is SetUserMfaPreferenceRequest && smsMfaSettings == other.smsMfaSettings && softwareTokenMfaSettings == other.softwareTokenMfaSettings && + emailMfaSettings == other.emailMfaSettings && accessToken == other.accessToken; } @@ -50,6 +54,7 @@ class _$SetUserMfaPreferenceRequest extends SetUserMfaPreferenceRequest { var _$hash = 0; _$hash = $jc(_$hash, smsMfaSettings.hashCode); _$hash = $jc(_$hash, softwareTokenMfaSettings.hashCode); + _$hash = $jc(_$hash, emailMfaSettings.hashCode); _$hash = $jc(_$hash, accessToken.hashCode); _$hash = $jf(_$hash); return _$hash; @@ -76,6 +81,12 @@ class SetUserMfaPreferenceRequestBuilder SoftwareTokenMfaSettingsTypeBuilder? softwareTokenMfaSettings) => _$this._softwareTokenMfaSettings = softwareTokenMfaSettings; + EmailMfaSettingsTypeBuilder? _emailMfaSettings; + EmailMfaSettingsTypeBuilder get emailMfaSettings => + _$this._emailMfaSettings ??= new EmailMfaSettingsTypeBuilder(); + set emailMfaSettings(EmailMfaSettingsTypeBuilder? emailMfaSettings) => + _$this._emailMfaSettings = emailMfaSettings; + String? _accessToken; String? get accessToken => _$this._accessToken; set accessToken(String? accessToken) => _$this._accessToken = accessToken; @@ -87,6 +98,7 @@ class SetUserMfaPreferenceRequestBuilder if ($v != null) { _smsMfaSettings = $v.smsMfaSettings?.toBuilder(); _softwareTokenMfaSettings = $v.softwareTokenMfaSettings?.toBuilder(); + _emailMfaSettings = $v.emailMfaSettings?.toBuilder(); _accessToken = $v.accessToken; _$v = null; } @@ -114,6 +126,7 @@ class SetUserMfaPreferenceRequestBuilder new _$SetUserMfaPreferenceRequest._( smsMfaSettings: _smsMfaSettings?.build(), softwareTokenMfaSettings: _softwareTokenMfaSettings?.build(), + emailMfaSettings: _emailMfaSettings?.build(), accessToken: BuiltValueNullFieldError.checkNotNull( accessToken, r'SetUserMfaPreferenceRequest', 'accessToken')); } catch (_) { @@ -123,6 +136,8 @@ class SetUserMfaPreferenceRequestBuilder _smsMfaSettings?.build(); _$failedField = 'softwareTokenMfaSettings'; _softwareTokenMfaSettings?.build(); + _$failedField = 'emailMfaSettings'; + _emailMfaSettings?.build(); } catch (e) { throw new BuiltValueNestedFieldError( r'SetUserMfaPreferenceRequest', _$failedField, e.toString()); diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/set_user_mfa_preference_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/set_user_mfa_preference_response.dart index 371c315986..bfb06d87f1 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/set_user_mfa_preference_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/set_user_mfa_preference_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.set_user_mfa_preference_response; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/sign_up_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/sign_up_request.dart index c3363048cb..8709755f15 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/sign_up_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/sign_up_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.sign_up_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/sign_up_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/sign_up_response.dart index c20050a0b7..5c5dc0cf4c 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/sign_up_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/sign_up_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.sign_up_response; // ignore_for_file: no_leading_underscores_for_library_prefixes @@ -57,7 +57,7 @@ abstract class SignUpResponse /// The code delivery details returned by the server response to the user registration request. CodeDeliveryDetailsType? get codeDeliveryDetails; - /// The UUID of the authenticated user. This isn't the same as `username`. + /// The 128-bit ID of the authenticated user. This isn't the same as `username`. String get userSub; @override List get props => [ diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/sms_mfa_settings_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/sms_mfa_settings_type.dart index 5fbcc78d0a..c69f645d76 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/sms_mfa_settings_type.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/sms_mfa_settings_type.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.sms_mfa_settings_type; // ignore_for_file: no_leading_underscores_for_library_prefixes @@ -45,7 +45,7 @@ abstract class SmsMfaSettingsType ..preferredMfa = false; } - /// Specifies whether SMS text message MFA is activated. If an MFA type is activated for a user, the user will be prompted for MFA during all sign-in attempts, unless device tracking is turned on and the device has been trusted. + /// Specifies whether SMS message MFA is activated. If an MFA type is activated for a user, the user will be prompted for MFA during all sign-in attempts, unless device tracking is turned on and the device has been trusted. bool get enabled; /// Specifies whether SMS is the preferred MFA method. diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/software_token_mfa_not_found_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/software_token_mfa_not_found_exception.dart index b886706039..b3e013dc50 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/software_token_mfa_not_found_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/software_token_mfa_not_found_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.software_token_mfa_not_found_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/software_token_mfa_settings_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/software_token_mfa_settings_type.dart index 25cfafd5a3..1aee62a4d4 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/software_token_mfa_settings_type.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/software_token_mfa_settings_type.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.software_token_mfa_settings_type; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/too_many_failed_attempts_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/too_many_failed_attempts_exception.dart index c487f39ff6..df9e4d77e4 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/too_many_failed_attempts_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/too_many_failed_attempts_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.too_many_failed_attempts_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/too_many_requests_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/too_many_requests_exception.dart index b1cb3aaa5f..dcf1d32175 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/too_many_requests_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/too_many_requests_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.too_many_requests_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/unauthorized_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/unauthorized_exception.dart index 50ecabe32d..e5c09b5106 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/unauthorized_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/unauthorized_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.unauthorized_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/unexpected_lambda_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/unexpected_lambda_exception.dart index 34a02e236b..474492765a 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/unexpected_lambda_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/unexpected_lambda_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.unexpected_lambda_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/unsupported_operation_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/unsupported_operation_exception.dart index c31068e2ae..0e4b511b26 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/unsupported_operation_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/unsupported_operation_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.unsupported_operation_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/unsupported_token_type_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/unsupported_token_type_exception.dart index 2979954ab5..acff97bd7d 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/unsupported_token_type_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/unsupported_token_type_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.unsupported_token_type_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/update_device_status_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/update_device_status_request.dart index 1935e80768..3c50ce8453 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/update_device_status_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/update_device_status_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.update_device_status_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/update_device_status_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/update_device_status_response.dart index 970c2e9b97..81f5daaa34 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/update_device_status_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/update_device_status_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.update_device_status_response; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/update_user_attributes_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/update_user_attributes_request.dart index 49238c60f8..50c621fa40 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/update_user_attributes_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/update_user_attributes_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.update_user_attributes_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/update_user_attributes_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/update_user_attributes_response.dart index a8dbfabd2c..65a464efff 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/update_user_attributes_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/update_user_attributes_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.update_user_attributes_response; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/user_context_data_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/user_context_data_type.dart index 5f214b4004..f98d85cfd4 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/user_context_data_type.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/user_context_data_type.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.user_context_data_type; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/user_lambda_validation_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/user_lambda_validation_exception.dart index 225e45dbca..19a37c5299 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/user_lambda_validation_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/user_lambda_validation_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.user_lambda_validation_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/user_not_confirmed_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/user_not_confirmed_exception.dart index a75f0605f2..1ba1c2d2e8 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/user_not_confirmed_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/user_not_confirmed_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.user_not_confirmed_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/user_not_found_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/user_not_found_exception.dart index 9d0d33889c..060958dac4 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/user_not_found_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/user_not_found_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.user_not_found_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/username_exists_exception.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/username_exists_exception.dart index 0d1ad7b19b..6a5e063454 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/username_exists_exception.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/username_exists_exception.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.username_exists_exception; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/verify_software_token_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/verify_software_token_request.dart index 78199373a4..b880b6ff91 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/verify_software_token_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/verify_software_token_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.verify_software_token_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/verify_software_token_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/verify_software_token_response.dart index 706fc241fe..5084e7f717 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/verify_software_token_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/verify_software_token_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.verify_software_token_response; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/verify_software_token_response_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/verify_software_token_response_type.dart index 4fa5346f09..5de62aad58 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/verify_software_token_response_type.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/verify_software_token_response_type.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.verify_software_token_response_type; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/verify_user_attribute_request.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/verify_user_attribute_request.dart index 7603269bcb..0ab9eb603b 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/verify_user_attribute_request.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/verify_user_attribute_request.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.verify_user_attribute_request; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/verify_user_attribute_response.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/verify_user_attribute_response.dart index 79883fe9ed..2bd2b4cd53 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/verify_user_attribute_response.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/verify_user_attribute_response.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.model.verify_user_attribute_response; // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/associate_software_token_operation.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/associate_software_token_operation.dart index 8a63714d88..a59df7d709 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/associate_software_token_operation.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/associate_software_token_operation.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.operation.associate_software_token_operation; // ignore_for_file: no_leading_underscores_for_library_prefixes @@ -23,7 +23,7 @@ import 'package:smithy_aws/smithy_aws.dart' as _i3; /// Begins setup of time-based one-time password (TOTP) multi-factor authentication (MFA) for a user, with a unique private key that Amazon Cognito generates and returns in the API response. You can authorize an `AssociateSoftwareToken` request with either the user's access token, or a session string from a challenge response that you received from Amazon Cognito. /// -/// Amazon Cognito disassociates an existing software token when you verify the new token in a [VerifySoftwareToken](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_VerifySoftwareToken.html) API request. If you don't verify the software token and your user pool doesn't require MFA, the user can then authenticate with user name and password credentials alone. If your user pool requires TOTP MFA, Amazon Cognito generates an `MFA_SETUP` or `SOFTWARE\_TOKEN\_SETUP` challenge each time your user signs. Complete setup with `AssociateSoftwareToken` and `VerifySoftwareToken`. +/// Amazon Cognito disassociates an existing software token when you verify the new token in a [VerifySoftwareToken](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_VerifySoftwareToken.html) API request. If you don't verify the software token and your user pool doesn't require MFA, the user can then authenticate with user name and password credentials alone. If your user pool requires TOTP MFA, Amazon Cognito generates an `MFA_SETUP` or `SOFTWARE\_TOKEN\_SETUP` challenge each time your user signs in. Complete setup with `AssociateSoftwareToken` and `VerifySoftwareToken`. /// /// After you set up software token MFA for your user, Amazon Cognito generates a `SOFTWARE\_TOKEN\_MFA` challenge when they authenticate. Respond to this challenge with your user's TOTP. /// @@ -35,7 +35,7 @@ class AssociateSoftwareTokenOperation extends _i1.HttpOperation< AssociateSoftwareTokenResponse> { /// Begins setup of time-based one-time password (TOTP) multi-factor authentication (MFA) for a user, with a unique private key that Amazon Cognito generates and returns in the API response. You can authorize an `AssociateSoftwareToken` request with either the user's access token, or a session string from a challenge response that you received from Amazon Cognito. /// - /// Amazon Cognito disassociates an existing software token when you verify the new token in a [VerifySoftwareToken](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_VerifySoftwareToken.html) API request. If you don't verify the software token and your user pool doesn't require MFA, the user can then authenticate with user name and password credentials alone. If your user pool requires TOTP MFA, Amazon Cognito generates an `MFA_SETUP` or `SOFTWARE\_TOKEN\_SETUP` challenge each time your user signs. Complete setup with `AssociateSoftwareToken` and `VerifySoftwareToken`. + /// Amazon Cognito disassociates an existing software token when you verify the new token in a [VerifySoftwareToken](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_VerifySoftwareToken.html) API request. If you don't verify the software token and your user pool doesn't require MFA, the user can then authenticate with user name and password credentials alone. If your user pool requires TOTP MFA, Amazon Cognito generates an `MFA_SETUP` or `SOFTWARE\_TOKEN\_SETUP` challenge each time your user signs in. Complete setup with `AssociateSoftwareToken` and `VerifySoftwareToken`. /// /// After you set up software token MFA for your user, Amazon Cognito generates a `SOFTWARE\_TOKEN\_MFA` challenge when they authenticate. Respond to this challenge with your user's TOTP. /// @@ -76,7 +76,7 @@ class AssociateSoftwareTokenOperation extends _i1.HttpOperation< credentialsProvider: _credentialsProvider, isOptional: true, ), - const _i1.WithUserAgent('aws-sdk-dart/0.3.1'), + const _i1.WithUserAgent('aws-sdk-dart/0.3.2'), const _i3.WithSdkInvocationId(), const _i3.WithSdkRequest(), ] + diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/change_password_operation.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/change_password_operation.dart index 81918f776a..7b6f0b0a20 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/change_password_operation.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/change_password_operation.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.operation.change_password_operation; // ignore_for_file: no_leading_underscores_for_library_prefixes @@ -15,6 +15,7 @@ import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/ import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/invalid_password_exception.dart'; import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/limit_exceeded_exception.dart'; import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/not_authorized_exception.dart'; +import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/password_history_policy_violation_exception.dart'; import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/password_reset_required_exception.dart'; import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/resource_not_found_exception.dart'; import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/too_many_requests_exception.dart'; @@ -70,7 +71,7 @@ class ChangePasswordOperation extends _i1.HttpOperation( + _i1.ShapeId( + namespace: 'com.amazonaws.cognitoidentityprovider', + shape: 'PasswordHistoryPolicyViolationException', + ), + _i1.ErrorKind.client, + PasswordHistoryPolicyViolationException, + statusCode: 400, + builder: PasswordHistoryPolicyViolationException.fromResponse, + ), _i1.SmithyError( _i1.ShapeId( diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/confirm_device_operation.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/confirm_device_operation.dart index 27c5bc8073..5e6c9a0969 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/confirm_device_operation.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/confirm_device_operation.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.operation.confirm_device_operation; // ignore_for_file: no_leading_underscores_for_library_prefixes @@ -72,7 +72,7 @@ class ConfirmDeviceOperation extends _i1.HttpOperation( + _i1.ShapeId( + namespace: 'com.amazonaws.cognitoidentityprovider', + shape: 'PasswordHistoryPolicyViolationException', + ), + _i1.ErrorKind.client, + PasswordHistoryPolicyViolationException, + statusCode: 400, + builder: PasswordHistoryPolicyViolationException.fromResponse, + ), _i1.SmithyError( _i1.ShapeId( namespace: 'com.amazonaws.cognitoidentityprovider', diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/confirm_sign_up_operation.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/confirm_sign_up_operation.dart index 9d62149fbf..dd03525a4f 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/confirm_sign_up_operation.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/confirm_sign_up_operation.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.operation.confirm_sign_up_operation; // ignore_for_file: no_leading_underscores_for_library_prefixes @@ -74,7 +74,7 @@ class ConfirmSignUpOperation extends _i1.HttpOperation { /// Calling this API causes a message to be sent to the end user with a confirmation code that is required to change the user's password. For the `Username` parameter, you can use the username or user alias. The method used to send the confirmation code is sent according to the specified AccountRecoverySetting. For more information, see [Recovering User Accounts](https://docs.aws.amazon.com/cognito/latest/developerguide/how-to-recover-a-user-account.html) in the _Amazon Cognito Developer Guide_. To use the confirmation code for resetting the password, call [ConfirmForgotPassword](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ConfirmForgotPassword.html). @@ -52,7 +52,7 @@ class ForgotPasswordOperation extends _i1.HttpOperation { /// Initiates sign-in for a user in the Amazon Cognito user directory. You can't sign in a user with a federated IdP with `InitiateAuth`. For more information, see [Adding user pool sign-in through a third party](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-identity-federation.html). @@ -44,7 +45,7 @@ class InitiateAuthOperation extends _i1.HttpOperation( + _i1.ShapeId( + namespace: 'com.amazonaws.cognitoidentityprovider', + shape: 'InvalidEmailRoleAccessPolicyException', + ), + _i1.ErrorKind.client, + InvalidEmailRoleAccessPolicyException, + statusCode: 400, + builder: InvalidEmailRoleAccessPolicyException.fromResponse, + ), _i1.SmithyError( _i1.ShapeId( diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/list_devices_operation.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/list_devices_operation.dart index 3c17fd4b17..e9087a8151 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/list_devices_operation.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/list_devices_operation.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.operation.list_devices_operation; // ignore_for_file: no_leading_underscores_for_library_prefixes @@ -69,7 +69,7 @@ class ListDevicesOperation extends _i1.HttpOperation( + _i1.ShapeId( + namespace: 'com.amazonaws.cognitoidentityprovider', + shape: 'InvalidEmailRoleAccessPolicyException', + ), + _i1.ErrorKind.client, + InvalidEmailRoleAccessPolicyException, + statusCode: 400, + builder: InvalidEmailRoleAccessPolicyException.fromResponse, + ), _i1.SmithyError( _i1.ShapeId( @@ -274,6 +287,17 @@ class RespondToAuthChallengeOperation extends _i1.HttpOperation< statusCode: 403, builder: NotAuthorizedException.fromResponse, ), + _i1.SmithyError( + _i1.ShapeId( + namespace: 'com.amazonaws.cognitoidentityprovider', + shape: 'PasswordHistoryPolicyViolationException', + ), + _i1.ErrorKind.client, + PasswordHistoryPolicyViolationException, + statusCode: 400, + builder: PasswordHistoryPolicyViolationException.fromResponse, + ), _i1.SmithyError( _i1.ShapeId( diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/revoke_token_operation.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/revoke_token_operation.dart index 7ae9abe992..e7878fd5f7 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/revoke_token_operation.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/revoke_token_operation.dart @@ -1,4 +1,4 @@ -// Generated with smithy-dart 0.3.1. DO NOT MODIFY. +// Generated with smithy-dart 0.3.2. DO NOT MODIFY. // ignore_for_file: avoid_unused_constructor_parameters,deprecated_member_use_from_same_package,non_constant_identifier_names,require_trailing_commas library amplify_auth_cognito_dart.cognito_identity_provider.operation.revoke_token_operation; // ignore_for_file: no_leading_underscores_for_library_prefixes @@ -62,7 +62,7 @@ class RevokeTokenOperation extends _i1.HttpOperation { /// Registers the user in the specified user pool and creates a user name, password, and user attributes. @@ -45,7 +45,7 @@ class SignUpOperation extends _i1.HttpOperation Date: Fri, 13 Sep 2024 16:38:52 -0700 Subject: [PATCH 12/91] chore: fix merge changes and sdk challenge name --- .../auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart | 2 +- .../lib/src/state/machines/sign_in_state_machine.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart index 593b38a583..ec6a73d46c 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart @@ -33,7 +33,7 @@ extension ChallengeNameTypeBridge on ChallengeNameType { ChallengeNameType.softwareTokenMfa => AuthSignInStep.confirmSignInWithTotpMfaCode, // TODO(khatruong2009): confirm ChallengeNameType.emailMfa is added to SDK - ChallengeNameType.emailMfa => AuthSignInStep.confirmSignInWithEmailMfaCode, + ChallengeNameType.emailOtp => AuthSignInStep.confirmSignInWithEmailMfaCode, ChallengeNameType.adminNoSrpAuth || ChallengeNameType.passwordVerifier || ChallengeNameType.devicePasswordVerifier || diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart index 46666c79fd..024e39c875 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart @@ -458,7 +458,7 @@ final class SignInStateMachine _enableMfaType = MfaType.email; return RespondToAuthChallengeRequest.build((b) { b - ..clientId = config.appClientId + ..clientId = _authOutputs.userPoolClientId ..challengeName = _challengeName ..challengeResponses.addAll({ CognitoConstants.challengeParamUsername: cognitoUsername, From c98ce74a40684320b0fca2722d23a89c898ea773 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Tue, 17 Sep 2024 13:40:46 -0700 Subject: [PATCH 13/91] chore: fix name of challenge to match with SDK changes and updated state machine --- .../lib/src/flows/constants.dart | 2 +- .../lib/src/state/machines/sign_in_state_machine.dart | 7 +++++-- .../lib/src/l10n/generated/input_localizations.dart | 6 ++++++ .../lib/src/l10n/generated/input_localizations_en.dart | 3 +++ .../lib/src/l10n/input_resolver.dart | 8 ++++++++ 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart index ff49ec7974..536c33c529 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart @@ -58,7 +58,7 @@ abstract class CognitoConstants { static const challengeParamSmsMfaCode = 'SMS_MFA_CODE'; /// The `EMAIL_MFA_CODE` parameter. - static const challengeParamEmailMfaCode = 'EMAIL_MFA_CODE'; + static const challengeParamEmailMfaCode = 'EMAIL_OTP_CODE'; /// The `SOFTWARE_TOKEN_MFA_CODE` parameter. static const challengeParamSoftwareTokenMfaCode = 'SOFTWARE_TOKEN_MFA_CODE'; diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart index 024e39c875..4dbc775736 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart @@ -211,7 +211,7 @@ final class SignInStateMachine (type) => switch (type) { 'SOFTWARE_TOKEN_MFA' => MfaType.totp, 'SMS_MFA' => MfaType.sms, - 'EMAIL_MFA' => MfaType.email, + 'EMAIL_OTP' => MfaType.email, _ => () { logger.error('Unrecognized MFA type: $type'); return null; @@ -326,6 +326,8 @@ final class SignInStateMachine createSmsMfaRequest(event), ChallengeNameType.softwareTokenMfa when hasUserResponse => createSoftwareTokenMfaRequest(event), + ChallengeNameType.emailOtp when hasUserResponse => + createEmailMfaRequest(event), ChallengeNameType.selectMfaType when hasUserResponse => createSelectMfaRequest(event), ChallengeNameType.mfaSetup when hasUserResponse => @@ -686,7 +688,7 @@ final class SignInStateMachine CognitoConstants.challengeParamAnswer: switch (selection) { 'sms' => 'SMS_MFA', 'totp' => 'SOFTWARE_TOKEN_MFA', - 'email' => 'EMAIL_MFA', + 'email' => 'EMAIL_OTP', _ => throw ArgumentError('Must be either SMS, Email, or TOTP'), }, }) @@ -954,6 +956,7 @@ final class SignInStateMachine accessToken: accessToken, sms: enableMfaType == MfaType.sms ? MfaPreference.enabled : null, totp: enableMfaType == MfaType.totp ? MfaPreference.enabled : null, + email: enableMfaType == MfaType.email ? MfaPreference.enabled : null, ); } on Exception catch (e, st) { logger.error( diff --git a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations.dart b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations.dart index 178e5b3eeb..c86a8a9ed4 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations.dart @@ -297,6 +297,12 @@ abstract class AuthenticatorInputLocalizations { /// **'Authenticator App (TOTP)'** String get selectTotp; + /// Label for the radio button to select email as the user's chosen MFA method. + /// + /// In en, this message translates to: + /// **'Email'** + String get selectEmail; + /// The instructional text for submitting a TOTP pass code /// /// In en, this message translates to: diff --git a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations_en.dart b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations_en.dart index dcd9c0139c..6b6d42a494 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations_en.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations_en.dart @@ -153,6 +153,9 @@ class AuthenticatorInputLocalizationsEn @override String get selectTotp => 'Authenticator App (TOTP)'; + @override + String get selectEmail => 'Email'; + @override String get totpCodePrompt => 'Please enter the code from your registered Authenticator app'; diff --git a/packages/authenticator/amplify_authenticator/lib/src/l10n/input_resolver.dart b/packages/authenticator/amplify_authenticator/lib/src/l10n/input_resolver.dart index ad9eed1b0c..4b04f86962 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/l10n/input_resolver.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/l10n/input_resolver.dart @@ -33,6 +33,7 @@ enum InputField { rememberDevice, selectSms, selectTotp, + selectEmail, totpCodePrompt, usernameType, } @@ -171,6 +172,11 @@ class InputResolverKey { field: InputField.selectSms, ); + static const selectEmail = InputResolverKey._( + InputResolverKeyType.title, + field: InputField.email, + ); + static const totpCodePrompt = InputResolverKey._( InputResolverKeyType.title, field: InputField.totpCodePrompt, @@ -456,6 +462,8 @@ class InputResolver extends Resolver { return AuthenticatorLocalizations.inputsOf(context).selectSms; case InputField.selectTotp: return AuthenticatorLocalizations.inputsOf(context).selectTotp; + case InputField.selectEmail: + return AuthenticatorLocalizations.inputsOf(context).selectEmail; case InputField.totpCodePrompt: return AuthenticatorLocalizations.inputsOf(context).totpCodePrompt; case InputField.usernameType: From c1d33e3ed83c407331594ce69c9322f1c1ee1301 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Tue, 17 Sep 2024 14:47:32 -0700 Subject: [PATCH 14/91] chore: edit doc comment in auth_plugin_impl --- .../amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart index f080f48fc2..02b5a8e2df 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart @@ -885,8 +885,8 @@ class AmplifyAuthCognitoDart extends AuthPluginInterface /// {@template amplify_core.amplify_auth_category.update_mfa_preference} /// Updates the MFA preference for the current user. /// - /// If [sms] or [totp] is `null`, the preference for that MFA type is left - /// unchanged. Setting either [sms] or [totp] to [MfaPreference.preferred] + /// If [sms], [totp], or [email] is `null`, the preference for that MFA type is left + /// unchanged. Setting either [sms], [totp], or [email] to [MfaPreference.preferred] /// will mark the other as not preferred. /// {@endtemplate} Future updateMfaPreference({ From 18a531669533d484f3c09efdac6aad6f9560b683 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Tue, 17 Sep 2024 14:52:31 -0700 Subject: [PATCH 15/91] chore: add emailMfaSettings to setMfaSettings --- .../auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart index ec6a73d46c..b65f5d3dfc 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart @@ -886,6 +886,7 @@ extension MfaSettings on CognitoIdentityProviderClient { accessToken: accessToken, smsMfaSettings: smsMfaSettings, softwareTokenMfaSettings: softwareTokenSettings, + emailMfaSettings: emailMfaSettings, ), ).result; } From d484c55a713bceaff89e682585667dcd042d1282 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Wed, 18 Sep 2024 09:40:31 -0700 Subject: [PATCH 16/91] chore: formatting --- .../lib/src/sdk/sdk_bridge.dart | 34 +++++++++++++++---- .../state/machines/sign_in_state_machine.dart | 3 +- .../l10n/generated/input_localizations.dart | 2 +- .../email_or_phone_config.dart | 2 +- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart index b65f5d3dfc..f183fd1914 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart @@ -33,7 +33,8 @@ extension ChallengeNameTypeBridge on ChallengeNameType { ChallengeNameType.softwareTokenMfa => AuthSignInStep.confirmSignInWithTotpMfaCode, // TODO(khatruong2009): confirm ChallengeNameType.emailMfa is added to SDK - ChallengeNameType.emailOtp => AuthSignInStep.confirmSignInWithEmailMfaCode, + ChallengeNameType.emailOtp => + AuthSignInStep.confirmSignInWithEmailMfaCode, ChallengeNameType.adminNoSrpAuth || ChallengeNameType.passwordVerifier || ChallengeNameType.devicePasswordVerifier || @@ -828,19 +829,40 @@ extension MfaSettings on CognitoIdentityProviderClient { return currentlyEnabled || requestingEnabled; } - final preferred = switch ((currentPreference, sms: sms, totp: totp, email: email)) { + final preferred = + switch ((currentPreference, sms: sms, totp: totp, email: email)) { // Prevent an invalid choice. - (_, sms: MfaPreference.preferred, totp: MfaPreference.preferred, email: MfaPreference.preferred) => + ( + _, + sms: MfaPreference.preferred, + totp: MfaPreference.preferred, + email: MfaPreference.preferred + ) => throw const InvalidParameterException( 'Cannot assign multiple MFA methods as preferred', ), // Setting one or the other as preferred overrides previous value. - (_, sms: MfaPreference.preferred, totp: != MfaPreference.preferred, email: != MfaPreference.preferred) => + ( + _, + sms: MfaPreference.preferred, + totp: != MfaPreference.preferred, + email: != MfaPreference.preferred + ) => MfaType.sms, - (_, sms: != MfaPreference.preferred, totp: MfaPreference.preferred, email: != MfaPreference.preferred) => + ( + _, + sms: != MfaPreference.preferred, + totp: MfaPreference.preferred, + email: != MfaPreference.preferred + ) => MfaType.totp, - (_, sms: != MfaPreference.preferred, totp: != MfaPreference.preferred, email: MfaPreference.preferred) => + ( + _, + sms: != MfaPreference.preferred, + totp: != MfaPreference.preferred, + email: MfaPreference.preferred + ) => MfaType.email, // Setting one or the other as disabled or not preferred removes current diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart index 4dbc775736..7794b48c15 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart @@ -956,7 +956,8 @@ final class SignInStateMachine accessToken: accessToken, sms: enableMfaType == MfaType.sms ? MfaPreference.enabled : null, totp: enableMfaType == MfaType.totp ? MfaPreference.enabled : null, - email: enableMfaType == MfaType.email ? MfaPreference.enabled : null, + email: + enableMfaType == MfaType.email ? MfaPreference.enabled : null, ); } on Exception catch (e, st) { logger.error( diff --git a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations.dart b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations.dart index c86a8a9ed4..b34f12cf8e 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations.dart @@ -298,7 +298,7 @@ abstract class AuthenticatorInputLocalizations { String get selectTotp; /// Label for the radio button to select email as the user's chosen MFA method. - /// + /// /// In en, this message translates to: /// **'Email'** String get selectEmail; diff --git a/packages/authenticator/amplify_authenticator_test/lib/src/amplify_outputs/email_or_phone_config.dart b/packages/authenticator/amplify_authenticator_test/lib/src/amplify_outputs/email_or_phone_config.dart index ad5ef29355..a7cc4c93ac 100644 --- a/packages/authenticator/amplify_authenticator_test/lib/src/amplify_outputs/email_or_phone_config.dart +++ b/packages/authenticator/amplify_authenticator_test/lib/src/amplify_outputs/email_or_phone_config.dart @@ -29,4 +29,4 @@ const emailOrPhoneConfig = '''{ "SMS" ] } -}'''; \ No newline at end of file +}'''; From f604447dffd7c747c5bbebca38c8e6ed57b59a96 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Wed, 18 Sep 2024 09:41:16 -0700 Subject: [PATCH 17/91] chore: update docs comment in constants --- .../auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart index 536c33c529..7a40ff446c 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart @@ -57,7 +57,7 @@ abstract class CognitoConstants { /// The `SMS_MFA_CODE` parameter. static const challengeParamSmsMfaCode = 'SMS_MFA_CODE'; - /// The `EMAIL_MFA_CODE` parameter. + /// The `EMAIL_OTP_CODE` parameter. static const challengeParamEmailMfaCode = 'EMAIL_OTP_CODE'; /// The `SOFTWARE_TOKEN_MFA_CODE` parameter. From b0c03b79a0fb9af10d25c31ee732a276d41a1fb1 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Wed, 18 Sep 2024 10:42:46 -0700 Subject: [PATCH 18/91] chore: add docs and formatting --- packages/amplify_core/doc/lib/auth.dart | 7 ++++++- .../lib/src/types/auth/sign_in/auth_sign_in_step.dart | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/amplify_core/doc/lib/auth.dart b/packages/amplify_core/doc/lib/auth.dart index 6e48014a9b..d7a0fd803b 100644 --- a/packages/amplify_core/doc/lib/auth.dart +++ b/packages/amplify_core/doc/lib/auth.dart @@ -104,7 +104,7 @@ Future resendSignUpCode(String username) async { } // #enddocregion resend-signup-code -// #docregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code +// #docregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code, handle-confirm-signin-email Future _handleSignInResult(SignInResult result) async { switch (result.nextStep.signInStep) { // #enddocregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code @@ -129,6 +129,11 @@ Future _handleSignInResult(SignInResult result) async { final codeDeliveryDetails = result.nextStep.codeDeliveryDetails!; _handleCodeDelivery(codeDeliveryDetails); // #enddocregion handle-confirm-signin-sms + // #docregion handle-confirm-signin-email + case AuthSignInStep.confirmSignInWithEmailMfaCode: + final codeDeliveryDetails = result.nextStep.codeDeliveryDetails!; + _handleCodeDelivery(codeDeliveryDetails); + // #enddocregion handle-confirm-signin-email // #docregion handle-confirm-signin-new-password case AuthSignInStep.confirmSignInWithNewPassword: safePrint('Enter a new password to continue signing in'); diff --git a/packages/amplify_core/lib/src/types/auth/sign_in/auth_sign_in_step.dart b/packages/amplify_core/lib/src/types/auth/sign_in/auth_sign_in_step.dart index 9631ca1d94..eef001a650 100644 --- a/packages/amplify_core/lib/src/types/auth/sign_in/auth_sign_in_step.dart +++ b/packages/amplify_core/lib/src/types/auth/sign_in/auth_sign_in_step.dart @@ -10,7 +10,7 @@ enum AuthSignInStep { /// an MFA method. continueSignInWithMfaSelection, - /// The sign-in is not complete and the user must select an MFA method to setup. + /// The sign-in is not complete and the user must select an MFA method to setup. continueSignInWithMfaSetupSelection, /// The sign-in is not complete and a TOTP authenticator app must be From 515368315eb444e77a5a1bb37a1b244e0ed8446a Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Wed, 18 Sep 2024 14:05:01 -0700 Subject: [PATCH 19/91] chore: revert package-lock.json changes --- infra-gen2/package-lock.json | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/infra-gen2/package-lock.json b/infra-gen2/package-lock.json index 191c337b64..806c800dd6 100644 --- a/infra-gen2/package-lock.json +++ b/infra-gen2/package-lock.json @@ -4462,18 +4462,6 @@ "inBundle": true, "license": "Apache-2.0", "dependencies": { - "@aws-crypto/sha256-browser": "5.2.0", - "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.624.0", - "@aws-sdk/client-sts": "3.624.0", - "@aws-sdk/core": "3.624.0", - "@aws-sdk/credential-provider-node": "3.624.0", - "@aws-sdk/middleware-host-header": "3.620.0", - "@aws-sdk/middleware-logger": "3.609.0", - "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-sdk-ec2": "3.622.0", - "@aws-sdk/middleware-user-agent": "3.620.0", - "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", "bowser": "^2.11.0", @@ -4486,27 +4474,9 @@ "inBundle": true, "license": "Apache-2.0", "dependencies": { - "@aws-crypto/sha256-browser": "5.2.0", - "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.624.0", - "@aws-sdk/middleware-host-header": "3.620.0", - "@aws-sdk/middleware-logger": "3.609.0", - "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.620.0", - "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/types": "^3.3.0", - "@smithy/url-parser": "^3.0.3", - "@smithy/util-base64": "^3.0.0", - "@smithy/util-body-length-browser": "^3.0.0", - "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", - "@smithy/util-endpoints": "^2.0.5", - "@smithy/util-middleware": "^3.0.3", - "@smithy/util-retry": "^3.0.3", - "@smithy/util-utf8": "^3.0.0", "tslib": "^2.6.2" }, "engines": { @@ -4622,8 +4592,6 @@ "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", - "@smithy/util-middleware": "^3.0.3", - "fast-xml-parser": "4.4.1", "tslib": "^2.6.2" }, "engines": { @@ -4638,7 +4606,6 @@ "dependencies": { "@smithy/eventstream-serde-universal": "^3.0.5", "@smithy/types": "^3.3.0", - "@smithy/util-stream": "^3.1.3", "tslib": "^2.6.2" }, "engines": { From 1d37caec6868c93b0064a886975e18334d7f0fd2 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Wed, 18 Sep 2024 14:14:17 -0700 Subject: [PATCH 20/91] chore: update mfaSetup to MfaSetupSelection --- .../auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart index f183fd1914..171c2feac3 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart @@ -29,10 +29,9 @@ extension ChallengeNameTypeBridge on ChallengeNameType { ChallengeNameType.selectMfaType => AuthSignInStep.continueSignInWithMfaSelection, ChallengeNameType.mfaSetup => - AuthSignInStep.continueSignInWithTotpSetup, + AuthSignInStep.continueSignInWithMfaSetupSelection, ChallengeNameType.softwareTokenMfa => AuthSignInStep.confirmSignInWithTotpMfaCode, - // TODO(khatruong2009): confirm ChallengeNameType.emailMfa is added to SDK ChallengeNameType.emailOtp => AuthSignInStep.confirmSignInWithEmailMfaCode, ChallengeNameType.adminNoSrpAuth || From e69d96bb657c48989dacd952d233232726693804 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Wed, 18 Sep 2024 14:16:29 -0700 Subject: [PATCH 21/91] chore: refactor setMfaSettings method to handle multiple mfa preferred scenarios --- .../lib/src/sdk/sdk_bridge.dart | 193 ++++++++---------- 1 file changed, 81 insertions(+), 112 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart index 171c2feac3..a95acbe95b 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart @@ -794,123 +794,92 @@ extension MfaSettings on CognitoIdentityProviderClient { /// Sets the MFA settings for the user. Future setMfaSettings({ - required String accessToken, - MfaPreference? sms, - MfaPreference? totp, - MfaPreference? email, - }) async { - final UserMfaPreference( - enabled: currentEnabled, - preferred: currentPreference - ) = await _getRawUserSettings( - accessToken: accessToken, - ); - const enabledValues = [ - MfaPreference.enabled, - MfaPreference.notPreferred, - MfaPreference.preferred, - ]; - bool isEnabled(MfaType mfaType) { - final explicitlyDisabled = switch (mfaType) { - MfaType.sms => sms == MfaPreference.disabled, - MfaType.totp => totp == MfaPreference.disabled, - MfaType.email => email == MfaPreference.disabled, - }; - if (explicitlyDisabled) { - return false; - } - final currentlyEnabled = currentEnabled.contains(mfaType); - final requestingEnabled = switch (mfaType) { - MfaType.sms => enabledValues.contains(sms), - MfaType.totp => enabledValues.contains(totp), - MfaType.email => enabledValues.contains(email), - }; - return currentlyEnabled || requestingEnabled; + required String accessToken, + MfaPreference? sms, + MfaPreference? totp, + MfaPreference? email, +}) async { + final UserMfaPreference( + enabled: currentEnabled, + preferred: currentPreference + ) = await _getRawUserSettings( + accessToken: accessToken, + ); + + const enabledValues = [ + MfaPreference.enabled, + MfaPreference.notPreferred, + MfaPreference.preferred, + ]; + + bool isEnabled(MfaType mfaType) { + final explicitlyDisabled = switch (mfaType) { + MfaType.sms => sms == MfaPreference.disabled, + MfaType.totp => totp == MfaPreference.disabled, + MfaType.email => email == MfaPreference.disabled, + }; + if (explicitlyDisabled) { + return false; } + final currentlyEnabled = currentEnabled.contains(mfaType); + final requestingEnabled = switch (mfaType) { + MfaType.sms => enabledValues.contains(sms), + MfaType.totp => enabledValues.contains(totp), + MfaType.email => enabledValues.contains(email), + }; + return currentlyEnabled || requestingEnabled; + } - final preferred = - switch ((currentPreference, sms: sms, totp: totp, email: email)) { - // Prevent an invalid choice. - ( - _, - sms: MfaPreference.preferred, - totp: MfaPreference.preferred, - email: MfaPreference.preferred - ) => - throw const InvalidParameterException( - 'Cannot assign multiple MFA methods as preferred', - ), + // Count the number of MFA methods set to preferred + final preferredMethods = [ + if (sms == MfaPreference.preferred) MfaType.sms, + if (totp == MfaPreference.preferred) MfaType.totp, + if (email == MfaPreference.preferred) MfaType.email, + ]; - // Setting one or the other as preferred overrides previous value. - ( - _, - sms: MfaPreference.preferred, - totp: != MfaPreference.preferred, - email: != MfaPreference.preferred - ) => - MfaType.sms, - ( - _, - sms: != MfaPreference.preferred, - totp: MfaPreference.preferred, - email: != MfaPreference.preferred - ) => - MfaType.totp, - ( - _, - sms: != MfaPreference.preferred, - totp: != MfaPreference.preferred, - email: MfaPreference.preferred - ) => - MfaType.email, - - // Setting one or the other as disabled or not preferred removes current - // preference if it matches. - ( - MfaType.sms, - sms: MfaPreference.notPreferred || MfaPreference.disabled, - totp: _, - email: _, - ) || - ( - MfaType.totp, - sms: _, - totp: MfaPreference.notPreferred || MfaPreference.disabled, - email: _, - ) || - ( - MfaType.email, - sms: _, - totp: _, - email: MfaPreference.notPreferred || MfaPreference.disabled, - ) => - null, - - // Ignore preference changes which do not affect the current preference. - (final currentPreference, sms: _, totp: _, email: _) => currentPreference, + if (preferredMethods.length > 1) { + throw const InvalidParameterException( + 'Cannot assign multiple MFA methods as preferred', + ); + } + + MfaType? preferred; + if (preferredMethods.isNotEmpty) { + preferred = preferredMethods.first; + } else { + // Check if the current preference needs to be removed + final isCurrentPreferenceDisabled = switch (currentPreference) { + MfaType.sms => sms == MfaPreference.disabled || sms == MfaPreference.notPreferred, + MfaType.totp => totp == MfaPreference.disabled || totp == MfaPreference.notPreferred, + MfaType.email => email == MfaPreference.disabled || email == MfaPreference.notPreferred, + _ => false, }; - final smsMfaSettings = SmsMfaSettingsType( - enabled: isEnabled(MfaType.sms), - preferredMfa: preferred == MfaType.sms, - ); - final softwareTokenSettings = SoftwareTokenMfaSettingsType( - enabled: isEnabled(MfaType.totp), - preferredMfa: preferred == MfaType.totp, - ); - // TODO(khatruong2009): confirm EmailMfaSettingsType is added to SDK - final emailMfaSettings = EmailMfaSettingsType( - enabled: isEnabled(MfaType.email), - preferredMfa: preferred == MfaType.email, - ); - await setUserMfaPreference( - SetUserMfaPreferenceRequest( - accessToken: accessToken, - smsMfaSettings: smsMfaSettings, - softwareTokenMfaSettings: softwareTokenSettings, - emailMfaSettings: emailMfaSettings, - ), - ).result; + preferred = isCurrentPreferenceDisabled ? null : currentPreference; } + + final smsMfaSettings = SmsMfaSettingsType( + enabled: isEnabled(MfaType.sms), + preferredMfa: preferred == MfaType.sms, + ); + final softwareTokenSettings = SoftwareTokenMfaSettingsType( + enabled: isEnabled(MfaType.totp), + preferredMfa: preferred == MfaType.totp, + ); + final emailMfaSettings = EmailMfaSettingsType( + enabled: isEnabled(MfaType.email), + preferredMfa: preferred == MfaType.email, + ); + + await setUserMfaPreference( + SetUserMfaPreferenceRequest( + accessToken: accessToken, + smsMfaSettings: smsMfaSettings, + softwareTokenMfaSettings: softwareTokenSettings, + emailMfaSettings: emailMfaSettings, + ), + ).result; +} + } extension on String { From 764f16d4ec6a0f4b2e396159f1bdf2692fa11440 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:49:08 -0700 Subject: [PATCH 22/91] chore: fix mfaType switch statement to reflect new name --- .../auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart index a95acbe95b..db8e3c856f 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart @@ -887,7 +887,7 @@ extension on String { MfaType get mfaType => switch (this) { 'SOFTWARE_TOKEN_MFA' => MfaType.totp, 'SMS_MFA' => MfaType.sms, - 'EMAIL_MFA' => MfaType.email, + 'EMAIL_OTP' => MfaType.email, final invalidType => throw StateError('Invalid MFA type: $invalidType'), }; } From 26bececf5457135fc2120e7b07e86ea7611cb1b5 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 20 Sep 2024 09:39:48 -0700 Subject: [PATCH 23/91] chore: refactor setMfaSettings method --- .../lib/src/sdk/sdk_bridge.dart | 141 ++++++++---------- 1 file changed, 63 insertions(+), 78 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart index db8e3c856f..8ea47761ed 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart @@ -794,92 +794,77 @@ extension MfaSettings on CognitoIdentityProviderClient { /// Sets the MFA settings for the user. Future setMfaSettings({ - required String accessToken, - MfaPreference? sms, - MfaPreference? totp, - MfaPreference? email, -}) async { - final UserMfaPreference( - enabled: currentEnabled, - preferred: currentPreference - ) = await _getRawUserSettings( - accessToken: accessToken, - ); - - const enabledValues = [ - MfaPreference.enabled, - MfaPreference.notPreferred, - MfaPreference.preferred, - ]; - - bool isEnabled(MfaType mfaType) { - final explicitlyDisabled = switch (mfaType) { - MfaType.sms => sms == MfaPreference.disabled, - MfaType.totp => totp == MfaPreference.disabled, - MfaType.email => email == MfaPreference.disabled, - }; - if (explicitlyDisabled) { - return false; + required String accessToken, + MfaPreference? sms, + MfaPreference? totp, + MfaPreference? email, + }) async { + final UserMfaPreference( + enabled: currentEnabled, + preferred: currentPreference, + ) = await _getRawUserSettings(accessToken: accessToken); + + final newPreferredMethods = [ + if (sms == MfaPreference.preferred) MfaType.sms, + if (totp == MfaPreference.preferred) MfaType.totp, + if (email == MfaPreference.preferred) MfaType.email, + ]; + + if (newPreferredMethods.length > 1) { + throw const InvalidParameterException( + 'Cannot assign multiple MFA methods as preferred', + ); } - final currentlyEnabled = currentEnabled.contains(mfaType); - final requestingEnabled = switch (mfaType) { - MfaType.sms => enabledValues.contains(sms), - MfaType.totp => enabledValues.contains(totp), - MfaType.email => enabledValues.contains(email), - }; - return currentlyEnabled || requestingEnabled; - } - // Count the number of MFA methods set to preferred - final preferredMethods = [ - if (sms == MfaPreference.preferred) MfaType.sms, - if (totp == MfaPreference.preferred) MfaType.totp, - if (email == MfaPreference.preferred) MfaType.email, - ]; + var preferred = newPreferredMethods.isNotEmpty + ? newPreferredMethods.first + : currentPreference; - if (preferredMethods.length > 1) { - throw const InvalidParameterException( - 'Cannot assign multiple MFA methods as preferred', - ); - } - - MfaType? preferred; - if (preferredMethods.isNotEmpty) { - preferred = preferredMethods.first; - } else { - // Check if the current preference needs to be removed final isCurrentPreferenceDisabled = switch (currentPreference) { - MfaType.sms => sms == MfaPreference.disabled || sms == MfaPreference.notPreferred, - MfaType.totp => totp == MfaPreference.disabled || totp == MfaPreference.notPreferred, - MfaType.email => email == MfaPreference.disabled || email == MfaPreference.notPreferred, + MfaType.sms => + sms == MfaPreference.disabled || sms == MfaPreference.notPreferred, + MfaType.totp => + totp == MfaPreference.disabled || totp == MfaPreference.notPreferred, + MfaType.email => + email == MfaPreference.disabled || email == MfaPreference.notPreferred, _ => false, }; - preferred = isCurrentPreferenceDisabled ? null : currentPreference; - } + preferred = isCurrentPreferenceDisabled ? null : preferred; + + const enabledValues = [ + MfaPreference.enabled, + MfaPreference.notPreferred, + MfaPreference.preferred, + ]; + + bool isMfaEnabled(MfaType mfaType, MfaPreference? preference) { + if (preference == MfaPreference.disabled) return false; + return currentEnabled.contains(mfaType) || + enabledValues.contains(preference); + } - final smsMfaSettings = SmsMfaSettingsType( - enabled: isEnabled(MfaType.sms), - preferredMfa: preferred == MfaType.sms, - ); - final softwareTokenSettings = SoftwareTokenMfaSettingsType( - enabled: isEnabled(MfaType.totp), - preferredMfa: preferred == MfaType.totp, - ); - final emailMfaSettings = EmailMfaSettingsType( - enabled: isEnabled(MfaType.email), - preferredMfa: preferred == MfaType.email, - ); - - await setUserMfaPreference( - SetUserMfaPreferenceRequest( - accessToken: accessToken, - smsMfaSettings: smsMfaSettings, - softwareTokenMfaSettings: softwareTokenSettings, - emailMfaSettings: emailMfaSettings, - ), - ).result; -} + final smsMfaSettings = SmsMfaSettingsType( + enabled: isMfaEnabled(MfaType.sms, sms), + preferredMfa: preferred == MfaType.sms, + ); + final softwareTokenSettings = SoftwareTokenMfaSettingsType( + enabled: isMfaEnabled(MfaType.totp, totp), + preferredMfa: preferred == MfaType.totp, + ); + final emailMfaSettings = EmailMfaSettingsType( + enabled: isMfaEnabled(MfaType.email, email), + preferredMfa: preferred == MfaType.email, + ); + await setUserMfaPreference( + SetUserMfaPreferenceRequest( + accessToken: accessToken, + smsMfaSettings: smsMfaSettings, + softwareTokenMfaSettings: softwareTokenSettings, + emailMfaSettings: emailMfaSettings, + ), + ).result; + } } extension on String { From 86a322877de0a91627fe49ecfcedd649e61a227d Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 20 Sep 2024 09:50:52 -0700 Subject: [PATCH 24/91] chore: mark sdk_exception file as generated --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index 3fcc994970..ab23572ce9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -74,6 +74,7 @@ ## Generated SDK files packages/**/lib/src/sdk/src/** linguist-generated +packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_exception.dart linguist-generated ## Generated Swift Plugins packages/amplify_datastore/ios/internal/** linguist-generated From 13e60c4f4f5d718ff9502a3a96ef30c316a867fe Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 20 Sep 2024 10:47:39 -0700 Subject: [PATCH 25/91] chore: update core docs --- packages/amplify_core/doc/lib/auth.dart | 31 +++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/packages/amplify_core/doc/lib/auth.dart b/packages/amplify_core/doc/lib/auth.dart index d7a0fd803b..384845b9c2 100644 --- a/packages/amplify_core/doc/lib/auth.dart +++ b/packages/amplify_core/doc/lib/auth.dart @@ -104,22 +104,32 @@ Future resendSignUpCode(String username) async { } // #enddocregion resend-signup-code -// #docregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code, handle-confirm-signin-email +// #docregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code, handle-confirm-signin-email-code, handle-confirm-signin-mfa-setup-selection, handle-confirm-signin-email-setup Future _handleSignInResult(SignInResult result) async { switch (result.nextStep.signInStep) { - // #enddocregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code + // #enddocregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-email-code, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code, handle-confirm-signin-mfa-setup-selection, handle-confirm-signin-email-setup // #docregion handle-confirm-signin-mfa-selection case AuthSignInStep.continueSignInWithMfaSelection: final allowedMfaTypes = result.nextStep.allowedMfaTypes!; final selection = await _promptUserPreference(allowedMfaTypes); return _handleMfaSelection(selection); // #enddocregion handle-confirm-signin-mfa-selection + // #docregion handle-confirm-signin-mfa-setup-selection + case AuthSignInStep.continueSignInWithMfaSetupSelection: + final allowedMfaTypes = result.nextStep.allowedMfaTypes!; + final selection = await _promptUserPreference(allowedMfaTypes); + return _handleMfaSetupSelection(selection); + // #enddocregion handle-confirm-signin-mfa-setup-selection // #docregion handle-confirm-signin-totp-setup case AuthSignInStep.continueSignInWithTotpSetup: final totpSetupDetails = result.nextStep.totpSetupDetails!; final setupUri = totpSetupDetails.getSetupUri(appName: 'MyApp'); safePrint('Open URI to complete setup: $setupUri'); // #enddocregion handle-confirm-signin-totp-setup + // #docregion handle-confirm-signin-email-setup + case AuthSignInStep.continueSignInWithEmailMfaSetup: + safePrint('A confirmation code has been sent to your email'); + // #enddocregion handle-confirm-signin-email-setup // #docregion handle-confirm-signin-totp-code case AuthSignInStep.confirmSignInWithTotpMfaCode: safePrint('Enter a one-time code from your registered Authenticator app'); @@ -163,10 +173,10 @@ Future _handleSignInResult(SignInResult result) async { case AuthSignInStep.done: safePrint('Sign in is complete'); // #enddocregion handle-confirm-signin-done - // #docregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code + // #docregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code, handle-confirm-signin-email-code, handle-confirm-signin-mfa-setup-selection, handle-confirm-signin-email-setup } } -// #enddocregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code +// #enddocregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code, handle-confirm-signin-email-code, handle-confirm-signin-mfa-setup-selection, handle-confirm-signin-email-setup // #docregion signin Future signInUser(String username, String password) async { @@ -241,6 +251,19 @@ Future _handleMfaSelection(MfaType selection) async { } // #enddocregion handle-mfa-selection +// #docregion handle-mfa-setup-selection +Future _handleMfaSetupSelection(MfaType selection) async { + try { + final result = await Amplify.Auth.confirmSignIn( + confirmationValue: selection.confirmationValue, + ); + return _handleSignInResult(result); + } on AuthException catch (e) { + safePrint('Error resending code: ${e.message}'); + } +} +// #enddocregion handle-mfa-setup-selection + // #docregion signout Future signOutCurrentUser() async { final result = await Amplify.Auth.signOut(); From 0d725dc204d945e6150e75d38f3657776ecde27e Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Mon, 30 Sep 2024 16:38:35 -0700 Subject: [PATCH 26/91] chore: update integ tests Update integ tests to change expected state from continueSignInWithTotpSetup to continueSignInWithMfaSetupSelection --- .../example/integration_test/mfa_sms_totp_required_test.dart | 2 +- .../example/integration_test/mfa_totp_required_test.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_totp_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_totp_required_test.dart index 32862bf0bb..2f5c1422e3 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_totp_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_sms_totp_required_test.dart @@ -35,7 +35,7 @@ void main() { signInRes.nextStep.signInStep, because: 'MFA is required, and TOTP is chosen when ' 'no phone number is registered', - ).equals(AuthSignInStep.continueSignInWithTotpSetup); + ).equals(AuthSignInStep.continueSignInWithMfaSetupSelection); final sharedSecret = signInRes.nextStep.totpSetupDetails!.sharedSecret; final setupRes = await Amplify.Auth.confirmSignIn( diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_totp_required_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_totp_required_test.dart index 84370b665c..323700b9f6 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_totp_required_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_totp_required_test.dart @@ -34,7 +34,7 @@ void main() { signInRes.nextStep.signInStep, because: "TOTP MFA is automatically enabled when it's the only option", - ).equals(AuthSignInStep.continueSignInWithTotpSetup); + ).equals(AuthSignInStep.continueSignInWithMfaSetupSelection); final sharedSecret = signInRes.nextStep.totpSetupDetails!.sharedSecret; final setupRes = await Amplify.Auth.confirmSignIn( From 69abe75023998122a5286c2e868e9a20b128b80f Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 4 Oct 2024 12:52:32 -0700 Subject: [PATCH 27/91] chore: update core docs example --- packages/amplify_core/doc/lib/auth.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/amplify_core/doc/lib/auth.dart b/packages/amplify_core/doc/lib/auth.dart index 384845b9c2..6364ceb84a 100644 --- a/packages/amplify_core/doc/lib/auth.dart +++ b/packages/amplify_core/doc/lib/auth.dart @@ -117,6 +117,9 @@ Future _handleSignInResult(SignInResult result) async { // #docregion handle-confirm-signin-mfa-setup-selection case AuthSignInStep.continueSignInWithMfaSetupSelection: final allowedMfaTypes = result.nextStep.allowedMfaTypes!; + if (allowedMfaTypes.length == 1) { + return _handleMfaSetupSelection(allowedMfaTypes.first); + } final selection = await _promptUserPreference(allowedMfaTypes); return _handleMfaSetupSelection(selection); // #enddocregion handle-confirm-signin-mfa-setup-selection From 970bf15dd1df3b1ce8b40ccfb1a9e7bae8b75394 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:00:06 -0700 Subject: [PATCH 28/91] chore: add authenticator state/step enums --- .../lib/src/enums/authenticator_step.dart | 11 ++++++++++ .../lib/src/state/auth_state.dart | 21 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/packages/authenticator/amplify_authenticator/lib/src/enums/authenticator_step.dart b/packages/authenticator/amplify_authenticator/lib/src/enums/authenticator_step.dart index a90f0f8b0a..5ef325081a 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/enums/authenticator_step.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/enums/authenticator_step.dart @@ -61,18 +61,29 @@ enum AuthenticatorStep { /// an MFA method. continueSignInWithMfaSelection, + /// The user is on the Continue Sign In with MFA Setup Selection step. + /// The sign-in is not complete and the user must select an MFA method to setup. + continueSignInWithMfaSetupSelection, + /// The user is on the Continue Sign In with TOTP setup step. /// /// The sign-in is not complete and a TOTP authenticator app must be /// registered before continuing. continueSignInWithTotpSetup, + /// The sign-in is not complete and an Email MFA must be set up before + /// continuing. + continueSignInWithEmailMfaSetup, + /// The user is on the Confirm Sign In with TOTP MFA step. /// /// The sign-in is not complete and must be confirmed with a TOTP code /// from a registered authenticator app. confirmSignInWithTotpMfaCode, + /// The sign-in is not complete and must be confirmed with an email code. + confirmSignInWithEmailMfaCode, + /// The user is on the Reset Password step. resetPassword, diff --git a/packages/authenticator/amplify_authenticator/lib/src/state/auth_state.dart b/packages/authenticator/amplify_authenticator/lib/src/state/auth_state.dart index 5a948e05bf..834afbe683 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/state/auth_state.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/state/auth_state.dart @@ -46,6 +46,12 @@ class UnauthenticatedState extends AuthState static const confirmSignInWithTotpMfaCode = UnauthenticatedState( step: AuthenticatorStep.confirmSignInWithTotpMfaCode, ); + static const continueSignInWithEmailMfaSetup = UnauthenticatedState( + step: AuthenticatorStep.continueSignInWithEmailMfaSetup, + ); + static const confirmSignInWithEmailMfaCode = UnauthenticatedState( + step: AuthenticatorStep.confirmSignInWithEmailMfaCode, + ); static const resetPassword = UnauthenticatedState(step: AuthenticatorStep.resetPassword); static const confirmResetPassword = @@ -111,6 +117,21 @@ class ContinueSignInWithMfaSelection extends UnauthenticatedState { String get runtimeTypeName => 'ContinueSignInWithMfaSelection'; } +class ContinueSignInWithMfaSetupSelection extends UnauthenticatedState { + const ContinueSignInWithMfaSetupSelection({ + Set? allowedMfaTypes, + }) : allowedMfaTypes = allowedMfaTypes ?? const {}, + super(step: AuthenticatorStep.continueSignInWithMfaSetupSelection); + + final Set allowedMfaTypes; + + @override + List get props => [step, allowedMfaTypes]; + + @override + String get runtimeTypeName => 'ContinueSignInWithMfaSetupSelection'; +} + class ContinueSignInTotpSetup extends UnauthenticatedState { const ContinueSignInTotpSetup(this.totpSetupDetails, this.totpSetupUri) : super(step: AuthenticatorStep.continueSignInWithTotpSetup); From 5586c16043a67a1d2de1e7bf43d72ce1c4fb035a Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:01:09 -0700 Subject: [PATCH 29/91] chore: change state machine and auth bloc to automatically move states if only one mfa method is allowed --- .../state/machines/sign_in_state_machine.dart | 70 ++++++++++++++++++- .../lib/src/blocs/auth/auth_bloc.dart | 48 +++++++++++++ 2 files changed, 116 insertions(+), 2 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart index 7794b48c15..03fc0c3edb 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart @@ -330,8 +330,56 @@ final class SignInStateMachine createEmailMfaRequest(event), ChallengeNameType.selectMfaType when hasUserResponse => createSelectMfaRequest(event), - ChallengeNameType.mfaSetup when hasUserResponse => - createMfaSetupRequest(event), + ChallengeNameType.mfaSetup => + (() async { + final allowedMfaTypes = _allowedMfaTypes; + if (allowedMfaTypes == null || allowedMfaTypes.isEmpty) { + throw const InvalidUserPoolConfigurationException( + 'No MFA types are allowed for setup.', + recoverySuggestion: 'Check your user pool MFA configuration.', + ); + } + // Exclude MfaType.sms from consideration + final mfaTypesForSetup = allowedMfaTypes.difference({MfaType.sms}); + if (mfaTypesForSetup.isEmpty) { + throw const InvalidUserPoolConfigurationException( + 'No eligible MFA types are available for setup.', + recoverySuggestion: 'Check your user pool MFA configuration.', + ); + } + if (mfaTypesForSetup.length == 1) { + final mfaType = mfaTypesForSetup.first; + if (mfaType == MfaType.totp) { + _enableMfaType = MfaType.totp; + _totpSetupResult ??= await associateSoftwareToken(); + if (hasUserResponse) { + return createMfaSetupRequest(event); + } else { + // Need to prompt user for the TOTP code + return null; + } + } else if (mfaType == MfaType.email) { + _enableMfaType = MfaType.email; + if (hasUserResponse) { + return createEmailMfaSetupRequest(event); + } else { + // Need to prompt user for the email verification code + return null; + } + } else { + throw InvalidUserPoolConfigurationException( + 'Unsupported MFA type: ${mfaType.name}', + recoverySuggestion: 'Check your user pool MFA configuration.', + ); + } + } else if (hasUserResponse) { + // Handle user's selection + return createMfaSetupRequest(event); + } else { + // Need to prompt user to select an MFA type + return null; + } + })(), ChallengeNameType.newPasswordRequired when hasUserResponse => createNewPasswordRequest(event), _ => null, @@ -674,6 +722,24 @@ final class SignInStateMachine }); } + /// Compeletes set up of an email MFA. + @protected + Future createEmailMfaSetupRequest( + SignInRespondToChallenge event, + ) async { + _enableMfaType = MfaType.email; + return RespondToAuthChallengeRequest.build((b) { + b + ..challengeName = ChallengeNameType.emailOtp + ..challengeResponses.addAll({ + CognitoConstants.challengeParamUsername: cognitoUsername, + CognitoConstants.challengeParamEmailMfaCode: event.answer, + }) + ..clientId = _authOutputs.userPoolClientId + ..clientMetadata.addAll(event.clientMetadata); + }); + } + /// Selects an MFA type to use for sign-in. @protected Future createSelectMfaRequest( diff --git a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart index 4c729b9078..41dcfe410e 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart @@ -227,10 +227,16 @@ class StateMachineBloc yield UnauthenticatedState.confirmSignInNewPassword; case AuthSignInStep.confirmSignInWithTotpMfaCode: yield UnauthenticatedState.confirmSignInWithTotpMfaCode; + case AuthSignInStep.confirmSignInWithEmailMfaCode: + yield UnauthenticatedState.confirmSignInWithEmailMfaCode; case AuthSignInStep.continueSignInWithMfaSelection: yield ContinueSignInWithMfaSelection( allowedMfaTypes: result.nextStep.allowedMfaTypes, ); + case AuthSignInStep.continueSignInWithMfaSetupSelection: + yield ContinueSignInWithMfaSetupSelection( + allowedMfaTypes: result.nextStep.allowedMfaTypes, + ); case AuthSignInStep.continueSignInWithTotpSetup: assert( result.nextStep.totpSetupDetails != null, @@ -333,6 +339,43 @@ class StateMachineBloc allowedMfaTypes: result.nextStep.allowedMfaTypes, ), ); + case AuthSignInStep.continueSignInWithMfaSetupSelection: + final allowedMfaTypes = result.nextStep.allowedMfaTypes; + if (allowedMfaTypes != null) { + final mfaTypesForSetup = allowedMfaTypes.toSet()..remove(MfaType.sms); + if (mfaTypesForSetup.length == 1) { + final mfaType = mfaTypesForSetup.first; + if (mfaType == MfaType.totp) { + assert( + result.nextStep.totpSetupDetails != null, + 'Sign In Result should have totpSetupDetails', + ); + _emit(await ContinueSignInTotpSetup.setupURI( + result.nextStep.totpSetupDetails!, + totpOptions, + ),); + } else if (mfaType == MfaType.email) { + _emit(UnauthenticatedState.continueSignInWithEmailMfaSetup); + } else { + throw InvalidUserPoolConfigurationException( + 'Unsupported MFA type: ${mfaType.name}', + recoverySuggestion: 'Check your user pool MFA configuration.', + ); + } + } else { + _emit( + ContinueSignInWithMfaSetupSelection( + allowedMfaTypes: result.nextStep.allowedMfaTypes, + ), + ); + } + } else { + _emit( + ContinueSignInWithMfaSetupSelection( + allowedMfaTypes: result.nextStep.allowedMfaTypes, + ), + ); + } case AuthSignInStep.continueSignInWithTotpSetup: assert( result.nextStep.totpSetupDetails != null, @@ -344,8 +387,13 @@ class StateMachineBloc totpOptions, ), ); + case AuthSignInStep.continueSignInWithEmailMfaSetup: + _emit(UnauthenticatedState.continueSignInWithEmailMfaSetup); case AuthSignInStep.confirmSignInWithTotpMfaCode: _emit(UnauthenticatedState.confirmSignInWithTotpMfaCode); + case AuthSignInStep.confirmSignInWithEmailMfaCode: + _notifyCodeSent(result.nextStep.codeDeliveryDetails?.destination); + _emit(UnauthenticatedState.confirmSignInWithEmailMfaCode); case AuthSignInStep.resetPassword: _emit(UnauthenticatedState.confirmResetPassword); case AuthSignInStep.confirmSignUp: From 472507467d8e031c5d87606355d0bddac5e944fe Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:01:26 -0700 Subject: [PATCH 30/91] chore: add email mfa to test_runner --- .../amplify_auth_integration_test/lib/src/test_runner.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/test/amplify_auth_integration_test/lib/src/test_runner.dart b/packages/test/amplify_auth_integration_test/lib/src/test_runner.dart index 1401bc4fd6..9654971cdd 100644 --- a/packages/test/amplify_auth_integration_test/lib/src/test_runner.dart +++ b/packages/test/amplify_auth_integration_test/lib/src/test_runner.dart @@ -145,6 +145,7 @@ class MfaInfo { this.required = false, this.smsEnabled = false, this.totpEnabled = false, + this.emailEnabled = false, }); /// Whether MFA is required (`true`) or optional (`false`). @@ -155,6 +156,9 @@ class MfaInfo { /// Whether TOTP MFA is available. final bool totpEnabled; + + /// Whether email MFA is available. + final bool emailEnabled; } /// A test environment descriptor. From f0b69a392fa98c6c261a408a96fe0a2e14351199 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:58:09 -0700 Subject: [PATCH 31/91] chore: dart format --- .../state/machines/sign_in_state_machine.dart | 91 +++++++++---------- 1 file changed, 45 insertions(+), 46 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart index 03fc0c3edb..39c6314a07 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart @@ -330,56 +330,55 @@ final class SignInStateMachine createEmailMfaRequest(event), ChallengeNameType.selectMfaType when hasUserResponse => createSelectMfaRequest(event), - ChallengeNameType.mfaSetup => - (() async { - final allowedMfaTypes = _allowedMfaTypes; - if (allowedMfaTypes == null || allowedMfaTypes.isEmpty) { - throw const InvalidUserPoolConfigurationException( - 'No MFA types are allowed for setup.', - recoverySuggestion: 'Check your user pool MFA configuration.', - ); - } - // Exclude MfaType.sms from consideration - final mfaTypesForSetup = allowedMfaTypes.difference({MfaType.sms}); - if (mfaTypesForSetup.isEmpty) { - throw const InvalidUserPoolConfigurationException( - 'No eligible MFA types are available for setup.', - recoverySuggestion: 'Check your user pool MFA configuration.', - ); - } - if (mfaTypesForSetup.length == 1) { - final mfaType = mfaTypesForSetup.first; - if (mfaType == MfaType.totp) { - _enableMfaType = MfaType.totp; - _totpSetupResult ??= await associateSoftwareToken(); - if (hasUserResponse) { - return createMfaSetupRequest(event); - } else { - // Need to prompt user for the TOTP code - return null; - } - } else if (mfaType == MfaType.email) { - _enableMfaType = MfaType.email; - if (hasUserResponse) { - return createEmailMfaSetupRequest(event); + ChallengeNameType.mfaSetup => (() async { + final allowedMfaTypes = _allowedMfaTypes; + if (allowedMfaTypes == null || allowedMfaTypes.isEmpty) { + throw const InvalidUserPoolConfigurationException( + 'No MFA types are allowed for setup.', + recoverySuggestion: 'Check your user pool MFA configuration.', + ); + } + // Exclude MfaType.sms from consideration + final mfaTypesForSetup = allowedMfaTypes.difference({MfaType.sms}); + if (mfaTypesForSetup.isEmpty) { + throw const InvalidUserPoolConfigurationException( + 'No eligible MFA types are available for setup.', + recoverySuggestion: 'Check your user pool MFA configuration.', + ); + } + if (mfaTypesForSetup.length == 1) { + final mfaType = mfaTypesForSetup.first; + if (mfaType == MfaType.totp) { + _enableMfaType = MfaType.totp; + _totpSetupResult ??= await associateSoftwareToken(); + if (hasUserResponse) { + return createMfaSetupRequest(event); + } else { + // Need to prompt user for the TOTP code + return null; + } + } else if (mfaType == MfaType.email) { + _enableMfaType = MfaType.email; + if (hasUserResponse) { + return createEmailMfaSetupRequest(event); + } else { + // Need to prompt user for the email verification code + return null; + } } else { - // Need to prompt user for the email verification code - return null; + throw InvalidUserPoolConfigurationException( + 'Unsupported MFA type: ${mfaType.name}', + recoverySuggestion: 'Check your user pool MFA configuration.', + ); } + } else if (hasUserResponse) { + // Handle user's selection + return createMfaSetupRequest(event); } else { - throw InvalidUserPoolConfigurationException( - 'Unsupported MFA type: ${mfaType.name}', - recoverySuggestion: 'Check your user pool MFA configuration.', - ); + // Need to prompt user to select an MFA type + return null; } - } else if (hasUserResponse) { - // Handle user's selection - return createMfaSetupRequest(event); - } else { - // Need to prompt user to select an MFA type - return null; - } - })(), + })(), ChallengeNameType.newPasswordRequired when hasUserResponse => createNewPasswordRequest(event), _ => null, From 7b901af8e6f44923a9b658d127a98e3a3ec4afe4 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Mon, 7 Oct 2024 12:07:51 -0700 Subject: [PATCH 32/91] chore: fix auth.dart docs --- packages/amplify_core/doc/lib/auth.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/amplify_core/doc/lib/auth.dart b/packages/amplify_core/doc/lib/auth.dart index 6364ceb84a..5573052fba 100644 --- a/packages/amplify_core/doc/lib/auth.dart +++ b/packages/amplify_core/doc/lib/auth.dart @@ -107,7 +107,7 @@ Future resendSignUpCode(String username) async { // #docregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code, handle-confirm-signin-email-code, handle-confirm-signin-mfa-setup-selection, handle-confirm-signin-email-setup Future _handleSignInResult(SignInResult result) async { switch (result.nextStep.signInStep) { - // #enddocregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-email-code, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code, handle-confirm-signin-mfa-setup-selection, handle-confirm-signin-email-setup + // #enddocregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code, handle-confirm-signin-email-code, handle-confirm-signin-mfa-setup-selection, handle-confirm-signin-email-setup // #docregion handle-confirm-signin-mfa-selection case AuthSignInStep.continueSignInWithMfaSelection: final allowedMfaTypes = result.nextStep.allowedMfaTypes!; @@ -121,6 +121,7 @@ Future _handleSignInResult(SignInResult result) async { return _handleMfaSetupSelection(allowedMfaTypes.first); } final selection = await _promptUserPreference(allowedMfaTypes); + safePrint('Selected MFA type: $selection'); return _handleMfaSetupSelection(selection); // #enddocregion handle-confirm-signin-mfa-setup-selection // #docregion handle-confirm-signin-totp-setup @@ -262,7 +263,7 @@ Future _handleMfaSetupSelection(MfaType selection) async { ); return _handleSignInResult(result); } on AuthException catch (e) { - safePrint('Error resending code: ${e.message}'); + safePrint('Error selecting MFA method: ${e.message}'); } } // #enddocregion handle-mfa-setup-selection From 66097f2af8fdad60c6be8ac5d2428431138c675b Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Mon, 7 Oct 2024 13:15:51 -0700 Subject: [PATCH 33/91] chore: moved ChallengeNameType.mfaSetup switch statement logic to a helper method --- .../state/machines/sign_in_state_machine.dart | 108 ++++++++++-------- 1 file changed, 59 insertions(+), 49 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart index 39c6314a07..6e6a121ceb 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart @@ -330,55 +330,8 @@ final class SignInStateMachine createEmailMfaRequest(event), ChallengeNameType.selectMfaType when hasUserResponse => createSelectMfaRequest(event), - ChallengeNameType.mfaSetup => (() async { - final allowedMfaTypes = _allowedMfaTypes; - if (allowedMfaTypes == null || allowedMfaTypes.isEmpty) { - throw const InvalidUserPoolConfigurationException( - 'No MFA types are allowed for setup.', - recoverySuggestion: 'Check your user pool MFA configuration.', - ); - } - // Exclude MfaType.sms from consideration - final mfaTypesForSetup = allowedMfaTypes.difference({MfaType.sms}); - if (mfaTypesForSetup.isEmpty) { - throw const InvalidUserPoolConfigurationException( - 'No eligible MFA types are available for setup.', - recoverySuggestion: 'Check your user pool MFA configuration.', - ); - } - if (mfaTypesForSetup.length == 1) { - final mfaType = mfaTypesForSetup.first; - if (mfaType == MfaType.totp) { - _enableMfaType = MfaType.totp; - _totpSetupResult ??= await associateSoftwareToken(); - if (hasUserResponse) { - return createMfaSetupRequest(event); - } else { - // Need to prompt user for the TOTP code - return null; - } - } else if (mfaType == MfaType.email) { - _enableMfaType = MfaType.email; - if (hasUserResponse) { - return createEmailMfaSetupRequest(event); - } else { - // Need to prompt user for the email verification code - return null; - } - } else { - throw InvalidUserPoolConfigurationException( - 'Unsupported MFA type: ${mfaType.name}', - recoverySuggestion: 'Check your user pool MFA configuration.', - ); - } - } else if (hasUserResponse) { - // Handle user's selection - return createMfaSetupRequest(event); - } else { - // Need to prompt user to select an MFA type - return null; - } - })(), + ChallengeNameType.mfaSetup => + handleMfaSetup(event: event, hasUserResponse: hasUserResponse), ChallengeNameType.newPasswordRequired when hasUserResponse => createNewPasswordRequest(event), _ => null, @@ -698,6 +651,63 @@ final class SignInStateMachine } } + /// Handles the MFA setup challenge. + @protected + Future handleMfaSetup({ + SignInEvent? event, + required bool hasUserResponse, + }) async { + final allowedMfaTypes = _allowedMfaTypes; + if (allowedMfaTypes == null || allowedMfaTypes.isEmpty) { + throw const InvalidUserPoolConfigurationException( + 'No MFA types are allowed for setup.', + recoverySuggestion: 'Check your user pool MFA configuration.', + ); + } + + // Exclude MfaType.sms from consideration + final mfaTypesForSetup = allowedMfaTypes.difference({MfaType.sms}); + if (mfaTypesForSetup.isEmpty) { + throw const InvalidUserPoolConfigurationException( + 'No eligible MFA types are available for setup.', + recoverySuggestion: 'Check your user pool MFA configuration.', + ); + } + + if (mfaTypesForSetup.length == 1) { + final mfaType = mfaTypesForSetup.first; + if (mfaType == MfaType.totp) { + _enableMfaType = MfaType.totp; + _totpSetupResult ??= await associateSoftwareToken(); + if (hasUserResponse) { + return createMfaSetupRequest(event as SignInRespondToChallenge); + } else { + // Need to prompt user for the TOTP code + return null; + } + } else if (mfaType == MfaType.email) { + _enableMfaType = MfaType.email; + if (hasUserResponse) { + return createEmailMfaSetupRequest(event as SignInRespondToChallenge); + } else { + // Need to prompt user for the email verification code + return null; + } + } else { + throw InvalidUserPoolConfigurationException( + 'Unsupported MFA type: ${mfaType.name}', + recoverySuggestion: 'Check your user pool MFA configuration.', + ); + } + } else if (hasUserResponse) { + // Handle user's selection + return createMfaSetupRequest(event as SignInRespondToChallenge); + } else { + // Need to prompt user to select an MFA type + return null; + } + } + /// Completes set up of a TOTP MFA. @protected Future createMfaSetupRequest( From 0fdcc15bbfe8784656e4b3df4c3b072a5240ea11 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Mon, 7 Oct 2024 13:27:53 -0700 Subject: [PATCH 34/91] chore: flatten an if statement in the helper method by adding mfaTypesForSetup in the first if statement --- .../src/state/machines/sign_in_state_machine.dart | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart index 6e6a121ceb..948a68cb2c 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart @@ -658,18 +658,11 @@ final class SignInStateMachine required bool hasUserResponse, }) async { final allowedMfaTypes = _allowedMfaTypes; - if (allowedMfaTypes == null || allowedMfaTypes.isEmpty) { - throw const InvalidUserPoolConfigurationException( - 'No MFA types are allowed for setup.', - recoverySuggestion: 'Check your user pool MFA configuration.', - ); - } - // Exclude MfaType.sms from consideration - final mfaTypesForSetup = allowedMfaTypes.difference({MfaType.sms}); - if (mfaTypesForSetup.isEmpty) { + final mfaTypesForSetup = allowedMfaTypes?.difference({MfaType.sms}); + if (allowedMfaTypes == null || allowedMfaTypes.isEmpty || mfaTypesForSetup == null || mfaTypesForSetup.isEmpty) { throw const InvalidUserPoolConfigurationException( - 'No eligible MFA types are available for setup.', + 'No eligible MFA types are allowed for setup.', recoverySuggestion: 'Check your user pool MFA configuration.', ); } From e630a30c59947125ac3dd053e42f756f1c36283d Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Mon, 7 Oct 2024 13:39:24 -0700 Subject: [PATCH 35/91] chore: dart format --- .../lib/src/state/machines/sign_in_state_machine.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart index 948a68cb2c..c0311d1f78 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart @@ -660,7 +660,10 @@ final class SignInStateMachine final allowedMfaTypes = _allowedMfaTypes; // Exclude MfaType.sms from consideration final mfaTypesForSetup = allowedMfaTypes?.difference({MfaType.sms}); - if (allowedMfaTypes == null || allowedMfaTypes.isEmpty || mfaTypesForSetup == null || mfaTypesForSetup.isEmpty) { + if (allowedMfaTypes == null || + allowedMfaTypes.isEmpty || + mfaTypesForSetup == null || + mfaTypesForSetup.isEmpty) { throw const InvalidUserPoolConfigurationException( 'No eligible MFA types are allowed for setup.', recoverySuggestion: 'Check your user pool MFA configuration.', From 334e8b3dead6cec863fb96d478cc77d5016c904a Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Mon, 7 Oct 2024 14:04:16 -0700 Subject: [PATCH 36/91] chore: remove extra if checks and add null check --- .../lib/src/state/machines/sign_in_state_machine.dart | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart index c0311d1f78..5d65b00f8e 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart @@ -661,16 +661,14 @@ final class SignInStateMachine // Exclude MfaType.sms from consideration final mfaTypesForSetup = allowedMfaTypes?.difference({MfaType.sms}); if (allowedMfaTypes == null || - allowedMfaTypes.isEmpty || - mfaTypesForSetup == null || - mfaTypesForSetup.isEmpty) { + allowedMfaTypes.isEmpty) { throw const InvalidUserPoolConfigurationException( 'No eligible MFA types are allowed for setup.', recoverySuggestion: 'Check your user pool MFA configuration.', ); } - if (mfaTypesForSetup.length == 1) { + if (mfaTypesForSetup!.length == 1) { final mfaType = mfaTypesForSetup.first; if (mfaType == MfaType.totp) { _enableMfaType = MfaType.totp; From 87bb72ba66bceb674f4d40aba82d73dbf198379c Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Mon, 7 Oct 2024 14:16:16 -0700 Subject: [PATCH 37/91] chore: dart format --- .../lib/src/state/machines/sign_in_state_machine.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart index 5d65b00f8e..b5ee708705 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart @@ -660,8 +660,7 @@ final class SignInStateMachine final allowedMfaTypes = _allowedMfaTypes; // Exclude MfaType.sms from consideration final mfaTypesForSetup = allowedMfaTypes?.difference({MfaType.sms}); - if (allowedMfaTypes == null || - allowedMfaTypes.isEmpty) { + if (allowedMfaTypes == null || allowedMfaTypes.isEmpty) { throw const InvalidUserPoolConfigurationException( 'No eligible MFA types are allowed for setup.', recoverySuggestion: 'Check your user pool MFA configuration.', From c4ee27de24f33b497a917e590885304df9f78d18 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Mon, 7 Oct 2024 14:21:05 -0700 Subject: [PATCH 38/91] chore: add back in mfaTypesForSetup instead of allowedMfaTypes --- .../lib/src/state/machines/sign_in_state_machine.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart index b5ee708705..725f66b9d1 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart @@ -660,14 +660,14 @@ final class SignInStateMachine final allowedMfaTypes = _allowedMfaTypes; // Exclude MfaType.sms from consideration final mfaTypesForSetup = allowedMfaTypes?.difference({MfaType.sms}); - if (allowedMfaTypes == null || allowedMfaTypes.isEmpty) { + if (mfaTypesForSetup == null || mfaTypesForSetup.isEmpty) { throw const InvalidUserPoolConfigurationException( 'No eligible MFA types are allowed for setup.', recoverySuggestion: 'Check your user pool MFA configuration.', ); } - if (mfaTypesForSetup!.length == 1) { + if (mfaTypesForSetup.length == 1) { final mfaType = mfaTypesForSetup.first; if (mfaType == MfaType.totp) { _enableMfaType = MfaType.totp; From c89773baa292995abd11beca1afe6cdeb94fcb8c Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 2 Aug 2024 16:33:08 -0700 Subject: [PATCH 39/91] chore: add ChallengeName --- .../model/challenge_name_type.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/challenge_name_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/challenge_name_type.dart index 245f07151e..29df69b192 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/challenge_name_type.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/challenge_name_type.dart @@ -80,6 +80,12 @@ class ChallengeNameType extends _i1.SmithyEnum { 'SOFTWARE_TOKEN_MFA', ); + static const emailMfa = ChallengeNameType._( + 10, + 'EMAIL_MFA', + 'EMAIL_MFA', + ); + /// All values of [ChallengeNameType]. static const values = [ ChallengeNameType.adminNoSrpAuth, @@ -93,6 +99,7 @@ class ChallengeNameType extends _i1.SmithyEnum { ChallengeNameType.selectMfaType, ChallengeNameType.smsMfa, ChallengeNameType.softwareTokenMfa, + ChallengeNameType.emailMfa, ]; static const List<_i1.SmithySerializer> serializers = [ From 255aaa64701052e38f369e537f6f355ac8eb8488 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Mon, 5 Aug 2024 10:46:40 -0700 Subject: [PATCH 40/91] Revert "chore: add ChallengeName" This reverts commit 04fbd0c4ebd073fe291d95abfb5f33aa8bfe1f50. --- .../model/challenge_name_type.dart | 7 ------- 1 file changed, 7 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/challenge_name_type.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/challenge_name_type.dart index 29df69b192..245f07151e 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/challenge_name_type.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/model/challenge_name_type.dart @@ -80,12 +80,6 @@ class ChallengeNameType extends _i1.SmithyEnum { 'SOFTWARE_TOKEN_MFA', ); - static const emailMfa = ChallengeNameType._( - 10, - 'EMAIL_MFA', - 'EMAIL_MFA', - ); - /// All values of [ChallengeNameType]. static const values = [ ChallengeNameType.adminNoSrpAuth, @@ -99,7 +93,6 @@ class ChallengeNameType extends _i1.SmithyEnum { ChallengeNameType.selectMfaType, ChallengeNameType.smsMfa, ChallengeNameType.softwareTokenMfa, - ChallengeNameType.emailMfa, ]; static const List<_i1.SmithySerializer> serializers = [ From d7a5700d4e4e17a3a25beaa3c7fbf062455fd0bb Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Thu, 12 Sep 2024 16:45:05 -0700 Subject: [PATCH 41/91] chore: merge main (#5449) * chore(api): update endpoint config to use ApiOutputs instead of AWSApiConfig type (#5193) * feat: bump json_annotation dependency to v4.9 * chore: update actions workflow to run aft link * chore(secure_storage): Plugin Endorsement (#5208) * chore(infra): bump deps (#5221) * chore(test): use Amplify Gen 2 config in unit tests (#5205) * chore: add testUrlScheme back to test (#5223) * chore: add gen2 auth e2e infra (#5179) * chore(infra): Api migrate to Gen 2 E2E * fix: git update-index --chmod=+x * fix: code review * chore: port auth backend * chore: port lambda triggers for create user and custom email sender * chore: move utils to infra-common * chore: compile infra common to js * chore: update utils for js restructure, add missing deps * chore: fix confirmation code infra * chore: update tests to run for gen2 stacks * chore: remove alias from custom sender lambda * chore: fix deliveryMedium in reset password test * chore: add phone sign in infra * chore: rename email-sign-in * chore: add license header * chore: fix formatting in GH workflow * chore: update package-lock * chore: remove deleted file * chore: fix formatting * chore: update package lock * chore: remove dup function * chore: remove changes from merge conflicts * chore: fix build script * chore: fetch auth amplify_outputs * chore: remove libgit2dart * chore: add custom sms sender * chore: add stack name to infra resources * chore: pull gen2 backend for authenticator * chore: update package-lock * chore: move dependencies to dev_dependencies * chore: update fetch auth session tests * chore: separate reset pw and confirmation delivery medium * chore: fix hanging test * chore: rename test group * chore: update comments, remove unused type * chore: update package lock --------- Co-authored-by: Elijah Quartey * chore(auth): sign-up state machine to use AmplifyOutputs instead of AmplifyConfig types (#5230) * chore(auth): sign-in state machine to use AmplifyOutputs instead of AmplifyConfig types (#5231) * chore(auth): fetch auth session state machine to use AmplifyOutputs instead of AmplifyConfig types (#5234) * chore(auth): sign-out state machine to use AmplifyOutputs instead of AmplifConfig types (#5235) * chore(actions): android emulator to start with clear cache and data (#5245) * chore(actions): e2e android tests to run with API 34 (#5247) * chore(infra): bump deps (#5246) Updated @aws-sdk/client-amplify @aws-sdk/client-cognito-identity-provider @aws-crypto/client-node @aws-sdk/client-s3 * chore(auth): cognito keys to not use AmplifyConfig types (#5243) * chore(auth): hosted ui state machine to not use AmplifyConfig types (#5254) * fix(datastore): Clear subscriptions on Stop (#5253) * Chore/goldens flutter lint (#5271) * temp: generate goldens png * test: fixing context mounted issue * chore: add todo comment about deprecated member use --------- Co-authored-by: Andrew Hahn * chore(infra): analytics integ test gen 2 backend (#5104) * chore(auth): device metadata repository to use AuthOutputs instead of CognitoUserPoolConfig (#5289) * feat(Auth): Add fetchCurrentDevice API (#5251) feat(Auth): Add fetchCurrentDevice API (#5251) * chore(dependencies): bump package_info_plus (#5274) chore: bump package_info_plus * chore: migrate sms only MFA infra to Gen 2 (#5291) * chore: add new auth backend * chore: add auth extension * chore: add license headers * chore: add mfa to env * chore: add trigger to enable MFA * chore: add infra for sms required * chore: refactor tests for gen 2 backends * chore: add backends to deploy script * chore: package-lock for mfa-required-sms * chore: remove bundling of @aws-crypto/client-node * chore: fix formatting * fix(datastore): Restart Sync Engine when network on/off (#5218) * chore: update authenticator tests (#5296) * chore(auth): hosted ui platforms to use AmplifyOutputs types instead of AmplifyConfig (#5273) * chore(auth): asf context data provider to use AuthOutputs instead of CognitoUserPoolConfig (#5290) * chore(auth): fix fetch current device test (#5297) * fix: push notification flush events (#5215) fix: push notification flush events (#5215) * chore(dependencies): bump build_runner (#5300) * chore(dependencies): bump build_runner * chore(bump): checks package (#5305) * chore(bump): checks package * chore(version): Bump version chore(): Fixed Version Bumps chore: fixed change log chore: fixed change log chore: fixed change log chore: fixed change log * chore: manually bump amplify_db_common version * chore(infra): Extend API key expiration (#5336) * chore(dev): use ubuntu image from amazon ECR public gallery instead of docket hub (#5341) * fix(api): web socket error handling (#5359) * chore: update issue template (#5369) * fix(datastore): FlutterSerializedModel.extractJsonValue returns `.some(nil)` instead of `nil` (#5370) * chore: add GH actions for issue open, close, comment, label events (#5310) * fix(secure_storage): add missing macOS plugin (#5372) fix(secure_storage): add missing macos plugin it's fixing #5361 * chore: update plugin registrant for example apps that depend on secure storage (#5379) * chore(version): Bump version - fix(secure_storage): add missing macOS plugin ([#5372](https://github.com/aws-amplify/amplify-flutter/pull/5372)) Updated-Components: Secure Storage * chore(deps): Amplify Android 2.21.1 (#5376) * update amplify android to latest * update amplify android to latest in notifications * feat(aws_common): Generated new AWSService constructors (#5378) * chore(infra): regen lock file (#5374) * chore(auth): credential store state machine to use AuthOutputs instead of AmplifyConfig types (#5298) * chore(api): Remove Gen 1 API backend (#5393) * chore(datastore): Add multi auth integration tests (#5204) * feat: move App Sync subscription headers to protocol (#5301) * chore: move subscription headers to protocol * fix: remove `=` from encoded headers * chore: add comment * chore: `aft version-bump` test suite (#5424) * chore: add `--skip-build-version` option * chore: use `base-ref`/`head-ref` over env vars * chore: add new version bump test suite * chore: remove old version bump tests * chore: only include first change log entry * fix: sort change types before writing to the change log * chore: remove non essential info from diffs * chore: generate repo snapshot * chore: generate diff snapshots * chore: clean up tests and test output * chore: update `aft generate workflows`, regenerate dependabot.yaml (#5441) * chore: skip repo snapshot in dependabot generation * chore: regenerate dependabot.yaml * chore: fix `aft version-bump` (#5436) * fix: properly handle component propagation * chore: add test for multi package update with breaking common package --------- Co-authored-by: NikaHsn Co-authored-by: Jordan Nelson Co-authored-by: Elijah Quartey Co-authored-by: Elijah Quartey Co-authored-by: Tyler-Larkin Co-authored-by: Andrew Hahn Co-authored-by: Andrew Hahn <58017052+hahnandrew@users.noreply.github.com> Co-authored-by: Burak Karahan Co-authored-by: Jamil Saadeh --- infra-gen2/package-lock.json | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/infra-gen2/package-lock.json b/infra-gen2/package-lock.json index 806c800dd6..191c337b64 100644 --- a/infra-gen2/package-lock.json +++ b/infra-gen2/package-lock.json @@ -4462,6 +4462,18 @@ "inBundle": true, "license": "Apache-2.0", "dependencies": { + "@aws-crypto/sha256-browser": "5.2.0", + "@aws-crypto/sha256-js": "5.2.0", + "@aws-sdk/client-sso-oidc": "3.624.0", + "@aws-sdk/client-sts": "3.624.0", + "@aws-sdk/core": "3.624.0", + "@aws-sdk/credential-provider-node": "3.624.0", + "@aws-sdk/middleware-host-header": "3.620.0", + "@aws-sdk/middleware-logger": "3.609.0", + "@aws-sdk/middleware-recursion-detection": "3.620.0", + "@aws-sdk/middleware-sdk-ec2": "3.622.0", + "@aws-sdk/middleware-user-agent": "3.620.0", + "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", "bowser": "^2.11.0", @@ -4474,9 +4486,27 @@ "inBundle": true, "license": "Apache-2.0", "dependencies": { + "@aws-crypto/sha256-browser": "5.2.0", + "@aws-crypto/sha256-js": "5.2.0", + "@aws-sdk/core": "3.624.0", + "@aws-sdk/middleware-host-header": "3.620.0", + "@aws-sdk/middleware-logger": "3.609.0", + "@aws-sdk/middleware-recursion-detection": "3.620.0", + "@aws-sdk/middleware-user-agent": "3.620.0", + "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/types": "^3.3.0", + "@smithy/url-parser": "^3.0.3", + "@smithy/util-base64": "^3.0.0", + "@smithy/util-body-length-browser": "^3.0.0", + "@smithy/util-body-length-node": "^3.0.0", + "@smithy/util-defaults-mode-browser": "^3.0.14", + "@smithy/util-defaults-mode-node": "^3.0.14", + "@smithy/util-endpoints": "^2.0.5", + "@smithy/util-middleware": "^3.0.3", + "@smithy/util-retry": "^3.0.3", + "@smithy/util-utf8": "^3.0.0", "tslib": "^2.6.2" }, "engines": { @@ -4592,6 +4622,8 @@ "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", + "@smithy/util-middleware": "^3.0.3", + "fast-xml-parser": "4.4.1", "tslib": "^2.6.2" }, "engines": { @@ -4606,6 +4638,7 @@ "dependencies": { "@smithy/eventstream-serde-universal": "^3.0.5", "@smithy/types": "^3.3.0", + "@smithy/util-stream": "^3.1.3", "tslib": "^2.6.2" }, "engines": { From 479a034eecf5da12c9c3f7937ab659d90b10d06b Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Wed, 18 Sep 2024 14:05:01 -0700 Subject: [PATCH 42/91] chore: revert package-lock.json changes --- infra-gen2/package-lock.json | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/infra-gen2/package-lock.json b/infra-gen2/package-lock.json index 191c337b64..806c800dd6 100644 --- a/infra-gen2/package-lock.json +++ b/infra-gen2/package-lock.json @@ -4462,18 +4462,6 @@ "inBundle": true, "license": "Apache-2.0", "dependencies": { - "@aws-crypto/sha256-browser": "5.2.0", - "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/client-sso-oidc": "3.624.0", - "@aws-sdk/client-sts": "3.624.0", - "@aws-sdk/core": "3.624.0", - "@aws-sdk/credential-provider-node": "3.624.0", - "@aws-sdk/middleware-host-header": "3.620.0", - "@aws-sdk/middleware-logger": "3.609.0", - "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-sdk-ec2": "3.622.0", - "@aws-sdk/middleware-user-agent": "3.620.0", - "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", "@smithy/types": "^3.3.0", "bowser": "^2.11.0", @@ -4486,27 +4474,9 @@ "inBundle": true, "license": "Apache-2.0", "dependencies": { - "@aws-crypto/sha256-browser": "5.2.0", - "@aws-crypto/sha256-js": "5.2.0", - "@aws-sdk/core": "3.624.0", - "@aws-sdk/middleware-host-header": "3.620.0", - "@aws-sdk/middleware-logger": "3.609.0", - "@aws-sdk/middleware-recursion-detection": "3.620.0", - "@aws-sdk/middleware-user-agent": "3.620.0", - "@aws-sdk/region-config-resolver": "3.614.0", "@aws-sdk/types": "3.609.0", "@smithy/node-config-provider": "^3.1.4", "@smithy/types": "^3.3.0", - "@smithy/url-parser": "^3.0.3", - "@smithy/util-base64": "^3.0.0", - "@smithy/util-body-length-browser": "^3.0.0", - "@smithy/util-body-length-node": "^3.0.0", - "@smithy/util-defaults-mode-browser": "^3.0.14", - "@smithy/util-defaults-mode-node": "^3.0.14", - "@smithy/util-endpoints": "^2.0.5", - "@smithy/util-middleware": "^3.0.3", - "@smithy/util-retry": "^3.0.3", - "@smithy/util-utf8": "^3.0.0", "tslib": "^2.6.2" }, "engines": { @@ -4622,8 +4592,6 @@ "license": "Apache-2.0", "dependencies": { "@smithy/types": "^3.3.0", - "@smithy/util-middleware": "^3.0.3", - "fast-xml-parser": "4.4.1", "tslib": "^2.6.2" }, "engines": { @@ -4638,7 +4606,6 @@ "dependencies": { "@smithy/eventstream-serde-universal": "^3.0.5", "@smithy/types": "^3.3.0", - "@smithy/util-stream": "^3.1.3", "tslib": "^2.6.2" }, "engines": { From 1eefc27c3285b780400434c359eedebcdd991608 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Wed, 28 Aug 2024 15:37:00 -0700 Subject: [PATCH 43/91] chore: add new AuthenticatorStep to switch statements in screen --- .../lib/src/screens/authenticator_screen.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart index 181816a0ba..f01f3111fd 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart @@ -91,6 +91,9 @@ class AuthenticatorScreen extends StatelessAuthenticatorComponent { case AuthenticatorStep.confirmResetPassword: case AuthenticatorStep.verifyUser: case AuthenticatorStep.confirmVerifyUser: + case AuthenticatorStep.confirmSignInWithEmailMfaCode: + case AuthenticatorStep.continueSignInWithEmailMfaSetup: + case AuthenticatorStep.continueSignInWithMfaSetupSelection: child = _FormWrapperView(step: step); case AuthenticatorStep.loading: throw StateError('Invalid step: $this'); @@ -299,6 +302,9 @@ extension on AuthenticatorStep { case AuthenticatorStep.verifyUser: case AuthenticatorStep.confirmVerifyUser: case AuthenticatorStep.loading: + case AuthenticatorStep.confirmSignInWithEmailMfaCode: + case AuthenticatorStep.continueSignInWithEmailMfaSetup: + case AuthenticatorStep.continueSignInWithMfaSetupSelection: throw StateError('Invalid step: $this'); } } From fd0db6f561c20583b58a85c6a06a819ec4107993 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 30 Aug 2024 15:00:12 -0700 Subject: [PATCH 44/91] chore: add input resolvers and localizations --- .../generated/input_localizations_en.dart | 3 +++ .../l10n/generated/title_localizations.dart | 18 ++++++++++++++ .../lib/src/l10n/input_resolver.dart | 2 +- .../lib/src/l10n/title_resolver.dart | 24 +++++++++++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations_en.dart b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations_en.dart index 6b6d42a494..300acbc706 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations_en.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations_en.dart @@ -159,4 +159,7 @@ class AuthenticatorInputLocalizationsEn @override String get totpCodePrompt => 'Please enter the code from your registered Authenticator app'; + + @override + String get selectEmail => 'Email'; } diff --git a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations.dart b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations.dart index 6d69ec3571..96b09f3830 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations.dart @@ -141,6 +141,24 @@ abstract class AuthenticatorTitleLocalizations { /// **'Enter your one-time passcode'** String get confirmSignInWithTotpMfaCode; + /// Title of the Confirm Sign In with Email MFA Code step and form + /// + /// In en, this message translates to: + /// **'Enter your one-time passcode'** + String get confirmSignInWithEmailMfaCode; + + /// Title of the Continue Sign In with Email MFA Setup step and form + /// + /// In en, this message translates to: + /// **'Set up Email Two-Factor Auth'** + String get continueSignInWithEmailMfaSetup; + + /// Title of the Continue Sign In with MFA Setup Selection step and form + /// + /// In en, this message translates to: + /// **'Select a Two-Factor Auth method to set up'** + String get continueSignInWithMfaSetupSelection; + /// Title of the Reset Password step and form /// /// In en, this message translates to: diff --git a/packages/authenticator/amplify_authenticator/lib/src/l10n/input_resolver.dart b/packages/authenticator/amplify_authenticator/lib/src/l10n/input_resolver.dart index 4b04f86962..0eb96b26f1 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/l10n/input_resolver.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/l10n/input_resolver.dart @@ -174,7 +174,7 @@ class InputResolverKey { static const selectEmail = InputResolverKey._( InputResolverKeyType.title, - field: InputField.email, + field: InputField.selectEmail, ); static const totpCodePrompt = InputResolverKey._( diff --git a/packages/authenticator/amplify_authenticator/lib/src/l10n/title_resolver.dart b/packages/authenticator/amplify_authenticator/lib/src/l10n/title_resolver.dart index bbbf34925c..e5c1b19480 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/l10n/title_resolver.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/l10n/title_resolver.dart @@ -49,6 +49,24 @@ class TitleResolver extends Resolver { .confirmSignInWithTotpMfaCode; } + /// The title for the confirm sign in (email MFA code) Widget. + String confirmSignInWithEmailMfaCode(BuildContext context) { + return AuthenticatorLocalizations.titlesOf(context) + .confirmSignInWithEmailMfaCode; + } + + /// The title for the continue sign in (email MFA setup) Widget. + String continueSignInWithEmailMfaSetup(BuildContext context) { + return AuthenticatorLocalizations.titlesOf(context) + .continueSignInWithEmailMfaSetup; + } + + /// The title for the continue sign in (mfa setup selection) Widget. + String continueSignInWithMfaSetupSelection(BuildContext context) { + return AuthenticatorLocalizations.titlesOf(context) + .continueSignInWithMfaSetupSelection; + } + /// The title for the reset password Widget. String resetPassword(BuildContext context) { return AuthenticatorLocalizations.titlesOf(context).resetPassword; @@ -81,6 +99,12 @@ class TitleResolver extends Resolver { return continueSignInWithTotpSetup(context); case AuthenticatorStep.confirmSignInWithTotpMfaCode: return confirmSignInWithTotpMfaCode(context); + case AuthenticatorStep.confirmSignInWithEmailMfaCode: + return confirmSignInWithEmailMfaCode(context); + case AuthenticatorStep.continueSignInWithEmailMfaSetup: + return continueSignInWithEmailMfaSetup(context); + case AuthenticatorStep.continueSignInWithMfaSetupSelection: + return continueSignInWithMfaSetupSelection(context); case AuthenticatorStep.resetPassword: return resetPassword(context); case AuthenticatorStep.confirmResetPassword: From 2f466d75bb71f2d55b8332e56ab409a35c7cab3b Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 30 Aug 2024 15:00:58 -0700 Subject: [PATCH 45/91] chore: add keys and enums --- .../amplify_authenticator/lib/src/enums/enums.dart | 1 + .../amplify_authenticator/lib/src/keys.dart | 5 +++++ .../lib/src/l10n/generated/title_localizations_en.dart | 10 ++++++++++ .../lib/src/l10n/src/inputs/inputs_en.arb | 6 +++++- .../amplify_authenticator/lib/src/widgets/form.dart | 2 +- 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/enums/enums.dart b/packages/authenticator/amplify_authenticator/lib/src/enums/enums.dart index f523de2aa8..3a4b577678 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/enums/enums.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/enums/enums.dart @@ -4,6 +4,7 @@ export 'authenticator_step.dart'; export 'confirm_signin_types.dart'; export 'confirm_signup_types.dart'; +export 'email_setup_types.dart'; export 'gender.dart'; export 'reset_password_field.dart'; export 'signin_types.dart'; diff --git a/packages/authenticator/amplify_authenticator/lib/src/keys.dart b/packages/authenticator/amplify_authenticator/lib/src/keys.dart index 49510ea7cf..bdc58969a1 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/keys.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/keys.dart @@ -140,3 +140,8 @@ const keyAuthenticatorBanner = Key('authenticatorBanner'); const keyQrCodeTotpSetupFormField = Key('qrCodeTotpSetupFormField'); const keyCopyKeyTotpSetupFormField = Key('copyKeyTotpSetupFormField'); const keyTotpSetupFormField = Key('totpSetupFormField'); + +// Email setup form keys +const keyEmailSetupFormField = Key('emailSetupFormField'); +const keyVerificationCodeEmailSetupFormField = + Key('verificationCodeEmailSetupFormField'); diff --git a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations_en.dart b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations_en.dart index 02fb43da7d..3f3ca2b794 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations_en.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations_en.dart @@ -30,6 +30,16 @@ class AuthenticatorTitleLocalizationsEn @override String get confirmSignInWithTotpMfaCode => 'Enter your one-time passcode'; + @override + String get confirmSignInWithEmailMfaCode => 'Enter your one-time passcode'; + + @override + String get continueSignInWithEmailMfaSetup => 'Set up Email Two-Factor Auth'; + + @override + String get continueSignInWithMfaSetupSelection => + 'Select a Two-Factor Auth method to set up'; + @override String get resetPassword => 'Send Code'; diff --git a/packages/authenticator/amplify_authenticator/lib/src/l10n/src/inputs/inputs_en.arb b/packages/authenticator/amplify_authenticator/lib/src/l10n/src/inputs/inputs_en.arb index 90399598d1..e32dd76731 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/l10n/src/inputs/inputs_en.arb +++ b/packages/authenticator/amplify_authenticator/lib/src/l10n/src/inputs/inputs_en.arb @@ -216,5 +216,9 @@ "totpCodePrompt": "Please enter the code from your registered Authenticator app", "@totpCodePrompt": { "description": "The instructional text for submitting a TOTP pass code" - } + }, + "selectEmail": "Email", + "@selectEmail": { + "description": "Label for the radio button to select email as the user's chosen MFA method." + }, } diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart index 301b61177c..59aa9f2689 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart @@ -544,7 +544,7 @@ class ConfirmSignInCustomAuthForm extends AuthenticatorForm { /// {@category Prebuilt Widgets} /// {@template amplify_authenticator.confirm_sign_in_mfa_form} /// A prebuilt form for completing the sign in process with an MFA code, from -/// either SMS or TOTP. +/// either SMS, TOTP, or Email. /// {@endtemplate} class ConfirmSignInMFAForm extends AuthenticatorForm { /// {@macro amplify_authenticator.confirm_sign_in_mfa_form} From 69fa04e846ef5723ee63040cdcf9e737334d47e7 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 30 Aug 2024 15:02:06 -0700 Subject: [PATCH 46/91] chore: add select email input resolver --- .../amplify_authenticator/lib/src/l10n/input_resolver.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/authenticator/amplify_authenticator/lib/src/l10n/input_resolver.dart b/packages/authenticator/amplify_authenticator/lib/src/l10n/input_resolver.dart index 0eb96b26f1..27626a8a6f 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/l10n/input_resolver.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/l10n/input_resolver.dart @@ -466,6 +466,8 @@ class InputResolver extends Resolver { return AuthenticatorLocalizations.inputsOf(context).selectEmail; case InputField.totpCodePrompt: return AuthenticatorLocalizations.inputsOf(context).totpCodePrompt; + case InputField.selectEmail: + return AuthenticatorLocalizations.inputsOf(context).selectEmail; case InputField.usernameType: return AuthenticatorLocalizations.inputsOf(context).usernameType; } From 059213dae2e8c608293090b96bed30513e76f738 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:35:17 -0700 Subject: [PATCH 47/91] chore: add EmailSetupField type for authenticator --- .../lib/src/enums/email_setup_types.dart | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 packages/authenticator/amplify_authenticator/lib/src/enums/email_setup_types.dart diff --git a/packages/authenticator/amplify_authenticator/lib/src/enums/email_setup_types.dart b/packages/authenticator/amplify_authenticator/lib/src/enums/email_setup_types.dart new file mode 100644 index 0000000000..a5f608d04b --- /dev/null +++ b/packages/authenticator/amplify_authenticator/lib/src/enums/email_setup_types.dart @@ -0,0 +1,7 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +enum EmailSetupField { + email, + code, +} From 111f35ee500215e3f50e3e14bbe661724f83e981 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:03:41 -0700 Subject: [PATCH 48/91] chore: add switch cases for future implementations of the forms --- .../lib/src/state/inherited_forms.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart b/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart index a2a0dfa5ae..6511ba682f 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart @@ -55,10 +55,16 @@ class InheritedForms extends InheritedWidget { return confirmSignInNewPasswordForm; case AuthenticatorStep.continueSignInWithMfaSelection: return continueSignInWithMfaSelectionForm; + case AuthenticatorStep.continueSignInWithMfaSetupSelection: + // TODO(khatruong2009): Implement this form case AuthenticatorStep.continueSignInWithTotpSetup: return continueSignInWithTotpSetupForm; case AuthenticatorStep.confirmSignInWithTotpMfaCode: return confirmSignInWithTotpMfaCodeForm; + case AuthenticatorStep.continueSignInWithEmailMfaSetup: + // TODO(khatruong2009): Implement this form + case AuthenticatorStep.confirmSignInWithEmailMfaCode: + // TODO(khatruong2009): Implement this form case AuthenticatorStep.resetPassword: return resetPasswordForm; case AuthenticatorStep.confirmResetPassword: From 8f2ccdfcd1f24afe4abef38d27bd86c0170e0425 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Wed, 4 Sep 2024 10:53:46 -0700 Subject: [PATCH 49/91] chore: add authenticator step cases for sign in with email mfa --- .../amplify_authenticator/lib/src/widgets/form_field.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_field.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_field.dart index f53a94b831..e8ba9fe1ae 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_field.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_field.dart @@ -28,6 +28,7 @@ import 'package:qr_flutter/qr_flutter.dart'; part 'form_fields/confirm_sign_in_form_field.dart'; part 'form_fields/confirm_sign_up_form_field.dart'; +part 'form_fields/email_setup_form_field.dart'; part 'form_fields/mfa_selection_form_field.dart'; part 'form_fields/phone_number_field.dart'; part 'form_fields/reset_password_form_field.dart'; @@ -228,12 +229,15 @@ abstract class AuthenticatorFormFieldState< case AuthenticatorStep.confirmSignInCustomAuth: state.confirmSignInCustomAuth(); case AuthenticatorStep.confirmSignInMfa: + case AuthenticatorStep.confirmSignInWithEmailMfaCode: state.confirmSignInMFA(); case AuthenticatorStep.confirmSignInNewPassword: state.confirmSignInNewPassword(); case AuthenticatorStep.confirmSignInWithTotpMfaCode: case AuthenticatorStep.continueSignInWithTotpSetup: state.confirmTotp(); + case AuthenticatorStep.continueSignInWithEmailMfaSetup: + state.continueEmailMfaSetup(); case AuthenticatorStep.resetPassword: state.resetPassword(); case AuthenticatorStep.confirmResetPassword: From db1409aab7d2ea9e1aef405c997ee5e93e3d8986 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Wed, 4 Sep 2024 10:56:31 -0700 Subject: [PATCH 50/91] chore: remove code from email setup field because only email is needed --- .../amplify_authenticator/lib/src/enums/email_setup_types.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/enums/email_setup_types.dart b/packages/authenticator/amplify_authenticator/lib/src/enums/email_setup_types.dart index a5f608d04b..88252cb4e5 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/enums/email_setup_types.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/enums/email_setup_types.dart @@ -3,5 +3,4 @@ enum EmailSetupField { email, - code, } From bafad94b6818137e8392f651df95eef1d7a9d354 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Wed, 4 Sep 2024 11:14:55 -0700 Subject: [PATCH 51/91] chore: add mfa email to authenticator state --- .../lib/src/state/authenticator_state.dart | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart b/packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart index 10bdef835b..38c630da49 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart @@ -160,6 +160,18 @@ class AuthenticatorState extends ChangeNotifier { notifyListeners(); } + /// The value for the email MFA setup form field + /// + /// This value will be used during continue email MFA setup + String get mfaEmail => _mfaEmail; + + set mfaEmail(String value) { + _mfaEmail = value.trim(); + notifyListeners(); + } + + String _mfaEmail = ''; + MfaType? _selectedMfaMethod; TotpSetupDetails? get totpSetupDetails { @@ -414,6 +426,23 @@ class AuthenticatorState extends ChangeNotifier { _setIsBusy(false); } + /// Complete MFA setup using the values for [confirmationCode] + Future continueEmailMfaSetup() async { + if (!_formKey.currentState!.validate()) { + return; + } + + _setIsBusy(true); + + final confirm = AuthConfirmSignInData( + confirmationValue: _mfaEmail.trim(), + ); + + _authBloc.add(AuthConfirmSignIn(confirm)); + await nextBlocEvent(); + _setIsBusy(false); + } + /// Complete the force password change with [newPassword] Future confirmSignInNewPassword() async { if (!_formKey.currentState!.validate()) { From c4b809bdd54f63c65206c73503e304ec21db7c28 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:35:24 -0700 Subject: [PATCH 52/91] chore: add email mfa setup form and form field --- .../lib/amplify_authenticator.dart | 2 + .../lib/src/state/inherited_forms.dart | 8 ++ .../lib/src/widgets/form.dart | 22 +++++ .../form_fields/email_setup_form_field.dart | 90 +++++++++++++++++++ 4 files changed, 122 insertions(+) create mode 100644 packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/email_setup_form_field.dart diff --git a/packages/authenticator/amplify_authenticator/lib/amplify_authenticator.dart b/packages/authenticator/amplify_authenticator/lib/amplify_authenticator.dart index bd71bfdf0b..8cfaf5ab79 100644 --- a/packages/authenticator/amplify_authenticator/lib/amplify_authenticator.dart +++ b/packages/authenticator/amplify_authenticator/lib/amplify_authenticator.dart @@ -77,6 +77,7 @@ export 'src/widgets/form.dart' ConfirmSignInNewPasswordForm, ContinueSignInWithMfaSelectionForm, ContinueSignInWithTotpSetupForm, + ContinueSignInWithEmailMfaSetupForm, ConfirmSignUpForm, ResetPasswordForm, ConfirmResetPasswordForm, @@ -712,6 +713,7 @@ class _AuthenticatorState extends State { ContinueSignInWithMfaSelectionForm(), continueSignInWithTotpSetupForm: ContinueSignInWithTotpSetupForm(), + continueSignInWithEmailMfaSetupForm: ContinueSignInWithEmailMfaSetupForm(), confirmSignInWithTotpMfaCodeForm: ConfirmSignInMFAForm(), verifyUserForm: VerifyUserForm(), confirmVerifyUserForm: ConfirmVerifyUserForm(), diff --git a/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart b/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart index 6511ba682f..ad3c0f93a4 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart @@ -17,6 +17,7 @@ class InheritedForms extends InheritedWidget { required this.confirmSignInNewPasswordForm, required this.continueSignInWithMfaSelectionForm, required this.continueSignInWithTotpSetupForm, + required this.continueSignInWithEmailMfaSetupForm, required this.confirmSignInWithTotpMfaCodeForm, required this.verifyUserForm, required this.confirmVerifyUserForm, @@ -31,6 +32,7 @@ class InheritedForms extends InheritedWidget { final ConfirmSignInNewPasswordForm confirmSignInNewPasswordForm; final ContinueSignInWithMfaSelectionForm continueSignInWithMfaSelectionForm; final ContinueSignInWithTotpSetupForm continueSignInWithTotpSetupForm; + final ContinueSignInWithEmailMfaSetupForm continueSignInWithEmailMfaSetupForm; final ConfirmSignInMFAForm confirmSignInWithTotpMfaCodeForm; final ResetPasswordForm resetPasswordForm; final ConfirmResetPasswordForm confirmResetPasswordForm; @@ -112,6 +114,12 @@ class InheritedForms extends InheritedWidget { oldWidget.confirmSignInWithTotpMfaCodeForm != confirmSignInWithTotpMfaCodeForm; } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(DiagnosticsProperty('continueSignInWithEmailMfaSetupForm', continueSignInWithEmailMfaSetupForm)); + } } // ignore_for_file: prefer_asserts_with_message diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart index 59aa9f2689..9c91c3fb0d 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart @@ -646,6 +646,28 @@ class ContinueSignInWithTotpSetupForm extends AuthenticatorForm { AuthenticatorFormState(); } +/// {@category Prebuilt Widgets} +/// {@template amplify_authenticator.continue_sign_in_with_email_mfa_setup_form} +/// A prebuilt form for completing the email mfa setup process. +/// {@endtemplate} +class ContinueSignInWithEmailMfaSetupForm extends AuthenticatorForm { + ContinueSignInWithEmailMfaSetupForm({ + super.key, + }) : super._( + fields: [ + EmailSetupFormField.email(), + ], + actions: const [ + ConfirmSignInMFAButton(), + BackToSignInButton(), + ], + ); + + @override + AuthenticatorFormState createState() => + AuthenticatorFormState(); +} + /// {@category Prebuilt Widgets} /// {@template amplify_authenticator.send_code_form} /// A prebuilt form for initiating the reset password flow. diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/email_setup_form_field.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/email_setup_form_field.dart new file mode 100644 index 0000000000..06647ee4f9 --- /dev/null +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/email_setup_form_field.dart @@ -0,0 +1,90 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +part of '../form_field.dart'; + +/// {@category Prebuilt Widgets} +/// {@template amplify_authenticator.email_setup_form_field} +/// A prebuilt form field widget for use on the Email MFA setup step. +/// {@endtemplate} +abstract class EmailSetupFormField + extends AuthenticatorFormField { + /// {@macro amplify_authenticator.email_setup_form_field} + /// + /// Either [titleKey] or [title] is required. + const EmailSetupFormField._({ + super.key, + required super.field, + super.titleKey, + super.hintTextKey, + super.title, + super.hintText, + super.validator, + super.autofillHints, + }) : super._(); + + /// Creates an email component. + static EmailSetupFormField email({ + Key? key, + FormFieldValidator? validator, + Iterable? autofillHints, + }) => + _EmailSetupTextField( + key: key ?? keyEmailSetupFormField, + titleKey: InputResolverKey.emailTitle, + hintTextKey: InputResolverKey.emailHint, + field: EmailSetupField.email, + validator: validator, + autofillHints: autofillHints, + ); +} + +abstract class _EmailSetupFormFieldState + extends AuthenticatorFormFieldState> { + @override + TextInputType get keyboardType { + return TextInputType.emailAddress; + } + + @override + Iterable? get autofillHints { + return [AutofillHints.email]; + } + + @override + bool get required { + switch (widget.field) { + case EmailSetupField.email: + return true; + } + } + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(DiagnosticsProperty('required', required)); + } +} + +class _EmailSetupTextField extends EmailSetupFormField { + const _EmailSetupTextField({ + super.key, + required super.field, + super.titleKey, + super.hintTextKey, + super.validator, + super.autofillHints, + }) : super._(); + + @override + _EmailSetupTextFieldState createState() => _EmailSetupTextFieldState(); +} + +class _EmailSetupTextFieldState extends _EmailSetupFormFieldState + with AuthenticatorTextField { + @override + bool get obscureText { + return false; + } +} From a07f13b1f6998ae3143aa88ddab5c50a679c3f87 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Thu, 5 Sep 2024 13:36:41 -0700 Subject: [PATCH 53/91] chore: adding steps to authenticator state machine --- .../amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart index 41dcfe410e..bbb05464e6 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart @@ -218,6 +218,7 @@ class StateMachineBloc switch (result.nextStep.signInStep) { case AuthSignInStep.confirmSignInWithSmsMfaCode: + case AuthSignInStep.confirmSignInWithEmailMfaCode: yield UnauthenticatedState.confirmSignInMfa; case AuthSignInStep.confirmSignInWithCustomChallenge: yield ConfirmSignInCustom( @@ -323,6 +324,7 @@ class StateMachineBloc }) async { switch (result.nextStep.signInStep) { case AuthSignInStep.confirmSignInWithSmsMfaCode: + case AuthSignInStep.confirmSignInWithEmailMfaCode: _notifyCodeSent(result.nextStep.codeDeliveryDetails?.destination); _emit(UnauthenticatedState.confirmSignInMfa); case AuthSignInStep.confirmSignInWithCustomChallenge: From 0b09af1ec866603f49b753901f90cdd56a32f8b0 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 6 Sep 2024 10:21:38 -0700 Subject: [PATCH 54/91] chore: remove this verification code form field key since we already have keyCodeConfirmSignInFormField --- packages/authenticator/amplify_authenticator/lib/src/keys.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/keys.dart b/packages/authenticator/amplify_authenticator/lib/src/keys.dart index bdc58969a1..7900366e37 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/keys.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/keys.dart @@ -143,5 +143,3 @@ const keyTotpSetupFormField = Key('totpSetupFormField'); // Email setup form keys const keyEmailSetupFormField = Key('emailSetupFormField'); -const keyVerificationCodeEmailSetupFormField = - Key('verificationCodeEmailSetupFormField'); From 362f97caa92cbd67207e5ca77ae5b2d440dd2570 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 6 Sep 2024 10:51:27 -0700 Subject: [PATCH 55/91] chore: add authenticator screen keys for new screens --- .../lib/src/screens/authenticator_screen.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart index f01f3111fd..8ffbc61622 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart @@ -39,6 +39,12 @@ class AuthenticatorScreen extends StatelessAuthenticatorComponent { const AuthenticatorScreen.confirmSignInWithTotpMfaCode({Key? key}) : this(key: key, step: AuthenticatorStep.confirmSignInWithTotpMfaCode); + + const AuthenticatorScreen.continueSignInWithEmailMfaSetup({Key? key}) + : this(key: key, step: AuthenticatorStep.continueSignInWithEmailMfaSetup); + + const AuthenticatorScreen.continueSignInWithMfaSetupSelection({Key? key}) + : this(key: key, step: AuthenticatorStep.continueSignInWithMfaSetupSelection); const AuthenticatorScreen.resetPassword({Key? key}) : this(key: key, step: AuthenticatorStep.resetPassword); From 6dfa933f01580df246ae4c659a417385dc0dd74c Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 6 Sep 2024 11:07:41 -0700 Subject: [PATCH 56/91] chore: remove dart auto formatted code --- .../lib/src/state/inherited_forms.dart | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart b/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart index ad3c0f93a4..7a292bc8f0 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart @@ -114,12 +114,6 @@ class InheritedForms extends InheritedWidget { oldWidget.confirmSignInWithTotpMfaCodeForm != confirmSignInWithTotpMfaCodeForm; } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties.add(DiagnosticsProperty('continueSignInWithEmailMfaSetupForm', continueSignInWithEmailMfaSetupForm)); - } } // ignore_for_file: prefer_asserts_with_message From 49d1d28c9ad7cdc10bbeab42d0b8bfd16494ff6a Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 6 Sep 2024 11:24:33 -0700 Subject: [PATCH 57/91] chore: add new email mfa setup form to inherited forms switch statement --- .../lib/src/state/inherited_forms.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart b/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart index 7a292bc8f0..ff42f558ee 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart @@ -58,15 +58,15 @@ class InheritedForms extends InheritedWidget { case AuthenticatorStep.continueSignInWithMfaSelection: return continueSignInWithMfaSelectionForm; case AuthenticatorStep.continueSignInWithMfaSetupSelection: - // TODO(khatruong2009): Implement this form + // TODO(khatruong2009): Implement this form case AuthenticatorStep.continueSignInWithTotpSetup: return continueSignInWithTotpSetupForm; case AuthenticatorStep.confirmSignInWithTotpMfaCode: return confirmSignInWithTotpMfaCodeForm; case AuthenticatorStep.continueSignInWithEmailMfaSetup: - // TODO(khatruong2009): Implement this form + return continueSignInWithEmailMfaSetupForm; case AuthenticatorStep.confirmSignInWithEmailMfaCode: - // TODO(khatruong2009): Implement this form + return confirmSignInMFAForm; case AuthenticatorStep.resetPassword: return resetPasswordForm; case AuthenticatorStep.confirmResetPassword: From 845892ef9af3e671792f58153379866be3a3960d Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 6 Sep 2024 11:26:56 -0700 Subject: [PATCH 58/91] chore: add cases to oldWidget --- .../lib/src/state/inherited_forms.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart b/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart index ff42f558ee..d83d7b850d 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart @@ -112,7 +112,11 @@ class InheritedForms extends InheritedWidget { oldWidget.continueSignInWithTotpSetupForm != continueSignInWithTotpSetupForm || oldWidget.confirmSignInWithTotpMfaCodeForm != - confirmSignInWithTotpMfaCodeForm; + confirmSignInWithTotpMfaCodeForm || + oldWidget.continueSignInWithEmailMfaSetupForm != + continueSignInWithEmailMfaSetupForm || + oldWidget.continueSignInWithMfaSelectionForm != + continueSignInWithMfaSelectionForm; } } From 8000bec28c0cfa7326b11f6a8314dd7adce4b948 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 6 Sep 2024 11:28:54 -0700 Subject: [PATCH 59/91] chore: add todo to add case for continueSignInWithMfaSetupSelection --- .../amplify_authenticator/lib/src/widgets/form_field.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_field.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_field.dart index e8ba9fe1ae..caa1d7151f 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_field.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_field.dart @@ -238,6 +238,7 @@ abstract class AuthenticatorFormFieldState< state.confirmTotp(); case AuthenticatorStep.continueSignInWithEmailMfaSetup: state.continueEmailMfaSetup(); + // TODO(khatruong2009): add case for AuthenticatorStep.continueSignInWithMfaSetupSelection case AuthenticatorStep.resetPassword: state.resetPassword(); case AuthenticatorStep.confirmResetPassword: From d6cd99578f622efc52183a1930ee9c1079ac5743 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:23:37 -0700 Subject: [PATCH 60/91] chore: remove duplicate localization and fix docs comments --- .../lib/src/l10n/generated/input_localizations_en.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations_en.dart b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations_en.dart index 300acbc706..bdf428025e 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations_en.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations_en.dart @@ -160,6 +160,4 @@ class AuthenticatorInputLocalizationsEn String get totpCodePrompt => 'Please enter the code from your registered Authenticator app'; - @override - String get selectEmail => 'Email'; } From 9af619d2962b6504d900f85d157e754976f7761f Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:24:10 -0700 Subject: [PATCH 61/91] chore: add continueSignInWithMfaSetupSelectionForm --- .../lib/amplify_authenticator.dart | 3 + .../lib/src/state/inherited_forms.dart | 5 +- .../lib/src/widgets/form.dart | 23 +++++++ .../lib/src/widgets/form_field.dart | 1 + .../form_fields/mfa_selection_form_field.dart | 5 ++ .../mfa_setup_selection_form_field.dart | 63 +++++++++++++++++++ 6 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/mfa_setup_selection_form_field.dart diff --git a/packages/authenticator/amplify_authenticator/lib/amplify_authenticator.dart b/packages/authenticator/amplify_authenticator/lib/amplify_authenticator.dart index 8cfaf5ab79..dc852fce19 100644 --- a/packages/authenticator/amplify_authenticator/lib/amplify_authenticator.dart +++ b/packages/authenticator/amplify_authenticator/lib/amplify_authenticator.dart @@ -76,6 +76,7 @@ export 'src/widgets/form.dart' ConfirmSignInMFAForm, ConfirmSignInNewPasswordForm, ContinueSignInWithMfaSelectionForm, + ContinueSignInWithMfaSetupSelectionForm, ContinueSignInWithTotpSetupForm, ContinueSignInWithEmailMfaSetupForm, ConfirmSignUpForm, @@ -711,6 +712,8 @@ class _AuthenticatorState extends State { confirmSignInMFAForm: ConfirmSignInMFAForm(), continueSignInWithMfaSelectionForm: ContinueSignInWithMfaSelectionForm(), + continueSignInWithMfaSetupSelectionForm: + ContinueSignInWithMfaSetupSelectionForm(), continueSignInWithTotpSetupForm: ContinueSignInWithTotpSetupForm(), continueSignInWithEmailMfaSetupForm: ContinueSignInWithEmailMfaSetupForm(), diff --git a/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart b/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart index d83d7b850d..876164b22a 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart @@ -16,6 +16,7 @@ class InheritedForms extends InheritedWidget { required this.confirmResetPasswordForm, required this.confirmSignInNewPasswordForm, required this.continueSignInWithMfaSelectionForm, + required this.continueSignInWithMfaSetupSelectionForm, required this.continueSignInWithTotpSetupForm, required this.continueSignInWithEmailMfaSetupForm, required this.confirmSignInWithTotpMfaCodeForm, @@ -31,6 +32,8 @@ class InheritedForms extends InheritedWidget { final ConfirmSignInMFAForm confirmSignInMFAForm; final ConfirmSignInNewPasswordForm confirmSignInNewPasswordForm; final ContinueSignInWithMfaSelectionForm continueSignInWithMfaSelectionForm; + final ContinueSignInWithMfaSetupSelectionForm + continueSignInWithMfaSetupSelectionForm; final ContinueSignInWithTotpSetupForm continueSignInWithTotpSetupForm; final ContinueSignInWithEmailMfaSetupForm continueSignInWithEmailMfaSetupForm; final ConfirmSignInMFAForm confirmSignInWithTotpMfaCodeForm; @@ -58,7 +61,7 @@ class InheritedForms extends InheritedWidget { case AuthenticatorStep.continueSignInWithMfaSelection: return continueSignInWithMfaSelectionForm; case AuthenticatorStep.continueSignInWithMfaSetupSelection: - // TODO(khatruong2009): Implement this form + return continueSignInWithMfaSetupSelectionForm; case AuthenticatorStep.continueSignInWithTotpSetup: return continueSignInWithTotpSetupForm; case AuthenticatorStep.confirmSignInWithTotpMfaCode: diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart index 9c91c3fb0d..a114fbb65c 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart @@ -623,6 +623,29 @@ class ContinueSignInWithMfaSelectionForm extends AuthenticatorForm { AuthenticatorFormState(); } +/// {@category Prebuilt Widgets} +/// {@template amplify_authenticator.continue_sign_in_with__mfa_setup_selection_form} +/// A prebuilt form for selecting an MFA method during setup. +/// {@endtemplate} +class ContinueSignInWithMfaSetupSelectionForm extends AuthenticatorForm { + /// {@macro amplify_authenticator.continue_sign_in_with__mfa_setup_selection_form} + ContinueSignInWithMfaSetupSelectionForm({ + super.key, + }) : super._( + fields: [ + ConfirmSignInFormField.mfaSelection(), + ], + actions: const [ + ContinueSignInMFASelectionButton(), + BackToSignInButton(), + ], + ); + + @override + AuthenticatorFormState createState() => + AuthenticatorFormState(); +} + /// {@category Prebuilt Widgets} /// {@template amplify_authenticator.continue_sign_in_with_totp_setup_form} /// A prebuilt form for completing the totp setup process. diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_field.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_field.dart index caa1d7151f..1c4477b91b 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_field.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_field.dart @@ -30,6 +30,7 @@ part 'form_fields/confirm_sign_in_form_field.dart'; part 'form_fields/confirm_sign_up_form_field.dart'; part 'form_fields/email_setup_form_field.dart'; part 'form_fields/mfa_selection_form_field.dart'; +part 'form_fields/mfa_setup_selection_form_field.dart'; part 'form_fields/phone_number_field.dart'; part 'form_fields/reset_password_form_field.dart'; part 'form_fields/sign_in_form_field.dart'; diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/mfa_selection_form_field.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/mfa_selection_form_field.dart index f5587071d0..8d73d1aae2 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/mfa_selection_form_field.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/mfa_selection_form_field.dart @@ -41,6 +41,11 @@ class _MfaSelectionFieldState extends _ConfirmSignInFormFieldState label: InputResolverKey.selectSms, value: MfaType.sms, ), + if (_allowedMfaTypes.contains(MfaType.email)) + const InputSelection( + label: InputResolverKey.selectEmail, + value: MfaType.email, + ), ]; @override diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/mfa_setup_selection_form_field.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/mfa_setup_selection_form_field.dart new file mode 100644 index 0000000000..76b4084337 --- /dev/null +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/mfa_setup_selection_form_field.dart @@ -0,0 +1,63 @@ +// mfa_setup_selection_form_field.dart + +// Copyright Amazon.com, Inc. or its affiliates. +// All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +part of '../form_field.dart'; + +/// {@category Prebuilt Widgets} +/// {@template amplify_authenticator.mfa_setup_selection_form_field} +/// A prebuilt form widget for use on the MFA setup selection step. +/// {@endtemplate} +class _MfaSetupMethodRadioField extends ConfirmSignInFormField { + const _MfaSetupMethodRadioField({ + super.key, + required super.field, + }) : super._(); + + @override + _MfaSetupSelectionFieldState createState() => _MfaSetupSelectionFieldState(); +} + +class _MfaSetupSelectionFieldState extends _ConfirmSignInFormFieldState + with AuthenticatorRadioField { + Set get _allowedMfaTypes { + final state = InheritedAuthBloc.of(context).currentState; + assert( + state is ContinueSignInWithMfaSetupSelection, + 'Expected ContinueSignInWithMfaSetupSelection for current screen', + ); + return (state as ContinueSignInWithMfaSetupSelection).allowedMfaTypes; + } + + @override + List> get selections => [ + if (_allowedMfaTypes.contains(MfaType.totp)) + const InputSelection( + label: InputResolverKey.selectTotp, + value: MfaType.totp, + ), + if (_allowedMfaTypes.contains(MfaType.email)) + const InputSelection( + label: InputResolverKey.selectEmail, + value: MfaType.email, + ), + ]; + + @override + MfaType get initialValue => selections.first.value; + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addPostFrameCallback((_) { + state.selectedMfaMethod = initialValue; + }); + } + + @override + ValueChanged get onChanged { + return (MfaType method) => state.selectedMfaMethod = method; + } +} From a8b41e93cc393c01715189ecd077fe07ef9dd2b9 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:40:20 -0700 Subject: [PATCH 62/91] chore: dart format and fix typos --- .../amplify_authenticator/lib/amplify_authenticator.dart | 3 ++- .../lib/src/l10n/generated/input_localizations_en.dart | 1 - .../lib/src/l10n/generated/title_localizations.dart | 6 +++--- .../lib/src/screens/authenticator_screen.dart | 6 ++++-- .../lib/src/state/authenticator_state.dart | 4 ++-- .../src/widgets/form_fields/confirm_sign_in_form_field.dart | 2 +- .../lib/src/widgets/form_fields/email_setup_form_field.dart | 5 ++--- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/authenticator/amplify_authenticator/lib/amplify_authenticator.dart b/packages/authenticator/amplify_authenticator/lib/amplify_authenticator.dart index dc852fce19..f83b9b84c4 100644 --- a/packages/authenticator/amplify_authenticator/lib/amplify_authenticator.dart +++ b/packages/authenticator/amplify_authenticator/lib/amplify_authenticator.dart @@ -716,7 +716,8 @@ class _AuthenticatorState extends State { ContinueSignInWithMfaSetupSelectionForm(), continueSignInWithTotpSetupForm: ContinueSignInWithTotpSetupForm(), - continueSignInWithEmailMfaSetupForm: ContinueSignInWithEmailMfaSetupForm(), + continueSignInWithEmailMfaSetupForm: + ContinueSignInWithEmailMfaSetupForm(), confirmSignInWithTotpMfaCodeForm: ConfirmSignInMFAForm(), verifyUserForm: VerifyUserForm(), confirmVerifyUserForm: ConfirmVerifyUserForm(), diff --git a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations_en.dart b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations_en.dart index bdf428025e..6b6d42a494 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations_en.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/input_localizations_en.dart @@ -159,5 +159,4 @@ class AuthenticatorInputLocalizationsEn @override String get totpCodePrompt => 'Please enter the code from your registered Authenticator app'; - } diff --git a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations.dart b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations.dart index 96b09f3830..05d73ef2a4 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations.dart @@ -142,19 +142,19 @@ abstract class AuthenticatorTitleLocalizations { String get confirmSignInWithTotpMfaCode; /// Title of the Confirm Sign In with Email MFA Code step and form - /// + /// /// In en, this message translates to: /// **'Enter your one-time passcode'** String get confirmSignInWithEmailMfaCode; /// Title of the Continue Sign In with Email MFA Setup step and form - /// + /// /// In en, this message translates to: /// **'Set up Email Two-Factor Auth'** String get continueSignInWithEmailMfaSetup; /// Title of the Continue Sign In with MFA Setup Selection step and form - /// + /// /// In en, this message translates to: /// **'Select a Two-Factor Auth method to set up'** String get continueSignInWithMfaSetupSelection; diff --git a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart index 8ffbc61622..b5d48988b1 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart @@ -39,12 +39,14 @@ class AuthenticatorScreen extends StatelessAuthenticatorComponent { const AuthenticatorScreen.confirmSignInWithTotpMfaCode({Key? key}) : this(key: key, step: AuthenticatorStep.confirmSignInWithTotpMfaCode); - + const AuthenticatorScreen.continueSignInWithEmailMfaSetup({Key? key}) : this(key: key, step: AuthenticatorStep.continueSignInWithEmailMfaSetup); const AuthenticatorScreen.continueSignInWithMfaSetupSelection({Key? key}) - : this(key: key, step: AuthenticatorStep.continueSignInWithMfaSetupSelection); + : this( + key: key, + step: AuthenticatorStep.continueSignInWithMfaSetupSelection); const AuthenticatorScreen.resetPassword({Key? key}) : this(key: key, step: AuthenticatorStep.resetPassword); diff --git a/packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart b/packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart index 38c630da49..8e4b5542e4 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart @@ -161,7 +161,7 @@ class AuthenticatorState extends ChangeNotifier { } /// The value for the email MFA setup form field - /// + /// /// This value will be used during continue email MFA setup String get mfaEmail => _mfaEmail; @@ -169,7 +169,7 @@ class AuthenticatorState extends ChangeNotifier { _mfaEmail = value.trim(); notifyListeners(); } - + String _mfaEmail = ''; MfaType? _selectedMfaMethod; diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/confirm_sign_in_form_field.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/confirm_sign_in_form_field.dart index d4b39d1d22..ce8bf33081 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/confirm_sign_in_form_field.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/confirm_sign_in_form_field.dart @@ -79,7 +79,7 @@ abstract class ConfirmSignInFormField autofillHints: autofillHints, ); - /// Creates a mfa preference selection component. + /// Creates an mfa preference selection component. static ConfirmSignInFormField mfaSelection({ Key? key, }) => diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/email_setup_form_field.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/email_setup_form_field.dart index 06647ee4f9..47951cbe8f 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/email_setup_form_field.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/email_setup_form_field.dart @@ -7,7 +7,7 @@ part of '../form_field.dart'; /// {@template amplify_authenticator.email_setup_form_field} /// A prebuilt form field widget for use on the Email MFA setup step. /// {@endtemplate} -abstract class EmailSetupFormField +abstract class EmailSetupFormField extends AuthenticatorFormField { /// {@macro amplify_authenticator.email_setup_form_field} /// @@ -52,7 +52,6 @@ abstract class _EmailSetupFormFieldState return [AutofillHints.email]; } - @override bool get required { switch (widget.field) { case EmailSetupField.email: @@ -76,7 +75,7 @@ class _EmailSetupTextField extends EmailSetupFormField { super.validator, super.autofillHints, }) : super._(); - + @override _EmailSetupTextFieldState createState() => _EmailSetupTextFieldState(); } From 3b50a1b1307b2aec26df958dbb1911b5cdd4817c Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:40:48 -0700 Subject: [PATCH 63/91] chore: fix mfaSetup fields and input_resolver duplicate --- .../amplify_authenticator/lib/src/keys.dart | 2 ++ .../lib/src/l10n/input_resolver.dart | 2 -- .../amplify_authenticator/lib/src/widgets/form.dart | 7 ++++--- .../widgets/form_fields/confirm_sign_in_form_field.dart | 9 +++++++++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/keys.dart b/packages/authenticator/amplify_authenticator/lib/src/keys.dart index 7900366e37..2f0665814e 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/keys.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/keys.dart @@ -52,6 +52,8 @@ const keyCustomChallengeConfirmSignInFormField = Key('customChallengeConfirmSignInFormField'); const keyMfaMethodRadioConfirmSignInFormField = Key('mfaMethodRadioConfirmSignInFormField'); +const keyMfaSetupMethodRadioConfirmSignInFormField = + Key('mfaSetupMethodRadioConfirmSignInFormField'); const keyUsernameConfirmSignInFormField = Key('usernameConfirmSignInFormField'); const keyPasswordConfirmSignInFormField = Key('passwordConfirmSignInFormField'); const keyNewPasswordConfirmSignInFormField = diff --git a/packages/authenticator/amplify_authenticator/lib/src/l10n/input_resolver.dart b/packages/authenticator/amplify_authenticator/lib/src/l10n/input_resolver.dart index 27626a8a6f..0eb96b26f1 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/l10n/input_resolver.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/l10n/input_resolver.dart @@ -466,8 +466,6 @@ class InputResolver extends Resolver { return AuthenticatorLocalizations.inputsOf(context).selectEmail; case InputField.totpCodePrompt: return AuthenticatorLocalizations.inputsOf(context).totpCodePrompt; - case InputField.selectEmail: - return AuthenticatorLocalizations.inputsOf(context).selectEmail; case InputField.usernameType: return AuthenticatorLocalizations.inputsOf(context).usernameType; } diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart index a114fbb65c..c79d308f84 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart @@ -633,7 +633,7 @@ class ContinueSignInWithMfaSetupSelectionForm extends AuthenticatorForm { super.key, }) : super._( fields: [ - ConfirmSignInFormField.mfaSelection(), + ConfirmSignInFormField.mfaSetupSelection(), ], actions: const [ ContinueSignInMFASelectionButton(), @@ -642,8 +642,9 @@ class ContinueSignInWithMfaSetupSelectionForm extends AuthenticatorForm { ); @override - AuthenticatorFormState createState() => - AuthenticatorFormState(); + AuthenticatorFormState + createState() => + AuthenticatorFormState(); } /// {@category Prebuilt Widgets} diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/confirm_sign_in_form_field.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/confirm_sign_in_form_field.dart index ce8bf33081..22d1253f39 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/confirm_sign_in_form_field.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/confirm_sign_in_form_field.dart @@ -88,6 +88,15 @@ abstract class ConfirmSignInFormField field: ConfirmSignInField.mfaMethod, ); + /// creates an mfa preference setup selection component. + static ConfirmSignInFormField mfaSetupSelection({ + Key? key, + }) => + _MfaSetupMethodRadioField( + key: key ?? keyMfaSetupMethodRadioConfirmSignInFormField, + field: ConfirmSignInField.mfaMethod, + ); + /// Creates a verification code component. static ConfirmSignInFormField verificationCode({ Key? key, From dab8ff46ea17d8160b75b86051ab3ed685bb82d7 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Wed, 25 Sep 2024 12:56:31 -0700 Subject: [PATCH 64/91] chore: remove duplicate analytics backend section --- infra-gen2/tool/deploy_gen2.dart | 5 ----- 1 file changed, 5 deletions(-) diff --git a/infra-gen2/tool/deploy_gen2.dart b/infra-gen2/tool/deploy_gen2.dart index 15ffcf10f4..e5f8cf1a1e 100644 --- a/infra-gen2/tool/deploy_gen2.dart +++ b/infra-gen2/tool/deploy_gen2.dart @@ -19,11 +19,6 @@ import 'package:path/path.dart' as p; /// 3. Add the backend to a category or create a new category /// 4. Run `dart tool/deploy_gen2.dart` to deploy the backend const List infraConfig = [ - AmplifyBackendGroup( - category: Category.analytics, - defaultOutput: '', - backends: [], - ), AmplifyBackendGroup( category: Category.api, defaultOutput: 'packages/api/amplify_api/example/lib', From 8b7771d4e19ee18101ca4063f868b81877a47e81 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Thu, 26 Sep 2024 16:33:17 -0700 Subject: [PATCH 65/91] chore: use confirmSignInWithEmailMfaCode instead of confirmSignInMfa --- .../lib/amplify_authenticator.dart | 1 + .../lib/src/blocs/auth/auth_bloc.dart | 2 -- .../src/l10n/generated/title_localizations.dart | 4 ++-- .../l10n/generated/title_localizations_en.dart | 4 ++-- .../lib/src/screens/authenticator_screen.dart | 7 ++++--- .../lib/src/state/authenticator_state.dart | 17 +++++++++++++++++ .../lib/src/state/inherited_forms.dart | 6 +++++- .../lib/src/widgets/form_field.dart | 3 ++- 8 files changed, 33 insertions(+), 11 deletions(-) diff --git a/packages/authenticator/amplify_authenticator/lib/amplify_authenticator.dart b/packages/authenticator/amplify_authenticator/lib/amplify_authenticator.dart index f83b9b84c4..55abb9c220 100644 --- a/packages/authenticator/amplify_authenticator/lib/amplify_authenticator.dart +++ b/packages/authenticator/amplify_authenticator/lib/amplify_authenticator.dart @@ -719,6 +719,7 @@ class _AuthenticatorState extends State { continueSignInWithEmailMfaSetupForm: ContinueSignInWithEmailMfaSetupForm(), confirmSignInWithTotpMfaCodeForm: ConfirmSignInMFAForm(), + confirmSignInWithEmailMfaCodeForm: ConfirmSignInMFAForm(), verifyUserForm: VerifyUserForm(), confirmVerifyUserForm: ConfirmVerifyUserForm(), child: widget.child, diff --git a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart index bbb05464e6..41dcfe410e 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart @@ -218,7 +218,6 @@ class StateMachineBloc switch (result.nextStep.signInStep) { case AuthSignInStep.confirmSignInWithSmsMfaCode: - case AuthSignInStep.confirmSignInWithEmailMfaCode: yield UnauthenticatedState.confirmSignInMfa; case AuthSignInStep.confirmSignInWithCustomChallenge: yield ConfirmSignInCustom( @@ -324,7 +323,6 @@ class StateMachineBloc }) async { switch (result.nextStep.signInStep) { case AuthSignInStep.confirmSignInWithSmsMfaCode: - case AuthSignInStep.confirmSignInWithEmailMfaCode: _notifyCodeSent(result.nextStep.codeDeliveryDetails?.destination); _emit(UnauthenticatedState.confirmSignInMfa); case AuthSignInStep.confirmSignInWithCustomChallenge: diff --git a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations.dart b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations.dart index 05d73ef2a4..852f8e4d7b 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations.dart @@ -150,13 +150,13 @@ abstract class AuthenticatorTitleLocalizations { /// Title of the Continue Sign In with Email MFA Setup step and form /// /// In en, this message translates to: - /// **'Set up Email Two-Factor Auth'** + /// **'Add Email for Two-Factor Authentication'** String get continueSignInWithEmailMfaSetup; /// Title of the Continue Sign In with MFA Setup Selection step and form /// /// In en, this message translates to: - /// **'Select a Two-Factor Auth method to set up'** + /// **'Choose your preferred two-factor authentication method to set up'** String get continueSignInWithMfaSetupSelection; /// Title of the Reset Password step and form diff --git a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations_en.dart b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations_en.dart index 3f3ca2b794..f547339bf5 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations_en.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations_en.dart @@ -34,11 +34,11 @@ class AuthenticatorTitleLocalizationsEn String get confirmSignInWithEmailMfaCode => 'Enter your one-time passcode'; @override - String get continueSignInWithEmailMfaSetup => 'Set up Email Two-Factor Auth'; + String get continueSignInWithEmailMfaSetup => 'Add Email for Two-Factor Authentication'; @override String get continueSignInWithMfaSetupSelection => - 'Select a Two-Factor Auth method to set up'; + 'Choose your preferred two-factor authentication method to set up'; @override String get resetPassword => 'Send Code'; diff --git a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart index b5d48988b1..e547dfd9f0 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart @@ -40,13 +40,14 @@ class AuthenticatorScreen extends StatelessAuthenticatorComponent { const AuthenticatorScreen.confirmSignInWithTotpMfaCode({Key? key}) : this(key: key, step: AuthenticatorStep.confirmSignInWithTotpMfaCode); + const AuthenticatorScreen.confirmSignInWithEmailMfaCode({Key? key}) + : this(key: key, step: AuthenticatorStep.confirmSignInWithEmailMfaCode); + const AuthenticatorScreen.continueSignInWithEmailMfaSetup({Key? key}) : this(key: key, step: AuthenticatorStep.continueSignInWithEmailMfaSetup); const AuthenticatorScreen.continueSignInWithMfaSetupSelection({Key? key}) - : this( - key: key, - step: AuthenticatorStep.continueSignInWithMfaSetupSelection); + : this(key: key, step: AuthenticatorStep.continueSignInWithMfaSetupSelection); const AuthenticatorScreen.resetPassword({Key? key}) : this(key: key, step: AuthenticatorStep.resetPassword); diff --git a/packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart b/packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart index 8e4b5542e4..bf434aba5c 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart @@ -426,6 +426,23 @@ class AuthenticatorState extends ChangeNotifier { _setIsBusy(false); } + /// complete Email MFA setup using the values for [confirmationCode] + Future confirmEmailMfa() async { + if (!_formKey.currentState!.validate()) { + return; + } + + _setIsBusy(true); + + final confirm = AuthConfirmSignInData( + confirmationValue: _confirmationCode.trim(), + ); + + _authBloc.add(AuthConfirmSignIn(confirm)); + await nextBlocEvent(); + _setIsBusy(false); + } + /// Complete MFA setup using the values for [confirmationCode] Future continueEmailMfaSetup() async { if (!_formKey.currentState!.validate()) { diff --git a/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart b/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart index 876164b22a..121f81bd0d 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart @@ -20,6 +20,7 @@ class InheritedForms extends InheritedWidget { required this.continueSignInWithTotpSetupForm, required this.continueSignInWithEmailMfaSetupForm, required this.confirmSignInWithTotpMfaCodeForm, + required this.confirmSignInWithEmailMfaCodeForm, required this.verifyUserForm, required this.confirmVerifyUserForm, required super.child, @@ -37,6 +38,7 @@ class InheritedForms extends InheritedWidget { final ContinueSignInWithTotpSetupForm continueSignInWithTotpSetupForm; final ContinueSignInWithEmailMfaSetupForm continueSignInWithEmailMfaSetupForm; final ConfirmSignInMFAForm confirmSignInWithTotpMfaCodeForm; + final ConfirmSignInMFAForm confirmSignInWithEmailMfaCodeForm; final ResetPasswordForm resetPasswordForm; final ConfirmResetPasswordForm confirmResetPasswordForm; final VerifyUserForm verifyUserForm; @@ -69,7 +71,7 @@ class InheritedForms extends InheritedWidget { case AuthenticatorStep.continueSignInWithEmailMfaSetup: return continueSignInWithEmailMfaSetupForm; case AuthenticatorStep.confirmSignInWithEmailMfaCode: - return confirmSignInMFAForm; + return confirmSignInWithEmailMfaCodeForm; case AuthenticatorStep.resetPassword: return resetPasswordForm; case AuthenticatorStep.confirmResetPassword: @@ -116,6 +118,8 @@ class InheritedForms extends InheritedWidget { continueSignInWithTotpSetupForm || oldWidget.confirmSignInWithTotpMfaCodeForm != confirmSignInWithTotpMfaCodeForm || + oldWidget.confirmSignInWithEmailMfaCodeForm != + confirmSignInWithEmailMfaCodeForm || oldWidget.continueSignInWithEmailMfaSetupForm != continueSignInWithEmailMfaSetupForm || oldWidget.continueSignInWithMfaSelectionForm != diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_field.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_field.dart index 1c4477b91b..a9824be8c5 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_field.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_field.dart @@ -230,8 +230,9 @@ abstract class AuthenticatorFormFieldState< case AuthenticatorStep.confirmSignInCustomAuth: state.confirmSignInCustomAuth(); case AuthenticatorStep.confirmSignInMfa: - case AuthenticatorStep.confirmSignInWithEmailMfaCode: state.confirmSignInMFA(); + case AuthenticatorStep.confirmSignInWithEmailMfaCode: + state.confirmEmailMfa(); case AuthenticatorStep.confirmSignInNewPassword: state.confirmSignInNewPassword(); case AuthenticatorStep.confirmSignInWithTotpMfaCode: From 93a8b758e77b4aaaa98e6c473b0461aea6f5cecc Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Tue, 1 Oct 2024 22:49:16 -0700 Subject: [PATCH 66/91] chore: dart format --- .../lib/src/l10n/generated/title_localizations_en.dart | 3 ++- .../lib/src/screens/authenticator_screen.dart | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations_en.dart b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations_en.dart index f547339bf5..692f579fa5 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations_en.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/l10n/generated/title_localizations_en.dart @@ -34,7 +34,8 @@ class AuthenticatorTitleLocalizationsEn String get confirmSignInWithEmailMfaCode => 'Enter your one-time passcode'; @override - String get continueSignInWithEmailMfaSetup => 'Add Email for Two-Factor Authentication'; + String get continueSignInWithEmailMfaSetup => + 'Add Email for Two-Factor Authentication'; @override String get continueSignInWithMfaSetupSelection => diff --git a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart index e547dfd9f0..2eeebb2f8b 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart @@ -47,7 +47,9 @@ class AuthenticatorScreen extends StatelessAuthenticatorComponent { : this(key: key, step: AuthenticatorStep.continueSignInWithEmailMfaSetup); const AuthenticatorScreen.continueSignInWithMfaSetupSelection({Key? key}) - : this(key: key, step: AuthenticatorStep.continueSignInWithMfaSetupSelection); + : this( + key: key, + step: AuthenticatorStep.continueSignInWithMfaSetupSelection); const AuthenticatorScreen.resetPassword({Key? key}) : this(key: key, step: AuthenticatorStep.resetPassword); From 64f25ad8c8eab09cfca4538755c862aea4718222 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Tue, 1 Oct 2024 22:57:21 -0700 Subject: [PATCH 67/91] chore: add trailing comma --- .../lib/src/screens/authenticator_screen.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart index 2eeebb2f8b..fd99bc74ba 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart @@ -49,7 +49,7 @@ class AuthenticatorScreen extends StatelessAuthenticatorComponent { const AuthenticatorScreen.continueSignInWithMfaSetupSelection({Key? key}) : this( key: key, - step: AuthenticatorStep.continueSignInWithMfaSetupSelection); + step: AuthenticatorStep.continueSignInWithMfaSetupSelection,); const AuthenticatorScreen.resetPassword({Key? key}) : this(key: key, step: AuthenticatorStep.resetPassword); From 7fd3b39b3ff1d2011cbf481e7da5c1868a29dabd Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Tue, 1 Oct 2024 23:02:55 -0700 Subject: [PATCH 68/91] chore: dart format --- .../lib/src/screens/authenticator_screen.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart index fd99bc74ba..e405a6a812 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart @@ -48,8 +48,9 @@ class AuthenticatorScreen extends StatelessAuthenticatorComponent { const AuthenticatorScreen.continueSignInWithMfaSetupSelection({Key? key}) : this( - key: key, - step: AuthenticatorStep.continueSignInWithMfaSetupSelection,); + key: key, + step: AuthenticatorStep.continueSignInWithMfaSetupSelection, + ); const AuthenticatorScreen.resetPassword({Key? key}) : this(key: key, step: AuthenticatorStep.resetPassword); From dd769423b1d5f611f008416577771f3a02b39616 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 11 Oct 2024 09:08:21 -0700 Subject: [PATCH 69/91] chore: doc fixes --- packages/amplify_core/doc/lib/auth.dart | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/packages/amplify_core/doc/lib/auth.dart b/packages/amplify_core/doc/lib/auth.dart index 5573052fba..d2bd9da534 100644 --- a/packages/amplify_core/doc/lib/auth.dart +++ b/packages/amplify_core/doc/lib/auth.dart @@ -118,11 +118,11 @@ Future _handleSignInResult(SignInResult result) async { case AuthSignInStep.continueSignInWithMfaSetupSelection: final allowedMfaTypes = result.nextStep.allowedMfaTypes!; if (allowedMfaTypes.length == 1) { - return _handleMfaSetupSelection(allowedMfaTypes.first); + return _handleMfaSelection(allowedMfaTypes.first); } final selection = await _promptUserPreference(allowedMfaTypes); safePrint('Selected MFA type: $selection'); - return _handleMfaSetupSelection(selection); + return _handleMfaSelection(selection); // #enddocregion handle-confirm-signin-mfa-setup-selection // #docregion handle-confirm-signin-totp-setup case AuthSignInStep.continueSignInWithTotpSetup: @@ -132,7 +132,7 @@ Future _handleSignInResult(SignInResult result) async { // #enddocregion handle-confirm-signin-totp-setup // #docregion handle-confirm-signin-email-setup case AuthSignInStep.continueSignInWithEmailMfaSetup: - safePrint('A confirmation code has been sent to your email'); + safePrint('Enter the email address you want to use for two-factor authentication'); // #enddocregion handle-confirm-signin-email-setup // #docregion handle-confirm-signin-totp-code case AuthSignInStep.confirmSignInWithTotpMfaCode: @@ -255,19 +255,6 @@ Future _handleMfaSelection(MfaType selection) async { } // #enddocregion handle-mfa-selection -// #docregion handle-mfa-setup-selection -Future _handleMfaSetupSelection(MfaType selection) async { - try { - final result = await Amplify.Auth.confirmSignIn( - confirmationValue: selection.confirmationValue, - ); - return _handleSignInResult(result); - } on AuthException catch (e) { - safePrint('Error selecting MFA method: ${e.message}'); - } -} -// #enddocregion handle-mfa-setup-selection - // #docregion signout Future signOutCurrentUser() async { final result = await Amplify.Auth.signOut(); From d602beffa9942964dbbec4bf9f4864d27f709fc4 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 11 Oct 2024 10:02:05 -0700 Subject: [PATCH 70/91] chore: fixed else statement circular loop --- .../lib/src/blocs/auth/auth_bloc.dart | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart index 41dcfe410e..2e879f38af 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart @@ -370,10 +370,9 @@ class StateMachineBloc ); } } else { - _emit( - ContinueSignInWithMfaSetupSelection( - allowedMfaTypes: result.nextStep.allowedMfaTypes, - ), + throw const InvalidUserPoolConfigurationException( + 'Allowed MFA types are null', + recoverySuggestion: 'Check your user pool MFA configuration.', ); } case AuthSignInStep.continueSignInWithTotpSetup: From e98a31c95cff8d2d3a04a4b9cb1624923e18d80b Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 11 Oct 2024 10:08:34 -0700 Subject: [PATCH 71/91] chore: dart format --- packages/amplify_core/doc/lib/auth.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/amplify_core/doc/lib/auth.dart b/packages/amplify_core/doc/lib/auth.dart index d2bd9da534..5480d2aa1e 100644 --- a/packages/amplify_core/doc/lib/auth.dart +++ b/packages/amplify_core/doc/lib/auth.dart @@ -132,7 +132,8 @@ Future _handleSignInResult(SignInResult result) async { // #enddocregion handle-confirm-signin-totp-setup // #docregion handle-confirm-signin-email-setup case AuthSignInStep.continueSignInWithEmailMfaSetup: - safePrint('Enter the email address you want to use for two-factor authentication'); + safePrint( + 'Enter the email address you want to use for two-factor authentication'); // #enddocregion handle-confirm-signin-email-setup // #docregion handle-confirm-signin-totp-code case AuthSignInStep.confirmSignInWithTotpMfaCode: From d7ebd261b33748b3518c9eb5aabd43e30be1e51f Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 11 Oct 2024 10:08:57 -0700 Subject: [PATCH 72/91] chore: dart format authenticator --- .../lib/src/blocs/auth/auth_bloc.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart index 2e879f38af..d0cbff9fe8 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart @@ -350,10 +350,12 @@ class StateMachineBloc result.nextStep.totpSetupDetails != null, 'Sign In Result should have totpSetupDetails', ); - _emit(await ContinueSignInTotpSetup.setupURI( - result.nextStep.totpSetupDetails!, - totpOptions, - ),); + _emit( + await ContinueSignInTotpSetup.setupURI( + result.nextStep.totpSetupDetails!, + totpOptions, + ), + ); } else if (mfaType == MfaType.email) { _emit(UnauthenticatedState.continueSignInWithEmailMfaSetup); } else { From aad98830d60b5e744c95cbcf3f136dd7c53a8d0f Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 11 Oct 2024 10:14:35 -0700 Subject: [PATCH 73/91] chore: add trailing comma --- packages/amplify_core/doc/lib/auth.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/amplify_core/doc/lib/auth.dart b/packages/amplify_core/doc/lib/auth.dart index 5480d2aa1e..cdd3b872c5 100644 --- a/packages/amplify_core/doc/lib/auth.dart +++ b/packages/amplify_core/doc/lib/auth.dart @@ -133,7 +133,7 @@ Future _handleSignInResult(SignInResult result) async { // #docregion handle-confirm-signin-email-setup case AuthSignInStep.continueSignInWithEmailMfaSetup: safePrint( - 'Enter the email address you want to use for two-factor authentication'); + 'Enter the email address you want to use for two-factor authentication',); // #enddocregion handle-confirm-signin-email-setup // #docregion handle-confirm-signin-totp-code case AuthSignInStep.confirmSignInWithTotpMfaCode: From 9d9abe864efea05e1b7f0a3fcc991160ecca27cf Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 11 Oct 2024 10:35:36 -0700 Subject: [PATCH 74/91] chore: dart format --- packages/amplify_core/doc/lib/auth.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/amplify_core/doc/lib/auth.dart b/packages/amplify_core/doc/lib/auth.dart index cdd3b872c5..79cc4e0858 100644 --- a/packages/amplify_core/doc/lib/auth.dart +++ b/packages/amplify_core/doc/lib/auth.dart @@ -133,7 +133,8 @@ Future _handleSignInResult(SignInResult result) async { // #docregion handle-confirm-signin-email-setup case AuthSignInStep.continueSignInWithEmailMfaSetup: safePrint( - 'Enter the email address you want to use for two-factor authentication',); + 'Enter the email address you want to use for two-factor authentication', + ); // #enddocregion handle-confirm-signin-email-setup // #docregion handle-confirm-signin-totp-code case AuthSignInStep.confirmSignInWithTotpMfaCode: From 0641f334b0e26e5a5214255139d6c566ac113f1b Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Tue, 8 Oct 2024 21:21:52 -0700 Subject: [PATCH 75/91] temp state machine changes --- .../lib/src/auth_plugin_impl.dart | 83 +++++++------ .../lib/src/flows/constants.dart | 3 + .../state/machines/sign_in_state_machine.dart | 117 ++++++++++++++---- .../lib/src/blocs/auth/auth_bloc.dart | 2 + .../amplify_authenticator/lib/src/keys.dart | 2 + .../lib/src/state/authenticator_state.dart | 23 ++++ .../lib/src/widgets/button.dart | 21 ++++ .../lib/src/widgets/form.dart | 2 +- 8 files changed, 191 insertions(+), 62 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart index 02b5a8e2df..8ccd19262a 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart @@ -481,45 +481,54 @@ class AmplifyAuthCognitoDart extends AuthPluginInterface } CognitoSignInResult _processSignInResult(SignInState result) { - return switch (result) { - SignInNotStarted _ || - SignInInitiating _ => - // This should never happen. - throw UnknownException( - 'Sign in could not be completed', - underlyingException: result, - ), - SignInCancelling _ => throw const UserCancelledException( - 'The user canceled the sign-in flow', - ), - SignInChallenge( - :final challengeName, - :final challengeParameters, - :final codeDeliveryDetails, - :final requiredAttributes, - :final allowedMfaTypes, - :final totpSetupResult, - ) => - CognitoSignInResult( - isSignedIn: false, - nextStep: AuthNextSignInStep( - signInStep: challengeName.signInStep, - codeDeliveryDetails: codeDeliveryDetails, - additionalInfo: challengeParameters, - missingAttributes: requiredAttributes, - allowedMfaTypes: allowedMfaTypes, - totpSetupDetails: totpSetupResult, - ), + switch (result) { + case SignInNotStarted(): + case SignInInitiating(): + // This should never happen. + throw UnknownException( + 'Sign in could not be completed', + underlyingException: result, + ); + + case SignInCancelling(): + throw const UserCancelledException( + 'The user canceled the sign-in flow', + ); + + case final SignInChallenge challenge: + // Print all properties of SignInChallenge + safePrint('Challenge name: ${challenge.challengeName}'); + safePrint('Sign in Step: ${challenge.challengeName.signInStep}'); + safePrint('Challenge parameters: ${challenge.challengeParameters}'); + safePrint('Code delivery details: ${challenge.codeDeliveryDetails}'); + safePrint('Required attributes: ${challenge.requiredAttributes}'); + safePrint('Allowed MFA types: ${challenge.allowedMfaTypes}'); + safePrint('TOTP setup result: ${challenge.totpSetupResult}'); + + return CognitoSignInResult( + isSignedIn: false, + nextStep: AuthNextSignInStep( + signInStep: challenge.challengeName.signInStep, + codeDeliveryDetails: challenge.codeDeliveryDetails, + additionalInfo: challenge.challengeParameters, + missingAttributes: challenge.requiredAttributes, + allowedMfaTypes: challenge.allowedMfaTypes, + totpSetupDetails: challenge.totpSetupResult, ), - SignInSuccess _ => const CognitoSignInResult( - isSignedIn: true, - nextStep: AuthNextSignInStep( - signInStep: AuthSignInStep.done, - ), + ); + + case SignInSuccess(): + return const CognitoSignInResult( + isSignedIn: true, + nextStep: AuthNextSignInStep( + signInStep: AuthSignInStep.done, ), - SignInFailure(:final exception, :final stackTrace) => - Error.throwWithStackTrace(exception, stackTrace), - }; + ); + + case final SignInFailure failure: + Error.throwWithStackTrace(failure.exception, failure.stackTrace); +// To satisfy Dart's requirements, even if unreachable + } } @override diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart index 7a40ff446c..361ac6ccb8 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart @@ -11,6 +11,9 @@ abstract class CognitoConstants { /// The `USERNAME` parameter. static const challengeParamUsername = 'USERNAME'; + /// The `EMAIL` parameter. + static const challengeParamEmail = 'EMAIL'; + /// The `SRP_A` parameter. static const challengeParamSrpA = 'SRP_A'; diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart index 725f66b9d1..3858159fd7 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart @@ -667,38 +667,65 @@ final class SignInStateMachine ); } - if (mfaTypesForSetup.length == 1) { - final mfaType = mfaTypesForSetup.first; - if (mfaType == MfaType.totp) { - _enableMfaType = MfaType.totp; - _totpSetupResult ??= await associateSoftwareToken(); - if (hasUserResponse) { - return createMfaSetupRequest(event as SignInRespondToChallenge); - } else { - // Need to prompt user for the TOTP code - return null; + // if (mfaTypesForSetup.length == 1) { + // // Only one MFA type is allowed for setup + // _enableMfaType = mfaTypesForSetup.first; + // if (_enableMfaType == MfaType.totp) { + // _totpSetupResult = await associateSoftwareToken(); + // return createMfaSetupRequest(event as SignInRespondToChallenge); + // } else if (_enableMfaType == MfaType.email) { + // return createEmailMfaSetupRequest(event as SignInRespondToChallenge); + // } + // } + + if (hasUserResponse) { + if (_enableMfaType == null) { + // User has just selected the MFA type + if (event == null) { + throw StateError('Event cannot be null when there is user response.'); + } + if (event is! SignInRespondToChallenge) { + throw StateError('Expected SignInRespondToChallenge event.'); } - } else if (mfaType == MfaType.email) { - _enableMfaType = MfaType.email; - if (hasUserResponse) { - return createEmailMfaSetupRequest(event as SignInRespondToChallenge); - } else { - // Need to prompt user for the email verification code + final selection = event.answer.toLowerCase(); + _enableMfaType = switch (selection) { + 'totp' => MfaType.totp, + 'email' => MfaType.email, + _ => + throw const InvalidParameterException('Invalid MFA type selected'), + }; + + if (_enableMfaType == MfaType.totp) { + final challengeResponses = { + CognitoConstants.challengeParamMfasCanSetup: + '["SOFTWARE_TOKEN_MFA"]', + }; + final builtMap = BuiltMap(challengeResponses); + _challengeParameters = builtMap; + // await _processChallenge(event); return null; + } else if (_enableMfaType == MfaType.email) { + await _processChallenge(event); } } else { - throw InvalidUserPoolConfigurationException( - 'Unsupported MFA type: ${mfaType.name}', - recoverySuggestion: 'Check your user pool MFA configuration.', - ); + // User has provided the verification code + if (event == null) { + throw StateError('Event cannot be null when there is user response.'); + } + if (event is! SignInRespondToChallenge) { + throw StateError('Expected SignInRespondToChallenge event.'); + } + if (_enableMfaType == MfaType.totp) { + return createMfaSetupRequest(event); + } else if (_enableMfaType == MfaType.email) { + return createEmailMfaSetupRequest(event); + } } - } else if (hasUserResponse) { - // Handle user's selection - return createMfaSetupRequest(event as SignInRespondToChallenge); } else { // Need to prompt user to select an MFA type return null; } + return null; } /// Completes set up of a TOTP MFA. @@ -988,6 +1015,9 @@ final class SignInStateMachine Future _processChallenge([SignInEvent? event]) async { // There can be an indefinite amount of challenges which need responses. // Only when authenticationResult is set is the flow considered complete. + if (event is SignInRespondToChallenge) { + safePrint('EVENT ANSWER: ${event.answer}'); + } final authenticationResult = _authenticationResult; if (authenticationResult != null) { final accessToken = await _saveAuthResult(authenticationResult); @@ -1042,6 +1072,14 @@ final class SignInStateMachine return SignInState.success(_user.build().authUser); } + if (event is SignInRespondToChallenge && event.answer == 'totp') { + safePrint('TOTP ANSWER: ${event.answer}'); + _challengeParameters = BuiltMap({ + CognitoConstants.challengeParamMfasCanSetup: '["SOFTWARE_TOKEN_MFA"]', + }); + return _processChallenge(); + } + await _updateUser(_challengeParameters); // Configure TOTP authentication if allowed. @@ -1055,9 +1093,40 @@ final class SignInStateMachine 'Contact an administrator to enable SMS MFA or allow TOTP MFA', ); } - _totpSetupResult ??= await associateSoftwareToken(); + final allowedMfaTypes1 = [...?_allowedMfaTypes]; + allowedMfaTypes1.remove(MfaType.sms); + if (allowedMfaTypes1.length == 1) { + if (allowedMfaTypes1.first == MfaType.totp) { + // If TOTP is the only MFA type allowed, automatically set it up. + _totpSetupResult ??= await associateSoftwareToken(); + } else if (allowedMfaTypes1.first == MfaType.email) { + _enableMfaType = MfaType.email; + } + } + // _totpSetupResult ??= await associateSoftwareToken(); } + // safePrint('_authenticationResult: $_authenticationResult'); + // safePrint('----------------------------------------'); + + // safePrint('_challengeName: $_challengeName'); + // safePrint('----------------------------------------'); + + // safePrint('_challengeParameters: $_challengeParameters'); + // safePrint('----------------------------------------'); + + // safePrint('_session: $_session'); + // safePrint('----------------------------------------'); + + // safePrint('_attributesNeedingUpdate: $_attributesNeedingUpdate'); + // safePrint('----------------------------------------'); + + // safePrint('_totpSetupResult: $_totpSetupResult'); + // safePrint('----------------------------------------'); + + // safePrint('_enableMfaType: $_enableMfaType'); + // safePrint('----------------------------------------'); + // Query the state machine for a response given potential user input in // `event`. final respondRequest = await createRespondToAuthChallengeRequest( diff --git a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart index 41dcfe410e..e0568dc897 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart @@ -246,6 +246,8 @@ class StateMachineBloc result.nextStep.totpSetupDetails!, totpOptions, ); + case AuthSignInStep.continueSignInWithEmailMfaSetup: + yield UnauthenticatedState.continueSignInWithEmailMfaSetup; case AuthSignInStep.resetPassword: yield UnauthenticatedState.resetPassword; case AuthSignInStep.confirmSignUp: diff --git a/packages/authenticator/amplify_authenticator/lib/src/keys.dart b/packages/authenticator/amplify_authenticator/lib/src/keys.dart index 2f0665814e..8cb32f3fba 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/keys.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/keys.dart @@ -109,6 +109,8 @@ const keyGoToSignInButton = Key('goToSignInButton'); const keyConfirmSignInButton = Key('confirmSignInButton'); const keyConfirmSignInMfaSelectionButton = Key('confirmSignInMfaSelectionButton'); +const keyConfirmSignInMfaSetupSelectionButton = + Key('confirmSignInMfaSetupSelectionButton'); const keyConfirmSignInCustomButton = Key('confirmSignInCustomButton'); const keyLostCodeButton = Key('lostCodeButton'); const keySendCodeButton = Key('sendCodeButton'); diff --git a/packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart b/packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart index bf434aba5c..45145d6084 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart @@ -407,6 +407,29 @@ class AuthenticatorState extends ChangeNotifier { _setIsBusy(false); } + /// Select MFA setup preference using the values for [selectedMfaMethod] + Future continueSignInWithMfaSetupSelection() async { + if (!_formKey.currentState!.validate()) { + return; + } + + _setIsBusy(true); + + final confirm = AuthConfirmSignInData( + confirmationValue: _selectedMfaMethod!.name, + ); + + // if (_selectedMfaMethod == MfaType.totp) { + // _authBloc.add(const AuthChangeScreen(AuthenticatorStep.continueSignInWithTotpSetup)); + // } else { + // _authBloc.add(AuthConfirmSignIn(confirm)); + // } + + _authBloc.add(AuthConfirmSignIn(confirm)); + await nextBlocEvent(); + _setIsBusy(false); + } + /// Complete TOTP setup using the values for [confirmationCode] /// and any user attributes. Future confirmTotp() async { diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/button.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/button.dart index c2c92e87bb..de0ea61761 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/widgets/button.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/button.dart @@ -253,6 +253,27 @@ class ContinueSignInMFASelectionButton extends AuthenticatorElevatedButton { state.continueSignInWithMfaSelection(); } +/// {@category Prebuilt Widgets} +/// {@template amplify_authenticator.continue_sign_in_mfa_setup_selection_button} +/// A prebuilt button for Sign In with MFA setup selection. +/// +/// Uses [ButtonResolverKey.confirm] for localization +/// {@endtemplate} +class ContinueSignInMFASetupSelectionButton extends AuthenticatorElevatedButton { + /// {@macro amplify_authenticator.continue_sign_in_mfa_setup_selection_button} + const ContinueSignInMFASetupSelectionButton({Key? key}) + : super( + key: key ?? keyConfirmSignInMfaSetupSelectionButton, + ); + + @override + ButtonResolverKey get labelKey => ButtonResolverKey.continueLabel; + + @override + void onPressed(BuildContext context, AuthenticatorState state) => + state.continueSignInWithMfaSetupSelection(); +} + /// {@category Prebuilt Widgets} /// {@template amplify_authenticator.confirm_sign_in_mfa_button} /// A prebuilt button for completing Sign In with and MFA code. diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart index c79d308f84..812a89c6ab 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart @@ -636,7 +636,7 @@ class ContinueSignInWithMfaSetupSelectionForm extends AuthenticatorForm { ConfirmSignInFormField.mfaSetupSelection(), ], actions: const [ - ContinueSignInMFASelectionButton(), + ContinueSignInMFASetupSelectionButton(), BackToSignInButton(), ], ); From d7dc6bc3f63c1315684a685ab76c7545e442fe3f Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Thu, 10 Oct 2024 22:14:21 -0700 Subject: [PATCH 76/91] chore: fix inherited_forms steps --- .../amplify_authenticator/lib/src/state/inherited_forms.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart b/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart index 121f81bd0d..2b75184038 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/state/inherited_forms.dart @@ -122,8 +122,8 @@ class InheritedForms extends InheritedWidget { confirmSignInWithEmailMfaCodeForm || oldWidget.continueSignInWithEmailMfaSetupForm != continueSignInWithEmailMfaSetupForm || - oldWidget.continueSignInWithMfaSelectionForm != - continueSignInWithMfaSelectionForm; + oldWidget.continueSignInWithMfaSetupSelectionForm != + continueSignInWithMfaSetupSelectionForm; } } From 2cd215bd0177806b20dccab0f39fc57b19b8df30 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 11 Oct 2024 00:01:42 -0700 Subject: [PATCH 77/91] chore: adjust continue sign in with email mfa setup form --- .../amplify_authenticator/lib/src/keys.dart | 2 ++ .../lib/src/state/authenticator_state.dart | 7 +----- .../lib/src/widgets/button.dart | 23 ++++++++++++++++++- .../lib/src/widgets/form.dart | 2 +- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/keys.dart b/packages/authenticator/amplify_authenticator/lib/src/keys.dart index 8cb32f3fba..2ad76b7c01 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/keys.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/keys.dart @@ -111,6 +111,8 @@ const keyConfirmSignInMfaSelectionButton = Key('confirmSignInMfaSelectionButton'); const keyConfirmSignInMfaSetupSelectionButton = Key('confirmSignInMfaSetupSelectionButton'); +const keyConfirmSignInWithEmailMfaSetupButton = + Key('confirmSignInWithEmailMfaSetupButton'); const keyConfirmSignInCustomButton = Key('confirmSignInCustomButton'); const keyLostCodeButton = Key('lostCodeButton'); const keySendCodeButton = Key('sendCodeButton'); diff --git a/packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart b/packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart index 45145d6084..836c4f1a01 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/state/authenticator_state.dart @@ -419,12 +419,6 @@ class AuthenticatorState extends ChangeNotifier { confirmationValue: _selectedMfaMethod!.name, ); - // if (_selectedMfaMethod == MfaType.totp) { - // _authBloc.add(const AuthChangeScreen(AuthenticatorStep.continueSignInWithTotpSetup)); - // } else { - // _authBloc.add(AuthConfirmSignIn(confirm)); - // } - _authBloc.add(AuthConfirmSignIn(confirm)); await nextBlocEvent(); _setIsBusy(false); @@ -713,6 +707,7 @@ class AuthenticatorState extends ChangeNotifier { authAttributes.clear(); _publicChallengeParams.clear(); _selectedMfaMethod = null; + _mfaEmail = ''; } void _resetFormKey() { diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/button.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/button.dart index de0ea61761..a288a9e2e3 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/widgets/button.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/button.dart @@ -257,7 +257,7 @@ class ContinueSignInMFASelectionButton extends AuthenticatorElevatedButton { /// {@template amplify_authenticator.continue_sign_in_mfa_setup_selection_button} /// A prebuilt button for Sign In with MFA setup selection. /// -/// Uses [ButtonResolverKey.confirm] for localization +/// Uses [ButtonResolverKey.continueLabel] for localization /// {@endtemplate} class ContinueSignInMFASetupSelectionButton extends AuthenticatorElevatedButton { /// {@macro amplify_authenticator.continue_sign_in_mfa_setup_selection_button} @@ -274,6 +274,27 @@ class ContinueSignInMFASetupSelectionButton extends AuthenticatorElevatedButton state.continueSignInWithMfaSetupSelection(); } +/// {@category Prebuilt Widgets} +/// {@template amplify_authenticator.continue_sign_in_with_email_mfa_setup_button} +/// A prebuilt button for Sign In with Email MFA setup. +/// +/// Uses [ButtonResolverKey.continueLabel] for localization +/// {@endtemplate} +class ContinueSignInWithEmailMfaSetupButton extends AuthenticatorElevatedButton { + /// {@macro amplify_authenticator.continue_sign_in_with_email_mfa_setup_button} + const ContinueSignInWithEmailMfaSetupButton({Key? key}) + : super( + key: key ?? keyConfirmSignInWithEmailMfaSetupButton, + ); + + @override + ButtonResolverKey get labelKey => ButtonResolverKey.continueLabel; + + @override + void onPressed(BuildContext context, AuthenticatorState state) => + state.continueEmailMfaSetup(); +} + /// {@category Prebuilt Widgets} /// {@template amplify_authenticator.confirm_sign_in_mfa_button} /// A prebuilt button for completing Sign In with and MFA code. diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart index 812a89c6ab..b8a7bd15b1 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/form.dart @@ -682,7 +682,7 @@ class ContinueSignInWithEmailMfaSetupForm extends AuthenticatorForm { EmailSetupFormField.email(), ], actions: const [ - ConfirmSignInMFAButton(), + ContinueSignInWithEmailMfaSetupButton(), BackToSignInButton(), ], ); From 495ff1e14fca974b3dacbe3a9025762642962b32 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 11 Oct 2024 00:02:10 -0700 Subject: [PATCH 78/91] chore: refactor large nested if statement blocks in state machine --- .../state/machines/sign_in_state_machine.dart | 147 +++++------------- 1 file changed, 41 insertions(+), 106 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart index 3858159fd7..55ea5cd602 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart @@ -667,67 +667,43 @@ final class SignInStateMachine ); } - // if (mfaTypesForSetup.length == 1) { - // // Only one MFA type is allowed for setup - // _enableMfaType = mfaTypesForSetup.first; - // if (_enableMfaType == MfaType.totp) { - // _totpSetupResult = await associateSoftwareToken(); - // return createMfaSetupRequest(event as SignInRespondToChallenge); - // } else if (_enableMfaType == MfaType.email) { - // return createEmailMfaSetupRequest(event as SignInRespondToChallenge); - // } - // } - - if (hasUserResponse) { - if (_enableMfaType == null) { - // User has just selected the MFA type - if (event == null) { - throw StateError('Event cannot be null when there is user response.'); - } - if (event is! SignInRespondToChallenge) { - throw StateError('Expected SignInRespondToChallenge event.'); - } - final selection = event.answer.toLowerCase(); - _enableMfaType = switch (selection) { - 'totp' => MfaType.totp, - 'email' => MfaType.email, - _ => - throw const InvalidParameterException('Invalid MFA type selected'), - }; - - if (_enableMfaType == MfaType.totp) { - final challengeResponses = { - CognitoConstants.challengeParamMfasCanSetup: - '["SOFTWARE_TOKEN_MFA"]', - }; - final builtMap = BuiltMap(challengeResponses); - _challengeParameters = builtMap; - // await _processChallenge(event); - return null; - } else if (_enableMfaType == MfaType.email) { - await _processChallenge(event); - } - } else { - // User has provided the verification code - if (event == null) { - throw StateError('Event cannot be null when there is user response.'); - } - if (event is! SignInRespondToChallenge) { - throw StateError('Expected SignInRespondToChallenge event.'); - } - if (_enableMfaType == MfaType.totp) { - return createMfaSetupRequest(event); - } else if (_enableMfaType == MfaType.email) { - return createEmailMfaSetupRequest(event); - } - } - } else { - // Need to prompt user to select an MFA type - return null; - } + if (!hasUserResponse) { + // Need to prompt user to select an MFA type + return null; + } + + if (event == null) { + throw StateError('Event cannot be null when there is user response.'); + } + if (event is! SignInRespondToChallenge) { + throw StateError('Expected SignInRespondToChallenge event.'); + } + + if (_enableMfaType == null) { + // User has just selected the MFA type + final selection = event.answer.toLowerCase(); + _enableMfaType = switch (selection) { + 'totp' => MfaType.totp, + 'email' => MfaType.email, + _ => throw const InvalidParameterException('Invalid MFA type selected'), + }; + + final challengeResponses = { + CognitoConstants.challengeParamMfasCanSetup: _enableMfaType == MfaType.totp + ? '["SOFTWARE_TOKEN_MFA"]' + : '["EMAIL_OTP"]', + }; + _challengeParameters = BuiltMap(challengeResponses); + await _processChallenge(); return null; } + // User has provided the verification code + return _enableMfaType == MfaType.totp + ? createMfaSetupRequest(event) + : createEmailMfaSetupRequest(event); + } + /// Completes set up of a TOTP MFA. @protected Future createMfaSetupRequest( @@ -759,10 +735,10 @@ final class SignInStateMachine _enableMfaType = MfaType.email; return RespondToAuthChallengeRequest.build((b) { b - ..challengeName = ChallengeNameType.emailOtp + ..challengeName = ChallengeNameType.mfaSetup ..challengeResponses.addAll({ CognitoConstants.challengeParamUsername: cognitoUsername, - CognitoConstants.challengeParamEmailMfaCode: event.answer, + CognitoConstants.challengeParamEmail: event.answer, }) ..clientId = _authOutputs.userPoolClientId ..clientMetadata.addAll(event.clientMetadata); @@ -1015,9 +991,6 @@ final class SignInStateMachine Future _processChallenge([SignInEvent? event]) async { // There can be an indefinite amount of challenges which need responses. // Only when authenticationResult is set is the flow considered complete. - if (event is SignInRespondToChallenge) { - safePrint('EVENT ANSWER: ${event.answer}'); - } final authenticationResult = _authenticationResult; if (authenticationResult != null) { final accessToken = await _saveAuthResult(authenticationResult); @@ -1072,61 +1045,23 @@ final class SignInStateMachine return SignInState.success(_user.build().authUser); } - if (event is SignInRespondToChallenge && event.answer == 'totp') { - safePrint('TOTP ANSWER: ${event.answer}'); - _challengeParameters = BuiltMap({ - CognitoConstants.challengeParamMfasCanSetup: '["SOFTWARE_TOKEN_MFA"]', - }); - return _processChallenge(); - } - await _updateUser(_challengeParameters); // Configure TOTP authentication if allowed. if (_allowedMfaTypes case final allowedMfaTypes? when _challengeParameters .containsKey(CognitoConstants.challengeParamMfasCanSetup)) { - if (!allowedMfaTypes.contains(MfaType.totp)) { + if (!allowedMfaTypes.contains(MfaType.totp) && !allowedMfaTypes.contains(MfaType.email)) { throw const InvalidUserPoolConfigurationException( - 'Cannot enable SMS MFA and TOTP MFA is not allowed', + 'Cannot enable SMS MFA and TOTP or EMAIL MFA is not allowed', recoverySuggestion: - 'Contact an administrator to enable SMS MFA or allow TOTP MFA', + 'Contact an administrator to enable SMS MFA or allow TOTP or EMAIL MFA', ); } - final allowedMfaTypes1 = [...?_allowedMfaTypes]; - allowedMfaTypes1.remove(MfaType.sms); - if (allowedMfaTypes1.length == 1) { - if (allowedMfaTypes1.first == MfaType.totp) { - // If TOTP is the only MFA type allowed, automatically set it up. - _totpSetupResult ??= await associateSoftwareToken(); - } else if (allowedMfaTypes1.first == MfaType.email) { - _enableMfaType = MfaType.email; - } - } - // _totpSetupResult ??= await associateSoftwareToken(); + final allowedMfaSetupTypes = [...?_allowedMfaTypes]..remove(MfaType.sms); + if (allowedMfaSetupTypes.length == 1 && allowedMfaSetupTypes.first == MfaType.totp) _totpSetupResult = await associateSoftwareToken(accessToken: _session); } - // safePrint('_authenticationResult: $_authenticationResult'); - // safePrint('----------------------------------------'); - - // safePrint('_challengeName: $_challengeName'); - // safePrint('----------------------------------------'); - - // safePrint('_challengeParameters: $_challengeParameters'); - // safePrint('----------------------------------------'); - - // safePrint('_session: $_session'); - // safePrint('----------------------------------------'); - - // safePrint('_attributesNeedingUpdate: $_attributesNeedingUpdate'); - // safePrint('----------------------------------------'); - - // safePrint('_totpSetupResult: $_totpSetupResult'); - // safePrint('----------------------------------------'); - - // safePrint('_enableMfaType: $_enableMfaType'); - // safePrint('----------------------------------------'); - // Query the state machine for a response given potential user input in // `event`. final respondRequest = await createRespondToAuthChallengeRequest( From e1bf813f39ecb73023b23513494020a4409ad14c Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Fri, 11 Oct 2024 00:08:51 -0700 Subject: [PATCH 79/91] chore: auth_bloc refactor to separate logic into a helper function and simplify the code --- .../lib/src/blocs/auth/auth_bloc.dart | 94 +++++++++---------- 1 file changed, 44 insertions(+), 50 deletions(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart index e0568dc897..bfb49dbbc5 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart @@ -234,9 +234,7 @@ class StateMachineBloc allowedMfaTypes: result.nextStep.allowedMfaTypes, ); case AuthSignInStep.continueSignInWithMfaSetupSelection: - yield ContinueSignInWithMfaSetupSelection( - allowedMfaTypes: result.nextStep.allowedMfaTypes, - ); + await _handleMfaSetupSelection(result); case AuthSignInStep.continueSignInWithTotpSetup: assert( result.nextStep.totpSetupDetails != null, @@ -342,53 +340,7 @@ class StateMachineBloc ), ); case AuthSignInStep.continueSignInWithMfaSetupSelection: - final allowedMfaTypes = result.nextStep.allowedMfaTypes; - if (allowedMfaTypes != null) { - final mfaTypesForSetup = allowedMfaTypes.toSet()..remove(MfaType.sms); - if (mfaTypesForSetup.length == 1) { - final mfaType = mfaTypesForSetup.first; - if (mfaType == MfaType.totp) { - assert( - result.nextStep.totpSetupDetails != null, - 'Sign In Result should have totpSetupDetails', - ); - _emit(await ContinueSignInTotpSetup.setupURI( - result.nextStep.totpSetupDetails!, - totpOptions, - ),); - } else if (mfaType == MfaType.email) { - _emit(UnauthenticatedState.continueSignInWithEmailMfaSetup); - } else { - throw InvalidUserPoolConfigurationException( - 'Unsupported MFA type: ${mfaType.name}', - recoverySuggestion: 'Check your user pool MFA configuration.', - ); - } - } else { - _emit( - ContinueSignInWithMfaSetupSelection( - allowedMfaTypes: result.nextStep.allowedMfaTypes, - ), - ); - } - } else { - _emit( - ContinueSignInWithMfaSetupSelection( - allowedMfaTypes: result.nextStep.allowedMfaTypes, - ), - ); - } - case AuthSignInStep.continueSignInWithTotpSetup: - assert( - result.nextStep.totpSetupDetails != null, - 'Sign In Result should have totpSetupDetails', - ); - _emit( - await ContinueSignInTotpSetup.setupURI( - result.nextStep.totpSetupDetails!, - totpOptions, - ), - ); + await _handleMfaSetupSelection(result); case AuthSignInStep.continueSignInWithEmailMfaSetup: _emit(UnauthenticatedState.continueSignInWithEmailMfaSetup); case AuthSignInStep.confirmSignInWithTotpMfaCode: @@ -591,6 +543,48 @@ class StateMachineBloc yield* const Stream.empty(); } +Future _handleMfaSetupSelection(SignInResult result) async { + final allowedMfaTypes = result.nextStep.allowedMfaTypes; + if (allowedMfaTypes != null) { + final mfaTypesForSetup = allowedMfaTypes.toSet()..remove(MfaType.sms); + if (mfaTypesForSetup.length == 1) { + final mfaType = mfaTypesForSetup.first; + if (mfaType == MfaType.totp) { + assert( + result.nextStep.totpSetupDetails != null, + 'Sign In Result should have totpSetupDetails', + ); + _emit( + await ContinueSignInTotpSetup.setupURI( + result.nextStep.totpSetupDetails!, + totpOptions, + ), + ); + } else if (mfaType == MfaType.email) { + _emit(UnauthenticatedState.continueSignInWithEmailMfaSetup); + } else { + throw InvalidUserPoolConfigurationException( + 'Unsupported MFA type: ${mfaType.name}', + recoverySuggestion: 'Check your user pool MFA configuration.', + ); + } + } else { + _emit( + ContinueSignInWithMfaSetupSelection( + allowedMfaTypes: result.nextStep.allowedMfaTypes, + ), + ); + } + } else { + _emit( + ContinueSignInWithMfaSetupSelection( + allowedMfaTypes: result.nextStep.allowedMfaTypes, + ), + ); + } +} + + @override Future close() async { await Future.wait([ From cd610eac7d13eebc01d5ef056610a4b11e0f5c54 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Mon, 14 Oct 2024 10:54:40 -0700 Subject: [PATCH 80/91] chore: fix the email setup form field --- .../lib/src/blocs/auth/auth_bloc.dart | 57 +++++++------- .../lib/src/widgets/button.dart | 8 +- .../form_fields/email_setup_form_field.dart | 74 ++++++++----------- 3 files changed, 62 insertions(+), 77 deletions(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart index bfb49dbbc5..6bf58c0493 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart @@ -543,30 +543,37 @@ class StateMachineBloc yield* const Stream.empty(); } -Future _handleMfaSetupSelection(SignInResult result) async { - final allowedMfaTypes = result.nextStep.allowedMfaTypes; - if (allowedMfaTypes != null) { - final mfaTypesForSetup = allowedMfaTypes.toSet()..remove(MfaType.sms); - if (mfaTypesForSetup.length == 1) { - final mfaType = mfaTypesForSetup.first; - if (mfaType == MfaType.totp) { - assert( - result.nextStep.totpSetupDetails != null, - 'Sign In Result should have totpSetupDetails', - ); + Future _handleMfaSetupSelection(SignInResult result) async { + final allowedMfaTypes = result.nextStep.allowedMfaTypes; + if (allowedMfaTypes != null) { + final mfaTypesForSetup = allowedMfaTypes.toSet()..remove(MfaType.sms); + if (mfaTypesForSetup.length == 1) { + final mfaType = mfaTypesForSetup.first; + if (mfaType == MfaType.totp) { + assert( + result.nextStep.totpSetupDetails != null, + 'Sign In Result should have totpSetupDetails', + ); + _emit( + await ContinueSignInTotpSetup.setupURI( + result.nextStep.totpSetupDetails!, + totpOptions, + ), + ); + } else if (mfaType == MfaType.email) { + _emit(UnauthenticatedState.continueSignInWithEmailMfaSetup); + } else { + throw InvalidUserPoolConfigurationException( + 'Unsupported MFA type: ${mfaType.name}', + recoverySuggestion: 'Check your user pool MFA configuration.', + ); + } + } else { _emit( - await ContinueSignInTotpSetup.setupURI( - result.nextStep.totpSetupDetails!, - totpOptions, + ContinueSignInWithMfaSetupSelection( + allowedMfaTypes: result.nextStep.allowedMfaTypes, ), ); - } else if (mfaType == MfaType.email) { - _emit(UnauthenticatedState.continueSignInWithEmailMfaSetup); - } else { - throw InvalidUserPoolConfigurationException( - 'Unsupported MFA type: ${mfaType.name}', - recoverySuggestion: 'Check your user pool MFA configuration.', - ); } } else { _emit( @@ -575,15 +582,7 @@ Future _handleMfaSetupSelection(SignInResult result) async { ), ); } - } else { - _emit( - ContinueSignInWithMfaSetupSelection( - allowedMfaTypes: result.nextStep.allowedMfaTypes, - ), - ); } -} - @override Future close() async { diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/button.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/button.dart index a288a9e2e3..ccd43114da 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/widgets/button.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/button.dart @@ -259,7 +259,8 @@ class ContinueSignInMFASelectionButton extends AuthenticatorElevatedButton { /// /// Uses [ButtonResolverKey.continueLabel] for localization /// {@endtemplate} -class ContinueSignInMFASetupSelectionButton extends AuthenticatorElevatedButton { +class ContinueSignInMFASetupSelectionButton + extends AuthenticatorElevatedButton { /// {@macro amplify_authenticator.continue_sign_in_mfa_setup_selection_button} const ContinueSignInMFASetupSelectionButton({Key? key}) : super( @@ -277,10 +278,11 @@ class ContinueSignInMFASetupSelectionButton extends AuthenticatorElevatedButton /// {@category Prebuilt Widgets} /// {@template amplify_authenticator.continue_sign_in_with_email_mfa_setup_button} /// A prebuilt button for Sign In with Email MFA setup. -/// +/// /// Uses [ButtonResolverKey.continueLabel] for localization /// {@endtemplate} -class ContinueSignInWithEmailMfaSetupButton extends AuthenticatorElevatedButton { +class ContinueSignInWithEmailMfaSetupButton + extends AuthenticatorElevatedButton { /// {@macro amplify_authenticator.continue_sign_in_with_email_mfa_setup_button} const ContinueSignInWithEmailMfaSetupButton({Key? key}) : super( diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/email_setup_form_field.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/email_setup_form_field.dart index 47951cbe8f..9884b69122 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/email_setup_form_field.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_fields/email_setup_form_field.dart @@ -7,8 +7,8 @@ part of '../form_field.dart'; /// {@template amplify_authenticator.email_setup_form_field} /// A prebuilt form field widget for use on the Email MFA setup step. /// {@endtemplate} -abstract class EmailSetupFormField - extends AuthenticatorFormField { +class EmailSetupFormField + extends AuthenticatorFormField { /// {@macro amplify_authenticator.email_setup_form_field} /// /// Either [titleKey] or [title] is required. @@ -23,25 +23,30 @@ abstract class EmailSetupFormField super.autofillHints, }) : super._(); - /// Creates an email component. - static EmailSetupFormField email({ + /// Creates an email FormField for the email setup step. + const EmailSetupFormField.email({ Key? key, FormFieldValidator? validator, Iterable? autofillHints, - }) => - _EmailSetupTextField( - key: key ?? keyEmailSetupFormField, - titleKey: InputResolverKey.emailTitle, - hintTextKey: InputResolverKey.emailHint, - field: EmailSetupField.email, - validator: validator, - autofillHints: autofillHints, - ); + }) : this._( + key: key ?? keyEmailSetupFormField, + field: EmailSetupField.email, + titleKey: InputResolverKey.emailTitle, + hintTextKey: InputResolverKey.emailHint, + validator: validator, + autofillHints: autofillHints, + ); + + @override + bool get required => true; + + @override + AuthenticatorFormFieldState + createState() => _EmailSetupFormFieldState(); } -abstract class _EmailSetupFormFieldState - extends AuthenticatorFormFieldState> { +class _EmailSetupFormFieldState extends AuthenticatorFormFieldState< + EmailSetupField, String, EmailSetupFormField> with AuthenticatorTextField { @override TextInputType get keyboardType { return TextInputType.emailAddress; @@ -52,38 +57,17 @@ abstract class _EmailSetupFormFieldState return [AutofillHints.email]; } - bool get required { - switch (widget.field) { - case EmailSetupField.email: - return true; - } - } - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties.add(DiagnosticsProperty('required', required)); + ValueChanged get onChanged { + return (v) => state.mfaEmail = v; } -} - -class _EmailSetupTextField extends EmailSetupFormField { - const _EmailSetupTextField({ - super.key, - required super.field, - super.titleKey, - super.hintTextKey, - super.validator, - super.autofillHints, - }) : super._(); - - @override - _EmailSetupTextFieldState createState() => _EmailSetupTextFieldState(); -} -class _EmailSetupTextFieldState extends _EmailSetupFormFieldState - with AuthenticatorTextField { @override - bool get obscureText { - return false; + FormFieldValidator get validator { + return validateEmail( + isOptional: isOptional, + context: context, + inputResolver: stringResolver.inputs, + ); } } From 1d44a2ef9d23f75a4fa60134a5af5c2aaea4ea14 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Mon, 14 Oct 2024 15:31:23 -0700 Subject: [PATCH 81/91] chore: fix totp selection flow --- .../lib/src/state/machines/sign_in_state_machine.dart | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart index 55ea5cd602..bd3f16ad88 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart @@ -679,7 +679,7 @@ final class SignInStateMachine throw StateError('Expected SignInRespondToChallenge event.'); } - if (_enableMfaType == null) { + if (_enableMfaType == null && _totpSetupResult == null) { // User has just selected the MFA type final selection = event.answer.toLowerCase(); _enableMfaType = switch (selection) { @@ -698,6 +698,11 @@ final class SignInStateMachine return null; } + // totp mfa method was already selected + if (mfaTypesForSetup.length == 1 && mfaTypesForSetup.contains(MfaType.totp) && _totpSetupResult != null) { + createSoftwareTokenMfaRequest(event); + } + // User has provided the verification code return _enableMfaType == MfaType.totp ? createMfaSetupRequest(event) @@ -1059,7 +1064,7 @@ final class SignInStateMachine ); } final allowedMfaSetupTypes = [...?_allowedMfaTypes]..remove(MfaType.sms); - if (allowedMfaSetupTypes.length == 1 && allowedMfaSetupTypes.first == MfaType.totp) _totpSetupResult = await associateSoftwareToken(accessToken: _session); + if (allowedMfaSetupTypes.length == 1 && allowedMfaSetupTypes.first == MfaType.totp && _totpSetupResult == null) _totpSetupResult = await associateSoftwareToken(accessToken: _session); } // Query the state machine for a response given potential user input in From 02fb1a6b55783106906d7b48fb3829e25c6742e9 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:17:34 -0700 Subject: [PATCH 82/91] chore: remove safePrint --- .../lib/src/auth_plugin_impl.dart | 9 --------- 1 file changed, 9 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart index 8ccd19262a..24f8ba145c 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart @@ -496,15 +496,6 @@ class AmplifyAuthCognitoDart extends AuthPluginInterface ); case final SignInChallenge challenge: - // Print all properties of SignInChallenge - safePrint('Challenge name: ${challenge.challengeName}'); - safePrint('Sign in Step: ${challenge.challengeName.signInStep}'); - safePrint('Challenge parameters: ${challenge.challengeParameters}'); - safePrint('Code delivery details: ${challenge.codeDeliveryDetails}'); - safePrint('Required attributes: ${challenge.requiredAttributes}'); - safePrint('Allowed MFA types: ${challenge.allowedMfaTypes}'); - safePrint('TOTP setup result: ${challenge.totpSetupResult}'); - return CognitoSignInResult( isSignedIn: false, nextStep: AuthNextSignInStep( From 85368f16f1c956cf27ada88502d3f4cd18e40561 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:17:58 -0700 Subject: [PATCH 83/91] chore: dart format --- .../lib/src/auth_plugin_impl.dart | 66 +++++++-------- .../state/machines/sign_in_state_machine.dart | 83 ++++++++++--------- 2 files changed, 78 insertions(+), 71 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart index 24f8ba145c..e6a848919e 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/auth_plugin_impl.dart @@ -481,43 +481,43 @@ class AmplifyAuthCognitoDart extends AuthPluginInterface } CognitoSignInResult _processSignInResult(SignInState result) { - switch (result) { - case SignInNotStarted(): - case SignInInitiating(): - // This should never happen. - throw UnknownException( - 'Sign in could not be completed', - underlyingException: result, - ); + switch (result) { + case SignInNotStarted(): + case SignInInitiating(): + // This should never happen. + throw UnknownException( + 'Sign in could not be completed', + underlyingException: result, + ); - case SignInCancelling(): - throw const UserCancelledException( - 'The user canceled the sign-in flow', - ); + case SignInCancelling(): + throw const UserCancelledException( + 'The user canceled the sign-in flow', + ); - case final SignInChallenge challenge: - return CognitoSignInResult( - isSignedIn: false, - nextStep: AuthNextSignInStep( - signInStep: challenge.challengeName.signInStep, - codeDeliveryDetails: challenge.codeDeliveryDetails, - additionalInfo: challenge.challengeParameters, - missingAttributes: challenge.requiredAttributes, - allowedMfaTypes: challenge.allowedMfaTypes, - totpSetupDetails: challenge.totpSetupResult, - ), - ); + case final SignInChallenge challenge: + return CognitoSignInResult( + isSignedIn: false, + nextStep: AuthNextSignInStep( + signInStep: challenge.challengeName.signInStep, + codeDeliveryDetails: challenge.codeDeliveryDetails, + additionalInfo: challenge.challengeParameters, + missingAttributes: challenge.requiredAttributes, + allowedMfaTypes: challenge.allowedMfaTypes, + totpSetupDetails: challenge.totpSetupResult, + ), + ); - case SignInSuccess(): - return const CognitoSignInResult( - isSignedIn: true, - nextStep: AuthNextSignInStep( - signInStep: AuthSignInStep.done, - ), - ); + case SignInSuccess(): + return const CognitoSignInResult( + isSignedIn: true, + nextStep: AuthNextSignInStep( + signInStep: AuthSignInStep.done, + ), + ); - case final SignInFailure failure: - Error.throwWithStackTrace(failure.exception, failure.stackTrace); + case final SignInFailure failure: + Error.throwWithStackTrace(failure.exception, failure.stackTrace); // To satisfy Dart's requirements, even if unreachable } } diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart index bd3f16ad88..e1d4f45101 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart @@ -667,46 +667,49 @@ final class SignInStateMachine ); } - if (!hasUserResponse) { - // Need to prompt user to select an MFA type - return null; - } - - if (event == null) { - throw StateError('Event cannot be null when there is user response.'); - } - if (event is! SignInRespondToChallenge) { - throw StateError('Expected SignInRespondToChallenge event.'); - } + if (!hasUserResponse) { + // Need to prompt user to select an MFA type + return null; + } - if (_enableMfaType == null && _totpSetupResult == null) { - // User has just selected the MFA type - final selection = event.answer.toLowerCase(); - _enableMfaType = switch (selection) { - 'totp' => MfaType.totp, - 'email' => MfaType.email, - _ => throw const InvalidParameterException('Invalid MFA type selected'), - }; + if (event == null) { + throw StateError('Event cannot be null when there is user response.'); + } + if (event is! SignInRespondToChallenge) { + throw StateError('Expected SignInRespondToChallenge event.'); + } - final challengeResponses = { - CognitoConstants.challengeParamMfasCanSetup: _enableMfaType == MfaType.totp - ? '["SOFTWARE_TOKEN_MFA"]' - : '["EMAIL_OTP"]', - }; - _challengeParameters = BuiltMap(challengeResponses); - await _processChallenge(); - return null; - } + if (_enableMfaType == null && _totpSetupResult == null) { + // User has just selected the MFA type + final selection = event.answer.toLowerCase(); + _enableMfaType = switch (selection) { + 'totp' => MfaType.totp, + 'email' => MfaType.email, + _ => throw const InvalidParameterException('Invalid MFA type selected'), + }; + + final challengeResponses = { + CognitoConstants.challengeParamMfasCanSetup: + _enableMfaType == MfaType.totp + ? '["SOFTWARE_TOKEN_MFA"]' + : '["EMAIL_OTP"]', + }; + _challengeParameters = BuiltMap(challengeResponses); + await _processChallenge(); + return null; + } - // totp mfa method was already selected - if (mfaTypesForSetup.length == 1 && mfaTypesForSetup.contains(MfaType.totp) && _totpSetupResult != null) { - createSoftwareTokenMfaRequest(event); - } + // totp mfa method was already selected + if (mfaTypesForSetup.length == 1 && + mfaTypesForSetup.contains(MfaType.totp) && + _totpSetupResult != null) { + createSoftwareTokenMfaRequest(event); + } - // User has provided the verification code - return _enableMfaType == MfaType.totp - ? createMfaSetupRequest(event) - : createEmailMfaSetupRequest(event); + // User has provided the verification code + return _enableMfaType == MfaType.totp + ? createMfaSetupRequest(event) + : createEmailMfaSetupRequest(event); } /// Completes set up of a TOTP MFA. @@ -1056,7 +1059,8 @@ final class SignInStateMachine if (_allowedMfaTypes case final allowedMfaTypes? when _challengeParameters .containsKey(CognitoConstants.challengeParamMfasCanSetup)) { - if (!allowedMfaTypes.contains(MfaType.totp) && !allowedMfaTypes.contains(MfaType.email)) { + if (!allowedMfaTypes.contains(MfaType.totp) && + !allowedMfaTypes.contains(MfaType.email)) { throw const InvalidUserPoolConfigurationException( 'Cannot enable SMS MFA and TOTP or EMAIL MFA is not allowed', recoverySuggestion: @@ -1064,7 +1068,10 @@ final class SignInStateMachine ); } final allowedMfaSetupTypes = [...?_allowedMfaTypes]..remove(MfaType.sms); - if (allowedMfaSetupTypes.length == 1 && allowedMfaSetupTypes.first == MfaType.totp && _totpSetupResult == null) _totpSetupResult = await associateSoftwareToken(accessToken: _session); + if (allowedMfaSetupTypes.length == 1 && + allowedMfaSetupTypes.first == MfaType.totp && + _totpSetupResult == null) + _totpSetupResult = await associateSoftwareToken(accessToken: _session); } // Query the state machine for a response given potential user input in From e7e08880d67aeb06455cdcb0f30a5bdb4f9e9ad9 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Mon, 14 Oct 2024 22:57:44 -0700 Subject: [PATCH 84/91] chore: refactor setMfaSettings to make it easier to read with helper methods --- .../lib/src/sdk/sdk_bridge.dart | 104 +++++++++++------- 1 file changed, 65 insertions(+), 39 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart index 8ea47761ed..d137d37225 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart @@ -804,55 +804,27 @@ extension MfaSettings on CognitoIdentityProviderClient { preferred: currentPreference, ) = await _getRawUserSettings(accessToken: accessToken); - final newPreferredMethods = [ - if (sms == MfaPreference.preferred) MfaType.sms, - if (totp == MfaPreference.preferred) MfaType.totp, - if (email == MfaPreference.preferred) MfaType.email, - ]; - - if (newPreferredMethods.length > 1) { - throw const InvalidParameterException( - 'Cannot assign multiple MFA methods as preferred', - ); - } - - var preferred = newPreferredMethods.isNotEmpty - ? newPreferredMethods.first - : currentPreference; - - final isCurrentPreferenceDisabled = switch (currentPreference) { - MfaType.sms => - sms == MfaPreference.disabled || sms == MfaPreference.notPreferred, - MfaType.totp => - totp == MfaPreference.disabled || totp == MfaPreference.notPreferred, - MfaType.email => - email == MfaPreference.disabled || email == MfaPreference.notPreferred, - _ => false, - }; - preferred = isCurrentPreferenceDisabled ? null : preferred; - - const enabledValues = [ - MfaPreference.enabled, - MfaPreference.notPreferred, - MfaPreference.preferred, - ]; + var preferred = + _getNewPreferredMethod(sms: sms, totp: totp, email: email) ?? + currentPreference; - bool isMfaEnabled(MfaType mfaType, MfaPreference? preference) { - if (preference == MfaPreference.disabled) return false; - return currentEnabled.contains(mfaType) || - enabledValues.contains(preference); + if (_isCurrentPreferenceDisabled(currentPreference, + sms: sms, totp: totp, email: email,)) { + preferred = null; } final smsMfaSettings = SmsMfaSettingsType( - enabled: isMfaEnabled(MfaType.sms, sms), + enabled: _isMfaEnabled(MfaType.sms, sms, currentEnabled), preferredMfa: preferred == MfaType.sms, ); + final softwareTokenSettings = SoftwareTokenMfaSettingsType( - enabled: isMfaEnabled(MfaType.totp, totp), + enabled: _isMfaEnabled(MfaType.totp, totp, currentEnabled), preferredMfa: preferred == MfaType.totp, ); + final emailMfaSettings = EmailMfaSettingsType( - enabled: isMfaEnabled(MfaType.email, email), + enabled: _isMfaEnabled(MfaType.email, email, currentEnabled), preferredMfa: preferred == MfaType.email, ); @@ -865,6 +837,60 @@ extension MfaSettings on CognitoIdentityProviderClient { ), ).result; } + + /// Making sure a maximum of one MFA method is set to preferred. + MfaType? _getNewPreferredMethod({ + MfaPreference? sms, + MfaPreference? totp, + MfaPreference? email, + }) { + final preferredMethods = [ + if (sms == MfaPreference.preferred) MfaType.sms, + if (totp == MfaPreference.preferred) MfaType.totp, + if (email == MfaPreference.preferred) MfaType.email, + ]; + + if (preferredMethods.length > 1) { + throw const InvalidParameterException( + 'Cannot assign multiple MFA methods as preferred', + ); + } + + return preferredMethods.isNotEmpty ? preferredMethods.first : null; + } + + /// Checks if the current preferred MFA method is being disabled or set to not preferred. + bool _isCurrentPreferenceDisabled( + MfaType? currentPreference, { + MfaPreference? sms, + MfaPreference? totp, + MfaPreference? email, + }) { + switch (currentPreference) { + case MfaType.sms: + return sms == MfaPreference.disabled || + sms == MfaPreference.notPreferred; + case MfaType.totp: + return totp == MfaPreference.disabled || + totp == MfaPreference.notPreferred; + case MfaType.email: + return email == MfaPreference.disabled || + email == MfaPreference.notPreferred; + default: + return false; + } + } + + /// Determines if an MFA type should be enabled based on preferences and current settings. + bool _isMfaEnabled( + MfaType mfaType, + MfaPreference? preference, + Set currentEnabled, + ) { + if (preference == MfaPreference.disabled) return false; + if (preference != null) return true; + return currentEnabled.contains(mfaType); + } } extension on String { From 4135f06efeeca7635285f2a9f0b46bc5bf433a40 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Mon, 14 Oct 2024 23:21:00 -0700 Subject: [PATCH 85/91] chore: refactor auth_bloc with helper function used in two switch statements --- .../lib/src/blocs/auth/auth_bloc.dart | 96 +++++++++---------- 1 file changed, 45 insertions(+), 51 deletions(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart index d0cbff9fe8..6bf58c0493 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart @@ -234,9 +234,7 @@ class StateMachineBloc allowedMfaTypes: result.nextStep.allowedMfaTypes, ); case AuthSignInStep.continueSignInWithMfaSetupSelection: - yield ContinueSignInWithMfaSetupSelection( - allowedMfaTypes: result.nextStep.allowedMfaTypes, - ); + await _handleMfaSetupSelection(result); case AuthSignInStep.continueSignInWithTotpSetup: assert( result.nextStep.totpSetupDetails != null, @@ -246,6 +244,8 @@ class StateMachineBloc result.nextStep.totpSetupDetails!, totpOptions, ); + case AuthSignInStep.continueSignInWithEmailMfaSetup: + yield UnauthenticatedState.continueSignInWithEmailMfaSetup; case AuthSignInStep.resetPassword: yield UnauthenticatedState.resetPassword; case AuthSignInStep.confirmSignUp: @@ -340,54 +340,7 @@ class StateMachineBloc ), ); case AuthSignInStep.continueSignInWithMfaSetupSelection: - final allowedMfaTypes = result.nextStep.allowedMfaTypes; - if (allowedMfaTypes != null) { - final mfaTypesForSetup = allowedMfaTypes.toSet()..remove(MfaType.sms); - if (mfaTypesForSetup.length == 1) { - final mfaType = mfaTypesForSetup.first; - if (mfaType == MfaType.totp) { - assert( - result.nextStep.totpSetupDetails != null, - 'Sign In Result should have totpSetupDetails', - ); - _emit( - await ContinueSignInTotpSetup.setupURI( - result.nextStep.totpSetupDetails!, - totpOptions, - ), - ); - } else if (mfaType == MfaType.email) { - _emit(UnauthenticatedState.continueSignInWithEmailMfaSetup); - } else { - throw InvalidUserPoolConfigurationException( - 'Unsupported MFA type: ${mfaType.name}', - recoverySuggestion: 'Check your user pool MFA configuration.', - ); - } - } else { - _emit( - ContinueSignInWithMfaSetupSelection( - allowedMfaTypes: result.nextStep.allowedMfaTypes, - ), - ); - } - } else { - throw const InvalidUserPoolConfigurationException( - 'Allowed MFA types are null', - recoverySuggestion: 'Check your user pool MFA configuration.', - ); - } - case AuthSignInStep.continueSignInWithTotpSetup: - assert( - result.nextStep.totpSetupDetails != null, - 'Sign In Result should have totpSetupDetails', - ); - _emit( - await ContinueSignInTotpSetup.setupURI( - result.nextStep.totpSetupDetails!, - totpOptions, - ), - ); + await _handleMfaSetupSelection(result); case AuthSignInStep.continueSignInWithEmailMfaSetup: _emit(UnauthenticatedState.continueSignInWithEmailMfaSetup); case AuthSignInStep.confirmSignInWithTotpMfaCode: @@ -590,6 +543,47 @@ class StateMachineBloc yield* const Stream.empty(); } + Future _handleMfaSetupSelection(SignInResult result) async { + final allowedMfaTypes = result.nextStep.allowedMfaTypes; + if (allowedMfaTypes != null) { + final mfaTypesForSetup = allowedMfaTypes.toSet()..remove(MfaType.sms); + if (mfaTypesForSetup.length == 1) { + final mfaType = mfaTypesForSetup.first; + if (mfaType == MfaType.totp) { + assert( + result.nextStep.totpSetupDetails != null, + 'Sign In Result should have totpSetupDetails', + ); + _emit( + await ContinueSignInTotpSetup.setupURI( + result.nextStep.totpSetupDetails!, + totpOptions, + ), + ); + } else if (mfaType == MfaType.email) { + _emit(UnauthenticatedState.continueSignInWithEmailMfaSetup); + } else { + throw InvalidUserPoolConfigurationException( + 'Unsupported MFA type: ${mfaType.name}', + recoverySuggestion: 'Check your user pool MFA configuration.', + ); + } + } else { + _emit( + ContinueSignInWithMfaSetupSelection( + allowedMfaTypes: result.nextStep.allowedMfaTypes, + ), + ); + } + } else { + _emit( + ContinueSignInWithMfaSetupSelection( + allowedMfaTypes: result.nextStep.allowedMfaTypes, + ), + ); + } + } + @override Future close() async { await Future.wait([ From eb93be4403c2148d3605f7f376df3c57dd1cb8d3 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Mon, 14 Oct 2024 23:49:17 -0700 Subject: [PATCH 86/91] chore: refactor auth bloc helper method to remove nested if/else statements --- .../lib/src/blocs/auth/auth_bloc.dart | 70 ++++++++++--------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart index 6bf58c0493..f53beb7acd 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart @@ -545,42 +545,48 @@ class StateMachineBloc Future _handleMfaSetupSelection(SignInResult result) async { final allowedMfaTypes = result.nextStep.allowedMfaTypes; - if (allowedMfaTypes != null) { - final mfaTypesForSetup = allowedMfaTypes.toSet()..remove(MfaType.sms); - if (mfaTypesForSetup.length == 1) { - final mfaType = mfaTypesForSetup.first; - if (mfaType == MfaType.totp) { - assert( - result.nextStep.totpSetupDetails != null, - 'Sign In Result should have totpSetupDetails', - ); - _emit( - await ContinueSignInTotpSetup.setupURI( - result.nextStep.totpSetupDetails!, - totpOptions, - ), - ); - } else if (mfaType == MfaType.email) { - _emit(UnauthenticatedState.continueSignInWithEmailMfaSetup); - } else { - throw InvalidUserPoolConfigurationException( - 'Unsupported MFA type: ${mfaType.name}', - recoverySuggestion: 'Check your user pool MFA configuration.', - ); - } - } else { - _emit( - ContinueSignInWithMfaSetupSelection( - allowedMfaTypes: result.nextStep.allowedMfaTypes, - ), - ); - } - } else { + + if (allowedMfaTypes == null) { + throw const InvalidUserPoolConfigurationException( + 'No MFA types are supported', + recoverySuggestion: 'Check your user pool MFA configuration.', + ); + } + + final mfaTypesForSetup = allowedMfaTypes.toSet()..remove(MfaType.sms); + + if (mfaTypesForSetup.length != 1) { _emit( ContinueSignInWithMfaSetupSelection( - allowedMfaTypes: result.nextStep.allowedMfaTypes, + allowedMfaTypes: allowedMfaTypes, ), ); + return; + } + + final mfaType = mfaTypesForSetup.first; + + switch (mfaType) { + case MfaType.totp: + assert( + result.nextStep.totpSetupDetails != null, + 'Sign In Result should have totpSetupDetails', + ); + _emit( + await ContinueSignInTotpSetup.setupURI( + result.nextStep.totpSetupDetails!, + totpOptions, + ), + ); + + case MfaType.email: + _emit(UnauthenticatedState.continueSignInWithEmailMfaSetup); + + default: + throw InvalidUserPoolConfigurationException( + 'Unsupported MFA type: ${mfaType.name}', + recoverySuggestion: 'Check your user pool MFA configuration.', + ); } } From daacad78fc72cd5c9b38d1aaa4a77804c411499a Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Tue, 15 Oct 2024 00:22:36 -0700 Subject: [PATCH 87/91] chore: refactor sign in state machine and add in constants for email challenge --- .../lib/src/flows/constants.dart | 3 + .../state/machines/sign_in_state_machine.dart | 89 +++++++++++-------- 2 files changed, 53 insertions(+), 39 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart index 7a40ff446c..7f916b290b 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/flows/constants.dart @@ -11,6 +11,9 @@ abstract class CognitoConstants { /// The `USERNAME` parameter. static const challengeParamUsername = 'USERNAME'; + /// The 'EMAIL' parameter. + static const challengeParamEmail = 'EMAIL'; + /// The `SRP_A` parameter. static const challengeParamSrpA = 'SRP_A'; diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart index 725f66b9d1..a62e593d4d 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart @@ -330,8 +330,8 @@ final class SignInStateMachine createEmailMfaRequest(event), ChallengeNameType.selectMfaType when hasUserResponse => createSelectMfaRequest(event), - ChallengeNameType.mfaSetup => - handleMfaSetup(event: event, hasUserResponse: hasUserResponse), + ChallengeNameType.mfaSetup when hasUserResponse => + handleMfaSetup(event: event), ChallengeNameType.newPasswordRequired when hasUserResponse => createNewPasswordRequest(event), _ => null, @@ -655,7 +655,6 @@ final class SignInStateMachine @protected Future handleMfaSetup({ SignInEvent? event, - required bool hasUserResponse, }) async { final allowedMfaTypes = _allowedMfaTypes; // Exclude MfaType.sms from consideration @@ -667,38 +666,44 @@ final class SignInStateMachine ); } - if (mfaTypesForSetup.length == 1) { - final mfaType = mfaTypesForSetup.first; - if (mfaType == MfaType.totp) { - _enableMfaType = MfaType.totp; - _totpSetupResult ??= await associateSoftwareToken(); - if (hasUserResponse) { - return createMfaSetupRequest(event as SignInRespondToChallenge); - } else { - // Need to prompt user for the TOTP code - return null; - } - } else if (mfaType == MfaType.email) { - _enableMfaType = MfaType.email; - if (hasUserResponse) { - return createEmailMfaSetupRequest(event as SignInRespondToChallenge); - } else { - // Need to prompt user for the email verification code - return null; - } - } else { - throw InvalidUserPoolConfigurationException( - 'Unsupported MFA type: ${mfaType.name}', - recoverySuggestion: 'Check your user pool MFA configuration.', - ); - } - } else if (hasUserResponse) { - // Handle user's selection - return createMfaSetupRequest(event as SignInRespondToChallenge); - } else { - // Need to prompt user to select an MFA type + if (event == null) { + throw StateError('Event cannot be null when there is user response.'); + } + if (event is! SignInRespondToChallenge) { + throw StateError('Expected SignInRespondToChallenge event.'); + } + + if (_enableMfaType == null && _totpSetupResult == null) { + // User has just selected the MFA type + final selection = event.answer.toLowerCase(); + _enableMfaType = switch (selection) { + 'totp' => MfaType.totp, + 'email' => MfaType.email, + _ => throw const InvalidParameterException('Invalid MFA type selected'), + }; + + final challengeResponses = { + CognitoConstants.challengeParamMfasCanSetup: + _enableMfaType == MfaType.totp + ? '["SOFTWARE_TOKEN_MFA"]' + : '["EMAIL_OTP"]', + }; + _challengeParameters = BuiltMap(challengeResponses); + await _processChallenge(); return null; } + + // totp mfa method was already selected + if (mfaTypesForSetup.length == 1 && + mfaTypesForSetup.contains(MfaType.totp) && + _totpSetupResult != null) { + await createSoftwareTokenMfaRequest(event); + } + + // User has provided the verification code + return _enableMfaType == MfaType.totp + ? createMfaSetupRequest(event) + : createEmailMfaSetupRequest(event); } /// Completes set up of a TOTP MFA. @@ -732,10 +737,10 @@ final class SignInStateMachine _enableMfaType = MfaType.email; return RespondToAuthChallengeRequest.build((b) { b - ..challengeName = ChallengeNameType.emailOtp + ..challengeName = ChallengeNameType.mfaSetup ..challengeResponses.addAll({ CognitoConstants.challengeParamUsername: cognitoUsername, - CognitoConstants.challengeParamEmailMfaCode: event.answer, + CognitoConstants.challengeParamEmail: event.answer, }) ..clientId = _authOutputs.userPoolClientId ..clientMetadata.addAll(event.clientMetadata); @@ -1048,14 +1053,20 @@ final class SignInStateMachine if (_allowedMfaTypes case final allowedMfaTypes? when _challengeParameters .containsKey(CognitoConstants.challengeParamMfasCanSetup)) { - if (!allowedMfaTypes.contains(MfaType.totp)) { + if (!allowedMfaTypes.contains(MfaType.totp) && + allowedMfaTypes.contains(MfaType.email)) { throw const InvalidUserPoolConfigurationException( - 'Cannot enable SMS MFA and TOTP MFA is not allowed', + 'Cannot enable SMS MFA and TOTP or EMAIL MFA is not allowed', recoverySuggestion: - 'Contact an administrator to enable SMS MFA or allow TOTP MFA', + 'Contact an administrator to enable SMS MFA or allow TOTP or EMAIL MFA', ); } - _totpSetupResult ??= await associateSoftwareToken(); + final allowedMfaSetupTypes = [...?_allowedMfaTypes]..remove(MfaType.sms); + if (allowedMfaSetupTypes.length == 1 && + allowedMfaSetupTypes.first == MfaType.totp && + _totpSetupResult == null) { + _totpSetupResult = await associateSoftwareToken(accessToken: _session); + } } // Query the state machine for a response given potential user input in From a3c57e90b26e4d8ba041f516127a488d791736f3 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Tue, 15 Oct 2024 00:24:20 -0700 Subject: [PATCH 88/91] chore: fix missing ! --- .../lib/src/state/machines/sign_in_state_machine.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart index a62e593d4d..2fdb6c66af 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart @@ -1054,7 +1054,7 @@ final class SignInStateMachine when _challengeParameters .containsKey(CognitoConstants.challengeParamMfasCanSetup)) { if (!allowedMfaTypes.contains(MfaType.totp) && - allowedMfaTypes.contains(MfaType.email)) { + !allowedMfaTypes.contains(MfaType.email)) { throw const InvalidUserPoolConfigurationException( 'Cannot enable SMS MFA and TOTP or EMAIL MFA is not allowed', recoverySuggestion: From 7129360f8eda5fddf007c9381aaa273927463eac Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Tue, 15 Oct 2024 00:47:31 -0700 Subject: [PATCH 89/91] chore: run dart format --- .../amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart index d137d37225..a48c8d4a01 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/sdk_bridge.dart @@ -808,8 +808,12 @@ extension MfaSettings on CognitoIdentityProviderClient { _getNewPreferredMethod(sms: sms, totp: totp, email: email) ?? currentPreference; - if (_isCurrentPreferenceDisabled(currentPreference, - sms: sms, totp: totp, email: email,)) { + if (_isCurrentPreferenceDisabled( + currentPreference, + sms: sms, + totp: totp, + email: email, + )) { preferred = null; } From 4eb2093592fdcc43d3556855a604f458310c8352 Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Thu, 17 Oct 2024 09:56:49 -0700 Subject: [PATCH 90/91] chore: add emit to processSignInResult --- .../amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart index 1ae97d13b2..353db05de4 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart @@ -340,7 +340,7 @@ class StateMachineBloc ), ); case AuthSignInStep.continueSignInWithMfaSetupSelection: - await _handleMfaSetupSelection(result); + _emit(await _handleMfaSetupSelection(result)); case AuthSignInStep.continueSignInWithEmailMfaSetup: _emit(UnauthenticatedState.continueSignInWithEmailMfaSetup); case AuthSignInStep.confirmSignInWithTotpMfaCode: From 37c769d83a964dd113160df3b65a072bd17760ac Mon Sep 17 00:00:00 2001 From: Kha Truong <64438356+khatruong2009@users.noreply.github.com> Date: Mon, 21 Oct 2024 17:54:48 -0700 Subject: [PATCH 91/91] chore: add mfa setup selection in authenticator step in form field --- .../amplify_authenticator/lib/src/widgets/form_field.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_field.dart b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_field.dart index a9824be8c5..cc538d7dc8 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/widgets/form_field.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/widgets/form_field.dart @@ -240,7 +240,8 @@ abstract class AuthenticatorFormFieldState< state.confirmTotp(); case AuthenticatorStep.continueSignInWithEmailMfaSetup: state.continueEmailMfaSetup(); - // TODO(khatruong2009): add case for AuthenticatorStep.continueSignInWithMfaSetupSelection + case AuthenticatorStep.continueSignInWithMfaSetupSelection: + state.continueSignInWithMfaSetupSelection(); case AuthenticatorStep.resetPassword: state.resetPassword(); case AuthenticatorStep.confirmResetPassword: