import { AuthStrategyEnum, FronteggApiError, IEnrollMFAWebAuthn, ILoginResponse, IPasswordlessPostLogin, IRecoverMFAToken, ITenantsResponse, IVerifyMFAWebAuthn, IVerifyNewWebAuthnDevice, IWebAuthnPostLogin } from '@frontegg/rest-api'; import { WithCallback } from '../../interfaces'; import { CustomEventsOptions } from '../interfaces'; export declare enum LoginStep { 'preLogin' = "preLogin", 'magicLinkPreLoginSuccess' = "magicLinkPreLoginSuccess", 'loginWithSmsOtc' = "loginWithSmsOtc", 'loginWithQuickSmsOtc' = "loginWithQuickSmsOtc", 'loginWithOtc' = "loginWithOtc", 'loginWithPassword' = "loginWithPassword", 'loginWithTwoFactor' = "loginWithTwoFactor", 'redirectToSSO' = "redirectToSSO", 'loginWithSSOFailed' = "loginWithSSOFailed", 'success' = "success", 'forceTwoFactor' = "forceTwoFactor", 'recoverTwoFactor' = "recoverTwoFactor", 'promptPasskeys' = "promptPasskeys", 'breachedPassword' = "breachedPassword", 'breachedPasswordSuccess' = "breachedPasswordSuccess", 'passwordRotationExpired' = "passwordRotationExpired", 'passwordRotationNotification' = "passwordRotationNotification", 'magicLinkPostLoginSuccess' = "magicLinkPostLoginSuccess", 'chooseTenant' = "chooseTenant" } export declare enum LoginFlow { Login = "login", RegisterQuickLogin = "registerQuickLogin" } export declare enum QuickLoginStrategy { Internal = "internal", UsbKey = "usb-key", Android = "android", Sms = "sms" } export interface LoginState { loading: boolean; error?: any; step: LoginStep; flow: LoginFlow; ssoRedirectUrl?: string; mfaRequired?: boolean; mfaToken?: string; email?: string; username?: string; tenants: ITenantsResponse[]; tenantsLoading?: boolean; allowRememberMfaDevice?: boolean; mfaDeviceExpiration?: number; inviteTokenTenantName?: string; inviteTokenError?: FronteggApiError | string; isNewUser?: boolean; phoneNumber?: string; quickLoginToRegister?: QuickLoginStrategy; changePhoneId?: string; isBreachedPassword?: boolean; resetPasswordToken?: string; passwordExpiresIn?: number; notificationPeriod?: number; userId?: string; /** * Guard for the post-auth "choose organization" gate (choose-organization feature). * Set to true once the user has resolved the tenant choice (or the escape hatch was used), * so re-entry into afterAuthNavigation finalizes without re-prompting. */ tenantChoiceResolved: boolean; /** * True from afterAuthNavigation entry until the choose-organization gate decides (choose-organization * feature, only when `tenantSelection.enabled`). The authenticated user is exposed in the store BEFORE * the gate's async work resolves, so host apps that redirect on `user != null` (e.g. the hosted-login * postlogin) must hold while this is set or they complete the flow before the chooser can render. */ tenantChoicePending?: boolean; /** * True while the choose-organization step is performing switchTenant + showing its success * interstitial. switchTenant refreshes the token, which re-enters afterAuthNavigation; this flag * makes that re-entry a no-op so the chooser controls navigation itself (no flicker / lost success). * Once set it latches on for the rest of the flow so a late/timed-out switch completion can't * navigate after the user already finalized. */ chooseTenantSwitching?: boolean; /** * One-shot flag the choose-organization confirm handler sets to let its single finalize navigation * through the `chooseTenantSwitching` latch; afterAuthNavigation consumes it on the next call so * subsequent (late switch) re-entries remain suppressed. */ chooseTenantFinalizing?: boolean; } export interface HostedLoginCallback { code: string; state?: string; nonce?: string; } export interface FronteggNextJSSession { accessToken: string; refreshToken?: string; user: ILoginResponse; } export interface IQuickSmsPasswordlessPreLoginPayload { userId: string; recaptchaToken?: string; invitationToken?: string; } export interface IPasswordlessPostLoginPayload extends IPasswordlessPostLogin { events?: CustomEventsOptions; } export type IWebAuthnPostLoginPayload = WithCallback> & { publicKey: Credential; }; export type IVerifyNewWebAuthnDevicePayload = WithCallback> & { publicKey: Credential; }; export { AuthStrategyEnum }; export interface IPreEnrollMFAWebAuthNForLoginResponse { webauthnToken: string; options: PublicKeyCredentialCreationOptions; } export interface IPreVerifyMFAWebAuthNForLoginResponse { webauthnToken: string; options: PublicKeyCredentialRequestOptions; } export type WithDeviceId = T & { deviceId: string; }; export type WithPhoneId = T & { phoneId: string; }; export type IEnrollMFAWebAuthnPayload = WithCallback> & { publicKey: Credential; }; export type IVerifyMFAWebAuthnPayload = WithCallback>> & { publicKey: Credential; }; export interface IRecoverMFATokenPayload extends WithCallback { recaptchaToken?: string; } /** * Type for action to set the loading state * @param options.loading - true if in loading state * @param options.error - error if in error state */ export type SetLoadingAction = ({ loading, error }: { loading?: boolean; error?: unknown; }) => void; export declare enum LoginActionTypes { 'social-login' = "social-login", 'custom-social-login' = "custom-social-login", direct = "direct", signup = "signup" } export interface LoginDirectAction { type: keyof typeof LoginActionTypes; data: any; additionalQueryParams?: Record; } export interface AfterAuthNavigationUtilOptions { customLoginAuthenticatedUrl?: string; forceStepUpUrl?: string; shouldStepUpDuringLogin?: boolean; preventRedirectUrlOriginCleaning?: boolean; }