gebeya-whatsapp-otp
Version:
React WhatsApp OTP verification component with Supabase integration
68 lines (61 loc) • 2.22 kB
TypeScript
import * as react from 'react';
import react__default from 'react';
interface CountryOption {
code: string;
country: string;
flag: string;
}
interface WhatsAppOTPConfig {
supabaseUrl: string;
supabaseKey: string;
countries?: CountryOption[];
defaultCountry?: string;
redirectUrl?: string;
}
interface WhatsAppOTPCallbacks {
onSuccess?: (phoneNumber: string) => void;
onError?: (error: string) => void;
onSuspension?: (message: string) => void;
onStepChange?: (step: VerificationStep) => void;
}
type VerificationStep = "phone" | "verify" | "success";
interface WhatsAppOTPProviderProps {
children: react__default.ReactNode;
config: WhatsAppOTPConfig;
callbacks?: WhatsAppOTPCallbacks;
}
declare const WhatsAppOTPProvider: react__default.FC<WhatsAppOTPProviderProps>;
interface VerifyWithWhatsAppButtonProps {
children?: react__default.ReactNode;
className?: string;
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link";
size?: "default" | "sm" | "lg" | "icon";
disabled?: boolean;
}
declare const VerifyWithWhatsAppButton: react__default.FC<VerifyWithWhatsAppButtonProps>;
interface WhatsAppOTPModalProps {
countries?: CountryOption[];
}
declare const WhatsAppOTPModal: react__default.FC<WhatsAppOTPModalProps>;
declare const useWhatsAppOTP: (config: WhatsAppOTPConfig, callbacks?: WhatsAppOTPCallbacks) => {
step: VerificationStep;
countryCode: string;
phoneNumber: string;
otpCode: string;
isLoading: boolean;
attemptsLeft: number;
maxAttemptsReached: boolean;
isSuspended: boolean;
suspensionMessage: string;
isModalOpen: boolean;
setCountryCode: react.Dispatch<react.SetStateAction<string>>;
setPhoneNumber: react.Dispatch<react.SetStateAction<string>>;
setOtpCode: react.Dispatch<react.SetStateAction<string>>;
sendOTP: () => Promise<void>;
verifyOTP: () => Promise<void>;
resetFlow: () => void;
openModal: () => void;
closeModal: () => void;
};
export { VerifyWithWhatsAppButton, WhatsAppOTPModal, WhatsAppOTPProvider, useWhatsAppOTP };
export type { CountryOption, VerificationStep, WhatsAppOTPCallbacks, WhatsAppOTPConfig };