@microsoft/omnichannel-chat-widget 1.8.1-main.20b15cc → 1.8.1-main.4fb8cb5

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.
Files changed (38) hide show
  1. package/lib/cjs/common/telemetry/TelemetryConstants.js +4 -0
  2. package/lib/cjs/common/telemetry/TelemetryManager.js +4 -4
  3. package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +4 -5
  4. package/lib/cjs/common/utils/xssUtils.js +79 -0
  5. package/lib/cjs/common/utils.js +3 -0
  6. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +7 -3
  7. package/lib/cjs/components/errorboundary/ErrorBoundary.js +68 -0
  8. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +12 -2
  9. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +4 -0
  10. package/lib/cjs/components/livechatwidget/common/startChat.js +1 -7
  11. package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +30 -1
  12. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +31 -19
  13. package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +23 -2
  14. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +14 -5
  15. package/lib/cjs/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +1 -0
  16. package/lib/esm/common/telemetry/TelemetryConstants.js +4 -0
  17. package/lib/esm/common/telemetry/TelemetryManager.js +4 -4
  18. package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +4 -5
  19. package/lib/esm/common/utils/xssUtils.js +72 -0
  20. package/lib/esm/common/utils.js +3 -0
  21. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +7 -3
  22. package/lib/esm/components/errorboundary/ErrorBoundary.js +59 -0
  23. package/lib/esm/components/livechatwidget/LiveChatWidget.js +13 -3
  24. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +4 -0
  25. package/lib/esm/components/livechatwidget/common/startChat.js +1 -7
  26. package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +28 -0
  27. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +31 -19
  28. package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +23 -2
  29. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +14 -5
  30. package/lib/esm/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +1 -0
  31. package/lib/types/common/telemetry/TelemetryConstants.d.ts +4 -0
  32. package/lib/types/common/telemetry/loggers/appInsightsLogger.d.ts +1 -1
  33. package/lib/types/common/utils/xssUtils.d.ts +29 -0
  34. package/lib/types/components/errorboundary/ErrorBoundary.d.ts +14 -0
  35. package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +1 -0
  36. package/lib/types/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.d.ts +2 -1
  37. package/lib/types/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +1 -0
  38. package/package.json +2 -2
@@ -18,13 +18,14 @@ var _isValidSurveyUrl = _interopRequireDefault(require("./common/isValidSurveyUr
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
20
20
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
- const generateSurveyInviteLink = function (surveyInviteLink, isEmbed, locale, compact) {
22
- let showMultiLingual = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
21
+ const generateSurveyInviteLink = function (surveyInviteLink, isEmbed, locale, compact, customerVoiceSurveyCorrelationId) {
22
+ let showMultiLingual = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
23
23
  const surveyLinkParams = new URLSearchParams({
24
24
  embed: isEmbed.toString(),
25
25
  compact: (compact ?? true).toString(),
26
26
  lang: locale ?? "en-us",
27
- showmultilingual: (showMultiLingual ?? false).toString()
27
+ showmultilingual: (showMultiLingual ?? false).toString(),
28
+ cvResponsePageRequestId: customerVoiceSurveyCorrelationId
28
29
  });
29
30
  return `${surveyInviteLink}&${surveyLinkParams.toString()}`;
30
31
  };
@@ -40,9 +41,9 @@ const PostChatSurveyPaneStateful = props => {
40
41
  // Bot survey enabled
41
42
  state.appStates.postChatParticipantType === _Constants.ParticipantType.Bot) {
42
43
  // Only Bot has engaged
43
- surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.botSurveyInviteLink, surveyMode, state.domainStates.postChatContext.botFormsProLocale, props.isCustomerVoiceSurveyCompact ?? true);
44
+ surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.botSurveyInviteLink, surveyMode, state.domainStates.postChatContext.botFormsProLocale, props.isCustomerVoiceSurveyCompact ?? true, props.customerVoiceSurveyCorrelationId || "");
44
45
  } else {
45
- surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.surveyInviteLink, surveyMode, state.domainStates.postChatContext.formsProLocale, props.isCustomerVoiceSurveyCompact ?? true);
46
+ surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.surveyInviteLink, surveyMode, state.domainStates.postChatContext.formsProLocale, props.isCustomerVoiceSurveyCompact ?? true, props.customerVoiceSurveyCorrelationId || "");
46
47
  }
47
48
  if (props.copilotSurveyContext) {
48
49
  surveyInviteLink = `${surveyInviteLink}&mcs_additionalcontext=${JSON.stringify(props.copilotSurveyContext)}`;
@@ -105,6 +106,14 @@ const PostChatSurveyPaneStateful = props => {
105
106
  message: "Customer Voice form response error."
106
107
  }
107
108
  });
109
+ } else if (typeof data === "string" && data.startsWith(_CustomerVoiceEvents.CustomerVoiceEvents.FormsError)) {
110
+ _TelemetryHelper.TelemetryHelper.logActionEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
111
+ Event: _TelemetryConstants.TelemetryEvent.CustomerVoiceFormsError,
112
+ Description: "Customer Voice failed to load with forms error.",
113
+ ExceptionDetails: {
114
+ message: `Customer Voice forms error details: ${data}`
115
+ }
116
+ });
108
117
  }
109
118
  });
110
119
  }, []);
@@ -10,4 +10,5 @@ exports.CustomerVoiceEvents = CustomerVoiceEvents;
10
10
  CustomerVoiceEvents["ResponsePageLoaded"] = "ResponsePageLoaded";
11
11
  CustomerVoiceEvents["FormResponseSubmitted"] = "FormResponseSubmitted";
12
12
  CustomerVoiceEvents["FormResponseError"] = "FormResponseError";
