@ada-cx/messaging-sdk 1.0.0-setup.0
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.
- package/README.md +211 -0
- package/dist/client/ada-settings-reader.d.ts +10 -0
- package/dist/client/client-channel-handlers.d.ts +92 -0
- package/dist/client/client-errors.d.ts +7 -0
- package/dist/client/client-frame-constants.d.ts +41 -0
- package/dist/client/client-frame-runtime.d.ts +54 -0
- package/dist/client/client-host-runtime.d.ts +73 -0
- package/dist/client/client-types.d.ts +231 -0
- package/dist/client/client.d.ts +843 -0
- package/dist/client/config-helpers.d.ts +157 -0
- package/dist/client/constants.d.ts +61 -0
- package/dist/client/core-channel-test-harness.d.ts +47 -0
- package/dist/client/embed-interface.d.ts +172 -0
- package/dist/client/embed-lifecycle.d.ts +12 -0
- package/dist/client/fallback-html.d.ts +1 -0
- package/dist/client/frame-manager.d.ts +64 -0
- package/dist/client/frame-styles.d.ts +164 -0
- package/dist/client/frame-visibility.d.ts +53 -0
- package/dist/client/integration-manager.d.ts +73 -0
- package/dist/client/legacy-callback-adapter.d.ts +22 -0
- package/dist/client/mask-element.d.ts +19 -0
- package/dist/client/proactive/index.d.ts +5 -0
- package/dist/client/proactive/proactive-channel.d.ts +33 -0
- package/dist/client/proactive/proactive-runtime.d.ts +65 -0
- package/dist/client/proactive/proactive-utils.d.ts +51 -0
- package/dist/client/sdk-error-reporter.d.ts +22 -0
- package/dist/client/sdk-event-bus.d.ts +116 -0
- package/dist/client/service-worker-notifications.d.ts +1 -0
- package/dist/client/url-business-events.d.ts +19 -0
- package/dist/frame-channel/frame-channel.d.ts +64 -0
- package/dist/frame-channel/frame-child.d.ts +45 -0
- package/dist/frame-channel/index.d.ts +3 -0
- package/dist/frame-channel/types.d.ts +736 -0
- package/dist/helpers/rollout.d.ts +18 -0
- package/dist/host-telemetry.d.ts +15 -0
- package/dist/index.d.ts +8 -0
- package/dist/logger.d.ts +59 -0
- package/dist/mobile-webview-runtime.d.ts +122 -0
- package/dist/npm/build-info.d.cts +17 -0
- package/dist/npm/build-info.d.ts +17 -0
- package/dist/npm/index.cjs +276 -0
- package/dist/npm/index.cjs.map +1 -0
- package/dist/npm/index.d.cts +15 -0
- package/dist/npm/index.d.ts +9 -0
- package/dist/npm/index.js +270 -0
- package/dist/npm/index.js.map +1 -0
- package/dist/npm/loader.d.cts +120 -0
- package/dist/npm/loader.d.ts +120 -0
- package/dist/npm/testing.cjs +155 -0
- package/dist/npm/testing.cjs.map +1 -0
- package/dist/npm/testing.d.cts +39 -0
- package/dist/npm/testing.d.ts +39 -0
- package/dist/npm/testing.js +154 -0
- package/dist/npm/testing.js.map +1 -0
- package/dist/sdk-module-loader.d.ts +1 -0
- package/dist/shared-utils/clusters.d.ts +5 -0
- package/dist/shared-utils/csat.d.ts +116 -0
- package/dist/shared-utils/host-telemetry.d.ts +35 -0
- package/dist/shared-utils/index.d.ts +3 -0
- package/dist/voice/voice-manager.d.ts +120 -0
- package/package.json +77 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determine whether this visitor should see the chat widget for the given rollout percentage.
|
|
3
|
+
*
|
|
4
|
+
* - `rollout == null` → always show (100%)
|
|
5
|
+
* - Non-finite values (NaN, ±Infinity) → fail open (always show)
|
|
6
|
+
* - `rollout >= 1` → always show (100%)
|
|
7
|
+
* - `rollout <= 0` → never show (0%)
|
|
8
|
+
* - Otherwise, persist a stable draw in [0,1) for the visitor and show whenever
|
|
9
|
+
* `draw < rollout`.
|
|
10
|
+
*
|
|
11
|
+
* Persisting the draw rather than the resulting group is what makes ramping monotone:
|
|
12
|
+
* raising the percentage only ever adds visitors and lowering it only ever removes them,
|
|
13
|
+
* so an already-assigned visitor is never re-bucketed by a percentage change. This mirrors
|
|
14
|
+
* the CDN version rollout in `scripts/sdk.js` (`selectAssignment` / `readStoredAssignment`).
|
|
15
|
+
*
|
|
16
|
+
* Fails open (returns true) if localStorage is unavailable (private browsing, storage blocked).
|
|
17
|
+
*/
|
|
18
|
+
export declare function isInRollout(handle: string, rollout: number | null | undefined): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { HostTelemetryContext, HostTelemetryPlatform, HostTelemetrySurface, HostTelemetryWebSdkOrigin } from "./shared-utils/index.js";
|
|
2
|
+
export type { HostTelemetryContext, HostTelemetryMobileShell, HostTelemetryPlatform, HostTelemetrySurface, HostTelemetryWebSdkOrigin, } from "./shared-utils/index.js";
|
|
3
|
+
export declare const HOST_TELEMETRY_QUERY_PARAM = "ada_host_telemetry";
|
|
4
|
+
interface HostTelemetryCarrier {
|
|
5
|
+
hostTelemetry?: unknown;
|
|
6
|
+
}
|
|
7
|
+
export declare function normalizeHostTelemetry(value: unknown): HostTelemetryContext | undefined;
|
|
8
|
+
export declare function attachInternalHostTelemetry<T extends object>(target: T, hostTelemetry?: HostTelemetryContext): T;
|
|
9
|
+
export declare function readInternalHostTelemetry(value: unknown): HostTelemetryContext | undefined;
|
|
10
|
+
export declare function stripPublicHostTelemetry<T extends object>(value: T): T;
|
|
11
|
+
export declare function resolveHostTelemetry(carrier: HostTelemetryCarrier, { defaultOrigin, defaultSurface, defaultPlatform, }: {
|
|
12
|
+
defaultOrigin: HostTelemetryWebSdkOrigin;
|
|
13
|
+
defaultSurface: HostTelemetrySurface;
|
|
14
|
+
defaultPlatform?: HostTelemetryPlatform;
|
|
15
|
+
}): HostTelemetryContext;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { AdaMessagingClient } from "./client/client.js";
|
|
2
|
+
export type { AdaMessagingClientConfig, AdaMessagingSettings, AdaMessagingStartOptions, AdaReadyCallbackParams, AdaSdkEventCallback, AdaSdkEventContext, AdaSdkEventKey, BeforeSend, ConversationInfo, Delegate, MetaFieldValue, PublicAgentInfo, PublicMessage, ResetParams, SendMessageResult, WindowInfo, } from "./client/client-types.js";
|
|
3
|
+
export { type ChatHtmlConfig, resolveChatHtmlConfig, } from "./client/config-helpers.js";
|
|
4
|
+
export type { AdaEmbedInterface, LoaderQueueAction, LoaderQueueActionOutcome, LoaderQueueActionOutcomeHandler, } from "./client/embed-interface.js";
|
|
5
|
+
export { createAdaEmbedInterface, dispatchEmbedLoaderInitialActionQueue, dispatchEmbedLoaderInitialActionQueueForAtomicHandoff, } from "./client/embed-interface.js";
|
|
6
|
+
export type { FrameMessage, FrameName, FrameToSdkEvents, SdkToFrameEvents, } from "./frame-channel/index.js";
|
|
7
|
+
export { FrameChannel, FrameChild } from "./frame-channel/index.js";
|
|
8
|
+
export { mountAdaWebViewRuntime, resolveAdaWebViewRuntimeAssets, } from "./mobile-webview-runtime.js";
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-page logger.
|
|
3
|
+
*
|
|
4
|
+
* The SDK runs directly on the customer's page, so its console output lands in
|
|
5
|
+
* *their* root window console. Anything written unconditionally is noise a
|
|
6
|
+
* customer cannot turn off and cannot attribute.
|
|
7
|
+
*
|
|
8
|
+
* The gate is deliberately asymmetric:
|
|
9
|
+
*
|
|
10
|
+
* - **`warn` / `debug` are gated.** These fire on ordinary page loads —
|
|
11
|
+
* deprecated-method calls, lifecycle diagnostics, a slow frame origin report.
|
|
12
|
+
* None of them mean anything is broken, so production is silent by default.
|
|
13
|
+
* - **`error` is never gated.** The remaining `logger.error` sites are all
|
|
14
|
+
* caught exceptions from host-supplied code — an `adaEmbed` subscriber, a
|
|
15
|
+
* window callback, custom JS — plus frame origin mismatches. Because the throw
|
|
16
|
+
* is caught, nothing else reports it: `setupSdkErrorReporter` only sees
|
|
17
|
+
* `window.onerror`, `unhandledrejection`, and `ada:error`. Suppressing those
|
|
18
|
+
* removed observability rather than noise.
|
|
19
|
+
*
|
|
20
|
+
* - **`dataLoss` is never gated.** This is the warning channel for a host value
|
|
21
|
+
* the SDK accepted but then had to drop or truncate. A production integration
|
|
22
|
+
* must not need a debug opt-in to learn that its configuration changed.
|
|
23
|
+
*
|
|
24
|
+
* Timeout and queued-loader-rejection sites are deliberately `warn`, not
|
|
25
|
+
* `error`, even though they signal a failure: they fire on slow connections
|
|
26
|
+
* where nothing is actually broken, so an ungated `error` there would be the
|
|
27
|
+
* timing-dependent noise this gate exists to remove. Demoting them costs Ada
|
|
28
|
+
* no telemetry either way — the SDK has no Sentry or Datadog on the host page,
|
|
29
|
+
* so a host-page `console.error` was only ever read by the integrator.
|
|
30
|
+
*
|
|
31
|
+
* Enabling the gated levels on a live site, in order of precedence:
|
|
32
|
+
* 1. `window.adaSettings.debug: true` (host page)
|
|
33
|
+
* 2. `localStorage.setItem("ada.debug", "1")` — the support path, usable from
|
|
34
|
+
* devtools on a page you cannot edit
|
|
35
|
+
*
|
|
36
|
+
* `dev` and `test` builds emit every level with no opt-in.
|
|
37
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
* Read the host-page opt-in. Never throws — `window.adaSettings` can be a
|
|
40
|
+
* throwing getter and storage access is denied outright in some embed contexts.
|
|
41
|
+
*
|
|
42
|
+
* Deliberately not memoized: a host or support engineer may set the flag after
|
|
43
|
+
* the SDK has already logged something, and a cached `false` would suppress
|
|
44
|
+
* every later diagnostic until reload. Both reads are cheap, and they only run
|
|
45
|
+
* on a gated call that is about to be dropped anyway.
|
|
46
|
+
*/
|
|
47
|
+
export declare function readDebugOptIn(): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Whether a gated level should emit. Takes the mode explicitly so it is
|
|
50
|
+
* testable — `__RUNTIME_MODE__` is a compile-time constant and cannot be
|
|
51
|
+
* stubbed.
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolveEnabled(mode: string, optIn?: () => boolean): boolean;
|
|
54
|
+
export declare const logger: {
|
|
55
|
+
debug: (...args: unknown[]) => void;
|
|
56
|
+
warn: (...args: unknown[]) => void;
|
|
57
|
+
dataLoss: (...args: unknown[]) => void;
|
|
58
|
+
error: (...args: unknown[]) => void;
|
|
59
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { MetaFieldValue } from "./client/client-types.js";
|
|
2
|
+
import type { HostTelemetryContext } from "./host-telemetry.js";
|
|
3
|
+
/** Which web runtime the webview mounts: the Messaging SDK or legacy embed2/Chat. */
|
|
4
|
+
export type AdaWebSdkMode = "messaging" | "legacy";
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for {@link mountAdaWebViewRuntime}, assembled by
|
|
7
|
+
* `webview.html` from its URL query parameters on behalf of the native
|
|
8
|
+
* iOS/Android/React Native wrappers.
|
|
9
|
+
*
|
|
10
|
+
* Sensitive values are never carried here or in query parameters: native
|
|
11
|
+
* hosts inject `identityToken` (and `appUrl`) at
|
|
12
|
+
* document-start as the one-shot `window.__ADA_WEBVIEW_CONFIG__` global,
|
|
13
|
+
* which the runtime reads and deletes during mount — see
|
|
14
|
+
* {@link AdaInjectedWebViewConfig}.
|
|
15
|
+
*/
|
|
16
|
+
export interface AdaWebViewRuntimeConfig {
|
|
17
|
+
/** Bot handle to mount. Required; surrounding whitespace is trimmed and an empty handle rejects the mount. */
|
|
18
|
+
handle: string;
|
|
19
|
+
/** Ada cluster host, e.g. `"ada.support"`, `"ada-dev2.support"`, or `"localhost"`. Invalid values fall back to the production assets. */
|
|
20
|
+
cluster?: string;
|
|
21
|
+
/** ISO language code forwarded to the web SDK. */
|
|
22
|
+
language?: string;
|
|
23
|
+
/** Greeting response ID forwarded to the web SDK. */
|
|
24
|
+
greeting?: string;
|
|
25
|
+
/** Suppress the default launcher/intro/drawer UI so the native host renders its own (Messaging mode). */
|
|
26
|
+
headless?: boolean;
|
|
27
|
+
/** Unlock the transcript-bearing programmatic APIs and gated `ada:message:*` events. */
|
|
28
|
+
enableProgrammaticControl?: boolean;
|
|
29
|
+
/** Initial non-sensitive meta fields for the chatter. */
|
|
30
|
+
metaFields?: Record<string, MetaFieldValue>;
|
|
31
|
+
/** Theme style overrides passed through to the web SDK, which applies its supported theme keys only (currently `tintColor`). */
|
|
32
|
+
styles?: Record<string, string>;
|
|
33
|
+
/** Internal host attribution metadata; defaults derive per web SDK mode with surface `"mobile"`. */
|
|
34
|
+
hostTelemetry?: HostTelemetryContext;
|
|
35
|
+
/** Element the runtime mounts into (`webview.html` supplies `#ada-root`). */
|
|
36
|
+
parentElement: HTMLElement;
|
|
37
|
+
/** Native bridge sink; receives `sdk.ready`, `sdk.event`, `sdk.state.cache`, and `sdk.error` messages. */
|
|
38
|
+
postToNative?: (message: Record<string, unknown>) => void;
|
|
39
|
+
/** Which web runtime to mount: `"messaging"` (default) or `"legacy"`. */
|
|
40
|
+
webSdk?: AdaWebSdkMode;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Shape of the one-shot `window.__ADA_WEBVIEW_CONFIG__` global that native
|
|
44
|
+
* hosts inject at document-start. String values only; unknown keys are
|
|
45
|
+
* ignored. {@link mountAdaWebViewRuntime} reads the global exactly once and
|
|
46
|
+
* deletes it immediately, so the identity token never persists on `window`
|
|
47
|
+
* and never appears in a URL. Applied to the Messaging runtime only — the
|
|
48
|
+
* legacy web SDK has no identity-token or custom-app-URL support.
|
|
49
|
+
*/
|
|
50
|
+
export interface AdaInjectedWebViewConfig {
|
|
51
|
+
/** One-shot Messaging identity token, merged into `adaEmbed.start()` as `identityToken`. */
|
|
52
|
+
identityToken?: string;
|
|
53
|
+
/** Custom app frame URL, merged into `adaEmbed.start()` as `appUrl`. Ada must allowlist the app origin for the handle. */
|
|
54
|
+
appUrl?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* sessionStorage key recording that an injected `identityToken` was consumed
|
|
58
|
+
* by a mount in this webview session. Native document-start scripts re-run on
|
|
59
|
+
* every main-frame document, so they check this marker and withhold the
|
|
60
|
+
* (spent, single-use) token from later documents — per the identity contract,
|
|
61
|
+
* an exchange attempt consumes the token even when it fails downstream, and
|
|
62
|
+
* re-supplying it forces the runtime through the failed-exchange storage
|
|
63
|
+
* wipe. The stored value is the non-sensitive `injectionId` the native host
|
|
64
|
+
* paired with the token (or `"1"` for hosts that sent none), so a NEW token
|
|
65
|
+
* (new id) still gets delivered after an old one was consumed. Never holds
|
|
66
|
+
* token material.
|
|
67
|
+
*/
|
|
68
|
+
export declare const IDENTITY_TOKEN_CONSUMED_STORAGE_KEY = "__ada_identity_token_consumed__";
|
|
69
|
+
type AdaWebViewRuntimeAssetConfig = Pick<AdaWebViewRuntimeConfig, "cluster" | "greeting" | "handle" | "hostTelemetry" | "language" | "metaFields" | "webSdk">;
|
|
70
|
+
export interface ResolvedAdaWebViewRuntimeAssets {
|
|
71
|
+
webSdk: AdaWebSdkMode;
|
|
72
|
+
scriptUrl?: string;
|
|
73
|
+
iframeUrl?: string;
|
|
74
|
+
metadataUrl?: string;
|
|
75
|
+
legacyRuntime?: "embed2" | "chat-iframe";
|
|
76
|
+
}
|
|
77
|
+
interface LegacyAdaEmbed {
|
|
78
|
+
start?: (config: Record<string, unknown>) => unknown;
|
|
79
|
+
reset?: (payload?: unknown) => unknown;
|
|
80
|
+
setLanguage?: (language: string) => unknown;
|
|
81
|
+
sendMessage?: (body: string) => unknown;
|
|
82
|
+
setMetaFields?: (fields: Record<string, unknown>) => unknown;
|
|
83
|
+
setSensitiveMetaFields?: (fields: Record<string, unknown>) => unknown;
|
|
84
|
+
setDeviceToken?: (token: string) => unknown;
|
|
85
|
+
deleteHistory?: () => unknown;
|
|
86
|
+
subscribeAll?: (callback: (key: string, payload: unknown) => void) => (() => void) | undefined;
|
|
87
|
+
subscribeEvent?: (key: string, callback: (payload: unknown) => void) => number | Promise<number>;
|
|
88
|
+
}
|
|
89
|
+
declare global {
|
|
90
|
+
interface Window {
|
|
91
|
+
__ADA_BRIDGE_DISPATCH__?: (jsonCommand: string) => void;
|
|
92
|
+
__ADA_WEBVIEW_CONFIG__?: unknown;
|
|
93
|
+
__ADA_ZD_AUTH_RESOLVER__?: (token: string | null) => void;
|
|
94
|
+
adaEmbed?: LegacyAdaEmbed;
|
|
95
|
+
adaSettings?: Record<string, unknown>;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Resolve which web runtime assets a native wrapper should load for the given
|
|
100
|
+
* webview config: the Messaging SDK bundle URL for the requested cluster, the
|
|
101
|
+
* static embed2 script for non-local legacy, or the local Chat iframe assets
|
|
102
|
+
* for localhost legacy development.
|
|
103
|
+
*/
|
|
104
|
+
export declare function resolveAdaWebViewRuntimeAssets(config: AdaWebViewRuntimeAssetConfig): ResolvedAdaWebViewRuntimeAssets;
|
|
105
|
+
/**
|
|
106
|
+
* Mount the Ada web runtime inside a native mobile webview (iOS, Android,
|
|
107
|
+
* React Native). Loads the Messaging SDK (or the legacy embed2/Chat runtime),
|
|
108
|
+
* starts it with the supplied config, and wires the native bridge:
|
|
109
|
+
* `window.__ADA_BRIDGE_DISPATCH__` for native → SDK commands and
|
|
110
|
+
* `config.postToNative` for SDK → native `sdk.ready`/`sdk.event`/
|
|
111
|
+
* `sdk.state.cache`/`sdk.error` messages.
|
|
112
|
+
*
|
|
113
|
+
* Consumes the one-shot `window.__ADA_WEBVIEW_CONFIG__` global
|
|
114
|
+
* ({@link AdaInjectedWebViewConfig}) exactly once per call — the global is
|
|
115
|
+
* deleted immediately after the read, even when the mount fails. In Messaging
|
|
116
|
+
* mode its `identityToken` and `appUrl` merge into the `adaEmbed.start()`
|
|
117
|
+
* config; the legacy runtime does not support them and injected values are
|
|
118
|
+
* reported to native as ignored. An `identityToken` supplied as a query
|
|
119
|
+
* parameter is never accepted and is reported via `sdk.error`.
|
|
120
|
+
*/
|
|
121
|
+
export declare function mountAdaWebViewRuntime(config: AdaWebViewRuntimeConfig): Promise<void>;
|
|
122
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git commit SHA of the monorepo commit this npm version was published from.
|
|
3
|
+
* The CDN pipeline deploys each main commit's runtime under an immutable
|
|
4
|
+
* SHA root, so this value names the CDN build associated with this npm
|
|
5
|
+
* version. Pass it as the `pinBuildSha` loader option to load exactly that
|
|
6
|
+
* runtime build — not recommended for production (see the README).
|
|
7
|
+
*
|
|
8
|
+
* In the repository, and in any locally built copy, the value is the
|
|
9
|
+
* unstamped 40-zero placeholder ({@link isCdnBuildShaStamped} returns
|
|
10
|
+
* `false`); only published tarballs carry a real SHA.
|
|
11
|
+
*/
|
|
12
|
+
export declare const CDN_BUILD_SHA: string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether `sha` (default {@link CDN_BUILD_SHA}) is a stamped full git commit
|
|
15
|
+
* SHA rather than the unstamped repo placeholder.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isCdnBuildShaStamped(sha?: string): boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git commit SHA of the monorepo commit this npm version was published from.
|
|
3
|
+
* The CDN pipeline deploys each main commit's runtime under an immutable
|
|
4
|
+
* SHA root, so this value names the CDN build associated with this npm
|
|
5
|
+
* version. Pass it as the `pinBuildSha` loader option to load exactly that
|
|
6
|
+
* runtime build — not recommended for production (see the README).
|
|
7
|
+
*
|
|
8
|
+
* In the repository, and in any locally built copy, the value is the
|
|
9
|
+
* unstamped 40-zero placeholder ({@link isCdnBuildShaStamped} returns
|
|
10
|
+
* `false`); only published tarballs carry a real SHA.
|
|
11
|
+
*/
|
|
12
|
+
export declare const CDN_BUILD_SHA: string;
|
|
13
|
+
/**
|
|
14
|
+
* Whether `sha` (default {@link CDN_BUILD_SHA}) is a stamped full git commit
|
|
15
|
+
* SHA rather than the unstamped repo placeholder.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isCdnBuildShaStamped(sha?: string): boolean;
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/npm/build-info.ts
|
|
3
|
+
var GIT_SHA_PATTERN = /^[0-9a-f]{40}$/;
|
|
4
|
+
var UNSTAMPED_SHA_PATTERN = /^0{40}$/;
|
|
5
|
+
/**
|
|
6
|
+
* Git commit SHA of the monorepo commit this npm version was published from.
|
|
7
|
+
* The CDN pipeline deploys each main commit's runtime under an immutable
|
|
8
|
+
* SHA root, so this value names the CDN build associated with this npm
|
|
9
|
+
* version. Pass it as the `pinBuildSha` loader option to load exactly that
|
|
10
|
+
* runtime build — not recommended for production (see the README).
|
|
11
|
+
*
|
|
12
|
+
* In the repository, and in any locally built copy, the value is the
|
|
13
|
+
* unstamped 40-zero placeholder ({@link isCdnBuildShaStamped} returns
|
|
14
|
+
* `false`); only published tarballs carry a real SHA.
|
|
15
|
+
*/
|
|
16
|
+
var CDN_BUILD_SHA = "0000000000000000000000000000000000000000";
|
|
17
|
+
/**
|
|
18
|
+
* Whether `sha` (default {@link CDN_BUILD_SHA}) is a stamped full git commit
|
|
19
|
+
* SHA rather than the unstamped repo placeholder.
|
|
20
|
+
*/
|
|
21
|
+
function isCdnBuildShaStamped(sha = CDN_BUILD_SHA) {
|
|
22
|
+
const normalized = sha.trim().toLowerCase();
|
|
23
|
+
return GIT_SHA_PATTERN.test(normalized) && !UNSTAMPED_SHA_PATTERN.test(normalized);
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/client/embed-lifecycle.ts
|
|
27
|
+
/**
|
|
28
|
+
* Lifecycle channel between `createAdaEmbedInterface` and the npm loader's
|
|
29
|
+
* memo: a non-enumerable getter over closure state, so the loader never
|
|
30
|
+
* mutates the public surface and `Object.freeze` on the facade still works.
|
|
31
|
+
* `Symbol.for` because the loader and the CDN runtime are separate builds;
|
|
32
|
+
* a runtime that predates the getter yields `undefined` — degrade gracefully.
|
|
33
|
+
*/
|
|
34
|
+
var EMBED_LIFECYCLE_STOPPED = Symbol.for("ada-cx/messaging-sdk/embed-stopped");
|
|
35
|
+
/** Read the facade's stopped flag; `undefined` when the runtime predates it. */
|
|
36
|
+
function readEmbedStoppedFlag(ada) {
|
|
37
|
+
const value = ada[EMBED_LIFECYCLE_STOPPED];
|
|
38
|
+
return typeof value === "boolean" ? value : void 0;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region \0@oxc-project+runtime@0.122.0/helpers/typeof.js
|
|
42
|
+
function _typeof(o) {
|
|
43
|
+
"@babel/helpers - typeof";
|
|
44
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
45
|
+
return typeof o;
|
|
46
|
+
} : function(o) {
|
|
47
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
48
|
+
}, _typeof(o);
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region \0@oxc-project+runtime@0.122.0/helpers/toPrimitive.js
|
|
52
|
+
function toPrimitive(t, r) {
|
|
53
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
54
|
+
var e = t[Symbol.toPrimitive];
|
|
55
|
+
if (void 0 !== e) {
|
|
56
|
+
var i = e.call(t, r || "default");
|
|
57
|
+
if ("object" != _typeof(i)) return i;
|
|
58
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
59
|
+
}
|
|
60
|
+
return ("string" === r ? String : Number)(t);
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region \0@oxc-project+runtime@0.122.0/helpers/toPropertyKey.js
|
|
64
|
+
function toPropertyKey(t) {
|
|
65
|
+
var i = toPrimitive(t, "string");
|
|
66
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region \0@oxc-project+runtime@0.122.0/helpers/defineProperty.js
|
|
70
|
+
function _defineProperty(e, r, t) {
|
|
71
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
72
|
+
value: t,
|
|
73
|
+
enumerable: !0,
|
|
74
|
+
configurable: !0,
|
|
75
|
+
writable: !0
|
|
76
|
+
}) : e[r] = t, e;
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/npm/loader.ts
|
|
80
|
+
/**
|
|
81
|
+
* Production CDN root the loader resolves the SDK bootstrap from when no
|
|
82
|
+
* `cdnBase` override is given. The npm package never pins a runtime version;
|
|
83
|
+
* the bootstrap at this root resolves the current rollout at load time.
|
|
84
|
+
*/
|
|
85
|
+
var DEFAULT_MESSAGING_CDN_BASE = "https://messaging-assets.ada.support/";
|
|
86
|
+
var SDK_BOOTSTRAP_FILENAME = "sdk.js";
|
|
87
|
+
var PINNED_SDK_ENTRY_PATH = "sdk/index.js";
|
|
88
|
+
var PINNED_BUILD_SHA_PATTERN = /^[0-9a-f]{40}$/;
|
|
89
|
+
var UNSTAMPED_BUILD_SHA_PATTERN = /^0{40}$/;
|
|
90
|
+
/** Typed failure raised by {@link loadMessagingSdk} and {@link loadAdaMessaging}. */
|
|
91
|
+
var MessagingSdkLoadError = class extends Error {
|
|
92
|
+
constructor(message, code, cause) {
|
|
93
|
+
super(message);
|
|
94
|
+
_defineProperty(this, "code", void 0);
|
|
95
|
+
this.name = "MessagingSdkLoadError";
|
|
96
|
+
this.code = code;
|
|
97
|
+
if (cause !== void 0) this.cause = cause;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
var defaultImportModule = (url) => import(
|
|
101
|
+
/* webpackIgnore: true */
|
|
102
|
+
/* @vite-ignore */
|
|
103
|
+
url
|
|
104
|
+
);
|
|
105
|
+
var inFlightByImporter = /* @__PURE__ */ new WeakMap();
|
|
106
|
+
var LOOPBACK_HOSTS = new Set([
|
|
107
|
+
"localhost",
|
|
108
|
+
"127.0.0.1",
|
|
109
|
+
"[::1]",
|
|
110
|
+
"::1"
|
|
111
|
+
]);
|
|
112
|
+
function isLoopbackHostname(hostname) {
|
|
113
|
+
const normalized = hostname.trim().toLowerCase();
|
|
114
|
+
return LOOPBACK_HOSTS.has(normalized) || normalized.endsWith(".localhost");
|
|
115
|
+
}
|
|
116
|
+
function resolvePinnedBuildSha(pinBuildSha) {
|
|
117
|
+
const sha = pinBuildSha.trim().toLowerCase();
|
|
118
|
+
if (!PINNED_BUILD_SHA_PATTERN.test(sha)) throw new MessagingSdkLoadError(`The pinBuildSha option must be a full 40-character hex git SHA: "${pinBuildSha}".`, "invalid_build_sha");
|
|
119
|
+
if (UNSTAMPED_BUILD_SHA_PATTERN.test(sha)) throw new MessagingSdkLoadError("The pinBuildSha option is the unstamped CDN_BUILD_SHA placeholder. Only the published npm package carries a stamped SHA; a repository or local build cannot pin a CDN build.", "unstamped_build_sha");
|
|
120
|
+
return sha;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* The runtime this URL serves carries the SDK's security logic (endpoint
|
|
124
|
+
* validation, session handling, the origin checks), so a cleartext transport
|
|
125
|
+
* would let an on-path attacker replace it wholesale: `https:` is required,
|
|
126
|
+
* with a loopback-only `http:` exception for local development.
|
|
127
|
+
*/
|
|
128
|
+
function resolveSdkBootstrapUrl(cdnBase, pinBuildSha) {
|
|
129
|
+
const base = (cdnBase ?? "https://messaging-assets.ada.support/").trim();
|
|
130
|
+
const normalizedBase = base.endsWith("/") ? base : `${base}/`;
|
|
131
|
+
const entryPath = pinBuildSha === void 0 ? SDK_BOOTSTRAP_FILENAME : `${resolvePinnedBuildSha(pinBuildSha)}/${PINNED_SDK_ENTRY_PATH}`;
|
|
132
|
+
let url;
|
|
133
|
+
try {
|
|
134
|
+
url = new URL(entryPath, normalizedBase);
|
|
135
|
+
} catch (cause) {
|
|
136
|
+
throw new MessagingSdkLoadError(`The cdnBase option is not a valid URL: "${base}".`, "invalid_cdn_base", cause);
|
|
137
|
+
}
|
|
138
|
+
const isHttps = url.protocol === "https:";
|
|
139
|
+
const isLoopbackHttp = url.protocol === "http:" && isLoopbackHostname(url.hostname);
|
|
140
|
+
if (!isHttps && !isLoopbackHttp) throw new MessagingSdkLoadError(`The cdnBase option must use https (plain http is allowed only for loopback hosts): "${base}".`, "invalid_cdn_base");
|
|
141
|
+
return url.toString();
|
|
142
|
+
}
|
|
143
|
+
function isMessagingSdkModule(value) {
|
|
144
|
+
if (typeof value !== "object" || value === null) return false;
|
|
145
|
+
const candidate = value;
|
|
146
|
+
return typeof candidate.createAdaEmbedInterface === "function" && typeof candidate.AdaMessagingClient === "function";
|
|
147
|
+
}
|
|
148
|
+
async function importSdkModule(url, importModule) {
|
|
149
|
+
let loaded;
|
|
150
|
+
try {
|
|
151
|
+
loaded = await importModule(url);
|
|
152
|
+
} catch (cause) {
|
|
153
|
+
throw new MessagingSdkLoadError(`The Ada Messaging SDK failed to load from ${url}.`, "sdk_import_failed", cause);
|
|
154
|
+
}
|
|
155
|
+
if (!isMessagingSdkModule(loaded)) throw new MessagingSdkLoadError(`The module at ${url} does not expose the Ada Messaging SDK interface.`, "sdk_module_invalid");
|
|
156
|
+
return loaded;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Load the Ada Messaging SDK module from Ada's CDN.
|
|
160
|
+
*
|
|
161
|
+
* The returned promise is memoized per resolved URL: concurrent and repeated
|
|
162
|
+
* calls share one in-flight import. A failed load clears the memo so a later
|
|
163
|
+
* call retries. Rejections are always {@link MessagingSdkLoadError}.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* const { createAdaEmbedInterface } = await loadMessagingSdk();
|
|
167
|
+
*/
|
|
168
|
+
function loadMessagingSdk(options = {}) {
|
|
169
|
+
const importModule = options.importModule ?? defaultImportModule;
|
|
170
|
+
let url;
|
|
171
|
+
try {
|
|
172
|
+
url = resolveSdkBootstrapUrl(options.cdnBase, options.pinBuildSha);
|
|
173
|
+
} catch (error) {
|
|
174
|
+
return Promise.reject(error);
|
|
175
|
+
}
|
|
176
|
+
let inFlight = inFlightByImporter.get(importModule);
|
|
177
|
+
if (!inFlight) {
|
|
178
|
+
inFlight = /* @__PURE__ */ new Map();
|
|
179
|
+
inFlightByImporter.set(importModule, inFlight);
|
|
180
|
+
}
|
|
181
|
+
const existing = inFlight.get(url);
|
|
182
|
+
if (existing) return existing;
|
|
183
|
+
const cache = inFlight;
|
|
184
|
+
const pending = importSdkModule(url, importModule);
|
|
185
|
+
cache.set(url, pending);
|
|
186
|
+
pending.catch(() => {
|
|
187
|
+
if (cache.get(url) === pending) cache.delete(url);
|
|
188
|
+
});
|
|
189
|
+
return pending;
|
|
190
|
+
}
|
|
191
|
+
var startedInterfaceByImporter = /* @__PURE__ */ new WeakMap();
|
|
192
|
+
function warnHost(message) {
|
|
193
|
+
try {
|
|
194
|
+
console.warn(`[Ada] ${message}`);
|
|
195
|
+
} catch {}
|
|
196
|
+
}
|
|
197
|
+
function isPlainObject(value) {
|
|
198
|
+
if (typeof value !== "object" || value === null) return false;
|
|
199
|
+
const prototype = Object.getPrototypeOf(value);
|
|
200
|
+
return prototype === Object.prototype || prototype === null;
|
|
201
|
+
}
|
|
202
|
+
function settingsEqual(a, b) {
|
|
203
|
+
if (Object.is(a, b)) return true;
|
|
204
|
+
if (typeof a === "function" && typeof b === "function") return true;
|
|
205
|
+
if (Array.isArray(a) && Array.isArray(b)) return a.length === b.length && a.every((item, index) => settingsEqual(item, b[index]));
|
|
206
|
+
if (isPlainObject(a) && isPlainObject(b)) {
|
|
207
|
+
const aKeys = Object.keys(a);
|
|
208
|
+
const bKeys = new Set(Object.keys(b));
|
|
209
|
+
return aKeys.length === bKeys.size && aKeys.every((key) => bKeys.has(key) && settingsEqual(a[key], b[key]));
|
|
210
|
+
}
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
function isInterfaceStopped(ada) {
|
|
214
|
+
return readEmbedStoppedFlag(ada) === true;
|
|
215
|
+
}
|
|
216
|
+
async function startAdaMessaging(settings, options) {
|
|
217
|
+
const ada = (await loadMessagingSdk(options)).createAdaEmbedInterface();
|
|
218
|
+
await ada.start(settings);
|
|
219
|
+
return ada;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Load the SDK, create the messaging interface, and start the widget —
|
|
223
|
+
* the npm-first equivalent of the script-tag + `window.adaSettings` setup.
|
|
224
|
+
*
|
|
225
|
+
* One widget per page: the returned promise is memoized, so repeated and
|
|
226
|
+
* concurrent calls resolve to the same started interface and the first
|
|
227
|
+
* call's settings win. A failed load or start clears the memo so a later
|
|
228
|
+
* call retries. Manage the running widget through the returned interface:
|
|
229
|
+
* `stop()` tears it down and a later `start(settings)` on the same interface
|
|
230
|
+
* runs again. Calling {@link loadAdaMessaging} after `stop()` returns the
|
|
231
|
+
* same stopped interface without restarting it. Both memo outcomes log a
|
|
232
|
+
* console warning: ignored differing settings, and a resolved interface
|
|
233
|
+
* whose widget was stopped.
|
|
234
|
+
*
|
|
235
|
+
* Never assigns the interface to `window` or any other global: the returned
|
|
236
|
+
* reference is the only handle, so hold it in module scope. A reference in
|
|
237
|
+
* module scope is reachable only by your own code, never by other scripts on
|
|
238
|
+
* the page.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* // module scope: your code keeps the only reference
|
|
242
|
+
* const ada = await loadAdaMessaging({
|
|
243
|
+
* handle: "my-bot",
|
|
244
|
+
* enableProgrammaticControl: true,
|
|
245
|
+
* });
|
|
246
|
+
* await ada.sendMessage("Hello");
|
|
247
|
+
*/
|
|
248
|
+
function loadAdaMessaging(settings, options = {}) {
|
|
249
|
+
const importModule = options.importModule ?? defaultImportModule;
|
|
250
|
+
const existing = startedInterfaceByImporter.get(importModule);
|
|
251
|
+
if (existing) {
|
|
252
|
+
if (!settingsEqual(settings, existing.settings)) warnHost("loadAdaMessaging() was already called: the new settings are ignored and the existing interface is returned. To apply new settings, call stop() then start(settings) on it.");
|
|
253
|
+
if (existing.ada && isInterfaceStopped(existing.ada)) warnHost("loadAdaMessaging() resolved an interface whose widget was stopped and never restarts it. Call start(settings) on it to run the widget again.");
|
|
254
|
+
return existing.promise;
|
|
255
|
+
}
|
|
256
|
+
const memo = {
|
|
257
|
+
promise: startAdaMessaging(settings, options),
|
|
258
|
+
settings
|
|
259
|
+
};
|
|
260
|
+
startedInterfaceByImporter.set(importModule, memo);
|
|
261
|
+
memo.promise.then((ada) => {
|
|
262
|
+
memo.ada = ada;
|
|
263
|
+
}, () => {
|
|
264
|
+
if (startedInterfaceByImporter.get(importModule) === memo) startedInterfaceByImporter.delete(importModule);
|
|
265
|
+
});
|
|
266
|
+
return memo.promise;
|
|
267
|
+
}
|
|
268
|
+
//#endregion
|
|
269
|
+
exports.CDN_BUILD_SHA = CDN_BUILD_SHA;
|
|
270
|
+
exports.DEFAULT_MESSAGING_CDN_BASE = DEFAULT_MESSAGING_CDN_BASE;
|
|
271
|
+
exports.MessagingSdkLoadError = MessagingSdkLoadError;
|
|
272
|
+
exports.isCdnBuildShaStamped = isCdnBuildShaStamped;
|
|
273
|
+
exports.loadAdaMessaging = loadAdaMessaging;
|
|
274
|
+
exports.loadMessagingSdk = loadMessagingSdk;
|
|
275
|
+
|
|
276
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/npm/build-info.ts","../../src/client/embed-lifecycle.ts","../../src/npm/loader.ts"],"sourcesContent":["// The repo copy carries the 40-zero placeholder; the publish workflow\n// (.github/workflows/messaging-publish-web-packages.yml) stamps the real\n// commit SHA into the built output via scripts/stamp-cdn-build-sha.mjs and\n// verifies the packed tarball before `npm publish`. Keep the placeholder as\n// a single 40-zero string literal: the stamp is a same-length text\n// replacement, so source maps stay valid.\nconst GIT_SHA_PATTERN = /^[0-9a-f]{40}$/;\nconst UNSTAMPED_SHA_PATTERN = /^0{40}$/;\n\n/**\n * Git commit SHA of the monorepo commit this npm version was published from.\n * The CDN pipeline deploys each main commit's runtime under an immutable\n * SHA root, so this value names the CDN build associated with this npm\n * version. Pass it as the `pinBuildSha` loader option to load exactly that\n * runtime build — not recommended for production (see the README).\n *\n * In the repository, and in any locally built copy, the value is the\n * unstamped 40-zero placeholder ({@link isCdnBuildShaStamped} returns\n * `false`); only published tarballs carry a real SHA.\n */\nexport const CDN_BUILD_SHA: string = \"0000000000000000000000000000000000000000\";\n\n/**\n * Whether `sha` (default {@link CDN_BUILD_SHA}) is a stamped full git commit\n * SHA rather than the unstamped repo placeholder.\n */\nexport function isCdnBuildShaStamped(sha: string = CDN_BUILD_SHA): boolean {\n\tconst normalized = sha.trim().toLowerCase();\n\treturn (\n\t\tGIT_SHA_PATTERN.test(normalized) && !UNSTAMPED_SHA_PATTERN.test(normalized)\n\t);\n}\n","/**\n * Lifecycle channel between `createAdaEmbedInterface` and the npm loader's\n * memo: a non-enumerable getter over closure state, so the loader never\n * mutates the public surface and `Object.freeze` on the facade still works.\n * `Symbol.for` because the loader and the CDN runtime are separate builds;\n * a runtime that predates the getter yields `undefined` — degrade gracefully.\n */\nexport const EMBED_LIFECYCLE_STOPPED = Symbol.for(\n\t\"ada-cx/messaging-sdk/embed-stopped\",\n);\n\n/** Read the facade's stopped flag; `undefined` when the runtime predates it. */\nexport function readEmbedStoppedFlag(ada: object): boolean | undefined {\n\tconst value = (ada as Record<symbol, unknown>)[EMBED_LIFECYCLE_STOPPED];\n\treturn typeof value === \"boolean\" ? value : undefined;\n}\n\n/** Define the getter at facade creation time, before any host freeze. */\nexport function defineEmbedStoppedFlag(\n\tada: object,\n\treadStopped: () => boolean,\n): void {\n\tObject.defineProperty(ada, EMBED_LIFECYCLE_STOPPED, {\n\t\tget: readStopped,\n\t\tenumerable: false,\n\t\tconfigurable: false,\n\t});\n}\n","import type { AdaMessagingClient } from \"../client/client\";\nimport type { AdaMessagingStartOptions } from \"../client/client-types\";\nimport type {\n\tAdaEmbedInterface,\n\tcreateAdaEmbedInterface,\n\tdispatchEmbedLoaderInitialActionQueue,\n\tdispatchEmbedLoaderInitialActionQueueForAtomicHandoff,\n} from \"../client/embed-interface\";\nimport { readEmbedStoppedFlag } from \"../client/embed-lifecycle\";\nimport type {\n\tmountAdaWebViewRuntime,\n\tresolveAdaWebViewRuntimeAssets,\n} from \"../mobile-webview-runtime\";\n\n/**\n * Production CDN root the loader resolves the SDK bootstrap from when no\n * `cdnBase` override is given. The npm package never pins a runtime version;\n * the bootstrap at this root resolves the current rollout at load time.\n */\nexport const DEFAULT_MESSAGING_CDN_BASE =\n\t\"https://messaging-assets.ada.support/\";\n\nconst SDK_BOOTSTRAP_FILENAME = \"sdk.js\";\n\n// The CDN pipeline deploys each main commit's runtime as an immutable\n// SHA-rooted entry (`<cdnBase>/<sha>/sdk/index.js`); the mutable `sdk.js`\n// bootstrap resolves the current rollout to one of those roots at load time.\n// A pin bypasses the bootstrap and imports one root directly.\nconst PINNED_SDK_ENTRY_PATH = \"sdk/index.js\";\n\n// Strict on purpose: the pin is interpolated into a CDN path, so only a full\n// lowercase 40-hex git SHA may pass (mirrors scripts/sdk.js's\n// VERSION_OVERRIDE_PATTERN security boundary, minus the short-SHA and pr-N\n// forms — the npm surface pins exactly what CDN_BUILD_SHA carries).\nconst PINNED_BUILD_SHA_PATTERN = /^[0-9a-f]{40}$/;\nconst UNSTAMPED_BUILD_SHA_PATTERN = /^0{40}$/;\n\n/** Why a {@link MessagingSdkLoadError} was raised. */\nexport type MessagingSdkLoadErrorCode =\n\t/**\n\t * The `cdnBase` option is not a valid `https:` URL (plain `http:` is\n\t * allowed only for loopback hosts).\n\t */\n\t| \"invalid_cdn_base\"\n\t/** The `pinBuildSha` option is not a full 40-character hex git SHA. */\n\t| \"invalid_build_sha\"\n\t/**\n\t * The `pinBuildSha` option is the unstamped 40-zero placeholder: this\n\t * copy of the package was built from the repository, not published, so\n\t * its `CDN_BUILD_SHA` names no CDN build.\n\t */\n\t| \"unstamped_build_sha\"\n\t/** The dynamic import of the CDN bootstrap failed (network, CSP, 404). */\n\t| \"sdk_import_failed\"\n\t/** The imported module does not expose the Ada Messaging SDK surface. */\n\t| \"sdk_module_invalid\";\n\n/** Typed failure raised by {@link loadMessagingSdk} and {@link loadAdaMessaging}. */\nexport class MessagingSdkLoadError extends Error {\n\treadonly code: MessagingSdkLoadErrorCode;\n\n\tconstructor(\n\t\tmessage: string,\n\t\tcode: MessagingSdkLoadErrorCode,\n\t\tcause?: unknown,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"MessagingSdkLoadError\";\n\t\tthis.code = code;\n\t\tif (cause !== undefined) {\n\t\t\tthis.cause = cause;\n\t\t}\n\t}\n}\n\n/**\n * The programmatic messaging interface {@link loadAdaMessaging} resolves. An\n * alias of the runtime's `AdaEmbedInterface`, which keeps that name because it\n * is also the legacy `window.adaEmbed` compat facade.\n */\nexport type AdaMessagingInterface = AdaEmbedInterface;\n\n/**\n * The public surface of the CDN-resolved SDK module, as loaded from\n * `<cdnBase>/sdk.js`. Types only — the implementation always comes from the\n * CDN at load time and is never part of this npm package.\n */\nexport interface MessagingSdkModule {\n\tAdaMessagingClient: typeof AdaMessagingClient;\n\tcreateAdaEmbedInterface: typeof createAdaEmbedInterface;\n\tdispatchEmbedLoaderInitialActionQueue: typeof dispatchEmbedLoaderInitialActionQueue;\n\tdispatchEmbedLoaderInitialActionQueueForAtomicHandoff: typeof dispatchEmbedLoaderInitialActionQueueForAtomicHandoff;\n\tmountAdaWebViewRuntime: typeof mountAdaWebViewRuntime;\n\tresolveAdaWebViewRuntimeAssets: typeof resolveAdaWebViewRuntimeAssets;\n}\n\ntype ImportSdkModule = (url: string) => Promise<unknown>;\n\nexport interface LoadMessagingSdkOptions {\n\t/**\n\t * CDN root to resolve `sdk.js` from. Must be an `https:` URL; plain\n\t * `http:` is accepted only for loopback hosts (`localhost`, `127.0.0.1`,\n\t * `[::1]`, `*.localhost`) during local development. Defaults to the\n\t * production root ({@link DEFAULT_MESSAGING_CDN_BASE}). Override it with\n\t * the Ada-provided asset host for a staging validation window only;\n\t * production pages must keep the default.\n\t */\n\tcdnBase?: string;\n\t/**\n\t * Full 40-character git commit SHA of a deployed CDN build. When set, the\n\t * loader skips the rollout bootstrap and imports that build's immutable\n\t * entry (`<cdnBase>/<sha>/sdk/index.js`) directly. Pass the package's\n\t * `CDN_BUILD_SHA` export to pin the build associated with this npm\n\t * version. NOT recommended for production: a pinned runtime misses Ada's\n\t * fixes and rollouts, and may predate server contract changes. Composes\n\t * with `cdnBase` for staged validation.\n\t */\n\tpinBuildSha?: string;\n\t/**\n\t * Import seam for unit tests. Defaults to a native dynamic `import()` of\n\t * the resolved bootstrap URL.\n\t */\n\timportModule?: ImportSdkModule;\n}\n\n// Both annotations are load-bearing: bundlers rewrite bare dynamic imports,\n// and this specifier must reach the browser untouched so the runtime always\n// resolves from Ada's CDN. The npm build for this entry is unminified so the\n// annotations survive into the published output.\nconst defaultImportModule: ImportSdkModule = (url) =>\n\timport(/* webpackIgnore: true */ /* @vite-ignore */ url);\n\n// Keyed by import seam so production memoizes on the module-level default\n// while each injected test seam gets an isolated cache.\nconst inFlightByImporter = new WeakMap<\n\tImportSdkModule,\n\tMap<string, Promise<MessagingSdkModule>>\n>();\n\n// Mirrors the loopback semantics of the shared `isLoopbackHost` /\n// `validateMessagingEndpoint` (shared/utils/src/url.ts) and the bridge\n// loader's copy (packages/bridge/src/loader.ts). Inlined because the\n// published loader must stay dependency-free; keep the host set in sync.\nconst LOOPBACK_HOSTS = new Set([\"localhost\", \"127.0.0.1\", \"[::1]\", \"::1\"]);\n\nfunction isLoopbackHostname(hostname: string): boolean {\n\tconst normalized = hostname.trim().toLowerCase();\n\t// `*.localhost` resolves to the loopback interface and is \"potentially\n\t// trustworthy\" per the Secure Contexts spec; no production host ends in\n\t// `.localhost`.\n\treturn LOOPBACK_HOSTS.has(normalized) || normalized.endsWith(\".localhost\");\n}\n\nfunction resolvePinnedBuildSha(pinBuildSha: string): string {\n\tconst sha = pinBuildSha.trim().toLowerCase();\n\tif (!PINNED_BUILD_SHA_PATTERN.test(sha)) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The pinBuildSha option must be a full 40-character hex git SHA: \"${pinBuildSha}\".`,\n\t\t\t\"invalid_build_sha\",\n\t\t);\n\t}\n\tif (UNSTAMPED_BUILD_SHA_PATTERN.test(sha)) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t\"The pinBuildSha option is the unstamped CDN_BUILD_SHA placeholder. Only the published npm package carries a stamped SHA; a repository or local build cannot pin a CDN build.\",\n\t\t\t\"unstamped_build_sha\",\n\t\t);\n\t}\n\treturn sha;\n}\n\n/**\n * The runtime this URL serves carries the SDK's security logic (endpoint\n * validation, session handling, the origin checks), so a cleartext transport\n * would let an on-path attacker replace it wholesale: `https:` is required,\n * with a loopback-only `http:` exception for local development.\n */\nfunction resolveSdkBootstrapUrl(\n\tcdnBase: string | undefined,\n\tpinBuildSha: string | undefined,\n): string {\n\tconst base = (cdnBase ?? DEFAULT_MESSAGING_CDN_BASE).trim();\n\t// Resolving against a base without a trailing slash would drop its last\n\t// path segment, so normalize before building the bootstrap URL.\n\tconst normalizedBase = base.endsWith(\"/\") ? base : `${base}/`;\n\tconst entryPath =\n\t\tpinBuildSha === undefined\n\t\t\t? SDK_BOOTSTRAP_FILENAME\n\t\t\t: `${resolvePinnedBuildSha(pinBuildSha)}/${PINNED_SDK_ENTRY_PATH}`;\n\tlet url: URL;\n\ttry {\n\t\turl = new URL(entryPath, normalizedBase);\n\t} catch (cause) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The cdnBase option is not a valid URL: \"${base}\".`,\n\t\t\t\"invalid_cdn_base\",\n\t\t\tcause,\n\t\t);\n\t}\n\tconst isHttps = url.protocol === \"https:\";\n\tconst isLoopbackHttp =\n\t\turl.protocol === \"http:\" && isLoopbackHostname(url.hostname);\n\tif (!isHttps && !isLoopbackHttp) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The cdnBase option must use https (plain http is allowed only for loopback hosts): \"${base}\".`,\n\t\t\t\"invalid_cdn_base\",\n\t\t);\n\t}\n\treturn url.toString();\n}\n\nfunction isMessagingSdkModule(value: unknown): value is MessagingSdkModule {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn false;\n\t}\n\tconst candidate = value as Record<string, unknown>;\n\treturn (\n\t\ttypeof candidate.createAdaEmbedInterface === \"function\" &&\n\t\ttypeof candidate.AdaMessagingClient === \"function\"\n\t);\n}\n\nasync function importSdkModule(\n\turl: string,\n\timportModule: ImportSdkModule,\n): Promise<MessagingSdkModule> {\n\tlet loaded: unknown;\n\ttry {\n\t\tloaded = await importModule(url);\n\t} catch (cause) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The Ada Messaging SDK failed to load from ${url}.`,\n\t\t\t\"sdk_import_failed\",\n\t\t\tcause,\n\t\t);\n\t}\n\tif (!isMessagingSdkModule(loaded)) {\n\t\tthrow new MessagingSdkLoadError(\n\t\t\t`The module at ${url} does not expose the Ada Messaging SDK interface.`,\n\t\t\t\"sdk_module_invalid\",\n\t\t);\n\t}\n\treturn loaded;\n}\n\n/**\n * Load the Ada Messaging SDK module from Ada's CDN.\n *\n * The returned promise is memoized per resolved URL: concurrent and repeated\n * calls share one in-flight import. A failed load clears the memo so a later\n * call retries. Rejections are always {@link MessagingSdkLoadError}.\n *\n * @example\n * const { createAdaEmbedInterface } = await loadMessagingSdk();\n */\nexport function loadMessagingSdk(\n\toptions: LoadMessagingSdkOptions = {},\n): Promise<MessagingSdkModule> {\n\tconst importModule = options.importModule ?? defaultImportModule;\n\tlet url: string;\n\ttry {\n\t\turl = resolveSdkBootstrapUrl(options.cdnBase, options.pinBuildSha);\n\t} catch (error) {\n\t\treturn Promise.reject(error);\n\t}\n\n\tlet inFlight = inFlightByImporter.get(importModule);\n\tif (!inFlight) {\n\t\tinFlight = new Map();\n\t\tinFlightByImporter.set(importModule, inFlight);\n\t}\n\tconst existing = inFlight.get(url);\n\tif (existing) {\n\t\treturn existing;\n\t}\n\n\tconst cache = inFlight;\n\tconst pending = importSdkModule(url, importModule);\n\tcache.set(url, pending);\n\tpending.catch(() => {\n\t\tif (cache.get(url) === pending) {\n\t\t\tcache.delete(url);\n\t\t}\n\t});\n\treturn pending;\n}\n\n// Keyed by import seam like the module memo above: production memoizes on\n// the module-level default while each injected test seam gets an isolated\n// cache. `ada` is set when the promise resolves, so the stopped-interface\n// diagnostic can consult the resolved facade without wrapping it.\ninterface StartedInterfaceMemo {\n\tpromise: Promise<AdaMessagingInterface>;\n\tsettings: AdaMessagingStartOptions;\n\tada?: AdaMessagingInterface;\n}\n\nconst startedInterfaceByImporter = new WeakMap<\n\tImportSdkModule,\n\tStartedInterfaceMemo\n>();\n\n// Ungated like the runtime logger's dropped-host-value channel: both call\n// sites fire only on host misuse, never on an ordinary page load.\nfunction warnHost(message: string): void {\n\ttry {\n\t\t// biome-ignore lint/suspicious/noConsole: the loader's sanctioned host-page diagnostic sink\n\t\tconsole.warn(`[Ada] ${message}`);\n\t} catch {\n\t\t// A host may replace console methods; diagnostics must not throw.\n\t}\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn false;\n\t}\n\tconst prototype = Object.getPrototypeOf(value);\n\treturn prototype === Object.prototype || prototype === null;\n}\n\n// Structural equality over the settings surface. Two functions compare equal:\n// fresh inline callbacks on a re-run (React Strict Mode effects) are not a\n// settings change worth a warning. Exotic objects compare by reference.\nfunction settingsEqual(a: unknown, b: unknown): boolean {\n\tif (Object.is(a, b)) {\n\t\treturn true;\n\t}\n\tif (typeof a === \"function\" && typeof b === \"function\") {\n\t\treturn true;\n\t}\n\tif (Array.isArray(a) && Array.isArray(b)) {\n\t\treturn (\n\t\t\ta.length === b.length &&\n\t\t\ta.every((item, index) => settingsEqual(item, b[index]))\n\t\t);\n\t}\n\tif (isPlainObject(a) && isPlainObject(b)) {\n\t\tconst aKeys = Object.keys(a);\n\t\tconst bKeys = new Set(Object.keys(b));\n\t\treturn (\n\t\t\taKeys.length === bKeys.size &&\n\t\t\taKeys.every((key) => bKeys.has(key) && settingsEqual(a[key], b[key]))\n\t\t);\n\t}\n\treturn false;\n}\n\n// Observes the facade's symbol-keyed lifecycle getter (embed-lifecycle.ts)\n// instead of wrapping stop/start, so the customer's interface is never\n// mutated; a pinned runtime that predates the getter yields no flag and the\n// stopped-interface diagnostic is skipped rather than guessed.\nfunction isInterfaceStopped(ada: AdaMessagingInterface): boolean {\n\treturn readEmbedStoppedFlag(ada) === true;\n}\n\nasync function startAdaMessaging(\n\tsettings: AdaMessagingStartOptions,\n\toptions: LoadMessagingSdkOptions,\n): Promise<AdaMessagingInterface> {\n\tconst sdkModule = await loadMessagingSdk(options);\n\tconst ada = sdkModule.createAdaEmbedInterface();\n\tawait ada.start(settings);\n\treturn ada;\n}\n\n/**\n * Load the SDK, create the messaging interface, and start the widget —\n * the npm-first equivalent of the script-tag + `window.adaSettings` setup.\n *\n * One widget per page: the returned promise is memoized, so repeated and\n * concurrent calls resolve to the same started interface and the first\n * call's settings win. A failed load or start clears the memo so a later\n * call retries. Manage the running widget through the returned interface:\n * `stop()` tears it down and a later `start(settings)` on the same interface\n * runs again. Calling {@link loadAdaMessaging} after `stop()` returns the\n * same stopped interface without restarting it. Both memo outcomes log a\n * console warning: ignored differing settings, and a resolved interface\n * whose widget was stopped.\n *\n * Never assigns the interface to `window` or any other global: the returned\n * reference is the only handle, so hold it in module scope. A reference in\n * module scope is reachable only by your own code, never by other scripts on\n * the page.\n *\n * @example\n * // module scope: your code keeps the only reference\n * const ada = await loadAdaMessaging({\n * handle: \"my-bot\",\n * enableProgrammaticControl: true,\n * });\n * await ada.sendMessage(\"Hello\");\n */\nexport function loadAdaMessaging(\n\tsettings: AdaMessagingStartOptions,\n\toptions: LoadMessagingSdkOptions = {},\n): Promise<AdaMessagingInterface> {\n\tconst importModule = options.importModule ?? defaultImportModule;\n\tconst existing = startedInterfaceByImporter.get(importModule);\n\tif (existing) {\n\t\tif (!settingsEqual(settings, existing.settings)) {\n\t\t\twarnHost(\n\t\t\t\t\"loadAdaMessaging() was already called: the new settings are ignored and the existing interface is returned. To apply new settings, call stop() then start(settings) on it.\",\n\t\t\t);\n\t\t}\n\t\tif (existing.ada && isInterfaceStopped(existing.ada)) {\n\t\t\twarnHost(\n\t\t\t\t\"loadAdaMessaging() resolved an interface whose widget was stopped and never restarts it. Call start(settings) on it to run the widget again.\",\n\t\t\t);\n\t\t}\n\t\treturn existing.promise;\n\t}\n\tconst memo: StartedInterfaceMemo = {\n\t\tpromise: startAdaMessaging(settings, options),\n\t\tsettings,\n\t};\n\tstartedInterfaceByImporter.set(importModule, memo);\n\tmemo.promise.then(\n\t\t(ada) => {\n\t\t\tmemo.ada = ada;\n\t\t},\n\t\t() => {\n\t\t\tif (startedInterfaceByImporter.get(importModule) === memo) {\n\t\t\t\tstartedInterfaceByImporter.delete(importModule);\n\t\t\t}\n\t\t},\n\t);\n\treturn memo.promise;\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AdaMessagingClient } from "../client/client.js" with { "resolution-mode": "import" };
|
|
2
|
+
export type { AdaMessagingClient };
|
|
3
|
+
import type { AdaMessagingClientConfig, AdaMessagingSettings, AdaMessagingStartOptions, AdaReadyCallbackParams, AdaSdkEventCallback, AdaSdkEventContext, AdaSdkEventKey, BeforeSend, ConversationInfo, Delegate, MetaFieldValue, PublicAgentInfo, PublicMessage, ResetParams, SendMessageResult, WindowInfo, } from "../client/client-types.js" with { "resolution-mode": "import" };
|
|
4
|
+
export type { AdaMessagingClientConfig, AdaMessagingSettings, AdaMessagingStartOptions, AdaReadyCallbackParams, AdaSdkEventCallback, AdaSdkEventContext, AdaSdkEventKey, BeforeSend, ConversationInfo, Delegate, MetaFieldValue, PublicAgentInfo, PublicMessage, ResetParams, SendMessageResult, WindowInfo };
|
|
5
|
+
import type { ChatHtmlConfig, resolveChatHtmlConfig, } from "../client/config-helpers.js" with { "resolution-mode": "import" };
|
|
6
|
+
export type { ChatHtmlConfig, resolveChatHtmlConfig };
|
|
7
|
+
import type { AdaEmbedInterface, createAdaEmbedInterface, dispatchEmbedLoaderInitialActionQueue, dispatchEmbedLoaderInitialActionQueueForAtomicHandoff, LoaderQueueAction, LoaderQueueActionOutcome, LoaderQueueActionOutcomeHandler, } from "../client/embed-interface.js" with { "resolution-mode": "import" };
|
|
8
|
+
export type { AdaEmbedInterface, createAdaEmbedInterface, dispatchEmbedLoaderInitialActionQueue, dispatchEmbedLoaderInitialActionQueueForAtomicHandoff, LoaderQueueAction, LoaderQueueActionOutcome, LoaderQueueActionOutcomeHandler };
|
|
9
|
+
import type { FrameChannel, FrameChild, FrameMessage, FrameName, FrameToSdkEvents, SdkToFrameEvents, } from "../frame-channel/index.js" with { "resolution-mode": "import" };
|
|
10
|
+
export type { FrameChannel, FrameChild, FrameMessage, FrameName, FrameToSdkEvents, SdkToFrameEvents };
|
|
11
|
+
import type { mountAdaWebViewRuntime, resolveAdaWebViewRuntimeAssets, } from "../mobile-webview-runtime.js" with { "resolution-mode": "import" };
|
|
12
|
+
export type { mountAdaWebViewRuntime, resolveAdaWebViewRuntimeAssets };
|
|
13
|
+
export { CDN_BUILD_SHA, isCdnBuildShaStamped } from "./build-info.cjs";
|
|
14
|
+
export type { AdaMessagingInterface, LoadMessagingSdkOptions, MessagingSdkLoadErrorCode, MessagingSdkModule, } from "./loader.cjs";
|
|
15
|
+
export { DEFAULT_MESSAGING_CDN_BASE, loadAdaMessaging, loadMessagingSdk, MessagingSdkLoadError, } from "./loader.cjs";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { AdaMessagingClient } from "../client/client.js";
|
|
2
|
+
export type { AdaMessagingClientConfig, AdaMessagingSettings, AdaMessagingStartOptions, AdaReadyCallbackParams, AdaSdkEventCallback, AdaSdkEventContext, AdaSdkEventKey, BeforeSend, ConversationInfo, Delegate, MetaFieldValue, PublicAgentInfo, PublicMessage, ResetParams, SendMessageResult, WindowInfo, } from "../client/client-types.js";
|
|
3
|
+
export type { ChatHtmlConfig, resolveChatHtmlConfig, } from "../client/config-helpers.js";
|
|
4
|
+
export type { AdaEmbedInterface, createAdaEmbedInterface, dispatchEmbedLoaderInitialActionQueue, dispatchEmbedLoaderInitialActionQueueForAtomicHandoff, LoaderQueueAction, LoaderQueueActionOutcome, LoaderQueueActionOutcomeHandler, } from "../client/embed-interface.js";
|
|
5
|
+
export type { FrameChannel, FrameChild, FrameMessage, FrameName, FrameToSdkEvents, SdkToFrameEvents, } from "../frame-channel/index.js";
|
|
6
|
+
export type { mountAdaWebViewRuntime, resolveAdaWebViewRuntimeAssets, } from "../mobile-webview-runtime.js";
|
|
7
|
+
export { CDN_BUILD_SHA, isCdnBuildShaStamped } from "./build-info.js";
|
|
8
|
+
export type { AdaMessagingInterface, LoadMessagingSdkOptions, MessagingSdkLoadErrorCode, MessagingSdkModule, } from "./loader.js";
|
|
9
|
+
export { DEFAULT_MESSAGING_CDN_BASE, loadAdaMessaging, loadMessagingSdk, MessagingSdkLoadError, } from "./loader.js";
|