@@ -11,6 +11,8 @@ import 'package:amplify_auth_cognito_dart/src/model/auth_user_ext.dart';
11
11
import 'package:amplify_auth_cognito_dart/src/state/cognito_state_machine.dart' ;
12
12
import 'package:amplify_auth_cognito_dart/src/state/state.dart' ;
13
13
import 'package:amplify_core/amplify_core.dart' ;
14
+ // ignore: implementation_imports
15
+ import 'package:amplify_core/src/config/amplify_outputs/auth/auth_outputs.dart' ;
14
16
import 'package:amplify_secure_storage_dart/amplify_secure_storage_dart.dart' ;
15
17
16
18
/// {@template amplify_auth_cognito.hosted_ui_state_machine}
@@ -31,16 +33,20 @@ final class HostedUiStateMachine
31
33
@override
32
34
String get runtimeTypeName => 'HostedUiStateMachine' ;
33
35
34
- CognitoOAuthConfig get _config => expect ();
35
- HostedUiKeys get _keys => HostedUiKeys (_config.appClientId);
36
+ AuthOutputs get _authOutputs {
37
+ final authOutputs = get <AuthOutputs >();
38
+ if (authOutputs? .oauth == null || authOutputs? .userPoolClientId == null ) {
39
+ throw const InvalidAccountTypeException .noUserPool ();
40
+ }
41
+ return authOutputs! ;
42
+ }
43
+
44
+ HostedUiKeys get _keys => HostedUiKeys (_authOutputs.userPoolClientId! );
36
45
SecureStorageInterface get _secureStorage => getOrCreate ();
37
46
38
47
/// The platform-specific behavior.
39
48
HostedUiPlatform get _platform => getOrCreate ();
40
49
41
- /// The configured identity pool.
42
- CognitoIdentityCredentialsProvider ? get _identityPoolConfig => get ();
43
-
44
50
@override
45
51
Future <void > resolve (HostedUiEvent event) async {
46
52
switch (event) {
@@ -192,9 +198,9 @@ final class HostedUiStateMachine
192
198
193
199
// Clear anonymous credentials, if there were any, and fetch authenticated
194
200
// credentials.
195
- if (_identityPoolConfig != null ) {
201
+ if (_authOutputs.identityPoolId != null ) {
196
202
await manager.clearCredentials (
197
- CognitoIdentityPoolKeys (_identityPoolConfig ! .poolId ),
203
+ CognitoIdentityPoolKeys (_authOutputs.identityPoolId ! ),
198
204
);
199
205
200
206
await manager.loadSession ();
0 commit comments