@microsoft/omnichannel-chat-widget 1.7.4-main.f0f5d34 → 1.7.5-main.290ba08

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 (114) hide show
  1. package/lib/cjs/common/facades/FacadeChatSDK.js +298 -0
  2. package/lib/cjs/common/facades/types/IFacadeChatSDKInput.js +1 -0
  3. package/lib/cjs/common/telemetry/TelemetryConstants.js +7 -0
  4. package/lib/cjs/common/telemetry/TelemetryHelper.js +12 -0
  5. package/lib/cjs/common/utils.js +2 -2
  6. package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +4 -8
  7. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -6
  8. package/lib/cjs/components/footerstateful/FooterStateful.js +15 -13
  9. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -10
  10. package/lib/cjs/components/headerstateful/HeaderStateful.js +4 -0
  11. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +26 -3
  12. package/lib/cjs/components/livechatwidget/common/authHelper.js +14 -5
  13. package/lib/cjs/components/livechatwidget/common/createAdapter.js +9 -9
  14. package/lib/cjs/components/livechatwidget/common/endChat.js +40 -30
  15. package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +3 -3
  16. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +15 -11
  17. package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +2 -3
  18. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +11 -12
  19. package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +5 -5
  20. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +4 -4
  21. package/lib/cjs/components/livechatwidget/common/startChat.js +54 -39
  22. package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +7 -7
  23. package/lib/cjs/components/livechatwidget/common/updateSessionDataForTelemetry.js +8 -8
  24. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +63 -40
  25. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -0
  26. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
  27. package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -2
  28. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +11 -6
  29. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +4 -1
  30. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +2 -1
  31. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -3
  32. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/index.js +115 -0
  33. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.js +3 -4
  34. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +3 -4
  35. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/toastMiddleware.js +2 -3
  36. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +4 -4
  37. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +8 -0
  38. package/lib/cjs/contexts/FacadeChatSDKStore.js +10 -0
  39. package/lib/cjs/hooks/useFacadeChatSDKStore.js +17 -0
  40. package/lib/cjs/index.js +34 -2
  41. package/lib/cjs/plugins/createChatTranscript.js +2 -2
  42. package/lib/esm/common/facades/FacadeChatSDK.js +291 -0
  43. package/lib/esm/common/facades/types/IFacadeChatSDKInput.js +1 -0
  44. package/lib/esm/common/telemetry/TelemetryConstants.js +7 -0
  45. package/lib/esm/common/telemetry/TelemetryHelper.js +12 -0
  46. package/lib/esm/common/utils.js +2 -2
  47. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +4 -8
  48. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -6
  49. package/lib/esm/components/footerstateful/FooterStateful.js +15 -13
  50. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -10
  51. package/lib/esm/components/headerstateful/HeaderStateful.js +4 -0
  52. package/lib/esm/components/livechatwidget/LiveChatWidget.js +26 -3
  53. package/lib/esm/components/livechatwidget/common/authHelper.js +14 -5
  54. package/lib/esm/components/livechatwidget/common/createAdapter.js +9 -9
  55. package/lib/esm/components/livechatwidget/common/endChat.js +40 -30
  56. package/lib/esm/components/livechatwidget/common/initCallingSdk.js +3 -3
  57. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +12 -8
  58. package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +2 -4
  59. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +11 -12
  60. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +5 -5
  61. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +4 -4
  62. package/lib/esm/components/livechatwidget/common/startChat.js +55 -40
  63. package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +7 -7
  64. package/lib/esm/components/livechatwidget/common/updateSessionDataForTelemetry.js +8 -8
  65. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +63 -40
  66. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -0
  67. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
  68. package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -2
  69. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +11 -6
  70. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +4 -1
  71. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +2 -1
  72. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -3
  73. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/index.js +10 -0
  74. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.js +2 -3
  75. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +2 -3
  76. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/toastMiddleware.js +2 -3
  77. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +4 -4
  78. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +8 -0
  79. package/lib/esm/contexts/FacadeChatSDKStore.js +4 -0
  80. package/lib/esm/hooks/useFacadeChatSDKStore.js +10 -0
  81. package/lib/esm/index.js +6 -4
  82. package/lib/esm/plugins/createChatTranscript.js +2 -2
  83. package/lib/types/common/facades/FacadeChatSDK.d.ts +71 -0
  84. package/lib/types/common/facades/types/IFacadeChatSDKInput.d.ts +13 -0
  85. package/lib/types/common/telemetry/TelemetryConstants.d.ts +9 -2
  86. package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
  87. package/lib/types/common/telemetry/definitions/Payload.d.ts +7 -0
  88. package/lib/types/common/utils.d.ts +2 -1
  89. package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +3 -2
  90. package/lib/types/components/livechatwidget/common/authHelper.d.ts +14 -1
  91. package/lib/types/components/livechatwidget/common/createAdapter.d.ts +2 -1
  92. package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -3
  93. package/lib/types/components/livechatwidget/common/initCallingSdk.d.ts +2 -1
  94. package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +2 -1
  95. package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +2 -1
  96. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +3 -2
  97. package/lib/types/components/livechatwidget/common/renderSurveyHelpers.d.ts +2 -1
  98. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +2 -1
  99. package/lib/types/components/livechatwidget/common/startChat.d.ts +5 -4
  100. package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +2 -1
  101. package/lib/types/components/livechatwidget/common/updateSessionDataForTelemetry.d.ts +2 -1
  102. package/lib/types/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +1 -0
  103. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +2 -1
  104. package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +1 -0
  105. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.d.ts +1 -2
  106. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/index.d.ts +10 -0
  107. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.d.ts +1 -2
  108. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +1 -2
  109. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/toastMiddleware.d.ts +1 -2
  110. package/lib/types/contexts/FacadeChatSDKStore.d.ts +1 -0
  111. package/lib/types/hooks/useFacadeChatSDKStore.d.ts +3 -0
  112. package/lib/types/index.d.ts +5 -3
  113. package/lib/types/plugins/createChatTranscript.d.ts +2 -1
  114. package/package.json +4 -2
