@microsoft/omnichannel-chat-widget 1.8.2-main.5a42a08 → 1.8.2-main.c423ac4

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.
@@ -40,6 +40,7 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
40
40
  Description: _Constants.PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithoutPostChat
41
41
  });
42
42
  await endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
43
+ return;
43
44
  }
44
45
 
45
46
  // Use Case: If ended by Agent, stay chat in InActive state
@@ -12,6 +12,7 @@ var _PostChatSurveyMode = require("../../postchatsurveypanestateful/enums/PostCh
12
12
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
13
13
  var _utils = require("../../../common/utils");
14
14
  var _liveChatConfigUtils = require("./liveChatConfigUtils");
15
+ var _createReducer = require("../../../contexts/createReducer");
15
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
17
  let conversationDetails = undefined;
17
18
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -64,6 +65,13 @@ const renderSurvey = async (postChatContext, state, dispatch) => {
64
65
  // Function for embed mode postchat workflow which is essentially same for both customer and agent
65
66
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
67
  const embedModePostChatWorkflow = async (postChatContext, state, dispatch) => {
68
+ const inMemoryState = (0, _createReducer.executeReducer)(state, {
69
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
70
+ payload: null
71
+ });
72
+ if (inMemoryState.appStates.conversationState === _ConversationState.ConversationState.Closed) {
73
+ return;
74
+ }
67
75
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
68
76
  Event: _TelemetryConstants.TelemetryEvent.EmbedModePostChatWorkflowStarted
69
77
  });
@@ -84,6 +92,13 @@ const embedModePostChatWorkflow = async (postChatContext, state, dispatch) => {
84
92
  payload: _ConversationState.ConversationState.PostchatLoading
85
93
  });
86
94
  await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
