recaptcha-v3.service.d.ts 2.5 KB

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