@microsoft/omnichannel-chat-widget 1.8.4-main.cbab5fc → 1.8.4-main.cc63f01

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 (143) hide show
  1. package/README.md +13 -3
  2. package/lib/cjs/common/Constants.js +5 -0
  3. package/lib/cjs/common/facades/FacadeChatSDK.js +235 -9
  4. package/lib/cjs/common/telemetry/TelemetryConstants.js +14 -0
  5. package/lib/cjs/common/telemetry/TelemetryManager.js +6 -1
  6. package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +7 -7
  7. package/lib/cjs/common/telemetry/sanitizeSasInPayload.js +82 -0
  8. package/lib/cjs/common/utils/xssUtils.js +23 -51
  9. package/lib/cjs/common/utils.js +106 -17
  10. package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +8 -1
  11. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -1
  12. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +36 -13
  13. package/lib/cjs/components/errorboundary/ErrorBoundary.js +2 -1
  14. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +9 -1
  15. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +23 -6
  16. package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +1 -0
  17. package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +9 -0
  18. package/lib/cjs/components/livechatwidget/common/authHelper.js +44 -4
  19. package/lib/cjs/components/livechatwidget/common/createAdapter.js +3 -2
  20. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +98 -5
  21. package/lib/cjs/components/livechatwidget/common/endChat.js +6 -0
  22. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +186 -1
  23. package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +36 -4
  24. package/lib/cjs/components/livechatwidget/common/startChat.js +31 -14
  25. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +124 -5
  26. package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +15 -3
  27. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +7 -4
  28. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +68 -2
  29. package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +2 -1
  30. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +0 -1
  31. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +157 -34
  32. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +10 -0
  33. package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +117 -16
  34. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -0
  35. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -1
  36. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +5 -1
  37. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +2 -2
  38. package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +3 -1
  39. package/lib/cjs/components/webchatcontainerstateful/common/utils/citationA11y.js +195 -0
  40. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +13 -2
  41. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +160 -167
  42. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +27 -8
  43. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  44. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.js +203 -0
  45. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  46. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +8 -3
  47. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +8 -1
  48. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +5 -13
  49. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.js +81 -0
  50. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +29 -1
  51. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +52 -8
  52. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +55 -1
  53. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
  54. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +17 -1
  55. package/lib/cjs/contexts/createReducer.js +15 -0
  56. package/lib/cjs/controller/componentController.js +13 -1
  57. package/lib/cjs/plugins/newMessageEventHandler.js +20 -3
  58. package/lib/esm/common/Constants.js +5 -0
  59. package/lib/esm/common/facades/FacadeChatSDK.js +236 -10
  60. package/lib/esm/common/telemetry/TelemetryConstants.js +14 -0
  61. package/lib/esm/common/telemetry/TelemetryManager.js +6 -1
  62. package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +7 -7
  63. package/lib/esm/common/telemetry/sanitizeSasInPayload.js +75 -0
  64. package/lib/esm/common/utils/xssUtils.js +23 -51
  65. package/lib/esm/common/utils.js +99 -14
  66. package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +8 -1
  67. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -1
  68. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +37 -14
  69. package/lib/esm/components/errorboundary/ErrorBoundary.js +4 -2
  70. package/lib/esm/components/livechatwidget/LiveChatWidget.js +9 -1
  71. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +23 -6
  72. package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +1 -0
  73. package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +9 -0
  74. package/lib/esm/components/livechatwidget/common/authHelper.js +44 -4
  75. package/lib/esm/components/livechatwidget/common/createAdapter.js +3 -2
  76. package/lib/esm/components/livechatwidget/common/createMarkdown.js +98 -5
  77. package/lib/esm/components/livechatwidget/common/endChat.js +6 -0
  78. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +186 -1
  79. package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +33 -2
  80. package/lib/esm/components/livechatwidget/common/startChat.js +31 -14
  81. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +125 -6
  82. package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +16 -4
  83. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +7 -4
  84. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +69 -3
  85. package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +2 -1
  86. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -2
  87. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +158 -35
  88. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +10 -0
  89. package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +117 -16
  90. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -0
  91. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -1
  92. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +5 -1
  93. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +2 -2
  94. package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +3 -1
  95. package/lib/esm/components/webchatcontainerstateful/common/utils/citationA11y.js +188 -0
  96. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +13 -2
  97. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +160 -171
  98. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +24 -6
  99. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  100. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.js +195 -0
  101. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  102. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +8 -3
  103. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +8 -1
  104. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +5 -13
  105. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.js +74 -0
  106. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +29 -1
  107. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +1 -0
  108. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +52 -8
  109. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +55 -1
  110. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
  111. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +17 -1
  112. package/lib/esm/contexts/createReducer.js +15 -0
  113. package/lib/esm/controller/componentController.js +13 -1
  114. package/lib/esm/plugins/newMessageEventHandler.js +20 -3
  115. package/lib/types/common/Constants.d.ts +4 -0
  116. package/lib/types/common/facades/FacadeChatSDK.d.ts +29 -0
  117. package/lib/types/common/facades/types/IFacadeChatSDKInput.d.ts +3 -1
  118. package/lib/types/common/telemetry/TelemetryConstants.d.ts +14 -2
  119. package/lib/types/common/telemetry/sanitizeSasInPayload.d.ts +24 -0
  120. package/lib/types/common/utils/xssUtils.d.ts +5 -21
  121. package/lib/types/common/utils.d.ts +12 -2
  122. package/lib/types/components/errorboundary/ErrorBoundary.d.ts +1 -1
  123. package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +1 -0
  124. package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +2 -1
  125. package/lib/types/components/livechatwidget/common/authHelper.d.ts +9 -2
  126. package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +11 -0
  127. package/lib/types/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.d.ts +1 -0
  128. package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +1 -1
  129. package/lib/types/components/webchatcontainerstateful/common/utils/citationA11y.d.ts +1 -0
  130. package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +3 -0
  131. package/lib/types/components/webchatcontainerstateful/interfaces/IBotAuthConfig.d.ts +7 -0
  132. package/lib/types/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.d.ts +1 -1
  133. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +7 -0
  134. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +14 -38
  135. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -0
  136. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.d.ts +18 -0
  137. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.d.ts +3 -0
  138. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.d.ts +12 -0
  139. package/lib/types/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.d.ts +7 -0
  140. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  141. package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +17 -0
  142. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
  143. package/package.json +37 -9
