diff --git a/packages/amplify_core/lib/src/category/amplify_auth_category.dart b/packages/amplify_core/lib/src/category/amplify_auth_category.dart index 7668db291c..4a23528d70 100644 --- a/packages/amplify_core/lib/src/category/amplify_auth_category.dart +++ b/packages/amplify_core/lib/src/category/amplify_auth_category.dart @@ -1292,21 +1292,6 @@ class AuthCategory extends AmplifyCategory { ), ); - /// {@macro amplify_core.amplify_auth_category.send_attribute_verification_code} - @Deprecated('Use sendUserAttributeVerificationCode.') - Future - resendUserAttributeConfirmationCode({ - required AuthUserAttributeKey userAttributeKey, - ResendUserAttributeConfirmationCodeOptions? options, - }) => - identifyCall( - AuthCategoryMethod.sendUserAttributeVerificationCode, - () => defaultPlugin.sendUserAttributeVerificationCode( - userAttributeKey: userAttributeKey, - options: options, - ), - ); - /// {@template amplify_core.amplify_auth_category.set_up_totp} /// Initiates setup of a time-based one-time passcode (TOTP) MFA method for the /// current user. diff --git a/packages/amplify_core/lib/src/config/auth/auth_config.dart b/packages/amplify_core/lib/src/config/auth/auth_config.dart index 77422d82cb..e3a4f45355 100644 --- a/packages/amplify_core/lib/src/config/auth/auth_config.dart +++ b/packages/amplify_core/lib/src/config/auth/auth_config.dart @@ -24,7 +24,6 @@ class AuthConfig extends AmplifyPluginConfigMap { CognitoUserPoolConfig? userPoolConfig, CognitoIdentityPoolConfig? identityPoolConfig, CognitoOAuthConfig? hostedUiConfig, - AuthenticationFlowType? authenticationFlowType, List? socialProviders, List? usernameAttributes, List? signupAttributes, @@ -40,7 +39,6 @@ class AuthConfig extends AmplifyPluginConfigMap { auth: AWSConfigMap.withDefault( CognitoAuthConfig( oAuth: hostedUiConfig, - authenticationFlowType: authenticationFlowType, socialProviders: socialProviders, usernameAttributes: usernameAttributes ?? const [], signupAttributes: signupAttributes ?? const [], diff --git a/packages/amplify_core/lib/src/config/auth/cognito/auth.dart b/packages/amplify_core/lib/src/config/auth/cognito/auth.dart index 07a85f3086..4883afd459 100644 --- a/packages/amplify_core/lib/src/config/auth/cognito/auth.dart +++ b/packages/amplify_core/lib/src/config/auth/cognito/auth.dart @@ -13,7 +13,6 @@ part 'auth.g.dart'; class CognitoAuthConfig with AWSEquatable, AWSSerializable { const CognitoAuthConfig({ this.oAuth, - this.authenticationFlowType, this.socialProviders, this.usernameAttributes, this.signupAttributes, @@ -29,10 +28,6 @@ class CognitoAuthConfig with AWSEquatable, AWSSerializable { @JsonKey(name: 'OAuth') final CognitoOAuthConfig? oAuth; - @JsonKey( - unknownEnumValue: JsonKey.nullForUndefinedEnumValue, - ) - final AuthenticationFlowType? authenticationFlowType; final List? socialProviders; final List? usernameAttributes; final List? signupAttributes; @@ -44,7 +39,6 @@ class CognitoAuthConfig with AWSEquatable, AWSSerializable { @override List get props => [ oAuth, - authenticationFlowType, socialProviders, usernameAttributes, signupAttributes, @@ -56,7 +50,6 @@ class CognitoAuthConfig with AWSEquatable, AWSSerializable { CognitoAuthConfig copyWith({ CognitoOAuthConfig? oAuth, - AuthenticationFlowType? authenticationFlowType, List? socialProviders, List? usernameAttributes, List? signupAttributes, @@ -67,8 +60,6 @@ class CognitoAuthConfig with AWSEquatable, AWSSerializable { }) { return CognitoAuthConfig( oAuth: oAuth ?? this.oAuth, - authenticationFlowType: - authenticationFlowType ?? this.authenticationFlowType, socialProviders: socialProviders ?? (this.socialProviders == null ? null 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 bfc236da4a..36e2c120cc 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 @@ -13,9 +13,6 @@ CognitoAuthConfig _$CognitoAuthConfigFromJson(Map json) => oAuth: json['OAuth'] == null ? null : CognitoOAuthConfig.fromJson(json['OAuth'] as Map), - authenticationFlowType: $enumDecodeNullable( - _$AuthenticationFlowTypeEnumMap, json['authenticationFlowType'], - unknownValue: JsonKey.nullForUndefinedEnumValue), socialProviders: (json['socialProviders'] as List?) ?.map((e) => $enumDecode(_$SocialProviderEnumMap, e)) .toList(), @@ -52,8 +49,6 @@ Map _$CognitoAuthConfigToJson(CognitoAuthConfig instance) { } writeNotNull('OAuth', instance.oAuth?.toJson()); - writeNotNull('authenticationFlowType', - _$AuthenticationFlowTypeEnumMap[instance.authenticationFlowType]); writeNotNull( 'socialProviders', instance.socialProviders @@ -83,14 +78,6 @@ Map _$CognitoAuthConfigToJson(CognitoAuthConfig instance) { return val; } -const _$AuthenticationFlowTypeEnumMap = { - AuthenticationFlowType.userSrpAuth: 'USER_SRP_AUTH', - AuthenticationFlowType.userPasswordAuth: 'USER_PASSWORD_AUTH', - AuthenticationFlowType.customAuth: 'CUSTOM_AUTH', - AuthenticationFlowType.customAuthWithSrp: 'CUSTOM_AUTH_WITH_SRP', - AuthenticationFlowType.customAuthWithoutSrp: 'CUSTOM_AUTH_WITHOUT_SRP', -}; - const _$SocialProviderEnumMap = { SocialProvider.facebook: 'FACEBOOK', SocialProvider.google: 'GOOGLE', diff --git a/packages/amplify_core/lib/src/config/auth/cognito/authentication_flow_type.dart b/packages/amplify_core/lib/src/config/auth/cognito/authentication_flow_type.dart index 4b574a8b91..9b9fcc3348 100644 --- a/packages/amplify_core/lib/src/config/auth/cognito/authentication_flow_type.dart +++ b/packages/amplify_core/lib/src/config/auth/cognito/authentication_flow_type.dart @@ -14,11 +14,6 @@ enum AuthenticationFlowType { @JsonValue('USER_PASSWORD_AUTH') userPasswordAuth('USER_PASSWORD_AUTH'), - /// Authentication flow for custom flow which are backed by Lambda triggers. - @Deprecated('Use customAuthWithSrp or customAuthWithoutSrp instead') - @JsonValue('CUSTOM_AUTH') - customAuth('CUSTOM_AUTH'), - /// Authentication flow which start with SRP and then move to custom auth /// flow. @JsonValue('CUSTOM_AUTH_WITH_SRP') diff --git a/packages/amplify_core/lib/src/plugin/amplify_auth_plugin_interface.dart b/packages/amplify_core/lib/src/plugin/amplify_auth_plugin_interface.dart index ccf764b554..43e74853f3 100644 --- a/packages/amplify_core/lib/src/plugin/amplify_auth_plugin_interface.dart +++ b/packages/amplify_core/lib/src/plugin/amplify_auth_plugin_interface.dart @@ -153,18 +153,6 @@ abstract class AuthPluginInterface extends AmplifyPluginInterface { ); } - /// {@macro amplify_core.amplify_auth_category.send_attribute_verification_code} - @Deprecated('Use sendUserAttributeVerificationCode instead.') - Future - resendUserAttributeConfirmationCode({ - required AuthUserAttributeKey userAttributeKey, - ResendUserAttributeConfirmationCodeOptions? options, - }) { - throw UnimplementedError( - 'resendUserAttributeConfirmationCode() has not been implemented.', - ); - } - /// {@macro amplify_core.amplify_auth_category.send_attribute_verification_code} Future sendUserAttributeVerificationCode({ diff --git a/packages/amplify_core/lib/src/types/auth/attribute/send_user_attribute_verification_code_options.dart b/packages/amplify_core/lib/src/types/auth/attribute/send_user_attribute_verification_code_options.dart index c6eb3e7405..582c834ff3 100644 --- a/packages/amplify_core/lib/src/types/auth/attribute/send_user_attribute_verification_code_options.dart +++ b/packages/amplify_core/lib/src/types/auth/attribute/send_user_attribute_verification_code_options.dart @@ -49,14 +49,3 @@ abstract class SendUserAttributeVerificationCodePluginOptions /// {@macro amplify_core.auth.send_user_attribute_verification_code_plugin_options} const SendUserAttributeVerificationCodePluginOptions(); } - -/// {@macro amplify_core.send_attribute_verification_code_options} -@Deprecated('Use SendUserAttributeVerificationCodeOptions.') -typedef ResendUserAttributeConfirmationCodeOptions - = SendUserAttributeVerificationCodeOptions; - -/// @nodoc -/// {@macro amplify_core.auth.send_user_attribute_verification_code_plugin_options} -@Deprecated('Use SendUserAttributeVerificationCodePluginOptions.') -typedef ResendUserAttributeConfirmationCodePluginOptions - = SendUserAttributeVerificationCodePluginOptions; diff --git a/packages/amplify_core/lib/src/types/auth/attribute/send_user_attribute_verification_code_result.dart b/packages/amplify_core/lib/src/types/auth/attribute/send_user_attribute_verification_code_result.dart index 7ea84637a4..649eaba943 100644 --- a/packages/amplify_core/lib/src/types/auth/attribute/send_user_attribute_verification_code_result.dart +++ b/packages/amplify_core/lib/src/types/auth/attribute/send_user_attribute_verification_code_result.dart @@ -40,8 +40,3 @@ class SendUserAttributeVerificationCodeResult Map toJson() => _$SendUserAttributeVerificationCodeResultToJson(this); } - -/// {@macro amplify_core.send_user_attribute_verification_code_result} -@Deprecated('Use SendUserAttributeVerificationCodeResult.') -typedef ResendUserAttributeConfirmationCodeResult - = SendUserAttributeVerificationCodeResult; diff --git a/packages/amplify_core/lib/src/types/auth/auth_code_delivery_details.dart b/packages/amplify_core/lib/src/types/auth/auth_code_delivery_details.dart index 97d881aab3..f8586972db 100644 --- a/packages/amplify_core/lib/src/types/auth/auth_code_delivery_details.dart +++ b/packages/amplify_core/lib/src/types/auth/auth_code_delivery_details.dart @@ -57,11 +57,6 @@ class AuthCodeDeliveryDetails /// being updated. final AuthUserAttributeKey? attributeKey; - /// If a user attribute update is underway, this is the name of the attribute - /// being updated. - @Deprecated('Use attributeKey instead') - String? get attributeName => attributeKey?.key; - @override List get props => [attributeKey, deliveryMedium, destination]; diff --git a/packages/amplify_core/lib/src/types/auth/session/fetch_auth_session_options.dart b/packages/amplify_core/lib/src/types/auth/session/fetch_auth_session_options.dart index aebcd42390..bfb7fa322e 100644 --- a/packages/amplify_core/lib/src/types/auth/session/fetch_auth_session_options.dart +++ b/packages/amplify_core/lib/src/types/auth/session/fetch_auth_session_options.dart @@ -3,11 +3,6 @@ import 'package:amplify_core/amplify_core.dart'; -/// @nodoc -/// {@macro amplify_core.auth.fetch_auth_session_options} -@Deprecated('Use FetchAuthSessionOptions instead') -typedef AuthSessionOptions = FetchAuthSessionOptions; - /// {@category Auth} /// {@template amplify_core.auth.fetch_auth_session_options} /// Options for `Amplify.Auth.fetchAuthSession`. diff --git a/packages/amplify_core/lib/src/types/auth/session/get_current_user_options.dart b/packages/amplify_core/lib/src/types/auth/session/get_current_user_options.dart index 0122fda10e..7f4b526047 100644 --- a/packages/amplify_core/lib/src/types/auth/session/get_current_user_options.dart +++ b/packages/amplify_core/lib/src/types/auth/session/get_current_user_options.dart @@ -2,11 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 import 'package:amplify_core/amplify_core.dart'; -/// @nodoc -/// {@macro amplify_core.auth.get_current_user_options} -@Deprecated('Use GetCurrentUserOptions instead') -typedef AuthUserOptions = GetCurrentUserOptions; - /// {@category Auth} /// {@template amplify_core.auth.get_current_user_options} /// Options for `Amplify.Auth.getCurrentUser`. diff --git a/packages/amplify_core/test/config/auth_config_test.dart b/packages/amplify_core/test/config/auth_config_test.dart index 4db2edab33..4460fac35d 100644 --- a/packages/amplify_core/test/config/auth_config_test.dart +++ b/packages/amplify_core/test/config/auth_config_test.dart @@ -13,6 +13,7 @@ import 'package:path/path.dart' as path; import 'package:test/test.dart'; import 'testdata/test_values.dart'; +import 'utils/remove_deprecated_key.dart'; void main() { group('Config', () { @@ -24,6 +25,7 @@ void main() { test(name, () { final json = File(file.path).readAsStringSync(); final configJson = jsonDecode(json) as Map; + final expectedJson = removeDeprecatedKeys(configJson); final config = AmplifyConfig.fromJson(configJson); final expectedConfig = expected[name]!; final cognitoConfig = config.auth!.awsPlugin!.auth!.default$!; @@ -32,7 +34,7 @@ void main() { expectedConfig.toJson(), equals( // ignore: avoid_dynamic_calls - (configJson['auth'] as Map)['plugins']['awsCognitoAuthPlugin'] + (expectedJson['auth'] as Map)['plugins']['awsCognitoAuthPlugin'] ['Auth']['Default'], ), ); @@ -53,7 +55,6 @@ void main() { const expected = { 'auth_with_all_attributes': CognitoAuthConfig( - authenticationFlowType: AuthenticationFlowType.userSrpAuth, signupAttributes: [ CognitoUserAttributeKey.address, CognitoUserAttributeKey.birthdate, @@ -87,7 +88,6 @@ const expected = { usernameAttributes: [], ), 'auth_with_email': CognitoAuthConfig( - authenticationFlowType: AuthenticationFlowType.userSrpAuth, signupAttributes: [ CognitoUserAttributeKey.email, ], @@ -113,7 +113,6 @@ const expected = { ], ), 'auth_with_multi_alias': CognitoAuthConfig( - authenticationFlowType: AuthenticationFlowType.userSrpAuth, signupAttributes: [ CognitoUserAttributeKey.email, CognitoUserAttributeKey.phoneNumber, @@ -132,7 +131,6 @@ const expected = { ], ), 'auth_with_username_no_attributes': CognitoAuthConfig( - authenticationFlowType: AuthenticationFlowType.userSrpAuth, signupAttributes: [ CognitoUserAttributeKey.email, ], @@ -150,7 +148,6 @@ const expected = { usernameAttributes: [], ), 'auth_with_email_or_phone': CognitoAuthConfig( - authenticationFlowType: AuthenticationFlowType.userSrpAuth, socialProviders: [], usernameAttributes: [ CognitoUserAttributeKey.email, @@ -185,7 +182,6 @@ const expected = { signOutRedirectUri: OAUTH_SIGNOUT, webDomain: OAUTH_DOMAIN, ), - authenticationFlowType: AuthenticationFlowType.userSrpAuth, socialProviders: [ SocialProvider.facebook, SocialProvider.google, @@ -215,7 +211,6 @@ const expected = { ], ), 'auth_with_username': CognitoAuthConfig( - authenticationFlowType: AuthenticationFlowType.userSrpAuth, socialProviders: [], usernameAttributes: [], signupAttributes: [ diff --git a/packages/amplify_core/test/config/cli_config_test.dart b/packages/amplify_core/test/config/cli_config_test.dart index 2129d41037..aa3ec66cea 100644 --- a/packages/amplify_core/test/config/cli_config_test.dart +++ b/packages/amplify_core/test/config/cli_config_test.dart @@ -8,6 +8,7 @@ import 'package:test/test.dart'; import 'testdata/cli_generated.dart'; import 'testdata/test_values.dart'; +import 'utils/remove_deprecated_key.dart'; void main() { group('Config', () { @@ -17,10 +18,11 @@ void main() { final name = testData.name; test(name, () { final json = jsonDecode(testData.config) as Map; + final expectedJson = removeDeprecatedKeys(json); final parsed = AmplifyConfig.fromJson(json.cast()); final expectedConfig = expected[name]!; expect(parsed, equals(expectedConfig)); - expect(expectedConfig.toJson(), equals(json)); + expect(expectedConfig.toJson(), equals(expectedJson)); }); } }); @@ -95,12 +97,8 @@ const expected = { signOutRedirectUri: OAUTH_SIGNOUT, webDomain: OAUTH_DOMAIN, ), - authenticationFlowType: AuthenticationFlowType.userSrpAuth, - ), - 'DefaultCustomAuth': CognitoAuthConfig( - // ignore: deprecated_member_use_from_same_package - authenticationFlowType: AuthenticationFlowType.customAuth, ), + 'DefaultCustomAuth': CognitoAuthConfig(), }), cognitoUserPool: AWSConfigMap({ 'CustomEndpoint': CognitoUserPoolConfig( diff --git a/packages/amplify_core/test/config/e2e_config_test.dart b/packages/amplify_core/test/config/e2e_config_test.dart index 9d543f080c..6317e67a68 100644 --- a/packages/amplify_core/test/config/e2e_config_test.dart +++ b/packages/amplify_core/test/config/e2e_config_test.dart @@ -11,6 +11,7 @@ import 'testdata/e2e/v4/amplifyconfiguration.dart' as v4; import 'testdata/e2e/v5/amplifyconfiguration.dart' as v5; import 'testdata/e2e/v6/amplifyconfiguration.dart' as v6; import 'testdata/e2e/v7/amplifyconfiguration.dart' as v7; +import 'utils/remove_deprecated_key.dart'; class E2ETest { const E2ETest(this.version, this.config); @@ -33,7 +34,8 @@ void main() { test('v${e2eTest.version}', () { final json = jsonDecode(e2eTest.config) as Map; final parsed = AmplifyConfig.fromJson(json.cast()); - expect(parsed.toJson(), equals(json)); + final expectedJson = removeDeprecatedKeys(json); + expect(parsed.toJson(), equals(expectedJson)); }); } }); diff --git a/packages/amplify_core/test/config/utils/remove_deprecated_key.dart b/packages/amplify_core/test/config/utils/remove_deprecated_key.dart new file mode 100644 index 0000000000..ab342101ec --- /dev/null +++ b/packages/amplify_core/test/config/utils/remove_deprecated_key.dart @@ -0,0 +1,67 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +/// Removes keys that are no longer supported in the config as of Amplify +/// Flutter version 2. +/// +/// This function creates a copy of the object. The original object is not mutated. +/// +/// The tests in this directory test against real configs generated by the Gen1 +/// CLI and assert that serializing a json object to an AmplifyConfig and back +/// to JSON does not change the shape. Deprecated keys will not be present in +/// the output and need to be removed before comparison. +Map removeDeprecatedKeys(Map object) { + final newObject = {...object}; + removeKey( + newObject, + [ + 'auth', + 'plugins', + 'awsCognitoAuthPlugin', + 'Auth', + 'DefaultCustomAuth', + 'authenticationFlowType', + ], + ); + removeKey( + newObject, + [ + 'auth', + 'plugins', + 'awsCognitoAuthPlugin', + 'Auth', + 'Default', + 'authenticationFlowType', + ], + ); + return newObject; +} + +/// Removes a deeply nested key from a map if it exists in the map. +/// +/// This function mutates the original object. +/// +/// [path] is the path to the deeply nested key. +/// +/// Example +/// ``` +/// final obj = { +/// 'foo': { +/// 'bar': { +/// 'baz':'val' +/// } +/// } +/// } +/// print(obj); // => {'foo': {'bar': {'baz': 'val'}}} +/// removeKey(obj, ['foo', 'bar', 'baz']); +/// print(obj2); // => {'foo': {'bar': {}}} +/// ``` +void removeKey(Map object, List path) { + if (path.isEmpty) object; + if (path.length == 1) { + object.removeWhere((key, value) => key == path.first); + } else if (object.containsKey(path.first) && + object[path.first] is Map) { + removeKey(object[path.first] as Map, path.sublist(1)); + } +} diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/custom_auth_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/custom_auth_test.dart index 268bb8e6da..4cbd2b9009 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/custom_auth_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/custom_auth_test.dart @@ -229,32 +229,6 @@ void main() { reason: 'Authorization failures are not retryable', ); }); - - asyncTest('works with deprecated auth flow', (_) async { - const options = SignInOptions( - pluginOptions: CognitoSignInPluginOptions( - // ignore: deprecated_member_use - authFlowType: AuthenticationFlowType.customAuth, - ), - ); - final signInRes = await Amplify.Auth.signIn( - username: username, - options: options, - ); - expect( - signInRes.nextStep.signInStep, - AuthSignInStep.confirmSignInWithCustomChallenge, - reason: 'should use non-SRP flow based on exclusion of password', - ); - final res = await Amplify.Auth.confirmSignIn( - confirmationValue: confirmationValue, - ); - expect( - res.isSignedIn, - isTrue, - reason: 'should use non-SRP flow based on exclusion of password', - ); - }); }); } @@ -422,33 +396,6 @@ void main() { reason: 'Authorization failures are not retryable', ); }); - - asyncTest('works with deprecated auth flow', (_) async { - const options = SignInOptions( - pluginOptions: CognitoSignInPluginOptions( - // ignore: deprecated_member_use - authFlowType: AuthenticationFlowType.customAuth, - ), - ); - final signInRes = await Amplify.Auth.signIn( - username: username, - password: password, - options: options, - ); - expect( - signInRes.nextStep.signInStep, - AuthSignInStep.confirmSignInWithCustomChallenge, - reason: 'should use SRP flow based on inclusion of password', - ); - final res = await Amplify.Auth.confirmSignIn( - confirmationValue: confirmationValue, - ); - expect( - res.isSignedIn, - isTrue, - reason: 'should use SRP flow based on inclusion of password', - ); - }); }); } diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_totp_optional_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_totp_optional_test.dart index 44cfe0d4ca..64dff5af8d 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/mfa_totp_optional_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/mfa_totp_optional_test.dart @@ -125,7 +125,7 @@ void main() { check( e, because: 'Invalid TOTP code should fail verification', - ).isA(); + ).isA(); } check( diff --git a/packages/auth/amplify_auth_cognito/example/integration_test/user_attributes_test.dart b/packages/auth/amplify_auth_cognito/example/integration_test/user_attributes_test.dart index 847ad1cc39..40891c585a 100644 --- a/packages/auth/amplify_auth_cognito/example/integration_test/user_attributes_test.dart +++ b/packages/auth/amplify_auth_cognito/example/integration_test/user_attributes_test.dart @@ -232,80 +232,6 @@ void main() { await createAndLoginUser(); }); - group('resendUserAttributeConfirmationCode', () { - asyncTest('to email', (_) async { - final newEmail = generateEmail(); - // Cognito sends the confirmation code to the new attribute - // even when `keepOriginal` is true and even though it uses the old - // attribute when resending the code. - final code = await getOtpCode(UserAttribute.email(newEmail)); - logger.debug( - 'Updating email (keepOriginal=$keepOriginal) to: $newEmail', - ); - final updateResult = await Amplify.Auth.updateUserAttribute( - userAttributeKey: AuthUserAttributeKey.email, - value: newEmail, - ); - expect(updateResult.isUpdated, false); - expect( - updateResult.nextStep.updateAttributeStep, - AuthUpdateAttributeStep.confirmAttributeWithCode, - ); - expect( - updateResult.nextStep.codeDeliveryDetails?.attributeKey, - AuthUserAttributeKey.email, - ); - expect( - updateResult.nextStep.codeDeliveryDetails?.deliveryMedium, - DeliveryMedium.email, - ); - expect( - updateResult.nextStep.codeDeliveryDetails?.destination, - isNotNull, - ); - - // Drain original code - await expectLater( - code.code, - completes, - reason: - 'Cognito sends the confirmation code to the new attribute ' - 'even when keepOriginal is true and even though it uses the old ' - 'attribute when resending the code', - ); - logger.debug('Got original code'); - - final resentCode = await getOtpCode( - UserAttribute.email(keepOriginal ? email : newEmail), - ); - final resendResult = - // ignore: deprecated_member_use - await Amplify.Auth.resendUserAttributeConfirmationCode( - userAttributeKey: AuthUserAttributeKey.email, - ); - expect( - resendResult.codeDeliveryDetails.attributeKey, - AuthUserAttributeKey.email, - ); - expect( - resendResult.codeDeliveryDetails.deliveryMedium, - DeliveryMedium.email, - ); - expect( - resendResult.codeDeliveryDetails.destination, - isNotNull, - ); - - await expectLater( - Amplify.Auth.confirmUserAttribute( - userAttributeKey: AuthUserAttributeKey.email, - confirmationCode: await resentCode.code, - ), - completes, - ); - }); - }); - group('sendUserAttributeVerificationCode', () { asyncTest('to email', (_) async { final newEmail = generateEmail(); diff --git a/packages/auth/amplify_auth_cognito_dart/lib/amplify_auth_cognito_dart.dart b/packages/auth/amplify_auth_cognito_dart/lib/amplify_auth_cognito_dart.dart index 51dcf4f857..398860faf0 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/amplify_auth_cognito_dart.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/amplify_auth_cognito_dart.dart @@ -16,25 +16,18 @@ export 'src/jwt/src/cognito.dart'; export 'src/jwt/src/token.dart'; export 'src/model/attribute/cognito_confirm_user_attribute_plugin_options.dart'; export 'src/model/attribute/cognito_fetch_user_attributes_plugin_options.dart'; -export 'src/model/attribute/cognito_send_user_attribute_verification_code_options.dart'; export 'src/model/attribute/cognito_send_user_attribute_verification_code_plugin_options.dart'; -export 'src/model/attribute/cognito_update_user_attribute_options.dart'; export 'src/model/attribute/cognito_update_user_attribute_plugin_options.dart'; -export 'src/model/attribute/cognito_update_user_attribute_step.dart'; -export 'src/model/attribute/cognito_update_user_attributes_options.dart'; export 'src/model/attribute/cognito_update_user_attributes_plugin_options.dart'; export 'src/model/auth_result.dart'; export 'src/model/device/cognito_device.dart'; export 'src/model/mfa/cognito_verify_totp_setup_plugin_options.dart'; -export 'src/model/password/cognito_confirm_reset_password_options.dart'; export 'src/model/password/cognito_confirm_reset_password_plugin_options.dart'; -export 'src/model/password/cognito_reset_password_options.dart'; export 'src/model/password/cognito_reset_password_plugin_options.dart'; export 'src/model/password/cognito_reset_password_result.dart'; export 'src/model/password/cognito_update_password_plugin_options.dart'; export 'src/model/session/cognito_auth_session.dart'; export 'src/model/session/cognito_auth_user.dart'; -export 'src/model/session/cognito_fetch_auth_session_options.dart'; export 'src/model/session/cognito_fetch_auth_session_plugin_options.dart'; export 'src/model/session/cognito_get_current_user_plugin_options.dart'; export 'src/model/session/cognito_sign_in_details.dart' @@ -43,23 +36,15 @@ export 'src/model/session/cognito_user_pool_tokens.dart'; export 'src/model/session/federate_to_identity_pool_options.dart'; export 'src/model/session/federate_to_identity_pool_request.dart'; export 'src/model/session/federate_to_identity_pool_result.dart'; -export 'src/model/signin/cognito_confirm_sign_in_options.dart'; export 'src/model/signin/cognito_confirm_sign_in_plugin_options.dart'; -export 'src/model/signin/cognito_sign_in_options.dart'; export 'src/model/signin/cognito_sign_in_plugin_options.dart'; export 'src/model/signin/cognito_sign_in_result.dart'; -export 'src/model/signin/cognito_sign_in_step.dart'; -export 'src/model/signin/cognito_sign_in_with_web_ui_options.dart'; export 'src/model/signin/cognito_sign_in_with_web_ui_plugin_options.dart'; export 'src/model/signout/cognito_sign_out_plugin_options.dart'; export 'src/model/signout/cognito_sign_out_result.dart'; -export 'src/model/signup/cognito_confirm_sign_up_options.dart'; export 'src/model/signup/cognito_confirm_sign_up_plugin_options.dart'; -export 'src/model/signup/cognito_resend_sign_up_code_options.dart'; export 'src/model/signup/cognito_resend_sign_up_code_plugin_options.dart'; export 'src/model/signup/cognito_resend_sign_up_code_result.dart'; -export 'src/model/signup/cognito_sign_up_options.dart'; export 'src/model/signup/cognito_sign_up_plugin_options.dart'; export 'src/model/signup/cognito_sign_up_result.dart'; -export 'src/model/signup/cognito_sign_up_step.dart'; export 'src/sdk/sdk_exception.dart' hide transformSdkException; 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 b168e8ed34..608fd09bf0 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 @@ -697,18 +697,6 @@ class AmplifyAuthCognitoDart extends AuthPluginInterface return const ConfirmUserAttributeResult(); } - @override - Future - resendUserAttributeConfirmationCode({ - required AuthUserAttributeKey userAttributeKey, - SendUserAttributeVerificationCodeOptions? options, - }) async { - return sendUserAttributeVerificationCode( - userAttributeKey: userAttributeKey, - options: options, - ); - } - @override Future sendUserAttributeVerificationCode({ @@ -941,8 +929,7 @@ class AmplifyAuthCognitoDart extends AuthPluginInterface switch (state) { case TotpSetupRequiresVerification _: - // TODO(equartey): Change to `CodeMismatchException` in next major version as breaking change - throw const EnableSoftwareTokenMfaException( + throw const CodeMismatchException( 'The code provided was incorrect, try again', ); case TotpSetupFailure(:final exception, :final stackTrace): diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/credentials/cognito_keys.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/credentials/cognito_keys.dart index 1216bc49f1..976c88a181 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/credentials/cognito_keys.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/credentials/cognito_keys.dart @@ -96,14 +96,6 @@ enum HostedUiKey { /// The OAuth code verifier. codeVerifier, - /// The OIDC nonce value. - @Deprecated( - 'This value should no longer be used except for removing existing usages. ' - 'The library used to support nonce verification of the OIDC tokens but no ' - 'longer does.', - ) - nonce, - /// The [CognitoSignInWithWebUIPluginOptions] passed to `signInWithWebUI`. options, diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/flows/hosted_ui/hosted_ui_platform.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/flows/hosted_ui/hosted_ui_platform.dart index 5bc151d67d..253d8da5cd 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/flows/hosted_ui/hosted_ui_platform.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/flows/hosted_ui/hosted_ui_platform.dart @@ -261,8 +261,6 @@ abstract class HostedUiPlatform implements Closeable { [ _secureStorage.delete(key: _keys[HostedUiKey.state]), _secureStorage.delete(key: _keys[HostedUiKey.codeVerifier]), - // ignore: deprecated_member_use_from_same_package - _secureStorage.delete(key: _keys[HostedUiKey.nonce]), _secureStorage.delete(key: _keys[HostedUiKey.options]), ].map(Future.value), ); diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/jwt/src/cognito.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/jwt/src/cognito.dart index c787e1b0ce..09eb32c8cb 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/jwt/src/cognito.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/jwt/src/cognito.dart @@ -89,26 +89,6 @@ extension CognitoAccessToken on JsonWebToken { /// - [OpenID Connect Core: ID Token](https://openid.net/specs/openid-connect-core-1_0.html#IDToken) /// - [OpenID Connect Core: Standard Claims](https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims) extension CognitoIdToken on JsonWebToken { - /// The `nonce` claim comes from a parameter of the same name that you can add - /// to requests to your OAuth 2.0 `authorize` endpoint. When you add the - /// parameter, the `nonce` claim is included in the ID token that Amazon - /// Cognito issues, and you can use it to guard against replay attacks. - /// - /// If you do not provide a nonce value in your request, Amazon Cognito - /// automatically generates and validates a nonce when you authenticate - /// through a third-party identity provider, then adds it as a nonce claim to - /// the ID token. - /// - /// The implementation of the nonce claim in Amazon Cognito is based on OIDC - /// standards. - /// - /// [Reference](https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-the-id-token.html) - @Deprecated(''' - Usage of the nonce claim is no longer supported in the Amplify Flutter libraries. - To avoid confusion, this getter will be removed in a future version of the library. - ''') - String? get nonce => claims.customClaims['nonce'] as String?; - /// The Cognito username. /// /// [Reference](https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-the-id-token.html) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_send_user_attribute_verification_code_options.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_send_user_attribute_verification_code_options.dart deleted file mode 100644 index 1f11fdd8f3..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_send_user_attribute_verification_code_options.dart +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -import 'package:amplify_auth_cognito_dart/amplify_auth_cognito_dart.dart'; -import 'package:amplify_core/amplify_core.dart'; - -part 'cognito_send_user_attribute_verification_code_options.g.dart'; - -const _deprecatedMessage = ''' -Use SendUserAttributeVerificationCodeOptions instead. If Cognito-specific options are needed, use `pluginOptions`: - -SendUserAttributeVerificationCodeOptions( - pluginOptions: CognitoSendUserAttributeVerificationCodePluginOptions( - clientMetadata: { - 'my-key': 'my-value', - }, - ), -) -'''; - -/// {@template amplify_auth_cognito.cognito_send_user_attribute_verification_code_options} -/// Cognito options for `Amplify.Auth.sendUserAttributeVerificationCode`. -/// {@endtemplate} -@zAmplifySerializable -@Deprecated(_deprecatedMessage) -class CognitoSendUserAttributeVerificationCodeOptions - extends SendUserAttributeVerificationCodeOptions { - /// {@macro amplify_auth_cognito.cognito_send_user_attribute_verification_code_options} - @Deprecated(_deprecatedMessage) - const CognitoSendUserAttributeVerificationCodeOptions({ - Map? clientMetadata, - }) : clientMetadata = clientMetadata ?? const {}; - - /// {@macro amplify_auth_cognito.cognito_send_user_attribute_verification_code_options} - @Deprecated(_deprecatedMessage) - factory CognitoSendUserAttributeVerificationCodeOptions.fromJson( - Map json, - ) => - _$CognitoSendUserAttributeVerificationCodeOptionsFromJson(json); - - /// {@macro amplify_auth_cognito.model.cognito_send_user_attribute_verification_code_plugin_options.client_metadata} - final Map clientMetadata; - - @override - CognitoSendUserAttributeVerificationCodePluginOptions get pluginOptions => - CognitoSendUserAttributeVerificationCodePluginOptions( - clientMetadata: clientMetadata, - ); - - @override - String get runtimeTypeName => - 'CognitoSendUserAttributeVerificationCodeOptions'; - - @override - Map toJson() => - _$CognitoSendUserAttributeVerificationCodeOptionsToJson(this); -} - -/// {@macro amplify_auth_cognito.cognito_send_user_attribute_verification_code_options} -@Deprecated(_deprecatedMessage) -typedef CognitoResendUserAttributeConfirmationCodeOptions - = CognitoSendUserAttributeVerificationCodeOptions; diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_send_user_attribute_verification_code_options.g.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_send_user_attribute_verification_code_options.g.dart deleted file mode 100644 index f43b90c0b4..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_send_user_attribute_verification_code_options.g.dart +++ /dev/null @@ -1,23 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'cognito_send_user_attribute_verification_code_options.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -CognitoSendUserAttributeVerificationCodeOptions - _$CognitoSendUserAttributeVerificationCodeOptionsFromJson( - Map json) => - CognitoSendUserAttributeVerificationCodeOptions( - clientMetadata: - (json['clientMetadata'] as Map?)?.map( - (k, e) => MapEntry(k, e as String), - ), - ); - -Map _$CognitoSendUserAttributeVerificationCodeOptionsToJson( - CognitoSendUserAttributeVerificationCodeOptions instance) => - { - 'clientMetadata': instance.clientMetadata, - }; diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_send_user_attribute_verification_code_plugin_options.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_send_user_attribute_verification_code_plugin_options.dart index e7a0ee342e..d4f9033bc8 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_send_user_attribute_verification_code_plugin_options.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_send_user_attribute_verification_code_plugin_options.dart @@ -39,8 +39,3 @@ class CognitoSendUserAttributeVerificationCodePluginOptions Map toJson() => _$CognitoSendUserAttributeVerificationCodePluginOptionsToJson(this); } - -/// {@macro amplify_auth_cognito.model.cognito_send_user_attribute_verification_code_plugin_options} -@Deprecated('Use CognitoSendUserAttributeVerificationCodePluginOptions') -typedef CognitoResendUserAttributeConfirmationCodePluginOptions - = CognitoSendUserAttributeVerificationCodePluginOptions; diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_update_user_attribute_options.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_update_user_attribute_options.dart deleted file mode 100644 index b4e3267b07..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_update_user_attribute_options.dart +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -import 'package:amplify_auth_cognito_dart/amplify_auth_cognito_dart.dart'; -import 'package:amplify_core/amplify_core.dart'; - -part 'cognito_update_user_attribute_options.g.dart'; - -const _deprecatedMessage = ''' -Use UpdateUserAttributeOptions instead. If Cognito-specific options are needed, use `pluginOptions`: - -UpdateUserAttributeOptions( - pluginOptions: CognitoUpdateUserAttributePluginOptions( - clientMetadata: { - 'my-key': 'my-value', - }, - ), -) -'''; - -/// {@template amplify_auth_cognito.cognito_update_user_attribute_options} -/// Cognito options for `Amplify.Auth.updateUserAttribute`. -/// {@endtemplate} -@zAmplifySerializable -@Deprecated(_deprecatedMessage) -class CognitoUpdateUserAttributeOptions extends UpdateUserAttributeOptions { - /// {@macro amplify_auth_cognito.cognito_update_user_attribute_options} - @Deprecated(_deprecatedMessage) - const CognitoUpdateUserAttributeOptions({ - Map? clientMetadata, - }) : clientMetadata = clientMetadata ?? const {}; - - /// {@macro amplify_auth_cognito.cognito_update_user_attribute_options} - @Deprecated(_deprecatedMessage) - factory CognitoUpdateUserAttributeOptions.fromJson( - Map json, - ) => - _$CognitoUpdateUserAttributeOptionsFromJson(json); - - /// {@macro amplify_auth_cognito.model.cognito_update_user_attribute_plugin_options.client_metadata} - final Map clientMetadata; - - @override - CognitoUpdateUserAttributePluginOptions get pluginOptions => - CognitoUpdateUserAttributePluginOptions(clientMetadata: clientMetadata); - - @override - String get runtimeTypeName => 'CognitoUpdateUserAttributeOptions'; - - @override - Map toJson() => - _$CognitoUpdateUserAttributeOptionsToJson(this); -} diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_update_user_attribute_options.g.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_update_user_attribute_options.g.dart deleted file mode 100644 index 0eeb6415ee..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_update_user_attribute_options.g.dart +++ /dev/null @@ -1,21 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'cognito_update_user_attribute_options.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -CognitoUpdateUserAttributeOptions _$CognitoUpdateUserAttributeOptionsFromJson( - Map json) => - CognitoUpdateUserAttributeOptions( - clientMetadata: (json['clientMetadata'] as Map?)?.map( - (k, e) => MapEntry(k, e as String), - ), - ); - -Map _$CognitoUpdateUserAttributeOptionsToJson( - CognitoUpdateUserAttributeOptions instance) => - { - 'clientMetadata': instance.clientMetadata, - }; diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_update_user_attribute_step.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_update_user_attribute_step.dart deleted file mode 100644 index b549c7263e..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_update_user_attribute_step.dart +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -import 'package:amplify_core/amplify_core.dart'; - -/// {@macro amplify_core.auth.auth_update_attribute_step} -@Deprecated(''' -Use AuthUpdateAttributeStep instead. These steps are generic and not specific -to Cognito. -''') -typedef CognitoUpdateUserAttributeStep = AuthUpdateAttributeStep; diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_update_user_attributes_options.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_update_user_attributes_options.dart deleted file mode 100644 index 7bd03d3435..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_update_user_attributes_options.dart +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -import 'package:amplify_auth_cognito_dart/amplify_auth_cognito_dart.dart'; -import 'package:amplify_core/amplify_core.dart'; - -part 'cognito_update_user_attributes_options.g.dart'; - -const _deprecatedMessage = ''' -Use UpdateUserAttributesOptions instead. If Cognito-specific options are needed, use `pluginOptions`: - -UpdateUserAttributesOptions( - pluginOptions: CognitoUpdateUserAttributesPluginOptions( - clientMetadata: { - 'my-key': 'my-value', - }, - ), -) -'''; - -/// {@template amplify_auth_cognito.cognito_update_user_attributes_options} -/// Cognito extension of [UpdateUserAttributesOptions] to add the platform -/// specific fields. -/// {@endtemplate} -@zAmplifySerializable -@Deprecated(_deprecatedMessage) -class CognitoUpdateUserAttributesOptions extends UpdateUserAttributesOptions { - /// {@macro amplify_auth_cognito.cognito_update_user_attributes_options} - @Deprecated(_deprecatedMessage) - const CognitoUpdateUserAttributesOptions({ - Map? clientMetadata, - }) : clientMetadata = clientMetadata ?? const {}; - - /// {@macro amplify_auth_cognito.cognito_update_user_attributes_options} - @Deprecated(_deprecatedMessage) - factory CognitoUpdateUserAttributesOptions.fromJson( - Map json, - ) => - _$CognitoUpdateUserAttributesOptionsFromJson(json); - - /// {@macro amplify_auth_cognito.model.cognito_update_user_attributes_plugin_options.client_metadata} - final Map clientMetadata; - - @override - CognitoUpdateUserAttributesPluginOptions get pluginOptions => - CognitoUpdateUserAttributesPluginOptions(clientMetadata: clientMetadata); - - @override - String get runtimeTypeName => 'CognitoUpdateUserAttributesOptions'; - - @override - Map toJson() => - _$CognitoUpdateUserAttributesOptionsToJson(this); -} diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_update_user_attributes_options.g.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_update_user_attributes_options.g.dart deleted file mode 100644 index 484205ed24..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/attribute/cognito_update_user_attributes_options.g.dart +++ /dev/null @@ -1,21 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'cognito_update_user_attributes_options.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -CognitoUpdateUserAttributesOptions _$CognitoUpdateUserAttributesOptionsFromJson( - Map json) => - CognitoUpdateUserAttributesOptions( - clientMetadata: (json['clientMetadata'] as Map?)?.map( - (k, e) => MapEntry(k, e as String), - ), - ); - -Map _$CognitoUpdateUserAttributesOptionsToJson( - CognitoUpdateUserAttributesOptions instance) => - { - 'clientMetadata': instance.clientMetadata, - }; diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/password/cognito_confirm_reset_password_options.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/password/cognito_confirm_reset_password_options.dart deleted file mode 100644 index eef71f690a..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/password/cognito_confirm_reset_password_options.dart +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -import 'package:amplify_auth_cognito_dart/amplify_auth_cognito_dart.dart'; -import 'package:amplify_core/amplify_core.dart'; - -part 'cognito_confirm_reset_password_options.g.dart'; - -const _deprecatedMessage = ''' -Use ConfirmResetPasswordOptions instead. If Cognito-specific options are needed, use `pluginOptions`: - -ConfirmResetPasswordOptions( - pluginOptions: CognitoConfirmResetPasswordPluginOptions( - clientMetadata: { - 'my-key': 'my-value', - }, - ), -) -'''; - -/// {@template amplify_auth_cognito.cognito_confirm_reset_password_options} -/// Cognito extension of [ConfirmResetPasswordOptions] to add the -/// platform-specific fields. -/// -/// Can be used to add [clientMetadata] to the operation. -/// {@endtemplate} -@zAmplifySerializable -@Deprecated(_deprecatedMessage) -class CognitoConfirmResetPasswordOptions extends ConfirmResetPasswordOptions { - /// {@macro amplify_auth_cognito.cognito_confirm_reset_password_options} - @Deprecated(_deprecatedMessage) - const CognitoConfirmResetPasswordOptions({ - Map? clientMetadata, - }) : clientMetadata = clientMetadata ?? const {}; - - /// {@macro amplify_auth_cognito.cognito_confirm_reset_password_options} - @Deprecated(_deprecatedMessage) - factory CognitoConfirmResetPasswordOptions.fromJson( - Map json, - ) => - _$CognitoConfirmResetPasswordOptionsFromJson(json); - - /// Additional custom attributes to be sent to the service such as information - /// about the client. - final Map clientMetadata; - - @override - CognitoConfirmResetPasswordPluginOptions get pluginOptions => - CognitoConfirmResetPasswordPluginOptions(clientMetadata: clientMetadata); - - @override - String get runtimeTypeName => 'CognitoConfirmResetPasswordOptions'; - - @override - Map toJson() => - _$CognitoConfirmResetPasswordOptionsToJson(this); -} diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/password/cognito_confirm_reset_password_options.g.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/password/cognito_confirm_reset_password_options.g.dart deleted file mode 100644 index 8cd5043920..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/password/cognito_confirm_reset_password_options.g.dart +++ /dev/null @@ -1,21 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'cognito_confirm_reset_password_options.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -CognitoConfirmResetPasswordOptions _$CognitoConfirmResetPasswordOptionsFromJson( - Map json) => - CognitoConfirmResetPasswordOptions( - clientMetadata: (json['clientMetadata'] as Map?)?.map( - (k, e) => MapEntry(k, e as String), - ), - ); - -Map _$CognitoConfirmResetPasswordOptionsToJson( - CognitoConfirmResetPasswordOptions instance) => - { - 'clientMetadata': instance.clientMetadata, - }; diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/password/cognito_reset_password_options.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/password/cognito_reset_password_options.dart deleted file mode 100644 index 52ab301b21..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/password/cognito_reset_password_options.dart +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -import 'package:amplify_auth_cognito_dart/amplify_auth_cognito_dart.dart'; -import 'package:amplify_core/amplify_core.dart'; - -part 'cognito_reset_password_options.g.dart'; - -const _deprecatedMessage = ''' -Use ResetPasswordOptions instead. If Cognito-specific options are needed, use `pluginOptions`: - -ResetPasswordOptions( - pluginOptions: CognitoResetPasswordPluginOptions( - clientMetadata: { - 'my-key': 'my-value', - }, - ), -) -'''; - -/// {@template amplify_auth_cognito.cognito_reset_password_options} -/// Cognito extension of [ResetPasswordOptions] to add the -/// platform-specific fields. -/// -/// Can be used to add [clientMetadata] to the operation. -/// {@endtemplate} -@zAmplifySerializable -@Deprecated(_deprecatedMessage) -class CognitoResetPasswordOptions extends ResetPasswordOptions { - /// {@macro amplify_auth_cognito.cognito_reset_password_options} - @Deprecated(_deprecatedMessage) - const CognitoResetPasswordOptions({ - Map? clientMetadata, - }) : clientMetadata = clientMetadata ?? const {}; - - /// {@macro amplify_auth_cognito.cognito_reset_password_options} - @Deprecated(_deprecatedMessage) - factory CognitoResetPasswordOptions.fromJson(Map json) => - _$CognitoResetPasswordOptionsFromJson(json); - - /// Additional custom attributes to be sent to the service such as information - /// about the client. - final Map clientMetadata; - - @override - CognitoResetPasswordPluginOptions get pluginOptions => - CognitoResetPasswordPluginOptions(clientMetadata: clientMetadata); - - @override - String get runtimeTypeName => 'CognitoResetPasswordOptions'; - - @override - Map toJson() => _$CognitoResetPasswordOptionsToJson(this); -} diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/password/cognito_reset_password_options.g.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/password/cognito_reset_password_options.g.dart deleted file mode 100644 index dc7d701eaa..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/password/cognito_reset_password_options.g.dart +++ /dev/null @@ -1,21 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'cognito_reset_password_options.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -CognitoResetPasswordOptions _$CognitoResetPasswordOptionsFromJson( - Map json) => - CognitoResetPasswordOptions( - clientMetadata: (json['clientMetadata'] as Map?)?.map( - (k, e) => MapEntry(k, e as String), - ), - ); - -Map _$CognitoResetPasswordOptionsToJson( - CognitoResetPasswordOptions instance) => - { - 'clientMetadata': instance.clientMetadata, - }; diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/session/cognito_auth_session.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/session/cognito_auth_session.dart index 0667672dab..c8fa3d0b44 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/session/cognito_auth_session.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/model/session/cognito_auth_session.dart @@ -33,22 +33,6 @@ class CognitoAuthSession extends AuthSession /// The AWS identity ID Result. final AuthResult identityIdResult; - /// The AWS credentials. - @Deprecated('Use `credentialsResult.value` instead') - AWSCredentials? get credentials => credentialsResult.valueOrNull; - - /// The User Pool tokens. - @Deprecated('Use `userPoolTokensResult.value` instead') - CognitoUserPoolTokens? get userPoolTokens => userPoolTokensResult.valueOrNull; - - /// The user ID (subject). - @Deprecated('Use `userSubResult.value` instead') - String? get userSub => userSubResult.valueOrNull; - - /// The AWS identity ID. - @Deprecated('Use `identityIdResult.value` instead') - String? get identityId => identityIdResult.valueOrNull; - @override List get props => [ userPoolTokensResult, diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/session/cognito_fetch_auth_session_options.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/session/cognito_fetch_auth_session_options.dart deleted file mode 100644 index 9a42538bd5..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/session/cognito_fetch_auth_session_options.dart +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -import 'package:amplify_core/amplify_core.dart'; - -part 'cognito_fetch_auth_session_options.g.dart'; - -const _deprecatedMessage = 'Use FetchAuthSessionOptions instead.'; - -const _getAWSCredentialsDeprecation = '`getAWSCredentials` is ignored. AWS ' - 'Credentials will always be retrieved. `credentialsResult` will contain ' - 'the result of retrieving credentials, which may be an error'; - -/// {@macro amplify_auth_cognito.model.cognito_fetch_auth_session_options} -@Deprecated('Use CognitoFetchAuthSessionOptions instead') -// ignore: deprecated_member_use_from_same_package -typedef CognitoSessionOptions = CognitoFetchAuthSessionOptions; - -/// {@template amplify_auth_cognito.model.cognito_fetch_auth_session_options} -/// Cognito options for `Amplify.Auth.fetchAuthSession`. -/// {@endtemplate} -@zAmplifySerializable -@Deprecated(_deprecatedMessage) -class CognitoFetchAuthSessionOptions extends FetchAuthSessionOptions { - /// {@macro amplify_auth_cognito.model.cognito_fetch_auth_session_options} - @Deprecated(_deprecatedMessage) - const CognitoFetchAuthSessionOptions({ - // ignore: avoid_unused_constructor_parameters - @Deprecated(_getAWSCredentialsDeprecation) bool? getAWSCredentials = false, - super.forceRefresh = false, - }); - - /// {@macro amplify_auth_cognito.model.cognito_fetch_auth_session_options} - @Deprecated(_deprecatedMessage) - factory CognitoFetchAuthSessionOptions.fromJson(Map json) => - _$CognitoFetchAuthSessionOptionsFromJson(json); - - @override - FetchAuthSessionPluginOptions? get pluginOptions => null; - - @override - String get runtimeTypeName => 'CognitoFetchAuthSessionOptions'; - - @override - Map toJson() => _$CognitoFetchAuthSessionOptionsToJson(this); -} diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/session/cognito_fetch_auth_session_options.g.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/session/cognito_fetch_auth_session_options.g.dart deleted file mode 100644 index 9f74aedda2..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/session/cognito_fetch_auth_session_options.g.dart +++ /dev/null @@ -1,19 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'cognito_fetch_auth_session_options.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -CognitoFetchAuthSessionOptions _$CognitoFetchAuthSessionOptionsFromJson( - Map json) => - CognitoFetchAuthSessionOptions( - forceRefresh: json['forceRefresh'] as bool? ?? false, - ); - -Map _$CognitoFetchAuthSessionOptionsToJson( - CognitoFetchAuthSessionOptions instance) => - { - 'forceRefresh': instance.forceRefresh, - }; diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/session/cognito_user_pool_tokens.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/session/cognito_user_pool_tokens.dart index ece405cf64..c7c1780b17 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/session/cognito_user_pool_tokens.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/model/session/cognito_user_pool_tokens.dart @@ -8,10 +8,6 @@ import 'package:json_annotation/json_annotation.dart'; part 'cognito_user_pool_tokens.g.dart'; -/// {@macro amplify_auth_dart.cognito_user_pool_tokens} -@Deprecated('Use CognitoUserPoolTokens instead') -typedef AWSCognitoUserPoolTokens = CognitoUserPoolTokens; - /// {@template amplify_auth_dart.cognito_user_pool_tokens} /// Cognito credentials of the active user. /// {@endtemplate} diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_confirm_sign_in_options.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_confirm_sign_in_options.dart deleted file mode 100644 index dc162a7d88..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_confirm_sign_in_options.dart +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -import 'package:amplify_auth_cognito_dart/amplify_auth_cognito_dart.dart'; - -const _deprecatedMessage = ''' -Use ConfirmSignInOptions instead. If Cognito-specific options are needed, use `pluginOptions`: - -ConfirmSignInOptions( - pluginOptions: CognitoConfirmSignInPluginOptions( - clientMetadata: { - 'my-key': 'my-value', - }, - ), -) -'''; - -/// {@template amplify_auth_cognito.model.cognito_confirm_sign_in_options} -/// Cognito options for `Amplify.Auth.confirmSignIn`. -/// {@endtemplate} -@Deprecated(_deprecatedMessage) -class CognitoConfirmSignInOptions extends ConfirmSignInOptions { - /// {@macro amplify_auth_cognito.model.cognito_confirm_sign_in_options} - @Deprecated(_deprecatedMessage) - const CognitoConfirmSignInOptions({ - Map? clientMetadata, - Map? userAttributes, - this.friendlyDeviceName, - }) : clientMetadata = clientMetadata ?? const {}, - userAttributes = userAttributes ?? const {}; - - /// A map of custom key-value pairs that you can provide as input for certain - /// custom workflows that this action triggers. - final Map clientMetadata; - - /// User attributes which were marked as required and have not been previously - /// provided. - final Map userAttributes; - - /// A unique name to help identify the registered TOTP device. - final String? friendlyDeviceName; - - @override - CognitoConfirmSignInPluginOptions get pluginOptions => - CognitoConfirmSignInPluginOptions( - clientMetadata: clientMetadata, - userAttributes: userAttributes, - friendlyDeviceName: friendlyDeviceName, - ); - - @override - List get props => [ - clientMetadata, - userAttributes, - friendlyDeviceName, - ]; - - @override - String get runtimeTypeName => 'CognitoConfirmSignInOptions'; -} diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_sign_in_options.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_sign_in_options.dart deleted file mode 100644 index 24b55bf46e..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_sign_in_options.dart +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -import 'package:amplify_auth_cognito_dart/amplify_auth_cognito_dart.dart'; -import 'package:amplify_core/amplify_core.dart'; - -part 'cognito_sign_in_options.g.dart'; - -const _deprecatedMessage = ''' -Use SignInOptions instead. If Cognito-specific options are needed, use `pluginOptions`: - -SignInOptions( - pluginOptions: CognitoSignInPluginOptions( - clientMetadata: { - 'my-key': 'my-value', - }, - ), -) -'''; - -/// {@macro amplify_auth_cognito.model.cognito_sign_in_plugin_options} -@zAmplifySerializable -@Deprecated(_deprecatedMessage) -class CognitoSignInOptions extends SignInOptions { - /// {@macro amplify_auth_cognito.model.cognito_sign_in_plugin_options} - @Deprecated(_deprecatedMessage) - const CognitoSignInOptions({ - this.authFlowType, - this.clientMetadata = const {}, - }); - - /// {@macro amplify_auth_cognito.model.cognito_sign_in_plugin_options} - @Deprecated(_deprecatedMessage) - factory CognitoSignInOptions.fromJson(Map json) => - _$CognitoSignInOptionsFromJson(json); - - /// {@macro amplify_auth_cognito_dart.cognito_sign_in_plugin_options.auth_flow_type} - final AuthenticationFlowType? authFlowType; - - /// {@macro amplify_auth_cognito_dart.cognito_sign_in_plugin_options.client_metadata} - final Map clientMetadata; - - @override - CognitoSignInPluginOptions get pluginOptions => CognitoSignInPluginOptions( - authFlowType: authFlowType, - clientMetadata: clientMetadata, - ); - - @override - String get runtimeTypeName => 'CognitoSignInOptions'; - - @override - Map toJson() => _$CognitoSignInOptionsToJson(this); -} diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_sign_in_options.g.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_sign_in_options.g.dart deleted file mode 100644 index 6dfb7f95a1..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_sign_in_options.g.dart +++ /dev/null @@ -1,42 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'cognito_sign_in_options.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -CognitoSignInOptions _$CognitoSignInOptionsFromJson( - Map json) => - CognitoSignInOptions( - authFlowType: $enumDecodeNullable( - _$AuthenticationFlowTypeEnumMap, json['authFlowType']), - clientMetadata: (json['clientMetadata'] as Map?)?.map( - (k, e) => MapEntry(k, e as String), - ) ?? - const {}, - ); - -Map _$CognitoSignInOptionsToJson( - CognitoSignInOptions instance) { - final val = {}; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull( - 'authFlowType', _$AuthenticationFlowTypeEnumMap[instance.authFlowType]); - val['clientMetadata'] = instance.clientMetadata; - return val; -} - -const _$AuthenticationFlowTypeEnumMap = { - AuthenticationFlowType.userSrpAuth: 'USER_SRP_AUTH', - AuthenticationFlowType.userPasswordAuth: 'USER_PASSWORD_AUTH', - AuthenticationFlowType.customAuth: 'CUSTOM_AUTH', - AuthenticationFlowType.customAuthWithSrp: 'CUSTOM_AUTH_WITH_SRP', - AuthenticationFlowType.customAuthWithoutSrp: 'CUSTOM_AUTH_WITHOUT_SRP', -}; diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_sign_in_plugin_options.g.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_sign_in_plugin_options.g.dart index 0a9a24a446..7cf95cfd65 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_sign_in_plugin_options.g.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_sign_in_plugin_options.g.dart @@ -36,7 +36,6 @@ Map _$CognitoSignInPluginOptionsToJson( const _$AuthenticationFlowTypeEnumMap = { AuthenticationFlowType.userSrpAuth: 'USER_SRP_AUTH', AuthenticationFlowType.userPasswordAuth: 'USER_PASSWORD_AUTH', - AuthenticationFlowType.customAuth: 'CUSTOM_AUTH', AuthenticationFlowType.customAuthWithSrp: 'CUSTOM_AUTH_WITH_SRP', AuthenticationFlowType.customAuthWithoutSrp: 'CUSTOM_AUTH_WITHOUT_SRP', }; diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_sign_in_step.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_sign_in_step.dart deleted file mode 100644 index 7def7d247c..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_sign_in_step.dart +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -import 'package:amplify_core/amplify_core.dart'; - -/// {@macro amplify_core.auth.auth_sign_in_step} -@Deprecated(''' -Use AuthSignInStep instead. These steps are generic and not specific to Cognito. -''') -typedef CognitoSignInStep = AuthSignInStep; diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_sign_in_with_web_ui_options.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_sign_in_with_web_ui_options.dart deleted file mode 100644 index ae8dd7c134..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_sign_in_with_web_ui_options.dart +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -import 'package:amplify_auth_cognito_dart/amplify_auth_cognito_dart.dart'; -import 'package:amplify_core/amplify_core.dart'; - -part 'cognito_sign_in_with_web_ui_options.g.dart'; - -const _deprecatedMessage = ''' -Use SignInWithWebUIOptions instead. If Cognito-specific options are needed, use `pluginOptions`: - -SignInWithWebUIOptions( - pluginOptions: CognitoSignInWithWebUIPluginOptions( - isPreferPrivateSession: true, - ), -) -'''; - -/// {@template amplify_auth_cognito.model.cognito_sign_in_with_web_ui_options} -/// Cognito options for `Amplify.Auth.signInWithWebUI`. -/// {@endtemplate} -@zAmplifySerializable -@Deprecated(_deprecatedMessage) -class CognitoSignInWithWebUIOptions extends SignInWithWebUIOptions { - /// {@macro amplify_auth_cognito.model.cognito_sign_in_with_web_ui_options} - @Deprecated(_deprecatedMessage) - const CognitoSignInWithWebUIOptions({ - this.isPreferPrivateSession = false, - this.browserPackageName, - }); - - /// {@macro amplify_auth_cognito.model.cognito_sign_in_with_web_ui_options} - @Deprecated(_deprecatedMessage) - factory CognitoSignInWithWebUIOptions.fromJson(Map json) => - _$CognitoSignInWithWebUIOptionsFromJson(json); - - /// {@macro amplify_auth_cognito.model.cognito_sign_in_with_web_ui_options.private_session} - final bool isPreferPrivateSession; - - /// {@macro amplify_auth_cognito.model.cognito_sign_in_with_web_ui_options.browser_package_name} - final String? browserPackageName; - - @override - CognitoSignInWithWebUIPluginOptions get pluginOptions => - CognitoSignInWithWebUIPluginOptions( - isPreferPrivateSession: isPreferPrivateSession, - browserPackageName: browserPackageName, - ); - - @override - String get runtimeTypeName => 'CognitoSignInWithWebUIOptions'; - - @override - Map toJson() => _$CognitoSignInWithWebUIOptionsToJson(this); -} diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_sign_in_with_web_ui_options.g.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_sign_in_with_web_ui_options.g.dart deleted file mode 100644 index 998c1a9c44..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signin/cognito_sign_in_with_web_ui_options.g.dart +++ /dev/null @@ -1,30 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'cognito_sign_in_with_web_ui_options.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -CognitoSignInWithWebUIOptions _$CognitoSignInWithWebUIOptionsFromJson( - Map json) => - CognitoSignInWithWebUIOptions( - isPreferPrivateSession: json['isPreferPrivateSession'] as bool? ?? false, - browserPackageName: json['browserPackageName'] as String?, - ); - -Map _$CognitoSignInWithWebUIOptionsToJson( - CognitoSignInWithWebUIOptions instance) { - final val = { - 'isPreferPrivateSession': instance.isPreferPrivateSession, - }; - - void writeNotNull(String key, dynamic value) { - if (value != null) { - val[key] = value; - } - } - - writeNotNull('browserPackageName', instance.browserPackageName); - return val; -} diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_confirm_sign_up_options.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_confirm_sign_up_options.dart deleted file mode 100644 index 5a22955ef5..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_confirm_sign_up_options.dart +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -import 'package:amplify_auth_cognito_dart/amplify_auth_cognito_dart.dart'; -import 'package:amplify_core/amplify_core.dart'; - -part 'cognito_confirm_sign_up_options.g.dart'; - -const _deprecatedMessage = ''' -Use ConfirmSignUpOptions instead. If Cognito-specific options are needed, use `pluginOptions`: - -ConfirmSignUpOptions( - pluginOptions: CognitoConfirmSignUpPluginOptions( - clientMetadata: { - 'my-key': 'my-value', - }, - ), -) -'''; - -/// {@template amplify_auth_cognito_dart.cognito_confirm_sign_up_options} -/// Options passed to `Amplify.Auth.confirmSignUp`. -/// {@endtemplate} -@zAmplifySerializable -@Deprecated(_deprecatedMessage) -class CognitoConfirmSignUpOptions extends ConfirmSignUpOptions { - /// {@macro amplify_auth_cognito_dart.cognito_confirm_sign_up_options} - @Deprecated(_deprecatedMessage) - const CognitoConfirmSignUpOptions({ - this.clientMetadata = const {}, - }); - - /// {@macro amplify_auth_cognito_dart.cognito_confirm_sign_up_options} - @Deprecated(_deprecatedMessage) - factory CognitoConfirmSignUpOptions.fromJson(Map json) => - _$CognitoConfirmSignUpOptionsFromJson(json); - - /// {@macro amplify_auth_cognito_dart.cognito_confirm_sign_up_plugin_options.client_metadata} - final Map clientMetadata; - - @override - CognitoConfirmSignUpPluginOptions get pluginOptions => - CognitoConfirmSignUpPluginOptions(clientMetadata: clientMetadata); - - @override - String get runtimeTypeName => 'CognitoConfirmSignUpOptions'; - - @override - Map toJson() => _$CognitoConfirmSignUpOptionsToJson(this); -} diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_confirm_sign_up_options.g.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_confirm_sign_up_options.g.dart deleted file mode 100644 index 3dc6285f8b..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_confirm_sign_up_options.g.dart +++ /dev/null @@ -1,22 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'cognito_confirm_sign_up_options.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -CognitoConfirmSignUpOptions _$CognitoConfirmSignUpOptionsFromJson( - Map json) => - CognitoConfirmSignUpOptions( - clientMetadata: (json['clientMetadata'] as Map?)?.map( - (k, e) => MapEntry(k, e as String), - ) ?? - const {}, - ); - -Map _$CognitoConfirmSignUpOptionsToJson( - CognitoConfirmSignUpOptions instance) => - { - 'clientMetadata': instance.clientMetadata, - }; diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_resend_sign_up_code_options.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_resend_sign_up_code_options.dart deleted file mode 100644 index dcffc20070..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_resend_sign_up_code_options.dart +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -import 'package:amplify_auth_cognito_dart/amplify_auth_cognito_dart.dart'; -import 'package:amplify_core/amplify_core.dart'; - -part 'cognito_resend_sign_up_code_options.g.dart'; - -const _deprecatedMessage = ''' -Use ResendSignUpCodeOptions instead. If Cognito-specific options are needed, use `pluginOptions`: - -ResendSignUpCodeOptions( - pluginOptions: CognitoResendSignUpCodePluginOptions( - clientMetadata: { - 'my-key': 'my-value', - }, - ), -) -'''; - -/// {@template amplify_auth_cognito.cognito_resend_sign_up_code_options} -/// Cognito extension of [ResendSignUpCodeOptions] to add the -/// platform-specific fields. -/// {@endtemplate} -@zAmplifySerializable -@Deprecated(_deprecatedMessage) -class CognitoResendSignUpCodeOptions extends ResendSignUpCodeOptions { - /// {@macro amplify_auth_cognito.cognito_resend_sign_up_code_options} - @Deprecated(_deprecatedMessage) - const CognitoResendSignUpCodeOptions({ - this.clientMetadata = const {}, - }); - - /// {@macro amplify_auth_cognito_dart.model.cognito_resend_sign_up_code_plugin_options.client_metadata} - final Map clientMetadata; - - @override - CognitoResendSignUpCodePluginOptions get pluginOptions => - CognitoResendSignUpCodePluginOptions(clientMetadata: clientMetadata); - - @override - String get runtimeTypeName => 'CognitoResendSignUpCodeOptions'; -} diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_resend_sign_up_code_options.g.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_resend_sign_up_code_options.g.dart deleted file mode 100644 index f2f084ee47..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_resend_sign_up_code_options.g.dart +++ /dev/null @@ -1,22 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'cognito_resend_sign_up_code_options.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -CognitoResendSignUpCodeOptions _$CognitoResendSignUpCodeOptionsFromJson( - Map json) => - CognitoResendSignUpCodeOptions( - clientMetadata: (json['clientMetadata'] as Map?)?.map( - (k, e) => MapEntry(k, e as String), - ) ?? - const {}, - ); - -Map _$CognitoResendSignUpCodeOptionsToJson( - CognitoResendSignUpCodeOptions instance) => - { - 'clientMetadata': instance.clientMetadata, - }; diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_sign_up_options.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_sign_up_options.dart deleted file mode 100644 index ce67fc06a7..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_sign_up_options.dart +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -import 'package:amplify_auth_cognito_dart/amplify_auth_cognito_dart.dart'; -import 'package:amplify_core/amplify_core.dart'; - -part 'cognito_sign_up_options.g.dart'; - -const _deprecatedMessage = ''' -Use SignUpOptions instead. If Cognito-specific options are needed, use `pluginOptions`: - -SignUpOptions( - userAttributes: { - CognitoUserAttributeKey.email: 'test@example.com', - }, - pluginOptions: CognitoSignUpPluginOptions( - clientMetadata: { - 'my-key': 'my-value', - }, - ), -) -'''; - -/// {@macro amplify_auth_cognito.model.cognito_sign_up_plugin_options} -@zAmplifySerializable -@Deprecated(_deprecatedMessage) -class CognitoSignUpOptions extends SignUpOptions { - /// {@macro amplify_auth_cognito.model.cognito_sign_up_plugin_options} - @Deprecated(_deprecatedMessage) - CognitoSignUpOptions({ - Map userAttributes = const {}, - Map? validationData, - Map? clientMetadata, - }) : validationData = validationData ?? const {}, - clientMetadata = clientMetadata ?? const {}, - userAttributes = Map.of(userAttributes) - ..removeWhere((key, value) => key.readOnly); - - /// {@macro amplify_auth_cognito.model.cognito_sign_up_plugin_options} - @Deprecated(_deprecatedMessage) - factory CognitoSignUpOptions.fromJson(Map json) => - _$CognitoSignUpOptionsFromJson(json); - - @override - // ignore: overridden_fields - final Map userAttributes; - - /// {@macro amplify_auth_cognito_dart.cognito_sign_up_options.validation_data} - final Map validationData; - - /// {@macro amplify_auth_cognito_dart.cognito_sign_up_options.client_metadata} - final Map clientMetadata; - - @override - CognitoSignUpPluginOptions get pluginOptions => CognitoSignUpPluginOptions( - clientMetadata: clientMetadata, - validationData: validationData, - ); - - @override - String get runtimeTypeName => 'CognitoSignUpOptions'; - - @override - Map toJson() => _$CognitoSignUpOptionsToJson(this); -} diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_sign_up_options.g.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_sign_up_options.g.dart deleted file mode 100644 index c7b8c6f8b3..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_sign_up_options.g.dart +++ /dev/null @@ -1,31 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'cognito_sign_up_options.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -CognitoSignUpOptions _$CognitoSignUpOptionsFromJson( - Map json) => - CognitoSignUpOptions( - userAttributes: json['userAttributes'] == null - ? const {} - : const CognitoUserAttributeMapConverter() - .fromJson(json['userAttributes'] as Map), - validationData: (json['validationData'] as Map?)?.map( - (k, e) => MapEntry(k, e as String), - ), - clientMetadata: (json['clientMetadata'] as Map?)?.map( - (k, e) => MapEntry(k, e as String), - ), - ); - -Map _$CognitoSignUpOptionsToJson( - CognitoSignUpOptions instance) => - { - 'userAttributes': const CognitoUserAttributeMapConverter() - .toJson(instance.userAttributes), - 'validationData': instance.validationData, - 'clientMetadata': instance.clientMetadata, - }; diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_sign_up_step.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_sign_up_step.dart deleted file mode 100644 index 5a1441d68f..0000000000 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/model/signup/cognito_sign_up_step.dart +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -import 'package:amplify_core/amplify_core.dart'; - -/// {@macro amplify_core.auth.auth_sign_up_step} -@Deprecated(''' -Use AuthSignUpStep instead. These steps are generic and not specific to Cognito. -''') -typedef CognitoSignUpStep = AuthSignUpStep; 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 d3f276939d..5c81717008 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 @@ -93,8 +93,6 @@ extension AuthenticationFlowTypeBridge on AuthenticationFlowType { /// The Cognito SDK value of `this`. AuthFlowType get sdkValue => switch (this) { AuthenticationFlowType.userSrpAuth => AuthFlowType.userSrpAuth, - // ignore: deprecated_member_use - AuthenticationFlowType.customAuth || AuthenticationFlowType.customAuthWithSrp || AuthenticationFlowType.customAuthWithoutSrp => AuthFlowType.customAuth, 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 4056a52582..b7cd0514e7 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 @@ -88,26 +88,6 @@ final class UnknownServiceException extends CognitoServiceException String get runtimeTypeName => 'UnknownServiceException'; } -/// Exception thrown when a verification code provided to the requested service -/// is expired. -@Deprecated('Use ExpiredCodeException instead') -typedef CodeExpiredException = ExpiredCodeException; - -/// Exception thrown when the software token time-based one-time password (TOTP) -/// multi-factor authentication (MFA) isn't activated for the user pool. -@Deprecated('Use SoftwareTokenMfaNotFoundException instead') -typedef SoftwareTokenMFANotFoundException = SoftwareTokenMfaNotFoundException; - -/// Exception thrown when too many failed attempts for a given action has been -/// made, such as sign-in. -@Deprecated('Use TooManyFailedAttemptsException instead') -typedef FailedAttemptsLimitExceededException = TooManyFailedAttemptsException; - -/// Exception thrown when the requested service cannot find a multi-factor -/// authentication (MFA) method. -@Deprecated('Use MfaMethodNotFoundException instead') -typedef MFAMethodNotFoundException = MfaMethodNotFoundException; - /// {@template amplify_auth_cognito_dart.sdk_exception.alias_exists_exception} /// This exception is thrown when a user tries to confirm the account with an email address or phone number that has already been supplied as an alias for a different user profile. This exception indicates that an account with this email address or phone already exists in a user pool that you've configured to use email address or phone number as a sign-in alias. /// {@endtemplate} 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 714b178016..691575f92a 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 @@ -56,15 +56,6 @@ final class SignInStateMachine /// Flow used to sign in. late AuthFlowType authFlowType; - /// The default flow used to sign in. - late final AuthFlowType defaultAuthFlowType = () { - // Get the flow from the plugin config - final pluginFlowType = - expect().auth?.default$?.authenticationFlowType ?? - AuthenticationFlowType.userSrpAuth; - return pluginFlowType.sdkValue; - }(); - /// Parameters to the flow. late SignInParameters parameters; @@ -291,7 +282,8 @@ final class SignInStateMachine return password; } - authFlowType = event.authFlowType?.sdkValue ?? defaultAuthFlowType; + authFlowType = event.authFlowType?.sdkValue ?? + AuthenticationFlowType.userSrpAuth.sdkValue; return switch (authFlowType) { AuthFlowType.userSrpAuth => () { expectPassword(); @@ -551,8 +543,6 @@ final class SignInStateMachine 'Do not include a password in your call to Amplify.Auth.signIn', ); } - // ignore: deprecated_member_use - case AuthenticationFlowType.customAuth: default: break; } diff --git a/packages/auth/amplify_auth_cognito_dart/tool/generate_sdk_exceptions.dart b/packages/auth/amplify_auth_cognito_dart/tool/generate_sdk_exceptions.dart index 1fc70a696a..20cf3da1a9 100644 --- a/packages/auth/amplify_auth_cognito_dart/tool/generate_sdk_exceptions.dart +++ b/packages/auth/amplify_auth_cognito_dart/tool/generate_sdk_exceptions.dart @@ -115,27 +115,6 @@ final class UnknownServiceException extends CognitoServiceException String get runtimeTypeName => 'UnknownServiceException'; } -/// Exception thrown when a verification code provided to the requested service -/// is expired. -@Deprecated('Use ExpiredCodeException instead') -typedef CodeExpiredException = ExpiredCodeException; - -/// Exception thrown when the software token time-based one-time password (TOTP) -/// multi-factor authentication (MFA) isn't activated for the user pool. -@Deprecated('Use SoftwareTokenMfaNotFoundException instead') -typedef SoftwareTokenMFANotFoundException - = SoftwareTokenMfaNotFoundException; - -/// Exception thrown when too many failed attempts for a given action has been -/// made, such as sign-in. -@Deprecated('Use TooManyFailedAttemptsException instead') -typedef FailedAttemptsLimitExceededException - = TooManyFailedAttemptsException; - -/// Exception thrown when the requested service cannot find a multi-factor -/// authentication (MFA) method. -@Deprecated('Use MfaMethodNotFoundException instead') -typedef MFAMethodNotFoundException = MfaMethodNotFoundException; '''); // Collect errors diff --git a/packages/auth/amplify_auth_cognito_test/test/state/sign_in_state_machine_test.dart b/packages/auth/amplify_auth_cognito_test/test/state/sign_in_state_machine_test.dart index a96e088155..c5bfbb87cc 100644 --- a/packages/auth/amplify_auth_cognito_test/test/state/sign_in_state_machine_test.dart +++ b/packages/auth/amplify_auth_cognito_test/test/state/sign_in_state_machine_test.dart @@ -33,71 +33,6 @@ void main() { ..addInstance(secureStorage); }); - test('can change flow at runtime', () async { - const config = AmplifyConfig( - auth: AuthConfig( - plugins: { - CognitoPluginConfig.pluginKey: CognitoPluginConfig( - auth: AWSConfigMap( - { - 'Default': CognitoAuthConfig( - authenticationFlowType: AuthenticationFlowType.userSrpAuth, - ), - }, - ), - cognitoUserPool: AWSConfigMap( - { - 'Default': CognitoUserPoolConfig( - poolId: testUserPoolId, - appClientId: testAppClientId, - region: testRegion, - ), - }, - ), - ), - }, - ), - ); - stateMachine - .dispatch( - const ConfigurationEvent.configure(config), - ) - .ignore(); - await expectLater( - stateMachine.stream.whereType().firstWhere( - (event) => event is Configured || event is ConfigureFailure, - ), - completion(isA()), - ); - - final mockClient = MockCognitoIdentityProviderClient( - initiateAuth: expectAsync1( - (_) async => cognito_idp.InitiateAuthResponse( - challengeName: cognito_idp.ChallengeNameType.customChallenge, - ), - ), - ); - stateMachine - ..addInstance(mockClient) - ..dispatch( - SignInEvent.initiate( - authFlowType: AuthenticationFlowType.customAuthWithSrp, - parameters: SignInParameters( - (p) => p - ..username = 'username' - ..password = 'password', - ), - ), - ).ignore(); - - final signInStateMachine = stateMachine.expect(SignInStateMachine.type); - await signInStateMachine.stream.whereType().first; - expect( - signInStateMachine.authFlowType, - cognito_idp.AuthFlowType.customAuth, - ); - }); - test('smoke test', () async { stateMachine .dispatch( @@ -234,54 +169,6 @@ void main() { ]), ); }); - - test('customAuth uses old behavior', () async { - stateMachine - .dispatch( - ConfigurationEvent.configure(userPoolOnlyConfig), - ) - .ignore(); - await expectLater( - stateMachine.stream.whereType().firstWhere( - (event) => event is Configured || event is ConfigureFailure, - ), - completion(isA()), - ); - - final mockClient = MockCognitoIdentityProviderClient( - initiateAuth: expectAsync1( - (_) async => cognito_idp.InitiateAuthResponse( - authenticationResult: cognito_idp.AuthenticationResultType( - accessToken: accessToken.raw, - refreshToken: refreshToken, - idToken: idToken.raw, - ), - ), - ), - ); - stateMachine - ..addInstance(mockClient) - ..dispatch( - SignInEvent.initiate( - // ignore: deprecated_member_use - authFlowType: AuthenticationFlowType.customAuth, - parameters: SignInParameters( - (p) => p - ..username = 'username' - ..password = 'password', - ), - ), - ).ignore(); - - final signInStateMachine = stateMachine.expect(SignInStateMachine.type); - expect( - signInStateMachine.stream, - emitsInOrder([ - isA(), - isA(), - ]), - ); - }); }); group('device tracking', () { diff --git a/packages/authenticator/amplify_authenticator/test/sign_up_form_test.dart b/packages/authenticator/amplify_authenticator/test/sign_up_form_test.dart index 119bf106b7..abaca33389 100644 --- a/packages/authenticator/amplify_authenticator/test/sign_up_form_test.dart +++ b/packages/authenticator/amplify_authenticator/test/sign_up_form_test.dart @@ -277,7 +277,6 @@ void main() { final passwordReqConfig = AmplifyConfig( auth: AuthConfig.cognito( - authenticationFlowType: AuthenticationFlowType.userSrpAuth, usernameAttributes: const [CognitoUserAttributeKey.email], signupAttributes: const [CognitoUserAttributeKey.email], passwordProtectionSettings: const PasswordProtectionSettings(