From 0f81bef9811dd13e13876fc577fa997a5070bc5f Mon Sep 17 00:00:00 2001 From: Joon Choi <13882232+joon-won@users.noreply.github.com> Date: Fri, 20 Dec 2024 20:09:23 -0800 Subject: [PATCH] chore(auth): update auth error message and description (#14098) * Update AuthError message with updated auth behavior --------- Co-authored-by: James Jarvis --- packages/auth/src/client/utils/store/signInStore.ts | 7 ++++--- packages/auth/src/providers/cognito/apis/confirmSignIn.ts | 4 ++-- packages/aws-amplify/package.json | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/auth/src/client/utils/store/signInStore.ts b/packages/auth/src/client/utils/store/signInStore.ts index 80b27f2a1c2..ceb86815693 100644 --- a/packages/auth/src/client/utils/store/signInStore.ts +++ b/packages/auth/src/client/utils/store/signInStore.ts @@ -24,8 +24,9 @@ type SignInAction = | { type: 'SET_SIGN_IN_SESSION'; value?: string } | { type: 'RESET_STATE' }; -// Minutes until stored session invalidates -const MS_TO_EXPIRY = 3 * 60 * 1000; // 3 mins +// Minutes until stored session invalidates is defaulted to 3 minutes +// to maintain parity with Amazon Cognito user pools API behavior +const MS_TO_EXPIRY = 3 * 60 * 1000; const TGT_STATE = 'CognitoSignInState'; const SIGN_IN_STATE_KEYS = { username: `${TGT_STATE}.username`, @@ -104,7 +105,7 @@ const getDefaultState = (): SignInState => ({ signInSession: undefined, }); -// Hydrate signInStore from syncSessionStorage +// Hydrate signInStore from syncSessionStorage if the session has not expired const getInitialState = (): SignInState => { const expiry = syncSessionStorage.getItem(SIGN_IN_STATE_KEYS.expiry); diff --git a/packages/auth/src/providers/cognito/apis/confirmSignIn.ts b/packages/auth/src/providers/cognito/apis/confirmSignIn.ts index 9a9af8e75b5..3edb0e9eab0 100644 --- a/packages/auth/src/providers/cognito/apis/confirmSignIn.ts +++ b/packages/auth/src/providers/cognito/apis/confirmSignIn.ts @@ -76,11 +76,11 @@ export async function confirmSignIn( This most likely occurred due to: 1. signIn was not called before confirmSignIn. 2. signIn threw an exception. - 3. page was refreshed during the sign in flow. + 3. page was refreshed during the sign in flow and session has expired. `, recoverySuggestion: 'Make sure a successful call to signIn is made before calling confirmSignIn' + - 'and that the page is not refreshed until the sign in process is done.', + 'and that the session has not expired.', }); try { diff --git a/packages/aws-amplify/package.json b/packages/aws-amplify/package.json index f5e6d8dc8e3..f021873f383 100644 --- a/packages/aws-amplify/package.json +++ b/packages/aws-amplify/package.json @@ -449,7 +449,7 @@ "name": "[Auth] Basic Auth Flow (Cognito)", "path": "./dist/esm/auth/index.mjs", "import": "{ signIn, signOut, fetchAuthSession, confirmSignIn }", - "limit": "30.88 kB" + "limit": "30.89 kB" }, { "name": "[Auth] OAuth Auth Flow (Cognito)",