@@ -3,11 +3,22 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.removeAuthTokenProvider = exports.handleAuthentication = exports.getAuthClientFunction = void 0;
6
+ exports.removeAuthTokenProvider = exports.isMidAuthEnabled = exports.handleAuthentication = exports.getAuthClientFunction = void 0;
7
7
  var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
8
8
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
9
9
  var _Constants = require("../../../common/Constants");
10
10
  var _utils = require("../../../common/utils");
11
+ /**
12
+ * Check if mid-auth is enabled based on chatConfig.
13
+ * Mid-auth flag lives under LiveWSAndLiveChatEngJoin.msdyn_authenticatedsigninoptional.
14
+ */
15
+ const isMidAuthEnabled = chatConfig => {
16
+ var _chatConfig$LiveWSAnd, _value$toString, _value$toString$call$, _value$toString$call;
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ const value = chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig$LiveWSAnd = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd === void 0 ? void 0 : _chatConfig$LiveWSAnd.msdyn_authenticatedsigninoptional;
19
+ return (value === null || value === void 0 ? void 0 : (_value$toString = value.toString) === null || _value$toString === void 0 ? void 0 : (_value$toString$call$ = (_value$toString$call = _value$toString.call(value)).toLowerCase) === null || _value$toString$call$ === void 0 ? void 0 : _value$toString$call$.call(_value$toString$call)) === "true";
20
+ };
21
+ exports.isMidAuthEnabled = isMidAuthEnabled;
11
22
  const getAuthClientFunction = chatConfig => {
12
23
  let authClientFunction = undefined;
13
24
  if (chatConfig !== null && chatConfig !== void 0 && chatConfig.LiveChatConfigAuthSettings) {
@@ -19,12 +30,17 @@ const getAuthClientFunction = chatConfig => {
19
30
  exports.getAuthClientFunction = getAuthClientFunction;
20
31
  const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
21
32
  var _chatSDK$chatSDKConfi;
33
+ const midAuthEnabled = isMidAuthEnabled(chatConfig);
22
34
  const authClientFunction = getAuthClientFunction(chatConfig);
23
35
  if (getAuthToken && authClientFunction) {
24
36
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
25
37
  Event: _TelemetryConstants.TelemetryEvent.GetAuthTokenCalled
26
38
  });
27
- const token = await getAuthToken(authClientFunction);
39
+
40
+ // Only pass isMidAuthEnabled option when mid-auth is enabled.
41
+ const token = midAuthEnabled ? await getAuthToken(authClientFunction, {
42
+ isMidAuthEnabled: midAuthEnabled
43
+ }) : await getAuthToken(authClientFunction);
28
44
  if (!(0, _utils.isNullOrEmptyString)(token)) {
29
45
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
46
  chatSDK.setAuthTokenProvider(async () => {
@@ -35,8 +51,21 @@ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
35
51
  "token": token
36
52
  };
37
53
  } else {
38
- // instead of returning false, it's more appropiate to thrown an error to force error handling on the caller side
39
- // this will help to avoid the error to be ignored and the chat to be started
54
+ // For mid-auth scenarios, empty token means "user not signed in" - this is expected behavior.
55
+ // Return result: true with empty token so caller can decide to proceed unauthenticated.
56
+ if (midAuthEnabled) {
57
+ // Expected behavior for mid-auth: user not signed in
58
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
59
+ Event: _TelemetryConstants.TelemetryEvent.GetAuthTokenCalled,
60
+ Description: "Mid-auth: token provider returned empty; user not signed in"
61
+ });
62
+ return {
63
+ "result": true,
64
+ "token": null
65
+ };
66
+ }
67
+
68
+ // For non-mid-auth scenarios, empty token is an error
40
69
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
41
70
  Event: _TelemetryConstants.TelemetryEvent.ReceivedNullOrEmptyToken
42
71
  });
