Created
January 20, 2021 20:04
-
-
Save kdawgwilk/5e09a25eb390cb96333dea5d94bb22a5 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const authMachine = Machine({ | |
id: 'AuthStateMachine', | |
initial: 'splash', | |
states: { | |
splash: { | |
on: { | |
NEEDS_SECONDARY_AUTH: 'needsSecondaryAuth', | |
LOGGED_OUT: 'loggedOut' | |
} | |
}, | |
loggedOut: { | |
on: { | |
LOGIN: 'loginInProgress' | |
}, | |
}, | |
loginInProgress: { | |
on: { | |
LOGIN_FAILED: 'loggedOut', | |
NEEDS_MFA_SETUP: 'mfaSetup', | |
NEEDS_MFA_CONFIRMATION: 'mfaConfirmation', | |
LOGGED_IN: 'chooseSecondaryAuth' | |
} | |
}, | |
mfaSetup: { | |
on: { | |
NEEDS_MFA_CONFIRMATION: 'mfaConfirmation' | |
} | |
}, | |
mfaConfirmation: { | |
on: { | |
MFA_CONFIRMED: 'chooseSecondaryAuth' | |
} | |
}, | |
needsSecondaryAuth: { | |
on: { | |
SECONDARY_AUTH_SUCCEEDED: 'loggedIn', | |
SECONDARY_AUTH_FAILED_MAX_TRIES: 'loggedOut', | |
SECONDARY_AUTH_FAILED: 'needsSecondaryAuth' | |
} | |
}, | |
chooseSecondaryAuth: { | |
on: { | |
SECONDARY_AUTH_CHOSEN: 'setupSecondaryAuth' | |
} | |
}, | |
setupSecondaryAuth: { | |
on: { | |
SECONDARY_AUTH_SETUP_COMPLETE: 'loggedIn', | |
SECONDARY_AUTH_SETUP_FAILED_MAX_TRIES: 'loggedOut' | |
} | |
}, | |
loggedIn: { | |
on: { | |
LOGOUT: 'loggedOut' | |
} | |
}, | |
}, | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment