@microsoft/omnichannel-chat-widget 1.7.4-main.0574a04 → 1.7.4-main.1f61ac6

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 (92) 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 +6 -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 +4 -5
  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 +21 -22
  15. package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +3 -3
  16. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +3 -3
  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 +48 -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 +43 -39
  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/common/mockchatsdk.js +4 -1
  29. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +4 -4
  30. package/lib/cjs/contexts/FacadeChatSDKStore.js +10 -0
  31. package/lib/cjs/hooks/useFacadeChatSDKStore.js +17 -0
  32. package/lib/cjs/index.js +9 -2
  33. package/lib/cjs/plugins/createChatTranscript.js +2 -2
  34. package/lib/esm/common/facades/FacadeChatSDK.js +291 -0
  35. package/lib/esm/common/facades/types/IFacadeChatSDKInput.js +1 -0
  36. package/lib/esm/common/telemetry/TelemetryConstants.js +6 -0
  37. package/lib/esm/common/telemetry/TelemetryHelper.js +12 -0
  38. package/lib/esm/common/utils.js +2 -2
  39. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +4 -8
  40. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +5 -6
  41. package/lib/esm/components/footerstateful/FooterStateful.js +4 -5
  42. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -10
  43. package/lib/esm/components/headerstateful/HeaderStateful.js +4 -0
  44. package/lib/esm/components/livechatwidget/LiveChatWidget.js +26 -3
  45. package/lib/esm/components/livechatwidget/common/authHelper.js +14 -5
  46. package/lib/esm/components/livechatwidget/common/createAdapter.js +9 -9
  47. package/lib/esm/components/livechatwidget/common/endChat.js +21 -22
  48. package/lib/esm/components/livechatwidget/common/initCallingSdk.js +3 -3
  49. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +3 -3
  50. package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +2 -4
  51. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +11 -12
  52. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +5 -5
  53. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +4 -4
  54. package/lib/esm/components/livechatwidget/common/startChat.js +49 -40
  55. package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +7 -7
  56. package/lib/esm/components/livechatwidget/common/updateSessionDataForTelemetry.js +8 -8
  57. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +43 -39
  58. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -0
  59. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
  60. package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +4 -2
  61. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +4 -1
  62. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +4 -4
  63. package/lib/esm/contexts/FacadeChatSDKStore.js +4 -0
  64. package/lib/esm/hooks/useFacadeChatSDKStore.js +10 -0
  65. package/lib/esm/index.js +5 -4
  66. package/lib/esm/plugins/createChatTranscript.js +2 -2
  67. package/lib/types/common/facades/FacadeChatSDK.d.ts +71 -0
  68. package/lib/types/common/facades/types/IFacadeChatSDKInput.d.ts +13 -0
  69. package/lib/types/common/telemetry/TelemetryConstants.d.ts +7 -1
  70. package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
  71. package/lib/types/common/telemetry/definitions/Payload.d.ts +7 -0
  72. package/lib/types/common/utils.d.ts +2 -1
  73. package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +3 -2
  74. package/lib/types/components/livechatwidget/common/authHelper.d.ts +14 -1
  75. package/lib/types/components/livechatwidget/common/createAdapter.d.ts +2 -1
  76. package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -3
  77. package/lib/types/components/livechatwidget/common/initCallingSdk.d.ts +2 -1
  78. package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +2 -1
  79. package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +2 -1
  80. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +3 -2
  81. package/lib/types/components/livechatwidget/common/renderSurveyHelpers.d.ts +2 -1
  82. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +2 -1
  83. package/lib/types/components/livechatwidget/common/startChat.d.ts +5 -4
  84. package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +2 -1
  85. package/lib/types/components/livechatwidget/common/updateSessionDataForTelemetry.d.ts +2 -1
  86. package/lib/types/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +1 -0
  87. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +2 -1
  88. package/lib/types/contexts/FacadeChatSDKStore.d.ts +1 -0
  89. package/lib/types/hooks/useFacadeChatSDKStore.d.ts +3 -0
  90. package/lib/types/index.d.ts +4 -3
  91. package/lib/types/plugins/createChatTranscript.d.ts +2 -1
  92. package/package.json +2 -2
@@ -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,
@@ -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,7 +51,7 @@ 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;
58
57
  BroadcastService.postMessage({
@@ -68,7 +67,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
68
67
  Event: TelemetryEvent.PrepareEndChat,
69
68
  Description: PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithInvalidPostChat
70
69
  });