@@ -46,6 +75,17 @@ const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
46
75
  var _chatSDK$chatSDKConfi2;
47
76
  const token = await ((_chatSDK$chatSDKConfi2 = chatSDK.chatSDKConfig) === null || _chatSDK$chatSDKConfi2 === void 0 ? void 0 : _chatSDK$chatSDKConfi2.getAuthToken());
48
77
  if ((0, _utils.isNullOrEmptyString)(token)) {
78
+ // For mid-auth scenarios, empty token from SDK's getAuthToken is also expected
79
+ if (midAuthEnabled) {
80
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
81
+ Event: _TelemetryConstants.TelemetryEvent.GetAuthTokenCalled,
82
+ Description: "Mid-auth: SDK getAuthToken returned empty; user not signed in"
83
+ });
84
+ return {
85
+ "result": true,
86
+ "token": null
87
+ };
88
+ }
49
89
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
50
90
  Event: _TelemetryConstants.TelemetryEvent.ReceivedNullOrEmptyToken,
51
91
  Description: "getAuthToken in chat SDK returns empty string"
@@ -45,10 +45,11 @@ const createAdapter = async (facadeChatSDK, props) => {
45
45
  //so far, there is no need to convert to the shim adapter when using visual tests
46
46
  const isMocked = facadeChatSDK.getChatSDK() instanceof _mockchatsdk.MockChatSDK;
47
47
  if (isMocked !== true) {
48
- var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4;
48
+ var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _props$webChatContain5, _props$webChatContain6;
49
49
  const botAuthActivitySubscriberOptionalParams = {
50
50
  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,
51
- fetchBotAuthConfigRetryInterval: (props === null || props === void 0 ? void 0 : (_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : (_props$webChatContain4 = _props$webChatContain3.botAuthConfig) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.fetchBotAuthConfigRetryInterval) || defaultBotAuthConfig.fetchBotAuthConfigRetryInterval
51
+ fetchBotAuthConfigRetryInterval: (props === null || props === void 0 ? void 0 : (_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : (_props$webChatContain4 = _props$webChatContain3.botAuthConfig) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.fetchBotAuthConfigRetryInterval) || defaultBotAuthConfig.fetchBotAuthConfigRetryInterval,
52
+ fallbackShowSignInCard: props === null || props === void 0 ? void 0 : (_props$webChatContain5 = props.webChatContainerProps) === null || _props$webChatContain5 === void 0 ? void 0 : (_props$webChatContain6 = _props$webChatContain5.botAuthConfig) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.fallbackShowSignInCard
52
53
  };
53
54
  adapter = new _ChatAdapterShim.ChatAdapterShim(adapter);
54
55
  adapter.addSubscriber(new _AddActivitySubscriber.AddActivitySubscriber());
@@ -42,10 +42,8 @@ const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdown
42
42
 
43
43
  markdown.disable(["strikethrough"]);
44
44
 
45
- // Custom plugin to fix numbered list continuity
45
+ // Custom plugin to fix numbered list continuity and merge adjacent markdown links with the same href.
46
46
  markdown.use(function (md) {
47
- const originalRender = md.render.bind(md);
48
- const originalRenderInline = md.renderInline.bind(md);
49
47
  function preprocessText(text) {
50
48
  // Handle numbered lists that come with double line breaks (knowledge article format)
51
49
  // This ensures proper continuous numbering instead of separate lists
@@ -80,16 +78,111 @@ const createMarkdown = (disableMarkdownMessageFormatting, disableNewLineMarkdown
80
78
  return result;
81
79
  }
82
80
 
81
+ // Accessibility fix: when a bot emits content like "[1.](url) [View details](url)",
82
+ // markdown-it renders two sibling links that screen readers announce as two separate
83
+ // focusable links. Merge consecutive markdown link tokens with identical attributes so
84
+ // the number and label form one combined focusable link without discarding metadata.
85
+ md.core.ruler.after("inline", "merge_adjacent_same_href_links", function (state) {
86
+ const sortedAttrs = token => (token.attrs || []).map(attr => `${attr[0]}=${attr[1]}`).sort();
87
+ const hasSameAttributes = (first, second) => {
88
+ const firstAttrs = sortedAttrs(first);
89
+ const secondAttrs = sortedAttrs(second);
90
+ return firstAttrs.length === secondAttrs.length && firstAttrs.every((attr, index) => attr === secondAttrs[index]);
91
+ };
92
+ const collectLink = (children, index) => {
93
+ var _open$attrGet;
94
+ const open = children[index];
95
+ if (!open || open.type !== "link_open") {
96
+ return undefined;
97
+ }
98
+ const href = (_open$attrGet = open.attrGet) === null || _open$attrGet === void 0 ? void 0 : _open$attrGet.call(open, "href");
99
+ if (!href) {
100
+ return undefined;
101
+ }
102
+ let depth = 0;
103
+ for (let currentIndex = index; currentIndex < children.length; currentIndex++) {
104
+ const token = children[currentIndex];
105
+ if (token.type === "link_open") {
106
+ depth++;
107
+ } else if (token.type === "link_close") {
108
+ depth--;
109
+ if (depth === 0) {
110
+ return {
111
+ closeIndex: currentIndex,
112
+ href,
113
+ open
114
+ };
115
+ }
116
+ }
117
+ }
118
+ return undefined;
119
+ };
120
+ const getNextAdjacentLink = (children, startIndex) => {
121
+ const separatorTokens = [];
122
+ let index = startIndex;
123
+ while (index < children.length && children[index].type === "text" && /^\s*$/.test(children[index].content || "")) {
124
+ separatorTokens.push(children[index]);
125
+ index++;
126
+ }
127
+ const link = collectLink(children, index);
128
+ if (!link) {
129
+ return undefined;
130
+ }
131
+ return {
132
+ ...link,
133
+ openIndex: index,
134
+ separatorTokens
135
+ };
136
+ };
137
+ state.tokens.forEach(blockToken => {
138
+ if (blockToken.type !== "inline" || !blockToken.children) {
139
+ return;
140
+ }
141
+ const mergedChildren = [];
142
+ const children = blockToken.children;
143
+ let index = 0;
144
+ while (index < children.length) {
145
+ const firstLink = collectLink(children, index);
146
+ if (!firstLink) {
147
+ mergedChildren.push(children[index]);
148
+ index++;
149
+ continue;
150
+ }
151
+ const linkTokens = [firstLink.open, ...children.slice(index + 1, firstLink.closeIndex)];
152
+ let nextIndex = firstLink.closeIndex + 1;
153
+ let mergedAnyLink = false;
154
+ let nextLink = getNextAdjacentLink(children, nextIndex);
155
+ while (nextLink && nextLink.href === firstLink.href && hasSameAttributes(firstLink.open, nextLink.open)) {
156
+ linkTokens.push(...nextLink.separatorTokens);
157
+ linkTokens.push(...children.slice(nextLink.openIndex + 1, nextLink.closeIndex));
158
+ nextIndex = nextLink.closeIndex + 1;
159
+ mergedAnyLink = true;
160
+ nextLink = getNextAdjacentLink(children, nextIndex);
161
+ }
162
+ if (mergedAnyLink) {
163
+ mergedChildren.push(...linkTokens, children[firstLink.closeIndex]);
164
+ index = nextIndex;
165
+ } else {
166
+ mergedChildren.push(children[index]);
167
+ index++;
168
+ }
169
+ }
170
+ blockToken.children = mergedChildren;
171
+ });
172
+ });
173
+
83
174
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
84
175
  md.render = function (text, env) {
176
+ const safeEnv = env ?? {};
85
177
  const processedText = preprocessText(text);
86
- return originalRender(processedText, env);
178
+ return md.renderer.render(md.parse(processedText, safeEnv), md.options, safeEnv);
87
179
  };
88
180
 
89
181
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
90
182
  md.renderInline = function (text, env) {
183
+ const safeEnv = env ?? {};
91
184
  const processedText = preprocessText(text);
92
- return originalRenderInline(processedText, env);
185
+ return md.renderer.render(md.parseInline(processedText, safeEnv), md.options, safeEnv);
93
186
  };
94
187
  });
95
188
 
@@ -11,6 +11,7 @@ var _renderSurveyHelpers = require("./renderSurveyHelpers");
11
11
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
12
12
  var _ConversationState = require("../../../contexts/common/ConversationState");
13
13
  var _LazyLoadActivity = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity");
14
+ var _activityMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware");
14
15
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
15
16
  var _NotificationHandler = require("../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler");
16
17
  var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios");
@@ -249,6 +250,7 @@ const endChat = async (props, facadeChatSDK, state, dispatch, setAdapter, setWeb
249
250
 
250
251
  // Call direct reset to ensure LazyLoadHandler gets reset regardless of broadcast timing
251
252
  _LazyLoadActivity.LazyLoadHandler.directReset();
253
+ (0, _activityMiddleware.resetActivityMiddlewareCache)();
252
254
  _omnichannelChatComponents.BroadcastService.postMessage({
253
255
  eventName: _TelemetryConstants.BroadcastEvent.PersistentConversationReset
254
256
  });
@@ -344,6 +346,10 @@ const closeChatStateCleanUp = dispatch => {
344
346
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CITATIONS,
345
347
  payload: {}
346
348
  });
349
+ dispatch({
350
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SHOW_EMAIL_TRANSCRIPT_PANE,
351
+ payload: false
352
+ });
347
353
 
348
354
  // Dismiss the chat disconnect notification banner if it was shown
349
355
  _NotificationHandler.NotificationHandler.dismissNotification(_NotificationScenarios.NotificationScenarios.ChatDisconnect);
@@ -16,6 +16,7 @@ var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidget
16
16
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
17
17
  var _WebChatStoreLoader = require("../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader");
18
18
  var _attachmentProcessingMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware"));
19
+ var _attachmentSentAnnouncementMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware"));
19
20
  var _channelDataMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware"));
20
21
  var _activityMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware");
21
22
  var _activityStatusMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware");
@@ -125,7 +126,7 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
125
126
  };
126
127
  webChatStore = (0, _botframeworkWebchat.createStore)({},
127
128
  //initial state
128
- _preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), (0, _customEventMiddleware.default)(_omnichannelChatComponents.BroadcastService), (0, _queueOverflowHandlerMiddleware.createQueueOverflowMiddleware)(state, dispatch), (0, _channelDataMiddleware.default)(addConversationalSurveyTagsCallback), (0, _conversationEndMiddleware.default)(conversationEndCallback, startConversationalSurveyCallback, endConversationalSurveyCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), _messageTimestampMiddleware.createMessageTimeStampMiddleware, _messageSequenceIdOverrideMiddleware.createMessageSequenceIdOverrideMiddleware, (0, _citationsMiddleware.createCitationsMiddleware)(state, dispatch), _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, (0, _htmlTextMiddleware.default)(honorsTargetInHTMLLinks), (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default, (0, _callActionMiddleware.default)(),
129
+ _preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), _attachmentSentAnnouncementMiddleware.default, (0, _customEventMiddleware.default)(_omnichannelChatComponents.BroadcastService), (0, _queueOverflowHandlerMiddleware.createQueueOverflowMiddleware)(state, dispatch), (0, _channelDataMiddleware.default)(addConversationalSurveyTagsCallback), (0, _conversationEndMiddleware.default)(conversationEndCallback, startConversationalSurveyCallback, endConversationalSurveyCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), _messageTimestampMiddleware.createMessageTimeStampMiddleware, _messageSequenceIdOverrideMiddleware.createMessageSequenceIdOverrideMiddleware, (0, _citationsMiddleware.createCitationsMiddleware)(state, dispatch), _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, (0, _htmlTextMiddleware.default)(honorsTargetInHTMLLinks), (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default, (0, _callActionMiddleware.default)(),
129
130
  // Pass a callback so middleware can push initials into React context for reactivity
130
131
  (0, _localizedStringsBotInitialsMiddleware.localizedStringsBotInitialsMiddleware)(initials => {
131
132
  dispatch({
@@ -151,14 +152,198 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
151
152
  markdownRenderers.forEach(renderer => {
152
153
  text = renderer.render(text);
153
154
  });
155
+
156
+ // EXISTING sanitization (continues to work as before)
154
157
  const config = {
155
158
  FORBID_TAGS: ["form", "button", "script", "div", "input"],
156
159
  FORBID_ATTR: ["action"],
157
160
  ADD_ATTR: ["target"]
158
161
  };
159
162
  text = _dompurify.default.sanitize(text, config);
163
+
164
+ // MONITOR-ONLY: Test what the stricter allowlist would remove (Phase 1)
165
+ // This does NOT modify the text, only logs telemetry
166
+ // Run during browser idle time to avoid blocking message flow and adding latency
167
+ const textToMonitor = text; // Capture current text value
168
+
169
+ // Schedule monitoring to run during browser idle time
170
+ const scheduleMonitoring = () => {
171
+ try {
172
+ monitorStrictSanitization(textToMonitor, state);
173
+ } catch (error) {
174
+ // Silently catch errors to prevent blocking message flow
175
+ if (process.env.NODE_ENV === "development") {
176
+ console.error("[Monitor] HTML sanitization monitoring failed:", error);
177
+ }
178
+ }
179
+ };
180
+
181
+ // Use requestIdleCallback for truly idle execution, fallback to setTimeout for older browsers
182
+ if (typeof window !== "undefined" && "requestIdleCallback" in window) {
183
+ window.requestIdleCallback(scheduleMonitoring);
184
+ } else {
185
+ setTimeout(scheduleMonitoring, 0);
186
+ }
160
187
  return text;
161
188
  };
189
+
190
+ /**
191
+ * Monitor-only sanitization (Phase 1: Gather telemetry)
192
+ * Tests what a stricter allowlist-based sanitization would remove
193
+ * WITHOUT actually removing it. Logs telemetry for analysis.
194
+ *
195
+ * IMPORTANT: This function is wrapped in try-catch and runs asynchronously
196
+ * to ensure failures don't block message flow or add latency.
197
+ *
198
+ * ISOLATION: Uses a separate DOMPurify instance to completely isolate
199
+ * monitoring hooks from other sanitization paths (e.g., postDomPurifyActivities).
200
+ * The instance is garbage collected after use, no cleanup needed.
201
+ *
202
+ * @param html - The HTML text that was already sanitized with existing config
203
+ * @param state - Widget state containing orgId and chatId
204
+ */
205
+ const monitorStrictSanitization = (html, state) => {
206
+ // Early exit for empty content
207
+ if (!html) return;
208
+
209
+ // Track execution time for performance monitoring
210
+ const startTime = performance.now();
211
+ try {
212
+ // Create a separate DOMPurify instance for monitoring
213
+ // This completely isolates monitoring from other sanitization paths
214
+ const monitorDOMPurify = (0, _dompurify.default)(window);
215
+
216
+ // Strict allowlist configuration (proposed new rules)
217
+ // Note: DOMPurify blocks event handlers (onclick, onerror, etc.) by default
218
+ const strictConfig = {
219
+ ALLOWED_TAGS: ["b", "strong",
220
+ // Bold text
221
+ "i", "em", "u",
222
+ // Italic, emphasis, underline
223
+ "br", "p",
224
+ // Line breaks and paragraphs
225
+ "ul", "ol", "li",
226
+ // Lists
227
+ "a" // Links (with restricted attributes)
228
+ ],
229
+
230
+ ALLOWED_ATTR: ["href",
231
+ // For links (will be restricted to http/https)
232
+ "target",
233
+ // For link behavior
234
+ "rel" // For security (noopener, noreferrer)
235
+ ],
236
+
237
+ FORBID_TAGS: ["img", "video", "audio",
238
+ // Media (tracking beacons)
239
+ "iframe", "object", "embed",
240
+ // Embedded content
241
+ "script", "style",
242
+ // Script and styling
243
+ "form", "input", "textarea", "button",
244
+ // Form elements
245
+ "link", "meta", "base",
246
+ // Document metadata
247
+ "div", "span" // Layout elements
248
+ ],
249
+
250
+ FORBID_ATTR: ["style",
251
+ // Inline CSS
252
+ "action" // Form action attribute (event handlers blocked by default)
253
+ ],
254
+
255
+ ALLOWED_URI_REGEXP: /^https?:/i,
256
+ ALLOW_DATA_ATTR: false,
257
+ ALLOW_UNKNOWN_PROTOCOLS: false
258
+ };
259
+
260
+ // Track what would be removed
261
+ const removedTags = [];
262
+ const removedAttributes = [];
263
+
264
+ // Add hooks to the isolated monitoring instance
265
+ monitorDOMPurify.addHook("uponSanitizeElement", (node, data) => {
266
+ try {
267
+ const tagName = data.tagName.toLowerCase();
268
+ // Filter out "body" tag which is DOMPurify's internal wrapper
269
+ if (node.nodeType === 1 && !strictConfig.ALLOWED_TAGS.includes(tagName) && tagName !== "body") {
270
+ removedTags.push(tagName);
271
+ }
272
+ } catch (hookError) {
273
+ // Silently ignore hook errors
274
+ }
275
+ });
276
+ monitorDOMPurify.addHook("uponSanitizeAttribute", (node, data) => {
277
+ try {
278
+ const attrName = data.attrName.toLowerCase();
279
+ if (!strictConfig.ALLOWED_ATTR.includes(attrName) && attrName !== "class" && attrName !== "id") {
280
+ removedAttributes.push(attrName);
281
+ }
282
+ } catch (hookError) {
283
+ // Silently ignore hook errors
284
+ }
285
+ });
286
+
287
+ // Run sanitization on the isolated instance (we discard the result)
288
+ // No cleanup needed - the instance will be garbage collected with its hooks
289
+ monitorDOMPurify.sanitize(html, strictConfig);
290
+
291
+ // Log telemetry if content would be affected by strict rules
292
+ if (removedTags.length > 0 || removedAttributes.length > 0) {
293
+ try {
294
+ var _state$domainStates, _state$domainStates$t, _state$domainStates2, _state$domainStates2$;
295
+ const uniqueTags = [...new Set(removedTags)];
296
+ const uniqueAttrs = [...new Set(removedAttributes)];
297
+
298
+ // Calculate execution time
299
+ const endTime = performance.now();
300
+ const executionTimeMs = Math.round((endTime - startTime) * 100) / 100; // Round to 2 decimal places
301
+
302
+ // Get context for telemetry (with safe fallbacks)
303
+ const orgId = (state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$t = _state$domainStates.telemetryInternalData) === null || _state$domainStates$t === void 0 ? void 0 : _state$domainStates$t.orgId) || "unknown";
304
+ const conversationId = (state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : (_state$domainStates2$ = _state$domainStates2.chatToken) === null || _state$domainStates2$ === void 0 ? void 0 : _state$domainStates2$.chatId) || "unknown";
305
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
306
+ Event: _TelemetryConstants.TelemetryEvent.HTMLSanitized,
307
+ Description: JSON.stringify({
308
+ message: "HTML content would be sanitized by stricter allowlist (monitor-only)",
309
+ removedTags: uniqueTags,
310
+ removedAttributes: uniqueAttrs,
311
+ phase: "Monitor",
312
+ organizationId: orgId,
313
+ conversationId: conversationId
314
+ }),
315
+ ElapsedTimeInMilliseconds: executionTimeMs
316
+ });
317
+
318
+ // Log to console in development for debugging
319
+ if (process.env.NODE_ENV === "development") {
320
+ console.warn("[Monitor] Stricter HTML sanitization telemetry:", {
321
+ description: JSON.parse(JSON.stringify({
322
+ message: "HTML content would be sanitized by stricter allowlist (monitor-only)",
323
+ removedTags: uniqueTags,
324
+ removedAttributes: uniqueAttrs,
325
+ phase: "Monitor"
326
+ })),
327
+ orgId,
328
+ conversationId,
329
+ executionTimeMs
330
+ });
331
+ }
332
+ } catch (telemetryError) {
333
+ // Silently ignore telemetry errors to prevent blocking
334
+ if (process.env.NODE_ENV === "development") {
335
+ console.error("[Monitor] Telemetry logging failed:", telemetryError);
336
+ }
337
+ }
338
+ }
339
+ } catch (error) {
340
+ // Catch-all for any unexpected errors
341
+ // Silently fail to ensure monitoring never blocks message flow
342
+ if (process.env.NODE_ENV === "development") {
343
+ console.error("[Monitor] Monitoring failed:", error);
344
+ }
345
+ }
346
+ };
162
347
  function postDomPurifyActivities() {
163
348
  _dompurify.default.addHook("afterSanitizeAttributes", function (node) {
164
349
  const target = node.getAttribute(_Constants.Constants.Target);
@@ -3,15 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isPostChatSurveyEnabled = exports.isPersistentChatEnabled = exports.getPostChatSurveyConfig = void 0;
7
- var _Constants = require("../../../common/Constants");
6
+ exports.shouldLoadPersistentChatHistory = exports.isPostChatSurveyEnabled = exports.isPersistentChatEnabled = exports.getPostChatSurveyConfig = void 0;
8
7
  var _utils = require("../../../common/utils");
8
+ var _Constants = require("../../../common/Constants");
9
9
  const isPostChatSurveyEnabled = async facadeChatSDK => {
10
10
  var _chatConfig$LiveWSAnd;
11
11
  const chatConfig = await facadeChatSDK.getLiveChatConfig();
12
12
  const postChatEnabled = (_chatConfig$LiveWSAnd = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd === void 0 ? void 0 : _chatConfig$LiveWSAnd.msdyn_postconversationsurveyenable.toString().toLowerCase();
13
13
  return postChatEnabled === "true";
14
14
  };
15
+
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
17
  exports.isPostChatSurveyEnabled = isPostChatSurveyEnabled;
16
18
  const getPostChatSurveyConfig = async facadeChatSDK => {
17
19
  var _chatConfig$LiveWSAnd2, _chatConfig$LiveWSAnd3, _chatConfig$LiveWSAnd4, _chatConfig$LiveWSAnd5, _chatConfig$LiveWSAnd6, _chatConfig$LiveWSAnd7, _chatConfig$LiveWSAnd8, _chatConfig$LiveWSAnd9, _chatConfig$LiveWSAnd10;
@@ -34,6 +36,36 @@ const isPersistentChatEnabled = conversationMode => {
34
36
  if ((0, _utils.isNullOrUndefined)(conversationMode)) {
35
37
  return false;
36
38
  }
37
- return (conversationMode === null || conversationMode === void 0 ? void 0 : conversationMode.toString().toLowerCase()) === _Constants.ConversationMode.Persistent;
39
+ return (conversationMode === null || conversationMode === void 0 ? void 0 : conversationMode.toString()) === _Constants.ConversationMode.Persistent;
40
+ };
41
+
42
+ /**
43
+ * Determines if persistent chat history should be loaded based on all required conditions.
44
+ *
45
+ * @param extendedChatConfig - The extended chat configuration object
46
+ * @returns true if ALL conditions are met:
47
+ * 1. Conversation mode must be Persistent ("192350001")
48
+ * 2. History is enabled in admin config (msdyn_enablepersistentchatpreviousconversations)
49
+ * 3. History is enabled via feature flag (lcwPersistentChatHistoryEnabled)
50
+ */
51
+ exports.isPersistentChatEnabled = isPersistentChatEnabled;
52
+ const shouldLoadPersistentChatHistory = extendedChatConfig => {
53
+ var _extendedChatConfig$L, _extendedChatConfig$L2, _extendedChatConfig$L3;
54
+ // CRITICAL: First check if conversation mode is persistent
55
+ // Only persistent mode ("192350001") should allow history loading
56
+ const isPersistentChatEnabledForWidget = isPersistentChatEnabled(extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L = extendedChatConfig.LiveWSAndLiveChatEngJoin) === null || _extendedChatConfig$L === void 0 ? void 0 : _extendedChatConfig$L.msdyn_conversationmode);
57
+ if (!isPersistentChatEnabledForWidget) {
58
+ return false;
59
+ }
60
+
61
+ // Check if history is enabled in admin config (handles both boolean and string "true"/"false")
62
+ const isHistoryEnabledInConfig = (0, _utils.parseBooleanFromConfig)(extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L2 = extendedChatConfig.LiveWSAndLiveChatEngJoin) === null || _extendedChatConfig$L2 === void 0 ? void 0 : _extendedChatConfig$L2.msdyn_enablepersistentchatpreviousconversations);
63
+ if (!isHistoryEnabledInConfig) {
64
+ return false;
65
+ }
66
+
67
+ // Check if history is enabled via feature flag (handles both boolean and string "true"/"false")
68
+ const isHistoryEnabledViaFCB = (0, _utils.parseBooleanFromConfig)(extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L3 = extendedChatConfig.LcwFcbConfiguration) === null || _extendedChatConfig$L3 === void 0 ? void 0 : _extendedChatConfig$L3.lcwPersistentChatHistoryEnabled);
69
+ return isHistoryEnabledViaFCB;
38
70
  };
39
- exports.isPersistentChatEnabled = isPersistentChatEnabled;
71
+ exports.shouldLoadPersistentChatHistory = shouldLoadPersistentChatHistory;