@microsoft/omnichannel-chat-widget 1.8.7 → 2.0.0-main.5ebd4eb

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 (251) hide show
  1. package/README.md +52 -5
  2. package/lib/cjs/common/Constants.js +5 -0
  3. package/lib/cjs/common/facades/FacadeChatSDK.js +234 -9
  4. package/lib/cjs/common/telemetry/TelemetryConstants.js +19 -0
  5. package/lib/cjs/common/telemetry/TelemetryManager.js +6 -1
  6. package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +2 -3
  7. package/lib/cjs/common/telemetry/sanitizeSasInPayload.js +91 -0
  8. package/lib/cjs/common/utils.js +93 -17
  9. package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +16 -6
  10. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +20 -10
  11. package/lib/cjs/components/citationpanestateful/CitationDim.js +2 -3
  12. package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +27 -5
  13. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +23 -3
  14. package/lib/cjs/components/dimlayer/DimLayer.js +1 -3
  15. package/lib/cjs/components/draggable/DraggableChatWidget.js +35 -15
  16. package/lib/cjs/components/draggable/DraggableEventEmitter.js +10 -1
  17. package/lib/cjs/components/draggable/DraggableEventReceiver.js +1 -3
  18. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +54 -17
  19. package/lib/cjs/components/errorboundary/ErrorBoundary.js +4 -12
  20. package/lib/cjs/components/footerstateful/FooterStateful.js +18 -9
  21. package/lib/cjs/components/footerstateful/audionotificationstateful/AudioNotificationStateful.js +2 -4
  22. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +4 -6
  23. package/lib/cjs/components/headerstateful/HeaderStateful.js +24 -12
  24. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +27 -4
  25. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +5 -11
  26. package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +1 -0
  27. package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +11 -4
  28. package/lib/cjs/components/livechatwidget/common/authHelper.js +44 -4
  29. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +98 -5
  30. package/lib/cjs/components/livechatwidget/common/endChat.js +12 -9
  31. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +182 -1
  32. package/lib/cjs/components/livechatwidget/common/recoveryEligibilityTelemetry.js +60 -0
  33. package/lib/cjs/components/livechatwidget/common/startChat.js +31 -14
  34. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +160 -21
  35. package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +16 -11
  36. package/lib/cjs/components/notificationpanestateful/NotificationPaneStateful.js +19 -12
  37. package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +13 -6
  38. package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +28 -5
  39. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +12 -5
  40. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +105 -11
  41. package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +12 -1
  42. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -7
  43. package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +16 -7
  44. package/lib/cjs/components/startchaterrorpanestateful/StartChatErrorPaneStateful.js +10 -2
  45. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +154 -29
  46. package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +10 -0
  47. package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +115 -10
  48. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -0
  49. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -1
  50. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +3 -1
  51. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +2 -2
  52. package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +3 -1
  53. package/lib/cjs/components/webchatcontainerstateful/common/utils/citationA11y.js +195 -0
  54. package/lib/cjs/components/webchatcontainerstateful/interfaces/IWebChatAction.js +17 -1
  55. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +27 -4
  56. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsEgressMiddleware.js +1 -3
  57. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsIngressMiddleware.js +1 -3
  58. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +180 -190
  59. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +3 -5
  60. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +22 -6
  61. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +12 -23
  62. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +27 -35
  63. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.js +199 -0
  64. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Attachment.js +29 -15
  65. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.js +5 -12
  66. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +1 -1
  67. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  68. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +8 -3
  69. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +8 -1
  70. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware.js +5 -8
  71. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.js +6 -4
  72. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +6 -4
  73. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +14 -12
  74. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +16 -14
  75. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +18 -30
  76. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +10 -2
  77. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/toastMiddleware.js +1 -3
  78. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +16 -12
  79. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +6 -6
  80. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.js +83 -0
  81. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +36 -8
  82. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.js +5 -1
  83. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +10 -7
  84. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +4 -0
  85. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -4
  86. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.js +5 -1
  87. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +7 -7
  88. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.js +10 -14
  89. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.js +6 -4
  90. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +13 -10
  91. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +57 -11
  92. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.js +6 -4
  93. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.js +25 -30
  94. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +10 -7
  95. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +6 -4
  96. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +55 -1
  97. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +2 -4
  98. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +5 -0
  99. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +17 -1
  100. package/lib/cjs/contexts/createReducer.js +15 -0
  101. package/lib/cjs/controller/componentController.js +13 -1
  102. package/lib/cjs/hooks/useWindowDimensions.js +13 -5
  103. package/lib/cjs/package.json +1 -0
  104. package/lib/cjs/plugins/createChatTranscript.js +3 -4
  105. package/lib/cjs/plugins/newMessageEventHandler.js +20 -3
  106. package/lib/esm/common/Constants.js +5 -0
  107. package/lib/esm/common/facades/FacadeChatSDK.js +235 -10
  108. package/lib/esm/common/telemetry/TelemetryConstants.js +19 -0
  109. package/lib/esm/common/telemetry/TelemetryManager.js +6 -1
  110. package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +2 -3
  111. package/lib/esm/common/telemetry/sanitizeSasInPayload.js +84 -0
  112. package/lib/esm/common/utils.js +88 -14
  113. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +15 -5
  114. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +19 -9
  115. package/lib/esm/components/citationpanestateful/CitationDim.js +2 -3
  116. package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +26 -4
  117. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +22 -2
  118. package/lib/esm/components/dimlayer/DimLayer.js +1 -3
  119. package/lib/esm/components/draggable/DraggableChatWidget.js +34 -14
  120. package/lib/esm/components/draggable/DraggableEventEmitter.js +10 -1
  121. package/lib/esm/components/draggable/DraggableEventReceiver.js +1 -3
  122. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +54 -17
  123. package/lib/esm/components/errorboundary/ErrorBoundary.js +4 -12
  124. package/lib/esm/components/footerstateful/FooterStateful.js +17 -8
  125. package/lib/esm/components/footerstateful/audionotificationstateful/AudioNotificationStateful.js +2 -4
  126. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +4 -6
  127. package/lib/esm/components/headerstateful/HeaderStateful.js +22 -10
  128. package/lib/esm/components/livechatwidget/LiveChatWidget.js +27 -4
  129. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +5 -11
  130. package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +1 -0
  131. package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +11 -4
  132. package/lib/esm/components/livechatwidget/common/authHelper.js +44 -4
  133. package/lib/esm/components/livechatwidget/common/createMarkdown.js +98 -5
  134. package/lib/esm/components/livechatwidget/common/endChat.js +12 -9
  135. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +182 -1
  136. package/lib/esm/components/livechatwidget/common/recoveryEligibilityTelemetry.js +52 -0
  137. package/lib/esm/components/livechatwidget/common/startChat.js +31 -14
  138. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +159 -20
  139. package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +14 -9
  140. package/lib/esm/components/notificationpanestateful/NotificationPaneStateful.js +17 -10
  141. package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +12 -5
  142. package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +28 -5
  143. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +11 -4
  144. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +105 -11
  145. package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +12 -1
  146. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +16 -6
  147. package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +15 -6
  148. package/lib/esm/components/startchaterrorpanestateful/StartChatErrorPaneStateful.js +9 -1
  149. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +154 -29
  150. package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +10 -0
  151. package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +115 -10
  152. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -0
  153. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -1
  154. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +3 -1
  155. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +2 -2
  156. package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +3 -1
  157. package/lib/esm/components/webchatcontainerstateful/common/utils/citationA11y.js +188 -0
  158. package/lib/esm/components/webchatcontainerstateful/interfaces/IWebChatAction.js +10 -1
  159. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +27 -4
  160. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsEgressMiddleware.js +1 -3
  161. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsIngressMiddleware.js +1 -3
  162. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +180 -190
  163. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +3 -5
  164. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +19 -4
  165. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +12 -23
  166. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +27 -32
  167. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.js +193 -0
  168. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Attachment.js +28 -14
  169. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.js +5 -12
  170. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +1 -1
  171. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
  172. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +8 -3
  173. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +8 -1
  174. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware.js +5 -8
  175. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.js +6 -4
  176. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +6 -4
  177. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +13 -11
  178. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +15 -13
  179. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +17 -27
  180. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +9 -1
  181. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/toastMiddleware.js +1 -3
  182. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +16 -10
  183. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +6 -6
  184. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.js +77 -0
  185. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +36 -8
  186. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.js +5 -2
  187. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +10 -7
  188. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +4 -0
  189. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -4
  190. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.js +5 -1
  191. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +7 -7
  192. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.js +10 -14
  193. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.js +6 -4
  194. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +13 -10
  195. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +57 -11
  196. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.js +6 -4
  197. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.js +25 -31
  198. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +10 -7
  199. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +6 -4
  200. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +55 -1
  201. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +2 -4
  202. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +5 -0
  203. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +17 -1
  204. package/lib/esm/contexts/createReducer.js +15 -0
  205. package/lib/esm/controller/componentController.js +13 -1
  206. package/lib/esm/hooks/useWindowDimensions.js +13 -5
  207. package/lib/esm/plugins/createChatTranscript.js +3 -4
  208. package/lib/esm/plugins/newMessageEventHandler.js +20 -3
  209. package/lib/types/common/Constants.d.ts +4 -0
  210. package/lib/types/common/facades/FacadeChatSDK.d.ts +29 -0
  211. package/lib/types/common/facades/types/IFacadeChatSDKInput.d.ts +3 -1
  212. package/lib/types/common/telemetry/TelemetryConstants.d.ts +15 -2
  213. package/lib/types/common/telemetry/sanitizeSasInPayload.d.ts +24 -0
  214. package/lib/types/common/utils.d.ts +3 -1
  215. package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +2 -1
  216. package/lib/types/components/livechatwidget/common/authHelper.d.ts +9 -2
  217. package/lib/types/components/livechatwidget/common/recoveryEligibilityTelemetry.d.ts +17 -0
  218. package/lib/types/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.d.ts +6 -0
  219. package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +1 -1
  220. package/lib/types/components/webchatcontainerstateful/common/utils/citationA11y.d.ts +1 -0
  221. package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +1 -0
  222. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatAction.d.ts +16 -1
  223. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +7 -0
  224. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +14 -38
  225. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -0
  226. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.d.ts +18 -0
  227. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.d.ts +3 -0
  228. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.d.ts +2 -4
  229. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +2 -4
  230. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.d.ts +2 -4
  231. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.d.ts +10 -0
  232. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.d.ts +2 -4
  233. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.d.ts +2 -2
  234. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.d.ts +2 -4
  235. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.d.ts +2 -2
  236. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.d.ts +2 -4
  237. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.d.ts +2 -2
  238. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.d.ts +2 -4
  239. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.d.ts +2 -4
  240. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.d.ts +2 -4
  241. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.d.ts +2 -4
  242. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.d.ts +2 -4
  243. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.d.ts +2 -4
  244. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.d.ts +2 -4
  245. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +2 -2
  246. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.d.ts +2 -4
  247. package/lib/types/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.d.ts +7 -0
  248. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  249. package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +17 -0
  250. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
  251. package/package.json +71 -57
