hanc-webrtc-widgets 2.8.7 → 2.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@ export declare class CallbackApiError extends Error {
5
5
  constructor(status: number, body: ApiError);
6
6
  }
7
7
  export declare function fetchManifest(agentId: string, apiBaseUrl?: string): Promise<Manifest>;
8
- export declare function submitCallback(agentId: string, phone: string, country: string, apiBaseUrl?: string, pageUrl?: string): Promise<SubmitResponse>;
8
+ export declare function submitCallback(agentId: string, phone: string, country: string, apiBaseUrl?: string, pageUrl?: string, recaptchaToken?: string): Promise<SubmitResponse>;
9
9
  export declare function fetchStatus(requestId: string, apiBaseUrl?: string, signal?: AbortSignal): Promise<StatusResponse>;
10
10
  export declare function cancelCallback(requestId: string, apiBaseUrl?: string): Promise<void>;
11
11
  /**
@@ -1,5 +1,13 @@
1
1
  import { LitElement, nothing } from 'lit';
2
2
  import { Manifest } from './types';
3
+ declare global {
4
+ interface Window {
5
+ grecaptcha?: {
6
+ render: (el: HTMLElement, params: Record<string, unknown>) => number;
7
+ reset: (widgetId?: number) => void;
8
+ };
9
+ }
10
+ }
3
11
  export declare class HancAiCallback extends LitElement {
4
12
  agentId: string;
5
13
  apiBaseUrl: string;
@@ -28,6 +36,9 @@ export declare class HancAiCallback extends LitElement {
28
36
  private apiError;
29
37
  private pickerOpen;
30
38
  private pickerSearch;
39
+ private recaptchaToken;
40
+ private recaptchaWidgetId;
41
+ private recaptchaRendering;
31
42
  /**
32
43
  * Once a submit succeeds (visitor's phone is in the queue / being dialed /
33
44
  * the call ended), the widget is "spent" for this page-load. open() will
@@ -53,6 +64,14 @@ export declare class HancAiCallback extends LitElement {
53
64
  connectedCallback(): Promise<void>;
54
65
  disconnectedCallback(): void;
55
66
  protected updated(changed: Map<string, unknown>): void;
67
+ /**
68
+ * Render (or tear down) the reCAPTCHA checkbox to match the current view.
69
+ * Only acts when the manifest shipped a site key. The form subtree is
70
+ * destroyed/recreated by Lit when leaving the form, so we drop the stale
71
+ * widget id on exit and render afresh into the new `.recaptcha-box` element
72
+ * the next time the form mounts.
73
+ */
74
+ private syncRecaptcha;
56
75
  private loadManifest;
57
76
  private adoptManifest;
58
77
  private detectCountryFromLocale;
@@ -62,6 +81,7 @@ export declare class HancAiCallback extends LitElement {
62
81
  private selectCountry;
63
82
  private onPhoneInput;
64
83
  private validatePhoneSoft;
84
+ private resetRecaptcha;
65
85
  private onSubmit;
66
86
  private handleSubmitError;
67
87
  private onCancel;
@@ -29,6 +29,13 @@ export interface Manifest {
29
29
  retry: ManifestRetry;
30
30
  allowed_countries: ManifestCountry[];
31
31
  terms?: ManifestTerms;
32
+ /**
33
+ * Public Google reCAPTCHA v2 site key. Present only when the platform has
34
+ * reCAPTCHA configured — the widget then renders the captcha and sends the
35
+ * resulting token to /submit (server verifies it, gate 4). Absent = no
36
+ * captcha rendered, behaviour unchanged.
37
+ */
38
+ recaptcha_site_key?: string;
32
39
  }
33
40
  export type CallbackStatus = 'queued' | 'dialing' | 'completed' | 'failed' | 'cancelled' | 'expired';
34
41
  export interface StatusResponse {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hanc-webrtc-widgets",
3
- "version": "2.8.7",
3
+ "version": "2.9.2",
4
4
  "type": "module",
5
5
  "main": "dist/hanc-webrtc-widgets.umd.js",
6
6
  "module": "dist/hanc-webrtc-widgets.es.js",