@microsoft/omnichannel-chat-widget 1.0.4 → 1.0.5-main.545bb43
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/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +4 -0
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +12 -1
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +3 -0
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +12 -1
- package/package.json +1 -1
package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js
CHANGED
|
@@ -9,6 +9,8 @@ var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcont
|
|
|
9
9
|
var _NotificationHandler = require("../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler");
|
|
10
10
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
11
11
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
12
|
+
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
14
|
const processDisplayName = displayName => {
|
|
13
15
|
// if displayname matches "teamsvisitor:<some alphanumeric string>", we replace it with "Customer"
|
|
14
16
|
const displayNameRegex = ".+:.+";
|
|
@@ -64,6 +66,8 @@ const processContent = (transcriptContent, isAgentChat, renderMarkDown) => {
|
|
|
64
66
|
}
|
|
65
67
|
if (renderMarkDown) {
|
|
66
68
|
transcriptContent = renderMarkDown(transcriptContent);
|
|
69
|
+
} else {
|
|
70
|
+
transcriptContent = _dompurify.default.sanitize(transcriptContent);
|
|
67
71
|
}
|
|
68
72
|
return transcriptContent;
|
|
69
73
|
};
|
|
@@ -34,10 +34,13 @@ var _htmlPlayerMiddleware = _interopRequireDefault(require("../../webchatcontain
|
|
|
34
34
|
var _htmlTextMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware"));
|
|
35
35
|
var _preProcessingMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware"));
|
|
36
36
|
var _sanitizationMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"));
|
|
37
|
+
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
37
38
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
38
39
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
40
|
const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
40
41
|
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain11, _props$webChatContain12, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain13, _props$webChatContain14, _defaultWebChatContai, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21, _props$webChatContain22;
|
|
42
|
+
// Add a hook to make all links open a new window
|
|
43
|
+
postDomPurifyActivities();
|
|
41
44
|
const localizedTexts = {
|
|
42
45
|
..._defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts,
|
|
43
46
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
|
|
@@ -90,9 +93,17 @@ const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
|
90
93
|
markdownRenderers.forEach(renderer => {
|
|
91
94
|
text = renderer.render(text);
|
|
92
95
|
});
|
|
96
|
+
text = _dompurify.default.sanitize(text);
|
|
93
97
|
return text;
|
|
94
98
|
};
|
|
95
|
-
|
|
99
|
+
function postDomPurifyActivities() {
|
|
100
|
+
_dompurify.default.addHook("afterSanitizeAttributes", function (node) {
|
|
101
|
+
// set all elements owning target to target=_blank
|
|
102
|
+
if ("target" in node) {
|
|
103
|
+
node.setAttribute("target", "_blank");
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
96
107
|
// Initialize the remaining Web Chat props
|
|
97
108
|
const webChatProps = {
|
|
98
109
|
..._defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps,
|
package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js
CHANGED
|
@@ -3,6 +3,7 @@ import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcon
|
|
|
3
3
|
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
4
4
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
5
5
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
6
|
+
import DOMPurify from "dompurify";
|
|
6
7
|
const processDisplayName = displayName => {
|
|
7
8
|
// if displayname matches "teamsvisitor:<some alphanumeric string>", we replace it with "Customer"
|
|
8
9
|
const displayNameRegex = ".+:.+";
|
|
@@ -58,6 +59,8 @@ const processContent = (transcriptContent, isAgentChat, renderMarkDown) => {
|
|
|
58
59
|
}
|
|
59
60
|
if (renderMarkDown) {
|
|
60
61
|
transcriptContent = renderMarkDown(transcriptContent);
|
|
62
|
+
} else {
|
|
63
|
+
transcriptContent = DOMPurify.sanitize(transcriptContent);
|
|
61
64
|
}
|
|
62
65
|
return transcriptContent;
|
|
63
66
|
};
|
|
@@ -28,10 +28,13 @@ import htmlPlayerMiddleware from "../../webchatcontainerstateful/webchatcontroll
|
|
|
28
28
|
import htmlTextMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware";
|
|
29
29
|
import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware";
|
|
30
30
|
import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
|
|
31
|
+
import DOMPurify from "dompurify";
|
|
31
32
|
|
|
32
33
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
34
|
export const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
34
35
|
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain11, _props$webChatContain12, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain13, _props$webChatContain14, _defaultWebChatContai, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21, _props$webChatContain22;
|
|
36
|
+
// Add a hook to make all links open a new window
|
|
37
|
+
postDomPurifyActivities();
|
|
35
38
|
const localizedTexts = {
|
|
36
39
|
...defaultMiddlewareLocalizedTexts,
|
|
37
40
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
|
|
@@ -84,9 +87,17 @@ export const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
|
84
87
|
markdownRenderers.forEach(renderer => {
|
|
85
88
|
text = renderer.render(text);
|
|
86
89
|
});
|
|
90
|
+
text = DOMPurify.sanitize(text);
|
|
87
91
|
return text;
|
|
88
92
|
};
|
|
89
|
-
|
|
93
|
+
function postDomPurifyActivities() {
|
|
94
|
+
DOMPurify.addHook("afterSanitizeAttributes", function (node) {
|
|
95
|
+
// set all elements owning target to target=_blank
|
|
96
|
+
if ("target" in node) {
|
|
97
|
+
node.setAttribute("target", "_blank");
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
90
101
|
// Initialize the remaining Web Chat props
|
|
91
102
|
const webChatProps = {
|
|
92
103
|
...defaultWebChatContainerStatefulProps.webChatProps,
|