UNPKG

recaptcha-node

Version:

A Node.js library to verify reCAPTCHA v2/v3 response tokens received from a client.

53 lines (52 loc) 2.07 kB
/// <reference types="node" /> import { Agent } from 'https'; import { RecaptchaV2Result, RecaptchaV3Result } from './recaptcha-result'; import { ClientOptions } from './client'; export declare type SupportedProtocols = 'https' | 'http'; export declare type RecaptchaOptions = { httpAgent?: Agent; /** The hostname that the client connects to. */ hostname?: string; port?: number | string; protocol?: SupportedProtocols; /** Milliseconds before a request times out. */ timeout?: number; }; declare abstract class Recaptcha implements RecaptchaOptions { private _protocol; httpAgent?: Agent; hostname?: string; port?: number | string; timeout?: number; secretKey: string; /** * * @param {string} secretKey - The secret key used for communication between * your site and reCAPTCHA. */ constructor(secretKey: string, options?: RecaptchaOptions); set protocol(value: SupportedProtocols); get protocol(): SupportedProtocols; _getData(responseToken: string, remoteIP?: string): string; _getClientOptions(responseToken: string, remoteIP?: string): ClientOptions; _request(responseToken: string, remoteIP?: string): Promise<any>; } export declare class RecaptchaV2 extends Recaptcha { /** * Verify the reCAPTCHA v2 response token received from the client. * @param {string} responseToken - The user response token provided by the * reCAPTCHA client-side integration on your site. * @param {string} [remoteIP] - The user's IP address. */ verify(responseToken: string, remoteIP?: string): Promise<RecaptchaV2Result>; } export declare class RecaptchaV3 extends Recaptcha { /** * Verify the reCAPTCHA v3 response token received from the client. * @param {string} responseToken - The user response token provided by the * reCAPTCHA client-side integration on your site. * @param {string} [remoteIP] - The user's IP address. */ verify(responseToken: string, remoteIP?: string): Promise<RecaptchaV3Result>; } export {};