@@ -2,6 +2,7 @@ import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConsta
2
2
  import React, { useEffect } from "react";
3
3
  import AudioNotificationStateful from "./audionotificationstateful/AudioNotificationStateful";
4
4
  import { Constants } from "../../common/Constants";
5
+ import { ConversationState } from "../../contexts/common/ConversationState";
5
6
  import { Footer } from "@microsoft/omnichannel-chat-components";
6
7
  import { LiveChatWidgetActionType } from "../../contexts/common/LiveChatWidgetActionType";
7
8
  import { NewMessageNotificationSoundBase64 } from "../../assets/Audios";
@@ -10,11 +11,11 @@ import { NotificationScenarios } from "../webchatcontainerstateful/webchatcontro
10
11
  import { TelemetryHelper } from "../../common/telemetry/TelemetryHelper";
11
12
  import { downloadTranscript } from "./downloadtranscriptstateful/DownloadTranscriptStateful";
12
13
  import useChatContextStore from "../../hooks/useChatContextStore";
13
- import useChatSDKStore from "../../hooks/useChatSDKStore";
14
+ import useFacadeSDKStore from "../../hooks/useFacadeChatSDKStore";
14
15
 
15
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
17
  export const FooterStateful = props => {
17
- var _footerProps$controlP3, _footerProps$controlP6;
18
+ var _footerProps$controlP3;
18
19
  const [state, dispatch] = useChatContextStore();
19
20
  // hideFooterDisplay - the purpose of this is to keep the footer always "active",
20
21
  // but hide it visually in certain states (e.g., loading state) and show in some other states (e.g. active state).
@@ -25,8 +26,7 @@ export const FooterStateful = props => {
25
26
  audioNotificationProps,
26
27
  hideFooterDisplay
27
28
  } = props;
28
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
- const chatSDK = useChatSDKStore();
29
+ const [facadeChatSDK] = useFacadeSDKStore();
30
30
  const controlProps = {
31
31
  id: "oc-lcw-footer",
32
32
  dir: state.domainStates.globalDir,
@@ -36,7 +36,7 @@ export const FooterStateful = props => {
36
36
  Event: TelemetryEvent.DownloadTranscriptButtonClicked,
37
37
  Description: "Download Transcript button clicked."
38
38
  });
39
- await downloadTranscript(chatSDK, downloadTranscriptProps, state);
39
+ await downloadTranscript(facadeChatSDK, downloadTranscriptProps, state);
40
40
  } catch (ex) {
41
41
  TelemetryHelper.logActionEvent(LogLevel.ERROR, {
42
42
  Event: TelemetryEvent.DownloadTranscriptFailed,
@@ -82,21 +82,23 @@ export const FooterStateful = props => {
82
82
  }
83
83
  };
84
84
  useEffect(() => {
85
- if (state.appStates.isAudioMuted === null) {
86
- var _footerProps$controlP4, _footerProps$controlP5;
87
- dispatch({
88
- type: LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
89
- payload: (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP4 = footerProps.controlProps) === null || _footerProps$controlP4 === void 0 ? void 0 : (_footerProps$controlP5 = _footerProps$controlP4.audioNotificationButtonProps) === null || _footerProps$controlP5 === void 0 ? void 0 : _footerProps$controlP5.isAudioMuted) ?? false
90
- });
85
+ if (state.appStates.conversationState === ConversationState.Active) {
86
+ if (state.appStates.isAudioMuted === null) {
87
+ var _footerProps$controlP4, _footerProps$controlP5, _footerProps$controlP6;
88
+ dispatch({
89
+ type: LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
90
+ payload: footerProps !== null && footerProps !== void 0 && (_footerProps$controlP4 = footerProps.controlProps) !== null && _footerProps$controlP4 !== void 0 && _footerProps$controlP4.hideAudioNotificationButton ? true : (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP5 = footerProps.controlProps) === null || _footerProps$controlP5 === void 0 ? void 0 : (_footerProps$controlP6 = _footerProps$controlP5.audioNotificationButtonProps) === null || _footerProps$controlP6 === void 0 ? void 0 : _footerProps$controlP6.isAudioMuted) ?? false
91
+ });
92
+ }
91
93
  }
92
- }, []);
94
+ }, [state.appStates.conversationState]);
93
95
  return /*#__PURE__*/React.createElement(React.Fragment, null, !hideFooterDisplay && /*#__PURE__*/React.createElement(Footer, {
94
96
  componentOverrides: footerProps === null || footerProps === void 0 ? void 0 : footerProps.componentOverrides,
95
97
  controlProps: controlProps,
96
98
  styleProps: footerProps === null || footerProps === void 0 ? void 0 : footerProps.styleProps
97
99
  }), /*#__PURE__*/React.createElement(AudioNotificationStateful, {
98
100
  audioSrc: (audioNotificationProps === null || audioNotificationProps === void 0 ? void 0 : audioNotificationProps.audioSrc) ?? NewMessageNotificationSoundBase64,
99
- isAudioMuted: state.appStates.isAudioMuted === null ? (footerProps === null || footerProps === void 0 ? void 0 : (_footerProps$controlP6 = footerProps.controlProps) === null || _footerProps$controlP6 === void 0 ? void 0 : _footerProps$controlP6.hideAudioNotificationButton) ?? false : state.appStates.isAudioMuted ?? false
101
+ isAudioMuted: state.appStates.isAudioMuted ?? false
100
102
  }));
