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 0678275f812..8c52bf30a1d 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)",