@developer.notchatbot/webchat 1.5.2 → 1.5.3
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/dist/utils/self-init.d.ts +40 -0
- package/dist/webchat-bundle.min.js +1409 -1359
- package/dist/webchat-bundle.min.umd.cjs +22 -22
- package/package.json +54 -53
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-initialization from the bundle's own <script> URL.
|
|
3
|
+
*
|
|
4
|
+
* Used by the Tiendanube 1-click install (Scripts API): Tiendanube injects
|
|
5
|
+
* <script src="https://unpkg.com/...bundle.min.umd.cjs?apiKey=<uid>&s=<base64url>">
|
|
6
|
+
* and the bundle configures itself from those params — zero requests to the
|
|
7
|
+
* NotChatbot backend on page view. The `s` payload is built SERVER-SIDE when
|
|
8
|
+
* the script is (re)associated to the store, so this module only decodes it;
|
|
9
|
+
* it never derives styles on its own.
|
|
10
|
+
*
|
|
11
|
+
* ⚠️ CRITICAL BACKWARD COMPATIBILITY ⚠️
|
|
12
|
+
* Every existing GTM/manual customer loads this same bundle from @latest
|
|
13
|
+
* WITHOUT query params. For any src without `apiKey` this module MUST return
|
|
14
|
+
* null and MUST NOT throw — the bundle then behaves exactly as before
|
|
15
|
+
* (waiting for a manual WebChat.initialize). Keep every code path here
|
|
16
|
+
* defensive: a broken payload degrades to apiKey-only defaults, never to an
|
|
17
|
+
* error that could interfere with the bundle load.
|
|
18
|
+
*/
|
|
19
|
+
/** Versioned payload carried in the `s` query param (base64url of its JSON). */
|
|
20
|
+
export interface StylesParamV1 {
|
|
21
|
+
v: 1;
|
|
22
|
+
/** Fully-resolved WebChatConfig (minus apiKey), built server-side. */
|
|
23
|
+
c: Record<string, unknown>;
|
|
24
|
+
/** CSS for window.injectWebChatCSS (button resize), or null. */
|
|
25
|
+
css: string | null;
|
|
26
|
+
}
|
|
27
|
+
export interface SelfInitPayload {
|
|
28
|
+
apiKey: string;
|
|
29
|
+
/** Resolved config from `s`, or null to initialize with defaults. */
|
|
30
|
+
config: Record<string, unknown> | null;
|
|
31
|
+
injectCss: string | null;
|
|
32
|
+
}
|
|
33
|
+
/** Encodes a styles payload to base64url. Exported for tests and tooling; production encoding lives server-side. */
|
|
34
|
+
export declare function encodeStylesParam(payload: StylesParamV1 | Record<string, unknown>): string;
|
|
35
|
+
/**
|
|
36
|
+
* Parses the bundle's own script src. Returns null unless the URL carries an
|
|
37
|
+
* `apiKey` query param (the self-init opt-in marker). A present-but-broken
|
|
38
|
+
* `s` param degrades to apiKey-only (default appearance) instead of failing.
|
|
39
|
+
*/
|
|
40
|
+
export declare function parseSelfInitFromSrc(src: string): SelfInitPayload | null;
|