@microsoft/omnichannel-chat-widget 0.1.0-main.d5846c0 → 0.1.0-main.d5e0dfe

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 (312) hide show
  1. package/README.md +32 -0
  2. package/lib/cjs/assets/Icons.js +4 -2
  3. package/lib/cjs/common/Constants.js +30 -163
  4. package/lib/cjs/common/KeyCodes.js +3 -4
  5. package/lib/cjs/common/contextDataStore/DataStoreManager.js +3 -5
  6. package/lib/cjs/common/storage/default/defaultCacheManager.js +26 -0
  7. package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +102 -0
  8. package/lib/cjs/common/storage/default/defaultInMemoryDataStore.js +78 -0
  9. package/lib/cjs/common/telemetry/TelemetryConstants.js +44 -27
  10. package/lib/cjs/common/telemetry/TelemetryHelper.js +21 -59
  11. package/lib/cjs/common/telemetry/TelemetryManager.js +3 -32
  12. package/lib/cjs/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +0 -2
  13. package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +30 -36
  14. package/lib/cjs/common/telemetry/loggers/consoleLogger.js +0 -9
  15. package/lib/cjs/common/utils.js +65 -93
  16. package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +8 -46
  17. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +14 -26
  18. package/lib/cjs/components/chatbuttonstateful/common/styleProps/defaultOutOfOfficeChatButtonStyleProps.js +3 -0
  19. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +8 -33
  20. package/lib/cjs/components/dimlayer/DimLayer.js +0 -4
  21. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +9 -37
  22. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.spec.js +6 -8
  23. package/lib/cjs/components/footerstateful/FooterStateful.js +11 -42
  24. package/lib/cjs/components/footerstateful/audionotificationstateful/AudioNotificationStateful.js +0 -6
  25. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +14 -43
  26. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.spec.js +6 -8
  27. package/lib/cjs/components/headerstateful/HeaderStateful.js +20 -32
  28. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +2 -14
  29. package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +39 -0
  30. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +20 -0
  31. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  32. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +34 -0
  33. package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +64 -0
  34. package/lib/cjs/components/livechatwidget/common/Deferred.js +37 -0
  35. package/lib/cjs/components/livechatwidget/common/authHelper.js +50 -0
  36. package/lib/cjs/components/livechatwidget/common/createAdapter.js +10 -9
  37. package/lib/cjs/components/livechatwidget/common/createFooter.js +4 -23
  38. package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +10 -10
  39. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +36 -43
  40. package/lib/cjs/components/livechatwidget/common/defaultProps/defaultScrollBarProps.js +14 -0
  41. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +126 -48
  42. package/lib/cjs/components/livechatwidget/common/disposeTelemetryLoggers.js +0 -3
  43. package/lib/cjs/components/livechatwidget/common/endChat.js +95 -48
  44. package/lib/cjs/components/livechatwidget/common/getGeneralStylesForButton.js +0 -6
  45. package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +7 -16
  46. package/lib/cjs/components/livechatwidget/common/initConfirmationPropsComposer.js +4 -8
  47. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +32 -53
  48. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +76 -129
  49. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +4 -17
  50. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +2 -15
  51. package/lib/cjs/components/livechatwidget/common/shareObservable.js +41 -0
  52. package/lib/cjs/components/livechatwidget/common/startChat.js +232 -126
  53. package/lib/cjs/components/livechatwidget/common/startProactiveChat.js +0 -8
  54. package/lib/cjs/components/livechatwidget/common/updateSessionDataForTelemetry.js +2 -11
  55. package/lib/cjs/components/livechatwidget/interfaces/IScrollBarProps.js +1 -0
  56. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +311 -218
  57. package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +19 -19
  58. package/lib/cjs/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.js +57 -0
  59. package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +4 -17
  60. package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +4 -17
  61. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +32 -23
  62. package/lib/cjs/components/postchatsurveypanestateful/common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps.js +1 -1
  63. package/lib/cjs/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +13 -0
  64. package/lib/cjs/components/postchatsurveypanestateful/enums/PostChatSurveyMode.js +0 -1
  65. package/lib/cjs/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.js +1 -0
  66. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +10 -42
  67. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +3 -33
  68. package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +6 -24
  69. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +94 -19
  70. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -7
  71. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -6
  72. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +11 -0
  73. package/lib/cjs/components/webchatcontainerstateful/common/mockadapter.js +12 -27
  74. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +6 -17
  75. package/lib/cjs/components/webchatcontainerstateful/common/utils/BrowserInfo.js +2 -24
  76. package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +5 -15
  77. package/lib/cjs/components/webchatcontainerstateful/common/utils/isMaskingFromCustomer.js +5 -8
  78. package/lib/cjs/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
  79. package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  80. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +12 -0
  81. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +3 -5
  82. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/BrowserVendor.js +0 -1
  83. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineActivityType.js +0 -1
  84. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineSenderRole.js +0 -1
  85. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/MessageType.js +0 -1
  86. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/NotificationLevel.js +0 -1
  87. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +0 -1
  88. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/SendStatus.js +0 -1
  89. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/WebChatActionType.js +0 -1
  90. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsEgressMiddleware.js +0 -7
  91. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsIngressMiddleware.js +0 -5
  92. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +27 -37
  93. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +10 -22
  94. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +25 -61
  95. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.js +7 -15
  96. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
  97. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +82 -0
  98. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +10 -0
  99. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +10 -0
  100. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampFailedStyles.js +2 -3
  101. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +2 -3
  102. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +10 -0
  103. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware.js +3 -9
  104. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +89 -0
  105. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +7 -18
  106. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +8 -42
  107. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +4 -22
  108. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +13 -30
  109. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +3 -9
  110. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +6 -34
  111. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +1 -10
  112. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +1 -12
  113. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +17 -19
  114. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.js +1 -9
  115. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.js +3 -9
  116. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +13 -34
  117. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.js +1 -10
  118. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.js +7 -11
  119. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +5 -14
  120. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +1 -21
  121. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +0 -12
  122. package/lib/cjs/contexts/ChatAdapterStore.js +0 -2
  123. package/lib/cjs/contexts/ChatContextStore.js +0 -2
  124. package/lib/cjs/contexts/ChatSDKStore.js +0 -2
  125. package/lib/cjs/contexts/common/ConversationState.js +3 -3
  126. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +30 -26
  127. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +13 -13
  128. package/lib/cjs/contexts/createReducer.js +164 -102
  129. package/lib/cjs/controller/componentController.js +4 -33
  130. package/lib/cjs/hooks/useChatAdapterStore.js +0 -6
  131. package/lib/cjs/hooks/useChatContextStore.js +0 -6
  132. package/lib/cjs/hooks/useChatSDKStore.js +0 -6
  133. package/lib/cjs/index.js +0 -5
  134. package/lib/cjs/plugins/newMessageEventHandler.js +19 -36
  135. package/lib/esm/assets/Icons.js +2 -1
  136. package/lib/esm/common/Constants.js +27 -150
  137. package/lib/esm/common/KeyCodes.js +3 -3
  138. package/lib/esm/common/contextDataStore/DataStoreManager.js +3 -3
  139. package/lib/esm/common/storage/default/defaultCacheManager.js +18 -0
  140. package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +95 -0
  141. package/lib/esm/common/storage/default/defaultInMemoryDataStore.js +70 -0
  142. package/lib/esm/common/telemetry/TelemetryConstants.js +48 -24
  143. package/lib/esm/common/telemetry/TelemetryHelper.js +21 -47
  144. package/lib/esm/common/telemetry/TelemetryManager.js +3 -19
  145. package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +28 -24
  146. package/lib/esm/common/telemetry/loggers/consoleLogger.js +0 -5
  147. package/lib/esm/common/utils.js +60 -50
  148. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +8 -17
  149. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +16 -12
  150. package/lib/esm/components/chatbuttonstateful/common/styleProps/defaultOutOfOfficeChatButtonStyleProps.js +3 -0
  151. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +10 -14
  152. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +9 -16
  153. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.spec.js +6 -6
  154. package/lib/esm/components/footerstateful/FooterStateful.js +13 -23
  155. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +14 -36
  156. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.spec.js +6 -6
  157. package/lib/esm/components/headerstateful/HeaderStateful.js +20 -17
  158. package/lib/esm/components/livechatwidget/LiveChatWidget.js +2 -2
  159. package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +32 -0
  160. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +13 -0
  161. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  162. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +27 -0
  163. package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +57 -0
  164. package/lib/esm/components/livechatwidget/common/Deferred.js +30 -0
  165. package/lib/esm/components/livechatwidget/common/authHelper.js +42 -0
  166. package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -4
  167. package/lib/esm/components/livechatwidget/common/createFooter.js +4 -16
  168. package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +10 -5
  169. package/lib/esm/components/livechatwidget/common/createMarkdown.js +38 -37
  170. package/lib/esm/components/livechatwidget/common/defaultProps/defaultScrollBarProps.js +7 -0
  171. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +127 -34
  172. package/lib/esm/components/livechatwidget/common/endChat.js +97 -32
  173. package/lib/esm/components/livechatwidget/common/getGeneralStylesForButton.js +0 -2
  174. package/lib/esm/components/livechatwidget/common/initCallingSdk.js +9 -11
  175. package/lib/esm/components/livechatwidget/common/initConfirmationPropsComposer.js +4 -5
  176. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +35 -22
  177. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +77 -111
  178. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +4 -9
  179. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +4 -7
  180. package/lib/esm/components/livechatwidget/common/shareObservable.js +35 -0
  181. package/lib/esm/components/livechatwidget/common/startChat.js +230 -102
  182. package/lib/esm/components/livechatwidget/common/updateSessionDataForTelemetry.js +4 -2
  183. package/lib/esm/components/livechatwidget/interfaces/IScrollBarProps.js +1 -0
  184. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +315 -161
  185. package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +19 -7
  186. package/lib/esm/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.js +50 -0
  187. package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +4 -5
  188. package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +4 -5
  189. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +32 -11
  190. package/lib/esm/components/postchatsurveypanestateful/common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps.js +1 -1
  191. package/lib/esm/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +6 -0
  192. package/lib/esm/components/postchatsurveypanestateful/enums/PostChatSurveyMode.js +0 -1
  193. package/lib/esm/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.js +1 -0
  194. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +13 -26
  195. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +5 -9
  196. package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +6 -6
  197. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +94 -4
  198. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -1
  199. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
  200. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +4 -0
  201. package/lib/esm/components/webchatcontainerstateful/common/mockadapter.js +12 -19
  202. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +6 -13
  203. package/lib/esm/components/webchatcontainerstateful/common/utils/BrowserInfo.js +2 -16
  204. package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +5 -5
  205. package/lib/esm/components/webchatcontainerstateful/common/utils/isMaskingFromCustomer.js +5 -6
  206. package/lib/esm/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
  207. package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  208. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
  209. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +3 -3
  210. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/BrowserVendor.js +0 -1
  211. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineActivityType.js +0 -1
  212. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineSenderRole.js +0 -1
  213. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/MessageType.js +0 -1
  214. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/NotificationLevel.js +0 -1
  215. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +0 -1
  216. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/SendStatus.js +0 -1
  217. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/WebChatActionType.js +0 -1
  218. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsEgressMiddleware.js +2 -5
  219. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsIngressMiddleware.js +0 -4
  220. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +27 -22
  221. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +12 -14
  222. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +25 -39
  223. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.js +9 -8
  224. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +34 -0
  225. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +80 -0
  226. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +3 -0
  227. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +3 -0
  228. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampFailedStyles.js +2 -1
  229. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +2 -1
  230. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +3 -0
  231. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware.js +3 -7
  232. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +83 -0
  233. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +8 -9
  234. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +9 -28
  235. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +5 -14
  236. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +15 -19
  237. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +5 -8
  238. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +6 -29
  239. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +3 -7
  240. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +3 -8
  241. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +17 -14
  242. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.js +3 -7
  243. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.js +3 -7
  244. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +15 -27
  245. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.js +3 -5
  246. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.js +9 -9
  247. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +7 -9
  248. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +1 -13
  249. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +0 -5
  250. package/lib/esm/contexts/ChatAdapterStore.js +2 -1
  251. package/lib/esm/contexts/ChatContextStore.js +2 -1
  252. package/lib/esm/contexts/ChatSDKStore.js +2 -1
  253. package/lib/esm/contexts/common/ConversationState.js +3 -3
  254. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +30 -26
  255. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +13 -9
  256. package/lib/esm/contexts/createReducer.js +164 -99
  257. package/lib/esm/controller/componentController.js +5 -4
  258. package/lib/esm/hooks/useChatAdapterStore.js +0 -4
  259. package/lib/esm/hooks/useChatContextStore.js +0 -4
  260. package/lib/esm/hooks/useChatSDKStore.js +0 -4
  261. package/lib/esm/plugins/newMessageEventHandler.js +19 -26
  262. package/lib/types/assets/Icons.d.ts +1 -0
  263. package/lib/types/common/Constants.d.ts +20 -0
  264. package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
  265. package/lib/types/common/storage/default/defaultCacheManager.d.ts +4 -0
  266. package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -0
  267. package/lib/types/common/storage/default/defaultInMemoryDataStore.d.ts +6 -0
  268. package/lib/types/common/telemetry/TelemetryConstants.d.ts +31 -9
  269. package/lib/types/common/telemetry/definitions/Contracts.d.ts +4 -4
  270. package/lib/types/common/telemetry/definitions/Payload.d.ts +1 -0
  271. package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +4 -0
  272. package/lib/types/common/utils.d.ts +7 -3
  273. package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +2 -1
  274. package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
  275. package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
  276. package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
  277. package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
  278. package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
  279. package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
  280. package/lib/types/components/livechatwidget/common/authHelper.d.ts +5 -0
  281. package/lib/types/components/livechatwidget/common/defaultProps/defaultScrollBarProps.d.ts +2 -0
  282. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +6 -7
  283. package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
  284. package/lib/types/components/livechatwidget/common/startChat.d.ts +6 -2
  285. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +2 -1
  286. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +5 -2
  287. package/lib/types/components/livechatwidget/interfaces/IScrollBarProps.d.ts +22 -0
  288. package/lib/types/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.d.ts +2 -0
  289. package/lib/types/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.d.ts +2 -2
  290. package/lib/types/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.d.ts +5 -0
  291. package/lib/types/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +4 -0
  292. package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -2
  293. package/lib/types/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.d.ts +2 -0
  294. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
  295. package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +4 -0
  296. package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
  297. package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +4 -1
  298. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +4 -0
  299. package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
  300. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -1
  301. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
  302. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
  303. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.d.ts +2 -0
  304. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.d.ts +3 -0
  305. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.d.ts +3 -0
  306. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
  307. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.d.ts +1 -1
  308. package/lib/types/contexts/common/ConversationState.d.ts +3 -2
  309. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +5 -3
  310. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +30 -25
  311. package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +1 -2
  312. package/package.json +5 -4
