@microsoft/omnichannel-chat-widget 0.1.0-main.3d1c026 → 0.1.0-main.4151518

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 (388) hide show
  1. package/README.md +232 -0
  2. package/lib/cjs/assets/Audios.js +8 -0
  3. package/lib/cjs/assets/Icons.js +30 -0
  4. package/lib/cjs/common/Constants.js +61 -151
  5. package/lib/cjs/common/KeyCodes.js +3 -4
  6. package/lib/cjs/common/contextDataStore/DataStoreManager.js +12 -0
  7. package/lib/cjs/common/storage/default/defaultCacheManager.js +26 -0
  8. package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +111 -0
  9. package/lib/cjs/common/storage/default/defaultInMemoryDataStore.js +78 -0
  10. package/lib/cjs/common/telemetry/TelemetryConstants.js +118 -26
  11. package/lib/cjs/common/telemetry/TelemetryHelper.js +31 -56
  12. package/lib/cjs/common/telemetry/TelemetryManager.js +17 -35
  13. package/lib/cjs/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
  14. package/lib/cjs/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -3
  15. package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +49 -35
  16. package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -14
  17. package/lib/cjs/common/utils.js +101 -80
  18. package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +21 -45
  19. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +20 -26
  20. package/lib/cjs/components/chatbuttonstateful/common/styleProps/defaultOutOfOfficeChatButtonStyleProps.js +3 -0
  21. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +21 -99
  22. package/lib/cjs/components/dimlayer/DimLayer.js +0 -4
  23. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +11 -39
  24. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.spec.js +6 -8
  25. package/lib/cjs/components/footerstateful/FooterStateful.js +14 -46
  26. package/lib/cjs/components/footerstateful/audionotificationstateful/AudioNotificationStateful.js +0 -6
  27. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +15 -44
  28. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.spec.js +6 -8
  29. package/lib/cjs/components/headerstateful/HeaderStateful.js +27 -35
  30. package/lib/cjs/components/livechatwidget/LiveChatWidget.js +2 -14
  31. package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +39 -0
  32. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +139 -0
  33. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +20 -0
  34. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  35. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +34 -0
  36. package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +64 -0
  37. package/lib/cjs/components/livechatwidget/common/Deferred.js +37 -0
  38. package/lib/cjs/components/livechatwidget/common/agentEndConversationHelper.js +36 -0
  39. package/lib/cjs/components/livechatwidget/common/authHelper.js +50 -0
  40. package/lib/cjs/components/livechatwidget/common/createAdapter.js +12 -9
  41. package/lib/cjs/components/livechatwidget/common/createFooter.js +4 -23
  42. package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +10 -10
  43. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +36 -44
  44. package/lib/cjs/components/livechatwidget/common/defaultProps/defaultScrollBarProps.js +14 -0
  45. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +151 -68
  46. package/lib/cjs/components/livechatwidget/common/disposeTelemetryLoggers.js +0 -3
  47. package/lib/cjs/components/livechatwidget/common/endChat.js +151 -61
  48. package/lib/cjs/components/livechatwidget/common/getGeneralStylesForButton.js +0 -6
  49. package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +10 -14
  50. package/lib/cjs/components/livechatwidget/common/initConfirmationPropsComposer.js +4 -8
  51. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +34 -74
  52. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +102 -66
  53. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +13 -20
  54. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +271 -29
  55. package/lib/cjs/components/livechatwidget/common/shareObservable.js +41 -0
  56. package/lib/cjs/components/livechatwidget/common/startChat.js +281 -67
  57. package/lib/cjs/components/livechatwidget/common/startProactiveChat.js +3 -11
  58. package/lib/cjs/components/livechatwidget/common/updateSessionDataForTelemetry.js +2 -11
  59. package/lib/cjs/components/livechatwidget/interfaces/IScrollBarProps.js +1 -0
  60. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +413 -165
  61. package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +38 -26
  62. package/lib/cjs/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.js +57 -0
  63. package/lib/cjs/components/loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.js +1 -0
  64. package/lib/cjs/components/loadingpanestateful/interfaces/IStartChatErrorPaneProps.js +1 -0
  65. package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +9 -14
  66. package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +9 -14
  67. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +35 -24
  68. package/lib/cjs/components/postchatsurveypanestateful/common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps.js +1 -1
  69. package/lib/cjs/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +13 -0
  70. package/lib/cjs/components/postchatsurveypanestateful/enums/PostChatSurveyMode.js +0 -1
  71. package/lib/cjs/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.js +1 -0
  72. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +27 -43
  73. package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
  74. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +27 -35
  75. package/lib/cjs/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js +1 -0
  76. package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +8 -24
  77. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +94 -19
  78. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -7
  79. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -6
  80. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +11 -0
  81. package/lib/cjs/components/webchatcontainerstateful/common/mockadapter.js +12 -27
  82. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +9 -16
  83. package/lib/cjs/components/webchatcontainerstateful/common/utils/BrowserInfo.js +2 -24
  84. package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +56 -88
  85. package/lib/cjs/components/webchatcontainerstateful/common/utils/isMaskingFromCustomer.js +5 -8
  86. package/lib/cjs/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
  87. package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  88. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +12 -0
  89. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +3 -5
  90. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/BrowserVendor.js +0 -1
  91. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineActivityType.js +0 -1
  92. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineSenderRole.js +0 -1
  93. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/MessageType.js +0 -1
  94. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/NotificationLevel.js +0 -1
  95. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +0 -1
  96. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/SendStatus.js +0 -1
  97. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/enums/WebChatActionType.js +0 -1
  98. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsEgressMiddleware.js +0 -7
  99. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsIngressMiddleware.js +0 -5
  100. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +33 -80
  101. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +10 -22
  102. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +27 -61
  103. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.js +7 -15
  104. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
  105. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +82 -0
  106. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +10 -0
  107. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +10 -0
  108. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampFailedStyles.js +2 -3
  109. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +2 -3
  110. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +10 -0
  111. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware.js +3 -9
  112. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +89 -0
  113. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +7 -18
  114. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +8 -42
  115. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +4 -22
  116. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +20 -33
  117. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +3 -9
  118. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +81 -45
  119. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +1 -10
  120. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +7 -18
  121. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +17 -19
  122. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.js +1 -9
  123. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.js +3 -9
  124. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +13 -34
  125. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.js +1 -10
  126. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.js +7 -11
  127. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +5 -14
  128. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +1 -21
  129. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +33 -0
  130. package/lib/cjs/contexts/ChatAdapterStore.js +0 -2
  131. package/lib/cjs/contexts/ChatContextStore.js +0 -2
  132. package/lib/cjs/contexts/ChatSDKStore.js +0 -2
  133. package/lib/cjs/contexts/common/ConversationEndEntity.js +12 -0
  134. package/lib/cjs/contexts/common/ConversationState.js +4 -3
  135. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +34 -24
  136. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +24 -12
  137. package/lib/cjs/contexts/createReducer.js +213 -106
  138. package/lib/cjs/controller/componentController.js +5 -34
  139. package/lib/cjs/hooks/useChatAdapterStore.js +0 -6
  140. package/lib/cjs/hooks/useChatContextStore.js +0 -6
  141. package/lib/cjs/hooks/useChatSDKStore.js +0 -6
  142. package/lib/cjs/hooks/useDebounce.js +28 -0
  143. package/lib/cjs/hooks/useWindowDimensions.js +30 -0
  144. package/lib/cjs/index.js +0 -5
  145. package/lib/cjs/plugins/newMessageEventHandler.js +92 -0
  146. package/lib/esm/assets/Audios.js +1 -0
  147. package/lib/esm/assets/Icons.js +12 -0
  148. package/lib/esm/common/Constants.js +55 -139
  149. package/lib/esm/common/KeyCodes.js +3 -3
  150. package/lib/esm/common/contextDataStore/DataStoreManager.js +5 -0
  151. package/lib/esm/common/interfaces/IContextDataStore.js +1 -0
  152. package/lib/esm/common/storage/default/defaultCacheManager.js +18 -0
  153. package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +104 -0
  154. package/lib/esm/common/storage/default/defaultInMemoryDataStore.js +70 -0
  155. package/lib/esm/common/telemetry/TelemetryConstants.js +117 -21
  156. package/lib/esm/common/telemetry/TelemetryHelper.js +32 -46
  157. package/lib/esm/common/telemetry/TelemetryManager.js +17 -24
  158. package/lib/esm/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
  159. package/lib/esm/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
  160. package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +49 -23
  161. package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -10
  162. package/lib/esm/common/utils.js +92 -44
  163. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +21 -16
  164. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +23 -13
  165. package/lib/esm/components/chatbuttonstateful/common/styleProps/defaultOutOfOfficeChatButtonStyleProps.js +3 -0
  166. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +22 -75
  167. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +11 -18
  168. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.spec.js +6 -6
  169. package/lib/esm/components/footerstateful/FooterStateful.js +15 -26
  170. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +15 -37
  171. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.spec.js +6 -6
  172. package/lib/esm/components/headerstateful/HeaderStateful.js +28 -21
  173. package/lib/esm/components/livechatwidget/LiveChatWidget.js +2 -2
  174. package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +32 -0
  175. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +134 -0
  176. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +13 -0
  177. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  178. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +27 -0
  179. package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +57 -0
  180. package/lib/esm/components/livechatwidget/common/Deferred.js +30 -0
  181. package/lib/esm/components/livechatwidget/common/agentEndConversationHelper.js +30 -0
  182. package/lib/esm/components/livechatwidget/common/authHelper.js +42 -0
  183. package/lib/esm/components/livechatwidget/common/createAdapter.js +14 -4
  184. package/lib/esm/components/livechatwidget/common/createFooter.js +4 -16
  185. package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +10 -5
  186. package/lib/esm/components/livechatwidget/common/createMarkdown.js +38 -37
  187. package/lib/esm/components/livechatwidget/common/defaultProps/defaultScrollBarProps.js +7 -0
  188. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +152 -57
  189. package/lib/esm/components/livechatwidget/common/endChat.js +152 -47
  190. package/lib/esm/components/livechatwidget/common/getGeneralStylesForButton.js +0 -2
  191. package/lib/esm/components/livechatwidget/common/initCallingSdk.js +12 -11
  192. package/lib/esm/components/livechatwidget/common/initConfirmationPropsComposer.js +4 -5
  193. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +35 -45
  194. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +102 -58
  195. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +13 -12
  196. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +272 -22
  197. package/lib/esm/components/livechatwidget/common/shareObservable.js +35 -0
  198. package/lib/esm/components/livechatwidget/common/startChat.js +284 -52
  199. package/lib/esm/components/livechatwidget/common/startProactiveChat.js +5 -5
  200. package/lib/esm/components/livechatwidget/common/updateSessionDataForTelemetry.js +4 -2
  201. package/lib/esm/components/livechatwidget/interfaces/IScrollBarProps.js +1 -0
  202. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +415 -117
  203. package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +39 -14
  204. package/lib/esm/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.js +50 -0
  205. package/lib/esm/components/loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.js +1 -0
  206. package/lib/esm/components/loadingpanestateful/interfaces/IStartChatErrorPaneProps.js +1 -0
  207. package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +9 -4
  208. package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +9 -4
  209. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +35 -12
  210. package/lib/esm/components/postchatsurveypanestateful/common/defaultStyleProps/defaultgeneralPostChatSurveyPaneStyleProps.js +1 -1
  211. package/lib/esm/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.js +6 -0
  212. package/lib/esm/components/postchatsurveypanestateful/enums/PostChatSurveyMode.js +0 -1
  213. package/lib/esm/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.js +1 -0
  214. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +30 -28
  215. package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
  216. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +30 -14
  217. package/lib/esm/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js +1 -0
  218. package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +8 -6
  219. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +94 -4
  220. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -1
  221. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatStatefulProps.js +2 -2
  222. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +4 -0
  223. package/lib/esm/components/webchatcontainerstateful/common/mockadapter.js +12 -19
  224. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +9 -12
  225. package/lib/esm/components/webchatcontainerstateful/common/utils/BrowserInfo.js +2 -16
  226. package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +7 -17
  227. package/lib/esm/components/webchatcontainerstateful/common/utils/isMaskingFromCustomer.js +5 -6
  228. package/lib/esm/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
  229. package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  230. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
  231. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +3 -3
  232. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/BrowserVendor.js +0 -1
  233. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineActivityType.js +0 -1
  234. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/DirectLineSenderRole.js +0 -1
  235. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/MessageType.js +0 -1
  236. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/NotificationLevel.js +0 -1
  237. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios.js +0 -1
  238. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/SendStatus.js +0 -1
  239. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/enums/WebChatActionType.js +0 -1
  240. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsEgressMiddleware.js +2 -5
  241. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsIngressMiddleware.js +0 -4
  242. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +34 -66
  243. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +12 -14
  244. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +27 -40
  245. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.js +9 -8
  246. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +34 -0
  247. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +80 -0
  248. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +3 -0
  249. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +3 -0
  250. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampFailedStyles.js +2 -1
  251. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +2 -1
  252. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +3 -0
  253. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware.js +3 -7
  254. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +83 -0
  255. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +8 -9
  256. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +9 -28
  257. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +5 -14
  258. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +20 -22
  259. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +5 -8
  260. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +81 -40
  261. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +3 -7
  262. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +9 -14
  263. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +17 -14
  264. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.js +3 -7
  265. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.js +3 -7
  266. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +15 -27
  267. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.js +3 -5
  268. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.js +9 -9
  269. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +7 -9
  270. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +1 -13
  271. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +27 -0
  272. package/lib/esm/contexts/ChatAdapterStore.js +2 -1
  273. package/lib/esm/contexts/ChatContextStore.js +2 -1
  274. package/lib/esm/contexts/ChatSDKStore.js +2 -1
  275. package/lib/esm/contexts/common/ConversationEndEntity.js +5 -0
  276. package/lib/esm/contexts/common/ConversationState.js +4 -3
  277. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +34 -24
  278. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +24 -8
  279. package/lib/esm/contexts/createReducer.js +213 -102
  280. package/lib/esm/controller/componentController.js +6 -5
  281. package/lib/esm/hooks/useChatAdapterStore.js +0 -4
  282. package/lib/esm/hooks/useChatContextStore.js +0 -4
  283. package/lib/esm/hooks/useChatSDKStore.js +0 -4
  284. package/lib/esm/hooks/useDebounce.js +22 -0
  285. package/lib/esm/hooks/useWindowDimensions.js +23 -0
  286. package/lib/esm/plugins/newMessageEventHandler.js +85 -0
  287. package/lib/types/assets/Audios.d.ts +1 -0
  288. package/lib/types/assets/Icons.d.ts +12 -0
  289. package/lib/types/common/Constants.d.ts +48 -1
  290. package/lib/types/common/contextDataStore/DataStoreManager.d.ts +4 -0
  291. package/lib/types/common/interfaces/IContextDataStore.d.ts +14 -0
  292. package/lib/types/common/storage/default/defaultCacheManager.d.ts +4 -0
  293. package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -0
  294. package/lib/types/common/storage/default/defaultInMemoryDataStore.d.ts +6 -0
  295. package/lib/types/common/telemetry/TelemetryConstants.d.ts +85 -7
  296. package/lib/types/common/telemetry/TelemetryHelper.d.ts +2 -0
  297. package/lib/types/common/telemetry/definitions/Contracts.d.ts +4 -4
  298. package/lib/types/common/telemetry/definitions/Payload.d.ts +13 -9
  299. package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +7 -3
  300. package/lib/types/common/utils.d.ts +9 -1
  301. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +0 -4
  302. package/lib/types/components/footerstateful/audionotificationstateful/interfaces/IAudioNotificationStatefulParams.d.ts +0 -1
  303. package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +5 -1
  304. package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
  305. package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +9 -0
  306. package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
  307. package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
  308. package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
  309. package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
  310. package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
  311. package/lib/types/components/livechatwidget/common/agentEndConversationHelper.d.ts +6 -0
  312. package/lib/types/components/livechatwidget/common/authHelper.d.ts +5 -0
  313. package/lib/types/components/livechatwidget/common/defaultProps/defaultScrollBarProps.d.ts +2 -0
  314. package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -1
  315. package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +1 -1
  316. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +6 -4
  317. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +6 -1
  318. package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
  319. package/lib/types/components/livechatwidget/common/startChat.d.ts +5 -2
  320. package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +2 -1
  321. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
  322. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +4 -1
  323. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +9 -2
  324. package/lib/types/components/livechatwidget/interfaces/IScrollBarProps.d.ts +22 -0
  325. package/lib/types/components/loadingpanestateful/LoadingPaneStateful.d.ts +1 -2
  326. package/lib/types/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.d.ts +2 -0
  327. package/lib/types/components/loadingpanestateful/interfaces/IStartChatErrorPaneControlProps.d.ts +4 -0
  328. package/lib/types/components/loadingpanestateful/interfaces/IStartChatErrorPaneProps.d.ts +4 -0
  329. package/lib/types/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.d.ts +2 -2
  330. package/lib/types/components/postchatsurveypanestateful/enums/CustomerVoiceEvents.d.ts +5 -0
  331. package/lib/types/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +4 -0
  332. package/lib/types/components/prechatsurveypanestateful/interfaces/IPreChatSurveyPaneStatefulParams.d.ts +1 -1
  333. package/lib/types/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.d.ts +3 -0
  334. package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +1 -2
  335. package/lib/types/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.d.ts +2 -0
  336. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +2 -0
  337. package/lib/types/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.d.ts +1 -1
  338. package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +4 -0
  339. package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
  340. package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +4 -1
  341. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +4 -0
  342. package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
  343. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +0 -1
  344. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -1
  345. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
  346. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
  347. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.d.ts +2 -0
  348. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.d.ts +3 -0
  349. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.d.ts +3 -0
  350. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
  351. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.d.ts +1 -1
  352. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.d.ts +1 -1
  353. package/lib/types/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.d.ts +1 -0
  354. package/lib/types/contexts/common/ConversationEndEntity.d.ts +4 -0
  355. package/lib/types/contexts/common/ConversationState.d.ts +4 -2
  356. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +13 -4
  357. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +34 -23
  358. package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +1 -2
  359. package/lib/types/hooks/useDebounce.d.ts +3 -0
  360. package/lib/types/hooks/useWindowDimensions.d.ts +4 -0
  361. package/lib/types/plugins/newMessageEventHandler.d.ts +2 -0
  362. package/package.json +12 -13
  363. package/lib/cjs/assets/audios/newMessageNotification.mp3 +0 -0
  364. package/lib/cjs/assets/icons/archiveIcon.svg +0 -3
  365. package/lib/cjs/assets/icons/audioIcon.svg +0 -6
  366. package/lib/cjs/assets/icons/blankIcon.svg +0 -6
  367. package/lib/cjs/assets/icons/excelIcon.svg +0 -6
  368. package/lib/cjs/assets/icons/imageIcon.svg +0 -6
  369. package/lib/cjs/assets/icons/oneNoteIcon.svg +0 -6
  370. package/lib/cjs/assets/icons/pdfIcon.svg +0 -6
  371. package/lib/cjs/assets/icons/powerpointIcon.svg +0 -6
  372. package/lib/cjs/assets/icons/videoIcon.svg +0 -6
  373. package/lib/cjs/assets/icons/visioIcon.svg +0 -6
  374. package/lib/cjs/assets/icons/wordIcon.svg +0 -6
  375. package/lib/esm/assets/assets.d.js +0 -0
  376. package/lib/esm/assets/audios/newMessageNotification.mp3 +0 -0
  377. package/lib/esm/assets/icons/archiveIcon.svg +0 -3
  378. package/lib/esm/assets/icons/audioIcon.svg +0 -6
  379. package/lib/esm/assets/icons/blankIcon.svg +0 -6
  380. package/lib/esm/assets/icons/excelIcon.svg +0 -6
  381. package/lib/esm/assets/icons/imageIcon.svg +0 -6
  382. package/lib/esm/assets/icons/oneNoteIcon.svg +0 -6
  383. package/lib/esm/assets/icons/pdfIcon.svg +0 -6
  384. package/lib/esm/assets/icons/powerpointIcon.svg +0 -6
  385. package/lib/esm/assets/icons/videoIcon.svg +0 -6
  386. package/lib/esm/assets/icons/visioIcon.svg +0 -6
  387. package/lib/esm/assets/icons/wordIcon.svg +0 -6
  388. /package/lib/cjs/{assets/assets.d.js → common/interfaces/IContextDataStore.js} +0 -0
