gebeya-telegram-otp
Version:
Reusable Telegram phone verification components for React applications
121 lines (107 loc) • 4.48 kB
TypeScript
import * as react_jsx_runtime from 'react/jsx-runtime';
import { ReactNode } from 'react';
import { ClassValue } from 'clsx';
interface TelegramUser {
id: string;
phone?: string;
phone_confirmed_at?: string;
}
interface TelegramVerificationData {
user: TelegramUser;
phoneNumber: string;
sessionId: string;
verificationMethod: 'telegram';
}
interface TelegramConfig {
botName: string;
botToken?: string;
}
interface TelegramVerifyButtonProps {
onVerificationComplete?: (userData: TelegramVerificationData) => void;
onVerificationStart?: () => void;
buttonText?: string;
variant?: 'default' | 'outline' | 'secondary' | 'ghost';
size?: 'sm' | 'default' | 'lg';
className?: string;
}
interface TelegramVerificationModalProps {
isOpen: boolean;
onClose: () => void;
onVerificationComplete?: (userData: TelegramVerificationData) => void;
onVerificationStart?: () => void;
}
interface TelegramVerificationProviderProps {
children: ReactNode;
supabaseClient: any;
telegramConfig: TelegramConfig;
onSuccess?: (userData: TelegramVerificationData) => void;
onError?: (error: string) => void;
theme?: {
primaryColor?: string;
borderRadius?: string;
fontSize?: string;
};
}
interface AuthFlowProps {
onComplete?: (userData: TelegramVerificationData) => void;
}
type AuthStep = 'phone' | 'qr' | 'otp' | 'success';
interface CountryOption {
code: string;
name: string;
flag: string;
}
declare const TelegramVerifyButton: ({ onVerificationComplete, onVerificationStart, buttonText, variant, size, className }: TelegramVerifyButtonProps) => react_jsx_runtime.JSX.Element;
declare const TelegramVerificationModal: ({ isOpen, onClose, onVerificationComplete, onVerificationStart }: TelegramVerificationModalProps) => react_jsx_runtime.JSX.Element;
interface TelegramVerificationContextType {
supabaseClient: any;
telegramConfig: TelegramConfig;
user: TelegramUser | null;
session: any;
loading: boolean;
onSuccess?: (userData: any) => void;
onError?: (error: string) => void;
theme?: {
primaryColor?: string;
borderRadius?: string;
fontSize?: string;
};
}
declare const useTelegramVerification: () => TelegramVerificationContextType;
declare const TelegramVerificationProvider: ({ children, supabaseClient, telegramConfig, onSuccess, onError, theme }: TelegramVerificationProviderProps) => react_jsx_runtime.JSX.Element;
declare const AuthFlow: ({ onComplete }: AuthFlowProps) => react_jsx_runtime.JSX.Element;
interface PhoneInputProps {
onSubmit: (phone: string) => void;
}
declare const PhoneInput: ({ onSubmit }: PhoneInputProps) => react_jsx_runtime.JSX.Element;
interface QRCodeScreenProps {
phoneNumber: string;
onNext: (sessionId: string) => void;
onBack: () => void;
}
declare const QRCodeScreen: ({ phoneNumber, onNext, onBack, }: QRCodeScreenProps) => react_jsx_runtime.JSX.Element;
interface OTPInputProps {
phoneNumber: string;
sessionId: string;
onVerify: (responseData?: any) => void;
onBack: () => void;
}
declare const OTPInput: ({ phoneNumber, sessionId, onVerify, onBack }: OTPInputProps) => react_jsx_runtime.JSX.Element;
interface SuccessScreenProps {
phoneNumber: string;
onStartOver: () => void;
onComplete: () => void;
actionLink?: string;
}
declare const SuccessScreen: ({ phoneNumber, onStartOver, onComplete, actionLink }: SuccessScreenProps) => react_jsx_runtime.JSX.Element;
interface CountrySelectorProps {
value: string;
onChange: (value: string) => void;
}
declare const CountrySelector: ({ value, onChange }: CountrySelectorProps) => react_jsx_runtime.JSX.Element;
declare const checkVerificationStatus: (phoneNumber: string, supabaseClient: any) => Promise<any>;
declare const validatePhone: (fullPhone: string) => boolean;
declare const formatTime: (seconds: number) => string;
declare function cn(...inputs: ClassValue[]): string;
export { AuthFlow, CountrySelector, OTPInput, PhoneInput, QRCodeScreen, SuccessScreen, TelegramVerificationModal, TelegramVerificationProvider, TelegramVerifyButton, checkVerificationStatus, cn, formatTime, useTelegramVerification, validatePhone };
export type { AuthFlowProps, AuthStep, CountryOption, TelegramConfig, TelegramUser, TelegramVerificationData, TelegramVerificationModalProps, TelegramVerificationProviderProps, TelegramVerifyButtonProps };