From 002ef3cbb8ae2696a6e3abea925b6253fde1b644 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Tue, 12 Aug 2025 08:58:38 -0700 Subject: [PATCH 1/7] changed initiateAuth to getTokensFromRefreshTokenAPI in refresh token function, changed tests to test rotation functionality --- ...t_tokens_from_refresh_token_operation.dart | 1 + .../fetch_auth_session_state_machine.dart | 37 ++-- .../test/plugin/fetch_auth_session_test.dart | 6 +- .../test/plugin/sign_out_test.dart | 2 + ...fetch_auth_session_state_machine_test.dart | 166 +++++++++--------- 5 files changed, 101 insertions(+), 111 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/get_tokens_from_refresh_token_operation.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/get_tokens_from_refresh_token_operation.dart index c92345a000..7287577c6c 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/get_tokens_from_refresh_token_operation.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/sdk/src/cognito_identity_provider/operation/get_tokens_from_refresh_token_operation.dart @@ -73,6 +73,7 @@ class GetTokensFromRefreshTokenOperation region: _region, service: _i4.AWSService.cognitoIdentityProvider, credentialsProvider: _credentialsProvider, + isOptional: true, ), const _i1.WithUserAgent('aws-sdk-dart/0.3.2'), const _i3.WithSdkInvocationId(), diff --git a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/fetch_auth_session_state_machine.dart b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/fetch_auth_session_state_machine.dart index 7119420870..b3d68b36ee 100644 --- a/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/fetch_auth_session_state_machine.dart +++ b/packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/fetch_auth_session_state_machine.dart @@ -7,14 +7,11 @@ import 'package:amplify_auth_cognito_dart/amplify_auth_cognito_dart.dart'; import 'package:amplify_auth_cognito_dart/src/credentials/auth_plugin_credentials_provider.dart'; import 'package:amplify_auth_cognito_dart/src/credentials/cognito_keys.dart'; import 'package:amplify_auth_cognito_dart/src/credentials/device_metadata_repository.dart'; -import 'package:amplify_auth_cognito_dart/src/flows/constants.dart'; -import 'package:amplify_auth_cognito_dart/src/flows/helpers.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.dart' hide NotAuthorizedException; import 'package:amplify_auth_cognito_dart/src/sdk/cognito_identity_provider.dart' as cognito_idp; -import 'package:amplify_auth_cognito_dart/src/sdk/src/cognito_identity_provider/model/analytics_metadata_type.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/amplify_core.dart'; @@ -359,7 +356,6 @@ final class FetchAuthSessionStateMachine AuthResult userSubResult; AuthResult credentialsResult; AuthResult identityIdResult; - final hasUserPool = _authConfig?.userPoolId != null; var userPoolTokens = result.userPoolTokens; if (!hasUserPool) { @@ -511,38 +507,25 @@ final class FetchAuthSessionStateMachine final deviceSecrets = await getOrCreate().get( userPoolTokens.username, ); - final refreshRequest = cognito_idp.InitiateAuthRequest.build((b) { - b - ..authFlow = cognito_idp.AuthFlowType.refreshTokenAuth - ..clientId = _authConfig?.userPoolClientId - ..authParameters.addAll({ - CognitoConstants.refreshToken: userPoolTokens.refreshToken, - }) - ..analyticsMetadata = get()?.toBuilder(); - - // ignore: invalid_use_of_internal_member - if (_authConfig?.appClientSecret != null && - _authConfig?.userPoolClientId != null) { - b.authParameters[CognitoConstants.challengeParamSecretHash] = - computeSecretHash( - userPoolTokens.username, - _authConfig!.userPoolClientId!, - // ignore: invalid_use_of_internal_member - _authConfig!.appClientSecret!, - ); - } + // seems we dont support client metadata + final refreshRequest = cognito_idp.GetTokensFromRefreshTokenRequest.build(( + b, + ) { + b + ..refreshToken = userPoolTokens.refreshToken + ..clientId = _authConfig?.userPoolClientId; final deviceKey = deviceSecrets?.deviceKey; if (deviceKey != null) { - b.authParameters[CognitoConstants.challengeParamDeviceKey] = deviceKey; + b.deviceKey = deviceKey; } }); try { final result = await _withZoneOverrides( - () => _cognitoIdpClient.initiateAuth(refreshRequest).result, + () => + _cognitoIdpClient.getTokensFromRefreshToken(refreshRequest).result, ); final authResult = result.authenticationResult; - final accessToken = authResult?.accessToken; final refreshToken = authResult?.refreshToken; final idToken = authResult?.idToken; diff --git a/packages/auth/amplify_auth_cognito_test/test/plugin/fetch_auth_session_test.dart b/packages/auth/amplify_auth_cognito_test/test/plugin/fetch_auth_session_test.dart index c9bccf223d..36d87123d6 100644 --- a/packages/auth/amplify_auth_cognito_test/test/plugin/fetch_auth_session_test.dart +++ b/packages/auth/amplify_auth_cognito_test/test/plugin/fetch_auth_session_test.dart @@ -48,10 +48,8 @@ void main() { stateMachine.addInstance( MockCognitoIdentityProviderClient( - initiateAuth: expectAsync1( - (_) async => throw const AuthNotAuthorizedException( - 'Refresh Token has expired.', - ), + getTokensFromRefreshToken: () async => throw const AuthNotAuthorizedException( + 'Refresh Token has expired.', ), ), ); diff --git a/packages/auth/amplify_auth_cognito_test/test/plugin/sign_out_test.dart b/packages/auth/amplify_auth_cognito_test/test/plugin/sign_out_test.dart index 3aa2d5d515..fbf41f6709 100644 --- a/packages/auth/amplify_auth_cognito_test/test/plugin/sign_out_test.dart +++ b/packages/auth/amplify_auth_cognito_test/test/plugin/sign_out_test.dart @@ -275,6 +275,8 @@ void main() { final mockIdp = MockCognitoIdentityProviderClient( initiateAuth: (p0) async => throw InternalErrorException(message: 'Invalid token'), + getTokensFromRefreshToken: () async => + throw const AuthNotAuthorizedException('Auth not authorized'), ); stateMachine.addInstance(mockIdp); diff --git a/packages/auth/amplify_auth_cognito_test/test/state/fetch_auth_session_state_machine_test.dart b/packages/auth/amplify_auth_cognito_test/test/state/fetch_auth_session_state_machine_test.dart index 890a20c975..98c5d2df38 100644 --- a/packages/auth/amplify_auth_cognito_test/test/state/fetch_auth_session_state_machine_test.dart +++ b/packages/auth/amplify_auth_cognito_test/test/state/fetch_auth_session_state_machine_test.dart @@ -380,13 +380,11 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - initiateAuth: expectAsync1( - (_) async => InitiateAuthResponse( - authenticationResult: AuthenticationResultType( - accessToken: newAccessToken.raw, - refreshToken: refreshToken, - idToken: newIdToken.raw, - ), + getTokensFromRefreshToken: () async => GetTokensFromRefreshTokenResponse( + authenticationResult: AuthenticationResultType( + accessToken: newAccessToken.raw, + refreshToken: refreshToken, + idToken: newIdToken.raw, ), ), ), @@ -425,10 +423,8 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - initiateAuth: expectAsync1( - (_) async => throw const AuthNotAuthorizedException( - 'Tokens expired', - ), + getTokensFromRefreshToken: () async => throw const AuthNotAuthorizedException( + 'Tokens expired', ), ), ); @@ -469,10 +465,8 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - initiateAuth: expectAsync1( - (_) async => - throw AWSHttpException(AWSHttpRequest.get(Uri())), - ), + getTokensFromRefreshToken: () async => + throw AWSHttpException(AWSHttpRequest.get(Uri())), ), ); session = await fetchAuthSession(willRefresh: true); @@ -512,9 +506,7 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - initiateAuth: expectAsync1( - (_) async => throw _ServiceException(), - ), + getTokensFromRefreshToken: () async => throw _ServiceException(), ), ); session = await fetchAuthSession(willRefresh: true); @@ -570,13 +562,11 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - initiateAuth: expectAsync1( - (_) async => InitiateAuthResponse( - authenticationResult: AuthenticationResultType( - accessToken: newAccessToken.raw, - refreshToken: refreshToken, - idToken: newIdToken.raw, - ), + getTokensFromRefreshToken: () async => GetTokensFromRefreshTokenResponse( + authenticationResult: AuthenticationResultType( + accessToken: newAccessToken.raw, + refreshToken: refreshToken, + idToken: newIdToken.raw, ), ), ), @@ -614,10 +604,8 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - initiateAuth: expectAsync1( - (_) async => - throw AWSHttpException(AWSHttpRequest.get(Uri())), - ), + getTokensFromRefreshToken: () async => + throw AWSHttpException(AWSHttpRequest.get(Uri())), ), ); session = await fetchAuthSession(willRefresh: true); @@ -657,9 +645,7 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - initiateAuth: expectAsync1( - (_) async => throw _ServiceException(), - ), + getTokensFromRefreshToken: () async => throw _ServiceException(), ), ); session = await fetchAuthSession(willRefresh: true); @@ -710,13 +696,11 @@ void main() { stateMachine ..addInstance( MockCognitoIdentityProviderClient( - initiateAuth: expectAsync1( - (_) async => InitiateAuthResponse( - authenticationResult: AuthenticationResultType( - accessToken: newAccessToken.raw, - refreshToken: refreshToken, - idToken: newIdToken.raw, - ), + getTokensFromRefreshToken: () async => GetTokensFromRefreshTokenResponse( + authenticationResult: AuthenticationResultType( + accessToken: newAccessToken.raw, + refreshToken: refreshToken, + idToken: newIdToken.raw, ), ), ), @@ -765,18 +749,56 @@ void main() { }); }); - group('expired', () { + group('with new refresh token', () { + const newRefreshToken = 'new-refresh-token-rotated'; setUp(() async { await configureAmplify(config); stateMachine ..addInstance( MockCognitoIdentityProviderClient( - initiateAuth: expectAsync1( - (_) async => throw const AuthNotAuthorizedException( - 'Tokens expired', + getTokensFromRefreshToken: () async => GetTokensFromRefreshTokenResponse( + authenticationResult: AuthenticationResultType( + accessToken: newAccessToken.raw, + refreshToken: newRefreshToken, + idToken: newIdToken.raw, + ), + ), + ), + ) + ..addInstance( + MockCognitoIdentityClient( + getCredentialsForIdentity: expectAsync0( + () async => GetCredentialsForIdentityResponse( + credentials: Credentials( + accessKeyId: newAccessKeyId, + secretKey: newSecretAccessKey, + ), ), ), ), + ); + session = await fetchAuthSession( + willRefresh: true, + forceRefresh: true, + ); + }); + + test('should return new refresh token', () { + final userPoolTokens = session.userPoolTokensResult.value; + expect(userPoolTokens.refreshToken, newRefreshToken); + }); + }); + + group('expired', () { + setUp(() async { + await configureAmplify(config); + stateMachine + ..addInstance( + MockCognitoIdentityProviderClient( + getTokensFromRefreshToken: () async => throw const AuthNotAuthorizedException( + 'Tokens expired', + ), + ), ) ..addInstance( MockCognitoIdentityClient( @@ -832,10 +854,8 @@ void main() { stateMachine ..addInstance( MockCognitoIdentityProviderClient( - initiateAuth: expectAsync1( - (_) async => - throw AWSHttpException(AWSHttpRequest.get(Uri())), - ), + getTokensFromRefreshToken: () async => + throw AWSHttpException(AWSHttpRequest.get(Uri())), ), ) ..addInstance( @@ -891,9 +911,7 @@ void main() { stateMachine ..addInstance( MockCognitoIdentityProviderClient( - initiateAuth: expectAsync1( - (_) async => throw _ServiceException(), - ), + getTokensFromRefreshToken: () async => throw _ServiceException(), ), ) ..addInstance( @@ -1270,13 +1288,11 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - initiateAuth: expectAsync1( - (_) async => InitiateAuthResponse( - authenticationResult: AuthenticationResultType( - accessToken: newAccessToken.raw, - refreshToken: refreshToken, - idToken: newIdToken.raw, - ), + getTokensFromRefreshToken: () async => GetTokensFromRefreshTokenResponse( + authenticationResult: AuthenticationResultType( + accessToken: newAccessToken.raw, + refreshToken: refreshToken, + idToken: newIdToken.raw, ), ), ), @@ -1318,9 +1334,7 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - initiateAuth: expectAsync1( - (_) async => throw _ServiceException(), - ), + getTokensFromRefreshToken: () async => throw _ServiceException(), ), ); session = await fetchAuthSession(willRefresh: true); @@ -1375,13 +1389,11 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - initiateAuth: expectAsync1( - (_) async => InitiateAuthResponse( - authenticationResult: AuthenticationResultType( - accessToken: newAccessToken.raw, - refreshToken: refreshToken, - idToken: newIdToken.raw, - ), + getTokensFromRefreshToken: () async => GetTokensFromRefreshTokenResponse( + authenticationResult: AuthenticationResultType( + accessToken: newAccessToken.raw, + refreshToken: refreshToken, + idToken: newIdToken.raw, ), ), ), @@ -1423,9 +1435,7 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - initiateAuth: expectAsync1( - (_) async => throw _ServiceException(), - ), + getTokensFromRefreshToken: () async => throw _ServiceException(), ), ); session = await fetchAuthSession(willRefresh: true); @@ -1478,13 +1488,11 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - initiateAuth: expectAsync1( - (_) async => InitiateAuthResponse( - authenticationResult: AuthenticationResultType( - accessToken: newAccessToken.raw, - refreshToken: refreshToken, - idToken: newIdToken.raw, - ), + getTokensFromRefreshToken: () async => GetTokensFromRefreshTokenResponse( + authenticationResult: AuthenticationResultType( + accessToken: newAccessToken.raw, + refreshToken: refreshToken, + idToken: newIdToken.raw, ), ), ), @@ -1530,9 +1538,7 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - initiateAuth: expectAsync1( - (_) async => throw _ServiceException(), - ), + getTokensFromRefreshToken: () async => throw _ServiceException(), ), ); session = await fetchAuthSession( From 282effab7daf466908d5855927ab990ac32c3b72 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Tue, 12 Aug 2025 13:50:38 -0700 Subject: [PATCH 2/7] formatting --- .../test/plugin/fetch_auth_session_test.dart | 7 +- ...fetch_auth_session_state_machine_test.dart | 133 ++++++++++-------- 2 files changed, 76 insertions(+), 64 deletions(-) diff --git a/packages/auth/amplify_auth_cognito_test/test/plugin/fetch_auth_session_test.dart b/packages/auth/amplify_auth_cognito_test/test/plugin/fetch_auth_session_test.dart index 36d87123d6..686f1ef4db 100644 --- a/packages/auth/amplify_auth_cognito_test/test/plugin/fetch_auth_session_test.dart +++ b/packages/auth/amplify_auth_cognito_test/test/plugin/fetch_auth_session_test.dart @@ -48,9 +48,10 @@ void main() { stateMachine.addInstance( MockCognitoIdentityProviderClient( - getTokensFromRefreshToken: () async => throw const AuthNotAuthorizedException( - 'Refresh Token has expired.', - ), + getTokensFromRefreshToken: () async => + throw const AuthNotAuthorizedException( + 'Refresh Token has expired.', + ), ), ); }); diff --git a/packages/auth/amplify_auth_cognito_test/test/state/fetch_auth_session_state_machine_test.dart b/packages/auth/amplify_auth_cognito_test/test/state/fetch_auth_session_state_machine_test.dart index 98c5d2df38..497c241869 100644 --- a/packages/auth/amplify_auth_cognito_test/test/state/fetch_auth_session_state_machine_test.dart +++ b/packages/auth/amplify_auth_cognito_test/test/state/fetch_auth_session_state_machine_test.dart @@ -380,13 +380,14 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - getTokensFromRefreshToken: () async => GetTokensFromRefreshTokenResponse( - authenticationResult: AuthenticationResultType( - accessToken: newAccessToken.raw, - refreshToken: refreshToken, - idToken: newIdToken.raw, - ), - ), + getTokensFromRefreshToken: () async => + GetTokensFromRefreshTokenResponse( + authenticationResult: AuthenticationResultType( + accessToken: newAccessToken.raw, + refreshToken: refreshToken, + idToken: newIdToken.raw, + ), + ), ), ); session = await fetchAuthSession(willRefresh: true); @@ -423,9 +424,8 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - getTokensFromRefreshToken: () async => throw const AuthNotAuthorizedException( - 'Tokens expired', - ), + getTokensFromRefreshToken: () async => + throw const AuthNotAuthorizedException('Tokens expired'), ), ); session = await fetchAuthSession(willRefresh: true); @@ -506,7 +506,8 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - getTokensFromRefreshToken: () async => throw _ServiceException(), + getTokensFromRefreshToken: () async => + throw _ServiceException(), ), ); session = await fetchAuthSession(willRefresh: true); @@ -562,13 +563,14 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - getTokensFromRefreshToken: () async => GetTokensFromRefreshTokenResponse( - authenticationResult: AuthenticationResultType( - accessToken: newAccessToken.raw, - refreshToken: refreshToken, - idToken: newIdToken.raw, - ), - ), + getTokensFromRefreshToken: () async => + GetTokensFromRefreshTokenResponse( + authenticationResult: AuthenticationResultType( + accessToken: newAccessToken.raw, + refreshToken: refreshToken, + idToken: newIdToken.raw, + ), + ), ), ); session = await fetchAuthSession(willRefresh: true); @@ -645,7 +647,8 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - getTokensFromRefreshToken: () async => throw _ServiceException(), + getTokensFromRefreshToken: () async => + throw _ServiceException(), ), ); session = await fetchAuthSession(willRefresh: true); @@ -696,13 +699,14 @@ void main() { stateMachine ..addInstance( MockCognitoIdentityProviderClient( - getTokensFromRefreshToken: () async => GetTokensFromRefreshTokenResponse( - authenticationResult: AuthenticationResultType( - accessToken: newAccessToken.raw, - refreshToken: refreshToken, - idToken: newIdToken.raw, - ), - ), + getTokensFromRefreshToken: () async => + GetTokensFromRefreshTokenResponse( + authenticationResult: AuthenticationResultType( + accessToken: newAccessToken.raw, + refreshToken: refreshToken, + idToken: newIdToken.raw, + ), + ), ), ) ..addInstance( @@ -756,13 +760,14 @@ void main() { stateMachine ..addInstance( MockCognitoIdentityProviderClient( - getTokensFromRefreshToken: () async => GetTokensFromRefreshTokenResponse( - authenticationResult: AuthenticationResultType( - accessToken: newAccessToken.raw, - refreshToken: newRefreshToken, - idToken: newIdToken.raw, - ), - ), + getTokensFromRefreshToken: () async => + GetTokensFromRefreshTokenResponse( + authenticationResult: AuthenticationResultType( + accessToken: newAccessToken.raw, + refreshToken: newRefreshToken, + idToken: newIdToken.raw, + ), + ), ), ) ..addInstance( @@ -795,9 +800,8 @@ void main() { stateMachine ..addInstance( MockCognitoIdentityProviderClient( - getTokensFromRefreshToken: () async => throw const AuthNotAuthorizedException( - 'Tokens expired', - ), + getTokensFromRefreshToken: () async => + throw const AuthNotAuthorizedException('Tokens expired'), ), ) ..addInstance( @@ -911,7 +915,8 @@ void main() { stateMachine ..addInstance( MockCognitoIdentityProviderClient( - getTokensFromRefreshToken: () async => throw _ServiceException(), + getTokensFromRefreshToken: () async => + throw _ServiceException(), ), ) ..addInstance( @@ -1288,13 +1293,14 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - getTokensFromRefreshToken: () async => GetTokensFromRefreshTokenResponse( - authenticationResult: AuthenticationResultType( - accessToken: newAccessToken.raw, - refreshToken: refreshToken, - idToken: newIdToken.raw, - ), - ), + getTokensFromRefreshToken: () async => + GetTokensFromRefreshTokenResponse( + authenticationResult: AuthenticationResultType( + accessToken: newAccessToken.raw, + refreshToken: refreshToken, + idToken: newIdToken.raw, + ), + ), ), ); session = await fetchAuthSession(willRefresh: true); @@ -1334,7 +1340,8 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - getTokensFromRefreshToken: () async => throw _ServiceException(), + getTokensFromRefreshToken: () async => + throw _ServiceException(), ), ); session = await fetchAuthSession(willRefresh: true); @@ -1389,13 +1396,14 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - getTokensFromRefreshToken: () async => GetTokensFromRefreshTokenResponse( - authenticationResult: AuthenticationResultType( - accessToken: newAccessToken.raw, - refreshToken: refreshToken, - idToken: newIdToken.raw, - ), - ), + getTokensFromRefreshToken: () async => + GetTokensFromRefreshTokenResponse( + authenticationResult: AuthenticationResultType( + accessToken: newAccessToken.raw, + refreshToken: refreshToken, + idToken: newIdToken.raw, + ), + ), ), ); session = await fetchAuthSession(willRefresh: true); @@ -1435,7 +1443,8 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - getTokensFromRefreshToken: () async => throw _ServiceException(), + getTokensFromRefreshToken: () async => + throw _ServiceException(), ), ); session = await fetchAuthSession(willRefresh: true); @@ -1488,13 +1497,14 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - getTokensFromRefreshToken: () async => GetTokensFromRefreshTokenResponse( - authenticationResult: AuthenticationResultType( - accessToken: newAccessToken.raw, - refreshToken: refreshToken, - idToken: newIdToken.raw, - ), - ), + getTokensFromRefreshToken: () async => + GetTokensFromRefreshTokenResponse( + authenticationResult: AuthenticationResultType( + accessToken: newAccessToken.raw, + refreshToken: refreshToken, + idToken: newIdToken.raw, + ), + ), ), ); session = await fetchAuthSession( @@ -1538,7 +1548,8 @@ void main() { await configureAmplify(config); stateMachine.addInstance( MockCognitoIdentityProviderClient( - getTokensFromRefreshToken: () async => throw _ServiceException(), + getTokensFromRefreshToken: () async => + throw _ServiceException(), ), ); session = await fetchAuthSession( From 18ef6f057724032965bebf9754febd87c91f51d3 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Fri, 15 Aug 2025 15:02:27 -0700 Subject: [PATCH 3/7] uninstall xcodes before attempting a new installation during iOS simulator gh action --- .github/composite_actions/launch_ios_simulator/dist/main.cjs | 2 +- .../lib/src/screens/authenticator_screen.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/composite_actions/launch_ios_simulator/dist/main.cjs b/.github/composite_actions/launch_ios_simulator/dist/main.cjs index 30a2c84da3..3af8589577 100644 --- a/.github/composite_actions/launch_ios_simulator/dist/main.cjs +++ b/.github/composite_actions/launch_ios_simulator/dist/main.cjs @@ -14679,7 +14679,7 @@ case 0: // Function start $async$goto = 2; - return A._asyncAwait(A.Exec_exec(type$.JSObject._as(self.exec), "brew", A._setArrayType(["install", "xcodesorg/made/xcodes", "aria2"], type$.JSArray_String), true), $async$call$0); + return A._asyncAwait(A.Exec_exec(type$.JSObject._as(self.exec), "/bin/sh", A._setArrayType(["-c", "brew uninstall --ignore-dependencies aria2 xcodes || true && brew install xcodesorg/made/xcodes aria2"], type$.JSArray_String), true), $async$call$0); case 2: // returning from await. if ($async$result.exitCode !== 0) diff --git a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart index 92b3d2ed83..e0826ef579 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart @@ -255,7 +255,7 @@ class _AuthenticatorTabViewState final isDark = Theme.of(context).brightness == Brightness.dark; final labelColor = Theme.of(context).tabBarTheme.labelColor; final textColor = Theme.of(context).textTheme.bodySmall?.color; - final fallbackColor = isDark ? Colors.white : Colors.black; + final fallbackColor = isDark ? Colors.white : Colors.white; return labelColor ?? textColor ?? fallbackColor; } From 454e124be53b03442d4c0c8f71afbf9f0aedca2b Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Fri, 15 Aug 2025 15:25:28 -0700 Subject: [PATCH 4/7] undid sample change to trigger ios tests --- .../lib/src/screens/authenticator_screen.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart index e0826ef579..92b3d2ed83 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart @@ -255,7 +255,7 @@ class _AuthenticatorTabViewState final isDark = Theme.of(context).brightness == Brightness.dark; final labelColor = Theme.of(context).tabBarTheme.labelColor; final textColor = Theme.of(context).textTheme.bodySmall?.color; - final fallbackColor = isDark ? Colors.white : Colors.white; + final fallbackColor = isDark ? Colors.white : Colors.black; return labelColor ?? textColor ?? fallbackColor; } From 2eb2c6c6508252f16a16350281fb7f6d0aaaa232 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Mon, 18 Aug 2025 13:54:50 -0700 Subject: [PATCH 5/7] changed to brew install xcodes --- .github/composite_actions/launch_ios_simulator/dist/main.cjs | 2 +- .../lib/src/screens/authenticator_screen.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/composite_actions/launch_ios_simulator/dist/main.cjs b/.github/composite_actions/launch_ios_simulator/dist/main.cjs index 3af8589577..da956c533e 100644 --- a/.github/composite_actions/launch_ios_simulator/dist/main.cjs +++ b/.github/composite_actions/launch_ios_simulator/dist/main.cjs @@ -14679,7 +14679,7 @@ case 0: // Function start $async$goto = 2; - return A._asyncAwait(A.Exec_exec(type$.JSObject._as(self.exec), "/bin/sh", A._setArrayType(["-c", "brew uninstall --ignore-dependencies aria2 xcodes || true && brew install xcodesorg/made/xcodes aria2"], type$.JSArray_String), true), $async$call$0); + return A._asyncAwait(A.Exec_exec(type$.JSObject._as(self.exec), "/bin/sh", A._setArrayType(["-c", "brew install xcodes"], type$.JSArray_String), true), $async$call$0); case 2: // returning from await. if ($async$result.exitCode !== 0) diff --git a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart index 92b3d2ed83..4bb92c655c 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart @@ -255,7 +255,7 @@ class _AuthenticatorTabViewState final isDark = Theme.of(context).brightness == Brightness.dark; final labelColor = Theme.of(context).tabBarTheme.labelColor; final textColor = Theme.of(context).textTheme.bodySmall?.color; - final fallbackColor = isDark ? Colors.white : Colors.black; + final fallbackColor = isDark ? Colors.white : Colors.red; return labelColor ?? textColor ?? fallbackColor; } From 1f73e87b8141aa327ce42f62306068ad4a2453c1 Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Mon, 18 Aug 2025 15:28:12 -0700 Subject: [PATCH 6/7] changed test commit --- .../lib/src/screens/authenticator_screen.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart index 4bb92c655c..92b3d2ed83 100644 --- a/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart +++ b/packages/authenticator/amplify_authenticator/lib/src/screens/authenticator_screen.dart @@ -255,7 +255,7 @@ class _AuthenticatorTabViewState final isDark = Theme.of(context).brightness == Brightness.dark; final labelColor = Theme.of(context).tabBarTheme.labelColor; final textColor = Theme.of(context).textTheme.bodySmall?.color; - final fallbackColor = isDark ? Colors.white : Colors.red; + final fallbackColor = isDark ? Colors.white : Colors.black; return labelColor ?? textColor ?? fallbackColor; } From eeb614a328a568b59308139d29924d692db5ebbf Mon Sep 17 00:00:00 2001 From: Ekjot <43255916+ekjotmultani@users.noreply.github.com> Date: Mon, 18 Aug 2025 15:37:35 -0700 Subject: [PATCH 7/7] updated to use activeThumbColor instead of activeColor in a datastore widget --- packages/amplify_datastore/example/lib/widgets/public_view.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/amplify_datastore/example/lib/widgets/public_view.dart b/packages/amplify_datastore/example/lib/widgets/public_view.dart index f85c0e390c..393ba7bd20 100644 --- a/packages/amplify_datastore/example/lib/widgets/public_view.dart +++ b/packages/amplify_datastore/example/lib/widgets/public_view.dart @@ -308,7 +308,7 @@ class _PublicViewState extends State } }, activeTrackColor: Colors.lightGreenAccent, - activeColor: Colors.green, + activeThumbColor: Colors.green, ), Padding(padding: EdgeInsets.all(5.0)),