@accurix/centrinfo-widget 1.0.1 → 1.1.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 CHANGED
@@ -17,7 +17,7 @@ Zero-JS, via `data-*` on the script:
17
17
 
18
18
  ```html
19
19
  <script
20
- src="https://cdn.accurix.com/centrinfo/js/sdk-centrinfo-widget-v1.0.0/centrinfo-widget.js"
20
+ src="https://cdn.accurixtech.com/centrinfo/js/sdk-centrinfo-widget-v1.0.0/centrinfo-widget.js"
21
21
  data-token="pub_8f3k…"
22
22
  defer
23
23
  ></script>
@@ -27,7 +27,7 @@ Or call `init` yourself:
27
27
 
28
28
  ```html
29
29
  <script
30
- src="https://cdn.accurix.com/centrinfo/js/sdk-centrinfo-widget-v1.0.0/centrinfo-widget.js"
30
+ src="https://cdn.accurixtech.com/centrinfo/js/sdk-centrinfo-widget-v1.0.0/centrinfo-widget.js"
31
31
  defer
32
32
  ></script>
33
33
  <script>
@@ -53,8 +53,11 @@ const widget = init({ token: 'pub_8f3k…' });
53
53
  | ------------------------------------------------------------- | ----------------------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------- |
54
54
  | `token` **(required)** | string | — | The org's `pub_*` token. It _is_ the org identity. |
55
55
  | `analyticsContextToken` | string | — | Server-signed governed analytics context. It must expire within 15 minutes and be scoped to this public widget token. |
56
+ | `identityToken` | string | — | Short-lived customer identity JWT. Authenticated history is scoped to its verified external user ID. |
57
+ | `getIdentityToken` | function | — | Returns a fresh customer identity JWT before authenticated requests. Prefer this for expiring tokens. |
56
58
  | `apiBaseUrl` | string | prod API | Override for staging / self-host. |
57
59
  | `accentColor` | string | brand green | Any CSS color — drives the launcher, header, user bubbles & send button (a darker shade for the gradient is derived automatically). |
60
+ | `themeTokens` | object | — | Enterprise theme tokens for chat surfaces: accent, background, surface, text, muted text, border, shadow, radius, and font family. |
58
61
  | `launcherIcon` | string | chat glyph | Image URL (e.g. the org's logo) shown in the launcher bubble. |
59
62
  | `theme` | `'light' \| 'dark' \| 'auto'` | `'auto'` | `auto` follows the host's `prefers-color-scheme`; `light`/`dark` force it. |
60
63
  | `openByDefault` | boolean | `false` | Open the panel on load. |
@@ -63,11 +66,58 @@ const widget = init({ token: 'pub_8f3k…' });
63
66
  | `configRefreshSeconds` | number | `30` | While the panel is open, refresh token branding/actions from `bootstrap`; set `0` to disable. |
64
67
  | `onOpen` / `onClose` / `onMessage` / `onAction` / `onHandoff` | function | — | Event hooks. |
65
68
 
69
+ ```ts
70
+ init({
71
+ token: 'pub_8f3k...',
72
+ themeTokens: {
73
+ accent: '#176b45',
74
+ accentStrong: '#0f5134',
75
+ background: '#f8fafc',
76
+ surface: '#ffffff',
77
+ surfaceMuted: '#f1f5f9',
78
+ text: '#0f172a',
79
+ mutedText: '#64748b',
80
+ border: '#cbd5e1',
81
+ radius: '10px',
82
+ fontFamily: 'Inter, system-ui, sans-serif',
83
+ },
84
+ });
85
+ ```
86
+
66
87
  Persona (agent name/avatar/greeting), the voice toggle, and which lead-gen
67
88
  actions appear all come from the token via `GET /public-chat/bootstrap` — not
68
89
  from the snippet. Open widgets refresh that bootstrap data every 30 seconds, so
69
90
  saved dashboard settings reach visitors without a page reload.
70
91
 
92
+ ## Authenticated history
93
+
94
+ For a logged-in customer, mint a short-lived identity token on the host
95
+ backend and supply `getIdentityToken`. Keep the signing private key on the
96
+ server, and use a stable external user ID for that customer.
97
+
98
+ ```ts
99
+ const widget = init({
100
+ token: 'pub_8f3k...',
101
+ getIdentityToken: async () => {
102
+ const response = await fetch('/api/centrinfo/token', {
103
+ credentials: 'include',
104
+ });
105
+ if (!response.ok) throw new Error('Sign in is required.');
106
+ return response.json();
107
+ },
108
+ });
109
+ ```
110
+
111
+ Authenticated conversations are restored from Centrinfo's backend in a new
112
+ browser or device after the identity token is verified. Anonymous history is
113
+ stored only according to the widget's `persistence` option and cannot be
114
+ loaded through authenticated history.
115
+
116
+ Call `widget.shutdown()` on host-app logout when the page may be shared. It
117
+ removes the local transcript and resets the mounted widget to an anonymous
118
+ session. Retained server history is not deleted and returns only when the same
119
+ verified customer signs in again.
120
+
71
121
  When business data chat is enabled for a widget token, responses follow a
72
122
  visitor-safe presentation contract:
73
123
 
@@ -156,7 +206,7 @@ Remove `?demo` to test the real public-chat API and the organization’s publish
156
206
  Canonical v1 CDN URL:
157
207
 
158
208
  ```text
159
- https://cdn.accurix.com/centrinfo/js/sdk-centrinfo-widget-v1.0.0/centrinfo-widget.js
209
+ https://cdn.accurixtech.com/centrinfo/js/sdk-centrinfo-widget-v1.0.0/centrinfo-widget.js
160
210
  ```
161
211
 
162
212
  ## Status