71
- 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);
72
71
  return;
73
72
  }
74
73
 
@@ -98,7 +97,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
98
97
  const endedByCustomer = (appStates === null || appStates === void 0 ? void 0 : appStates.conversationEndedBy) === "Customer";
99
98
 
100
99
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
101
- const commonParams = [props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter];
100
+ const commonParams = [props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter];
102
101
  if (persistentEnabled && endedByCustomer) {
103
102
  await endChat(...commonParams, true, false, true);
104
103
  } else {
@@ -123,7 +122,7 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
123
122
  Event: TelemetryEvent.PrepareEndChat,
124
123
  Description: PrepareEndChatDescriptionConstants.PrepareEndChatError
125
124
  });
126
- 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);
127
126
  }
128
127
  } finally {
129
128
  //Chat token clean up
@@ -132,8 +131,9 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
132
131
  };
133
132
 
134
133
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
135
- const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => {
136
- 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
137
  var _inMemoryState$appSta;
138
138
  const inMemoryState = executeReducer(state, {
139
139
  type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
@@ -146,9 +146,7 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
146
146
  TelemetryHelper.logSDKEvent(LogLevel.INFO, {
147
147
  Event: TelemetryEvent.EndChatSDKCall
148
148
  });
149
- //Get auth token again if chat continued for longer time, otherwise gets 401 error
150
- await handleAuthentication(chatSDK, props.chatConfig, props.getAuthToken);
151
- await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat(endChatOptionalParameters));
149
+ await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.endChat(endChatOptionalParameters));
152
150
  } catch (ex) {
153
151
  var _inMemoryState$appSta2;
154
152
  // if the chat was disconnected or ended by the agent, we don't want to log the error
@@ -170,6 +168,7 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
170
168
  postMessageToOtherTab = false;
171
169
  } finally {
172
170
  endChatStateCleanUp(dispatch);
171
+ facadeChatSDK.destroy();
173
172
  }
174
173
  }
175
174
  if (!skipCloseChat) {
@@ -205,10 +204,11 @@ const endChat = async (props, chatSDK, state, dispatch, setAdapter, setWebChatSt
205
204
  });
206
205
  // Always allow to close the chat for embedded mode irrespective of end chat errors
207
206
  closeChatWidget(dispatch, props, state);
207
+ facadeChatSDK.destroy();
208
208
  }
209
209
  }
