UNPKG

2.37 kBTypeScriptView Raw
1import { NgZone } from "@angular/core";
2import { Observable } from "rxjs";
3import { RecaptchaLoaderService } from "./recaptcha-loader.service";
4import * as i0 from "@angular/core";
5export interface OnExecuteData {
6 /**
7 * The name of the action that has been executed.
8 */
9 action: string;
10 /**
11 * The token that reCAPTCHA v3 provided when executing the action.
12 */
13 token: string;
14}
15export interface OnExecuteErrorData {
16 /**
17 * The name of the action that has been executed.
18 */
19 action: string;
20 /**
21 * The error which was encountered
22 */
23 error: any;
24}
25/**
26 * The main service for working with reCAPTCHA v3 APIs.
27 *
28 * Use the `execute` method for executing a single action, and
29 * `onExecute` observable for listening to all actions at once.
30 */
31export declare class ReCaptchaV3Service {
32 recaptchaLoader: RecaptchaLoaderService;
33 /** @internal */
34 private readonly siteKey;
35 /** @internal */
36 private readonly zone;
37 /** @internal */
38 private actionBacklog;
39 /** @internal */
40 private grecaptcha;
41 /** @internal */
42 private onExecuteSubject;
43 /** @internal */
44 private onExecuteErrorSubject;
45 /** @internal */
46 private onExecuteObservable;
47 /** @internal */
48 private onExecuteErrorObservable;
49 constructor(zone: NgZone, recaptchaLoader: RecaptchaLoaderService, siteKey: string);
50 get onExecute(): Observable<OnExecuteData>;
51 get onExecuteError(): Observable<OnExecuteErrorData>;
52 /**
53 * Executes the provided `action` with reCAPTCHA v3 API.
54 * Use the emitted token value for verification purposes on the backend.
55 *
56 * For more information about reCAPTCHA v3 actions and tokens refer to the official documentation at
57 * https://developers.google.com/recaptcha/docs/v3.
58 *
59 * @param {string} action the action to execute
60 * @returns {Observable<string>} an `Observable` that will emit the reCAPTCHA v3 string `token` value whenever ready.
61 * The returned `Observable` completes immediately after emitting a value.
62 */
63 execute(action: string): Observable<string>;
64 /** @internal */
65 private executeActionWithSubject;
66 /** @internal */
67 private init;
68 static ɵfac: i0.ɵɵFactoryDeclaration<ReCaptchaV3Service, never>;
69 static ɵprov: i0.ɵɵInjectableDeclaration<ReCaptchaV3Service>;
70}