@@ -3,36 +3,37 @@
3
3
  *
4
4
  * Checks if the attachment being uploaded satisfies Omnichannel's requirement on file extensions and file size.
5
5
  ******/
6
+
7
+ import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
6
8
  import { NotificationHandler } from "../../notification/NotificationHandler";
7
9
  import { NotificationScenarios } from "../../enums/NotificationScenarios";
8
10
  import { WebChatActionType } from "../../enums/WebChatActionType";
11
+ import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
12
+ import { AMSConstants } from "../../../../../common/Constants";
9
13
  const MBtoBRatio = 1000000;
14
+
10
15
  /*
11
16
  * If an attachment is invalid, delete this attachment from the attachments list
12
17
  * If the result attachment list is empty, return a dummy action
13
18
  */
14
-
15
- const validateAttachment = (action, allowedFileExtensions, maxUploadFileSize, localizedTexts) => {
19
+ const validateAttachment = (action, allowedFileExtensions, maxFileSizeSupportedByDynamics, localizedTexts) => {
16
20
  var _action$payload, _action$payload$activ, _action$payload2, _action$payload2$acti, _action$payload2$acti2, _action$payload3, _action$payload3$acti, _action$payload3$acti2;
17
-
18
21
  const attachments = action === null || action === void 0 ? void 0 : (_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.attachments;
19
22
  const attachmentSizes = action === null || action === void 0 ? void 0 : (_action$payload2 = action.payload) === null || _action$payload2 === void 0 ? void 0 : (_action$payload2$acti = _action$payload2.activity) === null || _action$payload2$acti === void 0 ? void 0 : (_action$payload2$acti2 = _action$payload2$acti.channelData) === null || _action$payload2$acti2 === void 0 ? void 0 : _action$payload2$acti2.attachmentSizes;
20
-
21
23
  if (attachments) {
22
24
  for (let i = 0; i < attachments.length; i++) {
25
+ const maxUploadFileSize = getMaxUploadFileSize(maxFileSizeSupportedByDynamics, attachments[i].contentType);
23
26
  const fileExtensionValid = validateFileExtension(attachments[i], allowedFileExtensions);
24
27
  const fileSizeValid = validateFileSize(attachmentSizes[i], maxUploadFileSize);
25
28
  const fileIsEmpty = parseInt(attachmentSizes[i]) == 0;
26
-
27
29
  if (!fileExtensionValid || !fileSizeValid || fileIsEmpty) {
28
- NotificationHandler.notifyError(NotificationScenarios.AttachmentError, buildErrorMessage(attachments[i].name, fileExtensionValid, fileSizeValid, fileIsEmpty, maxUploadFileSize, localizedTexts));
30
+ NotificationHandler.notifyError(NotificationScenarios.AttachmentError, buildErrorMessage(attachments[i].name, fileExtensionValid, fileSizeValid, fileIsEmpty, maxUploadFileSize.toString(), maxFileSizeSupportedByDynamics, localizedTexts));
29
31
  attachments.splice(i, 1);
30
32
  attachmentSizes.splice(i, 1);
31
33
  i--;
32
34
  }
33
35
  }
34
36
  }
35
-
36
37
  if ((action === null || action === void 0 ? void 0 : (_action$payload3 = action.payload) === null || _action$payload3 === void 0 ? void 0 : (_action$payload3$acti = _action$payload3.activity) === null || _action$payload3$acti === void 0 ? void 0 : (_action$payload3$acti2 = _action$payload3$acti.attachments) === null || _action$payload3$acti2 === void 0 ? void 0 : _action$payload3$acti2.length) > 0) {
37
38
  return action;
38
39
  } else {
@@ -41,109 +42,149 @@ const validateAttachment = (action, allowedFileExtensions, maxUploadFileSize, lo
41
42
  payload: null
42
43
  };
43
44
  }
44
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
-
45
+ };
46
46
 
47
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
48
  const validateFileExtension = (attachment, allowedFileExtensions) => {
48
49
  if (!allowedFileExtensions) {
49
50
  return true;
50
51
  }
51
-
52
52
  const fileName = attachment.name.toLowerCase();
53
53
  const index = fileName.lastIndexOf(".");
54
-
55
54
  if (!index) {
56
55
  return false;
57
56
  }
58
-
59
57
  const fileExtension = fileName.substring(index);
60
58
  const allExtensions = allowedFileExtensions === null || allowedFileExtensions === void 0 ? void 0 : allowedFileExtensions.toLowerCase().split(",");
61
59
  return allExtensions.indexOf(fileExtension) > -1;
62
60
  };
63
-
64
61
  const validateFileSize = (attachmentSize, maxUploadFileSize) => {
65
- return (maxUploadFileSize && parseInt(maxUploadFileSize) * MBtoBRatio) > parseInt(attachmentSize);
62
+ return maxUploadFileSize * MBtoBRatio > parseInt(attachmentSize);
66
63
  };
67
-
68
- const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize, fileIsEmpty, maxUploadFileSize, localizedTexts) => {
64
+ const getMaxUploadFileSize = (maxFileSizeSupportedByDynamicsStr, contentType) => {
65
+ const maxFileSizeSupportedByDynamics = maxFileSizeSupportedByDynamicsStr && parseInt(maxFileSizeSupportedByDynamicsStr) ? parseInt(maxFileSizeSupportedByDynamicsStr) : AMSConstants.maxSupportedFileSize;
66
+ const amsAttachmentSizeLimit = isImage(contentType) ? AMSConstants.maxSupportedImageSize : AMSConstants.maxSupportedFileSize;
67
+ // Takes the smallest max file size configure betteween AMS and Dynamics Config
68
+ return maxFileSizeSupportedByDynamics < amsAttachmentSizeLimit ? maxFileSizeSupportedByDynamics : amsAttachmentSizeLimit;
69
+ };
70
+ const isImage = contentType => {
71
+ return AMSConstants.supportedImagesMimeTypes.includes(contentType);
72
+ };
73
+ const buildErrorMessage = (fileName, supportedFileExtension, supportedFileSize, fileIsEmpty, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
69
74
  let errorMessage = "";
70
-
71
75
  if (!fileName || !maxUploadFileSize) {
76
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
77
+ Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
78
+ Description: "Attachment validation failed",
79
+ ExceptionDetails: {
80
+ ErrorDetails: "File provided is null"
81
+ }
82
+ });
72
83
  return localizedTexts.MIDDLEWARE_BANNER_FILE_NULL_ERROR ?? "";
73
84
  }
74
-
75
85
  if (!supportedFileExtension && !supportedFileSize) {
76
- errorMessage = getFileSizeAndFileExtensionErrorMessage(fileName, maxUploadFileSize, localizedTexts);
86
+ errorMessage = getFileSizeAndFileExtensionErrorMessage(fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
77
87
  } else if (!supportedFileSize) {
78
- errorMessage = getFileSizeErrorMessage(maxUploadFileSize, localizedTexts);
88
+ errorMessage = getFileSizeErrorMessage(maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts);
79
89
  } else if (!supportedFileExtension) {
80
90
  errorMessage = getFileExtensionErrorMessage(fileName, localizedTexts);
81
91
  } else if (fileIsEmpty) {
92
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
93
+ Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
94
+ Description: "Attachment validation failed",
95
+ ExceptionDetails: {
96
+ ErrorDetails: "File provided is empty"
97
+ }
98
+ });
82
99
  errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_IS_EMPTY_ERROR ?? "";
83
100
  } else {
101
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
102
+ Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
103
+ Description: "Attachment validation failed",
104
+ ExceptionDetails: {
105
+ ErrorDetails: `Unexpected error: supportedFileExtension=${supportedFileExtension} supportedFileSize=${supportedFileSize} fileIsEmpty=${!fileIsEmpty}`
106
+ }
107
+ });
84
108
  errorMessage = localizedTexts.MIDDLEWARE_BANNER_ERROR_MESSAGE ?? "";
