import type { LogoutEventMetadata } from '@dynamic-labs-sdk/client'; import { AuthEventPayload } from '@dynamic-labs/types'; import { SdkErrorCode } from '@dynamic-labs/utils'; import { SdkLogoutReason } from '../context/DynamicContext/hooks/useHandleLogout'; export type AuthEvents = { /** * Informs an auth attempt failed. * In general triggered when an error occurs or when user cancels out. * For email/sms, specifically happens when users cancels the OTP verification. */ authFailure: (method: AuthEventPayload, /** Will be SdkErrorCode.USER_CANCELLED when cancelled, or the error when there is an error */ reason: SdkErrorCode.USER_CANCELLED | { error: unknown; }) => void; /** Informs an auth attempt initialized, and provides insight into which auth option it is */ authInit: (method: AuthEventPayload) => void; logout: (metadata?: LogoutEventMetadata) => void; /** This event is used to trigger logout to be called, DO NOT listen to it. Listen to "logout" instead */ triggerLogout: (reason: SdkLogoutReason) => void; /** * Emitted when the user succesfully completes an MFA challenge */ mfaCompletionSuccess: (args: { mfaToken?: string; }) => void; /** * Emitted when there is an error verifiyng the MFA challenge */ mfaCompletionFailure: (args: { error: unknown; }) => void; };