@@ -4,21 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _Constants = require("../../../../../common/Constants");
9
-
10
8
  var _DirectLineSenderRole = require("../../enums/DirectLineSenderRole");
11
-
12
9
  var _MessageType = require("../../enums/MessageType");
13
-
14
10
  var _WebChatActionType = require("../../enums/WebChatActionType");
15
-
16
11
  /******
17
12
  * ConversationEndMiddleware
18
13
  *
19
14
  * This middleware is invoked when the conversation is ended by the agent/bot.
20
15
  * The callback is then invoked to hide the send box (by default).
21
16
  ******/
17
+
22
18
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
23
19
  const createConversationEndMiddleware = conversationEndCallback => _ref => {
24
20
  let {
@@ -26,32 +22,25 @@ const createConversationEndMiddleware = conversationEndCallback => _ref => {
26
22
  } = _ref;
27
23
  return next => action => {
28
24
  var _action$payload;
29
-
30
25
  if ((action === null || action === void 0 ? void 0 : action.type) == _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && (_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.activity) {
31
26
  var _activity$from, _activity$from2, _activity$channelData7, _activity$channelData8;
32
-
33
27
  const activity = action.payload.activity;
34
-
35
28
  if (((_activity$from = activity.from) === null || _activity$from === void 0 ? void 0 : _activity$from.role) === _DirectLineSenderRole.DirectLineSenderRole.Bot && activity.channelId === "ACS_CHANNEL") {
36
29
  var _activity$channelData, _activity$channelData2, _activity$channelData3, _activity$channelData4, _activity$channelData5, _activity$channelData6;
37
-
38
30
  // ACS
39
31
  if ((_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData2 = _activity$channelData.tags) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.includes(_Constants.Constants.systemMessageTag) && ((_activity$channelData3 = activity.channelData) !== null && _activity$channelData3 !== void 0 && (_activity$channelData4 = _activity$channelData3.tags) !== null && _activity$channelData4 !== void 0 && _activity$channelData4.includes(_Constants.Constants.agentEndConversationMessageTag) || (_activity$channelData5 = activity.channelData) !== null && _activity$channelData5 !== void 0 && (_activity$channelData6 = _activity$channelData5.tags) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.includes(_Constants.Constants.supervisorForceCloseMessageTag))) {
40
32
  conversationEndCallback();
41
33
  }
42
34
  } else if (((_activity$from2 = activity.from) === null || _activity$from2 === void 0 ? void 0 : _activity$from2.role) === _DirectLineSenderRole.DirectLineSenderRole.Channel && ((_activity$channelData7 = activity.channelData) === null || _activity$channelData7 === void 0 ? void 0 : _activity$channelData7.type) === _MessageType.MessageTypes.Thread && (_activity$channelData8 = activity.channelData) !== null && _activity$channelData8 !== void 0 && _activity$channelData8.properties) {
43
35
  var _activity$channelData9, _activity$channelData10, _activity$channelData11, _activity$channelData12;
44
-
45
36
  // IC3
46
37
  if (((_activity$channelData9 = activity.channelData) === null || _activity$channelData9 === void 0 ? void 0 : (_activity$channelData10 = _activity$channelData9.properties) === null || _activity$channelData10 === void 0 ? void 0 : _activity$channelData10.isdeleted) === _Constants.Constants.truePascal || !((_activity$channelData11 = activity.channelData) !== null && _activity$channelData11 !== void 0 && (_activity$channelData12 = _activity$channelData11.properties) !== null && _activity$channelData12 !== void 0 && _activity$channelData12.containsExternalEntitiesListeningAll)) {
47
38
  conversationEndCallback();
48
39
  }
49
40
  }
50
41
  }
51
-
52
42
  return next(action);
53
43
  };
54
44
  };
55
-
56
45
  var _default = createConversationEndMiddleware;
57
46
  exports.default = _default;
@@ -4,27 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _TelemetryConstants = require("../../../../../common/telemetry/TelemetryConstants");
9
-
10
8
  var _TelemetryHelper = require("../../../../../common/telemetry/TelemetryHelper");
11
-
12
9
  var _WebChatActionType = require("../../enums/WebChatActionType");
13
-
14
10
  var _isMaskingFromCustomer = require("../../../common/utils/isMaskingFromCustomer");
15
-
16
11
  /******
17
12
  * DataMaskingMiddleware
18
13
  *
19
14
  * Applies data masking rules that Omnichannel Admin has configured.
20
15
  ******/
16
+
21
17
  const applyDataMasking = (action, regexCollection) => {
22
18
  const maskedChar = "#"; //to do: load from env once OC SDK supporting.
23
-
24
19
  let {
25
20
  text
26
21
  } = action.payload;
27
-
28
22
  if (!regexCollection) {
29
23
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
30
24
  Event: _TelemetryConstants.TelemetryEvent.InvalidConfiguration,
@@ -32,25 +26,28 @@ const applyDataMasking = (action, regexCollection) => {
32
26
  ErrorDetails: "Invalid data masking rules"
33
27
  }
34
28
  });
35
-
36
29
  return action;
37
30
  }
38
-
31
+ let isRuleMatched = false;
39
32
  for (const ruleId of Object.keys(regexCollection)) {
40
33
  const item = regexCollection[ruleId];
41
-
42
34
  if (item) {
43
35
  try {
44
36
  const regex = new RegExp(item, "gi");
45
- let match; // eslint-disable-next-line no-cond-assign
46
-
37
+ let match;
38
+ // eslint-disable-next-line no-cond-assign
47
39
  while (match = regex.exec(text)) {
48
40
  const replaceStr = match[0].replace(/./gi, maskedChar);
49
41
  text = text.replace(match[0], replaceStr);
42
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
43
+ Event: _TelemetryConstants.TelemetryEvent.DataMaskingRuleApplied,
44
+ Description: `Data Masking Rule Id: ${ruleId} applied.`
45
+ });
46
+ isRuleMatched = true;
50
47
  }
51
48
  } catch (err) {
52
49
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
53
- Event: _TelemetryConstants.TelemetryEvent.DataMaskingRuleApplied,
50
+ Event: _TelemetryConstants.TelemetryEvent.DataMaskingRuleApplyFailed,
54
51
  ExceptionDetails: {
55
52
  RuleId: ruleId,
56
53
  Exception: err
@@ -58,28 +55,29 @@ const applyDataMasking = (action, regexCollection) => {
58
55
  });
59
56
  }
60
57
  }
