Skip to content

Commit

Permalink
chore(auth): Disable ASF
Browse files Browse the repository at this point in the history
  • Loading branch information
Dillon Nys authored and dnys1 committed Jun 21, 2023
1 parent bacbe37 commit 0a71336
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import 'package:flutter_test/flutter_test.dart';

import 'asf_test.dart' as asf_tests;
// import 'asf_test.dart' as asf_tests;
import 'confirm_sign_in_test.dart' as confirm_sign_in_tests;
import 'confirm_sign_up_test.dart' as confirm_sign_up_tests;
import 'custom_auth_test.dart' as custom_auth_tests;
Expand Down Expand Up @@ -31,7 +31,7 @@ void main() async {
testRunner.setupTests();

group('amplify_auth_cognito', () {
asf_tests.main();
// asf_tests.main();
confirm_sign_in_tests.main();
confirm_sign_up_tests.main();
custom_auth_tests.main();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import 'package:amplify_auth_cognito_dart/src/sdk/cognito_identity_provider.dart
GetUserRequest,
ListDevicesRequest,
ResendConfirmationCodeRequest,
UserContextDataType,
UpdateDeviceStatusRequest,
UpdateUserAttributesRequest,
VerifyUserAttributeRequest;
Expand Down Expand Up @@ -140,12 +139,6 @@ class AmplifyAuthCognitoDart extends AuthPluginInterface
/// Analytics Metadata Provider
AnalyticsMetadataType? get _analyticsMetadata => _stateMachine.get();

ASFContextDataProvider get _contextDataProvider => stateMachine.getOrCreate();

Future<cognito.UserContextDataType?> _getContextData(String username) async {
return _contextDataProvider.buildRequestData(username);
}

final StreamController<AuthHubEvent> _hubEventController =
StreamController.broadcast();

Expand Down Expand Up @@ -467,7 +460,6 @@ class AmplifyAuthCognitoDart extends AuthPluginInterface
pluginOptions: options?.pluginOptions,
defaultPluginOptions: const CognitoResendSignUpCodePluginOptions(),
);
final userContextData = await _getContextData(username);
final result = await _cognitoIdp.resendConfirmationCode(
cognito.ResendConfirmationCodeRequest.build((b) {
b
Expand All @@ -486,10 +478,6 @@ class AmplifyAuthCognitoDart extends AuthPluginInterface

final clientMetadata = pluginOptions.clientMetadata;
b.clientMetadata.addAll(clientMetadata);

if (userContextData != null) {
b.userContextData.replace(userContextData);
}
}),
).result;

Expand Down Expand Up @@ -775,7 +763,6 @@ class AmplifyAuthCognitoDart extends AuthPluginInterface
pluginOptions: options?.pluginOptions,
defaultPluginOptions: const CognitoResetPasswordPluginOptions(),
);
final userContextData = await _getContextData(username);
final result = await _cognitoIdp.forgotPassword(
cognito.ForgotPasswordRequest.build((b) {
b
Expand All @@ -792,10 +779,6 @@ class AmplifyAuthCognitoDart extends AuthPluginInterface
clientSecret,
);
}

if (userContextData != null) {
b.userContextData.replace(userContextData);
}
}),
).result;

Expand Down Expand Up @@ -826,7 +809,6 @@ class AmplifyAuthCognitoDart extends AuthPluginInterface
pluginOptions: options?.pluginOptions,
defaultPluginOptions: const CognitoConfirmResetPasswordPluginOptions(),
);
final userContextData = await _getContextData(username);
await _cognitoIdp.confirmForgotPassword(
cognito.ConfirmForgotPasswordRequest.build((b) {
b
Expand All @@ -845,10 +827,6 @@ class AmplifyAuthCognitoDart extends AuthPluginInterface
clientSecret,
);
}

if (userContextData != null) {
b.userContextData.replace(userContextData);
}
}),
).result;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ final defaultDependencies = <Token, DependencyBuilder>{
AuthPluginCredentialsProviderImpl.new,
const Token<DeviceMetadataRepository>():
DeviceMetadataRepository.fromDependencies,
const Token<ASFDeviceInfoCollector>(): (_) => ASFDeviceInfoCollector(),
const Token<ASFContextDataProvider>(): ASFContextDataProvider.new,
};

/// {@template amplify_auth_cognito.cognito_auth_state_machine}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ final class SignInStateMachine
/// The Cognito Identity Provider service client.
late final CognitoIdentityProviderClient cognitoIdentityProvider = expect();

/// The advanced security features (ASF) context data provider.
ASFContextDataProvider get contextDataProvider => getOrCreate();

/// The user built via the auth flow process.
var _user = CognitoUserBuilder();

Expand Down Expand Up @@ -596,15 +593,6 @@ final class SignInStateMachine
}
});

final contextDataProvider = this.contextDataProvider;
final contextData = await contextDataProvider.buildRequestData(
_user.username!,
);
if (contextData != null) {
initRequest = initRequest.rebuild(
(b) => b.userContextData.replace(contextData),
);
}
final initResponse =
await cognitoIdentityProvider.initiateAuth(initRequest).result;

Expand Down Expand Up @@ -764,12 +752,6 @@ final class SignInStateMachine
SignInEvent? event,
RespondToAuthChallengeRequest respondRequest,
) async {
UserContextDataType? userContextData;
final contextDataProvider = this.contextDataProvider;
userContextData = await contextDataProvider.buildRequestData(
_user.username!,
);

respondRequest = respondRequest.rebuild((b) {
b
..session ??= _session
Expand All @@ -786,10 +768,6 @@ final class SignInStateMachine
config.appClientSecret!,
);
}

if (userContextData != null) {
b.userContextData.replace(userContextData);
}
});

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ final class SignUpStateMachine
return userPoolConfig;
}

ASFContextDataProvider get _contextDataProvider => getOrCreate();

@override
Future<void> resolve(SignUpEvent event) async {
switch (event) {
Expand All @@ -69,11 +67,6 @@ final class SignUpStateMachine

/// State machine callback for the [SignUpInitiate] event.
Future<void> onInitiate(SignUpInitiate event) async {
UserContextDataType? contextData;
final contextDataProvider = _contextDataProvider;
contextData = await contextDataProvider.buildRequestData(
event.parameters.username,
);
final resp = await _cognito.signUp(
SignUpRequest.build(
(b) {
Expand Down Expand Up @@ -108,10 +101,6 @@ final class SignUpStateMachine
clientSecret,
);
}

if (contextData != null) {
b.userContextData.replace(contextData);
}
},
),
).result;
Expand All @@ -130,11 +119,6 @@ final class SignUpStateMachine

/// State machine callback for the [SignUpConfirm] event.
Future<void> onConfirm(SignUpConfirm event) async {
UserContextDataType? contextData;
final contextDataProvider = _contextDataProvider;
contextData = await contextDataProvider.buildRequestData(
event.username,
);
await _cognito.confirmSignUp(
ConfirmSignUpRequest.build((b) {
b
Expand All @@ -152,10 +136,6 @@ final class SignUpStateMachine
clientSecret,
);
}

if (contextData != null) {
b.userContextData.replace(contextData);
}
}),
).result;

Expand Down

0 comments on commit 0a71336

Please sign in to comment.