@microsoft/omnichannel-chat-widget 1.8.4-main.4f09da2 → 1.8.4-main.5d1fc98
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 +12 -3
- package/lib/cjs/common/Constants.js +2 -0
- package/lib/cjs/common/facades/FacadeChatSDK.js +235 -9
- package/lib/cjs/common/telemetry/TelemetryConstants.js +13 -0
- package/lib/cjs/common/utils/xssUtils.js +23 -51
- package/lib/cjs/common/utils.js +1 -1
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +9 -1
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +23 -6
- package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +1 -0
- package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +9 -0
- package/lib/cjs/components/livechatwidget/common/authHelper.js +44 -4
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +3 -2
- package/lib/cjs/components/livechatwidget/common/endChat.js +2 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +31 -14
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +108 -2
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +0 -1
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +40 -22
- package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +117 -16
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +2 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +13 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +160 -167
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +25 -8
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +8 -3
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +6 -1
- package/lib/cjs/contexts/createReducer.js +15 -0
- package/lib/cjs/controller/componentController.js +13 -1
- package/lib/cjs/plugins/newMessageEventHandler.js +20 -3
- package/lib/esm/common/Constants.js +2 -0
- package/lib/esm/common/facades/FacadeChatSDK.js +236 -10
- package/lib/esm/common/telemetry/TelemetryConstants.js +13 -0
- package/lib/esm/common/utils/xssUtils.js +23 -51
- package/lib/esm/common/utils.js +1 -1
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +9 -1
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +23 -6
- package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +1 -0
- package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +9 -0
- package/lib/esm/components/livechatwidget/common/authHelper.js +44 -4
- package/lib/esm/components/livechatwidget/common/createAdapter.js +3 -2
- package/lib/esm/components/livechatwidget/common/endChat.js +2 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +31 -14
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +108 -2
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -2
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +40 -22
- package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +117 -16
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +2 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +13 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +160 -171
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +22 -6
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +8 -3
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +6 -1
- package/lib/esm/contexts/createReducer.js +15 -0
- package/lib/esm/controller/componentController.js +13 -1
- package/lib/esm/plugins/newMessageEventHandler.js +20 -3
- package/lib/types/common/Constants.d.ts +2 -0
- package/lib/types/common/facades/FacadeChatSDK.d.ts +29 -0
- package/lib/types/common/facades/types/IFacadeChatSDKInput.d.ts +3 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +13 -2
- package/lib/types/common/utils/xssUtils.d.ts +5 -21
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/authHelper.d.ts +9 -2
- package/lib/types/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotAuthConfig.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +14 -38
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.d.ts +3 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/package.json +14 -5
package/README.md
CHANGED
|
@@ -177,7 +177,7 @@ Header's and Footer's child components consist of three parts:
|
|
|
177
177
|
1. "middleGroup" - adding child components in the middle of the Header/Footer
|
|
178
178
|
1. "rightGroup" - adding child components at the right of the Header/Footer
|
|
179
179
|
|
|
180
|
-
By default Header has the header icon and title on the left and minimize and close buttons on the right, and Footer has Download Transcript and Email Transcript buttons on the left and audio notification button on the right. These components can be overriden with [ComponentOverrides](#
|
|
180
|
+
By default Header has the header icon and title on the left and minimize and close buttons on the right, and Footer has Download Transcript and Email Transcript buttons on the left and audio notification button on the right. These components can be overriden with [ComponentOverrides](#componentoverrides). In addition, other custom child components can be added to both Header and Footer by creating custom react nodes and adding them to attributes "leftGroup", "middleGroup" or "rightGroup" of "controlProps".
|
|
181
181
|
|
|
182
182
|
```js
|
|
183
183
|
const buttonStyleProps: IButtonStyles = {
|
|
@@ -224,8 +224,10 @@ const customizedFooterProp: IFooterProps = {
|
|
|
224
224
|
> :pushpin: Note that [WebChat hooks](https://github.com/microsoft/BotFramework-WebChat/blob/main/docs/HOOKS.md) can also be used in any custom components.
|
|
225
225
|
|
|
226
226
|
#### Bidirectional Custom Events
|
|
227
|
+
|
|
227
228
|
- Sending events from a hosting web page to bots/agents
|
|
228
|
-
|
|
229
|
+
- Register a function to post event
|
|
230
|
+
|
|
229
231
|
```js
|
|
230
232
|
//define sendCustomEvent function
|
|
231
233
|
const sendCustomEvent = (payload) => {
|
|
@@ -253,7 +255,9 @@ const customizedFooterProp: IFooterProps = {
|
|
|
253
255
|
}
|
|
254
256
|
})
|
|
255
257
|
```
|
|
256
|
-
|
|
258
|
+
|
|
259
|
+
- Receiving events from bots/agents
|
|
260
|
+
|
|
257
261
|
```js
|
|
258
262
|
//define setOnCustomEvent function
|
|
259
263
|
const setOnCustomEvent = (callback) => {
|
|
@@ -269,8 +273,10 @@ const customizedFooterProp: IFooterProps = {
|
|
|
269
273
|
```
|
|
270
274
|
|
|
271
275
|
#### Trigger initiateEndChat event
|
|
276
|
+
|
|
272
277
|
Customer can trigger the initiateEndChat event via BroadcastService to end a chat session.
|
|
273
278
|
When needed, the payload below could be triggered:
|
|
279
|
+
|
|
274
280
|
```js
|
|
275
281
|
const endChatEvent = {
|
|
276
282
|
eventName: "InitiateEndChat",
|
|
@@ -283,18 +289,21 @@ BroadcastService.postMessage(endChatEvent);
|
|
|
283
289
|
|
|
284
290
|
The payload of the event is optional, only needed when force closing of a persistent chat session is not required.
|
|
285
291
|
When chat widget receives the event without any payload, it will:
|
|
292
|
+
|
|
286
293
|
1. set the widget to closed state, the widget panel will be minimized. Post chat survey will not be displayed.
|
|
287
294
|
2. trigger a sessionclose service network request to OmniChannel services.
|
|
288
295
|
|
|
289
296
|
If skipSessionCloseForPersistentChat is set to true. The session close network request will not be triggered, instead, if postChat survey is available, post chat survey will be displayed.
|
|
290
297
|
|
|
291
298
|
After successfully processed initiateEndChat event. The CloseChat event is broadcasted.
|
|
299
|
+
|
|
292
300
|
```js
|
|
293
301
|
BroadcastService.getMessageByEventName("CloseChat").subscribe(async (msg) => {
|
|
294
302
|
console.log("close chat received: ", msg);
|
|
295
303
|
//more actions to unmount component and resources
|
|
296
304
|
})
|
|
297
305
|
```
|
|
306
|
+
|
|
298
307
|
## See Also
|
|
299
308
|
|
|
300
309
|
[Customizations Dev Guide](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/customizations/getstarted.md)\
|
|
@@ -82,6 +82,8 @@ _defineProperty(Constants, "audioMediaRegex", /(\.)(aac|aiff|alac|amr|flac|mp2|m
|
|
|
82
82
|
_defineProperty(Constants, "videoMediaRegex", /(\.)(avchd|avi|flv|mpe|mpeg|mpg|mpv|mp4|m4p|m4v|mov|qt|swf|webm|wmv)$/i);
|
|
83
83
|
_defineProperty(Constants, "chromeSupportedInlineMediaRegex", /(\.)(aac|mp3|wav|mp4)$/i);
|
|
84
84
|
_defineProperty(Constants, "firefoxSupportedInlineMediaRegex", /(\.)(aac|flac|mp3|wav|mp4|mov)$/i);
|
|
85
|
+
_defineProperty(Constants, "AdaptiveCardType", "adaptivecard");
|
|
86
|
+
_defineProperty(Constants, "SuggestedActionsType", "suggestedactions");
|
|
85
87
|
// calling container event names
|
|
86
88
|
_defineProperty(Constants, "CallAdded", "callAdded");
|
|
87
89
|
_defineProperty(Constants, "LocalVideoStreamAdded", "localVideoStreamAdded");
|
|
@@ -26,6 +26,8 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
26
26
|
_defineProperty(this, "getAuthToken", void 0);
|
|
27
27
|
_defineProperty(this, "sdkMocked", void 0);
|
|
28
28
|
_defineProperty(this, "disableReauthentication", void 0);
|
|
29
|
+
// Stays true so CASE 1 re-triggers on every startChat to set deferInitialAuth
|
|
30
|
+
_defineProperty(this, "pendingMidAuthUnauthenticatedState", false);
|
|
29
31
|
this.chatSDK = input.chatSDK;
|
|
30
32
|
this.chatConfig = input.chatConfig;
|
|
31
33
|
this.getAuthToken = input.getAuthToken;
|
|
@@ -50,6 +52,12 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
50
52
|
value: function destroy() {
|
|
51
53
|
this.token = null;
|
|
52
54
|
this.expiration = 0;
|
|
55
|
+
if ((0, _authHelper.isMidAuthEnabled)(this.chatConfig)) {
|
|
56
|
+
this.pendingMidAuthUnauthenticatedState = false;
|
|
57
|
+
this.isAuthenticated = true;
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
|
+
this.chatSDK.deferInitialAuth = false;
|
|
60
|
+
}
|
|
53
61
|
}
|
|
54
62
|
}, {
|
|
55
63
|
key: "isTokenSet",
|
|
@@ -214,6 +222,10 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
214
222
|
message: "Token is valid"
|
|
215
223
|
};
|
|
216
224
|
}
|
|
225
|
+
|
|
226
|
+
// Token missing or expired - need to get a new one via getAuthToken
|
|
227
|
+
// For mid-auth: getAuthToken receives { isMidAuthEnabled: true } so customer implementations
|
|
228
|
+
// can check portal state and return null for logged-out users
|
|
217
229
|
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
218
230
|
Event: _TelemetryConstants.TelemetryEvent.NewTokenValidationStarted,
|
|
219
231
|
Description: "Token validation started."
|
|
@@ -234,6 +246,7 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
234
246
|
this.token = "";
|
|
235
247
|
this.expiration = 0;
|
|
236
248
|
try {
|
|
249
|
+
var _ring$error, _ring$error2;
|
|
237
250
|
const ring = await (0, _authHelper.handleAuthentication)(this.chatSDK, this.chatConfig, this.getAuthToken);
|
|
238
251
|
if ((ring === null || ring === void 0 ? void 0 : ring.result) === true && ring !== null && ring !== void 0 && ring.token) {
|
|
239
252
|
await this.setToken(ring.token);
|
|
@@ -248,18 +261,35 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
248
261
|
result: true,
|
|
249
262
|
message: "New Token obtained"
|
|
250
263
|
};
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Mid-auth: no token available - set pending flag for startChat to handle
|
|
267
|
+
const isEmptyTokenWithoutError = (0, _utils.isNullOrEmptyString)(ring === null || ring === void 0 ? void 0 : ring.token) && ((ring === null || ring === void 0 ? void 0 : ring.result) === true || (ring === null || ring === void 0 ? void 0 : ring.result) === false && !(ring !== null && ring !== void 0 && ring.error));
|
|
268
|
+
if ((0, _authHelper.isMidAuthEnabled)(this.chatConfig) && isEmptyTokenWithoutError) {
|
|
269
|
+
// Clear Facade and SDK token state so API calls use unauthenticated endpoints
|
|
270
|
+
this.token = "";
|
|
271
|
+
this.expiration = 0;
|
|
272
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
273
|
+
this.chatSDK.authenticatedUserToken = null;
|
|
274
|
+
this.pendingMidAuthUnauthenticatedState = true;
|
|
275
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
276
|
+
Event: _TelemetryConstants.TelemetryEvent.NewTokenValidationCompleted,
|
|
277
|
+
Description: "Mid-auth enabled: no token returned; proceeding as unauthenticated"
|
|
257
278
|
});
|
|
258
279
|
return {
|
|
259
|
-
result:
|
|
260
|
-
message:
|
|
280
|
+
result: true,
|
|
281
|
+
message: "Mid-auth: proceeding as unauthenticated"
|
|
261
282
|
};
|
|
262
283
|
}
|
|
284
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
|
|
285
|
+
Event: _TelemetryConstants.TelemetryEvent.NewTokenValidationFailed,
|
|
286
|
+
Description: (_ring$error = ring.error) === null || _ring$error === void 0 ? void 0 : _ring$error.message,
|
|
287
|
+
ExceptionDetails: ring === null || ring === void 0 ? void 0 : ring.error
|
|
288
|
+
});
|
|
289
|
+
return {
|
|
290
|
+
result: false,
|
|
291
|
+
message: (ring === null || ring === void 0 ? void 0 : (_ring$error2 = ring.error) === null || _ring$error2 === void 0 ? void 0 : _ring$error2.message) || "Failed to get token"
|
|
292
|
+
};
|
|
263
293
|
} catch (e) {
|
|
264
294
|
console.error("Unexpected error while getting token", e);
|
|
265
295
|
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
|
|
@@ -273,6 +303,155 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
273
303
|
};
|
|
274
304
|
}
|
|
275
305
|
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Sets unauthenticated state for mid-auth flow.
|
|
309
|
+
* Clears SDK internal state to prevent reconnection to previous authenticated session.
|
|
310
|
+
*/
|
|
311
|
+
}, {
|
|
312
|
+
key: "setMidAuthUnauthenticatedState",
|
|
313
|
+
value: function setMidAuthUnauthenticatedState() {
|
|
314
|
+
var _sdk$chatToken, _sdk$chatToken2;
|
|
315
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
316
|
+
const sdk = this.chatSDK;
|
|
317
|
+
const hadExistingChat = !!((_sdk$chatToken = sdk.chatToken) !== null && _sdk$chatToken !== void 0 && _sdk$chatToken.chatId);
|
|
318
|
+
const previousChatId = (_sdk$chatToken2 = sdk.chatToken) === null || _sdk$chatToken2 === void 0 ? void 0 : _sdk$chatToken2.chatId;
|
|
319
|
+
this.clearAuthState();
|
|
320
|
+
|
|
321
|
+
// Clear SDK internal state for fresh unauthenticated chat
|
|
322
|
+
sdk.chatToken = {};
|
|
323
|
+
sdk.reconnectId = null;
|
|
324
|
+
sdk.requestId = null;
|
|
325
|
+
sdk.sessionId = null;
|
|
326
|
+
sdk.conversation = null;
|
|
327
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
328
|
+
Event: _TelemetryConstants.TelemetryEvent.MidConversationAuthReset,
|
|
329
|
+
Description: hadExistingChat ? "Mid-auth without token: local state cleared" : "Mid-auth: initialized as unauthenticated (no prior chat)",
|
|
330
|
+
Data: hadExistingChat ? {
|
|
331
|
+
previousChatId
|
|
332
|
+
} : undefined
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** Clears authentication state in both FacadeChatSDK and underlying SDK */
|
|
337
|
+
}, {
|
|
338
|
+
key: "clearAuthState",
|
|
339
|
+
value: function clearAuthState() {
|
|
340
|
+
this.token = "";
|
|
341
|
+
this.expiration = 0;
|
|
342
|
+
this.isAuthenticated = false;
|
|
343
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
344
|
+
this.chatSDK.authenticatedUserToken = null;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Migrates conversation from unauthenticated to authenticated via authenticateChat.
|
|
349
|
+
* Called after startChat() when user has a valid token but the backend conversation
|
|
350
|
+
* was started as unauthenticated.
|
|
351
|
+
*/
|
|
352
|
+
}, {
|
|
353
|
+
key: "migrateConversationToAuthenticated",
|
|
354
|
+
value: async function migrateConversationToAuthenticated() {
|
|
355
|
+
try {
|
|
356
|
+
await this.chatSDK.authenticateChat(this.token, {
|
|
357
|
+
refreshChatToken: true
|
|
358
|
+
});
|
|
359
|
+
this.isAuthenticated = true;
|
|
360
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
361
|
+
Event: _TelemetryConstants.TelemetryEvent.MidConversationAuthSucceeded,
|
|
362
|
+
Description: "Mid-auth: authenticateChat completed, conversation migrated to authenticated"
|
|
363
|
+
});
|
|
364
|
+
} catch (e) {
|
|
365
|
+
// Non-fatal: Chat is already active via startChat, will retry on next reconnect
|
|
366
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.WARN, {
|
|
367
|
+
Event: _TelemetryConstants.TelemetryEvent.MidConversationAuthFailed,
|
|
368
|
+
Description: "Mid-auth: authenticateChat returned error after startChat, chat still active",
|
|
369
|
+
ExceptionDetails: {
|
|
370
|
+
message: e === null || e === void 0 ? void 0 : e.message
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Configures SDK auth state before startChat.
|
|
378
|
+
* CASE 1: Pending unauthenticated (no token) - sets deferInitialAuth=true
|
|
379
|
+
* CASE 2: Authenticated with valid token - sets SDK token and deferInitialAuth based on scenario
|
|
380
|
+
*/
|
|
381
|
+
}, {
|
|
382
|
+
key: "configureMidAuthState",
|
|
383
|
+
value: function configureMidAuthState(isReconnect, wasPreviousSessionAuthenticated) {
|
|
384
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
385
|
+
const sdk = this.chatSDK;
|
|
386
|
+
|
|
387
|
+
// CASE 1: No token available (user not logged in)
|
|
388
|
+
// pendingMidAuthUnauthenticatedState stays true until user logs in (cleared in tokenRing)
|
|
389
|
+
if (this.pendingMidAuthUnauthenticatedState) {
|
|
390
|
+
const shouldClear = this.handlePendingUnauthenticatedState(wasPreviousSessionAuthenticated);
|
|
391
|
+
sdk.deferInitialAuth = true;
|
|
392
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
393
|
+
Event: _TelemetryConstants.TelemetryEvent.MidConversationAuthReset,
|
|
394
|
+
Description: "Mid-auth configureMidAuthState: CASE 1 - unauthenticated, deferInitialAuth=true",
|
|
395
|
+
Data: {
|
|
396
|
+
isReconnect: String(isReconnect),
|
|
397
|
+
wasPreviousSessionAuthenticated: String(wasPreviousSessionAuthenticated),
|
|
398
|
+
shouldClearReconnectParams: String(shouldClear)
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
return {
|
|
402
|
+
shouldClearReconnectParams: shouldClear
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// CASE 2: Authenticated with valid token
|
|
407
|
+
if (this.isTokenSet() && !this.isTokenExpired()) {
|
|
408
|
+
this.handleAuthenticatedState(isReconnect, wasPreviousSessionAuthenticated);
|
|
409
|
+
}
|
|
410
|
+
return {
|
|
411
|
+
shouldClearReconnectParams: false
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* CASE 1 handler: Returns true if reconnect params should be cleared (Auth -> Unauth transition)
|
|
417
|
+
*/
|
|
418
|
+
}, {
|
|
419
|
+
key: "handlePendingUnauthenticatedState",
|
|
420
|
+
value: function handlePendingUnauthenticatedState(wasPreviousSessionAuthenticated) {
|
|
421
|
+
if (wasPreviousSessionAuthenticated) {
|
|
422
|
+
// Auth -> Unauth: user logged out, clear state for fresh chat
|
|
423
|
+
this.setMidAuthUnauthenticatedState();
|
|
424
|
+
return true;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// Unauth -> Unauth: keep liveChatContext for reconnection
|
|
428
|
+
this.isAuthenticated = false;
|
|
429
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
430
|
+
this.chatSDK.authenticatedUserToken = null;
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* CASE 2 handler: Sets deferInitialAuth only for reconnects to unauthenticated sessions (need migration).
|
|
436
|
+
* For new chats or reconnects to authenticated sessions, SDK handles auth internally.
|
|
437
|
+
*/
|
|
438
|
+
}, {
|
|
439
|
+
key: "handleAuthenticatedState",
|
|
440
|
+
value: function handleAuthenticatedState(isReconnect, wasPreviousSessionAuthenticated) {
|
|
441
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
442
|
+
const sdk = this.chatSDK;
|
|
443
|
+
sdk.authenticatedUserToken = this.token;
|
|
444
|
+
if (isReconnect && !wasPreviousSessionAuthenticated) {
|
|
445
|
+
sdk.deferInitialAuth = true;
|
|
446
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
447
|
+
Event: _TelemetryConstants.TelemetryEvent.MidConversationAuthSucceeded,
|
|
448
|
+
Description: "Mid-auth handleAuthenticatedState: CASE 2 - reconnect to unauth session, deferInitialAuth=true (migration needed)"
|
|
449
|
+
});
|
|
450
|
+
} else {
|
|
451
|
+
// Reset to prevent inheriting deferInitialAuth=true from a previous unauthenticated chat
|
|
452
|
+
sdk.deferInitialAuth = false;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
276
455
|
}, {
|
|
277
456
|
key: "validateAndExecuteCall",
|
|
278
457
|
value: async function validateAndExecuteCall(functionName, fn) {
|
|
@@ -307,7 +486,53 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
307
486
|
key: "startChat",
|
|
308
487
|
value: async function startChat() {
|
|
309
488
|
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
310
|
-
|
|
489
|
+
const midAuthEnabled = (0, _authHelper.isMidAuthEnabled)(this.chatConfig);
|
|
490
|
+
const isReconnect = !!optionalParams.liveChatContext || !!optionalParams.reconnectId;
|
|
491
|
+
const wasPreviousSessionAuthenticated = optionalParams.wasAuthenticated === true;
|
|
492
|
+
return this.validateAndExecuteCall("startChat", async () => {
|
|
493
|
+
if (midAuthEnabled) {
|
|
494
|
+
const {
|
|
495
|
+
shouldClearReconnectParams
|
|
496
|
+
} = this.configureMidAuthState(isReconnect, wasPreviousSessionAuthenticated);
|
|
497
|
+
if (shouldClearReconnectParams) {
|
|
498
|
+
delete optionalParams.liveChatContext;
|
|
499
|
+
delete optionalParams.reconnectId;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
await this.chatSDK.startChat(optionalParams);
|
|
503
|
+
|
|
504
|
+
// Migrate to authenticated if needed (reconnects to unauthenticated sessions only)
|
|
505
|
+
if (midAuthEnabled) {
|
|
506
|
+
const shouldMigrateToAuth = isReconnect && this.isTokenSet() && !this.isTokenExpired() && !wasPreviousSessionAuthenticated;
|
|
507
|
+
if (shouldMigrateToAuth) {
|
|
508
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
509
|
+
Event: _TelemetryConstants.TelemetryEvent.MidConversationAuthSucceeded,
|
|
510
|
+
Description: "Mid-auth startChat: initiating migration to authenticated",
|
|
511
|
+
Data: {
|
|
512
|
+
isReconnect: String(isReconnect),
|
|
513
|
+
wasPreviousSessionAuthenticated: String(wasPreviousSessionAuthenticated)
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
await this.migrateConversationToAuthenticated();
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// Broadcast final auth state after startChat completes (only on state change)
|
|
521
|
+
if (midAuthEnabled) {
|
|
522
|
+
const isAuthenticatedAfterStart = this.isTokenSet() && !this.isTokenExpired();
|
|
523
|
+
const authStateChanged = !isReconnect || isAuthenticatedAfterStart !== wasPreviousSessionAuthenticated;
|
|
524
|
+
if (authStateChanged) {
|
|
525
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
526
|
+
eventName: isAuthenticatedAfterStart ? _TelemetryConstants.BroadcastEvent.MidConversationAuthSucceeded : _TelemetryConstants.BroadcastEvent.MidConversationAuthReset,
|
|
527
|
+
payload: {
|
|
528
|
+
isAuthenticated: isAuthenticatedAfterStart,
|
|
529
|
+
isStartChatComplete: true,
|
|
530
|
+
isReconnect
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
});
|
|
311
536
|
}
|
|
312
537
|
}, {
|
|
313
538
|
key: "endChat",
|
|
@@ -445,6 +670,7 @@ let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
445
670
|
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
446
671
|
return this.validateAndExecuteCall("getAgentAvailability", () => this.chatSDK.getAgentAvailability(optionalParams));
|
|
447
672
|
}
|
|
673
|
+
|
|
448
674
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
449
675
|
}, {
|
|
450
676
|
key: "getReconnectableChats",
|
|
@@ -74,6 +74,8 @@ exports.BroadcastEvent = BroadcastEvent;
|
|
|
74
74
|
BroadcastEvent["FMLTrackingCompletedAck"] = "FMLTrackingCompletedAck";
|
|
75
75
|
BroadcastEvent["FMLTrackingCompleted"] = "FMLTrackingCompleted";
|
|
76
76
|
BroadcastEvent["PersistentConversationReset"] = "PersistentConversationReset";
|
|
77
|
+
BroadcastEvent["MidConversationAuthSucceeded"] = "MidConversationAuthSucceeded";
|
|
78
|
+
BroadcastEvent["MidConversationAuthReset"] = "MidConversationAuthReset";
|
|
77
79
|
})(BroadcastEvent || (exports.BroadcastEvent = BroadcastEvent = {}));
|
|
78
80
|
let TelemetryEvent;
|
|
79
81
|
exports.TelemetryEvent = TelemetryEvent;
|
|
@@ -108,6 +110,9 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
108
110
|
TelemetryEvent["CallingSDKInitFailed"] = "CallingSDKInitFailed";
|
|
109
111
|
TelemetryEvent["CallingSDKLoadSuccess"] = "CallingSDKLoadSuccess";
|
|
110
112
|
TelemetryEvent["CallingSDKLoadFailed"] = "CallingSDKLoadFailed";
|
|
113
|
+
TelemetryEvent["MidConversationAuthSucceeded"] = "MidConversationAuthSucceeded";
|
|
114
|
+
TelemetryEvent["MidConversationAuthFailed"] = "MidConversationAuthFailed";
|
|
115
|
+
TelemetryEvent["MidConversationAuthReset"] = "MidConversationAuthReset";
|
|
111
116
|
TelemetryEvent["GetConversationDetailsCallStarted"] = "GetConversationDetailsCallStarted";
|
|
112
117
|
TelemetryEvent["GetConversationDetailsCallFailed"] = "GetConversationDetailsCallFailed";
|
|
113
118
|
TelemetryEvent["EndChatSDKCallFailed"] = "EndChatSDKCallFailed";
|
|
@@ -318,10 +323,16 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
318
323
|
TelemetryEvent["LCWLazyLoadNoMoreHistory"] = "LCWLazyLoadNoMoreHistory";
|
|
319
324
|
TelemetryEvent["LCWLazyLoadHistoryError"] = "LCWLazyLoadHistoryError";
|
|
320
325
|
TelemetryEvent["LCWLazyLoadDestroyed"] = "LCWLazyLoadDestroyed";
|
|
326
|
+
TelemetryEvent["LCWLazyLoadTriggerFired"] = "LCWLazyLoadTriggerFired";
|
|
327
|
+
TelemetryEvent["LCWLazyLoadBatchReceived"] = "LCWLazyLoadBatchReceived";
|
|
328
|
+
TelemetryEvent["LCWLazyLoadInitialLoadComplete"] = "LCWLazyLoadInitialLoadComplete";
|
|
329
|
+
TelemetryEvent["LCWLazyLoadScrollAnchorApplied"] = "LCWLazyLoadScrollAnchorApplied";
|
|
321
330
|
TelemetryEvent["SecureEventBusUnauthorizedDispatch"] = "SecureEventBusUnauthorizedDispatch";
|
|
322
331
|
TelemetryEvent["SecureEventBusListenerError"] = "SecureEventBusListenerError";
|
|
323
332
|
TelemetryEvent["SecureEventBusDispatchError"] = "SecureEventBusDispatchError";
|
|
324
333
|
TelemetryEvent["StartChatComplete"] = "StartChatComplete";
|
|
334
|
+
TelemetryEvent["AgentJoinedConversation"] = "AgentJoinedConversation";
|
|
335
|
+
TelemetryEvent["BrowserTabHidden"] = "BrowserTabHidden";
|
|
325
336
|
})(TelemetryEvent || (exports.TelemetryEvent = TelemetryEvent = {}));
|
|
326
337
|
let TelemetryConstants = /*#__PURE__*/function () {
|
|
327
338
|
function TelemetryConstants() {
|
|
@@ -392,6 +403,8 @@ let TelemetryConstants = /*#__PURE__*/function () {
|
|
|
392
403
|
case TelemetryEvent.SecureEventBusUnauthorizedDispatch:
|
|
393
404
|
case TelemetryEvent.SecureEventBusListenerError:
|
|
394
405
|
case TelemetryEvent.SecureEventBusDispatchError:
|
|
406
|
+
case TelemetryEvent.AgentJoinedConversation:
|
|
407
|
+
case TelemetryEvent.BrowserTabHidden:
|
|
395
408
|
return ScenarioType.ACTIONS;
|
|
396
409
|
case TelemetryEvent.StartChatSDKCall:
|
|
397
410
|
case TelemetryEvent.StartChatEventReceived:
|
|
@@ -7,70 +7,42 @@ exports.detectAndCleanXSS = void 0;
|
|
|
7
7
|
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Sanitizes text input and detects XSS attack patterns.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* against various XSS techniques including script injection, event handler injection, style-based
|
|
15
|
-
* attacks, and encoded payloads.
|
|
12
|
+
* Sanitizes first with DOMPurify, then checks for malicious patterns in both
|
|
13
|
+
* the original and sanitized text to catch mutation XSS attacks.
|
|
16
14
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* - HTML event handlers (onmouseover, onclick, etc.)
|
|
20
|
-
* - Script tags (<script>)
|
|
21
|
-
* - CSS expression() functions
|
|
22
|
-
* - CSS url() functions
|
|
23
|
-
* - Position-based CSS attacks (position: fixed/absolute)
|
|
24
|
-
* - VBScript protocol URLs
|
|
25
|
-
* - Data URLs with HTML content
|
|
26
|
-
* - Fragment identifiers with escaped quotes
|
|
27
|
-
* - HTML entity-encoded angle brackets
|
|
28
|
-
*
|
|
29
|
-
* @param text - The input text to be analyzed and sanitized
|
|
30
|
-
* @returns An object containing:
|
|
31
|
-
* - cleanText: The sanitized version of the input text with all HTML tags and attributes removed
|
|
32
|
-
* - isXSSDetected: Boolean flag indicating whether potential XSS patterns were found in the original text
|
|
15
|
+
* @param text - Input text to sanitize
|
|
16
|
+
* @returns Object with cleanText (sanitized) and isXSSDetected flag
|
|
33
17
|
*/
|
|
34
18
|
const detectAndCleanXSS = text => {
|
|
35
|
-
//
|
|
36
|
-
const xssPatterns = [/javascript\s*:/gi,
|
|
37
|
-
// JavaScript protocol URLs (with optional spaces)
|
|
38
|
-
/vbscript\s*:/gi,
|
|
39
|
-
// VBScript protocol URLs (with optional spaces)
|
|
40
|
-
/on\w+\s*=/gi,
|
|
41
|
-
// HTML event handlers (onmouseover, onclick, onload, etc.)
|
|
42
|
-
/<\s*script/gi,
|
|
43
|
-
// Script tag opening (with optional spaces)
|
|
44
|
-
/expression\s*\(/gi,
|
|
45
|
-
// CSS expression() function (IE-specific)
|
|
46
|
-
/url\s*\(/gi,
|
|
47
|
-
// CSS url() function
|
|
48
|
-
/style\s*=.*position\s*:\s*fixed/gi,
|
|
49
|
-
// CSS position fixed attacks
|
|
50
|
-
/style\s*=.*position\s*:\s*absolute/gi,
|
|
51
|
-
// CSS position absolute attacks
|
|
52
|
-
/data\s*:\s*text\s*\/\s*html/gi,
|
|
53
|
-
// Data URLs containing HTML
|
|
54
|
-
/#.*\\"/gi,
|
|
55
|
-
// Fragment identifiers with escaped quotes
|
|
56
|
-
/>.*</gi // HTML entity-encoded angle brackets indicating tag structure
|
|
57
|
-
];
|
|
58
|
-
|
|
59
|
-
// Check if any XSS patterns are detected in the input text
|
|
60
|
-
const isXSSDetected = xssPatterns.some(pattern => pattern.test(text));
|
|
61
|
-
|
|
62
|
-
// Clean the text using DOMPurify with strict config
|
|
19
|
+
// Sanitize first to prevent mutation XSS (e.g., "s<iframe></iframe>tyle" → "style")
|
|
63
20
|
const cleanText = _dompurify.default.sanitize(text, {
|
|
64
21
|
ALLOWED_TAGS: [],
|
|
65
|
-
// No HTML tags allowed in title
|
|
66
22
|
ALLOWED_ATTR: [],
|
|
67
23
|
KEEP_CONTENT: true,
|
|
68
|
-
// Keep text content
|
|
69
24
|
ALLOW_DATA_ATTR: false,
|
|
70
25
|
ALLOW_UNKNOWN_PROTOCOLS: false,
|
|
71
26
|
SANITIZE_DOM: true,
|
|
72
27
|
FORCE_BODY: false
|
|
73
28
|
});
|
|
29
|
+
const contentChanged = text !== cleanText;
|
|
30
|
+
|
|
31
|
+
// Non-global regex patterns to avoid stateful .test() issues
|
|
32
|
+
const xssPatterns = [/javascript\s*:/i, /vbscript\s*:/i, /on\w+\s*=/i,
|
|
33
|
+
// Event handlers
|
|
34
|
+
/<\s*script/i, /<\s*iframe/i, /<\s*object/i, /<\s*embed/i, /<\s*svg/i, /expression\s*\(/i,
|
|
35
|
+
// IE CSS expressions
|
|
36
|
+
/style\s*=.*position\s*:\s*(fixed|absolute)/i, /data\s*:\s*text\s*\/\s*html/i, /#.*\\"/i, /&(lt|gt|#x3c|#60|#x3e|#62);/i,
|
|
37
|
+
// HTML entities
|
|
38
|
+
/&#x?[0-9a-f]+;.*</i, /\u003c.*\u003e/i,
|
|
39
|
+
// Unicode escapes
|
|
40
|
+
/src\s*=\s*["']?\s*javascript:/i, /href\s*=\s*["']?\s*javascript:/i];
|
|
41
|
+
const hasXSSPattern = xssPatterns.some(pattern => {
|
|
42
|
+
return pattern.test(text) || pattern.test(cleanText);
|
|
43
|
+
});
|
|
44
|
+
const hasHTMLStructure = /<[^>]+>/.test(text) && !/<[^>]+>/.test(cleanText);
|
|
45
|
+
const isXSSDetected = contentChanged || hasXSSPattern || hasHTMLStructure;
|
|
74
46
|
return {
|
|
75
47
|
cleanText,
|
|
76
48
|
isXSSDetected
|
package/lib/cjs/common/utils.js
CHANGED
|
@@ -480,7 +480,7 @@ const setOcUserAgent = chatSDK => {
|
|
|
480
480
|
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
481
481
|
if ((_chatSDK$OCClient = chatSDK.OCClient) !== null && _chatSDK$OCClient !== void 0 && _chatSDK$OCClient.ocUserAgent && !((_chatSDK$OCClient2 = chatSDK.OCClient) !== null && _chatSDK$OCClient2 !== void 0 && _chatSDK$OCClient2.ocUserAgent.join(" ").includes("omnichannel-chat-widget/"))) {
|
|
482
482
|
try {
|
|
483
|
-
const version = require("
|
|
483
|
+
const version = require("../../package.json").version; // eslint-disable-line @typescript-eslint/no-var-requires
|
|
484
484
|
const userAgent = `omnichannel-chat-widget/${version}`;
|
|
485
485
|
chatSDK.OCClient.ocUserAgent = [userAgent, ...chatSDK.OCClient.ocUserAgent];
|
|
486
486
|
} catch (error) {
|
|
@@ -35,8 +35,16 @@ const LiveChatWidget = props => {
|
|
|
35
35
|
throw new Error("chatConfig is required");
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
// Check configuration flags
|
|
38
39
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
-
const
|
|
40
|
+
const hasAuthClientFn = !!((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction);
|
|
41
|
+
const persistentChatEnabled = (0, _liveChatConfigUtils.isPersistentChatEnabled)((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_conversationmode);
|
|
42
|
+
|
|
43
|
+
// isAuthenticatedChat determines if FacadeChatSDK should require authentication:
|
|
44
|
+
// REGULAR AUTH FLOW (config-based):
|
|
45
|
+
// - Persistent chat enabled ? always authenticated
|
|
46
|
+
// - Auth settings exist ? authenticated from start
|
|
47
|
+
const isAuthenticatedChat = persistentChatEnabled || hasAuthClientFn;
|
|
40
48
|
if (!facadeChatSDK) {
|
|
41
49
|
var _props$mock;
|
|
42
50
|
setFacadeChatSDK(new _FacadeChatSDK.FacadeChatSDK({
|
package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js
CHANGED
|
@@ -44,7 +44,7 @@ const extractSasUrl = async attachment => {
|
|
|
44
44
|
}
|
|
45
45
|
return sasUrl;
|
|
46
46
|
};
|
|
47
|
-
const fetchBotAuthConfig = async (retries, interval) => {
|
|
47
|
+
const fetchBotAuthConfig = async (retries, interval, fallback) => {
|
|
48
48
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
49
49
|
Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderFetchConfig
|
|
50
50
|
});
|
|
@@ -60,13 +60,23 @@ const fetchBotAuthConfig = async (retries, interval) => {
|
|
|
60
60
|
});
|
|
61
61
|
if (retries === 1) {
|
|
62
62
|
// Base Case
|
|
63
|
-
|
|
63
|
+
if (response !== undefined) {
|
|
64
|
+
return response;
|
|
65
|
+
}
|
|
66
|
+
if (fallback !== undefined) {
|
|
67
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.WARN, {
|
|
68
|
+
Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderNotFound,
|
|
69
|
+
Description: `Failed to fetch bot auth config after maximum retries. Using fallback value: ${fallback}`
|
|
70
|
+
});
|
|
71
|
+
return fallback;
|
|
72
|
+
}
|
|
73
|
+
throw new Error("Failed to fetch bot auth config after maximum retries");
|
|
64
74
|
}
|
|
65
75
|
await delay(interval);
|
|
66
76
|
if (response !== undefined) {
|
|
67
77
|
return response;
|
|
68
78
|
}
|
|
69
|
-
return await fetchBotAuthConfig(--retries, interval);
|
|
79
|
+
return await fetchBotAuthConfig(--retries, interval, fallback);
|
|
70
80
|
};
|
|
71
81
|
let BotAuthActivitySubscriber = /*#__PURE__*/function () {
|
|
72
82
|
function BotAuthActivitySubscriber() {
|
|
@@ -76,6 +86,7 @@ let BotAuthActivitySubscriber = /*#__PURE__*/function () {
|
|
|
76
86
|
_defineProperty(this, "signInCardSeen", void 0);
|
|
77
87
|
_defineProperty(this, "fetchBotAuthConfigRetries", void 0);
|
|
78
88
|
_defineProperty(this, "fetchBotAuthConfigRetryInterval", void 0);
|
|
89
|
+
_defineProperty(this, "fallbackShowSignInCard", void 0);
|
|
79
90
|
this.signInCardSeen = new Set();
|
|
80
91
|
this.fetchBotAuthConfigRetries = 3;
|
|
81
92
|
this.fetchBotAuthConfigRetryInterval = 1000;
|
|
@@ -85,6 +96,11 @@ let BotAuthActivitySubscriber = /*#__PURE__*/function () {
|
|
|
85
96
|
if (optionalParams.fetchBotAuthConfigRetryInterval) {
|
|
86
97
|
this.fetchBotAuthConfigRetryInterval = optionalParams.fetchBotAuthConfigRetryInterval;
|
|
87
98
|
}
|
|
99
|
+
this.fallbackShowSignInCard = optionalParams.fallbackShowSignInCard;
|
|
100
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
101
|
+
Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderFetchConfig,
|
|
102
|
+
Description: `BotAuthActivitySubscriber initialized with fallbackShowSignInCard: ${optionalParams.fallbackShowSignInCard}`
|
|
103
|
+
});
|
|
88
104
|
}
|
|
89
105
|
_createClass(BotAuthActivitySubscriber, [{
|
|
90
106
|
key: "applicable",
|
|
@@ -129,7 +145,7 @@ let BotAuthActivitySubscriber = /*#__PURE__*/function () {
|
|
|
129
145
|
_omnichannelChatComponents.BroadcastService.postMessage(event);
|
|
130
146
|
}
|
|
131
147
|
try {
|
|
132
|
-
const response = await fetchBotAuthConfig(this.fetchBotAuthConfigRetries, this.fetchBotAuthConfigRetryInterval);
|
|
148
|
+
const response = await fetchBotAuthConfig(this.fetchBotAuthConfigRetries, this.fetchBotAuthConfigRetryInterval, this.fallbackShowSignInCard);
|
|
133
149
|
if (response === false) {
|
|
134
150
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
135
151
|
Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderHideCard
|
|
@@ -140,9 +156,10 @@ let BotAuthActivitySubscriber = /*#__PURE__*/function () {
|
|
|
140
156
|
});
|
|
141
157
|
return activity;
|
|
142
158
|
}
|
|
143
|
-
} catch {
|
|
159
|
+
} catch (e) {
|
|
144
160
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
145
|
-
Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderNotFound
|
|
161
|
+
Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderNotFound,
|
|
162
|
+
ExceptionDetails: e instanceof Error ? e.message : JSON.stringify(e)
|
|
146
163
|
});
|
|
147
164
|
//this is to ensure listener continues waiting for response
|
|
148
165
|
if (this.signInCardSeen.has(signInId)) {
|
|
@@ -10,6 +10,7 @@ var ChatWidgetEvents;
|
|
|
10
10
|
ChatWidgetEvents["FETCH_PERSISTENT_CHAT_HISTORY"] = "CHAT_WIDGET/FETCH_PERSISTENT_CHAT_HISTORY";
|
|
11
11
|
ChatWidgetEvents["NO_MORE_HISTORY_AVAILABLE"] = "CHAT_WIDGET/NO_MORE_HISTORY_AVAILABLE";
|
|
12
12
|
ChatWidgetEvents["HISTORY_LOAD_ERROR"] = "CHAT_WIDGET/HISTORY_LOAD_ERROR";
|
|
13
|
+
ChatWidgetEvents["HISTORY_BATCH_LOADED"] = "CHAT_WIDGET/HISTORY_BATCH_LOADED";
|
|
13
14
|
})(ChatWidgetEvents || (ChatWidgetEvents = {}));
|
|
14
15
|
var _default = ChatWidgetEvents;
|
|
15
16
|
exports.default = _default;
|
|
@@ -133,6 +133,12 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
|
|
|
133
133
|
}
|
|
134
134
|
const messagesDescOrder = (_ref = [...messages]) === null || _ref === void 0 ? void 0 : _ref.reverse();
|
|
135
135
|
this.processHistoryMessages(messagesDescOrder);
|
|
136
|
+
|
|
137
|
+
// Signal that a batch of history messages has been added to the store.
|
|
138
|
+
// LazyLoadActivity subscribes to this to apply scroll anchoring after render.
|
|
139
|
+
(0, _dispatchCustomEvent.default)(_ChatWidgetEvents.default.HISTORY_BATCH_LOADED, {
|
|
140
|
+
messageCount: messages.length
|
|
141
|
+
});
|
|
136
142
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
137
143
|
Event: _TelemetryConstants.TelemetryEvent.LCWPersistentHistoryPullCompleted,
|
|
138
144
|
Description: "History pull completed successfully",
|
|
@@ -241,6 +247,9 @@ let PersistentConversationHandler = /*#__PURE__*/function () {
|
|
|
241
247
|
value: function processMessageToActivity(message) {
|
|
242
248
|
try {
|
|
243
249
|
const activity = (0, _convertPersistentChatHistoryMessageToActivity.default)(message);
|
|
250
|
+
if (!activity) {
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
244
253
|
activity.id = activity.id || `activity-${this.count}`;
|
|
245
254
|
activity.channelData = {
|
|
246
255
|
...activity.channelData,
|