Skip to content

Instantly share code, notes, and snippets.

View hrafnkellpalsson's full-sized avatar

Hrafnkell Pálsson hrafnkellpalsson

View GitHub Profile
@hrafnkellpalsson
hrafnkellpalsson / authMachine.js
Last active April 6, 2021 03:58
Auth state machine for AWS Amplify Authenticator component
import { Machine } from "xstate"
import Auth from "@aws-amplify/auth"
import { Hub } from "@aws-amplify/core"
import { sentry } from "../sentry"
import { queryCache } from "react-query"
// Some of the events from the Hub auth channel are in the documentation here
// https://docs.amplify.aws/lib/auth/auth-events/q/platform/js
// Even more events in the source code
// https://github.com/aws-amplify/amplify-js/blob/92d8d800256119d1ba84bb90097f91a983b1e5c0/packages/auth/src/Auth.ts
// API of the search prop is based on React's setState API
// crp stands for "create redirect params"
type O = Record<string, any>
type CrpBase = {
pathname: string
status: number
}
type CrpObj = CrpBase & { search: O }
type CrpFunc = CrpBase & {
// API of the search prop is based on React's setState API
// crp stands for "create redirect params"
type O = Record<string, any>
type CrpBase = {
pathname: string
status: number
}
type CrpObj = CrpBase & { search: O }
type CrpFunc = CrpBase & {