paybito-slider-captcha
Version:
A beautiful, interactive slider-based CAPTCHA verification system with puzzle piece matching. Provides secure human verification with an elegant user interface.
116 lines (95 loc) • 2.95 kB
TypeScript
/**
* TypeScript definitions for Paybito Slider Captcha
*/
export interface VerificationSliderOptions {
/** API endpoint for generating CAPTCHA */
apiEndpoint?: string;
/** Tolerance for position matching (default: 5) */
tolerance?: number;
/** Default image URL to use */
defaultImage?: string;
/** Image width in pixels (default: 300) */
imageWidth?: number;
/** Image height in pixels (default: 200) */
imageHeight?: number;
/** Puzzle piece size in pixels (default: 50) */
pieceSize?: number;
}
export interface VerificationResult {
/** Whether verification was successful */
success: boolean;
/** Session ID from the CAPTCHA API (only present on success) */
sessionId?: string;
/** Encrypted response data (only present on success) */
gRecaptchaResponse?: string;
}
export type VerificationCallback = (result: VerificationResult) => void;
export interface CaptchaData {
/** Session ID from the API */
sessionId: string;
/** X position for the puzzle */
positionX: string;
/** Y position for the puzzle */
positionY: string;
/** Base64 encoded image */
baseImage: string;
}
/**
* Interactive slider-based CAPTCHA verification system
*/
export declare class VerificationSlider {
/** API endpoint for CAPTCHA generation */
readonly API_ENDPOINT: string;
/** Current puzzle X position */
readonly puzzleX: number;
/** Current slider value (0-100) */
readonly sliderValue: number;
/** Current CAPTCHA session ID */
readonly captchaId: string;
/** Position tolerance for matching */
readonly tolerance: number;
/** Available puzzle piece shapes */
readonly shapes: string[];
/** Whether the slider is initialized */
readonly isInitialized: boolean;
/** Whether the modal is currently visible */
readonly isVisible: boolean;
/**
* Create a new VerificationSlider instance
* @param options Configuration options
*/
constructor(options?: VerificationSliderOptions);
/**
* Initialize the verification slider
* Creates the modal and sets up the interface
*/
init(): void;
/**
* Show verification modal and start the verification process
* @param callback Function called when verification completes
*/
verify(callback: VerificationCallback): void;
/**
* Hide the verification modal
*/
hideModal(): void;
/**
* Refresh the CAPTCHA puzzle with a new challenge
*/
refreshCaptcha(): void;
/**
* Destroy the verification slider and clean up resources
*/
destroy(): void;
}
/**
* Global instance for backward compatibility
*/
declare const verificationSlider: VerificationSlider;
declare global {
interface Window {
VerificationSlider: typeof VerificationSlider;
verificationSlider: VerificationSlider;
}
}
export default VerificationSlider;