@microsoft/omnichannel-chat-widget 1.7.7 → 1.7.8-main.9e74278
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/facades/FacadeChatSDK.js +2 -1
- package/lib/cjs/components/livechatwidget/common/authHelper.js +15 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +7 -1
- package/lib/cjs/plugins/createChatTranscript.js +1 -1
- package/lib/esm/common/facades/FacadeChatSDK.js +2 -1
- package/lib/esm/components/livechatwidget/common/authHelper.js +15 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +7 -1
- package/lib/esm/plugins/createChatTranscript.js +1 -1
- package/package.json +1 -1
|
@@ -149,6 +149,7 @@ class FacadeChatSDK {
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
async tokenRing() {
|
|
152
|
+
var _this$chatSDK$chatSDK;
|
|
152
153
|
if (this.disableReauthentication === true) {
|
|
153
154
|
// facade feature is disabled, so we are bypassing the re authentication and let it fail.
|
|
154
155
|
return {
|
|
@@ -176,7 +177,7 @@ class FacadeChatSDK {
|
|
|
176
177
|
message: "Token is valid"
|
|
177
178
|
};
|
|
178
179
|
}
|
|
179
|
-
if (this.getAuthToken === undefined) {
|
|
180
|
+
if (this.getAuthToken === undefined && ((_this$chatSDK$chatSDK = this.chatSDK.chatSDKConfig) === null || _this$chatSDK$chatSDK === void 0 ? void 0 : _this$chatSDK$chatSDK.getAuthToken) === undefined) {
|
|
180
181
|
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
181
182
|
Event: _TelemetryConstants.TelemetryEvent.NewTokenFailed,
|
|
182
183
|
Description: "GetAuthToken function is not present",
|
|
@@ -18,6 +18,7 @@ const getAuthClientFunction = chatConfig => {
|
|
|
18
18
|
};
|
|
19
19
|
exports.getAuthClientFunction = getAuthClientFunction;
|
|
20
20
|
const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
21
|
+
var _chatSDK$chatSDKConfi;
|
|
21
22
|
const authClientFunction = getAuthClientFunction(chatConfig);
|
|
22
23
|
if (getAuthToken && authClientFunction) {
|
|
23
24
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -41,6 +42,20 @@ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
|
41
42
|
});
|
|
42
43
|
throw new Error(_Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
43
44
|
}
|
|
45
|
+
} else if (chatSDK !== null && chatSDK !== void 0 && (_chatSDK$chatSDKConfi = chatSDK.chatSDKConfig) !== null && _chatSDK$chatSDKConfi !== void 0 && _chatSDK$chatSDKConfi.getAuthToken) {
|
|
46
|
+
var _chatSDK$chatSDKConfi2;
|
|
47
|
+
const token = await ((_chatSDK$chatSDKConfi2 = chatSDK.chatSDKConfig) === null || _chatSDK$chatSDKConfi2 === void 0 ? void 0 : _chatSDK$chatSDKConfi2.getAuthToken());
|
|
48
|
+
if ((0, _utils.isNullOrEmptyString)(token)) {
|
|
49
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
50
|
+
Event: _TelemetryConstants.TelemetryEvent.ReceivedNullOrEmptyToken,
|
|
51
|
+
Description: "getAuthToken in chat SDK returns empty string"
|
|
52
|
+
});
|
|
53
|
+
throw new Error(_Constants.WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
"result": true,
|
|
57
|
+
token
|
|
58
|
+
};
|
|
44
59
|
}
|
|
45
60
|
return {
|
|
46
61
|
"result": false,
|
|
@@ -41,6 +41,7 @@ const convertTextToHtmlNode = text => {
|
|
|
41
41
|
|
|
42
42
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
43
|
const processHTMLText = (action, text, honorsTargetInHTMLLinks) => {
|
|
44
|
+
var _htmlNode$tagName;
|
|
44
45
|
const htmlNode = convertTextToHtmlNode(text);
|
|
45
46
|
const aNodes = htmlNode.getElementsByTagName(_Constants.HtmlAttributeNames.aTagName);
|
|
46
47
|
if ((aNodes === null || aNodes === void 0 ? void 0 : aNodes.length) > 0) {
|
|
@@ -70,6 +71,7 @@ const processHTMLText = (action, text, honorsTargetInHTMLLinks) => {
|
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
}
|
|
74
|
+
action = (0, _simpleUpdateIn.default)(action, [_Constants.Constants.payload, _Constants.Constants.activity, _Constants.Constants.text], () => htmlNode.innerHTML);
|
|
73
75
|
} catch (e) {
|
|
74
76
|
let errorMessage = "Failed to apply action: ";
|
|
75
77
|
try {
|
|
@@ -86,7 +88,11 @@ const processHTMLText = (action, text, honorsTargetInHTMLLinks) => {
|
|
|
86
88
|
});
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
|
-
|
|
91
|
+
|
|
92
|
+
// if empty div tag after sanitization
|
|
93
|
+
if (((_htmlNode$tagName = htmlNode.tagName) === null || _htmlNode$tagName === void 0 ? void 0 : _htmlNode$tagName.toLowerCase()) === _Constants.HtmlAttributeNames.div && htmlNode.children.length === 0 && htmlNode.innerHTML.trim() === "") {
|
|
94
|
+
action = (0, _simpleUpdateIn.default)(action, [_Constants.Constants.payload, _Constants.Constants.activity, _Constants.Constants.text], () => "");
|
|
95
|
+
}
|
|
90
96
|
return action;
|
|
91
97
|
};
|
|
92
98
|
|
|
@@ -677,7 +677,7 @@ const createChatTranscript = async function (transcript, facadeChatSDK) {
|
|
|
677
677
|
};
|
|
678
678
|
let messages = transcriptMessages.filter(message => {
|
|
679
679
|
message.content = _dompurify.default.sanitize(message.content);
|
|
680
|
-
return message
|
|
680
|
+
return message;
|
|
681
681
|
});
|
|
682
682
|
if (renderAttachments) {
|
|
683
683
|
messages = await Promise.all(transcriptMessages.map(async message => {
|
|
@@ -143,6 +143,7 @@ export class FacadeChatSDK {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
async tokenRing() {
|
|
146
|
+
var _this$chatSDK$chatSDK;
|
|
146
147
|
if (this.disableReauthentication === true) {
|
|
147
148
|
// facade feature is disabled, so we are bypassing the re authentication and let it fail.
|
|
148
149
|
return {
|
|
@@ -170,7 +171,7 @@ export class FacadeChatSDK {
|
|
|
170
171
|
message: "Token is valid"
|
|
171
172
|
};
|
|
172
173
|
}
|
|
173
|
-
if (this.getAuthToken === undefined) {
|
|
174
|
+
if (this.getAuthToken === undefined && ((_this$chatSDK$chatSDK = this.chatSDK.chatSDKConfig) === null || _this$chatSDK$chatSDK === void 0 ? void 0 : _this$chatSDK$chatSDK.getAuthToken) === undefined) {
|
|
174
175
|
TelemetryHelper.logFacadeChatSDKEvent(LogLevel.ERROR, {
|
|
175
176
|
Event: TelemetryEvent.NewTokenFailed,
|
|
176
177
|
Description: "GetAuthToken function is not present",
|
|
@@ -11,6 +11,7 @@ const getAuthClientFunction = chatConfig => {
|
|
|
11
11
|
return authClientFunction;
|
|
12
12
|
};
|
|
13
13
|
const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
14
|
+
var _chatSDK$chatSDKConfi;
|
|
14
15
|
const authClientFunction = getAuthClientFunction(chatConfig);
|
|
15
16
|
if (getAuthToken && authClientFunction) {
|
|
16
17
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
@@ -34,6 +35,20 @@ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
|
34
35
|
});
|
|
35
36
|
throw new Error(WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
36
37
|
}
|
|
38
|
+
} else if (chatSDK !== null && chatSDK !== void 0 && (_chatSDK$chatSDKConfi = chatSDK.chatSDKConfig) !== null && _chatSDK$chatSDKConfi !== void 0 && _chatSDK$chatSDKConfi.getAuthToken) {
|
|
39
|
+
var _chatSDK$chatSDKConfi2;
|
|
40
|
+
const token = await ((_chatSDK$chatSDKConfi2 = chatSDK.chatSDKConfig) === null || _chatSDK$chatSDKConfi2 === void 0 ? void 0 : _chatSDK$chatSDKConfi2.getAuthToken());
|
|
41
|
+
if (isNullOrEmptyString(token)) {
|
|
42
|
+
TelemetryHelper.logActionEvent(LogLevel.ERROR, {
|
|
43
|
+
Event: TelemetryEvent.ReceivedNullOrEmptyToken,
|
|
44
|
+
Description: "getAuthToken in chat SDK returns empty string"
|
|
45
|
+
});
|
|
46
|
+
throw new Error(WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
"result": true,
|
|
50
|
+
token
|
|
51
|
+
};
|
|
37
52
|
}
|
|
38
53
|
return {
|
|
39
54
|
"result": false,
|
|
@@ -35,6 +35,7 @@ const convertTextToHtmlNode = text => {
|
|
|
35
35
|
|
|
36
36
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
37
|
const processHTMLText = (action, text, honorsTargetInHTMLLinks) => {
|
|
38
|
+
var _htmlNode$tagName;
|
|
38
39
|
const htmlNode = convertTextToHtmlNode(text);
|
|
39
40
|
const aNodes = htmlNode.getElementsByTagName(HtmlAttributeNames.aTagName);
|
|
40
41
|
if ((aNodes === null || aNodes === void 0 ? void 0 : aNodes.length) > 0) {
|
|
@@ -64,6 +65,7 @@ const processHTMLText = (action, text, honorsTargetInHTMLLinks) => {
|
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
}
|
|
68
|
+
action = updateIn(action, [Constants.payload, Constants.activity, Constants.text], () => htmlNode.innerHTML);
|
|
67
69
|
} catch (e) {
|
|
68
70
|
let errorMessage = "Failed to apply action: ";
|
|
69
71
|
try {
|
|
@@ -80,7 +82,11 @@ const processHTMLText = (action, text, honorsTargetInHTMLLinks) => {
|
|
|
80
82
|
});
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
|
-
|
|
85
|
+
|
|
86
|
+
// if empty div tag after sanitization
|
|
87
|
+
if (((_htmlNode$tagName = htmlNode.tagName) === null || _htmlNode$tagName === void 0 ? void 0 : _htmlNode$tagName.toLowerCase()) === HtmlAttributeNames.div && htmlNode.children.length === 0 && htmlNode.innerHTML.trim() === "") {
|
|
88
|
+
action = updateIn(action, [Constants.payload, Constants.activity, Constants.text], () => "");
|
|
89
|
+
}
|
|
84
90
|
return action;
|
|
85
91
|
};
|
|
86
92
|
|
|
@@ -672,7 +672,7 @@ const createChatTranscript = async function (transcript, facadeChatSDK) {
|
|
|
672
672
|
};
|
|
673
673
|
let messages = transcriptMessages.filter(message => {
|
|
674
674
|
message.content = DOMPurify.sanitize(message.content);
|
|
675
|
-
return message
|
|
675
|
+
return message;
|
|
676
676
|
});
|
|
677
677
|
if (renderAttachments) {
|
|
678
678
|
messages = await Promise.all(transcriptMessages.map(async message => {
|