13
+ CustomerVoiceEvents["FormsError"] = "FormsError";
13
14
  })(CustomerVoiceEvents || (exports.CustomerVoiceEvents = CustomerVoiceEvents = {}));
@@ -106,6 +106,8 @@ export let TelemetryEvent;
106
106
  TelemetryEvent["DisconnectEndChatSDKCallFailed"] = "DisconnectEndChatSDKCallFailed";
107
107
  TelemetryEvent["GetChatReconnectContextSDKCallStarted"] = "GetChatReconnectContextSDKCallStarted";
108
108
  TelemetryEvent["GetChatReconnectContextSDKCallFailed"] = "GetChatReconnectContextSDKCallFailed";
109
+ TelemetryEvent["CheckContactIdError"] = "checkContactIdError";
110
+ TelemetryEvent["GetChatReconnectContextSDKCallSucceeded"] = "GetChatReconnectContextSDKCallSucceeded";
109
111
  TelemetryEvent["ParseAdaptiveCardFailed"] = "ParseAdaptiveCardFailed";
110
112
  TelemetryEvent["ClientDataStoreProviderFailed"] = "ClientDataStoreProviderFailed";
111
113
  TelemetryEvent["InMemoryDataStoreFailed"] = "InMemoryDataStoreFailed";
@@ -173,6 +175,7 @@ export let TelemetryEvent;
173
175
  TelemetryEvent["CustomerVoiceResponsePageLoaded"] = "CustomerVoiceResponsePageLoaded";
174
176
  TelemetryEvent["CustomerVoiceFormResponseSubmitted"] = "CustomerVoiceFormResponseSubmitted";
175
177
  TelemetryEvent["CustomerVoiceFormResponseError"] = "CustomerVoiceFormResponseError";
178
+ TelemetryEvent["CustomerVoiceFormsError"] = "CustomerVoiceFormsError";
176
179
  TelemetryEvent["BotAuthActivityEmptySasUrl"] = "BotAuthActivityEmptySasUrl";
177
180
  TelemetryEvent["SetBotAuthProviderFetchConfig"] = "SetBotAuthProviderFetchConfig";
178
181
  TelemetryEvent["SetBotAuthProviderHideCard"] = "SetBotAuthProviderHideCard";
@@ -250,6 +253,7 @@ export let TelemetryEvent;
250
253
  TelemetryEvent["UXNotificationPaneCompleted"] = "UXNotificationPaneCompleted";
251
254
  TelemetryEvent["UXOutOfOfficeHoursPaneStart"] = "UXOutOfOfficeHoursPaneStart";
252
255
  TelemetryEvent["UXOutOfOfficeHoursPaneCompleted"] = "UXOutOfOfficeHoursPaneCompleted";
256
+ TelemetryEvent["XSSTextDetected"] = "XSSTextDetected";
253
257
  TelemetryEvent["UXPostChatLoadingPaneStart"] = "UXPostChatLoadingPaneStart";
254
258
  TelemetryEvent["UXPostChatLoadingPaneCompleted"] = "UXPostChatLoadingPaneCompleted";
255
259
  TelemetryEvent["UXPrechatPaneStart"] = "UXPrechatPaneStart";
@@ -6,11 +6,11 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
6
6
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
7
  import { LogLevel, ScenarioType, TelemetryConstants, TelemetryEvent } from "./TelemetryConstants";
8
8
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
9
+ import { TelemetryHelper } from "./TelemetryHelper";
10
+ import { appInsightsLogger } from "./loggers/appInsightsLogger";
9
11
  import { ariaTelemetryLogger } from "./loggers/ariaTelemetryLogger";
10
12
  import { consoleLogger } from "./loggers/consoleLogger";
11
13
  import { defaultAriaConfig } from "./defaultConfigs/defaultAriaConfig";
12
- import { TelemetryHelper } from "./TelemetryHelper";
13
- import { appInsightsLogger } from "./loggers/appInsightsLogger";
14
14
  export let TelemetryTimers = /*#__PURE__*/_createClass(function TelemetryTimers() {
15
15
  _classCallCheck(this, TelemetryTimers);
16
16
  });