95
+ const inMemoryState = (0, _createReducer.executeReducer)(state, {
96
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
97
+ payload: null
98
+ });
99
+ if (inMemoryState.appStates.conversationState === _ConversationState.ConversationState.Closed) {
100
+ return;
101
+ }
87
102
  dispatch({
88
103
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
89
104
  payload: _ConversationState.ConversationState.Postchat
@@ -102,6 +117,14 @@ const embedModePostChatWorkflow = async (postChatContext, state, dispatch) => {
102
117
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
103
118
  const initiatePostChat = async (props, conversationDetailsParam, state, dispatch, postchatContext) => {
104
119
  var _conversationDetails;
120
+ const inMemoryState = (0, _createReducer.executeReducer)(state, {
121
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
122
+ payload: null
123
+ });
124
+ if (inMemoryState.appStates.conversationState === _ConversationState.ConversationState.Closed) {
125
+ // If the conversation is closed, we need to reset the state
126
+ return;
127
+ }
105
128
  conversationDetails = conversationDetailsParam;
106
129
  const participantType = ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.participantType) ?? postchatContext.participantType;
107
130
  await setSurveyMode(props, participantType, state, dispatch);
@@ -705,10 +705,23 @@ const createChatTranscript = async function (transcript, facadeChatSDK) {
705
705
  reader.readAsDataURL(blob);
706
706
  });
707
707
  };
708
+
709
+ // Configure DOMPurify to remove target attribute from br tags
710
+ const hook = function (node) {
711
+ // eslint-disable-line @typescript-eslint/no-explicit-any
712
+ // Remove target attribute from br tags as it causes them to display as literal text
713
+ if (node.tagName === "BR" && node.hasAttribute("target")) {
714
+ node.removeAttribute("target");
715
+ }
716
+ };
717
+ _dompurify.default.addHook("afterSanitizeAttributes", hook);
708
718
  let messages = transcriptMessages.filter(message => {
709
719
  message.content = _dompurify.default.sanitize(message.content);
710
720
  return message;
711
721
  });
722
+
723
+ // Clean up the hook after processing all messages
724
+ _dompurify.default.removeHook("afterSanitizeAttributes", hook);
712
725
  if (renderAttachments) {
713
726
  messages = await Promise.all(transcriptMessages.map(async message => {
714
727
  // eslint-disable-line @typescript-eslint/no-explicit-any
@@ -35,6 +35,7 @@ const prepareEndChat = async (props, facadeChatSDK, state, dispatch, setAdapter,
35
35
  Description: PrepareEndChatDescriptionConstants.ConversationEndedByCustomerWithoutPostChat
36
36
  });
37
37
  await endChat(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
38
+ return;
38
39
  }
39
40
 
40
41
  // Use Case: If ended by Agent, stay chat in InActive state
@@ -6,6 +6,7 @@ import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostC
6
6
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
7
7
  import { addDelayInMs } from "../../../common/utils";
8
8
  import { getPostChatSurveyConfig } from "./liveChatConfigUtils";
9
+ import { executeReducer } from "../../../contexts/createReducer";
9
10
 
10
11
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
12
  let conversationDetails = undefined;
@@ -59,6 +60,13 @@ const renderSurvey = async (postChatContext, state, dispatch) => {
59
60
  // Function for embed mode postchat workflow which is essentially same for both customer and agent
60
61
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
62
  const embedModePostChatWorkflow = async (postChatContext, state, dispatch) => {
63
+ const inMemoryState = executeReducer(state, {
64
+ type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
65
+ payload: null
66
+ });
67
+ if (inMemoryState.appStates.conversationState === ConversationState.Closed) {
68
+ return;
69
+ }
62
70
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
63
71
  Event: TelemetryEvent.EmbedModePostChatWorkflowStarted
64
72
  });
@@ -79,6 +87,13 @@ const embedModePostChatWorkflow = async (postChatContext, state, dispatch) => {
79
87
  payload: ConversationState.PostchatLoading
80
88
  });
81
89
  await addDelayInMs(Constants.PostChatLoadingDurationInMs);
90
+ const inMemoryState = executeReducer(state, {
91
+ type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
92
+ payload: null
93
+ });
94
+ if (inMemoryState.appStates.conversationState === ConversationState.Closed) {
95
+ return;
96
+ }
82
97
  dispatch({
83
98
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
84
99
  payload: ConversationState.Postchat
@@ -97,6 +112,14 @@ const embedModePostChatWorkflow = async (postChatContext, state, dispatch) => {
97
112
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
113
  const initiatePostChat = async (props, conversationDetailsParam, state, dispatch, postchatContext) => {
99
114
  var _conversationDetails;
115
+ const inMemoryState = executeReducer(state, {
116
+ type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
117
+ payload: null
118
+ });
119
+ if (inMemoryState.appStates.conversationState === ConversationState.Closed) {
120
+ // If the conversation is closed, we need to reset the state
121
+ return;
122
+ }
100
123
  conversationDetails = conversationDetailsParam;
101
124
  const participantType = ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.participantType) ?? postchatContext.participantType;
102
125
  await setSurveyMode(props, participantType, state, dispatch);
@@ -700,10 +700,23 @@ const createChatTranscript = async function (transcript, facadeChatSDK) {
700
700
  reader.readAsDataURL(blob);
701
701
  });
702
702
  };
703
+
704
+ // Configure DOMPurify to remove target attribute from br tags
705
+ const hook = function (node) {
706
+ // eslint-disable-line @typescript-eslint/no-explicit-any
707
+ // Remove target attribute from br tags as it causes them to display as literal text
708
+ if (node.tagName === "BR" && node.hasAttribute("target")) {
709
+ node.removeAttribute("target");
710
+ }
711
+ };
712
+ DOMPurify.addHook("afterSanitizeAttributes", hook);
703
713
  let messages = transcriptMessages.filter(message => {
704
714
  message.content = DOMPurify.sanitize(message.content);
705
715
  return message;
706
716
  });
717
+
718
+ // Clean up the hook after processing all messages
719
+ DOMPurify.removeHook("afterSanitizeAttributes", hook);
707
720
  if (renderAttachments) {
708
721
  messages = await Promise.all(transcriptMessages.map(async message => {
709
722
  // eslint-disable-line @typescript-eslint/no-explicit-any
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.8.2-main.5a42a08",
3
+ "version": "1.8.2-main.c423ac4",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -87,7 +87,7 @@
87
87
  "@azure/core-tracing": "^1.2.0",
88
88
  "@microsoft/applicationinsights-web": "^3.3.6",
89
89
  "@microsoft/omnichannel-chat-components": "1.1.13",
90
- "@microsoft/omnichannel-chat-sdk": "^1.11.4",
90
+ "@microsoft/omnichannel-chat-sdk": "^1.11.6",
91
91
  "@opentelemetry/api": "^1.9.0",
92
92
  "abort-controller": "^3",
93
93
  "abort-controller-es5": "^2.0.1",