UNPKG

@benny_gebeya/gebeya-whatsapp-otp

Version:

React WhatsApp OTP verification component library with Supabase integration for phone number authentication

81 lines 2.69 kB
/** * Configuration interface for WhatsApp OTP integration with Supabase */ export interface WhatsAppOTPConfig { /** Supabase project URL */ supabaseUrl: string; /** Supabase anon/service role key */ supabaseKey: string; /** Default country code (e.g., "+251" for Ethiopia) */ defaultCountry?: string; } /** * Callback functions for WhatsApp OTP events */ export interface WhatsAppOTPCallbacks { /** Called when OTP verification is successful */ onSuccess?: (phoneNumber: string) => void; /** Called when an error occurs during the process */ onError?: (error: string) => void; /** Called when the verification step changes */ onStepChange?: (step: VerificationStep) => void; /** Called when a phone number gets suspended */ onSuspension?: (message: string) => void; } /** * Union type representing the different steps in the verification flow */ export type VerificationStep = "phone" | "verify" | "success"; /** * Interface for country selection options */ export interface CountryOption { /** Country calling code (e.g., "+251") */ code: string; /** Country name (e.g., "Ethiopia") */ country: string; /** Country flag emoji (e.g., "🇪🇹") */ flag: string; } /** * Context type for the WhatsApp OTP provider */ export interface WhatsAppOTPContextType { /** Current step in the verification flow */ step: VerificationStep; /** Selected country code */ countryCode: string; /** Phone number entered by user */ phoneNumber: string; /** OTP code entered by user */ otpCode: string; /** Loading state for async operations */ isLoading: boolean; /** Number of verification attempts remaining */ attemptsLeft: number; /** Whether maximum attempts have been reached */ maxAttemptsReached: boolean; /** Whether the phone number is suspended */ isSuspended: boolean; /** Suspension message from the server */ suspensionMessage: string; /** Whether the modal is open */ isModalOpen: boolean; /** Set the selected country code */ setCountryCode: (code: string) => void; /** Set the phone number */ setPhoneNumber: (number: string) => void; /** Set the OTP code */ setOtpCode: (code: string) => void; /** Send OTP to the phone number */ sendOTP: () => Promise<void>; /** Verify the entered OTP code */ verifyOTP: () => Promise<void>; /** Reset the verification flow to initial state */ resetFlow: () => void; /** Open the verification modal */ openModal: () => void; /** Close the verification modal */ closeModal: () => void; } //# sourceMappingURL=index.d.ts.map