diff --git a/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_credential_provider_android.dart b/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_credential_provider_android.dart index 1698d6cf69..19e59eec2d 100644 --- a/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_credential_provider_android.dart +++ b/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_credential_provider_android.dart @@ -10,9 +10,7 @@ import 'package:amplify_auth_cognito/src/native_auth_plugin.g.dart' import 'package:amplify_auth_cognito_dart/src/credentials/legacy_credential_provider.dart'; import 'package:amplify_auth_cognito_dart/src/state/cognito_state_machine.dart'; import 'package:amplify_auth_cognito_dart/src/state/state.dart'; -import 'package:amplify_core/src/config/auth/cognito/credentials_provider.dart'; -import 'package:amplify_core/src/config/auth/cognito/oauth.dart'; -import 'package:amplify_core/src/config/auth/cognito/user_pool.dart'; +import 'package:amplify_core/src/config/amplify_outputs/auth/auth_outputs.dart'; /// {@template amplify_auth_cognito.legacy_android_credential_provider} /// The implementation of [LegacyCredentialProvider] for migrating @@ -25,54 +23,51 @@ class LegacyCredentialProviderAndroid implements LegacyCredentialProvider { final CognitoAuthStateMachine _stateMachine; @override - Future fetchLegacyCredentials({ - CognitoUserPoolConfig? userPoolConfig, - CognitoIdentityCredentialsProvider? identityPoolConfig, - CognitoOAuthConfig? hostedUiConfig, - }) async { + Future fetchLegacyCredentials( + AuthOutputs authOutputs, + ) async { final bridge = _stateMachine.expect(); final legacyCredentials = await bridge.getLegacyCredentials( - identityPoolConfig?.poolId, - userPoolConfig?.appClientId, + authOutputs.identityPoolId, + authOutputs.userPoolClientId, ); return legacyCredentials.toCredentialStoreData(); } @override - Future deleteLegacyCredentials({ - CognitoUserPoolConfig? userPoolConfig, - CognitoIdentityCredentialsProvider? identityPoolConfig, - CognitoOAuthConfig? hostedUiConfig, - }) { + Future deleteLegacyCredentials( + AuthOutputs authOutputs, + ) { final bridge = _stateMachine.expect(); return bridge.clearLegacyCredentials(); } @override - Future fetchLegacyDeviceSecrets({ - required String username, - CognitoUserPoolConfig? userPoolConfig, - }) async { - if (userPoolConfig == null) return null; + Future fetchLegacyDeviceSecrets( + String username, + AuthOutputs authOutputs, + ) async { + final userPoolId = authOutputs.userPoolId; + if (userPoolId == null) return null; final bridge = _stateMachine.expect(); final device = await bridge.fetchLegacyDeviceSecrets( username, - userPoolConfig.poolId, + userPoolId, ); return device?.toLegacyDeviceDetails(); } @override - Future deleteLegacyDeviceSecrets({ - required String username, - CognitoUserPoolConfig? userPoolConfig, - }) async { - if (userPoolConfig != null) { - final bridge = _stateMachine.expect(); - return bridge.deleteLegacyDeviceSecrets( - username, - userPoolConfig.poolId, - ); - } + Future deleteLegacyDeviceSecrets( + String username, + AuthOutputs authOutputs, + ) async { + final userPoolId = authOutputs.userPoolId; + if (userPoolId == null) return; + final bridge = _stateMachine.expect(); + return bridge.deleteLegacyDeviceSecrets( + username, + userPoolId, + ); } } diff --git a/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_credential_provider_impl.dart b/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_credential_provider_impl.dart index 40736a0efc..113eaea679 100644 --- a/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_credential_provider_impl.dart +++ b/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_credential_provider_impl.dart @@ -12,6 +12,8 @@ import 'package:amplify_auth_cognito_dart/src/state/cognito_state_machine.dart'; // ignore: implementation_imports, invalid_use_of_internal_member import 'package:amplify_auth_cognito_dart/src/state/state.dart'; import 'package:amplify_core/amplify_core.dart'; +// ignore: implementation_imports +import 'package:amplify_core/src/config/amplify_outputs/auth/auth_outputs.dart'; /// {@template amplify_auth_cognito.legacy_credential_provider_impl} /// The implementation of [LegacyCredentialProvider] for migrating @@ -35,54 +37,46 @@ class LegacyCredentialProviderImpl implements LegacyCredentialProvider { }(); @override - Future fetchLegacyCredentials({ - CognitoUserPoolConfig? userPoolConfig, - CognitoIdentityCredentialsProvider? identityPoolConfig, - CognitoOAuthConfig? hostedUiConfig, - }) async { + Future fetchLegacyCredentials( + AuthOutputs authOutputs, + ) async { if (_instance == null) return null; return _instance.fetchLegacyCredentials( - userPoolConfig: userPoolConfig, - identityPoolConfig: identityPoolConfig, - hostedUiConfig: hostedUiConfig, + authOutputs, ); } @override - Future deleteLegacyCredentials({ - CognitoUserPoolConfig? userPoolConfig, - CognitoIdentityCredentialsProvider? identityPoolConfig, - CognitoOAuthConfig? hostedUiConfig, - }) async { + Future deleteLegacyCredentials( + AuthOutputs authOutputs, + ) async { if (_instance == null) return; return _instance.deleteLegacyCredentials( - userPoolConfig: userPoolConfig, - identityPoolConfig: identityPoolConfig, - hostedUiConfig: hostedUiConfig, + authOutputs, ); } @override - Future fetchLegacyDeviceSecrets({ - required String username, - CognitoUserPoolConfig? userPoolConfig, - }) async { + Future fetchLegacyDeviceSecrets( + String username, + AuthOutputs authOutputs, + ) async { if (_instance == null) return null; return _instance.fetchLegacyDeviceSecrets( - username: username, - userPoolConfig: userPoolConfig, + username, + authOutputs, ); } @override - Future deleteLegacyDeviceSecrets({ - required String username, - CognitoUserPoolConfig? userPoolConfig, - }) async { + Future deleteLegacyDeviceSecrets( + String username, + AuthOutputs authOutputs, + ) async { if (_instance == null) return; return _instance.deleteLegacyDeviceSecrets( - username: username, - userPoolConfig: userPoolConfig, + username, + authOutputs, ); } } diff --git a/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_credential_provider_ios.dart b/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_credential_provider_ios.dart index 41b27782a0..0c388bd54b 100644 --- a/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_credential_provider_ios.dart +++ b/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_credential_provider_ios.dart @@ -14,6 +14,8 @@ import 'package:amplify_auth_cognito_dart/src/credentials/legacy_credential_prov import 'package:amplify_auth_cognito_dart/src/state/cognito_state_machine.dart'; // ignore: implementation_imports, invalid_use_of_internal_member import 'package:amplify_auth_cognito_dart/src/state/state.dart'; +// ignore: implementation_imports +import 'package:amplify_core/src/config/amplify_outputs/auth/auth_outputs.dart'; import 'package:amplify_flutter/amplify_flutter.dart'; import 'package:async/async.dart'; @@ -28,22 +30,21 @@ class LegacyCredentialProviderIOS implements LegacyCredentialProvider { final CognitoAuthStateMachine _stateMachine; @override - Future fetchLegacyCredentials({ - CognitoUserPoolConfig? userPoolConfig, - CognitoIdentityCredentialsProvider? identityPoolConfig, - CognitoOAuthConfig? hostedUiConfig, - }) async { + Future fetchLegacyCredentials( + AuthOutputs authOutputs, + ) async { CognitoUserPoolTokens? userPoolTokens; - if (userPoolConfig != null) { + final userPoolClientId = authOutputs.userPoolClientId; + if (userPoolClientId != null) { final userPoolStorage = await _getUserPoolStorage(); - final cognitoUserKeys = LegacyCognitoUserKeys(userPoolConfig); + final cognitoUserKeys = LegacyCognitoUserKeys(userPoolClientId); final currentUserId = await userPoolStorage.read( key: cognitoUserKeys[LegacyCognitoKey.currentUser], ); if (currentUserId != null) { final userPoolKeys = LegacyCognitoUserPoolKeys( currentUserId, - userPoolConfig, + userPoolClientId, ); final accessToken = await userPoolStorage.read( key: userPoolKeys[LegacyCognitoUserPoolKey.accessToken], @@ -56,7 +57,7 @@ class LegacyCredentialProviderIOS implements LegacyCredentialProvider { ); if (accessToken != null && refreshToken != null && idToken != null) { // TODO(Jordan-Nelson): fetch sign in method from keychain on iOS - final signInMethod = hostedUiConfig != null + final signInMethod = authOutputs.oauth != null ? CognitoSignInMethod.hostedUi : CognitoSignInMethod.default$; userPoolTokens = CognitoUserPoolTokens( @@ -71,7 +72,7 @@ class LegacyCredentialProviderIOS implements LegacyCredentialProvider { String? identityId; AWSCredentials? awsCredentials; - final identityPoolId = identityPoolConfig?.poolId; + final identityPoolId = authOutputs.identityPoolId; if (identityPoolId != null) { final identityPoolStorage = await _getIdentityPoolStorage( identityPoolId, @@ -122,21 +123,20 @@ class LegacyCredentialProviderIOS implements LegacyCredentialProvider { } @override - Future deleteLegacyCredentials({ - CognitoUserPoolConfig? userPoolConfig, - CognitoIdentityCredentialsProvider? identityPoolConfig, - CognitoOAuthConfig? hostedUiConfig, - }) async { - if (userPoolConfig != null) { + Future deleteLegacyCredentials( + AuthOutputs authOutputs, + ) async { + final userPoolClientId = authOutputs.userPoolClientId; + if (userPoolClientId != null) { final userPoolStorage = await _getUserPoolStorage(); - final cognitoUserKeys = LegacyCognitoUserKeys(userPoolConfig); + final cognitoUserKeys = LegacyCognitoUserKeys(userPoolClientId); final currentUser = await userPoolStorage.read( key: cognitoUserKeys[LegacyCognitoKey.currentUser], ); if (currentUser != null) { final userPoolKeys = LegacyCognitoUserPoolKeys( currentUser, - userPoolConfig, + userPoolClientId, ); await userPoolStorage.deleteMany([ userPoolKeys[LegacyCognitoUserPoolKey.accessToken], @@ -147,9 +147,9 @@ class LegacyCredentialProviderIOS implements LegacyCredentialProvider { } } - final identityPoolId = identityPoolConfig?.poolId; - if (identityPoolId != null) { - final identityPoolStorage = await _getIdentityPoolStorage(identityPoolId); + if (authOutputs.identityPoolId != null) { + final identityPoolStorage = + await _getIdentityPoolStorage(authOutputs.identityPoolId!); const identityPoolKeys = LegacyCognitoIdentityPoolKeys(); await identityPoolStorage.deleteMany([ identityPoolKeys[LegacyCognitoIdentityPoolKey.identityId], @@ -162,20 +162,22 @@ class LegacyCredentialProviderIOS implements LegacyCredentialProvider { } @override - Future fetchLegacyDeviceSecrets({ - required String username, - CognitoUserPoolConfig? userPoolConfig, - }) async { - if (userPoolConfig == null) return null; + Future fetchLegacyDeviceSecrets( + String username, + AuthOutputs authOutputs, + ) async { + final userPoolClientId = authOutputs.userPoolClientId; + if (userPoolClientId == null) return null; final userPoolStorage = await _getUserPoolStorage(); - final cognitoUserKeys = LegacyCognitoUserKeys(userPoolConfig); + final cognitoUserKeys = LegacyCognitoUserKeys(userPoolClientId); final currentUserId = await userPoolStorage.read( key: cognitoUserKeys[LegacyCognitoKey.currentUser], ); - if (currentUserId == null) return null; + final userPoolId = authOutputs.userPoolId; + if (currentUserId == null || userPoolId == null) return null; final keys = LegacyDeviceSecretKeys( currentUserId, - userPoolConfig, + userPoolId, ); final deviceKey = await userPoolStorage.read( key: keys[LegacyDeviceSecretKey.id], @@ -187,7 +189,7 @@ class LegacyCredentialProviderIOS implements LegacyCredentialProvider { key: keys[LegacyDeviceSecretKey.group], ); - final asfKeys = LegacyAsfDeviceKeys(currentUserId, userPoolConfig); + final asfKeys = LegacyAsfDeviceKeys(currentUserId, userPoolId); final asfDeviceId = await userPoolStorage.read( key: asfKeys[LegacyAsfDeviceKey.id], ); @@ -201,19 +203,21 @@ class LegacyCredentialProviderIOS implements LegacyCredentialProvider { } @override - Future deleteLegacyDeviceSecrets({ - required String username, - CognitoUserPoolConfig? userPoolConfig, - }) async { - if (userPoolConfig == null) return; + Future deleteLegacyDeviceSecrets( + String username, + AuthOutputs authOutputs, + ) async { + final userPoolClientId = authOutputs.userPoolClientId; + if (userPoolClientId == null) return; final userPoolStorage = await _getUserPoolStorage(); - final cognitoUserKeys = LegacyCognitoUserKeys(userPoolConfig); + final cognitoUserKeys = LegacyCognitoUserKeys(userPoolClientId); final currentUserId = await userPoolStorage.read( key: cognitoUserKeys[LegacyCognitoKey.currentUser], ); - if (currentUserId == null) return; - final keys = LegacyDeviceSecretKeys(currentUserId, userPoolConfig); - final asfKeys = LegacyAsfDeviceKeys(currentUserId, userPoolConfig); + final userPoolId = authOutputs.userPoolId; + if (currentUserId == null || userPoolId == null) return; + final keys = LegacyDeviceSecretKeys(currentUserId, userPoolId); + final asfKeys = LegacyAsfDeviceKeys(currentUserId, userPoolId); await userPoolStorage.deleteMany([ keys[LegacyDeviceSecretKey.id], keys[LegacyDeviceSecretKey.secret], diff --git a/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_ios_cognito_keys.dart b/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_ios_cognito_keys.dart index a7f74a832d..f1479a35df 100644 --- a/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_ios_cognito_keys.dart +++ b/packages/auth/amplify_auth_cognito/lib/src/credentials/legacy_ios_cognito_keys.dart @@ -11,7 +11,6 @@ library amplify_auth_cognito.credentials.legacy_ios_cognito_keys; import 'dart:collection'; -import 'package:amplify_core/amplify_core.dart'; import 'package:meta/meta.dart'; /// Discrete keys stored for Legacy Cognito operations on iOS. @@ -77,17 +76,17 @@ enum LegacyAsfDeviceKey { /// {@endtemplate} class LegacyCognitoUserKeys extends LegacyIOSCognitoKeys { /// {@macro amplify_auth_cognito.legacy_cognito_identity_pool_keys} - const LegacyCognitoUserKeys(this.config); + const LegacyCognitoUserKeys(this.userPoolClientId); - /// The Cognito identity pool configuration, used to determine the key + /// The Cognito user pool client id , used to determine the key /// prefixes. - final CognitoUserPoolConfig config; + final String userPoolClientId; @override List get _values => LegacyCognitoKey.values; @override - String? get prefix => config.appClientId; + String? get prefix => userPoolClientId; } /// {@template amplify_auth_cognito.legacy_cognito_identity_pool_keys} @@ -114,11 +113,11 @@ class LegacyCognitoIdentityPoolKeys class LegacyCognitoUserPoolKeys extends LegacyIOSCognitoKeys { /// {@macro amplify_auth_cognito.cognito_user_pool_keys} - const LegacyCognitoUserPoolKeys(this.currentUserId, this.config); + const LegacyCognitoUserPoolKeys(this.currentUserId, this.userPoolClientId); - /// The Cognito identity pool configuration, used to determine the key + /// The Cognito user pool client id, used to determine the key /// prefixes. - final CognitoUserPoolConfig config; + final String userPoolClientId; /// The current user ID, used to determine the key prefixes. final String currentUserId; @@ -127,7 +126,7 @@ class LegacyCognitoUserPoolKeys List get _values => LegacyCognitoUserPoolKey.values; @override - String get prefix => '${config.appClientId}.$currentUserId'; + String get prefix => '$userPoolClientId.$currentUserId'; } /// {@template amplify_auth_cognito.cognito_user_pool_keys} @@ -137,11 +136,11 @@ class LegacyCognitoUserPoolKeys class LegacyDeviceSecretKeys extends LegacyIOSCognitoKeys { /// {@macro amplify_auth_cognito.cognito_user_pool_keys} - const LegacyDeviceSecretKeys(this.currentUserId, this.config); + const LegacyDeviceSecretKeys(this.currentUserId, this.userPoolId); - /// The Cognito identity pool configuration, used to determine the key + /// The Cognito user pool id, used to determine the key /// prefixes. - final CognitoUserPoolConfig config; + final String userPoolId; /// The current user ID, used to determine the key prefixes. final String currentUserId; @@ -150,7 +149,7 @@ class LegacyDeviceSecretKeys List get _values => LegacyDeviceSecretKey.values; @override - String get prefix => '${config.poolId}.$currentUserId.device'; + String get prefix => '$userPoolId.$currentUserId.device'; } /// {@template amplify_auth_cognito.cognito_user_pool_keys} @@ -159,11 +158,11 @@ class LegacyDeviceSecretKeys /// {@endtemplate} class LegacyAsfDeviceKeys extends LegacyIOSCognitoKeys { /// {@macro amplify_auth_cognito.cognito_user_pool_keys} - const LegacyAsfDeviceKeys(this.currentUserId, this.config); + const LegacyAsfDeviceKeys(this.currentUserId, this.userPoolId); - /// The Cognito identity pool configuration, used to determine the key + /// The Cognito user pool id, used to determine the key /// prefixes. - final CognitoUserPoolConfig config; + final String userPoolId; /// The current user ID, used to determine the key prefixes. final String currentUserId; @@ -172,7 +171,7 @@ class LegacyAsfDeviceKeys extends LegacyIOSCognitoKeys { List get _values => LegacyAsfDeviceKey.values; @override - String get prefix => '${config.poolId}.$currentUserId.asf.device'; + String get prefix => '$userPoolId.$currentUserId.asf.device'; } /// {@template amplify_auth_cognito.cognito_keys} diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/credentials/legacy_credential_provider.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/credentials/legacy_credential_provider.dart index cfb262e1bf..2ffeeaaf91 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/credentials/legacy_credential_provider.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/credentials/legacy_credential_provider.dart @@ -2,7 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 import 'package:amplify_auth_cognito_dart/src/state/state/auth_state.dart'; -import 'package:amplify_core/amplify_core.dart'; +// ignore: implementation_imports +import 'package:amplify_core/src/config/amplify_outputs/auth/auth_outputs.dart'; /// {@template amplify_auth_cognito_dart.legacy_credential_provider} /// Provides methods to fetch and delete legacy credentials if they exist. @@ -12,30 +13,26 @@ abstract interface class LegacyCredentialProvider { const LegacyCredentialProvider(); /// Fetches legacy credentials if they are present. - Future fetchLegacyCredentials({ - CognitoUserPoolConfig? userPoolConfig, - CognitoIdentityCredentialsProvider? identityPoolConfig, - CognitoOAuthConfig? hostedUiConfig, - }); + Future fetchLegacyCredentials( + AuthOutputs authOutputs, + ); /// Fetches legacy device secrets if they are present. - Future fetchLegacyDeviceSecrets({ - required String username, - CognitoUserPoolConfig? userPoolConfig, - }); + Future fetchLegacyDeviceSecrets( + String username, + AuthOutputs authOutputs, + ); /// Deletes legacy credentials if they are present. - Future deleteLegacyCredentials({ - CognitoUserPoolConfig? userPoolConfig, - CognitoIdentityCredentialsProvider? identityPoolConfig, - CognitoOAuthConfig? hostedUiConfig, - }); + Future deleteLegacyCredentials( + AuthOutputs authOutputs, + ); /// Deletes legacy device secrets if they are present. - Future deleteLegacyDeviceSecrets({ - required String username, - CognitoUserPoolConfig? userPoolConfig, - }); + Future deleteLegacyDeviceSecrets( + String username, + AuthOutputs authOutputs, + ); } /// {@template amplify_auth_cognito_dart.legacy_device_details} diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/credential_store_state_machine.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/credential_store_state_machine.dart index 1c224e428c..9b66397eb8 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/credential_store_state_machine.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/credential_store_state_machine.dart @@ -10,7 +10,6 @@ import 'package:amplify_auth_cognito_dart/src/credentials/credential_store_keys. import 'package:amplify_auth_cognito_dart/src/credentials/device_metadata_repository.dart'; import 'package:amplify_auth_cognito_dart/src/credentials/legacy_credential_provider.dart'; import 'package:amplify_auth_cognito_dart/src/credentials/secure_storage_extension.dart'; -import 'package:amplify_auth_cognito_dart/src/model/auth_configuration.dart'; import 'package:amplify_auth_cognito_dart/src/model/cognito_device_secrets.dart'; import 'package:amplify_auth_cognito_dart/src/model/session/cognito_sign_in_details.dart'; import 'package:amplify_auth_cognito_dart/src/sdk/cognito_identity_provider.dart'; @@ -336,15 +335,11 @@ final class CredentialStoreStateMachine /// Migrates AWS Credentials and User Pool tokens. Future _migrateLegacyCredentials() async { final provider = get(); - // TODO(nikahsn): remove after refactoring LegacyCredentialProvider - final authConfig = expect(); if (provider == null) return null; CredentialStoreData? legacyData; try { legacyData = await provider.fetchLegacyCredentials( - userPoolConfig: authConfig.userPoolConfig, - identityPoolConfig: authConfig.identityPoolConfig, - hostedUiConfig: authConfig.hostedUiConfig, + _authOutputs, ); if (legacyData != null) { await _storeCredentials(legacyData); @@ -358,14 +353,12 @@ final class CredentialStoreStateMachine /// Migrates legacy device secrets. Future _migrateDeviceSecrets(String username) async { final credentialProvider = get(); - // TODO(nikahsn): remove after refactoring LegacyCredentialProvider - final authConfig = expect(); final userPoolKeys = CognitoUserPoolKeys(_authOutputs.userPoolClientId!); if (credentialProvider == null) return; try { final legacySecrets = await credentialProvider.fetchLegacyDeviceSecrets( - username: username, - userPoolConfig: authConfig.userPoolConfig, + username, + _authOutputs, ); if (legacySecrets != null) { final secrets = CognitoDeviceSecrets.fromLegacyDeviceDetails( @@ -387,8 +380,8 @@ final class CredentialStoreStateMachine } finally { try { await credentialProvider.deleteLegacyDeviceSecrets( - username: username, - userPoolConfig: authConfig.userPoolConfig, + username, + _authOutputs, ); } on Object catch (e, s) { logger.error('Error clearing legacy device secrets', e, s); @@ -399,14 +392,10 @@ final class CredentialStoreStateMachine /// Deletes legacy credentials. Future _deleteLegacyCredentials() async { final provider = get(); - // TODO(nikahsn): remove after refactoring LegacyCredentialProvider - final authConfig = expect(); if (provider == null) return; try { await provider.deleteLegacyCredentials( - userPoolConfig: authConfig.userPoolConfig, - identityPoolConfig: authConfig.identityPoolConfig, - hostedUiConfig: authConfig.hostedUiConfig, + _authOutputs, ); } on Object catch (e, s) { logger.error('Error clearing legacy credentials', e, s); diff --git a/packages/auth/amplify_auth_cognito_test/lib/common/mock_legacy_credential_provider.dart b/packages/auth/amplify_auth_cognito_test/lib/common/mock_legacy_credential_provider.dart index 4212215ecc..db9a6a8b5f 100644 --- a/packages/auth/amplify_auth_cognito_test/lib/common/mock_legacy_credential_provider.dart +++ b/packages/auth/amplify_auth_cognito_test/lib/common/mock_legacy_credential_provider.dart @@ -3,9 +3,7 @@ import 'package:amplify_auth_cognito_dart/src/credentials/legacy_credential_provider.dart'; import 'package:amplify_auth_cognito_dart/src/state/state.dart'; -import 'package:amplify_core/src/config/auth/cognito/credentials_provider.dart'; -import 'package:amplify_core/src/config/auth/cognito/oauth.dart'; -import 'package:amplify_core/src/config/auth/cognito/user_pool.dart'; +import 'package:amplify_core/src/config/amplify_outputs/auth/auth_outputs.dart'; class MockLegacyCredentialProvider implements LegacyCredentialProvider { MockLegacyCredentialProvider({CredentialStoreData? initialData}) @@ -14,36 +12,32 @@ class MockLegacyCredentialProvider implements LegacyCredentialProvider { CredentialStoreData? data; @override - Future deleteLegacyCredentials({ - CognitoUserPoolConfig? userPoolConfig, - CognitoIdentityCredentialsProvider? identityPoolConfig, - CognitoOAuthConfig? hostedUiConfig, - }) async { + Future deleteLegacyCredentials( + AuthOutputs authOutputs, + ) async { data = null; } @override - Future fetchLegacyCredentials({ - CognitoUserPoolConfig? userPoolConfig, - CognitoIdentityCredentialsProvider? identityPoolConfig, - CognitoOAuthConfig? hostedUiConfig, - }) async { + Future fetchLegacyCredentials( + AuthOutputs authOutputs, + ) async { return data; } @override - Future fetchLegacyDeviceSecrets({ - required String username, - CognitoUserPoolConfig? userPoolConfig, - }) async { + Future fetchLegacyDeviceSecrets( + String username, + AuthOutputs authOutputs, + ) async { return null; } @override - Future deleteLegacyDeviceSecrets({ - required String username, - CognitoUserPoolConfig? userPoolConfig, - }) async { + Future deleteLegacyDeviceSecrets( + String username, + AuthOutputs authOutputs, + ) async { return; } } diff --git a/packages/auth/amplify_auth_cognito_test/test/state/credential_store_state_machine_test.dart b/packages/auth/amplify_auth_cognito_test/test/state/credential_store_state_machine_test.dart index b30f9e6d23..9b9e1926eb 100644 --- a/packages/auth/amplify_auth_cognito_test/test/state/credential_store_state_machine_test.dart +++ b/packages/auth/amplify_auth_cognito_test/test/state/credential_store_state_machine_test.dart @@ -31,8 +31,7 @@ void main() { secureStorage = MockSecureStorage(); manager = DependencyManager() ..addInstance(secureStorage) - ..addInstance(mockConfig.auth!) - ..addInstance(authConfig); + ..addInstance(mockConfig.auth!); stateMachine = CognitoAuthStateMachine(dependencyManager: manager); });