Source

lib/flow-api/types/state.ts

import {
  CredentialOnboardingChooserActions,
  DeviceTrustActions,
  LoginInitActions,
  LoginMethodChooserActions,
  LoginOTPActions,
  LoginPasskeyActions,
  LoginPasswordActions,
  LoginPasswordRecoveryActions,
  LoginSecurityKeyActions,
  MFAAOTPSecretCreationActions,
  MFAMethodChooserActions,
  MFASecurityKeyCreationActions,
  OnboardingCreatePasskeyActions,
  OnboardingEmailActions,
  OnboardingUsernameActions,
  OnboardingVerifyPasskeyAttestationActions,
  PasscodeConfirmationActions,
  PasswordCreationActions,
  PreflightActions,
  ProfileInitActions,
  RegistrationInitActions,
  ThirdPartyActions,
} from "./action";

import {
  LoginInitPayload,
  LoginPasskeyPayload,
  MFAOTPSecretCreationPayload,
  OnboardingVerifyPasskeyAttestationPayload,
  PasscodeConfirmationPayload,
  ProfilePayload,
  SuccessPayload,
  ThirdPartyPayload,
} from "./payload";

/**
 * The name of a possible state within a flow. Every flow (see {@link FlowName}) transitions between
 * a subset of these states; use {@link Actions} and {@link Payloads} to look up what a given state
 * exposes.
 * @category SDK
 * @subcategory Flow Types
 */
export type StateName =
  | "account_deleted"
  | "credential_onboarding_chooser"
  | "device_trust"
  | "error"
  | "login_init"
  | "login_method_chooser"
  | "login_otp"
  | "login_passkey"
  | "login_password"
  | "login_password_recovery"
  | "login_security_key"
  | "mfa_method_chooser"
  | "mfa_otp_secret_creation"
  | "mfa_security_key_creation"
  | "onboarding_create_passkey"
  | "onboarding_email"
  | "onboarding_username"
  | "onboarding_verify_passkey_attestation"
  | "passcode_confirmation"
  | "password_creation"
  | "preflight"
  | "profile_init"
  | "registration_init"
  | "success"
  | "thirdparty"
  | "webauthn_credential_verification";

/**
 * Maps each {@link StateName} to the interface describing the actions available in that state
 * (`null` for states that expose no actions, e.g. terminal states).
 * @interface
 * @category SDK
 * @subcategory Flow Types
 */
export interface Actions {
  readonly account_deleted: null;
  readonly credential_onboarding_chooser: CredentialOnboardingChooserActions;
  readonly device_trust: DeviceTrustActions;
  readonly error: null;
  readonly login_init: LoginInitActions;
  readonly login_method_chooser: LoginMethodChooserActions;
  readonly login_otp: LoginOTPActions;
  readonly login_passkey: LoginPasskeyActions;
  readonly login_password: LoginPasswordActions;
  readonly login_password_recovery: LoginPasswordRecoveryActions;
  readonly login_security_key: LoginSecurityKeyActions;
  readonly mfa_method_chooser: MFAMethodChooserActions;
  readonly mfa_otp_secret_creation: MFAAOTPSecretCreationActions;
  readonly mfa_security_key_creation: MFASecurityKeyCreationActions;
  readonly onboarding_create_passkey: OnboardingCreatePasskeyActions;
  readonly onboarding_email: OnboardingEmailActions;
  readonly onboarding_username: OnboardingUsernameActions;
  readonly onboarding_verify_passkey_attestation: OnboardingVerifyPasskeyAttestationActions;
  readonly passcode_confirmation: PasscodeConfirmationActions;
  readonly password_creation: PasswordCreationActions;
  readonly preflight: PreflightActions;
  readonly profile_init: ProfileInitActions;
  readonly registration_init: RegistrationInitActions;
  readonly success: null;
  readonly thirdparty: ThirdPartyActions;
  readonly webauthn_credential_verification: OnboardingVerifyPasskeyAttestationActions;
}

/**
 * Maps each {@link StateName} to the type describing that state's payload data
 * (`null` for states that carry no payload).
 * @interface
 * @category SDK
 * @subcategory Flow Types
 */
export interface Payloads {
  readonly account_deleted: null;
  readonly credential_onboarding_chooser: null;
  readonly device_trust: null;
  readonly error: null;
  readonly login_init: LoginInitPayload;
  readonly login_method_chooser: null;
  readonly login_otp: null;
  readonly login_passkey: LoginPasskeyPayload;
  readonly login_password: null;
  readonly login_password_recovery: null;
  readonly login_security_key: null;
  readonly mfa_method_chooser: null;
  readonly mfa_otp_secret_creation: MFAOTPSecretCreationPayload;
  readonly mfa_security_key_creation: null;
  readonly onboarding_create_passkey: null;
  readonly onboarding_email: null;
  readonly onboarding_username: null;
  readonly onboarding_verify_passkey_attestation: OnboardingVerifyPasskeyAttestationPayload;
  readonly passcode_confirmation: PasscodeConfirmationPayload;
  readonly password_creation: null;
  readonly preflight: null;
  readonly profile_init: ProfilePayload;
  readonly registration_init: null;
  readonly success: SuccessPayload;
  readonly thirdparty: ThirdPartyPayload;
  readonly webauthn_credential_verification: OnboardingVerifyPasskeyAttestationPayload;
}