UNPKG

tamil-captcha

Version:

A lightweight math-based CAPTCHA generator in Tamil language for Node.js and browser applications

169 lines (149 loc) 5.07 kB
/** * TypeScript definitions for tamil-captcha */ export interface CaptchaOptions { /** Minimum number to use in CAPTCHA (1-10, default: 1) */ minNumber?: number; /** Maximum number to use in CAPTCHA (1-10, default: 10) */ maxNumber?: number; /** Array of operations to use (default: ['+', '-', '*']) */ operations?: Array<'+' | '-' | '*'>; } export interface CaptchaResult { /** Tamil language math question string */ question: string; /** Correct numeric answer */ answer: number; /** Operation used in the question */ operation: '+' | '-' | '*'; /** The two numbers used in the question */ numbers: [number, number]; /** Additional metadata about the CAPTCHA */ metadata: { /** Tamil words for the numbers used */ tamilNumbers: [string, string]; /** Tamil word for the operation */ operationWord: string; }; } export interface OperationInfo { /** Operation key */ key: '+' | '-' | '*'; /** Operation symbol */ symbol: string; /** Tamil word for the operation */ word: string; } /** * Generates a Tamil math CAPTCHA challenge * @param options Configuration options for the CAPTCHA * @returns CAPTCHA object with question and answer */ export function generateCaptcha(options?: CaptchaOptions): CaptchaResult; /** * Verifies if the user's input matches the CAPTCHA answer * @param userInput User's answer (string or number) * @param actualAnswer Correct answer from generateCaptcha() * @returns True if the answer is correct */ export function verifyCaptcha(userInput: string | number, actualAnswer: number): boolean; /** * Gets Tamil word for a number (1-10) * @param number Number to convert (1-10) * @returns Tamil word for the number * @throws Error if number is not between 1 and 10 */ export function getTamilNumber(number: number): string; /** * Gets all available Tamil numbers * @returns Object mapping numbers (1-10) to Tamil words */ export function getAllTamilNumbers(): Record<number, string>; /** * Gets information about available operations * @returns Array of operation details */ export function getOperations(): OperationInfo[]; // Default export (for compatibility) declare const tamilCaptcha: { generateCaptcha: typeof generateCaptcha; verifyCaptcha: typeof verifyCaptcha; getTamilNumber: typeof getTamilNumber; getAllTamilNumbers: typeof getAllTamilNumbers; getOperations: typeof getOperations; }; export default tamilCaptcha;/** * TypeScript definitions for tamil-captcha */ export interface CaptchaOptions { /** Minimum number to use in CAPTCHA (1-10, default: 1) */ minNumber?: number; /** Maximum number to use in CAPTCHA (1-10, default: 10) */ maxNumber?: number; /** Array of operations to use (default: ['+', '-', '*']) */ operations?: Array<'+' | '-' | '*'>; } export interface CaptchaResult { /** Tamil language math question string */ question: string; /** Correct numeric answer */ answer: number; /** Operation used in the question */ operation: '+' | '-' | '*'; /** The two numbers used in the question */ numbers: [number, number]; /** Additional metadata about the CAPTCHA */ metadata: { /** Tamil words for the numbers used */ tamilNumbers: [string, string]; /** Tamil word for the operation */ operationWord: string; }; } export interface OperationInfo { /** Operation key */ key: '+' | '-' | '*'; /** Operation symbol */ symbol: string; /** Tamil word for the operation */ word: string; } /** * Generates a Tamil math CAPTCHA challenge * @param options Configuration options for the CAPTCHA * @returns CAPTCHA object with question and answer */ export function generateCaptcha(options?: CaptchaOptions): CaptchaResult; /** * Verifies if the user's input matches the CAPTCHA answer * @param userInput User's answer (string or number) * @param actualAnswer Correct answer from generateCaptcha() * @returns True if the answer is correct */ export function verifyCaptcha(userInput: string | number, actualAnswer: number): boolean; /** * Gets Tamil word for a number (1-10) * @param number Number to convert (1-10) * @returns Tamil word for the number * @throws Error if number is not between 1 and 10 */ export function getTamilNumber(number: number): string; /** * Gets all available Tamil numbers * @returns Object mapping numbers (1-10) to Tamil words */ export function getAllTamilNumbers(): Record<number, string>; /** * Gets information about available operations * @returns Array of operation details */ export function getOperations(): OperationInfo[]; // Default export (for compatibility) declare const tamilCaptcha: { generateCaptcha: typeof generateCaptcha; verifyCaptcha: typeof verifyCaptcha; getTamilNumber: typeof getTamilNumber; getAllTamilNumbers: typeof getAllTamilNumbers; getOperations: typeof getOperations; }; export default tamilCaptcha;