Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: remove deprecated auth types #4764

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1292,21 +1292,6 @@ class AuthCategory extends AmplifyCategory<AuthPluginInterface> {
),
);

/// {@macro amplify_core.amplify_auth_category.send_attribute_verification_code}
@Deprecated('Use sendUserAttributeVerificationCode.')
Future<ResendUserAttributeConfirmationCodeResult>
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.
Expand Down
2 changes: 0 additions & 2 deletions packages/amplify_core/lib/src/config/auth/auth_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class AuthConfig extends AmplifyPluginConfigMap {
CognitoUserPoolConfig? userPoolConfig,
CognitoIdentityPoolConfig? identityPoolConfig,
CognitoOAuthConfig? hostedUiConfig,
AuthenticationFlowType? authenticationFlowType,
List<SocialProvider>? socialProviders,
List<CognitoUserAttributeKey>? usernameAttributes,
List<CognitoUserAttributeKey>? signupAttributes,
Expand All @@ -40,7 +39,6 @@ class AuthConfig extends AmplifyPluginConfigMap {
auth: AWSConfigMap.withDefault(
CognitoAuthConfig(
oAuth: hostedUiConfig,
authenticationFlowType: authenticationFlowType,
socialProviders: socialProviders,
usernameAttributes: usernameAttributes ?? const [],
signupAttributes: signupAttributes ?? const [],
Expand Down
9 changes: 0 additions & 9 deletions packages/amplify_core/lib/src/config/auth/cognito/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ part 'auth.g.dart';
class CognitoAuthConfig with AWSEquatable<CognitoAuthConfig>, AWSSerializable {
const CognitoAuthConfig({
this.oAuth,
this.authenticationFlowType,
this.socialProviders,
this.usernameAttributes,
this.signupAttributes,
Expand All @@ -29,10 +28,6 @@ class CognitoAuthConfig with AWSEquatable<CognitoAuthConfig>, AWSSerializable {
@JsonKey(name: 'OAuth')
final CognitoOAuthConfig? oAuth;

@JsonKey(
unknownEnumValue: JsonKey.nullForUndefinedEnumValue,
)
final AuthenticationFlowType? authenticationFlowType;
final List<SocialProvider>? socialProviders;
final List<CognitoUserAttributeKey>? usernameAttributes;
final List<CognitoUserAttributeKey>? signupAttributes;
Expand All @@ -44,7 +39,6 @@ class CognitoAuthConfig with AWSEquatable<CognitoAuthConfig>, AWSSerializable {
@override
List<Object?> get props => [
oAuth,
authenticationFlowType,
socialProviders,
usernameAttributes,
signupAttributes,
Expand All @@ -56,7 +50,6 @@ class CognitoAuthConfig with AWSEquatable<CognitoAuthConfig>, AWSSerializable {

CognitoAuthConfig copyWith({
CognitoOAuthConfig? oAuth,
AuthenticationFlowType? authenticationFlowType,
List<SocialProvider>? socialProviders,
List<CognitoUserAttributeKey>? usernameAttributes,
List<CognitoUserAttributeKey>? signupAttributes,
Expand All @@ -67,8 +60,6 @@ class CognitoAuthConfig with AWSEquatable<CognitoAuthConfig>, AWSSerializable {
}) {
return CognitoAuthConfig(
oAuth: oAuth ?? this.oAuth,
authenticationFlowType:
authenticationFlowType ?? this.authenticationFlowType,
socialProviders: socialProviders ??
(this.socialProviders == null
? null
Expand Down
13 changes: 0 additions & 13 deletions packages/amplify_core/lib/src/config/auth/cognito/auth.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,6 @@ abstract class AuthPluginInterface extends AmplifyPluginInterface {
);
}

/// {@macro amplify_core.amplify_auth_category.send_attribute_verification_code}
@Deprecated('Use sendUserAttributeVerificationCode instead.')
Future<ResendUserAttributeConfirmationCodeResult>
resendUserAttributeConfirmationCode({
required AuthUserAttributeKey userAttributeKey,
ResendUserAttributeConfirmationCodeOptions? options,
}) {
throw UnimplementedError(
'resendUserAttributeConfirmationCode() has not been implemented.',
);
}

/// {@macro amplify_core.amplify_auth_category.send_attribute_verification_code}
Future<SendUserAttributeVerificationCodeResult>
sendUserAttributeVerificationCode({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,3 @@ class SendUserAttributeVerificationCodeResult
Map<String, Object?> toJson() =>
_$SendUserAttributeVerificationCodeResultToJson(this);
}

/// {@macro amplify_core.send_user_attribute_verification_code_result}
@Deprecated('Use SendUserAttributeVerificationCodeResult.')
typedef ResendUserAttributeConfirmationCodeResult
= SendUserAttributeVerificationCodeResult;
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object?> get props => [attributeKey, deliveryMedium, destination];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
11 changes: 3 additions & 8 deletions packages/amplify_core/test/config/auth_config_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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', () {
Expand All @@ -24,6 +25,7 @@ void main() {
test(name, () {
final json = File(file.path).readAsStringSync();
final configJson = jsonDecode(json) as Map<String, Object?>;
final expectedJson = removeDeprecatedKeys(configJson);
final config = AmplifyConfig.fromJson(configJson);
final expectedConfig = expected[name]!;
final cognitoConfig = config.auth!.awsPlugin!.auth!.default$!;
Expand All @@ -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'],
),
);
Expand All @@ -53,7 +55,6 @@ void main() {

const expected = <String, CognitoAuthConfig>{
'auth_with_all_attributes': CognitoAuthConfig(
authenticationFlowType: AuthenticationFlowType.userSrpAuth,
signupAttributes: [
CognitoUserAttributeKey.address,
CognitoUserAttributeKey.birthdate,
Expand Down Expand Up @@ -87,7 +88,6 @@ const expected = <String, CognitoAuthConfig>{
usernameAttributes: [],
),
'auth_with_email': CognitoAuthConfig(
authenticationFlowType: AuthenticationFlowType.userSrpAuth,
signupAttributes: [
CognitoUserAttributeKey.email,
],
Expand All @@ -113,7 +113,6 @@ const expected = <String, CognitoAuthConfig>{
],
),
'auth_with_multi_alias': CognitoAuthConfig(
authenticationFlowType: AuthenticationFlowType.userSrpAuth,
signupAttributes: [
CognitoUserAttributeKey.email,
CognitoUserAttributeKey.phoneNumber,
Expand All @@ -132,7 +131,6 @@ const expected = <String, CognitoAuthConfig>{
],
),
'auth_with_username_no_attributes': CognitoAuthConfig(
authenticationFlowType: AuthenticationFlowType.userSrpAuth,
signupAttributes: [
CognitoUserAttributeKey.email,
],
Expand All @@ -150,7 +148,6 @@ const expected = <String, CognitoAuthConfig>{
usernameAttributes: [],
),
'auth_with_email_or_phone': CognitoAuthConfig(
authenticationFlowType: AuthenticationFlowType.userSrpAuth,
socialProviders: [],
usernameAttributes: [
CognitoUserAttributeKey.email,
Expand Down Expand Up @@ -185,7 +182,6 @@ const expected = <String, CognitoAuthConfig>{
signOutRedirectUri: OAUTH_SIGNOUT,
webDomain: OAUTH_DOMAIN,
),
authenticationFlowType: AuthenticationFlowType.userSrpAuth,
socialProviders: [
SocialProvider.facebook,
SocialProvider.google,
Expand Down Expand Up @@ -215,7 +211,6 @@ const expected = <String, CognitoAuthConfig>{
],
),
'auth_with_username': CognitoAuthConfig(
authenticationFlowType: AuthenticationFlowType.userSrpAuth,
socialProviders: [],
usernameAttributes: [],
signupAttributes: [
Expand Down
10 changes: 4 additions & 6 deletions packages/amplify_core/test/config/cli_config_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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', () {
Expand All @@ -17,10 +18,11 @@ void main() {
final name = testData.name;
test(name, () {
final json = jsonDecode(testData.config) as Map<String, Object?>;
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));
});
}
});
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 3 additions & 1 deletion packages/amplify_core/test/config/e2e_config_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -33,7 +34,8 @@ void main() {
test('v${e2eTest.version}', () {
final json = jsonDecode(e2eTest.config) as Map<String, Object?>;
final parsed = AmplifyConfig.fromJson(json.cast());
expect(parsed.toJson(), equals(json));
final expectedJson = removeDeprecatedKeys(json);
expect(parsed.toJson(), equals(expectedJson));
});
}
});
Expand Down
Loading
Loading