101
103
  };
102
104
  export default FooterStateful;
@@ -1,13 +1,13 @@
1
1
  import { Constants, TranscriptConstants } from "../../../common/Constants";
2
- import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
2
+ import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
+ import { createFileAndDownload, isNullOrUndefined } from "../../../common/utils";
4
+ import DOMPurify from "dompurify";
5
+ import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
3
6
  import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
7
+ import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
4
8
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
5
- import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
6
9
  import createChatTranscript from "../../../plugins/createChatTranscript";
7
- import DOMPurify from "dompurify";
8
- import { createFileAndDownload, isNullOrUndefined } from "../../../common/utils";
9
10
  import { executeReducer } from "../../../contexts/createReducer";
10
- import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
11
11
  const processDisplayName = displayName => {
12
12
  // if displayname matches "teamsvisitor:<some alphanumeric string>", we replace it with "Customer"
13
13
  const displayNameRegex = ".+:.+";
@@ -156,9 +156,7 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
156
156
  const str = docTypeTag + docStartTag + docMetaTag + bodyStartTag + mainTranscriptSection + beautifiedChats + divEndTag + bodyEndTag + docEndTag;
157
157
  return str;
158
158
  };
159
-
160
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
161
- export const downloadTranscript = async (chatSDK, downloadTranscriptProps, state) => {
159
+ export const downloadTranscript = async (facadeChatSDK, downloadTranscriptProps, state) => {
162
160
  var _state$domainStates;
163
161
  // Need to keep existing live chat context for scenarios when transcript is downloaded after endchat
164
162
  let liveChatContext = state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatContext;
@@ -169,7 +167,7 @@ export const downloadTranscript = async (chatSDK, downloadTranscriptProps, state
169
167
  });
170
168
  liveChatContext = inMemoryState.domainStates.liveChatContext;
171
169
  }
