@pangz/ng-cloudflare-turnstile
Version:
An intuitive, lightweight and easy to integrate cloudflare-turnstile component for Angular.
157 lines (156 loc) • 4.44 kB
TypeScript
import { EventEmitter, type AfterViewInit, type OnInit } from '@angular/core';
import * as i0 from "@angular/core";
declare global {
interface Window {
onloadTurnstileCallback: () => void;
turnstile: {
render: (idOrContainer: string | HTMLElement, options: any) => string;
reset: (widgetIdOrContainer: string | HTMLElement) => void;
getResponse: (widgetIdOrContainer: string | HTMLElement) => string | undefined;
remove: (widgetIdOrContainer: string | HTMLElement) => void;
};
}
}
export declare enum DevSiteKey {
ALWAYS_PASSES = "1x00000000000000000000AA",
ALWAYS_BLOCKS = "2x00000000000000000000AB",
ALWAYS_PASSES_INVISIBLE = "1x00000000000000000000BB",
ALWAYS_BLOCKS_INVISIBLE = "2x00000000000000000000BB",
FORCE_INTERACTIVE_CHALLENGE = "3x00000000000000000000FF"
}
export declare enum Language {
AUTO = "auto",
ARABIC = "ar-eg",
BULGARIAN = "bg-bg",
CHINESE_SIMPLIFIED = "zh-cn",
CHINESE_TRADITIONAL = "zh-tw",
CROATIAN = "hr-hr",
CZECH = "cs-cz",
DANISH = "da-dk",
DUTCH = "nl-nl",
ENGLISH = "en-us",
FARSI = "fa-ir",
FINNISH = "fi-fi",
FRENCH = "fr-fr",
GERMAN = "de-de",
GREEK = "el-gr",
HEBREW = "he-il",
HINDI = "hi-in",
HUNGARIAN = "hu-hu",
INDONESIAN = "id-id",
ITALIAN = "it-it",
JAPANESE = "ja-jp",
KLINGON = "tlh",
KOREAN = "ko-kr",
LITHUANIAN = "lt-lt",
MALAY = "ms-my",
NORWEGIAN = "nb-no",
POLISH = "pl-pl",
PORTUGUESE = "pt-br",
ROMANIAN = "ro-ro",
RUSSIAN = "ru-ru",
SERBIAN = "sr-ba",
SLOVAK = "sk-sk",
SLOVENIAN = "sl-si",
SPANISH = "es-es",
SWEDISH = "sv-se",
TAGALOG = "tl-ph",
THAI = "th-th",
TURKISH = "tr-tr",
UKRAINIAN = "uk-ua",
VIETNAMESE = "vi-vn"
}
export declare enum Theme {
LIGHT = "light",
DARK = "dark",
AUTO = "auto"
}
export declare enum Size {
NORMAL = "normal",
FLEXIBLE = "flexible",
COMPACT = "compact"
}
export declare enum Appearance {
ALWAYS = "always",
EXECUTE = "execute",
INTERACTION_ONLY = "interaction-only"
}
export declare enum Retry {
AUTO = "auto",
NEVER = "never"
}
export declare enum RefreshExpiry {
AUTO = "auto",
MANUAL = "manual",
NEVER = "never"
}
export declare enum RefreshTimeout {
AUTO = "auto",
MANUAL = "manual",
NEVER = "never"
}
export declare enum State {
SUCCESS = 0,
WIDGET_CREATED = 1,
WIDGET_REMOVED = 2,
WIDGET_RESET = 3,
AFTER_INTERACTIVE = 4,
BEFORE_INTERACTIVE = 5,
ERROR = -1,
EXPIRED = -2,
TIMEOUT = -3
}
export type Result = {
name: string;
data?: any;
result: number;
manager: TurnstileManager;
};
export type EventCallback = (d: Result) => void;
export type Config = {
siteKey: string;
action?: string;
cData?: string;
tabIndex?: number;
language?: Language;
theme?: Theme;
responseField?: boolean;
size?: Size;
appearance?: Appearance;
retry?: Retry;
retryInterval?: number;
refreshExpired?: RefreshExpiry;
refreshTimeout?: RefreshTimeout;
feedbackEnabled?: boolean;
onSuccess?: EventCallback;
onError?: EventCallback;
onExpired?: EventCallback;
onBeforeInteractive?: EventCallback;
onAfterInteractive?: EventCallback;
onTimeout?: EventCallback;
onCreate?: EventCallback;
onReset?: EventCallback;
onRemove?: EventCallback;
};
export declare class TurnstileManager {
private obj;
private event;
private widgetId;
private containerRef;
private options;
constructor(obj: any, event: EventEmitter<Result>, widgetId?: string, containerRef?: string | HTMLElement, options?: any);
reRender(options: Config): void;
reset(id: string | HTMLElement | null): void;
remove(id: string | HTMLElement | null): void;
private updateOptions;
}
export declare class NgCloudflareTurnstile implements AfterViewInit, OnInit {
config: Config;
event: EventEmitter<Result>;
constructor();
ngOnInit(): void;
ngAfterViewInit(): void;
private loadTurnstileScript;
static ɵfac: i0.ɵɵFactoryDeclaration<NgCloudflareTurnstile, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<NgCloudflareTurnstile, "ng-cloudflare-turnstile", never, { "config": { "alias": "config"; "required": false; }; }, { "event": "event"; }, never, never, true, never>;
}