61
- }
62
58
 
59
+ // Exit if rule matched
60
+ if (isRuleMatched === true) {
61
+ break;
62
+ }
63
+ }
63
64
  action.payload.text = text;
64
65
  return action;
65
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
66
-
66
+ };
67
67
 
68
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
68
69
  const createDataMaskingMiddleware = dataMaskingInfo => _ref => {
69
70
  let {
70
71
  dispatch
71
72
  } = _ref;
72
73
  return next => action => {
73
74
  var _action$payload;
74
-
75
75
  if ((0, _isMaskingFromCustomer.isMaskingforCustomer)(dataMaskingInfo) && (_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.text && action.type === _WebChatActionType.WebChatActionType.WEB_CHAT_SEND_MESSAGE) {
76
76
  const regexCollection = dataMaskingInfo === null || dataMaskingInfo === void 0 ? void 0 : dataMaskingInfo.dataMaskingRules;
77
77
  return next(applyDataMasking(action, regexCollection));
78
78
  }
79
-
80
79
  return next(action);
81
80
  };
82
81
  };
83
-
84
82
  var _default = createDataMaskingMiddleware;
85
83
  exports.default = _default;
@@ -4,16 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _Constants = require("../../../../../common/Constants");
9
-
10
8
  var _WebChatActionType = require("../../enums/WebChatActionType");
11
-
12
9
  /******
13
10
  * GIFUploadMiddleware
14
11
  *
15
12
  * Ensures that GIF are properly uploaded.
16
13
  ******/
14
+
17
15
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
18
16
  const gifUploadMiddleware = _ref => {
19
17
  let {
@@ -22,16 +20,13 @@ const gifUploadMiddleware = _ref => {
22
20
  return next => action => {
23
21
  if (action.type === _WebChatActionType.WebChatActionType.DIRECT_LINE_POST_ACTIVITY) {
24
22
  var _activity$attachments, _activity$channelData, _activity$channelData2;
25
-
26
23
  const {
27
24
  payload: {
28
25
  activity
29
26
  }
30
27
  } = action;
31
-
32
28
  if ((activity === null || activity === void 0 ? void 0 : (_activity$attachments = activity.attachments) === null || _activity$attachments === void 0 ? void 0 : _activity$attachments.length) === (activity === null || activity === void 0 ? void 0 : (_activity$channelData = activity.channelData) === null || _activity$channelData === void 0 ? void 0 : (_activity$channelData2 = _activity$channelData.attachmentSizes) === null || _activity$channelData2 === void 0 ? void 0 : _activity$channelData2.length)) {
33
29
  var _activity$attachments2;
34
-
35
30
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
31
  activity === null || activity === void 0 ? void 0 : (_activity$attachments2 = activity.attachments) === null || _activity$attachments2 === void 0 ? void 0 : _activity$attachments2.forEach(attachment => {
37
32
  const {
@@ -39,17 +34,14 @@ const gifUploadMiddleware = _ref => {
39
34
  contentUrl,
40
35
  contentType
41
36
  } = attachment;
42
-
43
37
  if (contentType === _Constants.Constants.GifContentType && thumbnailUrl !== contentUrl) {
44
38
  attachment.thumbnailUrl = contentUrl;
45
39
  }
46
40
  });
47
41
  }
48
42
  }
49
-
50
43
  return next(action);
51
44
  };
52
45
  };
53
-
54
46
  var _default = gifUploadMiddleware;
55
47
  exports.default = _default;
@@ -4,21 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _Constants = require("../../../../../common/Constants");
9
-
10
8
  var _WebChatActionType = require("../../enums/WebChatActionType");
11
-
12
9
  /******
13
10
  * HTMLPlayerMiddleware
14
11
  *
15
12
  * Ensures that video/audio attachment are properly rendered.
16
13
  ******/
14
+
17
15
  const disableHTMLPlayerDownloadButton = htmlTag => {
18
16
  setTimeout(() => {
19
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
18
  const elements = document.getElementsByTagName(htmlTag);
21
-
22
19
  for (let index = 0; index < elements.length; index++) {
23
20
  if (!elements[index].getAttribute(_Constants.Constants.controlsList)) {
24
21
  elements[index].setAttribute(_Constants.Constants.controlsList, _Constants.Constants.nodownload);
@@ -30,24 +27,21 @@ const disableHTMLPlayerDownloadButton = htmlTag => {
30
27
  }
31
28
  }
32
29
  }, 500);
33
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
34
-
30
+ };
35
31
 
32
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
36
33
  const htmlPlayerMiddleware = _ref => {
37
34
  let {
38
35
  dispatch
39
36
  } = _ref;
40
37
  return next => action => {
41
38
  var _action$payload, _action$payload$activ, _action$payload$activ2;
42
-
43
39
  if (action.type === _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && ((_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : (_action$payload$activ = _action$payload.activity) === null || _action$payload$activ === void 0 ? void 0 : (_action$payload$activ2 = _action$payload$activ.attachments) === null || _action$payload$activ2 === void 0 ? void 0 : _action$payload$activ2.length) > 0) {
44
40
  disableHTMLPlayerDownloadButton(_Constants.Constants.video);
45
41
  disableHTMLPlayerDownloadButton(_Constants.Constants.audio);
46
42
  }
47
-
48
43
  return next(action);
49
44
  };
50
45
  };
51
-
52
46
  var _default = htmlPlayerMiddleware;
53
47
  exports.default = _default;
@@ -4,36 +4,28 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _Constants = require("../../../../../common/Constants");
9
-
10
8
  var _dompurify = _interopRequireDefault(require("dompurify"));
11
-
12
9
  var _WebChatActionType = require("../../enums/WebChatActionType");
13
-
14
10
  var _TelemetryHelper = require("../../../../../common/telemetry/TelemetryHelper");
15
-
16
11
  var _TelemetryConstants = require("../../../../../common/telemetry/TelemetryConstants");
17
-
18
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
13
  /******
21
14
  * HTMLTextMiddleware
22
15
  *
23
16
  * Ensures that links within messages are processed so that the caller website cannot be traced.
24
17
  ******/
18
+
25
19
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
20
  const convertTextToHtmlNode = text => {
27
21
  if (!text) return "";
28
22
  const element = document.createElement(_Constants.HtmlAttributeNames.div);
29
-
30
23
  try {
31
24
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
25
  text = _dompurify.default.sanitize(text);
33
26
  element.innerHTML = text;
34
27
  } catch (e) {
35
28
  const errorMessage = `Failed to purify and set innertHTML with text: ${text}`;
36
-
37
29
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
38
30
  Event: _TelemetryConstants.TelemetryEvent.ProcessingHTMLTextMiddlewareFailed,
39
31
  ExceptionDetails: {
@@ -42,56 +34,50 @@ const convertTextToHtmlNode = text => {
42
34
  }
43
35
  });
44
36
  }
45
-
46
37
  return element;
47
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
-
38
+ };
49
39
 
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
41
  const processHTMLText = (action, text) => {
51
42
  const htmlNode = convertTextToHtmlNode(text);
52
43
  const aNodes = htmlNode.getElementsByTagName(_Constants.HtmlAttributeNames.aTagName);
53
-
54
44
  if ((aNodes === null || aNodes === void 0 ? void 0 : aNodes.length) > 0) {
55
45
  try {
56
46
  for (let index = 0; index < aNodes.length; index++) {
57
47
  var _aNode$tagName;
58
-
59
- const aNode = aNodes[index]; // Skip if the node is not valid or the node's tag name is not equal to 'a', or the node href is empty.
60
-
48
+ const aNode = aNodes[index];
49
+ // Skip if the node is not valid or the node's tag name is not equal to 'a', or the node href is empty.
61
50
  if (((_aNode$tagName = aNode.tagName) === null || _aNode$tagName === void 0 ? void 0 : _aNode$tagName.toLowerCase()) !== _Constants.HtmlAttributeNames.aTagName || !aNode.href) {
62
51
  continue;
63
- } // Add target to 'a' node if target is missing or does not equal to blank
64
-
52
+ }
65
53
 
54
+ // Add target to 'a' node if target is missing or does not equal to blank
66
55
  if (!aNode.target || aNode.target !== _Constants.Constants.blank) {
67
56
  aNode.target = _Constants.Constants.blank;
68
- } // If rel is missing or rel does not include noopener and noreferrer, add them
69
-
57
+ }
70
58
 
59
+ // If rel is missing or rel does not include noopener and noreferrer, add them
71
60
  if (!aNode.rel) {
72
61
  aNode.rel = `${_Constants.HtmlAttributeNames.noopenerTag} ${_Constants.HtmlAttributeNames.noreferrerTag}`;
73
62
  } else {
74
63
  if (aNode.rel.indexOf(_Constants.HtmlAttributeNames.noopenerTag) === -1) {
75
64
  aNode.rel += ` ${_Constants.HtmlAttributeNames.noopenerTag}`;
76
65
  }
77
-
78
66
  if (aNode.rel.indexOf(_Constants.HtmlAttributeNames.noreferrerTag) === -1) {
79
67
  aNode.rel += ` ${_Constants.HtmlAttributeNames.noreferrerTag}`;
80
68
  }
81
69
  }
82
- } // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
-
70
+ }
84
71
 
72
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
73
  action = window.simpleUpdateIn(action, [_Constants.Constants.payload, _Constants.Constants.activity, _Constants.Constants.text], () => htmlNode.innerHTML);
86
74
  } catch (e) {
87
75
  let errorMessage = "Failed to apply action: ";
88
-
89
76
  try {
90
77
  errorMessage += JSON.stringify(action);
91
78
  } catch (e) {
92
79
  errorMessage += " (unable to stringify action)";
93
80
  }
94
-
95
81
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
96
82
  Event: _TelemetryConstants.TelemetryEvent.ProcessingHTMLTextMiddlewareFailed,
97
83
  ExceptionDetails: {
@@ -101,11 +87,10 @@ const processHTMLText = (action, text) => {
101
87
  });
102
88
  }
103
89
  }
104
-
105
90
  return action;
106
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
107
-
91
+ };
108
92
 
93
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
109
94
  const htmlTextMiddleware = _ref => {
110
95
  let {
111
96
  dispatch
@@ -114,21 +99,17 @@ const htmlTextMiddleware = _ref => {
114
99
  if (action.type === _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY) {
115
100
  try {
116
101
  var _action$payload, _action$payload$activ;
117
-
118
102
  const text = (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : (_action$payload$activ = _action$payload.activity) === null || _action$payload$activ === void 0 ? void 0 : _action$payload$activ.text;
119
-
120
103
  if (text) {
121
104
  action = processHTMLText(action, text);
122
105
  }
123
106
  } catch (e) {
124
107
  let errorMessage = "Failed to validate action.";
125
-
126
108
  try {
127
109
  errorMessage += JSON.stringify(action);
128
110
  } catch (e) {
129
111
  errorMessage += " (unable to stringify action)";
130
112
  }
131
-
132
113
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
133
114
  Event: _TelemetryConstants.TelemetryEvent.ProcessingHTMLTextMiddlewareFailed,
134
115
  ExceptionDetails: {
@@ -138,10 +119,8 @@ const htmlTextMiddleware = _ref => {
138
119
  });
139
120
  }
140
121
  }
141
-
142
122
  return next(action);
143
123
  };
144
124
  };
145
-
146
125
  var _default = htmlTextMiddleware;
147
126
  exports.default = _default;
@@ -4,20 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _NotificationHandler = require("../../notification/NotificationHandler");
9
-
10
8
  var _NotificationScenarios = require("../../enums/NotificationScenarios");
11
-
12
9
  var _WebChatActionType = require("../../enums/WebChatActionType");
13
-
14
10
  var _Constants = require("../../../../../common/Constants");
15
-
16
11
  /******
17
12
  * MaxMessageSizeValidator
18
13
  *
19
14
  * Enforces a max character limit that the sender can send to comply to Omnichannel chat services' limitation.
20
15
  ******/
16
+
21
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
22
18
  const createMaxMessageSizeValidator = localizedTexts => _ref => {
23
19
  let {
@@ -26,21 +22,16 @@ const createMaxMessageSizeValidator = localizedTexts => _ref => {
26
22
  return next => action => {
27
23
  if (action.type === _WebChatActionType.WebChatActionType.WEB_CHAT_SET_SEND_BOX) {
28
24
  var _action$payload, _action$payload$text;
29
-
30
25
  const textLength = ((_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : (_action$payload$text = _action$payload.text) === null || _action$payload$text === void 0 ? void 0 : _action$payload$text.length) || 0;
31
-
32
26
  if (textLength > _Constants.WebChatMiddlewareConstants.maxTextLength) {
33
27
  _NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.MaxSizeError, localizedTexts.MIDDLEWARE_MAX_CHARACTER_COUNT_EXCEEDED);
34
-
35
28
  return next(action);
36
29
  } else {
37
30
  _NotificationHandler.NotificationHandler.dismissNotification(_NotificationScenarios.NotificationScenarios.MaxSizeError);
38
31
  }
39
32
  }
40
-
41
33
  return next(action);
42
34
  };
43
35
  };
44
-
45
36
  var _default = createMaxMessageSizeValidator;
46
37
  exports.default = _default;
@@ -4,16 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _Constants = require("../../../../../common/Constants");
9
-
10
8
  var _WebChatActionType = require("../../enums/WebChatActionType");
11
-
12
9
  /******
13
10
  * PreProcessingMiddleware
14
11
  *
15
12
  * Adds necessary fields for the activity for the other middlewares to function as expected.
16
13
  ******/
14
+
17
15
  // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
18
16
  const preProcessingMiddleware = _ref => {
19
17
  let {
@@ -24,31 +22,29 @@ const preProcessingMiddleware = _ref => {
24
22
  const {
25
23
  activity
26
24
  } = action.payload;
27
-
28
25
  if (!activity.from || activity.from.role === _Constants.Constants.userMessageTag) {
29
- action = { ...action,
30
- payload: { ...action.payload,
31
- activity: { ...action.payload.activity,
26
+ action = {
27
+ ...action,
28
+ payload: {
29
+ ...action.payload,
30
+ activity: {
31
+ ...action.payload.activity,
32
32
  textFormat: _Constants.Constants.markdown
33
33
  }
34
34
  }
35
35
  };
36
36
  }
37
37
  }
38
-
39
38
  if (action.type === _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY) {
40
39
  const {
41
40
  activity
42
41
  } = action.payload;
43
-
44
42
  if (activity) {
45
43
  action.payload.activity[_Constants.Constants.actionType] = _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY;
46
44
  }
47
45
  }
48
-
49
46
  return next(action);
50
47
  };
51
48
  };
52
-
53
49
  var _default = preProcessingMiddleware;
54
50
  exports.default = _default;
@@ -4,22 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _dompurify = _interopRequireDefault(require("dompurify"));
9
-
10
8
  var _TelemetryConstants = require("../../../../../common/telemetry/TelemetryConstants");
11
-
12
9
  var _TelemetryHelper = require("../../../../../common/telemetry/TelemetryHelper");
13
-
14
10
  var _WebChatActionType = require("../../enums/WebChatActionType");
15
-
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
12
  /******
19
13
  * SanitizationMiddleware
20
14
  *
21
15
  * Sanitizes the text.
22
16
  ******/
17
+
23
18
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
24
19
  const sanitizationMiddleware = _ref => {
25
20
  let {
@@ -29,26 +24,24 @@ const sanitizationMiddleware = _ref => {
29
24
  if (action.type === _WebChatActionType.WebChatActionType.WEB_CHAT_SEND_MESSAGE) {
30
25
  try {
31
26
  var _action$payload;
32
-
33
27
  let text = (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : _action$payload.text;
34
-
35
28
  if (text) {
36
29
  text = _dompurify.default.sanitize(text) ?? " ";
37
30
  }
38
31
  } catch (e) {
39
- const copyDataForTelemetry = { ...action,
40
- payload: { ...action.payload,
32
+ const copyDataForTelemetry = {
33
+ ...action,
34
+ payload: {
35
+ ...action.payload,
41
36
  text: undefined
42
37
  }
43
38
  };
44
39
  let errorMessage = "Failed to apply action: ";
45
-
46
40
  try {
47
41
  errorMessage += JSON.stringify(copyDataForTelemetry);
48
42
  } catch (e) {
49
43
  errorMessage += " (unable to stringify action)";
50
44
  }
51
-
52
45
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
53
46
  Event: _TelemetryConstants.TelemetryEvent.ProcessingSanitizationMiddlewareFailed,
54
47
  ExceptionDetails: {
@@ -58,10 +51,8 @@ const sanitizationMiddleware = _ref => {
58
51
  });
59
52
  }
60
53
  }
61
-
62
54
  return next(action);
63
55
  };
64
56
  };
65
-
66
57
  var _default = sanitizationMiddleware;
67
58
  exports.default = _default;
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.NotificationHandler = void 0;
7
-
8
7
  var _Constants = require("../../../../common/Constants");
9
-
10
8
  var _NotificationLevel = require("../enums/NotificationLevel");
11
-
12
9
  var _WebChatActionType = require("../enums/WebChatActionType");
13
-
14
10
  var _WebChatStoreLoader = require("../WebChatStoreLoader");
15
-
16
11
  var _utils = require("../../../../common/utils");
17
-
18
12
  class NotificationHandler {
19
13
  static notify(id, level, message) {
20
14
  if (_WebChatStoreLoader.WebChatStoreLoader.store) {
@@ -26,11 +20,9 @@ class NotificationHandler {
26
20
  message
27
21
  }
28
22
  });
29
-
30
23
  NotificationHandler.setFocusOnNotificationCloseButton();
31
24
  }
32
25
  }
33
-
34
26
  static dismissNotification(id) {
35
27
  if (_WebChatStoreLoader.WebChatStoreLoader.store) {
36
28
  _WebChatStoreLoader.WebChatStoreLoader.store.dispatch({
@@ -41,23 +33,18 @@ class NotificationHandler {
41
33
  });
42
34
  }
43
35
  }
44
-
45
36
  static notifyError(id, message) {
46
37
  this.notify(id, _NotificationLevel.NotificationLevel.Error, message);
47
38
  }
48
-
49
39
  static notifyWarning(id, message) {
50
40
  this.notify(id, _NotificationLevel.NotificationLevel.Warning, message);
51
41
  }
52
-
53
42
  static notifyInfo(id, message) {
54
43
  this.notify(id, _NotificationLevel.NotificationLevel.Info, message);
55
44
  }
56
-
57
45
  static notifySuccess(id, message) {
58
46
  this.notify(id, _NotificationLevel.NotificationLevel.Success, message);
59
47
  }
60
-
61
48
  static notifyWithLevel(id, message, level) {
62
49
  if (!level) {
63
50
  this.notifyInfo(id, message);
@@ -65,32 +52,25 @@ class NotificationHandler {
65
52
  this.notify(id, level, message);
66
53
  }
67
54
  }
68
- /* Bypass WebChat behavior and focus on banner close button */
69
-
70
55
 
56
+ /* Bypass WebChat behavior and focus on banner close button */
71
57
  static setFocusOnNotificationCloseButton() {
72
58
  const expandButton = document.querySelector(`#${_Constants.HtmlIdNames.MSLiveChatWidget} .${_Constants.HtmlClassNames.webChatBannerExpandButton}`);
73
-
74
59
  if (expandButton) {
75
60
  expandButton.focus();
76
61
  return;
77
62
  }
78
-
79
63
  const closeButton = document.querySelector(`#${_Constants.HtmlIdNames.MSLiveChatWidget} .${_Constants.HtmlClassNames.webChatBannerCloseButton}`);
80
-
81
64
  if (closeButton) {
82
65
  closeButton.focus();
83
66
  NotificationHandler.registerOnCloseEvent(closeButton);
84
67
  return;
85
68
  }
86
69
  }
87
-
88
70
  static registerOnCloseEvent(button) {
89
71
  button.onclick = () => {
90
72
  (0, _utils.setFocusOnSendBox)();
91
73
  };
92
74
  }
93
-
94
75
  }
95
-
96
76
  exports.NotificationHandler = NotificationHandler;