@moveo-ai/web-client 0.127.0-true.55 → 0.127.0-true.57

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
@@ -178,7 +178,7 @@ Initializes the chat widget.
178
178
  | `integrationId` | `string` | Yes | Your Moveo.ai integration ID |
179
179
  | `host` | `string` | No | Regional channels host, when it differs from the default |
180
180
  | `element` | `HTMLElement \| string` | No | Embed target, required for the `embed` widget position |
181
- | `identityToken` | `string` | No | Signed token that verifies the user's identity on the session |
181
+ | `identityToken` | `string \| () => string \| Promise<string>` | No | Signed token that verifies the user's identity on the session. See [Identity token](#identity-token) |
182
182
  | `voiceIntegrationId` | `string` | No | Deprecated and ignored: the call uses the desk voice pairing |
183
183
  | `variant` | `'default' \| 'nbg' \| 'alpha' \| 'fiserv'` | No | Visual variant |
184
184
 
@@ -368,6 +368,37 @@ MoveoAI.init({
368
368
  });
369
369
  ```
370
370
 
371
+ ### Identity token
372
+
373
+ An identity token is a JWT that your server signs to tell Moveo who the visitor is. Pass a function, not a fixed string, so the widget always gets the page's current token:
374
+
375
+ ```javascript
376
+ MoveoAI.init({
377
+ integrationId: 'YOUR_INTEGRATION_ID',
378
+ identityToken: async () => {
379
+ const response = await fetch('/api/moveo-token', {
380
+ credentials: 'include',
381
+ });
382
+ if (response.status === 401) {
383
+ return ''; // The visitor is logged out.
384
+ }
385
+ if (!response.ok) {
386
+ throw new Error(`Token endpoint: ${response.status}`);
387
+ }
388
+ const { token } = await response.json();
389
+ return token;
390
+ },
391
+ }).then((instance) => {
392
+ console.log('Moveo widget ready', instance);
393
+ });
394
+ ```
395
+
396
+ The function stays on your page. The widget calls it before each session create and each reconnect, and keeps no token between calls. So a short-lived token works for a long conversation, and a logout or an account switch takes effect at the next reconnect, also on a single-page app that does not reload.
397
+
398
+ - Return `''` when the visitor is logged out. If the integration requires an identity token, channels then refuses the reconnect, and the visitor starts a new conversation.
399
+ - Mint a new token on each call. Channels refuses a token without `exp`, or with an `exp` more than 24 hours ahead.
400
+ - If the function throws, returns no string, or takes more than 10 seconds, the widget calls it again after 1 second and after 2 more seconds. If every call fails, the widget continues without a token.
401
+
371
402
  ### Teaser
372
403
 
373
404
  The teaser is the invitation shown beside the closed launcher. `variant` picks
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * @moveo-ai/web-client v0.127.0-true.55
3
+ * @moveo-ai/web-client v0.127.0-true.57
4
4
  * Copyright (c) Moveo.ai (TM)
5
5
  *
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * @moveo-ai/web-client v0.127.0-true.55
3
+ * @moveo-ai/web-client v0.127.0-true.57
4
4
  * Copyright (c) Moveo.ai (TM)
5
5
  *
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * @moveo-ai/web-client v0.127.0-true.55
3
+ * @moveo-ai/web-client v0.127.0-true.57
4
4
  * Copyright (c) Moveo.ai (TM)
5
5
  *
6
6
  */