@hcaptcha/vanilla-hcaptcha
Version:
Vanilla Web Component for hCaptcha. 0 dependencies. <1kb gzipped.
71 lines (70 loc) • 2.08 kB
TypeScript
/// <reference types="@hcaptcha/types" />
export interface VanillaHCaptchaJsApiConfig {
/**
* The hCaptcha JS API.
* Default: "https://js.hcaptcha.com/1/api.js"
*/
jsapi: string;
/**
* Default: true
*/
sentry?: string;
/**
* Disable drop-in replacement for reCAPTCHA with false to prevent
* hCaptcha from injecting into window.grecaptcha.
* Default: true
*/
recaptchacompat?: string;
/**
* hCaptcha auto-detects language via the user's browser.
* This overrides that to set a default UI language.
*/
hl?: string;
endpoint?: string;
reportapi?: string;
assethost?: string;
imghost?: string;
host?: string;
}
type VanillaHCaptchaRenderConfig = Omit<ConfigRender, "callback" | "expired-callback" | "chalexpired-callback" | "error-callback" | "open-callback" | "close-callback">;
export declare class VanillaHCaptchaWebComponent extends HTMLElement {
private hcaptchaId;
private loadJsApiTimeout;
private jsApiLoaded;
connectedCallback(): void;
disconnectedCallback(): void;
static get observedAttributes(): string[];
attributeChangedCallback(): void;
private isJsApiConfigValid;
private tryLoadingJsApi;
private getAttr;
private getJsApiConfig;
private onApiLoaded;
private onError;
private $emit;
/**
* Programmatically render the hCaptcha checkbox.
* The config object must specify all required properties.
* The web component attributes are ignored for more explicit behavior.
* @param config
*/
render(config: VanillaHCaptchaRenderConfig): void;
/**
* Sets the rqdata.
*/
setData(rqdata: string): void;
/**
* Triggers hCaptcha verification.
*/
execute(): void;
/**
* Triggers a verification request.
* Returns a Promise which resolved with the token results or throws in case of errors.
*/
executeAsync(): Promise<HCaptchaResponse>;
/**
* Resets the hCaptcha verification.
*/
reset(): void;
}
export {};