UNPKG

@aws-amplify/ui

Version:

`@aws-amplify/ui` contains low-level logic & styles for stand-alone usage or re-use in framework-specific implementations.

71 lines (69 loc) 2.84 kB
const getRoute = (state, actorState) => { // 'federatedSignIn' exists as a state on both the 'signInActor' and 'signUpActor', // match against the `actorState` initially to determine if the federated sign in flow // has begun, then which actor has begun the flow and return the corresponding `route` if (actorState?.matches('federatedSignIn')) { if (state.matches('signUpActor')) { return 'signUp'; } if (state.matches('signInActor')) { return 'signIn'; } } switch (true) { case state.matches('idle'): return 'idle'; case state.matches('setup'): return 'setup'; case state.matches('signOut'): return 'signOut'; case state.matches('authenticated'): return 'authenticated'; case actorState?.matches('confirmSignUp'): case actorState?.matches('resendSignUpCode'): return 'confirmSignUp'; case actorState?.matches('confirmSignIn'): return 'confirmSignIn'; case actorState?.matches('setupTotp.edit'): case actorState?.matches('setupTotp.submit'): return 'setupTotp'; case actorState?.matches('signIn.submit'): return actorState?.context.selectedAuthMethod != null ? 'signInSelectAuthFactor' : 'signIn'; case actorState?.matches('signIn.selectMethod'): return 'signInSelectAuthFactor'; case actorState?.matches('passkeyPrompt'): return 'passkeyPrompt'; case actorState?.matches('signIn'): return 'signIn'; case actorState?.matches('signUp'): case actorState?.matches('autoSignIn'): return 'signUp'; case actorState?.matches('forceChangePassword'): return 'forceNewPassword'; case actorState?.matches('forgotPassword'): return 'forgotPassword'; case actorState?.matches('confirmResetPassword'): return 'confirmResetPassword'; case actorState?.matches('selectUserAttributes'): return 'verifyUser'; case actorState?.matches('confirmVerifyUserAttribute'): return 'confirmVerifyUser'; case actorState?.matches('setupEmail'): return 'setupEmail'; case actorState?.matches('selectMfaType'): return 'selectMfaType'; case state.matches('getCurrentUser'): case actorState?.matches('fetchUserAttributes'): /** * This route is needed for autoSignIn to capture both the * autoSignIn.pending and the resolved states when the * signIn actor is running. */ return 'transition'; default: return null; } }; export { getRoute };