85
109
  }
86
-
87
110
  return errorMessage;
88
111
  };
89
-
90
- const getFileSizeAndFileExtensionErrorMessage = (fileName, maxUploadFileSize, localizedTexts) => {
112
+ const getFileSizeAndFileExtensionErrorMessage = (fileName, maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
91
113
  const index = fileName.lastIndexOf(".");
92
- let errorMessage;
93
-
114
+ let errorMessage, exceptionDetails;
94
115
  if (index < 0) {
95
116
  errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_WITHOUT_EXTENSION_ERROR;
117
+ exceptionDetails = `File exceeded the allowed limit of ${maxUploadFileSize} MB and File provided without file extension`;
96
118
  } else {
97
119
  var _errorMessage;
98
-
99
120
  const fileExtension = fileName.substring(index);
100
121
  errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_EXTENSION_ERROR;
101
-
122
+ exceptionDetails = `File exceeds the allowed limit of ${maxUploadFileSize} MB and ${fileExtension} files are not supported`;
102
123
  if ((_errorMessage = errorMessage) !== null && _errorMessage !== void 0 && _errorMessage.includes("{1}")) {
103
124
  errorMessage = errorMessage.replace("{1}", fileExtension);
104
125
  }
105
126
  }
106
-
127
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
128
+ Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
129
+ Description: "Attachment validation failed",
130
+ ExceptionDetails: {
131
+ ErrorDetails: `${exceptionDetails} Dynamics file size limit=${maxFileSizeSupportedByDynamics} AMS image size limit=${AMSConstants.maxSupportedImageSize} AMS file size limit=${AMSConstants.maxSupportedFileSize}`
132
+ }
133
+ });
107
134
  return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", maxUploadFileSize) : errorMessage : "";
