@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.
- package/lib/cjs/common/telemetry/TelemetryConstants.js +4 -0
- package/lib/cjs/common/telemetry/TelemetryManager.js +4 -4
- package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +4 -5
- package/lib/cjs/common/utils/xssUtils.js +79 -0
- package/lib/cjs/common/utils.js +3 -0
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +7 -3
- package/lib/cjs/components/errorboundary/ErrorBoundary.js +68 -0
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +12 -2
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +4 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +1 -7
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +30 -1
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +31 -19
- package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +23 -2
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +14 -5
- package/lib/cjs/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +1 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +4 -0
- package/lib/esm/common/telemetry/TelemetryManager.js +4 -4
- package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +4 -5
- package/lib/esm/common/utils/xssUtils.js +72 -0
- package/lib/esm/common/utils.js +3 -0
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +7 -3
- package/lib/esm/components/errorboundary/ErrorBoundary.js +59 -0
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +13 -3
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +4 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +1 -7
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +28 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +31 -19
- package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +23 -2
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +14 -5
- package/lib/esm/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +1 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +4 -0
- package/lib/types/common/telemetry/loggers/appInsightsLogger.d.ts +1 -1
- package/lib/types/common/utils/xssUtils.d.ts +29 -0
- package/lib/types/components/errorboundary/ErrorBoundary.d.ts +14 -0
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +1 -0
- package/lib/types/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.d.ts +2 -1
- package/lib/types/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +1 -0
- package/package.json +2 -2
|
@@ -112,6 +112,8 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
112
112
|
TelemetryEvent["DisconnectEndChatSDKCallFailed"] = "DisconnectEndChatSDKCallFailed";
|
|
113
113
|
TelemetryEvent["GetChatReconnectContextSDKCallStarted"] = "GetChatReconnectContextSDKCallStarted";
|
|
114
114
|
TelemetryEvent["GetChatReconnectContextSDKCallFailed"] = "GetChatReconnectContextSDKCallFailed";
|
|
115
|
+
TelemetryEvent["CheckContactIdError"] = "checkContactIdError";
|
|
116
|
+
TelemetryEvent["GetChatReconnectContextSDKCallSucceeded"] = "GetChatReconnectContextSDKCallSucceeded";
|
|
115
117
|
TelemetryEvent["ParseAdaptiveCardFailed"] = "ParseAdaptiveCardFailed";
|
|
116
118
|
TelemetryEvent["ClientDataStoreProviderFailed"] = "ClientDataStoreProviderFailed";
|
|
117
119
|
TelemetryEvent["InMemoryDataStoreFailed"] = "InMemoryDataStoreFailed";
|
|
@@ -179,6 +181,7 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
179
181
|
TelemetryEvent["CustomerVoiceResponsePageLoaded"] = "CustomerVoiceResponsePageLoaded";
|
|
180
182
|
TelemetryEvent["CustomerVoiceFormResponseSubmitted"] = "CustomerVoiceFormResponseSubmitted";
|
|
181
183
|
TelemetryEvent["CustomerVoiceFormResponseError"] = "CustomerVoiceFormResponseError";
|
|
184
|
+
TelemetryEvent["CustomerVoiceFormsError"] = "CustomerVoiceFormsError";
|
|
182
185
|
TelemetryEvent["BotAuthActivityEmptySasUrl"] = "BotAuthActivityEmptySasUrl";
|
|
183
186
|
TelemetryEvent["SetBotAuthProviderFetchConfig"] = "SetBotAuthProviderFetchConfig";
|
|
184
187
|
TelemetryEvent["SetBotAuthProviderHideCard"] = "SetBotAuthProviderHideCard";
|
|
@@ -256,6 +259,7 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
256
259
|
TelemetryEvent["UXNotificationPaneCompleted"] = "UXNotificationPaneCompleted";
|
|
257
260
|
TelemetryEvent["UXOutOfOfficeHoursPaneStart"] = "UXOutOfOfficeHoursPaneStart";
|
|
258
261
|
TelemetryEvent["UXOutOfOfficeHoursPaneCompleted"] = "UXOutOfOfficeHoursPaneCompleted";
|
|
262
|
+
TelemetryEvent["XSSTextDetected"] = "XSSTextDetected";
|
|
259
263
|
TelemetryEvent["UXPostChatLoadingPaneStart"] = "UXPostChatLoadingPaneStart";
|
|
260
264
|
TelemetryEvent["UXPostChatLoadingPaneCompleted"] = "UXPostChatLoadingPaneCompleted";
|
|
261
265
|
TelemetryEvent["UXPrechatPaneStart"] = "UXPrechatPaneStart";
|
|
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.disposeLoggers = exports.TelemetryTimers = exports.TelemetryManager = exports.RegisterLoggers = void 0;
|
|
7
7
|
var _TelemetryConstants = require("./TelemetryConstants");
|
|
8
8
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
9
|
+
var _TelemetryHelper = require("./TelemetryHelper");
|
|
10
|
+
var _appInsightsLogger = require("./loggers/appInsightsLogger");
|
|
9
11
|
var _ariaTelemetryLogger = require("./loggers/ariaTelemetryLogger");
|
|
10
12
|
var _consoleLogger = require("./loggers/consoleLogger");
|
|
11
13
|
var _defaultAriaConfig = require("./defaultConfigs/defaultAriaConfig");
|
|
12
|
-
var _TelemetryHelper = require("./TelemetryHelper");
|
|
13
|
-
var _appInsightsLogger = require("./loggers/appInsightsLogger");
|
|
14
14
|
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); } }
|
|
15
15
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
16
16
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -64,8 +64,8 @@ const RegisterLoggers = () => {
|
|
|
64
64
|
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) {
|
|
65
65
|
var _TelemetryManager$Int24;
|
|
66
66
|
if ((_TelemetryManager$Int24 = TelemetryManager.InternalTelemetryData) !== null && _TelemetryManager$Int24 !== void 0 && _TelemetryManager$Int24.appInsightsConfig.appInsightsKey) {
|
|
67
|
-
var _TelemetryManager$Int25
|
|
68
|
-
loggers.push((0, _appInsightsLogger.appInsightsLogger)((_TelemetryManager$Int25 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int25 === void 0 ? void 0 : _TelemetryManager$Int25.appInsightsConfig.appInsightsKey
|
|
67
|
+
var _TelemetryManager$Int25;
|
|
68
|
+
loggers.push((0, _appInsightsLogger.appInsightsLogger)((_TelemetryManager$Int25 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int25 === void 0 ? void 0 : _TelemetryManager$Int25.appInsightsConfig.appInsightsKey));
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
}
|
|
@@ -25,14 +25,14 @@ var AllowedKeys;
|
|
|
25
25
|
AllowedKeys["ElapsedTimeInMilliseconds"] = "DurationInMilliseconds";
|
|
26
26
|
})(AllowedKeys || (AllowedKeys = {}));
|
|
27
27
|
let initializationPromise = null;
|
|
28
|
-
const appInsightsLogger =
|
|
28
|
+
const appInsightsLogger = appInsightsKey => {
|
|
29
29
|
const isValidKey = key => {
|
|
30
30
|
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}";
|
|
31
31
|
const INSTRUMENTATION_KEY_REGEX = new RegExp(`^${INSTRUMENTATION_KEY_PATTERN}$`);
|
|
32
32
|
const CONNECTION_STRING_REGEX = new RegExp(`^InstrumentationKey=${INSTRUMENTATION_KEY_PATTERN};IngestionEndpoint=https://[a-zA-Z0-9\\-\\.]+\\.applicationinsights\\.azure\\.com/.*`);
|
|
33
33
|
return INSTRUMENTATION_KEY_REGEX.test(key) || CONNECTION_STRING_REGEX.test(key);
|
|
34
34
|
};
|
|
35
|
-
const initializeAppInsights = async
|
|
35
|
+
const initializeAppInsights = async appInsightsKey => {
|
|
36
36
|
if (!window.appInsights && appInsightsKey) {
|
|
37
37
|
if (!isValidKey(appInsightsKey)) {
|
|
38
38
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
@@ -54,8 +54,7 @@ const appInsightsLogger = (appInsightsKey, disableCookiesUsage) => {
|
|
|
54
54
|
connectionString: appInsightsKey
|
|
55
55
|
} : {
|
|
56
56
|
instrumentationKey: appInsightsKey
|
|
57
|
-
})
|
|
58
|
-
disableCookiesUsage: disableCookiesUsage
|
|
57
|
+
})
|
|
59
58
|
};
|
|
60
59
|
|
|
61
60
|
// Initialize Application Insights instance
|
|
@@ -82,7 +81,7 @@ const appInsightsLogger = (appInsightsKey, disableCookiesUsage) => {
|
|
|
82
81
|
};
|
|
83
82
|
const logger = async () => {
|
|
84
83
|
if (!initializationPromise) {
|
|
85
|
-
initializationPromise = initializeAppInsights(appInsightsKey
|
|
84
|
+
initializationPromise = initializeAppInsights(appInsightsKey);
|
|
86
85
|
}
|
|
87
86
|
await initializationPromise;
|
|
88
87
|
return window.appInsights;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.detectAndCleanXSS = void 0;
|
|
7
|
+
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
/**
|
|
10
|
+
* Detects potential Cross-Site Scripting (XSS) attacks in text input and sanitizes the content.
|
|
11
|
+
*
|
|
12
|
+
* This function performs comprehensive XSS detection using pattern matching for common attack vectors
|
|
13
|
+
* and then sanitizes the input using DOMPurify with strict configuration. It's designed to protect
|
|
14
|
+
* against various XSS techniques including script injection, event handler injection, style-based
|
|
15
|
+
* attacks, and encoded payloads.
|
|
16
|
+
*
|
|
17
|
+
* Security patterns detected:
|
|
18
|
+
* - JavaScript protocol URLs (javascript:)
|
|
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
|
|
33
|
+
*/
|
|
34
|
+
const detectAndCleanXSS = text => {
|
|
35
|
+
// Comprehensive array of regular expressions to detect common XSS attack patterns
|
|
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
|
|
63
|
+
const cleanText = _dompurify.default.sanitize(text, {
|
|
64
|
+
ALLOWED_TAGS: [],
|
|
65
|
+
// No HTML tags allowed in title
|
|
66
|
+
ALLOWED_ATTR: [],
|
|
67
|
+
KEEP_CONTENT: true,
|
|
68
|
+
// Keep text content
|
|
69
|
+
ALLOW_DATA_ATTR: false,
|
|
70
|
+
ALLOW_UNKNOWN_PROTOCOLS: false,
|
|
71
|
+
SANITIZE_DOM: true,
|
|
72
|
+
FORCE_BODY: false
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
cleanText,
|
|
76
|
+
isXSSDetected
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
exports.detectAndCleanXSS = detectAndCleanXSS;
|
package/lib/cjs/common/utils.js
CHANGED
|
@@ -421,6 +421,9 @@ const getConversationDetailsCall = async function (facadeChatSDK) {
|
|
|
421
421
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
422
422
|
exports.getConversationDetailsCall = getConversationDetailsCall;
|
|
423
423
|
const checkContactIdError = e => {
|
|
424
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
425
|
+
Event: _TelemetryConstants.TelemetryEvent.CheckContactIdError
|
|
426
|
+
});
|
|
424
427
|
if ((e === null || e === void 0 ? void 0 : e.message) === _omnichannelChatSdk.ChatSDKErrorName.AuthContactIdNotFoundFailure) {
|
|
425
428
|
const contactIdNotFoundErrorEvent = {
|
|
426
429
|
eventName: _TelemetryConstants.BroadcastEvent.ContactIdNotFound,
|
|
@@ -84,9 +84,13 @@ const ConfirmationPaneStateful = props => {
|
|
|
84
84
|
(0, _react.useEffect)(() => {
|
|
85
85
|
(0, _utils.preventFocusToMoveOutOfElement)(controlProps.id);
|
|
86
86
|
const focusableElements = (0, _utils.findAllFocusableElement)(`#${controlProps.id}`);
|
|
87
|
-
|
|
88
|
-
focusableElements[0]
|
|
89
|
-
|
|
87
|
+
requestAnimationFrame(() => {
|
|
88
|
+
if (focusableElements && focusableElements.length > 0 && focusableElements[0]) {
|
|
89
|
+
focusableElements[0].focus({
|
|
90
|
+
preventScroll: true
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
});
|
|
90
94
|
elements = (0, _utils.findParentFocusableElementsWithoutChildContainer)(controlProps.id);
|
|
91
95
|
(0, _utils.setTabIndices)(elements, initialTabIndexMap, false);
|
|
92
96
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
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); }
|
|
9
|
+
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; }
|
|
10
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
+
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); } }
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
14
|
+
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); }
|
|
15
|
+
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); }
|
|
16
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
17
|
+
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); }; }
|
|
18
|
+
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); }
|
|
19
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
20
|
+
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; } }
|
|
21
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
+
const RenderChildrenFunction = _ref => {
|
|
23
|
+
let {
|
|
24
|
+
children
|
|
25
|
+
} = _ref;
|
|
26
|
+
return typeof children === 'function' ? children() : children;
|
|
27
|
+
};
|
|
28
|
+
let ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
29
|
+
_inherits(ErrorBoundary, _Component);
|
|
30
|
+
var _super = _createSuper(ErrorBoundary);
|
|
31
|
+
function ErrorBoundary(props) {
|
|
32
|
+
var _this;
|
|
33
|
+
_classCallCheck(this, ErrorBoundary);
|
|
34
|
+
_this = _super.call(this, props);
|
|
35
|
+
_this.state = {
|
|
36
|
+
hasError: false
|
|
37
|
+
};
|
|
38
|
+
return _this;
|
|
39
|
+
}
|
|
40
|
+
_createClass(ErrorBoundary, [{
|
|
41
|
+
key: "componentDidCatch",
|
|
42
|
+
value: function componentDidCatch(error) {
|
|
43
|
+
const {
|
|
44
|
+
onError
|
|
45
|
+
} = this.props;
|
|
46
|
+
this.setState({
|
|
47
|
+
hasError: true
|
|
48
|
+
});
|
|
49
|
+
if (onError) {
|
|
50
|
+
onError(error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}, {
|
|
54
|
+
key: "render",
|
|
55
|
+
value: function render() {
|
|
56
|
+
const {
|
|
57
|
+
children
|
|
58
|
+
} = this.props;
|
|
59
|
+
const {
|
|
60
|
+
hasError
|
|
61
|
+
} = this.state;
|
|
62
|
+
return !hasError && /*#__PURE__*/_react.default.createElement(RenderChildrenFunction, null, children);
|
|
63
|
+
}
|
|
64
|
+
}]);
|
|
65
|
+
return ErrorBoundary;
|
|
66
|
+
}(_react.Component);
|
|
67
|
+
var _default = ErrorBoundary;
|
|
68
|
+
exports.default = _default;
|
|
@@ -8,6 +8,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _ChatAdapterStore = require("../../contexts/ChatAdapterStore");
|
|
9
9
|
var _ChatContextStore = require("../../contexts/ChatContextStore");
|
|
10
10
|
var _ChatSDKStore = require("../../contexts/ChatSDKStore");
|
|
11
|
+
var _ErrorBoundary = _interopRequireDefault(require("../errorboundary/ErrorBoundary"));
|
|
11
12
|
var _FacadeChatSDK = require("../../common/facades/FacadeChatSDK");
|
|
12
13
|
var _FacadeChatSDKStore = require("../../contexts/FacadeChatSDKStore");
|
|
13
14
|
var _LiveChatWidgetStateful = _interopRequireDefault(require("./livechatwidgetstateful/LiveChatWidgetStateful"));
|
|
@@ -16,6 +17,8 @@ var _LiveChatWidgetContextInitialState = require("../../contexts/common/LiveChat
|
|
|
16
17
|
var _getMockChatSDKIfApplicable = require("./common/getMockChatSDKIfApplicable");
|
|
17
18
|
var _utils = require("../../common/utils");
|
|
18
19
|
var _overridePropsOnMockIfApplicable = _interopRequireDefault(require("./common/overridePropsOnMockIfApplicable"));
|
|
20
|
+
var _registerTelemetryLoggers = require("./common/registerTelemetryLoggers");
|
|
21
|
+
var _startChatErrorHandler = require("./common/startChatErrorHandler");
|
|
19
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
23
|
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); }
|
|
21
24
|
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; }
|
|
@@ -46,7 +49,14 @@ const LiveChatWidget = props => {
|
|
|
46
49
|
"isSDKMocked": !(0, _utils.isNullOrUndefined)(props === null || props === void 0 ? void 0 : (_props$mock2 = props.mock) === null || _props$mock2 === void 0 ? void 0 : _props$mock2.type)
|
|
47
50
|
}, disableReauthentication));
|
|
48
51
|
}
|
|
49
|
-
|
|
52
|
+
(0, _react.useEffect)(() => {
|
|
53
|
+
(0, _registerTelemetryLoggers.registerTelemetryLoggers)(props, dispatch);
|
|
54
|
+
}, [dispatch]);
|
|
55
|
+
return /*#__PURE__*/_react.default.createElement(_ErrorBoundary.default, {
|
|
56
|
+
onError: error => {
|
|
57
|
+
(0, _startChatErrorHandler.logWidgetLoadWithUnexpectedError)(error);
|
|
58
|
+
}
|
|
59
|
+
}, /*#__PURE__*/_react.default.createElement(_FacadeChatSDKStore.FacadeChatSDKStore.Provider, {
|
|
50
60
|
value: [facadeChatSDK, setFacadeChatSDK]
|
|
51
61
|
}, /*#__PURE__*/_react.default.createElement(_ChatSDKStore.ChatSDKStore.Provider, {
|
|
52
62
|
value: chatSDK
|
|
@@ -54,7 +64,7 @@ const LiveChatWidget = props => {
|
|
|
54
64
|
value: [adapter, setAdapter]
|
|
55
65
|
}, /*#__PURE__*/_react.default.createElement(_ChatContextStore.ChatContextStore.Provider, {
|
|
56
66
|
value: [state, dispatch]
|
|
57
|
-
}, /*#__PURE__*/_react.default.createElement(_LiveChatWidgetStateful.default, props)))));
|
|
67
|
+
}, /*#__PURE__*/_react.default.createElement(_LiveChatWidgetStateful.default, props))))));
|
|
58
68
|
};
|
|
59
69
|
exports.LiveChatWidget = LiveChatWidget;
|
|
60
70
|
var _default = LiveChatWidget;
|
|
@@ -73,6 +73,10 @@ const getChatReconnectContext = async (facadeChatSDK, chatConfig, props, isAuthe
|
|
|
73
73
|
// AuthToken will be reset later at start chat
|
|
74
74
|
(0, _authHelper.removeAuthTokenProvider)(facadeChatSDK.getChatSDK());
|
|
75
75
|
}
|
|
76
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
77
|
+
Event: _TelemetryConstants.TelemetryEvent.GetChatReconnectContextSDKCallSucceeded,
|
|
78
|
+
Description: "Reconnect context SDK call succeeded"
|
|
79
|
+
});
|
|
76
80
|
return reconnectChatContext;
|
|
77
81
|
}
|
|
78
82
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -315,13 +315,7 @@ const canConnectToExistingChat = async (props, facadeChatSDK, state, dispatch, s
|
|
|
315
315
|
|
|
316
316
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
317
317
|
const setCustomContextParams = async (state, props) => {
|
|
318
|
-
var
|
|
319
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
320
|
-
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;
|
|
321
|
-
//Should not set custom context for auth chat
|
|
322
|
-
if (isAuthenticatedChat) {
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
318
|
+
var _state$domainStates8, _persistedState$domai8;
|
|
325
319
|
if (state !== null && state !== void 0 && (_state$domainStates8 = state.domainStates) !== null && _state$domainStates8 !== void 0 && _state$domainStates8.customContext) {
|
|
326
320
|
var _state$domainStates9;
|
|
327
321
|
optionalParams = Object.assign({}, optionalParams, {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.logWidgetLoadComplete = exports.handleStartChatError = void 0;
|
|
6
|
+
exports.logWidgetLoadWithUnexpectedError = exports.logWidgetLoadComplete = exports.handleStartChatError = void 0;
|
|
7
7
|
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
8
8
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
9
9
|
var _Constants = require("../../../common/Constants");
|
|
@@ -148,8 +148,37 @@ const logWidgetLoadCompleteWithError = ex => {
|
|
|
148
148
|
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed
|
|
149
149
|
});
|
|
150
150
|
};
|
|
151
|
+
const logWidgetLoadWithUnexpectedError = ex => {
|
|
152
|
+
var _TelemetryTimers$Widg4;
|
|
153
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
154
|
+
const details = {
|
|
155
|
+
message: (ex === null || ex === void 0 ? void 0 : ex.message) || "An unexpected error occurred",
|
|
156
|
+
stack: (ex === null || ex === void 0 ? void 0 : ex.stack) || "No stack trace available"
|
|
157
|
+
};
|
|
158
|
+
let additionalDetails = "";
|
|
159
|
+
try {
|
|
160
|
+
additionalDetails = JSON.stringify(details);
|
|
161
|
+
} catch (error) {
|
|
162
|
+
additionalDetails = "Failed to stringify error details";
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
166
|
+
const exDetails = {
|
|
167
|
+
Exception: `Widget load with unexpected error: ${additionalDetails}`
|
|
168
|
+
};
|
|
169
|
+
if (ex !== null && ex !== void 0 && ex.httpResponseStatusCode) {
|
|
170
|
+
exDetails.HttpResponseStatusCode = ex.httpResponseStatusCode;
|
|
171
|
+
}
|
|
172
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
|
|
173
|
+
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
174
|
+
Description: "Widget load with unexpected error",
|
|
175
|
+
ExceptionDetails: exDetails,
|
|
176
|
+
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg4 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg4 === void 0 ? void 0 : _TelemetryTimers$Widg4.milliSecondsElapsed
|
|
177
|
+
});
|
|
178
|
+
};
|
|
151
179
|
|
|
152
180
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
181
|
+
exports.logWidgetLoadWithUnexpectedError = logWidgetLoadWithUnexpectedError;
|
|
153
182
|
const forceEndChat = facadeChatSDK => {
|
|
154
183
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
155
184
|
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
@@ -52,7 +52,6 @@ var _initCallingSdk = require("../common/initCallingSdk");
|
|
|
52
52
|
var _initConfirmationPropsComposer = require("../common/initConfirmationPropsComposer");
|
|
53
53
|
var _initWebChatComposer = require("../common/initWebChatComposer");
|
|
54
54
|
var _defaultCacheManager = require("../../../common/storage/default/defaultCacheManager");
|
|
55
|
-
var _registerTelemetryLoggers = require("../common/registerTelemetryLoggers");
|
|
56
55
|
var _setPostChatContextAndLoadSurvey = require("../common/setPostChatContextAndLoadSurvey");
|
|
57
56
|
var _startProactiveChat = require("../common/startProactiveChat");
|
|
58
57
|
var _useChatAdapterStore = _interopRequireDefault(require("../../../hooks/useChatAdapterStore"));
|
|
@@ -64,7 +63,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
64
63
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
65
64
|
let uiTimer;
|
|
66
65
|
const LiveChatWidgetStateful = props => {
|
|
67
|
-
var _props$webChatContain, _props$
|
|
66
|
+
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;
|
|
68
67
|
(0, _react2.useEffect)(() => {
|
|
69
68
|
uiTimer = (0, _utils.createTimer)();
|
|
70
69
|
_TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -83,10 +82,13 @@ const LiveChatWidgetStateful = props => {
|
|
|
83
82
|
const [facadeChatSDK] = (0, _useFacadeChatSDKStore.default)();
|
|
84
83
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
85
84
|
const [voiceVideoCallingSDK, setVoiceVideoCallingSDK] = (0, _react2.useState)(undefined);
|
|
85
|
+
const [conversationId, setConversationId] = (0, _react2.useState)("");
|
|
86
86
|
const {
|
|
87
87
|
Composer
|
|
88
88
|
} = _botframeworkWebchat.Components;
|
|
89
89
|
const canStartProactiveChat = (0, _react2.useRef)(true);
|
|
90
|
+
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.defaultAdaptiveCardStyles.background;
|
|
91
|
+
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.defaultAdaptiveCardStyles.color;
|
|
90
92
|
|
|
91
93
|
// Process general styles
|
|
92
94
|
const generalStyles = {
|
|
@@ -95,7 +97,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
95
97
|
|
|
96
98
|
//Scrollbar styles
|
|
97
99
|
const scrollbarProps = Object.assign({}, _defaultScrollBarProps.defaultScrollBarProps, props === null || props === void 0 ? void 0 : props.scrollBarProps);
|
|
98
|
-
const sendBoxTextArea = props === null || props === void 0 ? void 0 : (_props$
|
|
100
|
+
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;
|
|
99
101
|
|
|
100
102
|
// In case the broadcast channel is already initialized elsewhere; One tab can only hold 1 instance
|
|
101
103
|
if ((props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.skipBroadcastChannelInit) !== true) {
|
|
@@ -228,7 +230,6 @@ const LiveChatWidgetStateful = props => {
|
|
|
228
230
|
state.domainStates.confirmationPaneConfirmedOptionClicked = false;
|
|
229
231
|
state.domainStates.confirmationState = _Constants.ConfirmationState.NotSet;
|
|
230
232
|
setupClientDataStore();
|
|
231
|
-
(0, _registerTelemetryLoggers.registerTelemetryLoggers)(props, dispatch);
|
|
232
233
|
(0, _createInternetConnectionChangeHandler.createInternetConnectionChangeHandler)(state);
|
|
233
234
|
dispatch({
|
|
234
235
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_ELEMENT_ID,
|
|
@@ -578,6 +579,14 @@ const LiveChatWidgetStateful = props => {
|
|
|
578
579
|
});
|
|
579
580
|
});
|
|
580
581
|
|
|
582
|
+
// Retrieve convId
|
|
583
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.UpdateConversationDataForTelemetry).subscribe(msg => {
|
|
584
|
+
var _msg$payload11, _msg$payload11$liveWo;
|
|
585
|
+
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) {
|
|
586
|
+
setConversationId(msg.payload.liveWorkItem.conversationId);
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
|
|
581
590
|
// Check for TPC and log in telemetry if blocked
|
|
582
591
|
(0, _defaultClientDataStoreProvider.isCookieAllowed)();
|
|
583
592
|
return () => {
|
|
@@ -624,8 +633,8 @@ const LiveChatWidgetStateful = props => {
|
|
|
624
633
|
});
|
|
625
634
|
}
|
|
626
635
|
if (state.appStates.conversationState === _ConversationState.ConversationState.InActive) {
|
|
627
|
-
var _props$
|
|
628
|
-
if ((props === null || props === void 0 ? void 0 : (_props$
|
|
636
|
+
var _props$webChatContain12, _props$webChatContain13;
|
|
637
|
+
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) {
|
|
629
638
|
setWebChatStyles(styles => {
|
|
630
639
|
return {
|
|
631
640
|
...styles,
|
|
@@ -669,12 +678,12 @@ const LiveChatWidgetStateful = props => {
|
|
|
669
678
|
}
|
|
670
679
|
}, [state.appStates.unreadMessageCount]);
|
|
671
680
|
(0, _react2.useEffect)(() => {
|
|
672
|
-
var _props$
|
|
681
|
+
var _props$webChatContain14;
|
|
673
682
|
setWebChatStyles({
|
|
674
683
|
...webChatStyles,
|
|
675
|
-
...((_props$
|
|
684
|
+
...((_props$webChatContain14 = props.webChatContainerProps) === null || _props$webChatContain14 === void 0 ? void 0 : _props$webChatContain14.webChatStyles)
|
|
676
685
|
});
|
|
677
|
-
}, [(_props$
|
|
686
|
+
}, [(_props$webChatContain15 = props.webChatContainerProps) === null || _props$webChatContain15 === void 0 ? void 0 : _props$webChatContain15.webChatStyles]);
|
|
678
687
|
(0, _react2.useEffect)(() => {
|
|
679
688
|
//Confirmation pane dismissing through OK option, so proceed with end chat
|
|
680
689
|
if (state.domainStates.confirmationState === _Constants.ConfirmationState.Ok) {
|
|
@@ -773,12 +782,12 @@ const LiveChatWidgetStateful = props => {
|
|
|
773
782
|
|
|
774
783
|
// if props state gets updates we need to update the renderingMiddlewareProps in the state
|
|
775
784
|
(0, _react2.useEffect)(() => {
|
|
776
|
-
var _props$
|
|
785
|
+
var _props$webChatContain16;
|
|
777
786
|
dispatch({
|
|
778
787
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_RENDERING_MIDDLEWARE_PROPS,
|
|
779
|
-
payload: (_props$
|
|
788
|
+
payload: (_props$webChatContain16 = props.webChatContainerProps) === null || _props$webChatContain16 === void 0 ? void 0 : _props$webChatContain16.renderingMiddlewareProps
|
|
780
789
|
});
|
|
781
|
-
}, [(_props$
|
|
790
|
+
}, [(_props$webChatContain17 = props.webChatContainerProps) === null || _props$webChatContain17 === void 0 ? void 0 : _props$webChatContain17.renderingMiddlewareProps]);
|
|
782
791
|
(0, _react2.useEffect)(() => {
|
|
783
792
|
_TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
784
793
|
Event: _TelemetryConstants.TelemetryEvent.UXLiveChatWidgetCompleted,
|
|
@@ -821,7 +830,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
821
830
|
const webChatProps = (0, _initWebChatComposer.initWebChatComposer)(props, state, dispatch, facadeChatSDK, endChatRelay);
|
|
822
831
|
const downloadTranscriptProps = (0, _createDownloadTranscriptProps.default)(props.downloadTranscriptProps, {
|
|
823
832
|
...(_defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps === null || _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps === void 0 ? void 0 : _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatStyles),
|
|
824
|
-
...((_props$
|
|
833
|
+
...((_props$webChatContain18 = props.webChatContainerProps) === null || _props$webChatContain18 === void 0 ? void 0 : _props$webChatContain18.webChatStyles)
|
|
825
834
|
}, props.webChatContainerProps);
|
|
826
835
|
const livechatProps = {
|
|
827
836
|
...props,
|
|
@@ -847,6 +856,11 @@ const LiveChatWidgetStateful = props => {
|
|
|
847
856
|
(0, _utils.setOcUserAgent)(facadeChatSDK.getChatSDK());
|
|
848
857
|
const directLine = ((_livechatProps$webCha = livechatProps.webChatContainerProps) === null || _livechatProps$webCha === void 0 ? void 0 : _livechatProps$webCha.directLine) ?? adapter ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.directLine;
|
|
849
858
|
const userID = directLine.getState ? directLine === null || directLine === void 0 ? void 0 : directLine.getState("acs.userId") : "teamsvisitor";
|
|
859
|
+
const styleOptions = _react2.default.useMemo(() => ({
|
|
860
|
+
...webChatStyles,
|
|
861
|
+
bubbleBackground,
|
|
862
|
+
bubbleTextColor
|
|
863
|
+
}), [webChatStyles, bubbleBackground, bubbleTextColor]);
|
|
850
864
|
|
|
851
865
|
// WebChat's Composer can only be rendered if a directLine object is defined
|
|
852
866
|
return directLine && /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement("style", null, `
|
|
@@ -885,11 +899,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
885
899
|
}`}
|
|
886
900
|
`), /*#__PURE__*/_react2.default.createElement(_DraggableChatWidget.default, chatWidgetDraggableConfig, /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
|
|
887
901
|
userID: userID,
|
|
888
|
-
styleOptions:
|
|
889
|
-
...webChatStyles,
|
|
890
|
-
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.defaultAdaptiveCardStyles.background,
|
|
891
|
-
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.defaultAdaptiveCardStyles.color
|
|
892
|
-
},
|
|
902
|
+
styleOptions: styleOptions,
|
|
893
903
|
directLine: directLine
|
|
894
904
|
}), /*#__PURE__*/_react2.default.createElement(_react.Stack, {
|
|
895
905
|
id: widgetElementId,
|
|
@@ -920,7 +930,9 @@ const LiveChatWidgetStateful = props => {
|
|
|
920
930
|
}, livechatProps.callingContainerProps)), !((_livechatProps$contro11 = livechatProps.controlProps) !== null && _livechatProps$contro11 !== void 0 && _livechatProps$contro11.hideWebChatContainer) && (0, _componentController.shouldShowWebChatContainer)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon9 = livechatProps.componentOverrides) === null || _livechatProps$compon9 === void 0 ? void 0 : _livechatProps$compon9.webChatContainer) || /*#__PURE__*/_react2.default.createElement(_WebChatContainerStateful.default, livechatProps)), !((_livechatProps$contro12 = livechatProps.controlProps) !== null && _livechatProps$contro12 !== void 0 && _livechatProps$contro12.hideConfirmationPane) && (0, _componentController.shouldShowConfirmationPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon10 = livechatProps.componentOverrides) === null || _livechatProps$compon10 === void 0 ? void 0 : _livechatProps$compon10.confirmationPane) || /*#__PURE__*/_react2.default.createElement(_ConfirmationPaneStateful.default, _extends({}, confirmationPaneProps, {
|
|
921
931
|
setPostChatContext: setPostChatContextRelay,
|
|
922
932
|
prepareEndChat: prepareEndChatRelay
|
|
923
|
-
}))), !((_livechatProps$contro13 = livechatProps.controlProps) !== null && _livechatProps$contro13 !== void 0 && _livechatProps$contro13.hidePostChatLoadingPane) && (0, _componentController.shouldShowPostChatLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon11 = livechatProps.componentOverrides) === null || _livechatProps$compon11 === void 0 ? void 0 : _livechatProps$compon11.postChatLoadingPane) || /*#__PURE__*/_react2.default.createElement(_PostChatLoadingPaneStateful.default, livechatProps.postChatLoadingPaneProps)), (0, _componentController.shouldShowPostChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon12 = livechatProps.componentOverrides) === null || _livechatProps$compon12 === void 0 ? void 0 : _livechatProps$compon12.postChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PostChatSurveyPaneStateful.default, _extends({}, livechatProps.postChatSurveyPaneProps, livechatProps.chatSDK
|
|
933
|
+
}))), !((_livechatProps$contro13 = livechatProps.controlProps) !== null && _livechatProps$contro13 !== void 0 && _livechatProps$contro13.hidePostChatLoadingPane) && (0, _componentController.shouldShowPostChatLoadingPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon11 = livechatProps.componentOverrides) === null || _livechatProps$compon11 === void 0 ? void 0 : _livechatProps$compon11.postChatLoadingPane) || /*#__PURE__*/_react2.default.createElement(_PostChatLoadingPaneStateful.default, livechatProps.postChatLoadingPaneProps)), (0, _componentController.shouldShowPostChatSurveyPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon12 = livechatProps.componentOverrides) === null || _livechatProps$compon12 === void 0 ? void 0 : _livechatProps$compon12.postChatSurveyPane) || /*#__PURE__*/_react2.default.createElement(_PostChatSurveyPaneStateful.default, _extends({}, livechatProps.postChatSurveyPaneProps, livechatProps.chatSDK, {
|
|
934
|
+
customerVoiceSurveyCorrelationId: conversationId
|
|
935
|
+
}))), (0, _createFooter.createFooter)(livechatProps, state), (0, _componentController.shouldShowEmailTranscriptPane)(state) && ((0, _omnichannelChatComponents.decodeComponentString)((_livechatProps$compon13 = livechatProps.componentOverrides) === null || _livechatProps$compon13 === void 0 ? void 0 : _livechatProps$compon13.emailTranscriptPane) || /*#__PURE__*/_react2.default.createElement(_EmailTranscriptPaneStateful.default, livechatProps.emailTranscriptPane))))));
|
|
924
936
|
};
|
|
925
937
|
exports.LiveChatWidgetStateful = LiveChatWidgetStateful;
|
|
926
938
|
var _default = LiveChatWidgetStateful;
|
|
@@ -7,15 +7,16 @@ exports.default = exports.OutOfOfficeHoursPaneStateful = void 0;
|
|
|
7
7
|
var _TelemetryConstants = require("../../common/telemetry/TelemetryConstants");
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _utils = require("../../common/utils");
|
|
10
|
-
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
11
10
|
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
12
11
|
var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
|
|
13
12
|
var _defaultgeneralOOOHPaneStyleProps = require("./common/defaultStyleProps/defaultgeneralOOOHPaneStyleProps");
|
|
13
|
+
var _xssUtils = require("../../common/utils/xssUtils");
|
|
14
14
|
var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
16
|
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); }
|
|
17
17
|
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; }
|
|
18
18
|
let uiTimer;
|
|
19
|
+
const OOOHPaneTitleText = "Thanks for contacting us. You have reached us outside of our operating hours. An agent will respond when we open.";
|
|
19
20
|
const OutOfOfficeHoursPaneStateful = props => {
|
|
20
21
|
var _props$styleProps;
|
|
21
22
|
(0, _react.useEffect)(() => {
|
|
@@ -54,8 +55,28 @@ const OutOfOfficeHoursPaneStateful = props => {
|
|
|
54
55
|
ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
|
|
55
56
|
});
|
|
56
57
|
}, []);
|
|
58
|
+
|
|
59
|
+
// Enhanced titleText sanitization
|
|
57
60
|
if (controlProps !== null && controlProps !== void 0 && controlProps.titleText) {
|
|
58
|
-
|
|
61
|
+
const {
|
|
62
|
+
cleanText,
|
|
63
|
+
isXSSDetected
|
|
64
|
+
} = (0, _xssUtils.detectAndCleanXSS)(controlProps.titleText);
|
|
65
|
+
if (!isXSSDetected) {
|
|
66
|
+
// replace with the sanitized text
|
|
67
|
+
controlProps.titleText = cleanText;
|
|
68
|
+
} else {
|
|
69
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.WARN, {
|
|
70
|
+
Event: _TelemetryConstants.TelemetryEvent.XSSTextDetected,
|
|
71
|
+
Description: "Potential XSS attempt detected in titleText",
|
|
72
|
+
CustomProperties: {
|
|
73
|
+
originalText: controlProps.titleText.substring(0, 100),
|
|
74
|
+
// Log first 100 chars for analysis
|
|
75
|
+
cleanedText: cleanText.substring(0, 100)
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
controlProps.titleText = OOOHPaneTitleText;
|
|
79
|
+
}
|
|
59
80
|
}
|
|
60
81
|
return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.OutOfOfficeHoursPane, {
|
|
61
82
|
componentOverrides: props.componentOverrides,
|