@@ -723,10 +723,9 @@ const createChatTranscript = async function (transcript, facadeChatSDK) {
723
723
  if (renderAttachments) {
724
724
  messages = await Promise.all(transcriptMessages.map(async message => {
725
725
  // eslint-disable-line @typescript-eslint/no-explicit-any
726
- const {
727
- amsReferences = message.amsreferences,
728
- amsMetadata
729
- } = message;
726
+ const _message$amsReference = message.amsReferences,
727
+ amsReferences = _message$amsReference === void 0 ? message.amsreferences : _message$amsReference,
728
+ amsMetadata = message.amsMetadata;
730
729
  if (amsReferences && amsMetadata) {
731
730
  const references = JSON.parse(amsReferences);
732
731
  const metadata = JSON.parse(amsMetadata);
@@ -20,6 +20,8 @@ const createOnNewAdapterActivityHandler = (chatId, userId, startTime) => {
20
20
  // this is a workaround for the fact that we dont have a way to identify if a message is history or new, and it will provide consistency across different scenarios
21
21
 
22
22
  let isHistoryMessageReceivedEventRaised = false;
23
+ let isInQueue = false;
24
+ let agentJoinLogged = false;
23
25
  const onNewAdapterActivityHandler = activity => {
24
26
  raiseMessageEvent(activity);
25
27
  };
@@ -41,9 +43,14 @@ const createOnNewAdapterActivityHandler = (chatId, userId, startTime) => {
41
43
  });
42
44
  };
43
45
  const systemMessageStrategy = activity => {
44
- var _TelemetryManager$Int3;
46
+ var _activity$channelData, _TelemetryManager$Int3;
45
47
  const payload = (0, _util.buildMessagePayload)(activity, userId);
46
48
  payload.messageType = _Constants2.Constants.systemMessageTag;
49
+
50
+ // Track queue entry for agent-join detection
51
+ if (activity !== null && activity !== void 0 && (_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData = _activity$channelData.tags) !== null && _activity$channelData !== void 0 && _activity$channelData.includes(_Constants2.Constants.queuePositionMessageTag)) {
52
+ isInQueue = true;
53
+ }
47
54
  if ((0, _util.isHistoryMessage)(activity, startTime)) {
48
55
  var _TelemetryManager$Int2;
49
56
  historyMessageStrategy((0, _util.polyfillMessagePayloadForEvent)(activity, payload, (_TelemetryManager$Int2 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int2 === void 0 ? void 0 : _TelemetryManager$Int2.conversationId));
@@ -76,11 +83,11 @@ const createOnNewAdapterActivityHandler = (chatId, userId, startTime) => {
76
83
  }
77
84
  };
78
85
  const isValidMessage = activity => {
79
- var _activity$channelData, _activity$channelData2;
86
+ var _activity$channelData2, _activity$channelData3;
80
87
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
88
  const messageHasNoText = !(activity !== null && activity !== void 0 && activity.text);
82
89
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
- const messageHasNoTags = !(activity !== null && activity !== void 0 && activity.channelData) || !(activity !== null && activity !== void 0 && (_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && _activity$channelData.tags) || (activity === null || activity === void 0 || (_activity$channelData2 = activity.channelData) === null || _activity$channelData2 === void 0 || (_activity$channelData2 = _activity$channelData2.tags) === null || _activity$channelData2 === void 0 ? void 0 : _activity$channelData2.length) === 0;
90
+ const messageHasNoTags = !(activity !== null && activity !== void 0 && activity.channelData) || !(activity !== null && activity !== void 0 && (_activity$channelData2 = activity.channelData) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.tags) || (activity === null || activity === void 0 || (_activity$channelData3 = activity.channelData) === null || _activity$channelData3 === void 0 || (_activity$channelData3 = _activity$channelData3.tags) === null || _activity$channelData3 === void 0 ? void 0 : _activity$channelData3.length) === 0;
84
91
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
92
  const messageHasNoAttachments = !(activity !== null && activity !== void 0 && activity.attachments) || (activity === null || activity === void 0 ? void 0 : activity.attachments.length) === 0;
86
93
  if (messageHasNoTags && messageHasNoText && messageHasNoAttachments) {
@@ -102,6 +109,16 @@ const createOnNewAdapterActivityHandler = (chatId, userId, startTime) => {
102
109
  historyMessageStrategy((0, _util.polyfillMessagePayloadForEvent)(activity, payload, (_TelemetryManager$Int4 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int4 === void 0 ? void 0 : _TelemetryManager$Int4.conversationId));
103
110
  return;
104
111
  }
112
+
113
+ // Log agent joining when first non-history message is received after queue
114
+ if (isInQueue && !agentJoinLogged) {
115
+ agentJoinLogged = true;
116
+ isInQueue = false;
117
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
118
+ Event: _TelemetryConstants.TelemetryEvent.AgentJoinedConversation,
119
+ Description: "First message received from agent after queue"
120
+ });
121
+ }
105
122
  firstResponseLatencyTracker.stopClock(payload);
106
123
  const newMessageReceivedEvent = {
107
124
  eventName: _TelemetryConstants.BroadcastEvent.NewMessageReceived,
@@ -75,6 +75,8 @@ _defineProperty(Constants, "audioMediaRegex", /(\.)(aac|aiff|alac|amr|flac|mp2|m
75
75
  _defineProperty(Constants, "videoMediaRegex", /(\.)(avchd|avi|flv|mpe|mpeg|mpg|mpv|mp4|m4p|m4v|mov|qt|swf|webm|wmv)$/i);
76
76
  _defineProperty(Constants, "chromeSupportedInlineMediaRegex", /(\.)(aac|mp3|wav|mp4)$/i);
77
77
  _defineProperty(Constants, "firefoxSupportedInlineMediaRegex", /(\.)(aac|flac|mp3|wav|mp4|mov)$/i);
78
+ _defineProperty(Constants, "AdaptiveCardType", "adaptivecard");
79
+ _defineProperty(Constants, "SuggestedActionsType", "suggestedactions");
78
80
  // calling container event names
79
81
  _defineProperty(Constants, "CallAdded", "callAdded");
80
82
  _defineProperty(Constants, "LocalVideoStreamAdded", "localVideoStreamAdded");
@@ -137,6 +139,9 @@ _defineProperty(Constants, "customEventValue", "customEventValue");
137
139
  _defineProperty(Constants, "Hidden", "Hidden");
138
140
  _defineProperty(Constants, "EndConversationDueToOverflow", "endconversationduetooverflow");
139
141
  _defineProperty(Constants, "SkipSessionCloseForPersistentChatFlag", "skipSessionCloseForPersistentChat");
142
+ // Minimum font-size for input fields to prevent iOS Safari auto-zoom on focus
143
+ _defineProperty(Constants, "minInputFontSizePx", 16);
144
+ _defineProperty(Constants, "minInputFontSize", "16px");
140
145
  export const Regex = (_Class = /*#__PURE__*/_createClass(function Regex() {
141
146
  _classCallCheck(this, Regex);
142
147
  }), _defineProperty(_Class, "EmailRegex", "^(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\])$"), _Class);
@@ -5,7 +5,7 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
6
6
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
7
  import { BroadcastEvent, LogLevel, TelemetryEvent } from "../telemetry/TelemetryConstants";
8
- import { getAuthClientFunction, handleAuthentication } from "../../components/livechatwidget/common/authHelper";
8
+ import { getAuthClientFunction, handleAuthentication, isMidAuthEnabled } from "../../components/livechatwidget/common/authHelper";
9
9
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
10
10
  import { TelemetryHelper } from "../telemetry/TelemetryHelper";
11
11
  import { isNullOrEmptyString } from "../utils";
@@ -20,6 +20,8 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
20
20
  _defineProperty(this, "getAuthToken", void 0);
21
21
  _defineProperty(this, "sdkMocked", void 0);
22
22
  _defineProperty(this, "disableReauthentication", void 0);
23
+ // Stays true so CASE 1 re-triggers on every startChat to set deferInitialAuth
24
+ _defineProperty(this, "pendingMidAuthUnauthenticatedState", false);
23
25
  this.chatSDK = input.chatSDK;
24
26
  this.chatConfig = input.chatConfig;
25
27
  this.getAuthToken = input.getAuthToken;
@@ -44,6 +46,12 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
44
46
  value: function destroy() {
45
47
  this.token = null;
46
48
  this.expiration = 0;
49
+ if (isMidAuthEnabled(this.chatConfig)) {
50
+ this.pendingMidAuthUnauthenticatedState = false;
51
+ this.isAuthenticated = true;
52
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
+ this.chatSDK.deferInitialAuth = false;
54
+ }
47
55
  }
48
56
  }, {
49
57
  key: "isTokenSet",
@@ -208,6 +216,10 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
208
216
  message: "Token is valid"
209
217
  };
210
218
  }
219
+
220
+ // Token missing or expired - need to get a new one via getAuthToken
221
+ // For mid-auth: getAuthToken receives { isMidAuthEnabled: true } so customer implementations
222
+ // can check portal state and return null for logged-out users
211
223
  TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.INFO, {
212
224
  Event: TelemetryEvent.NewTokenValidationStarted,
213
225
  Description: "Token validation started."
@@ -228,6 +240,7 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
228
240
  this.token = "";
229
241
  this.expiration = 0;
230
242
  try {
243
+ var _ring$error, _ring$error2;
231
244
  const ring = await handleAuthentication(this.chatSDK, this.chatConfig, this.getAuthToken);
232
245
  if ((ring === null || ring === void 0 ? void 0 : ring.result) === true && ring !== null && ring !== void 0 && ring.token) {
233
246
  await this.setToken(ring.token);
@@ -242,18 +255,35 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
242
255
  result: true,
243
256
  message: "New Token obtained"
244
257
  };
245
- } else {
246
- var _ring$error, _ring$error2;
247
- TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.ERROR, {
248
- Event: TelemetryEvent.NewTokenValidationFailed,
249
- Description: (_ring$error = ring.error) === null || _ring$error === void 0 ? void 0 : _ring$error.message,
250
- ExceptionDetails: ring === null || ring === void 0 ? void 0 : ring.error
258
+ }
259
+
260
+ // Mid-auth: no token available - set pending flag for startChat to handle
261
+ const isEmptyTokenWithoutError = isNullOrEmptyString(ring === null || ring === void 0 ? void 0 : ring.token) && ((ring === null || ring === void 0 ? void 0 : ring.result) === true || (ring === null || ring === void 0 ? void 0 : ring.result) === false && !(ring !== null && ring !== void 0 && ring.error));
262
+ if (isMidAuthEnabled(this.chatConfig) && isEmptyTokenWithoutError) {
263
+ // Clear Facade and SDK token state so API calls use unauthenticated endpoints
264
+ this.token = "";
265
+ this.expiration = 0;
266
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
267
+ this.chatSDK.authenticatedUserToken = null;
268
+ this.pendingMidAuthUnauthenticatedState = true;
269
+ TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.INFO, {
270
+ Event: TelemetryEvent.NewTokenValidationCompleted,
271
+ Description: "Mid-auth enabled: no token returned; proceeding as unauthenticated"
251
272
  });
252
273
  return {
253
- result: false,
254
- message: (ring === null || ring === void 0 || (_ring$error2 = ring.error) === null || _ring$error2 === void 0 ? void 0 : _ring$error2.message) || "Failed to get token"
274
+ result: true,
275
+ message: "Mid-auth: proceeding as unauthenticated"
255
276
  };
256
277
  }
278
+ TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.ERROR, {
279
+ Event: TelemetryEvent.NewTokenValidationFailed,
280
+ Description: (_ring$error = ring.error) === null || _ring$error === void 0 ? void 0 : _ring$error.message,
281
+ ExceptionDetails: ring === null || ring === void 0 ? void 0 : ring.error
282
+ });
283
+ return {
284
+ result: false,
285
+ message: (ring === null || ring === void 0 || (_ring$error2 = ring.error) === null || _ring$error2 === void 0 ? void 0 : _ring$error2.message) || "Failed to get token"
286
+ };
257
287
  } catch (e) {
258
288
  console.error("Unexpected error while getting token", e);
259
289
  TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.ERROR, {
@@ -267,6 +297,155 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
267
297
  };
268
298
  }
269
299
  }
300
+
301
+ /**
302
+ * Sets unauthenticated state for mid-auth flow.
303
+ * Clears SDK internal state to prevent reconnection to previous authenticated session.
304
+ */
305
+ }, {
306
+ key: "setMidAuthUnauthenticatedState",
307
+ value: function setMidAuthUnauthenticatedState() {
308
+ var _sdk$chatToken, _sdk$chatToken2;
309
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
310
+ const sdk = this.chatSDK;
311
+ const hadExistingChat = !!((_sdk$chatToken = sdk.chatToken) !== null && _sdk$chatToken !== void 0 && _sdk$chatToken.chatId);
312
+ const previousChatId = (_sdk$chatToken2 = sdk.chatToken) === null || _sdk$chatToken2 === void 0 ? void 0 : _sdk$chatToken2.chatId;
313
+ this.clearAuthState();
314
+
315
+ // Clear SDK internal state for fresh unauthenticated chat
316
+ sdk.chatToken = {};
317
+ sdk.reconnectId = null;
318
+ sdk.requestId = null;
319
+ sdk.sessionId = null;
320
+ sdk.conversation = null;
321
+ TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.INFO, {
322
+ Event: TelemetryEvent.MidConversationAuthReset,
323
+ Description: hadExistingChat ? "Mid-auth without token: local state cleared" : "Mid-auth: initialized as unauthenticated (no prior chat)",
324
+ Data: hadExistingChat ? {
325
+ previousChatId
326
+ } : undefined
327
+ });
328
+ }
329
+
330
+ /** Clears authentication state in both FacadeChatSDK and underlying SDK */
331
+ }, {
332
+ key: "clearAuthState",
333
+ value: function clearAuthState() {
334
+ this.token = "";
335
+ this.expiration = 0;
336
+ this.isAuthenticated = false;
337
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
338
+ this.chatSDK.authenticatedUserToken = null;
339
+ }
340
+
341
+ /**
342
+ * Migrates conversation from unauthenticated to authenticated via authenticateChat.
343
+ * Called after startChat() when user has a valid token but the backend conversation
344
+ * was started as unauthenticated.
345
+ */
346
+ }, {
347
+ key: "migrateConversationToAuthenticated",
348
+ value: async function migrateConversationToAuthenticated() {
349
+ try {
350
+ await this.chatSDK.authenticateChat(this.token, {
351
+ refreshChatToken: true
352
+ });
353
+ this.isAuthenticated = true;
354
+ TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.INFO, {
355
+ Event: TelemetryEvent.MidConversationAuthSucceeded,
356
+ Description: "Mid-auth: authenticateChat completed, conversation migrated to authenticated"
357
+ });
358
+ } catch (e) {
359
+ // Non-fatal: Chat is already active via startChat, will retry on next reconnect
360
+ TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.WARN, {
361
+ Event: TelemetryEvent.MidConversationAuthFailed,
362
+ Description: "Mid-auth: authenticateChat returned error after startChat, chat still active",
363
+ ExceptionDetails: {
364
+ message: e === null || e === void 0 ? void 0 : e.message
365
+ }
366
+ });
367
+ }
368
+ }
369
+
370
+ /**
371
+ * Configures SDK auth state before startChat.
372
+ * CASE 1: Pending unauthenticated (no token) - sets deferInitialAuth=true
373
+ * CASE 2: Authenticated with valid token - sets SDK token and deferInitialAuth based on scenario
374
+ */
375
+ }, {
376
+ key: "configureMidAuthState",
377
+ value: function configureMidAuthState(isReconnect, wasPreviousSessionAuthenticated) {
378
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
379
+ const sdk = this.chatSDK;
380
+
381
+ // CASE 1: No token available (user not logged in)
382
+ // pendingMidAuthUnauthenticatedState stays true until user logs in (cleared in tokenRing)
383
+ if (this.pendingMidAuthUnauthenticatedState) {
384
+ const shouldClear = this.handlePendingUnauthenticatedState(wasPreviousSessionAuthenticated);
385
+ sdk.deferInitialAuth = true;
386
+ TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.INFO, {
387
+ Event: TelemetryEvent.MidConversationAuthReset,
388
+ Description: "Mid-auth configureMidAuthState: CASE 1 - unauthenticated, deferInitialAuth=true",
389
+ Data: {
390
+ isReconnect: String(isReconnect),
391
+ wasPreviousSessionAuthenticated: String(wasPreviousSessionAuthenticated),
392
+ shouldClearReconnectParams: String(shouldClear)
393
+ }
394
+ });
395
+ return {
396
+ shouldClearReconnectParams: shouldClear
397
+ };
398
+ }
399
+
400
+ // CASE 2: Authenticated with valid token
401
+ if (this.isTokenSet() && !this.isTokenExpired()) {
402
+ this.handleAuthenticatedState(isReconnect, wasPreviousSessionAuthenticated);
403
+ }
404
+ return {
405
+ shouldClearReconnectParams: false
406
+ };
407
+ }
408
+
409
+ /**
410
+ * CASE 1 handler: Returns true if reconnect params should be cleared (Auth -> Unauth transition)
411
+ */
412
+ }, {
413
+ key: "handlePendingUnauthenticatedState",
414
+ value: function handlePendingUnauthenticatedState(wasPreviousSessionAuthenticated) {
415
+ if (wasPreviousSessionAuthenticated) {
416
+ // Auth -> Unauth: user logged out, clear state for fresh chat
417
+ this.setMidAuthUnauthenticatedState();
418
+ return true;
419
+ }
420
+
421
+ // Unauth -> Unauth: keep liveChatContext for reconnection
422
+ this.isAuthenticated = false;
423
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
424
+ this.chatSDK.authenticatedUserToken = null;
425
+ return false;
426
+ }
427
+
428
+ /**
429
+ * CASE 2 handler: Sets deferInitialAuth only for reconnects to unauthenticated sessions (need migration).
430
+ * For new chats or reconnects to authenticated sessions, SDK handles auth internally.
431
+ */
432
+ }, {
433
+ key: "handleAuthenticatedState",
434
+ value: function handleAuthenticatedState(isReconnect, wasPreviousSessionAuthenticated) {
435
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
436
+ const sdk = this.chatSDK;
437
+ sdk.authenticatedUserToken = this.token;
438
+ if (isReconnect && !wasPreviousSessionAuthenticated) {
439
+ sdk.deferInitialAuth = true;
440
+ TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.INFO, {
441
+ Event: TelemetryEvent.MidConversationAuthSucceeded,
442
+ Description: "Mid-auth handleAuthenticatedState: CASE 2 - reconnect to unauth session, deferInitialAuth=true (migration needed)"
443
+ });
444
+ } else {
445
+ // Reset to prevent inheriting deferInitialAuth=true from a previous unauthenticated chat
446
+ sdk.deferInitialAuth = false;
447
+ }
448
+ }
270
449
  }, {
271
450
  key: "validateAndExecuteCall",
272
451
  value: async function validateAndExecuteCall(functionName, fn) {
@@ -301,7 +480,52 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
301
480
  key: "startChat",
302
481
  value: async function startChat() {
303
482
  let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
304
- return this.validateAndExecuteCall("startChat", () => this.chatSDK.startChat(optionalParams));
483
+ const midAuthEnabled = isMidAuthEnabled(this.chatConfig);
484
+ const isReconnect = !!optionalParams.liveChatContext || !!optionalParams.reconnectId;
485
+ const wasPreviousSessionAuthenticated = optionalParams.wasAuthenticated === true;
486
+ return this.validateAndExecuteCall("startChat", async () => {
487
+ if (midAuthEnabled) {
488
+ const _this$configureMidAut = this.configureMidAuthState(isReconnect, wasPreviousSessionAuthenticated),
489
+ shouldClearReconnectParams = _this$configureMidAut.shouldClearReconnectParams;
490
+ if (shouldClearReconnectParams) {
491
+ delete optionalParams.liveChatContext;
492
+ delete optionalParams.reconnectId;
493
+ }
494
+ }
495
+ await this.chatSDK.startChat(optionalParams);
496
+
497
+ // Migrate to authenticated if needed (reconnects to unauthenticated sessions only)
498
+ if (midAuthEnabled) {
499
+ const shouldMigrateToAuth = isReconnect && this.isTokenSet() && !this.isTokenExpired() && !wasPreviousSessionAuthenticated;
500
+ if (shouldMigrateToAuth) {
501
+ TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.INFO, {
502
+ Event: TelemetryEvent.MidConversationAuthSucceeded,
503
+ Description: "Mid-auth startChat: initiating migration to authenticated",
504
+ Data: {
505
+ isReconnect: String(isReconnect),
506
+ wasPreviousSessionAuthenticated: String(wasPreviousSessionAuthenticated)
507
+ }
508
+ });
509
+ await this.migrateConversationToAuthenticated();
510
+ }
511
+ }
512
+
513
+ // Broadcast final auth state after startChat completes (only on state change)
514
+ if (midAuthEnabled) {
515
+ const isAuthenticatedAfterStart = this.isTokenSet() && !this.isTokenExpired();
516
+ const authStateChanged = !isReconnect || isAuthenticatedAfterStart !== wasPreviousSessionAuthenticated;
517
+ if (authStateChanged) {
518
+ BroadcastService.postMessage({
519
+ eventName: isAuthenticatedAfterStart ? BroadcastEvent.MidConversationAuthSucceeded : BroadcastEvent.MidConversationAuthReset,
520
+ payload: {
521
+ isAuthenticated: isAuthenticatedAfterStart,
522
+ isStartChatComplete: true,
523
+ isReconnect
524
+ }
525
+ });
526
+ }
527
+ }
528
+ });
305
529
  }
306
530
  }, {
307
531
  key: "endChat",
@@ -439,6 +663,7 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
439
663
  let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
440
664
  return this.validateAndExecuteCall("getAgentAvailability", () => this.chatSDK.getAgentAvailability(optionalParams));
441
665
  }
666
+
442
667
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
443
668
  }, {
444
669
  key: "getReconnectableChats",
@@ -67,6 +67,9 @@ export let BroadcastEvent = /*#__PURE__*/function (BroadcastEvent) {
67
67
  BroadcastEvent["FMLTrackingCompletedAck"] = "FMLTrackingCompletedAck";
68
68
  BroadcastEvent["FMLTrackingCompleted"] = "FMLTrackingCompleted";
69
69
  BroadcastEvent["PersistentConversationReset"] = "PersistentConversationReset";
70
+ BroadcastEvent["MidConversationAuthSucceeded"] = "MidConversationAuthSucceeded";
71
+ // Emitted when mid-conversation auth succeeds (for reconnect support)
72
+ BroadcastEvent["MidConversationAuthReset"] = "MidConversationAuthReset"; // Emitted when mid-auth falls back to unauthenticated mode (token null/empty)
70
73
  return BroadcastEvent;
71
74
  }({});
72
75
 
@@ -103,6 +106,10 @@ export let TelemetryEvent = /*#__PURE__*/function (TelemetryEvent) {
103
106
  TelemetryEvent["CallingSDKInitFailed"] = "CallingSDKInitFailed";
104
107
  TelemetryEvent["CallingSDKLoadSuccess"] = "CallingSDKLoadSuccess";
105
108
  TelemetryEvent["CallingSDKLoadFailed"] = "CallingSDKLoadFailed";
109
+ TelemetryEvent["MidConversationAuthSucceeded"] = "MidConversationAuthSucceeded";
110
+ TelemetryEvent["MidConversationAuthFailed"] = "MidConversationAuthFailed";
111
+ TelemetryEvent["MidConversationAuthReset"] = "MidConversationAuthReset";
112
+ TelemetryEvent["RecoveryEligibilityEvaluated"] = "RecoveryEligibilityEvaluated";
106
113
  TelemetryEvent["GetConversationDetailsCallStarted"] = "GetConversationDetailsCallStarted";
107
114
  TelemetryEvent["GetConversationDetailsCallFailed"] = "GetConversationDetailsCallFailed";
108
115
  TelemetryEvent["EndChatSDKCallFailed"] = "EndChatSDKCallFailed";
@@ -193,6 +200,7 @@ export let TelemetryEvent = /*#__PURE__*/function (TelemetryEvent) {
193
200
  //WebChat Middleware Events
194
201
  TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
195
202
  TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
203
+ TelemetryEvent["HTMLSanitized"] = "HTMLSanitized";
196
204
  TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
197
205
  TelemetryEvent["AttachmentUploadValidatorMiddlewareFailed"] = "AttachmentUploadValidatorMiddlewareFailed";
198
206
  TelemetryEvent["CitationMiddlewareFailed"] = "CitationMiddlewareFailed";
@@ -319,11 +327,19 @@ export let TelemetryEvent = /*#__PURE__*/function (TelemetryEvent) {
319
327
  TelemetryEvent["LCWLazyLoadNoMoreHistory"] = "LCWLazyLoadNoMoreHistory";
320
328
  TelemetryEvent["LCWLazyLoadHistoryError"] = "LCWLazyLoadHistoryError";
321
329
  TelemetryEvent["LCWLazyLoadDestroyed"] = "LCWLazyLoadDestroyed";
330
+ TelemetryEvent["LCWLazyLoadTriggerFired"] = "LCWLazyLoadTriggerFired";
331
+ TelemetryEvent["LCWLazyLoadBatchReceived"] = "LCWLazyLoadBatchReceived";
332
+ TelemetryEvent["LCWLazyLoadInitialLoadComplete"] = "LCWLazyLoadInitialLoadComplete";
333
+ TelemetryEvent["LCWLazyLoadScrollAnchorApplied"] = "LCWLazyLoadScrollAnchorApplied";
322
334
  // SecureEventBus events
323
335
  TelemetryEvent["SecureEventBusUnauthorizedDispatch"] = "SecureEventBusUnauthorizedDispatch";
324
336
  TelemetryEvent["SecureEventBusListenerError"] = "SecureEventBusListenerError";
325
337
  TelemetryEvent["SecureEventBusDispatchError"] = "SecureEventBusDispatchError";
326
338
  TelemetryEvent["StartChatComplete"] = "StartChatComplete";
339
+ // Queue & Agent Assignment
340
+ TelemetryEvent["AgentJoinedConversation"] = "AgentJoinedConversation";
341
+ // Browser Close Detection
342
+ TelemetryEvent["BrowserTabHidden"] = "BrowserTabHidden";
327
343
  return TelemetryEvent;
328
344
  }({});
329
345
  export let TelemetryConstants = /*#__PURE__*/function () {
@@ -395,6 +411,9 @@ export let TelemetryConstants = /*#__PURE__*/function () {
395
411
  case TelemetryEvent.SecureEventBusUnauthorizedDispatch:
396
412
  case TelemetryEvent.SecureEventBusListenerError:
397
413
  case TelemetryEvent.SecureEventBusDispatchError:
414
+ case TelemetryEvent.AgentJoinedConversation:
415
+ case TelemetryEvent.BrowserTabHidden:
416
+ case TelemetryEvent.RecoveryEligibilityEvaluated:
398
417
  return ScenarioType.ACTIONS;
399
418
  case TelemetryEvent.StartChatSDKCall:
400
419
  case TelemetryEvent.StartChatEventReceived:
@@ -11,6 +11,7 @@ import { appInsightsLogger } from "./loggers/appInsightsLogger";
11
11
  import { ariaTelemetryLogger } from "./loggers/ariaTelemetryLogger";
12
12
  import { consoleLogger } from "./loggers/consoleLogger";
13
13
  import { defaultAriaConfig } from "./defaultConfigs/defaultAriaConfig";
14
+ import { sanitizeSasInPayload } from "./sanitizeSasInPayload";
14
15
  export let TelemetryTimers = /*#__PURE__*/_createClass(function TelemetryTimers() {
15
16
  _classCallCheck(this, TelemetryTimers);
16
17
  });
@@ -72,11 +73,15 @@ export const RegisterLoggers = () => {
72
73
  };
73
74
  };
74
75
  const logTelemetry = telemetryEvent => {
76
+ // Redact Azure SAS credentials in any URL embedded in the payload (e.g.
77
+ // customer-supplied blob asset URLs in widget customization props) before
78
+ // it fans out to console, Aria, AppInsights, or any custom logger.
79
+ const sanitizedPayload = sanitizeSasInPayload(telemetryEvent === null || telemetryEvent === void 0 ? void 0 : telemetryEvent.payload);
75
80
  loggers.map(logger => {
76
81
  var _payload, _telemetryInput$paylo;
77
82
  const logLevel = telemetryEvent.logLevel ?? LogLevel.INFO;
78
83
  const scenarioType = ((_payload = telemetryEvent.payload) === null || _payload === void 0 ? void 0 : _payload.scenarioType) ?? ScenarioType.UNDEFINED;
79
- const telemetryInput = parseInput(telemetryEvent === null || telemetryEvent === void 0 ? void 0 : telemetryEvent.payload, scenarioType);
84
+ const telemetryInput = parseInput(sanitizedPayload, scenarioType);
80
85
  telemetryInput.telemetryInfo = {
81
86
  telemetryInfo: TelemetryHelper.buildTelemetryEvent(logLevel, telemetryInput)
82
87
  };
@@ -34,9 +34,8 @@ export const appInsightsLogger = appInsightsKey => {
34
34
  }
35
35
  try {
36
36
  // Dynamically import Application Insights
37
- const {
38
- ApplicationInsights
39
- } = await import("@microsoft/applicationinsights-web");
37
+ const _await$import = await import("@microsoft/applicationinsights-web"),
38
+ ApplicationInsights = _await$import.ApplicationInsights;
40
39
  const config = {
41
40
  ...(appInsightsKey.includes("IngestionEndpoint") ? {
42
41
  connectionString: appInsightsKey
@@ -0,0 +1,84 @@
1
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
7
+ /**
8
+ * Redacts the values of Azure Shared Access Signature (SAS) query parameters in any
9
+ * URL embedded in a telemetry payload, so customer-supplied SAS URLs (e.g. blob asset
10
+ * URLs in widget customization props) cannot leak credentials through Aria/AppInsights.
11
+ *
12
+ * Trigger: any URL whose query string contains `sig=`. When detected, every well-known
13
+ * SAS parameter value in that query is replaced with `[REDACTED]`. Other URLs and other
14
+ * substrings of the payload pass through unchanged.
15
+ *
16
+ * Coverage of SAS parameter names:
17
+ * - Service/Blob SAS: sig, sv, se, st, sp, spr, sr, sip
18
+ * - Account SAS: ss, srt
19
+ * - User-delegation key SAS: skoid, sktid, skt, ske, sks, skv, saoid, suoid, sce, sdd
20
+ * - Response header overrides: rscc, rscd, rsce, rscl, rsct
21
+ *
22
+ * Reference: https://learn.microsoft.com/en-us/rest/api/storageservices/create-service-sas
23
+ */
24
+
25
+ const SAS_PARAM_NAMES = new Set(["sig", "sv", "se", "st", "sp", "spr", "sr", "sip", "ss", "srt", "skoid", "sktid", "skt", "ske", "sks", "skv", "saoid", "suoid", "sce", "sdd", "rscc", "rscd", "rsce", "rscl", "rsct"]);
26
+ const REDACTED_VALUE = "[REDACTED]";
27
+
28
+ // Matches any http(s) URL substring up to whitespace / closing quote / angle-bracket / paren.
29
+ const URL_REGEX = /\bhttps?:\/\/[^\s"'<>)]+/gi;
30
+ const redactQueryIfSas = url => {
31
+ const queryIdx = url.indexOf("?");
32
+ if (queryIdx < 0) {
33
+ return url;
34
+ }
35
+ // Separate the fragment (#...) before processing the query — fragments come
36
+ // after the query string in URL syntax and must not be folded into the last
37
+ // query parameter's value when we split on `&`.
38
+ const afterQuestionMark = url.slice(queryIdx + 1);
39
+ const fragIdx = afterQuestionMark.indexOf("#");
40
+ const query = fragIdx < 0 ? afterQuestionMark : afterQuestionMark.slice(0, fragIdx);
41
+ const fragment = fragIdx < 0 ? "" : afterQuestionMark.slice(fragIdx); // includes the leading '#'
42
+ if (!/(^|&)sig=/i.test(query)) {
43
+ // No SAS signature present — leave the URL alone so legitimate non-SAS query
44
+ // strings (e.g. ?utm_source=...) are not mangled.
45
+ return url;
46
+ }
47
+ const base = url.slice(0, queryIdx);
48
+ const sanitizedQuery = query.split("&").map(pair => {
49
+ const eqIdx = pair.indexOf("=");
50
+ if (eqIdx < 0) {
51
+ return pair;
52
+ }
53
+ const name = pair.slice(0, eqIdx).toLowerCase();
54
+ return SAS_PARAM_NAMES.has(name) ? `${pair.slice(0, eqIdx)}=${REDACTED_VALUE}` : pair;
55
+ }).join("&");
56
+ return `${base}?${sanitizedQuery}${fragment}`;
57
+ };
58
+ const sanitizeString = s => s.replace(URL_REGEX, redactQueryIfSas);
59
+
60
+ /**
61
+ * Deep-walk a value and redact SAS credentials in any string it contains.
62
+ * Returns a new object/array (originals are not mutated); non-string leaves are
63
+ * passed through. Tree-shaped, JSON-like values only — not designed for class
64
+ * instances, prototype-bound objects, or cyclic graphs.
65
+ */
66
+ export const sanitizeSasInPayload = value => {
67
+ if (typeof value === "string") {
68
+ return sanitizeString(value);
69
+ }
70
+ if (Array.isArray(value)) {
71
+ return value.map(sanitizeSasInPayload);
72
+ }
73
+ if (value !== null && typeof value === "object") {
74
+ const out = {};
75
+ for (const _ref of Object.entries(value)) {
76
+ var _ref2 = _slicedToArray(_ref, 2);
77
+ const k = _ref2[0];
78
+ const v = _ref2[1];
79
+ out[k] = sanitizeSasInPayload(v);
80
+ }
81
+ return out;
82
+ }
83
+ return value;
84
+ };