108
135
  };
109
-
110
136
  const getFileExtensionErrorMessage = (fileName, localizedTexts) => {
111
137
  const index = fileName.lastIndexOf(".");
112
-
113
138
  if (index < 0) {
139
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
140
+ Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
141
+ Description: "Attachment validation failed",
142
+ ExceptionDetails: {
143
+ ErrorDetails: "File provided without file extension"
144
+ }
145
+ });
114
146
  return localizedTexts.MIDDLEWARE_BANNER_FILE_WITHOUT_EXTENSION ?? "";
115
147
  } else {
116
148
  const fileExtension = fileName.substring(index);
149
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
150
+ Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
151
+ Description: "Attachment validation failed",
152
+ ExceptionDetails: {
153
+ ErrorDetails: `${fileExtension} files extension is not supported.`
154
+ }
155
+ });
117
156
  const errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_EXTENSION_ERROR;
118
157
  return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", fileExtension) : errorMessage : "";
119
158
  }
120
159
  };
121
-
122
- const getFileSizeErrorMessage = (maxUploadFileSize, localizedTexts) => {
160
+ const getFileSizeErrorMessage = (maxUploadFileSize, maxFileSizeSupportedByDynamics, localizedTexts) => {
161
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
162
+ Event: TelemetryEvent.AttachmentUploadValidatorMiddlewareFailed,
163
+ Description: "Attachment validation failed",
164
+ ExceptionDetails: {
165
+ ErrorDetails: `File exceeds the allowed limit of ${maxUploadFileSize}MB. Dynamics file size limit=${maxFileSizeSupportedByDynamics} AMS image size limit=${AMSConstants.maxSupportedImageSize} AMS file size limit=${AMSConstants.maxSupportedFileSize}`
166
+ }
167
+ });
123
168
  const errorMessage = localizedTexts.MIDDLEWARE_BANNER_FILE_SIZE_ERROR;