210
210
  if (postMessageToOtherTab) {
211
- const endChatEventName = await getEndChatEventName(chatSDK, props);
211
+ const endChatEventName = await getEndChatEventName(facadeChatSDK, props);
212
212
  BroadcastService.postMessage({
213
213
  eventName: endChatEventName,
214
214
  payload: {
@@ -303,11 +303,11 @@ export const chatSDKStateCleanUp = chatSDK => {
303
303
  };
304
304
 
305
305
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
306
- export const endVoiceVideoCallIfOngoing = async (chatSDK, dispatch) => {
306
+ export const endVoiceVideoCallIfOngoing = async (facadeChatSDK, dispatch) => {
307
307
  let callId = "";
308
308
  try {
309
- if (chatSDK.isVoiceVideoCallingEnabled()) {
310
- const voiceVideoCallingSdk = await chatSDK.getVoiceVideoCalling();
309
+ if (facadeChatSDK.getChatSDK().isVoiceVideoCallingEnabled()) {
310
+ const voiceVideoCallingSdk = await facadeChatSDK.getVoiceVideoCalling();
311
311
  if (voiceVideoCallingSdk && voiceVideoCallingSdk.isInACall()) {
312
312
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
313
313
  callId = voiceVideoCallingSdk.callId;
@@ -360,9 +360,8 @@ const chatTokenCleanUp = async dispatch => {
360
360
  // Need to keep liveChatContext until chat is fully closed to for transcript download/email
361
361
  };
362
362
 
363
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
364
- const getEndChatEventName = async (chatSDK, props) => {
365
- var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$controlProps4;
366
- 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) ?? "");
367
366
  };
368
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
@@ -33,7 +33,7 @@ import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontr
33
33
  import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
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,
@@ -101,7 +101,7 @@ export const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) =>
101
101
  text = renderer.render(text);
102
102
  });
103
103
  const config = {
104
- FORBID_TAGS: ["form", "button", "script", "div"],
104
+ FORBID_TAGS: ["form", "button", "script", "div", "input"],
105
105
  FORBID_ATTR: ["action"]
106
106
  };
107
107
  text = DOMPurify.sanitize(text, config);
@@ -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
  };
@@ -1,9 +1,9 @@
1
1
  import "regenerator-runtime/runtime";
2
2
  import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
+ import { ConversationMode, WidgetLoadCustomErrorString } from "../../../common/Constants";
3
4
  import { checkContactIdError, isNullOrEmptyString, isNullOrUndefined } from "../../../common/utils";
4
5
  import { handleAuthentication, removeAuthTokenProvider } from "./authHelper";
5
6
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
6
- import { ConversationMode, WidgetLoadCustomErrorString } from "../../../common/Constants";
7
7
  import { ConversationState } from "../../../contexts/common/ConversationState";
8
8
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
9
9
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
@@ -11,13 +11,12 @@ import { handleStartChatError } from "./startChatErrorHandler";
11
11
 
12
12
  // Return value: should start normal chat flow when reconnect is enabled
13
13
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
- const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initStartChat, state) => {
14
+ const handleChatReconnect = async (facadeChatSDK, props, dispatch, setAdapter, initStartChat, state) => {
15
15
  var _props$chatConfig, _props$chatConfig$Liv;
16
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
17
  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 ? true : false;
18
-
19
18
  // Get chat reconnect context
20
- const reconnectChatContext = await getChatReconnectContext(chatSDK, props.chatConfig, props, isAuthenticatedChat, dispatch);
19
+ const reconnectChatContext = (await getChatReconnectContext(facadeChatSDK, props.chatConfig, props, isAuthenticatedChat, dispatch)) ?? {};
21
20
 
22
21
  // Redirect if enabled
23
22
  if (reconnectChatContext !== null && reconnectChatContext !== void 0 && reconnectChatContext.redirectURL) {
@@ -29,7 +28,7 @@ const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initSta
29
28
  var _props$reconnectChatP2, _props$reconnectChatP3, _props$controlProps;
30
29
  //if reconnect id is provided in props, or hideReconnectChatPane is true, don't show reconnect pane
31
30
  if ((_props$reconnectChatP2 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP2 !== void 0 && _props$reconnectChatP2.reconnectId && !isNullOrEmptyString((_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.reconnectId) || (_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hideReconnectChatPane) {
32
- await setReconnectIdAndStartChat(isAuthenticatedChat, chatSDK, state, props, dispatch, setAdapter, reconnectChatContext.reconnectId ?? "", initStartChat);
31
+ await setReconnectIdAndStartChat(isAuthenticatedChat, facadeChatSDK, state, props, dispatch, setAdapter, reconnectChatContext.reconnectId ?? "", initStartChat);
33
32
  return false;
34
33
  }
35
34
 
@@ -52,7 +51,7 @@ const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initSta
52
51
  };
53
52
 
54
53
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
- const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticatedChat, dispatch) => {
54
+ const getChatReconnectContext = async (facadeChatSDK, chatConfig, props, isAuthenticatedChat, dispatch) => {
56
55
  try {
57
56
  var _props$reconnectChatP4;
58
57
  TelemetryHelper.logSDKEvent(LogLevel.INFO, {
@@ -65,13 +64,13 @@ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticat
65
64
  // Get auth token for getting chat reconnect context
66
65
  if (isAuthenticatedChat) {
67
66
  // handle authentication will throw error if auth token is not available, so no need to check for response
68
- await handleAuthentication(chatSDK, chatConfig, props.getAuthToken);
67
+ await handleAuthentication(facadeChatSDK.getChatSDK(), chatConfig, props.getAuthToken);
69
68
  }
70
- const reconnectChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatReconnectContext(chatReconnectOptionalParams));
69
+ const reconnectChatContext = await (facadeChatSDK === null || facadeChatSDK === void 0 ? void 0 : facadeChatSDK.getChatReconnectContext(chatReconnectOptionalParams));
71
70
  if (isAuthenticatedChat) {
72
71
  // remove auth token after reconnectId is fetched
73
72
  // AuthToken will be reset later at start chat
74
- removeAuthTokenProvider(chatSDK);
73
+ removeAuthTokenProvider(facadeChatSDK.getChatSDK());
75
74
  }
76
75
  return reconnectChatContext;
77
76
  }
@@ -87,14 +86,14 @@ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticat
87
86
 
88
87
  // when auth token is not available, propagate the error to stop the execution and ensure error pane is loaded
89
88
  if ((error === null || error === void 0 ? void 0 : error.message) == WidgetLoadCustomErrorString.AuthenticationFailedErrorString) {
90
- handleStartChatError(dispatch, chatSDK, props, new Error(WidgetLoadCustomErrorString.AuthenticationFailedErrorString), false);
89
+ handleStartChatError(dispatch, facadeChatSDK, props, new Error(WidgetLoadCustomErrorString.AuthenticationFailedErrorString), false);
91
90
  throw error;
92
91
  }
93
92
  }
94
93
  };
95
94
 
96
95
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
97
- const setReconnectIdAndStartChat = async (isAuthenticatedChat, chatSDK, state, props, dispatch, setAdapter, reconnectId, initStartChat) => {
96
+ const setReconnectIdAndStartChat = async (isAuthenticatedChat, facadeChatSDK, state, props, dispatch, setAdapter, reconnectId, initStartChat) => {
98
97
  if (!isAuthenticatedChat) {
99
98
  const startUnauthenticatedReconnectChat = {
100
99
  eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
@@ -112,7 +111,7 @@ const setReconnectIdAndStartChat = async (isAuthenticatedChat, chatSDK, state, p
112
111
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
113
112
  payload: ConversationState.Loading
114
113
  });
115
- await initStartChat(chatSDK, dispatch, setAdapter, state, props, optionalParams);
114
+ await initStartChat(facadeChatSDK, dispatch, setAdapter, state, props, optionalParams);
116
115
  };
117
116
  const redirectPage = (redirectURL, redirectInSameWindow) => {
118
117
  const redirectPageRequest = {
@@ -1,10 +1,10 @@
1
1
  import { Constants, ParticipantType, PostChatSurveyTelemetryMessage } from "../../../common/Constants";
2
2
  import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
- import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
4
- import { addDelayInMs } from "../../../common/utils";
5
3
  import { ConversationState } from "../../../contexts/common/ConversationState";
6
4
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
7
5
  import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
6
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
7
+ import { addDelayInMs } from "../../../common/utils";
8
8
  import { isPostChatSurveyEnabled } from "./liveChatConfigUtils";
9
9
 
10
10
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -100,14 +100,14 @@ const isPostChatEnabled = (props, state) => {
100
100
  };
101
101
 
102
102
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
103
- const getPostChatContext = async (chatSDK, state, dispatch) => {
103
+ const getPostChatContext = async (facadeChatSDK, state, dispatch) => {
104
104
  try {
105
- const postChatEnabled = await isPostChatSurveyEnabled(chatSDK);
105
+ const postChatEnabled = await isPostChatSurveyEnabled(facadeChatSDK);
106
106
  if (postChatEnabled) {
107
107
  var _state$domainStates2;
108
108
  if ((state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.postChatContext) === undefined) {
109
109
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
110
- const context = await chatSDK.getPostChatSurveyContext();
110
+ const context = await facadeChatSDK.getPostChatSurveyContext();
111
111
  TelemetryHelper.logSDKEvent(LogLevel.INFO, {
112
112
  Event: TelemetryEvent.PostChatContextCallSucceed,
113
113
  Description: PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
@@ -2,18 +2,18 @@ import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryCon
2
2
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
3
3
  import { ConversationState } from "../../../contexts/common/ConversationState";
4
4
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
5
- import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
6
5
  import { PostChatSurveyTelemetryMessage } from "../../../common/Constants";
6
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
7
7
  import { isPostChatSurveyEnabled } from "./liveChatConfigUtils";
8
8
 
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
- export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat) => {
10
+ export const setPostChatContextAndLoadSurvey = async (facadeChatSDK, dispatch, persistedChat) => {
11
11
  try {
12
- const postChatEnabled = await isPostChatSurveyEnabled(chatSDK);
12
+ const postChatEnabled = await isPostChatSurveyEnabled(facadeChatSDK);
13
13
  if (postChatEnabled) {
14
14
  if (!persistedChat) {
15
15
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
- const context = await chatSDK.getPostChatSurveyContext();
16
+ const context = await facadeChatSDK.getPostChatSurveyContext();
17
17
  TelemetryHelper.logSDKEvent(LogLevel.INFO, {
18
18
  Event: TelemetryEvent.PostChatContextCallSucceed,
19
19
  Description: PostChatSurveyTelemetryMessage.PostChatContextCallSucceed