172
- let data = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getLiveChatTranscript({
170
+ let data = await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.getLiveChatTranscript({
173
171
  liveChatContext
174
172
  }));
175
173
  if (typeof data === Constants.String) {
@@ -187,7 +185,7 @@ export const downloadTranscript = async (chatSDK, downloadTranscriptProps, state
187
185
  const transcriptOptions = {
188
186
  ...webChatTranscript
189
187
  };
190
- await createChatTranscript(data[Constants.ChatMessagesJson], chatSDK, false, transcriptOptions);
188
+ await createChatTranscript(data[Constants.ChatMessagesJson], facadeChatSDK, false, transcriptOptions);
191
189
  } else {
192
190
  // Legacy Transcript
193
191
  const chatTranscripts = window.btoa(encodeURIComponent(beautifyChatTranscripts(data[Constants.ChatMessagesJson], renderMarkDown, attachmentMessage)));
@@ -79,6 +79,10 @@ export const HeaderStateful = props => {
79
79
  text: "We're Offline"
80
80
  },
81
81
  onMinimizeClick: () => {
82
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
83
+ Event: TelemetryEvent.HeaderMinimizeButtonClicked,
84
+ Description: "Header Minimize button clicked."
85
+ });
82
86
  dispatch({
83
87
  type: LiveChatWidgetActionType.SET_MINIMIZED,
84
88
  payload: true
@@ -2,25 +2,48 @@ import React, { 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 { FacadeChatSDK } from "../../common/facades/FacadeChatSDK";
6
+ import { FacadeChatSDKStore } from "../../contexts/FacadeChatSDKStore";
5
7
  import LiveChatWidgetStateful from "./livechatwidgetstateful/LiveChatWidgetStateful";
6
8
  import { createReducer } from "../../contexts/createReducer";
7
9
  import { getLiveChatWidgetContextInitialState } from "../../contexts/common/LiveChatWidgetContextInitialState";
8
10
  import { getMockChatSDKIfApplicable } from "./common/getMockChatSDKIfApplicable";
11
+ import { isNullOrUndefined } from "../../common/utils";
9
12
  import overridePropsOnMockIfApplicable from "./common/overridePropsOnMockIfApplicable";
10
13
  export const LiveChatWidget = props => {
11
- var _props$mock;
14
+ var _props$mock, _props$chatConfig, _props$chatConfig$Liv;
12
15
  const reducer = createReducer();
13
16
  const [state, dispatch] = useReducer(reducer, getLiveChatWidgetContextInitialState(props));
14
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
18
  const [adapter, setAdapter] = useState(undefined);
19
+ const [facadeChatSDK, setFacadeChatSDK] = useState(undefined);
16
20
  const chatSDK = getMockChatSDKIfApplicable(props.chatSDK, props === null || props === void 0 ? void 0 : (_props$mock = props.mock) === null || _props$mock === void 0 ? void 0 : _props$mock.type);
17
21
  overridePropsOnMockIfApplicable(props);
18
- return /*#__PURE__*/React.createElement(ChatSDKStore.Provider, {
22
+ if (!props.chatConfig) {
23
+ throw new Error("chatConfig is required");
24
+ }
25
+
26
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
+ const isAuthenticatedChat = !!((_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);
28
+ if (!facadeChatSDK) {
29
+ var _props$mock2;
30
+ setFacadeChatSDK(new FacadeChatSDK({
31
+ "chatSDK": chatSDK,
32
+ "chatConfig": props.chatConfig,
33
+ "isAuthenticated": isAuthenticatedChat,
34
+ "getAuthToken": props === null || props === void 0 ? void 0 : props.getAuthToken,
35
+ //when type is not undefined, it means the SDK is mocked
36
+ "isSDKMocked": !isNullOrUndefined(props === null || props === void 0 ? void 0 : (_props$mock2 = props.mock) === null || _props$mock2 === void 0 ? void 0 : _props$mock2.type)
37
+ }));
38
+ }
39
+ return /*#__PURE__*/React.createElement(FacadeChatSDKStore.Provider, {
40
+ value: [facadeChatSDK, setFacadeChatSDK]
41
+ }, /*#__PURE__*/React.createElement(ChatSDKStore.Provider, {
19
42
  value: chatSDK
20
43
  }, /*#__PURE__*/React.createElement(ChatAdapterStore.Provider, {
21
44
  value: [adapter, setAdapter]
22
45
  }, /*#__PURE__*/React.createElement(ChatContextStore.Provider, {
23
46
  value: [state, dispatch]
24
- }, /*#__PURE__*/React.createElement(LiveChatWidgetStateful, props))));
47
+ }, /*#__PURE__*/React.createElement(LiveChatWidgetStateful, props)))));
25
48
  };
26
49
  export default LiveChatWidget;
@@ -1,7 +1,7 @@
1
1
  import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
2
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
3
- import { isNullOrEmptyString } from "../../../common/utils";
4
3
  import { WidgetLoadCustomErrorString } from "../../../common/Constants";
4
+ import { isNullOrEmptyString } from "../../../common/utils";
5
5
  const getAuthClientFunction = chatConfig => {
6
6
  let authClientFunction = undefined;
7
7
  if (chatConfig !== null && chatConfig !== void 0 && chatConfig.LiveChatConfigAuthSettings) {
@@ -10,8 +10,6 @@ const getAuthClientFunction = chatConfig => {
10
10
  }
11
11
  return authClientFunction;
12
12
  };
13
-
14
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
13
  const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
16
14
  const authClientFunction = getAuthClientFunction(chatConfig);
17
15
  if (getAuthToken && authClientFunction) {
@@ -24,7 +22,10 @@ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
24
22
  chatSDK.setAuthTokenProvider(async () => {
25
23
  return token;
26
24
  });
27
- return true;
25
+ return {
26
+ "result": true,
27
+ "token": token
28
+ };
28
29
  } else {
29
30
  // instead of returning false, it's more appropiate to thrown an error to force error handling on the caller side
30
31
  // this will help to avoid the error to be ignored and the chat to be started
@@ -34,7 +35,15 @@ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
34
35
  throw new Error(WidgetLoadCustomErrorString.AuthenticationFailedErrorString);
35
36
  }
36
37
  }
37
- return false;
38
+ return {
39
+ "result": false,
40
+ "token": null,
41
+ "error": {
42
+ "message": "No auth client function or getAuthToken function provided",
43
+ "getAuthTokenPresent": getAuthToken ? true : false,
44
+ "authClientFunctionPresent": authClientFunction ? true : false
45
+ }
46
+ };
38
47
  };
39
48
 
40
49
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1,18 +1,17 @@
1
+ import { BotAuthActivitySubscriber } from "./ActivitySubscriber/BotAuthActivitySubscriber";
2
+ import { ChatAdapterShim } from "./ChatAdapterShim";
3
+ import { HiddenAdaptiveCardActivitySubscriber } from "./ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber";
4
+ import { MockChatSDK } from "../../webchatcontainerstateful/common/mockchatsdk";
1
5
  import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
2
6
  import { NotificationLevel } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationLevel";
3
7
  import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
4
- import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
5
- import { ChatAdapterShim } from "./ChatAdapterShim";
6
8
  import { PauseActivitySubscriber } from "./ActivitySubscriber/PauseActivitySubscriber";
7
- import { BotAuthActivitySubscriber } from "./ActivitySubscriber/BotAuthActivitySubscriber";
8
- import { HiddenAdaptiveCardActivitySubscriber } from "./ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber";
9
+ import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
9
10
  const defaultBotAuthConfig = {
10
11
  fetchBotAuthConfigRetries: 3,
11
12
  fetchBotAuthConfigRetryInterval: 1000
12
13
  };
13
-
14
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
- export const createAdapter = async (chatSDK, props) => {
14
+ export const createAdapter = async (facadeChatSDK, props) => {
16
15
  const chatAdapterOptionalParams = {
17
16
  IC3Adapter: {
18
17
  options: {
@@ -35,9 +34,10 @@ export const createAdapter = async (chatSDK, props) => {
35
34
  }
36
35
  }
37
36
  };
38
- let adapter = await chatSDK.createChatAdapter(chatAdapterOptionalParams);
37
+ let adapter = await facadeChatSDK.createChatAdapter(chatAdapterOptionalParams);
39
38
  //so far, there is no need to convert to the shim adapter when using visual tests
40
- if (chatSDK.isMockModeOn !== true) {
39
+ const isMocked = facadeChatSDK.getChatSDK() instanceof MockChatSDK;
40
+ if (isMocked !== true) {
41
41
  var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4;
42
42
  const botAuthActivitySubscriberOptionalParams = {
43
43
  fetchBotAuthConfigRetries: (props === null || props === void 0 ? void 0 : (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.botAuthConfig) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.fetchBotAuthConfigRetries) || defaultBotAuthConfig.fetchBotAuthConfigRetries,
@@ -1,5 +1,5 @@
1
+ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
1
2
  import { ConfirmationState, Constants, ConversationEndEntity, ParticipantType, PrepareEndChatDescriptionConstants } from "../../../common/Constants";
2
- import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
3
  import { getConversationDetailsCall, getWidgetEndChatEventName } from "../../../common/utils";
4
4
  import { getPostChatContext, initiatePostChat } from "./renderSurveyHelpers";
5
5
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
@@ -10,12 +10,11 @@ import { TelemetryManager } from "../../../common/telemetry/TelemetryManager";
10
10
  import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
11
11
  import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
12
12
  import { executeReducer } from "../../../contexts/createReducer";
13
- import { handleAuthentication } from "./authHelper";
14
13
  import { isPersistentEnabled } from "./reconnectChatHelper";
15
14
  import { uuidv4 } from "@microsoft/omnichannel-chat-sdk";
16
15
 
17
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
- const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter) => {
17
+ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter) => {
19
18
  try {
20
19
  var _conversationDetails$, _state$domainStates, _state$appStates3;
21
20
  const {
@@ -23,8 +22,8 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
23
22
  } = props;
24
23
 
25
24
  // Use Case: If call is ongoing, end the call by simulating end call button click
26
- endVoiceVideoCallIfOngoing(chatSDK, dispatch);
27
- const conversationDetails = await getConversationDetailsCall(chatSDK);
25
+ endVoiceVideoCallIfOngoing(facadeChatSDK, dispatch);
26
+ const conversationDetails = await getConversationDetailsCall(facadeChatSDK);
28
27
 
29
28
  // Use Case: When post chat is not configured
30
29
  if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : (_conversationDetails$ = conversationDetails.canRenderPostChat) === null || _conversationDetails$ === void 0 ? void 0 : _conversationDetails$.toLowerCase()) === Constants.false) {
@@ -35,7 +34,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
35
34
  Event: TelemetryEvent.PrepareEndChat,
36
35
  Description: PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithoutPostChat
37
36
  });
38
- await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
37
+ await endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
39
38
  }
40
39
 
41
40
  // Use Case: If ended by Agent, stay chat in InActive state
@@ -52,16 +51,23 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
52
51
 
53
52
  // Use Case: Can render post chat scenarios
54
53
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
- const postchatContext = (await getPostChatContext(chatSDK, state, dispatch)) ?? (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.postChatContext);
54
+ const postchatContext = (await getPostChatContext(facadeChatSDK, state, dispatch)) ?? (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.postChatContext);
56
55
  if (postchatContext === undefined) {
57
56
  var _state$appStates2;
57
+ BroadcastService.postMessage({
58
+ eventName: BroadcastEvent.OnWidgetError,
59
+ payload: {
60
+ errorMessage: "Widget did not display post chat survey as getPostChatContext returned undefined."
61
+ }
62
+ });
63
+
58
64
  // For Customer intiated conversations, just close chat widget
59
65
  if ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.conversationEndedBy) === ConversationEndEntity.Customer) {
60
66
  TelemetryHelper.logSDKEvent(LogLevel.INFO, {
61
67
  Event: TelemetryEvent.PrepareEndChat,
62
68
  Description: PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithInvalidPostChat
63
69
  });
64
- await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
70
+ await endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
65
71
  return;
66
72
  }
67
73
 
@@ -91,7 +97,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
91
97
  const endedByCustomer = (appStates === null || appStates === void 0 ? void 0 : appStates.conversationEndedBy) === "Customer";
92
98
 
93
99
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
94
- const commonParams = [props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter];
100
+ const commonParams = [props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter];
95
101
  if (persistentEnabled && endedByCustomer) {
96
102
  await endChat(...commonParams, true, false, true);
97
103
  } else {
@@ -116,7 +122,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
116
122
  Event: TelemetryEvent.PrepareEndChat,
117
123
  Description: PrepareEndChatDescriptionConstants.PrepareEndChatError
118
124
  });
119
- await endChat(props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
125
+ await endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
120
126
  }
121
127
  } finally {
122
128
  //Chat token clean up
@@ -125,23 +131,26 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
125
131
  };
126
132
 
127
133
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
128
- const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => {
129
- if (!skipEndChatSDK && chatSDK.conversation) {
134
+ const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => {
135
+ var _facadeChatSDK$getCha;
136
+ if (!skipEndChatSDK && facadeChatSDK !== null && facadeChatSDK !== void 0 && (_facadeChatSDK$getCha = facadeChatSDK.getChatSDK()) !== null && _facadeChatSDK$getCha !== void 0 && _facadeChatSDK$getCha.conversation) {
137
+ var _inMemoryState$appSta;
138
+ const inMemoryState = executeReducer(state, {
139
+ type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
140
+ payload: null
141
+ });
142
+ const endChatOptionalParameters = {
143
+ isSessionEnded: inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.chatDisconnectEventReceived
144
+ };
130
145
  try {
131
146
  TelemetryHelper.logSDKEvent(LogLevel.INFO, {
132
147
  Event: TelemetryEvent.EndChatSDKCall
133
148
  });
134
- //Get auth token again if chat continued for longer time, otherwise gets 401 error
135
- await handleAuthentication(chatSDK, props.chatConfig, props.getAuthToken);
136
- await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
149
+ await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.endChat(endChatOptionalParameters));
137
150
  } catch (ex) {
138
- var _inMemoryState$appSta;
139
- const inMemoryState = executeReducer(state, {
140
- type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
141
- payload: null
142
- });
151
+ var _inMemoryState$appSta2;
143
152
  // if the chat was disconnected or ended by the agent, we don't want to log the error
144
- if (!(inMemoryState !== null && inMemoryState !== void 0 && (_inMemoryState$appSta = inMemoryState.appStates) !== null && _inMemoryState$appSta !== void 0 && _inMemoryState$appSta.chatDisconnectEventReceived)) {
153
+ if (!(inMemoryState !== null && inMemoryState !== void 0 && (_inMemoryState$appSta2 = inMemoryState.appStates) !== null && _inMemoryState$appSta2 !== void 0 && _inMemoryState$appSta2.chatDisconnectEventReceived)) {
145
154
  TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
146
155
  Event: TelemetryEvent.EndChatSDKCallFailed,
147
156
  ExceptionDetails: {
@@ -158,7 +167,8 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
158
167
  }
159
168
  postMessageToOtherTab = false;
160
169
  } finally {
161
- await endChatStateCleanUp(dispatch);
170
+ endChatStateCleanUp(dispatch);
171
+ facadeChatSDK.destroy();
162
172
  }
163
173
  }
164
174
  if (!skipCloseChat) {
@@ -194,10 +204,11 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
194
204
  });
195
205
  // Always allow to close the chat for embedded mode irrespective of end chat errors
196
206
  closeChatWidget(dispatch, props, state);
207
+ facadeChatSDK.destroy();
197
208
  }
198
209
  }
199
210
  if (postMessageToOtherTab) {
200
- const endChatEventName = await getEndChatEventName(chatSDK, props);
211
+ const endChatEventName = await getEndChatEventName(facadeChatSDK, props);
201
212
  BroadcastService.postMessage({
202
213
  eventName: endChatEventName,
203
214
  payload: {
@@ -292,11 +303,11 @@ export const chatSDKStateCleanUp = chatSDK => {
292
303
  };
293
304
 
294
305
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
295
- export const endVoiceVideoCallIfOngoing = async (chatSDK, dispatch) => {
306
+ export const endVoiceVideoCallIfOngoing = async (facadeChatSDK, dispatch) => {
296
307
  let callId = "";
297
308
  try {
298
- if (chatSDK.isVoiceVideoCallingEnabled()) {
299
- const voiceVideoCallingSdk = await chatSDK.getVoiceVideoCalling();
309
+ if (facadeChatSDK.getChatSDK().isVoiceVideoCallingEnabled()) {
310
+ const voiceVideoCallingSdk = await facadeChatSDK.getVoiceVideoCalling();
300
311
  if (voiceVideoCallingSdk && voiceVideoCallingSdk.isInACall()) {
301
312
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
302
313
  callId = voiceVideoCallingSdk.callId;
@@ -349,9 +360,8 @@ const chatTokenCleanUp = async dispatch => {
349
360
  // Need to keep liveChatContext until chat is fully closed to for transcript download/email
350
361
  };
351
362
 
352
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
353
- const getEndChatEventName = async (chatSDK, props) => {
354
- var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$controlProps4;
355
- return getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps4 = props.controlProps) === null || _props$controlProps4 === void 0 ? void 0 : _props$controlProps4.widgetInstanceId) ?? "");
363
+ const getEndChatEventName = async (facadeChatSDK, props) => {
364
+ var _facadeChatSDK$getCha2, _facadeChatSDK$getCha3, _facadeChatSDK$getCha4, _facadeChatSDK$getCha5, _props$controlProps4;
365
+ return getWidgetEndChatEventName((_facadeChatSDK$getCha2 = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha2 === void 0 ? void 0 : (_facadeChatSDK$getCha3 = _facadeChatSDK$getCha2.omnichannelConfig) === null || _facadeChatSDK$getCha3 === void 0 ? void 0 : _facadeChatSDK$getCha3.orgId, (_facadeChatSDK$getCha4 = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha4 === void 0 ? void 0 : (_facadeChatSDK$getCha5 = _facadeChatSDK$getCha4.omnichannelConfig) === null || _facadeChatSDK$getCha5 === void 0 ? void 0 : _facadeChatSDK$getCha5.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps4 = props.controlProps) === null || _props$controlProps4 === void 0 ? void 0 : _props$controlProps4.widgetInstanceId) ?? "");
356
366
  };
357
367
  export { prepareEndChat, endChat };
@@ -2,12 +2,12 @@ import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryCon
2
2
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
3
3
 
4
4
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
- export const initCallingSdk = async (chatSDK, setVoiceVideoCallingSDK) => {
5
+ export const initCallingSdk = async (facadeChatSDK, setVoiceVideoCallingSDK) => {
6
6
  try {
7
7
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
- if (chatSDK.getVoiceVideoCalling) {
8
+ if (facadeChatSDK.getChatSDK().getVoiceVideoCalling) {
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
- const callingSDK = await chatSDK.getVoiceVideoCalling();
10
+ const callingSDK = await facadeChatSDK.getChatSDK().getVoiceVideoCalling();
11
11
  setVoiceVideoCallingSDK(callingSDK);
12
12
  TelemetryHelper.logCallingEvent(LogLevel.INFO, {
13
13
  Event: TelemetryEvent.CallingSDKLoadSuccess
@@ -1,6 +1,7 @@
1
1
  import { ConversationEndEntity, ParticipantType } from "../../../common/Constants";
2
2
  import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
3
  import { changeLanguageCodeFormatForWebChat, getConversationDetailsCall } from "../../../common/utils";
4
+ import DOMPurify from "dompurify";
4
5
  import HyperlinkTextOverrideRenderer from "../../webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer";
5
6
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
6
7
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
@@ -8,7 +9,7 @@ import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontro
8
9
  import attachmentProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware";
9
10
  import channelDataMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware";
10
11
  import { createActivityMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware";
11
- import createAttachmentMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware";
12
+ import { createAttachmentMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware";
12
13
  import createAttachmentUploadValidatorMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware";
13
14
  import { createAvatarMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware";
14
15
  import { createCardActionMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware";
@@ -16,8 +17,10 @@ import createConversationEndMiddleware from "../../webchatcontainerstateful/webc
16
17
  import createDataMaskingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware";
17
18
  import { createMarkdown } from "./createMarkdown";
18
19
  import createMaxMessageSizeValidator from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator";
19
- import createMessageTimeStampMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware";
20
+ import { createMessageSequenceIdOverrideMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware";
21
+ import { createMessageTimeStampMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware";
20
22
  import { createStore } from "botframework-webchat";
23
+ import { createToastMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/toastMiddleware";
21
24
  import { createWebChatTelemetry } from "../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger";
22
25
  import { defaultAttachmentProps } from "../../webchatcontainerstateful/common/defaultProps/defaultAttachmentProps";
23
26
  import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
@@ -28,12 +31,9 @@ import htmlPlayerMiddleware from "../../webchatcontainerstateful/webchatcontroll
28
31
  import htmlTextMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware";
29
32
  import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware";
30
33
  import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
31
- import DOMPurify from "dompurify";
32
- import createMessageSequenceIdOverrideMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware";
33
- import createToastMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/toastMiddleware";
34
34
 
35
35
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
- export const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) => {
36
+ export const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) => {
37
37
  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, _props$webChatContain17, _props$webChatContain18, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai2, _props$webChatContain21, _props$webChatContain22, _defaultWebChatContai3, _props$webChatContain23, _props$webChatContain24;
38
38
  // Add a hook to make all links open a new window
39
39
  postDomPurifyActivities();
@@ -52,7 +52,7 @@ export const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) =>
52
52
  var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain5;
53
53
  const conversationEndCallback = async () => {
54
54
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
- const conversationDetails = await getConversationDetailsCall(chatSDK);
55
+ const conversationDetails = await getConversationDetailsCall(facadeChatSDK);
56
56
  if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === ParticipantType.Bot) {
57
57
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
58
58
  Event: TelemetryEvent.ConversationEndedThreadEventReceived,
@@ -100,7 +100,11 @@ export const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) =>
100
100
  markdownRenderers.forEach(renderer => {
101
101
  text = renderer.render(text);
102
102
  });
103
- text = DOMPurify.sanitize(text);
103
+ const config = {
104
+ FORBID_TAGS: ["form", "button", "script", "div", "input"],
105
+ FORBID_ATTR: ["action"]
106
+ };
107
+ text = DOMPurify.sanitize(text, config);
104
108
  return text;
105
109
  };
106
110
  function postDomPurifyActivities() {
@@ -1,10 +1,8 @@
1
1
  import { ConversationMode } from "../../../common/Constants";
2
2
  import { isNullOrUndefined } from "../../../common/utils";
3
-
4
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
- export const isPostChatSurveyEnabled = async chatSDK => {
3
+ export const isPostChatSurveyEnabled = async facadeChatSDK => {
6
4
  var _chatConfig$LiveWSAnd;
7
- const chatConfig = await chatSDK.getLiveChatConfig();
5
+ const chatConfig = await facadeChatSDK.getLiveChatConfig();
8
6
  const postChatEnabled = (_chatConfig$LiveWSAnd = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd === void 0 ? void 0 : _chatConfig$LiveWSAnd.msdyn_postconversationsurveyenable.toString().toLowerCase();
9
7
  return postChatEnabled === "true";
10
8
  };