124
169
  return errorMessage ? errorMessage.includes("{0}") ? errorMessage.replace("{0}", maxUploadFileSize) : errorMessage : "";
125
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
126
-
170
+ };
127
171
 
128
- const createAttachmentUploadValidatorMiddleware = (allowedFileExtensions, maxUploadFileSize, localizedTexts) => _ref => {
172
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
173
+ const createAttachmentUploadValidatorMiddleware = (allowedFileExtensions, maxFileSizeSupportedByDynamics, localizedTexts) => _ref => {
129
174
  let {
130
175
  dispatch
131
176
  } = _ref;
132
177
  return next => action => {
133
178
  if (action.type === WebChatActionType.DIRECT_LINE_POST_ACTIVITY) {
134
179
  var _payload$activity, _payload$activity2, _payload$activity2$ch, _payload$activity3, _payload$activity3$at, _payload$activity4, _payload$activity4$ch, _payload$activity4$ch2;
135
-
136
180
  const {
137
181
  payload
138
182
  } = action;
139
-
140
183
  if (payload !== null && payload !== void 0 && (_payload$activity = payload.activity) !== null && _payload$activity !== void 0 && _payload$activity.attachments && payload !== null && payload !== void 0 && (_payload$activity2 = payload.activity) !== null && _payload$activity2 !== void 0 && (_payload$activity2$ch = _payload$activity2.channelData) !== null && _payload$activity2$ch !== void 0 && _payload$activity2$ch.attachmentSizes && (payload === null || payload === void 0 ? void 0 : (_payload$activity3 = payload.activity) === null || _payload$activity3 === void 0 ? void 0 : (_payload$activity3$at = _payload$activity3.attachments) === null || _payload$activity3$at === void 0 ? void 0 : _payload$activity3$at.length) === (payload === null || payload === void 0 ? void 0 : (_payload$activity4 = payload.activity) === null || _payload$activity4 === void 0 ? void 0 : (_payload$activity4$ch = _payload$activity4.channelData) === null || _payload$activity4$ch === void 0 ? void 0 : (_payload$activity4$ch2 = _payload$activity4$ch.attachmentSizes) === null || _payload$activity4$ch2 === void 0 ? void 0 : _payload$activity4$ch2.length)) {
141
- return next(validateAttachment(action, allowedFileExtensions, maxUploadFileSize, localizedTexts));
184
+ return next(validateAttachment(action, allowedFileExtensions, maxFileSizeSupportedByDynamics, localizedTexts));
142
185
  }
143
186
  }
144
-
145
187
  return next(action);
146
188
  };
147
189
  };
148
-
149
190
  export default createAttachmentUploadValidatorMiddleware;
@@ -3,26 +3,25 @@
3
3
  *
4
4
  * Adds necessary tags if not present so that the rendering middlewares can process them later.
5
5
  ******/
6
+
6
7
  import { Constants } from "../../../../../common/Constants";
7
8
  import { DeliveryMode } from "@microsoft/omnichannel-chat-sdk";
8
- import { WebChatActionType } from "../../enums/WebChatActionType"; // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
9
+ import { WebChatActionType } from "../../enums/WebChatActionType";
9
10
 
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
10
12
  const channelDataMiddleware = _ref => {
11
13
  let {
12
14
  dispatch
13
15
  } = _ref;
14
16
  return next => action => {
15
17
  var _action$payload, _action$payload$activ;
16
-
17
18
  if ((action === null || action === void 0 ? void 0 : action.type) === WebChatActionType.DIRECT_LINE_POST_ACTIVITY_PENDING && action !== null && action !== void 0 && (_action$payload = action.payload) !== null && _action$payload !== void 0 && (_action$payload$activ = _action$payload.activity) !== null && _action$payload$activ !== void 0 && _action$payload$activ.channelData) {
18
19
  const channelIdTag = `${Constants.channelIdKey}${Constants.ChannelId}`;
19
20
  const customerMessageTag = `${Constants.CustomerTag}`;
20
-
21
21
  if (action.payload.activity.channelData.tags) {
22
22
  if (!action.payload.activity.channelData.tags.includes(channelIdTag)) {
23
23
  action.payload.activity.channelData.tags.push(channelIdTag);
24
24
  }
25
-
26
25
  if (!action.payload.activity.channelData.tags.includes(customerMessageTag)) {
27
26
  action.payload.activity.channelData.tags.push(customerMessageTag);
28
27
  }
@@ -30,14 +29,11 @@ const channelDataMiddleware = _ref => {
30
29
  action.payload.activity.channelData.tags = [channelIdTag];
31
30
  action.payload.activity.channelData.tags.push(customerMessageTag);
32
31
  }
33
-
34
32
  action.payload.activity.channelData.metadata = {
35
33
  deliveryMode: DeliveryMode.Bridged
36
34
  };
37
35
  }
38
-
39
36
  return next(action);
40
37
  };
41
38
  };
42
-
43
39
  export default channelDataMiddleware;
@@ -4,42 +4,37 @@
4
4
  * This middleware is invoked when the conversation is ended by the agent/bot.
5
5
  * The callback is then invoked to hide the send box (by default).
6
6
  ******/
7
+
7
8
  import { Constants } from "../../../../../common/Constants";
8
9
  import { DirectLineSenderRole } from "../../enums/DirectLineSenderRole";
9
10
  import { MessageTypes } from "../../enums/MessageType";
10
- import { WebChatActionType } from "../../enums/WebChatActionType"; // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
11
+ import { WebChatActionType } from "../../enums/WebChatActionType";
11
12
 
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
12
14
  const createConversationEndMiddleware = conversationEndCallback => _ref => {
13
15
  let {
14
16
  dispatch
15
17
  } = _ref;
16
18
  return next => action => {
17
19
  var _action$payload;
18
-
19
20
  if ((action === null || action === void 0 ? void 0 : action.type) == WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && (_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.activity) {
20
- var _activity$from, _activity$from2, _activity$channelData5, _activity$channelData6;
21
-
21
+ var _activity$from, _activity$from2, _activity$channelData7, _activity$channelData8;
22
22
  const activity = action.payload.activity;
23
-
24
23
  if (((_activity$from = activity.from) === null || _activity$from === void 0 ? void 0 : _activity$from.role) === DirectLineSenderRole.Bot && activity.channelId === "ACS_CHANNEL") {
25
- var _activity$channelData, _activity$channelData2, _activity$channelData3, _activity$channelData4;
26
-
24
+ var _activity$channelData, _activity$channelData2, _activity$channelData3, _activity$channelData4, _activity$channelData5, _activity$channelData6;
27
25
  // ACS
28
- if ((_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData2 = _activity$channelData.tags) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.includes(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.agentEndConversationMessageTag)) {
26
+ if ((_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData2 = _activity$channelData.tags) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.includes(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.agentEndConversationMessageTag) || (_activity$channelData5 = activity.channelData) !== null && _activity$channelData5 !== void 0 && (_activity$channelData6 = _activity$channelData5.tags) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.includes(Constants.supervisorForceCloseMessageTag))) {
29
27
  conversationEndCallback();
30
28
  }
31
- } else if (((_activity$from2 = activity.from) === null || _activity$from2 === void 0 ? void 0 : _activity$from2.role) === DirectLineSenderRole.Channel && ((_activity$channelData5 = activity.channelData) === null || _activity$channelData5 === void 0 ? void 0 : _activity$channelData5.type) === MessageTypes.Thread && (_activity$channelData6 = activity.channelData) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.properties) {
32
- var _activity$channelData7, _activity$channelData8, _activity$channelData9, _activity$channelData10;
33
-
29
+ } else if (((_activity$from2 = activity.from) === null || _activity$from2 === void 0 ? void 0 : _activity$from2.role) === DirectLineSenderRole.Channel && ((_activity$channelData7 = activity.channelData) === null || _activity$channelData7 === void 0 ? void 0 : _activity$channelData7.type) === MessageTypes.Thread && (_activity$channelData8 = activity.channelData) !== null && _activity$channelData8 !== void 0 && _activity$channelData8.properties) {
30
+ var _activity$channelData9, _activity$channelData10, _activity$channelData11, _activity$channelData12;
34
31
  // IC3
35
- if (((_activity$channelData7 = activity.channelData) === null || _activity$channelData7 === void 0 ? void 0 : (_activity$channelData8 = _activity$channelData7.properties) === null || _activity$channelData8 === void 0 ? void 0 : _activity$channelData8.isdeleted) === Constants.truePascal || !((_activity$channelData9 = activity.channelData) !== null && _activity$channelData9 !== void 0 && (_activity$channelData10 = _activity$channelData9.properties) !== null && _activity$channelData10 !== void 0 && _activity$channelData10.containsExternalEntitiesListeningAll)) {
32
+ 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.truePascal || !((_activity$channelData11 = activity.channelData) !== null && _activity$channelData11 !== void 0 && (_activity$channelData12 = _activity$channelData11.properties) !== null && _activity$channelData12 !== void 0 && _activity$channelData12.containsExternalEntitiesListeningAll)) {
36
33
  conversationEndCallback();
37
34
  }
38
35
  }
39
36
  }
40
-
41
37
  return next(action);
42
38
  };
43
39
  };
44
-
45
40
  export default createConversationEndMiddleware;
@@ -3,18 +3,16 @@
3
3
  *
4
4
  * Applies data masking rules that Omnichannel Admin has configured.
5
5
  ******/
6
+
6
7
  import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
7
8
  import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
8
9
  import { WebChatActionType } from "../../enums/WebChatActionType";
9
10
  import { isMaskingforCustomer } from "../../../common/utils/isMaskingFromCustomer";
10
-
11
11
  const applyDataMasking = (action, regexCollection) => {
12
12
  const maskedChar = "#"; //to do: load from env once OC SDK supporting.
13
-
14
13
  let {
15
14
  text
16
15
  } = action.payload;
17
-
18
16
  if (!regexCollection) {
19
17
  TelemetryHelper.logActionEvent(LogLevel.ERROR, {
20
18
  Event: TelemetryEvent.InvalidConfiguration,
@@ -24,22 +22,26 @@ const applyDataMasking = (action, regexCollection) => {
24
22
  });
25
23
  return action;
26
24
  }
27
-
25
+ let isRuleMatched = false;
28
26
  for (const ruleId of Object.keys(regexCollection)) {
29
27
  const item = regexCollection[ruleId];
30
-
31
28
  if (item) {
32
29
  try {
33
30
  const regex = new RegExp(item, "gi");
34
- let match; // eslint-disable-next-line no-cond-assign
35
-
31
+ let match;
32
+ // eslint-disable-next-line no-cond-assign
36
33
  while (match = regex.exec(text)) {
37
34
  const replaceStr = match[0].replace(/./gi, maskedChar);
38
35
  text = text.replace(match[0], replaceStr);
36
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
37
+ Event: TelemetryEvent.DataMaskingRuleApplied,
38
+ Description: `Data Masking Rule Id: ${ruleId} applied.`
39
+ });
40
+ isRuleMatched = true;
39
41
  }
40
42
  } catch (err) {
41
43
  TelemetryHelper.logActionEvent(LogLevel.ERROR, {
42
- Event: TelemetryEvent.DataMaskingRuleApplied,
44
+ Event: TelemetryEvent.DataMaskingRuleApplyFailed,
43
45
  ExceptionDetails: {
44
46
  RuleId: ruleId,
45
47
  Exception: err
@@ -47,27 +49,28 @@ const applyDataMasking = (action, regexCollection) => {
47
49
  });
48
50
  }
49
51
  }
50
- }
51
52
 
53
+ // Exit if rule matched
54
+ if (isRuleMatched === true) {
55
+ break;
56
+ }
57
+ }
52
58
  action.payload.text = text;
53
59
  return action;
54
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
55
-
60
+ };
56
61
 
62
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
57
63
  const createDataMaskingMiddleware = dataMaskingInfo => _ref => {
58
64
  let {
59
65
  dispatch
60
66
  } = _ref;
61
67
  return next => action => {
62
68
  var _action$payload;
63
-
64
69
  if (isMaskingforCustomer(dataMaskingInfo) && (_action$payload = action.payload) !== null && _action$payload !== void 0 && _action$payload.text && action.type === WebChatActionType.WEB_CHAT_SEND_MESSAGE) {
65
70
  const regexCollection = dataMaskingInfo === null || dataMaskingInfo === void 0 ? void 0 : dataMaskingInfo.dataMaskingRules;
66
71
  return next(applyDataMasking(action, regexCollection));
67
72
  }
68
-
69
73
  return next(action);
70
74
  };
71
75
  };
72
-
73
76
  export default createDataMaskingMiddleware;
@@ -3,9 +3,11 @@
3
3
  *
4
4
  * Ensures that GIF are properly uploaded.
5
5
  ******/
6
+
6
7
  import { Constants } from "../../../../../common/Constants";
7
- import { WebChatActionType } from "../../enums/WebChatActionType"; // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
8
+ import { WebChatActionType } from "../../enums/WebChatActionType";
8
9
 
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
9
11
  const gifUploadMiddleware = _ref => {
10
12
  let {
11
13
  dispatch
@@ -13,16 +15,13 @@ const gifUploadMiddleware = _ref => {
13
15
  return next => action => {
14
16
  if (action.type === WebChatActionType.DIRECT_LINE_POST_ACTIVITY) {
15
17
  var _activity$attachments, _activity$channelData, _activity$channelData2;
16
-
17
18
  const {
18
19
  payload: {
19
20
  activity
20
21
  }
21
22
  } = action;
22
-
23
23
  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)) {
24
24
  var _activity$attachments2;
25
-
26
25
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
26
  activity === null || activity === void 0 ? void 0 : (_activity$attachments2 = activity.attachments) === null || _activity$attachments2 === void 0 ? void 0 : _activity$attachments2.forEach(attachment => {
28
27
  const {
@@ -30,16 +29,13 @@ const gifUploadMiddleware = _ref => {
30
29
  contentUrl,
31
30
  contentType
32
31
  } = attachment;
33
-
34
32
  if (contentType === Constants.GifContentType && thumbnailUrl !== contentUrl) {
35
33
  attachment.thumbnailUrl = contentUrl;
36
34
  }
37
35
  });
38
36
  }
39
37
  }
40
-
41
38
  return next(action);
42
39
  };
43
40
  };
44
-
45
41
  export default gifUploadMiddleware;
@@ -3,14 +3,13 @@
3
3
  *
4
4
  * Ensures that video/audio attachment are properly rendered.
5
5
  ******/
6
+
6
7
  import { Constants } from "../../../../../common/Constants";
7
8
  import { WebChatActionType } from "../../enums/WebChatActionType";
8
-
9
9
  const disableHTMLPlayerDownloadButton = htmlTag => {
10
10
  setTimeout(() => {
11
11
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
12
  const elements = document.getElementsByTagName(htmlTag);
13
-
14
13
  for (let index = 0; index < elements.length; index++) {
15
14
  if (!elements[index].getAttribute(Constants.controlsList)) {
16
15
  elements[index].setAttribute(Constants.controlsList, Constants.nodownload);
@@ -22,23 +21,20 @@ const disableHTMLPlayerDownloadButton = htmlTag => {
22
21
  }
23
22
  }
24
23
  }, 500);
25
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
26
-
24
+ };
27
25
 
26
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
28
27
  const htmlPlayerMiddleware = _ref => {
29
28
  let {
30
29
  dispatch
31
30
  } = _ref;
32
31
  return next => action => {
33
32
  var _action$payload, _action$payload$activ, _action$payload$activ2;
34
-
35
33
  if (action.type === 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) {
36
34
  disableHTMLPlayerDownloadButton(Constants.video);
37
35
  disableHTMLPlayerDownloadButton(Constants.audio);
38
36
  }
39
-
40
37
  return next(action);
41
38
  };
42
39
  };
43
-
44
40
  export default htmlPlayerMiddleware;
@@ -3,16 +3,17 @@
3
3
  *
4
4
  * Ensures that links within messages are processed so that the caller website cannot be traced.
5
5
  ******/
6
+
6
7
  import { Constants, HtmlAttributeNames } from "../../../../../common/Constants";
7
8
  import DOMPurify from "dompurify";
8
9
  import { WebChatActionType } from "../../enums/WebChatActionType";
9
10
  import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
10
- import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
11
12
 
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
14
  const convertTextToHtmlNode = text => {
13
15
  if (!text) return "";
14
16
  const element = document.createElement(HtmlAttributeNames.div);
15
-
16
17
  try {
17
18
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
19
  text = DOMPurify.sanitize(text);
@@ -27,56 +28,50 @@ const convertTextToHtmlNode = text => {
27
28
  }
28
29
  });
29
30
  }
30
-
31
31
  return element;
32
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
-
32
+ };
34
33
 
34
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
35
  const processHTMLText = (action, text) => {
36
36
  const htmlNode = convertTextToHtmlNode(text);
37
37
  const aNodes = htmlNode.getElementsByTagName(HtmlAttributeNames.aTagName);
38
-
39
38
  if ((aNodes === null || aNodes === void 0 ? void 0 : aNodes.length) > 0) {
40
39
  try {
41
40
  for (let index = 0; index < aNodes.length; index++) {
42
41
  var _aNode$tagName;
43
-
44
- 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.
45
-
42
+ const aNode = aNodes[index];
43
+ // Skip if the node is not valid or the node's tag name is not equal to 'a', or the node href is empty.
46
44
  if (((_aNode$tagName = aNode.tagName) === null || _aNode$tagName === void 0 ? void 0 : _aNode$tagName.toLowerCase()) !== HtmlAttributeNames.aTagName || !aNode.href) {
47
45
  continue;
48
- } // Add target to 'a' node if target is missing or does not equal to blank
49
-
46
+ }
50
47
 
48
+ // Add target to 'a' node if target is missing or does not equal to blank
51
49
  if (!aNode.target || aNode.target !== Constants.blank) {
52
50
  aNode.target = Constants.blank;
53
- } // If rel is missing or rel does not include noopener and noreferrer, add them
54
-
51
+ }
55
52
 
53
+ // If rel is missing or rel does not include noopener and noreferrer, add them
56
54
  if (!aNode.rel) {
57
55
  aNode.rel = `${HtmlAttributeNames.noopenerTag} ${HtmlAttributeNames.noreferrerTag}`;
58
56
  } else {
59
57
  if (aNode.rel.indexOf(HtmlAttributeNames.noopenerTag) === -1) {
60
58
  aNode.rel += ` ${HtmlAttributeNames.noopenerTag}`;
61
59
  }
62
-
63
60
  if (aNode.rel.indexOf(HtmlAttributeNames.noreferrerTag) === -1) {
64
61
  aNode.rel += ` ${HtmlAttributeNames.noreferrerTag}`;
65
62
  }
66
63
  }
67
- } // eslint-disable-next-line @typescript-eslint/no-explicit-any
68
-
64
+ }
69
65
 
66
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
67
  action = window.simpleUpdateIn(action, [Constants.payload, Constants.activity, Constants.text], () => htmlNode.innerHTML);
71
68
  } catch (e) {
72
69
  let errorMessage = "Failed to apply action: ";
73
-
74
70
  try {
75
71
  errorMessage += JSON.stringify(action);
76
72
  } catch (e) {
77
73
  errorMessage += " (unable to stringify action)";
78
74
  }
79
-
80
75
  TelemetryHelper.logActionEvent(LogLevel.ERROR, {
81
76
  Event: TelemetryEvent.ProcessingHTMLTextMiddlewareFailed,
82
77
  ExceptionDetails: {
@@ -86,11 +81,10 @@ const processHTMLText = (action, text) => {
86
81
  });
87
82
  }
88
83
  }
89
-
90
84
  return action;
91
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
92
-
85
+ };
93
86
 
87
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
94
88
  const htmlTextMiddleware = _ref => {
95
89
  let {
96
90
  dispatch
@@ -99,21 +93,17 @@ const htmlTextMiddleware = _ref => {
99
93
  if (action.type === WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY) {
100
94
  try {
101
95
  var _action$payload, _action$payload$activ;
102
-
103
96
  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;
104
-
105
97
  if (text) {
106
98
  action = processHTMLText(action, text);
107
99
  }
108
100
  } catch (e) {
109
101
  let errorMessage = "Failed to validate action.";
110
-
111
102
  try {
112
103
  errorMessage += JSON.stringify(action);
113
104
  } catch (e) {
114
105
  errorMessage += " (unable to stringify action)";
115
106
  }
116
-
117
107
  TelemetryHelper.logActionEvent(LogLevel.ERROR, {
118
108
  Event: TelemetryEvent.ProcessingHTMLTextMiddlewareFailed,
119
109
  ExceptionDetails: {
@@ -123,9 +113,7 @@ const htmlTextMiddleware = _ref => {
123
113
  });
124
114
  }
125
115
  }
126
-
127
116
  return next(action);
128
117
  };
129
118
  };
130
-
131
119
  export default htmlTextMiddleware;