@microsoft/omnichannel-chat-widget 1.7.7 → 1.7.8-main.7a07fc5

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.
@@ -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,
@@ -11,6 +11,7 @@ var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components
11
11
  var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
12
12
  var _defaultgeneralOOOHPaneStyleProps = require("./common/defaultStyleProps/defaultgeneralOOOHPaneStyleProps");
13
13
  var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
14
+ var _dompurify = _interopRequireDefault(require("dompurify"));
14
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
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); }
16
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; }
@@ -49,6 +50,9 @@ const OutOfOfficeHoursPaneStateful = props => {
49
50
  ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
50
51
  });
51
52
  }, []);
53
+ if (controlProps !== null && controlProps !== void 0 && controlProps.titleText) {
54
+ controlProps.titleText = _dompurify.default.sanitize(controlProps.titleText);
55
+ }
52
56
  return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.OutOfOfficeHoursPane, {
53
57
  componentOverrides: props.componentOverrides,
54
58
  controlProps: controlProps,
@@ -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
- action = (0, _simpleUpdateIn.default)(action, [_Constants.Constants.payload, _Constants.Constants.activity, _Constants.Constants.text], () => htmlNode.innerHTML);
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.content.length > 0;
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,
@@ -5,6 +5,7 @@ import { OutOfOfficeHoursPane } from "@microsoft/omnichannel-chat-components";
5
5
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
6
6
  import { defaultGeneralStyleProps } from "./common/defaultStyleProps/defaultgeneralOOOHPaneStyleProps";
7
7
  import useChatContextStore from "../../hooks/useChatContextStore";
8
+ import DOMPurify from "dompurify";
8
9
  let uiTimer;
9
10
  export const OutOfOfficeHoursPaneStateful = props => {
10
11
  var _props$styleProps;
@@ -40,6 +41,9 @@ export const OutOfOfficeHoursPaneStateful = props => {
40
41
  ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
41
42
  });
42
43
  }, []);
44
+ if (controlProps !== null && controlProps !== void 0 && controlProps.titleText) {
45
+ controlProps.titleText = DOMPurify.sanitize(controlProps.titleText);
46
+ }
43
47
  return /*#__PURE__*/React.createElement(OutOfOfficeHoursPane, {
44
48
  componentOverrides: props.componentOverrides,
45
49
  controlProps: controlProps,
@@ -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
- action = updateIn(action, [Constants.payload, Constants.activity, Constants.text], () => htmlNode.innerHTML);
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.content.length > 0;
675
+ return message;
676
676
  });
677
677
  if (renderAttachments) {
678
678
  messages = await Promise.all(transcriptMessages.map(async message => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.7.7",
3
+ "version": "1.7.8-main.7a07fc5",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",