@@ -55,8 +55,8 @@ export const RegisterLoggers = () => {
55
55
  if (((_TelemetryManager$Int22 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int22 === void 0 ? void 0 : (_TelemetryManager$Int23 = _TelemetryManager$Int22.appInsightsConfig) === null || _TelemetryManager$Int23 === void 0 ? void 0 : _TelemetryManager$Int23.appInsightsDisabled) === false) {
56
56
  var _TelemetryManager$Int24;
57
57
  if ((_TelemetryManager$Int24 = TelemetryManager.InternalTelemetryData) !== null && _TelemetryManager$Int24 !== void 0 && _TelemetryManager$Int24.appInsightsConfig.appInsightsKey) {
58
- var _TelemetryManager$Int25, _TelemetryManager$Int26, _TelemetryManager$Int27;
59
- loggers.push(appInsightsLogger((_TelemetryManager$Int25 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int25 === void 0 ? void 0 : _TelemetryManager$Int25.appInsightsConfig.appInsightsKey, ((_TelemetryManager$Int26 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int26 === void 0 ? void 0 : (_TelemetryManager$Int27 = _TelemetryManager$Int26.ariaConfig) === null || _TelemetryManager$Int27 === void 0 ? void 0 : _TelemetryManager$Int27.disableCookieUsage) ?? defaultAriaConfig.disableCookieUsage));
58
+ var _TelemetryManager$Int25;
59
+ loggers.push(appInsightsLogger((_TelemetryManager$Int25 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int25 === void 0 ? void 0 : _TelemetryManager$Int25.appInsightsConfig.appInsightsKey));
60
60
  }
61
61
  }
62
62
  }
@@ -16,14 +16,14 @@ var AllowedKeys;
16
16
  AllowedKeys["ElapsedTimeInMilliseconds"] = "DurationInMilliseconds";
17
17
  })(AllowedKeys || (AllowedKeys = {}));
18
18
  let initializationPromise = null;
19
- export const appInsightsLogger = (appInsightsKey, disableCookiesUsage) => {
19
+ export const appInsightsLogger = appInsightsKey => {
20
20
  const isValidKey = key => {
21
21
  const INSTRUMENTATION_KEY_PATTERN = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
22
22
  const INSTRUMENTATION_KEY_REGEX = new RegExp(`^${INSTRUMENTATION_KEY_PATTERN}$`);
23
23
  const CONNECTION_STRING_REGEX = new RegExp(`^InstrumentationKey=${INSTRUMENTATION_KEY_PATTERN};IngestionEndpoint=https://[a-zA-Z0-9\\-\\.]+\\.applicationinsights\\.azure\\.com/.*`);
24
24
  return INSTRUMENTATION_KEY_REGEX.test(key) || CONNECTION_STRING_REGEX.test(key);
25
25
  };
26
- const initializeAppInsights = async (appInsightsKey, disableCookiesUsage) => {
26
+ const initializeAppInsights = async appInsightsKey => {
27
27
  if (!window.appInsights && appInsightsKey) {
28
28
  if (!isValidKey(appInsightsKey)) {
29
29
  TelemetryHelper.logActionEvent(LogLevel.ERROR, {
@@ -45,8 +45,7 @@ export const appInsightsLogger = (appInsightsKey, disableCookiesUsage) => {
45
45
  connectionString: appInsightsKey
46
46
  } : {
47
47
  instrumentationKey: appInsightsKey
48
- }),
49
- disableCookiesUsage: disableCookiesUsage
48
+ })
50
49
  };
51
50
 
52
51
  // Initialize Application Insights instance
@@ -73,7 +72,7 @@ export const appInsightsLogger = (appInsightsKey, disableCookiesUsage) => {
73
72
  };
74
73
  const logger = async () => {
75
74
  if (!initializationPromise) {
76
- initializationPromise = initializeAppInsights(appInsightsKey, disableCookiesUsage);
75
+ initializationPromise = initializeAppInsights(appInsightsKey);
77
76
  }
78
77
  await initializationPromise;
79
78
  return window.appInsights;
@@ -0,0 +1,72 @@
1
+ import DOMPurify from "dompurify";
2
+
3
+ /**
4
+ * Detects potential Cross-Site Scripting (XSS) attacks in text input and sanitizes the content.
5
+ *
6
+ * This function performs comprehensive XSS detection using pattern matching for common attack vectors
7
+ * and then sanitizes the input using DOMPurify with strict configuration. It's designed to protect
8
+ * against various XSS techniques including script injection, event handler injection, style-based
9
+ * attacks, and encoded payloads.
10
+ *
11
+ * Security patterns detected:
12
+ * - JavaScript protocol URLs (javascript:)
13
+ * - HTML event handlers (onmouseover, onclick, etc.)
14
+ * - Script tags (<script>)
15
+ * - CSS expression() functions
16
+ * - CSS url() functions
17
+ * - Position-based CSS attacks (position: fixed/absolute)
18
+ * - VBScript protocol URLs
19
+ * - Data URLs with HTML content
20
+ * - Fragment identifiers with escaped quotes
21
+ * - HTML entity-encoded angle brackets
22
+ *
23
+ * @param text - The input text to be analyzed and sanitized
24
+ * @returns An object containing:
25
+ * - cleanText: The sanitized version of the input text with all HTML tags and attributes removed
26
+ * - isXSSDetected: Boolean flag indicating whether potential XSS patterns were found in the original text
27
+ */
28
+ export const detectAndCleanXSS = text => {
29
+ // Comprehensive array of regular expressions to detect common XSS attack patterns
30
+ const xssPatterns = [/javascript\s*:/gi,
31
+ // JavaScript protocol URLs (with optional spaces)
32
+ /vbscript\s*:/gi,
33
+ // VBScript protocol URLs (with optional spaces)
34
+ /on\w+\s*=/gi,
35
+ // HTML event handlers (onmouseover, onclick, onload, etc.)
36
+ /<\s*script/gi,
37
+ // Script tag opening (with optional spaces)
38
+ /expression\s*\(/gi,
39
+ // CSS expression() function (IE-specific)
40
+ /url\s*\(/gi,
41
+ // CSS url() function
42
+ /style\s*=.*position\s*:\s*fixed/gi,
43
+ // CSS position fixed attacks
44
+ /style\s*=.*position\s*:\s*absolute/gi,
45
+ // CSS position absolute attacks
46
+ /data\s*:\s*text\s*\/\s*html/gi,
47
+ // Data URLs containing HTML
48
+ /#.*\\"/gi,
49
+ // Fragment identifiers with escaped quotes
50
+ /&gt;.*&lt;/gi // HTML entity-encoded angle brackets indicating tag structure
51
+ ];
52
+
53
+ // Check if any XSS patterns are detected in the input text
54
+ const isXSSDetected = xssPatterns.some(pattern => pattern.test(text));
55
+
56
+ // Clean the text using DOMPurify with strict config
57
+ const cleanText = DOMPurify.sanitize(text, {
58
+ ALLOWED_TAGS: [],
59
+ // No HTML tags allowed in title
60
+ ALLOWED_ATTR: [],
61
+ KEEP_CONTENT: true,
62
+ // Keep text content
63
+ ALLOW_DATA_ATTR: false,
64
+ ALLOW_UNKNOWN_PROTOCOLS: false,
65
+ SANITIZE_DOM: true,
66
+ FORCE_BODY: false
67
+ });
68
+ return {
69
+ cleanText,
70
+ isXSSDetected
71
+ };
72
+ };
@@ -385,6 +385,9 @@ export const getConversationDetailsCall = async function (facadeChatSDK) {
385
385
 
386
386
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
387
387
  export const checkContactIdError = e => {
388
+ TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
389
+ Event: TelemetryEvent.CheckContactIdError
390
+ });
388
391
  if ((e === null || e === void 0 ? void 0 : e.message) === ChatSDKErrorName.AuthContactIdNotFoundFailure) {
389
392
  const contactIdNotFoundErrorEvent = {
390
393
  eventName: BroadcastEvent.ContactIdNotFound,
@@ -75,9 +75,13 @@ export const ConfirmationPaneStateful = props => {
75
75
  useEffect(() => {
76
76
  preventFocusToMoveOutOfElement(controlProps.id);
77
77
  const focusableElements = findAllFocusableElement(`#${controlProps.id}`);
78
- if (focusableElements) {
79
- focusableElements[0].focus();
80
- }
78
+ requestAnimationFrame(() => {
79
+ if (focusableElements && focusableElements.length > 0 && focusableElements[0]) {
80
+ focusableElements[0].focus({
81
+ preventScroll: true
82
+ });
83
+ }
84
+ });
81
85
  elements = findParentFocusableElementsWithoutChildContainer(controlProps.id);
82
86
  setTabIndices(elements, initialTabIndexMap, false);
83
87
  TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
@@ -0,0 +1,59 @@
1
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
7
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
8
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
+ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
10
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
13
+ import React, { Component } from 'react';
14
+ const RenderChildrenFunction = _ref => {
15
+ let {
16
+ children
17
+ } = _ref;
18
+ return typeof children === 'function' ? children() : children;
19
+ };
20
+ let ErrorBoundary = /*#__PURE__*/function (_Component) {
21
+ _inherits(ErrorBoundary, _Component);
22
+ var _super = _createSuper(ErrorBoundary);
23
+ function ErrorBoundary(props) {
24
+ var _this;
25
+ _classCallCheck(this, ErrorBoundary);
26
+ _this = _super.call(this, props);
27
+ _this.state = {
28
+ hasError: false
29
+ };
30
+ return _this;
31
+ }
32
+ _createClass(ErrorBoundary, [{
33
+ key: "componentDidCatch",
34
+ value: function componentDidCatch(error) {
35
+ const {
36
+ onError
37
+ } = this.props;
38
+ this.setState({
39
+ hasError: true
40
+ });
41
+ if (onError) {
42
+ onError(error);
43
+ }
44
+ }
45
+ }, {
46
+ key: "render",
47
+ value: function render() {
48
+ const {
49
+ children
50
+ } = this.props;
51
+ const {
52
+ hasError
53
+ } = this.state;
54
+ return !hasError && /*#__PURE__*/React.createElement(RenderChildrenFunction, null, children);
55
+ }
56
+ }]);
57
+ return ErrorBoundary;
58
+ }(Component);
59
+ export default ErrorBoundary;
@@ -1,7 +1,8 @@
1
- import React, { useReducer, useState } from "react";
1
+ import React, { useEffect, useReducer, useState } from "react";
2
2
  import { ChatAdapterStore } from "../../contexts/ChatAdapterStore";
3
3
  import { ChatContextStore } from "../../contexts/ChatContextStore";
4
4
  import { ChatSDKStore } from "../../contexts/ChatSDKStore";
5
+ import ErrorBoundary from "../errorboundary/ErrorBoundary";
5
6
  import { FacadeChatSDK } from "../../common/facades/FacadeChatSDK";
6
7
  import { FacadeChatSDKStore } from "../../contexts/FacadeChatSDKStore";
7
8
  import LiveChatWidgetStateful from "./livechatwidgetstateful/LiveChatWidgetStateful";
@@ -10,6 +11,8 @@ import { getLiveChatWidgetContextInitialState } from "../../contexts/common/Live
10
11
  import { getMockChatSDKIfApplicable } from "./common/getMockChatSDKIfApplicable";
11
12
  import { isNullOrUndefined } from "../../common/utils";
12
13
  import overridePropsOnMockIfApplicable from "./common/overridePropsOnMockIfApplicable";
14
+ import { registerTelemetryLoggers } from "./common/registerTelemetryLoggers";
15
+ import { logWidgetLoadWithUnexpectedError } from "./common/startChatErrorHandler";
13
16
  export const LiveChatWidget = props => {
14
17
  var _props$mock, _props$featureConfigP, _props$chatConfig, _props$chatConfig$Liv;
15
18
  const reducer = createReducer();
@@ -37,7 +40,14 @@ export const LiveChatWidget = props => {
37
40
  "isSDKMocked": !isNullOrUndefined(props === null || props === void 0 ? void 0 : (_props$mock2 = props.mock) === null || _props$mock2 === void 0 ? void 0 : _props$mock2.type)
38
41
  }, disableReauthentication));
39
42
  }
40
- return /*#__PURE__*/React.createElement(FacadeChatSDKStore.Provider, {
43
+ useEffect(() => {
44
+ registerTelemetryLoggers(props, dispatch);
45
+ }, [dispatch]);
46
+ return /*#__PURE__*/React.createElement(ErrorBoundary, {
47
+ onError: error => {
48
+ logWidgetLoadWithUnexpectedError(error);
49
+ }
50
+ }, /*#__PURE__*/React.createElement(FacadeChatSDKStore.Provider, {
41
51
  value: [facadeChatSDK, setFacadeChatSDK]
42
52
  }, /*#__PURE__*/React.createElement(ChatSDKStore.Provider, {
43
53
  value: chatSDK
@@ -45,6 +55,6 @@ export const LiveChatWidget = props => {
45
55
  value: [adapter, setAdapter]
46
56
  }, /*#__PURE__*/React.createElement(ChatContextStore.Provider, {
47
57
  value: [state, dispatch]
48
- }, /*#__PURE__*/React.createElement(LiveChatWidgetStateful, props)))));
58
+ }, /*#__PURE__*/React.createElement(LiveChatWidgetStateful, props))))));
49
59
  };
50
60
  export default LiveChatWidget;
@@ -67,6 +67,10 @@ const getChatReconnectContext = async (facadeChatSDK, chatConfig, props, isAuthe
67
67
  // AuthToken will be reset later at start chat
68
68
  removeAuthTokenProvider(facadeChatSDK.getChatSDK());
69
69
  }
70
+ TelemetryHelper.logSDKEvent(LogLevel.INFO, {
71
+ Event: TelemetryEvent.GetChatReconnectContextSDKCallSucceeded,
72
+ Description: "Reconnect context SDK call succeeded"
73
+ });
70
74
  return reconnectChatContext;
71
75
  }
72
76
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -307,13 +307,7 @@ const canConnectToExistingChat = async (props, facadeChatSDK, state, dispatch, s
307
307
 
308
308
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
309
309
  const setCustomContextParams = async (state, props) => {
310
- var _props$chatConfig, _props$chatConfig$Liv, _state$domainStates8, _persistedState$domai8;
311
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
312
- const isAuthenticatedChat = props !== null && props !== void 0 && (_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 ? true : false;
313
- //Should not set custom context for auth chat
314
- if (isAuthenticatedChat) {
315
- return;
316
- }
310
+ var _state$domainStates8, _persistedState$domai8;
317
311
  if (state !== null && state !== void 0 && (_state$domainStates8 = state.domainStates) !== null && _state$domainStates8 !== void 0 && _state$domainStates8.customContext) {
318
312
  var _state$domainStates9;
319
313
  optionalParams = Object.assign({}, optionalParams, {
@@ -141,6 +141,34 @@ const logWidgetLoadCompleteWithError = ex => {
141
141
  ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed
142
142
  });
143
143
  };
144
+ export const logWidgetLoadWithUnexpectedError = ex => {
145
+ var _TelemetryTimers$Widg4;
146
+ // eslint-disable-line @typescript-eslint/no-explicit-any
147
+ const details = {
148
+ message: (ex === null || ex === void 0 ? void 0 : ex.message) || "An unexpected error occurred",
149
+ stack: (ex === null || ex === void 0 ? void 0 : ex.stack) || "No stack trace available"
150
+ };
151
+ let additionalDetails = "";
152
+ try {
153
+ additionalDetails = JSON.stringify(details);
154
+ } catch (error) {
155
+ additionalDetails = "Failed to stringify error details";
156
+ }
157
+
158
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
159
+ const exDetails = {
160
+ Exception: `Widget load with unexpected error: ${additionalDetails}`
161
+ };
162
+ if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
163
+ exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
164
+ }
165
+ TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.ERROR, {
166
+ Event: TelemetryEvent.WidgetLoadFailed,
167
+ Description: "Widget load with unexpected error",
168
+ ExceptionDetails: exDetails,
169
+ ElapsedTimeInMilliseconds: TelemetryTimers === null || TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg4 = TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg4 === void 0 ? void 0 : _TelemetryTimers$Widg4.milliSecondsElapsed
170
+ });
171
+ };
144
172
 
145
173
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
146
174
  const forceEndChat = facadeChatSDK => {
@@ -48,7 +48,6 @@ import { initCallingSdk } from "../common/initCallingSdk";
48
48
  import { initConfirmationPropsComposer } from "../common/initConfirmationPropsComposer";
49
49
  import { initWebChatComposer } from "../common/initWebChatComposer";
50
50
  import { registerBroadcastServiceForStorage } from "../../../common/storage/default/defaultCacheManager";
51
- import { registerTelemetryLoggers } from "../common/registerTelemetryLoggers";
52
51
  import { setPostChatContextAndLoadSurvey } from "../common/setPostChatContextAndLoadSurvey";
53
52
  import { startProactiveChat } from "../common/startProactiveChat";
54
53
  import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
@@ -56,7 +55,7 @@ import useChatContextStore from "../../../hooks/useChatContextStore";
56
55
  import useFacadeSDKStore from "../../../hooks/useFacadeChatSDKStore";
57
56
  let uiTimer;
58
57
  export const LiveChatWidgetStateful = props => {
59
- var _props$webChatContain, _props$styleProps, _props$webChatContain2, _props$webChatContain3, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain7, _state$appStates14, _props$webChatContain9, _props$webChatContain10, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _livechatProps$webCha, _props$webChatContain11, _props$webChatContain12, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _props$webChatContain17, _props$webChatContain18, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
58
+ var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _props$webChatContain5, _props$webChatContain6, _props$webChatContain7, _props$webChatContain8, _props$webChatContain9, _props$styleProps, _props$webChatContain10, _props$webChatContain11, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain15, _state$appStates14, _props$webChatContain17, _props$webChatContain18, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _livechatProps$webCha, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
60
59
  useEffect(() => {
61
60
  uiTimer = createTimer();
62
61
  TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.INFO, {
@@ -75,10 +74,13 @@ export const LiveChatWidgetStateful = props => {
75
74
  const [facadeChatSDK] = useFacadeSDKStore();
76
75
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
76
  const [voiceVideoCallingSDK, setVoiceVideoCallingSDK] = useState(undefined);
77
+ const [conversationId, setConversationId] = useState("");
78
78
  const {
79
79
  Composer
80
80
  } = Components;
81
81
  const canStartProactiveChat = useRef(true);
82
+ const bubbleBackground = ((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : (_props$webChatContain3 = _props$webChatContain2.webChatStyles) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.bubbleBackground) ?? ((_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : (_props$webChatContain5 = _props$webChatContain4.adaptiveCardStyles) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.background) ?? defaultAdaptiveCardStyles.background;
83
+ const bubbleTextColor = ((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : (_props$webChatContain7 = _props$webChatContain6.webChatStyles) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.bubbleTextColor) ?? ((_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : (_props$webChatContain9 = _props$webChatContain8.adaptiveCardStyles) === null || _props$webChatContain9 === void 0 ? void 0 : _props$webChatContain9.color) ?? defaultAdaptiveCardStyles.color;
82
84
 
83
85
  // Process general styles
84
86
  const generalStyles = {
@@ -87,7 +89,7 @@ export const LiveChatWidgetStateful = props => {
87
89
 
88
90
  //Scrollbar styles
89
91
  const scrollbarProps = Object.assign({}, defaultScrollBarProps, props === null || props === void 0 ? void 0 : props.scrollBarProps);
90
- const sendBoxTextArea = props === null || props === void 0 ? void 0 : (_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : (_props$webChatContain3 = _props$webChatContain2.sendBoxTextBox) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.textarea;
92
+ const sendBoxTextArea = props === null || props === void 0 ? void 0 : (_props$webChatContain10 = props.webChatContainerProps) === null || _props$webChatContain10 === void 0 ? void 0 : (_props$webChatContain11 = _props$webChatContain10.sendBoxTextBox) === null || _props$webChatContain11 === void 0 ? void 0 : _props$webChatContain11.textarea;
91
93
 
92
94
  // In case the broadcast channel is already initialized elsewhere; One tab can only hold 1 instance
93
95
  if ((props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.skipBroadcastChannelInit) !== true) {
@@ -220,7 +222,6 @@ export const LiveChatWidgetStateful = props => {
220
222
  state.domainStates.confirmationPaneConfirmedOptionClicked = false;
221
223
  state.domainStates.confirmationState = ConfirmationState.NotSet;
222
224
  setupClientDataStore();
223
- registerTelemetryLoggers(props, dispatch);
224
225
  createInternetConnectionChangeHandler(state);
225
226
  dispatch({
226
227
  type: LiveChatWidgetActionType.SET_WIDGET_ELEMENT_ID,
@@ -570,6 +571,14 @@ export const LiveChatWidgetStateful = props => {
570
571
  });
571
572
  });
572
573
 
574
+ // Retrieve convId
575
+ BroadcastService.getMessageByEventName(BroadcastEvent.UpdateConversationDataForTelemetry).subscribe(msg => {
576
+ var _msg$payload11, _msg$payload11$liveWo;
577
+ if ((_msg$payload11 = msg.payload) !== null && _msg$payload11 !== void 0 && (_msg$payload11$liveWo = _msg$payload11.liveWorkItem) !== null && _msg$payload11$liveWo !== void 0 && _msg$payload11$liveWo.conversationId) {
578
+ setConversationId(msg.payload.liveWorkItem.conversationId);
579
+ }
580
+ });
581
+
573
582
  // Check for TPC and log in telemetry if blocked
574
583
  isCookieAllowed();
575
584
  return () => {
@@ -616,8 +625,8 @@ export const LiveChatWidgetStateful = props => {
616
625
  });
617
626
  }
618
627
  if (state.appStates.conversationState === ConversationState.InActive) {
619
- var _props$webChatContain4, _props$webChatContain5;
620
- if ((props === null || props === void 0 ? void 0 : (_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : (_props$webChatContain5 = _props$webChatContain4.renderingMiddlewareProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.hideSendboxOnConversationEnd) !== false) {
628
+ var _props$webChatContain12, _props$webChatContain13;
629
+ if ((props === null || props === void 0 ? void 0 : (_props$webChatContain12 = props.webChatContainerProps) === null || _props$webChatContain12 === void 0 ? void 0 : (_props$webChatContain13 = _props$webChatContain12.renderingMiddlewareProps) === null || _props$webChatContain13 === void 0 ? void 0 : _props$webChatContain13.hideSendboxOnConversationEnd) !== false) {
621
630
  setWebChatStyles(styles => {
622
631
  return {
623
632
  ...styles,
@@ -661,12 +670,12 @@ export const LiveChatWidgetStateful = props => {
661
670
  }
662
671
  }, [state.appStates.unreadMessageCount]);
663
672
  useEffect(() => {
664
- var _props$webChatContain6;
673
+ var _props$webChatContain14;
665
674
  setWebChatStyles({
666
675
  ...webChatStyles,
667
- ...((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.webChatStyles)
676
+ ...((_props$webChatContain14 = props.webChatContainerProps) === null || _props$webChatContain14 === void 0 ? void 0 : _props$webChatContain14.webChatStyles)
668
677
  });
669
- }, [(_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.webChatStyles]);
678
+ }, [(_props$webChatContain15 = props.webChatContainerProps) === null || _props$webChatContain15 === void 0 ? void 0 : _props$webChatContain15.webChatStyles]);
670
679
  useEffect(() => {
671
680
  //Confirmation pane dismissing through OK option, so proceed with end chat
672
681
  if (state.domainStates.confirmationState === ConfirmationState.Ok) {
@@ -765,12 +774,12 @@ export const LiveChatWidgetStateful = props => {
765
774
 
766
775
  // if props state gets updates we need to update the renderingMiddlewareProps in the state
767
776
  useEffect(() => {
768
- var _props$webChatContain8;
777
+ var _props$webChatContain16;
769
778
  dispatch({
770
779
  type: LiveChatWidgetActionType.SET_RENDERING_MIDDLEWARE_PROPS,
771
- payload: (_props$webChatContain8 = props.webChatContainerProps) === null || _props$webChatContain8 === void 0 ? void 0 : _props$webChatContain8.renderingMiddlewareProps
780
+ payload: (_props$webChatContain16 = props.webChatContainerProps) === null || _props$webChatContain16 === void 0 ? void 0 : _props$webChatContain16.renderingMiddlewareProps
772
781
  });
773
- }, [(_props$webChatContain9 = props.webChatContainerProps) === null || _props$webChatContain9 === void 0 ? void 0 : _props$webChatContain9.renderingMiddlewareProps]);
782
+ }, [(_props$webChatContain17 = props.webChatContainerProps) === null || _props$webChatContain17 === void 0 ? void 0 : _props$webChatContain17.renderingMiddlewareProps]);
774
783
  useEffect(() => {
775
784
  TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.INFO, {
776
785
  Event: TelemetryEvent.UXLiveChatWidgetCompleted,
@@ -813,7 +822,7 @@ export const LiveChatWidgetStateful = props => {
813
822
  const webChatProps = initWebChatComposer(props, state, dispatch, facadeChatSDK, endChatRelay);
814
823
  const downloadTranscriptProps = createDownloadTranscriptProps(props.downloadTranscriptProps, {
815
824
  ...(defaultWebChatContainerStatefulProps === null || defaultWebChatContainerStatefulProps === void 0 ? void 0 : defaultWebChatContainerStatefulProps.webChatStyles),
816
- ...((_props$webChatContain10 = props.webChatContainerProps) === null || _props$webChatContain10 === void 0 ? void 0 : _props$webChatContain10.webChatStyles)
825
+ ...((_props$webChatContain18 = props.webChatContainerProps) === null || _props$webChatContain18 === void 0 ? void 0 : _props$webChatContain18.webChatStyles)
817
826
  }, props.webChatContainerProps);
818
827
  const livechatProps = {
819
828
  ...props,
@@ -839,6 +848,11 @@ export const LiveChatWidgetStateful = props => {
839
848
  setOcUserAgent(facadeChatSDK.getChatSDK());
840
849
  const directLine = ((_livechatProps$webCha = livechatProps.webChatContainerProps) === null || _livechatProps$webCha === void 0 ? void 0 : _livechatProps$webCha.directLine) ?? adapter ?? defaultWebChatContainerStatefulProps.directLine;
841
850
  const userID = directLine.getState ? directLine === null || directLine === void 0 ? void 0 : directLine.getState("acs.userId") : "teamsvisitor";
851
+ const styleOptions = React.useMemo(() => ({
852
+ ...webChatStyles,
853
+ bubbleBackground,
854
+ bubbleTextColor
855
+ }), [webChatStyles, bubbleBackground, bubbleTextColor]);
842
856
 
843
857
  // WebChat's Composer can only be rendered if a directLine object is defined
844
858
  return directLine && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("style", null, `
@@ -877,11 +891,7 @@ export const LiveChatWidgetStateful = props => {
877
891
  }`}
878
892
  `), /*#__PURE__*/React.createElement(DraggableChatWidget, chatWidgetDraggableConfig, /*#__PURE__*/React.createElement(Composer, _extends({}, webChatProps, {
879
893
  userID: userID,
880
- styleOptions: {
881
- ...webChatStyles,
882
- bubbleBackground: ((_props$webChatContain11 = props.webChatContainerProps) === null || _props$webChatContain11 === void 0 ? void 0 : (_props$webChatContain12 = _props$webChatContain11.webChatStyles) === null || _props$webChatContain12 === void 0 ? void 0 : _props$webChatContain12.bubbleBackground) ?? ((_props$webChatContain13 = props.webChatContainerProps) === null || _props$webChatContain13 === void 0 ? void 0 : (_props$webChatContain14 = _props$webChatContain13.adaptiveCardStyles) === null || _props$webChatContain14 === void 0 ? void 0 : _props$webChatContain14.background) ?? defaultAdaptiveCardStyles.background,
883
- bubbleTextColor: ((_props$webChatContain15 = props.webChatContainerProps) === null || _props$webChatContain15 === void 0 ? void 0 : (_props$webChatContain16 = _props$webChatContain15.webChatStyles) === null || _props$webChatContain16 === void 0 ? void 0 : _props$webChatContain16.bubbleTextColor) ?? ((_props$webChatContain17 = props.webChatContainerProps) === null || _props$webChatContain17 === void 0 ? void 0 : (_props$webChatContain18 = _props$webChatContain17.adaptiveCardStyles) === null || _props$webChatContain18 === void 0 ? void 0 : _props$webChatContain18.color) ?? defaultAdaptiveCardStyles.color
884
- },
894
+ styleOptions: styleOptions,
885
895
  directLine: directLine
886
896
  }), /*#__PURE__*/React.createElement(Stack, {
887
897
  id: widgetElementId,
@@ -912,6 +922,8 @@ export const LiveChatWidgetStateful = props => {
912
922
  }, livechatProps.callingContainerProps)), !((_livechatProps$contro11 = livechatProps.controlProps) !== null && _livechatProps$contro11 !== void 0 && _livechatProps$contro11.hideWebChatContainer) && shouldShowWebChatContainer(state) && (decodeComponentString((_livechatProps$compon9 = livechatProps.componentOverrides) === null || _livechatProps$compon9 === void 0 ? void 0 : _livechatProps$compon9.webChatContainer) || /*#__PURE__*/React.createElement(WebChatContainerStateful, livechatProps)), !((_livechatProps$contro12 = livechatProps.controlProps) !== null && _livechatProps$contro12 !== void 0 && _livechatProps$contro12.hideConfirmationPane) && shouldShowConfirmationPane(state) && (decodeComponentString((_livechatProps$compon10 = livechatProps.componentOverrides) === null || _livechatProps$compon10 === void 0 ? void 0 : _livechatProps$compon10.confirmationPane) || /*#__PURE__*/React.createElement(ConfirmationPaneStateful, _extends({}, confirmationPaneProps, {
913
923
  setPostChatContext: setPostChatContextRelay,
914
924
  prepareEndChat: prepareEndChatRelay
915
- }))), !((_livechatProps$contro13 = livechatProps.controlProps) !== null && _livechatProps$contro13 !== void 0 && _livechatProps$contro13.hidePostChatLoadingPane) && shouldShowPostChatLoadingPane(state) && (decodeComponentString((_livechatProps$compon11 = livechatProps.componentOverrides) === null || _livechatProps$compon11 === void 0 ? void 0 : _livechatProps$compon11.postChatLoadingPane) || /*#__PURE__*/React.createElement(PostChatLoadingPaneStateful, livechatProps.postChatLoadingPaneProps)), shouldShowPostChatSurveyPane(state) && (decodeComponentString((_livechatProps$compon12 = livechatProps.componentOverrides) === null || _livechatProps$compon12 === void 0 ? void 0 : _livechatProps$compon12.postChatSurveyPane) || /*#__PURE__*/React.createElement(PostChatSurveyPaneStateful, _extends({}, livechatProps.postChatSurveyPaneProps, livechatProps.chatSDK))), createFooter(livechatProps, state), shouldShowEmailTranscriptPane(state) && (decodeComponentString((_livechatProps$compon13 = livechatProps.componentOverrides) === null || _livechatProps$compon13 === void 0 ? void 0 : _livechatProps$compon13.emailTranscriptPane) || /*#__PURE__*/React.createElement(EmailTranscriptPaneStateful, livechatProps.emailTranscriptPane))))));
925
+ }))), !((_livechatProps$contro13 = livechatProps.controlProps) !== null && _livechatProps$contro13 !== void 0 && _livechatProps$contro13.hidePostChatLoadingPane) && shouldShowPostChatLoadingPane(state) && (decodeComponentString((_livechatProps$compon11 = livechatProps.componentOverrides) === null || _livechatProps$compon11 === void 0 ? void 0 : _livechatProps$compon11.postChatLoadingPane) || /*#__PURE__*/React.createElement(PostChatLoadingPaneStateful, livechatProps.postChatLoadingPaneProps)), shouldShowPostChatSurveyPane(state) && (decodeComponentString((_livechatProps$compon12 = livechatProps.componentOverrides) === null || _livechatProps$compon12 === void 0 ? void 0 : _livechatProps$compon12.postChatSurveyPane) || /*#__PURE__*/React.createElement(PostChatSurveyPaneStateful, _extends({}, livechatProps.postChatSurveyPaneProps, livechatProps.chatSDK, {
926
+ customerVoiceSurveyCorrelationId: conversationId
927
+ }))), createFooter(livechatProps, state), shouldShowEmailTranscriptPane(state) && (decodeComponentString((_livechatProps$compon13 = livechatProps.componentOverrides) === null || _livechatProps$compon13 === void 0 ? void 0 : _livechatProps$compon13.emailTranscriptPane) || /*#__PURE__*/React.createElement(EmailTranscriptPaneStateful, livechatProps.emailTranscriptPane))))));
916
928
  };
917
929
  export default LiveChatWidgetStateful;
@@ -1,12 +1,13 @@
1
1
  import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
2
  import React, { useEffect } from "react";
3
3
  import { createTimer, findAllFocusableElement } from "../../common/utils";
4
- import DOMPurify from "dompurify";
5
4
  import { OutOfOfficeHoursPane } from "@microsoft/omnichannel-chat-components";
6
5
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
7
6
  import { defaultGeneralStyleProps } from "./common/defaultStyleProps/defaultgeneralOOOHPaneStyleProps";
7
+ import { detectAndCleanXSS } from "../../common/utils/xssUtils";
8
8
  import useChatContextStore from "../../hooks/useChatContextStore";
9
9
  let uiTimer;
10
+ const OOOHPaneTitleText = "Thanks for contacting us. You have reached us outside of our operating hours. An agent will respond when we open.";
10
11
  export const OutOfOfficeHoursPaneStateful = props => {
11
12
  var _props$styleProps;
12
13
  useEffect(() => {
@@ -45,8 +46,28 @@ export const OutOfOfficeHoursPaneStateful = props => {
45
46
  ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
46
47
  });
47
48
  }, []);
49
+
50
+ // Enhanced titleText sanitization
48
51
  if (controlProps !== null && controlProps !== void 0 && controlProps.titleText) {
49
- controlProps.titleText = DOMPurify.sanitize(controlProps.titleText);
52
+ const {
53
+ cleanText,
54
+ isXSSDetected
55
+ } = detectAndCleanXSS(controlProps.titleText);
56
+ if (!isXSSDetected) {
57
+ // replace with the sanitized text
58
+ controlProps.titleText = cleanText;
59
+ } else {
60
+ TelemetryHelper.logLoadingEventToAllTelemetry(LogLevel.WARN, {
61
+ Event: TelemetryEvent.XSSTextDetected,
62
+ Description: "Potential XSS attempt detected in titleText",
63
+ CustomProperties: {
64
+ originalText: controlProps.titleText.substring(0, 100),
65
+ // Log first 100 chars for analysis
66
+ cleanedText: cleanText.substring(0, 100)
67
+ }
68
+ });
69
+ controlProps.titleText = OOOHPaneTitleText;
70
+ }
50
71
  }
51
72
  return /*#__PURE__*/React.createElement(OutOfOfficeHoursPane, {
52
73
  componentOverrides: props.componentOverrides,