@microsoft/omnichannel-chat-widget 1.8.7 → 2.0.0-main.ba244dd
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.
- package/README.md +42 -3
- package/lib/cjs/common/Constants.js +5 -0
- package/lib/cjs/common/facades/FacadeChatSDK.js +234 -9
- package/lib/cjs/common/telemetry/TelemetryConstants.js +17 -0
- package/lib/cjs/common/telemetry/TelemetryManager.js +6 -1
- package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +2 -3
- package/lib/cjs/common/telemetry/sanitizeSasInPayload.js +91 -0
- package/lib/cjs/common/utils.js +93 -17
- package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +16 -6
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +20 -10
- package/lib/cjs/components/citationpanestateful/CitationDim.js +2 -3
- package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +27 -5
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +23 -3
- package/lib/cjs/components/dimlayer/DimLayer.js +1 -3
- package/lib/cjs/components/draggable/DraggableChatWidget.js +35 -15
- package/lib/cjs/components/draggable/DraggableEventEmitter.js +10 -1
- package/lib/cjs/components/draggable/DraggableEventReceiver.js +1 -3
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +54 -17
- package/lib/cjs/components/errorboundary/ErrorBoundary.js +4 -12
- package/lib/cjs/components/footerstateful/FooterStateful.js +18 -9
- package/lib/cjs/components/footerstateful/audionotificationstateful/AudioNotificationStateful.js +2 -4
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +4 -6
- package/lib/cjs/components/headerstateful/HeaderStateful.js +24 -12
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +27 -4
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +5 -11
- package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +1 -0
- package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +11 -4
- package/lib/cjs/components/livechatwidget/common/authHelper.js +44 -4
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +98 -5
- package/lib/cjs/components/livechatwidget/common/endChat.js +12 -9
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +182 -1
- package/lib/cjs/components/livechatwidget/common/startChat.js +31 -14
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +158 -21
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +16 -11
- package/lib/cjs/components/notificationpanestateful/NotificationPaneStateful.js +19 -12
- package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +13 -6
- package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +28 -5
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +12 -5
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +105 -11
- package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +12 -1
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -7
- package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +16 -7
- package/lib/cjs/components/startchaterrorpanestateful/StartChatErrorPaneStateful.js +10 -2
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +154 -29
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +10 -0
- package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +115 -10
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -0
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +2 -2
- package/lib/cjs/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +3 -1
- package/lib/cjs/components/webchatcontainerstateful/common/utils/citationA11y.js +195 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IWebChatAction.js +17 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +27 -4
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsEgressMiddleware.js +1 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsIngressMiddleware.js +1 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +180 -190
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +3 -5
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +22 -6
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +12 -23
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +27 -35
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.js +199 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Attachment.js +29 -15
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.js +5 -12
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +8 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +8 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware.js +5 -8
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.js +6 -4
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +6 -4
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +14 -12
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +16 -14
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +18 -30
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +10 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/toastMiddleware.js +1 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +16 -12
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +6 -6
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.js +83 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +36 -8
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.js +5 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +10 -7
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +4 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -4
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.js +5 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +7 -7
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.js +10 -14
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.js +6 -4
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +13 -10
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +57 -11
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.js +6 -4
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.js +25 -30
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +10 -7
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +6 -4
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +55 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +2 -4
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +5 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +17 -1
- package/lib/cjs/contexts/createReducer.js +15 -0
- package/lib/cjs/controller/componentController.js +13 -1
- package/lib/cjs/hooks/useWindowDimensions.js +13 -5
- package/lib/cjs/package.json +1 -0
- package/lib/cjs/plugins/createChatTranscript.js +3 -4
- package/lib/cjs/plugins/newMessageEventHandler.js +20 -3
- package/lib/esm/common/Constants.js +5 -0
- package/lib/esm/common/facades/FacadeChatSDK.js +235 -10
- package/lib/esm/common/telemetry/TelemetryConstants.js +17 -0
- package/lib/esm/common/telemetry/TelemetryManager.js +6 -1
- package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +2 -3
- package/lib/esm/common/telemetry/sanitizeSasInPayload.js +84 -0
- package/lib/esm/common/utils.js +88 -14
- package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +15 -5
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +19 -9
- package/lib/esm/components/citationpanestateful/CitationDim.js +2 -3
- package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +26 -4
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +22 -2
- package/lib/esm/components/dimlayer/DimLayer.js +1 -3
- package/lib/esm/components/draggable/DraggableChatWidget.js +34 -14
- package/lib/esm/components/draggable/DraggableEventEmitter.js +10 -1
- package/lib/esm/components/draggable/DraggableEventReceiver.js +1 -3
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +54 -17
- package/lib/esm/components/errorboundary/ErrorBoundary.js +4 -12
- package/lib/esm/components/footerstateful/FooterStateful.js +17 -8
- package/lib/esm/components/footerstateful/audionotificationstateful/AudioNotificationStateful.js +2 -4
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +4 -6
- package/lib/esm/components/headerstateful/HeaderStateful.js +22 -10
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +27 -4
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +5 -11
- package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +1 -0
- package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +11 -4
- package/lib/esm/components/livechatwidget/common/authHelper.js +44 -4
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +98 -5
- package/lib/esm/components/livechatwidget/common/endChat.js +12 -9
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +182 -1
- package/lib/esm/components/livechatwidget/common/startChat.js +31 -14
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +157 -20
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +14 -9
- package/lib/esm/components/notificationpanestateful/NotificationPaneStateful.js +17 -10
- package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +12 -5
- package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +28 -5
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +11 -4
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +105 -11
- package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +12 -1
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +16 -6
- package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +15 -6
- package/lib/esm/components/startchaterrorpanestateful/StartChatErrorPaneStateful.js +9 -1
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +154 -29
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +10 -0
- package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +115 -10
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultWebChatStyles.js +2 -2
- package/lib/esm/components/webchatcontainerstateful/common/utils/chatAdapterUtils.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/utils/citationA11y.js +188 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IWebChatAction.js +10 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +27 -4
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsEgressMiddleware.js +1 -3
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/adaptermiddlewares/formatTagsIngressMiddleware.js +1 -3
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +180 -190
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LoadInlineBannerActivity.js +3 -5
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +19 -4
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +12 -23
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +27 -32
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.js +193 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/Attachment.js +28 -14
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.js +5 -12
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultAvatarTextStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.js +8 -3
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultTimestampRetryStyles.js +8 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware.js +5 -8
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.js +6 -4
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +6 -4
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +13 -11
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/HistoryMessageTimestamp.js +15 -13
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +17 -27
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +9 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/toastMiddleware.js +1 -3
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +16 -10
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.js +6 -6
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.js +77 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +36 -8
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.js +5 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +10 -7
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +4 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +6 -4
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.js +5 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.js +7 -7
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.js +10 -14
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.js +6 -4
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.js +13 -10
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +57 -11
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.js +6 -4
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.js +25 -31
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +10 -7
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.js +6 -4
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +55 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +2 -4
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +5 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +17 -1
- package/lib/esm/contexts/createReducer.js +15 -0
- package/lib/esm/controller/componentController.js +13 -1
- package/lib/esm/hooks/useWindowDimensions.js +13 -5
- package/lib/esm/plugins/createChatTranscript.js +3 -4
- package/lib/esm/plugins/newMessageEventHandler.js +20 -3
- package/lib/types/common/Constants.d.ts +4 -0
- package/lib/types/common/facades/FacadeChatSDK.d.ts +29 -0
- package/lib/types/common/facades/types/IFacadeChatSDKInput.d.ts +3 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +14 -2
- package/lib/types/common/telemetry/sanitizeSasInPayload.d.ts +24 -0
- package/lib/types/common/utils.d.ts +3 -1
- package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/authHelper.d.ts +9 -2
- package/lib/types/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.d.ts +6 -0
- package/lib/types/components/webchatcontainerstateful/common/utils/chatAdapterUtils.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/common/utils/citationA11y.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatAction.d.ts +16 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +14 -38
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.d.ts +18 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageStyles.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageSequenceIdOverrideMiddleware.d.ts +2 -4
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +2 -4
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware.d.ts +2 -4
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.d.ts +10 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.d.ts +2 -4
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.d.ts +2 -2
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.d.ts +2 -4
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.d.ts +2 -2
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.d.ts +2 -4
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.d.ts +2 -2
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/dataMaskingMiddleware.d.ts +2 -4
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/gifUploadMiddleware.d.ts +2 -4
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware.d.ts +2 -4
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware.d.ts +2 -4
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.d.ts +2 -4
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/maxMessageSizeValidator.d.ts +2 -4
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware.d.ts +2 -4
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +2 -2
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware.d.ts +2 -4
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.d.ts +7 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +17 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/package.json +69 -56
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
1. [Introduction](#introduction)
|
|
13
13
|
1. [Installation](#installation)
|
|
14
|
+
1. [WebChat dependency constraint](#webchat-dependency-constraint)
|
|
14
15
|
1. [Example Usage](#example-usage)
|
|
15
16
|
1. [Components](#components)
|
|
16
17
|
1. [See Also](#see-also)
|
|
@@ -47,6 +48,34 @@ or
|
|
|
47
48
|
yarn add @microsoft/omnichannel-chat-components
|
|
48
49
|
```
|
|
49
50
|
|
|
51
|
+
This package requires Node.js `>=22.12.0` for consumer builds. Node 20 is not supported.
|
|
52
|
+
|
|
53
|
+
TypeScript consumers that imported the exported Web Chat middleware factories now receive Redux 5 `unknown` actions. Narrow with `isWebChatAction` before reading `type` or `payload`. Runtime behavior is unchanged.
|
|
54
|
+
|
|
55
|
+
## WebChat dependency constraint
|
|
56
|
+
|
|
57
|
+
The widget must use `botframework-webchat@4.18.1-hotfix.20260308.b15b405`.
|
|
58
|
+
|
|
59
|
+
Do not upgrade or replace this version. It contains a required product hotfix. The PR workflow rejects a different version.
|
|
60
|
+
|
|
61
|
+
This hotfix still declares these vulnerable transitive versions:
|
|
62
|
+
|
|
63
|
+
| Package | Hotfix version |
|
|
64
|
+
| --- | --- |
|
|
65
|
+
| `adaptivecards` | `3.0.2` |
|
|
66
|
+
| `markdown-it` | `13.0.2` |
|
|
67
|
+
| `linkify-it` | `4.0.1` |
|
|
68
|
+
| `@babel/runtime` | `7.14.8`, `7.15.4`, and `7.19.0` |
|
|
69
|
+
| `@babel/runtime-corejs3` | `7.20.13` |
|
|
70
|
+
| `sanitize-html` | `2.14.0` |
|
|
71
|
+
| `swiper` | `8.4.7` |
|
|
72
|
+
| `valibot` | `1.1.0` |
|
|
73
|
+
| `uuid` | `3.4.0`, `8.3.2`, and `9.0.1` |
|
|
74
|
+
|
|
75
|
+
The consumer audit permits only the reviewed advisories from this hotfix. It rejects each new advisory.
|
|
76
|
+
|
|
77
|
+
A new WebChat hotfix must preserve the product fix and update these dependencies.
|
|
78
|
+
|
|
50
79
|
## Example Usage
|
|
51
80
|
|
|
52
81
|
The basic example below takes in the ```<LiveChatWidget/>``` component along with the Chat SDK to create a customized Omnichannel chat widget.
|
|
@@ -177,7 +206,7 @@ Header's and Footer's child components consist of three parts:
|
|
|
177
206
|
1. "middleGroup" - adding child components in the middle of the Header/Footer
|
|
178
207
|
1. "rightGroup" - adding child components at the right of the Header/Footer
|
|
179
208
|
|
|
180
|
-
By default Header has the header icon and title on the left and minimize and close buttons on the right, and Footer has Download Transcript and Email Transcript buttons on the left and audio notification button on the right. These components can be overriden with [ComponentOverrides](#
|
|
209
|
+
By default Header has the header icon and title on the left and minimize and close buttons on the right, and Footer has Download Transcript and Email Transcript buttons on the left and audio notification button on the right. These components can be overriden with [ComponentOverrides](#componentoverrides). In addition, other custom child components can be added to both Header and Footer by creating custom react nodes and adding them to attributes "leftGroup", "middleGroup" or "rightGroup" of "controlProps".
|
|
181
210
|
|
|
182
211
|
```js
|
|
183
212
|
const buttonStyleProps: IButtonStyles = {
|
|
@@ -224,8 +253,10 @@ const customizedFooterProp: IFooterProps = {
|
|
|
224
253
|
> :pushpin: Note that [WebChat hooks](https://github.com/microsoft/BotFramework-WebChat/blob/main/docs/HOOKS.md) can also be used in any custom components.
|
|
225
254
|
|
|
226
255
|
#### Bidirectional Custom Events
|
|
256
|
+
|
|
227
257
|
- Sending events from a hosting web page to bots/agents
|
|
228
|
-
|
|
258
|
+
- Register a function to post event
|
|
259
|
+
|
|
229
260
|
```js
|
|
230
261
|
//define sendCustomEvent function
|
|
231
262
|
const sendCustomEvent = (payload) => {
|
|
@@ -253,7 +284,9 @@ const customizedFooterProp: IFooterProps = {
|
|
|
253
284
|
}
|
|
254
285
|
})
|
|
255
286
|
```
|
|
256
|
-
|
|
287
|
+
|
|
288
|
+
- Receiving events from bots/agents
|
|
289
|
+
|
|
257
290
|
```js
|
|
258
291
|
//define setOnCustomEvent function
|
|
259
292
|
const setOnCustomEvent = (callback) => {
|
|
@@ -269,8 +302,10 @@ const customizedFooterProp: IFooterProps = {
|
|
|
269
302
|
```
|
|
270
303
|
|
|
271
304
|
#### Trigger initiateEndChat event
|
|
305
|
+
|
|
272
306
|
Customer can trigger the initiateEndChat event via BroadcastService to end a chat session.
|
|
273
307
|
When needed, the payload below could be triggered:
|
|
308
|
+
|
|
274
309
|
```js
|
|
275
310
|
const endChatEvent = {
|
|
276
311
|
eventName: "InitiateEndChat",
|
|
@@ -283,18 +318,21 @@ BroadcastService.postMessage(endChatEvent);
|
|
|
283
318
|
|
|
284
319
|
The payload of the event is optional, only needed when force closing of a persistent chat session is not required.
|
|
285
320
|
When chat widget receives the event without any payload, it will:
|
|
321
|
+
|
|
286
322
|
1. set the widget to closed state, the widget panel will be minimized. Post chat survey will not be displayed.
|
|
287
323
|
2. trigger a sessionclose service network request to OmniChannel services.
|
|
288
324
|
|
|
289
325
|
If skipSessionCloseForPersistentChat is set to true. The session close network request will not be triggered, instead, if postChat survey is available, post chat survey will be displayed.
|
|
290
326
|
|
|
291
327
|
After successfully processed initiateEndChat event. The CloseChat event is broadcasted.
|
|
328
|
+
|
|
292
329
|
```js
|
|
293
330
|
BroadcastService.getMessageByEventName("CloseChat").subscribe(async (msg) => {
|
|
294
331
|
console.log("close chat received: ", msg);
|
|
295
332
|
//more actions to unmount component and resources
|
|
296
333
|
})
|
|
297
334
|
```
|
|
335
|
+
|
|
298
336
|
## See Also
|
|
299
337
|
|
|
300
338
|
[Customizations Dev Guide](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/customizations/getstarted.md)\
|
|
@@ -302,6 +340,7 @@ BroadcastService.getMessageByEventName("CloseChat").subscribe(async (msg) => {
|
|
|
302
340
|
[Create LiveChatWidget with Webpack5 and TypeScript](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/BuildingUsingWebpack5.md)\
|
|
303
341
|
[Omnichannel Features](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/Features.md)\
|
|
304
342
|
[How to Add Visual Regression Tests](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/VisualRegressionTestingGuide.md)\
|
|
343
|
+
[Accessibility Tooling](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/accessibility/README.md)\
|
|
305
344
|
[Security](https://github.com/microsoft/omnichannel-chat-widget/blob/main/SECURITY.md)\
|
|
306
345
|
[Third Party Cookie Support](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/Tpc.md)\
|
|
307
346
|
[Storybook](https://microsoft.github.io/omnichannel-chat-widget/docs/storybook/)
|
|
@@ -81,6 +81,8 @@ _defineProperty(Constants, "audioMediaRegex", /(\.)(aac|aiff|alac|amr|flac|mp2|m
|
|
|
81
81
|
_defineProperty(Constants, "videoMediaRegex", /(\.)(avchd|avi|flv|mpe|mpeg|mpg|mpv|mp4|m4p|m4v|mov|qt|swf|webm|wmv)$/i);
|
|
82
82
|
_defineProperty(Constants, "chromeSupportedInlineMediaRegex", /(\.)(aac|mp3|wav|mp4)$/i);
|
|
83
83
|
_defineProperty(Constants, "firefoxSupportedInlineMediaRegex", /(\.)(aac|flac|mp3|wav|mp4|mov)$/i);
|
|
84
|
+
_defineProperty(Constants, "AdaptiveCardType", "adaptivecard");
|
|
85
|
+
_defineProperty(Constants, "SuggestedActionsType", "suggestedactions");
|
|
84
86
|
// calling container event names
|
|
85
87
|
_defineProperty(Constants, "CallAdded", "callAdded");
|
|
86
88
|
_defineProperty(Constants, "LocalVideoStreamAdded", "localVideoStreamAdded");
|
|
@@ -143,6 +145,9 @@ _defineProperty(Constants, "customEventValue", "customEventValue");
|
|
|
143
145
|
_defineProperty(Constants, "Hidden", "Hidden");
|
|
144
146
|
_defineProperty(Constants, "EndConversationDueToOverflow", "endconversationduetooverflow");
|
|
145
147
|
_defineProperty(Constants, "SkipSessionCloseForPersistentChatFlag", "skipSessionCloseForPersistentChat");
|
|
148
|
+
// Minimum font-size for input fields to prevent iOS Safari auto-zoom on focus
|
|
149
|
+
_defineProperty(Constants, "minInputFontSizePx", 16);
|
|
150
|
+
_defineProperty(Constants, "minInputFontSize", "16px");
|
|
146
151
|
const Regex = exports.Regex = (_Class = /*#__PURE__*/_createClass(function Regex() {
|
|
147
152
|
_classCallCheck(this, Regex);
|
|
148
153
|
}), _defineProperty(_Class, "EmailRegex", "^(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\])$"), _Class);
|
|
@@ -26,6 +26,8 @@ let FacadeChatSDK = exports.FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
26
26
|
_defineProperty(this, "getAuthToken", void 0);
|
|
27
27
|
_defineProperty(this, "sdkMocked", void 0);
|
|
28
28
|
_defineProperty(this, "disableReauthentication", void 0);
|
|
29
|
+
// Stays true so CASE 1 re-triggers on every startChat to set deferInitialAuth
|
|
30
|
+
_defineProperty(this, "pendingMidAuthUnauthenticatedState", false);
|
|
29
31
|
this.chatSDK = input.chatSDK;
|
|
30
32
|
this.chatConfig = input.chatConfig;
|
|
31
33
|
this.getAuthToken = input.getAuthToken;
|
|
@@ -50,6 +52,12 @@ let FacadeChatSDK = exports.FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
50
52
|
value: function destroy() {
|
|
51
53
|
this.token = null;
|
|
52
54
|
this.expiration = 0;
|
|
55
|
+
if ((0, _authHelper.isMidAuthEnabled)(this.chatConfig)) {
|
|
56
|
+
this.pendingMidAuthUnauthenticatedState = false;
|
|
57
|
+
this.isAuthenticated = true;
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
|
+
this.chatSDK.deferInitialAuth = false;
|
|
60
|
+
}
|
|
53
61
|
}
|
|
54
62
|
}, {
|
|
55
63
|
key: "isTokenSet",
|
|
@@ -214,6 +222,10 @@ let FacadeChatSDK = exports.FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
214
222
|
message: "Token is valid"
|
|
215
223
|
};
|
|
216
224
|
}
|
|
225
|
+
|
|
226
|
+
// Token missing or expired - need to get a new one via getAuthToken
|
|
227
|
+
// For mid-auth: getAuthToken receives { isMidAuthEnabled: true } so customer implementations
|
|
228
|
+
// can check portal state and return null for logged-out users
|
|
217
229
|
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
218
230
|
Event: _TelemetryConstants.TelemetryEvent.NewTokenValidationStarted,
|
|
219
231
|
Description: "Token validation started."
|
|
@@ -234,6 +246,7 @@ let FacadeChatSDK = exports.FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
234
246
|
this.token = "";
|
|
235
247
|
this.expiration = 0;
|
|
236
248
|
try {
|
|
249
|
+
var _ring$error, _ring$error2;
|
|
237
250
|
const ring = await (0, _authHelper.handleAuthentication)(this.chatSDK, this.chatConfig, this.getAuthToken);
|
|
238
251
|
if ((ring === null || ring === void 0 ? void 0 : ring.result) === true && ring !== null && ring !== void 0 && ring.token) {
|
|
239
252
|
await this.setToken(ring.token);
|
|
@@ -248,18 +261,35 @@ let FacadeChatSDK = exports.FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
248
261
|
result: true,
|
|
249
262
|
message: "New Token obtained"
|
|
250
263
|
};
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Mid-auth: no token available - set pending flag for startChat to handle
|
|
267
|
+
const isEmptyTokenWithoutError = (0, _utils.isNullOrEmptyString)(ring === null || ring === void 0 ? void 0 : ring.token) && ((ring === null || ring === void 0 ? void 0 : ring.result) === true || (ring === null || ring === void 0 ? void 0 : ring.result) === false && !(ring !== null && ring !== void 0 && ring.error));
|
|
268
|
+
if ((0, _authHelper.isMidAuthEnabled)(this.chatConfig) && isEmptyTokenWithoutError) {
|
|
269
|
+
// Clear Facade and SDK token state so API calls use unauthenticated endpoints
|
|
270
|
+
this.token = "";
|
|
271
|
+
this.expiration = 0;
|
|
272
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
273
|
+
this.chatSDK.authenticatedUserToken = null;
|
|
274
|
+
this.pendingMidAuthUnauthenticatedState = true;
|
|
275
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
276
|
+
Event: _TelemetryConstants.TelemetryEvent.NewTokenValidationCompleted,
|
|
277
|
+
Description: "Mid-auth enabled: no token returned; proceeding as unauthenticated"
|
|
257
278
|
});
|
|
258
279
|
return {
|
|
259
|
-
result:
|
|
260
|
-
message:
|
|
280
|
+
result: true,
|
|
281
|
+
message: "Mid-auth: proceeding as unauthenticated"
|
|
261
282
|
};
|
|
262
283
|
}
|
|
284
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
|
|
285
|
+
Event: _TelemetryConstants.TelemetryEvent.NewTokenValidationFailed,
|
|
286
|
+
Description: (_ring$error = ring.error) === null || _ring$error === void 0 ? void 0 : _ring$error.message,
|
|
287
|
+
ExceptionDetails: ring === null || ring === void 0 ? void 0 : ring.error
|
|
288
|
+
});
|
|
289
|
+
return {
|
|
290
|
+
result: false,
|
|
291
|
+
message: (ring === null || ring === void 0 || (_ring$error2 = ring.error) === null || _ring$error2 === void 0 ? void 0 : _ring$error2.message) || "Failed to get token"
|
|
292
|
+
};
|
|
263
293
|
} catch (e) {
|
|
264
294
|
console.error("Unexpected error while getting token", e);
|
|
265
295
|
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.ERROR, {
|
|
@@ -273,6 +303,155 @@ let FacadeChatSDK = exports.FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
273
303
|
};
|
|
274
304
|
}
|
|
275
305
|
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Sets unauthenticated state for mid-auth flow.
|
|
309
|
+
* Clears SDK internal state to prevent reconnection to previous authenticated session.
|
|
310
|
+
*/
|
|
311
|
+
}, {
|
|
312
|
+
key: "setMidAuthUnauthenticatedState",
|
|
313
|
+
value: function setMidAuthUnauthenticatedState() {
|
|
314
|
+
var _sdk$chatToken, _sdk$chatToken2;
|
|
315
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
316
|
+
const sdk = this.chatSDK;
|
|
317
|
+
const hadExistingChat = !!((_sdk$chatToken = sdk.chatToken) !== null && _sdk$chatToken !== void 0 && _sdk$chatToken.chatId);
|
|
318
|
+
const previousChatId = (_sdk$chatToken2 = sdk.chatToken) === null || _sdk$chatToken2 === void 0 ? void 0 : _sdk$chatToken2.chatId;
|
|
319
|
+
this.clearAuthState();
|
|
320
|
+
|
|
321
|
+
// Clear SDK internal state for fresh unauthenticated chat
|
|
322
|
+
sdk.chatToken = {};
|
|
323
|
+
sdk.reconnectId = null;
|
|
324
|
+
sdk.requestId = null;
|
|
325
|
+
sdk.sessionId = null;
|
|
326
|
+
sdk.conversation = null;
|
|
327
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
328
|
+
Event: _TelemetryConstants.TelemetryEvent.MidConversationAuthReset,
|
|
329
|
+
Description: hadExistingChat ? "Mid-auth without token: local state cleared" : "Mid-auth: initialized as unauthenticated (no prior chat)",
|
|
330
|
+
Data: hadExistingChat ? {
|
|
331
|
+
previousChatId
|
|
332
|
+
} : undefined
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** Clears authentication state in both FacadeChatSDK and underlying SDK */
|
|
337
|
+
}, {
|
|
338
|
+
key: "clearAuthState",
|
|
339
|
+
value: function clearAuthState() {
|
|
340
|
+
this.token = "";
|
|
341
|
+
this.expiration = 0;
|
|
342
|
+
this.isAuthenticated = false;
|
|
343
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
344
|
+
this.chatSDK.authenticatedUserToken = null;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Migrates conversation from unauthenticated to authenticated via authenticateChat.
|
|
349
|
+
* Called after startChat() when user has a valid token but the backend conversation
|
|
350
|
+
* was started as unauthenticated.
|
|
351
|
+
*/
|
|
352
|
+
}, {
|
|
353
|
+
key: "migrateConversationToAuthenticated",
|
|
354
|
+
value: async function migrateConversationToAuthenticated() {
|
|
355
|
+
try {
|
|
356
|
+
await this.chatSDK.authenticateChat(this.token, {
|
|
357
|
+
refreshChatToken: true
|
|
358
|
+
});
|
|
359
|
+
this.isAuthenticated = true;
|
|
360
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
361
|
+
Event: _TelemetryConstants.TelemetryEvent.MidConversationAuthSucceeded,
|
|
362
|
+
Description: "Mid-auth: authenticateChat completed, conversation migrated to authenticated"
|
|
363
|
+
});
|
|
364
|
+
} catch (e) {
|
|
365
|
+
// Non-fatal: Chat is already active via startChat, will retry on next reconnect
|
|
366
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.WARN, {
|
|
367
|
+
Event: _TelemetryConstants.TelemetryEvent.MidConversationAuthFailed,
|
|
368
|
+
Description: "Mid-auth: authenticateChat returned error after startChat, chat still active",
|
|
369
|
+
ExceptionDetails: {
|
|
370
|
+
message: e === null || e === void 0 ? void 0 : e.message
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Configures SDK auth state before startChat.
|
|
378
|
+
* CASE 1: Pending unauthenticated (no token) - sets deferInitialAuth=true
|
|
379
|
+
* CASE 2: Authenticated with valid token - sets SDK token and deferInitialAuth based on scenario
|
|
380
|
+
*/
|
|
381
|
+
}, {
|
|
382
|
+
key: "configureMidAuthState",
|
|
383
|
+
value: function configureMidAuthState(isReconnect, wasPreviousSessionAuthenticated) {
|
|
384
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
385
|
+
const sdk = this.chatSDK;
|
|
386
|
+
|
|
387
|
+
// CASE 1: No token available (user not logged in)
|
|
388
|
+
// pendingMidAuthUnauthenticatedState stays true until user logs in (cleared in tokenRing)
|
|
389
|
+
if (this.pendingMidAuthUnauthenticatedState) {
|
|
390
|
+
const shouldClear = this.handlePendingUnauthenticatedState(wasPreviousSessionAuthenticated);
|
|
391
|
+
sdk.deferInitialAuth = true;
|
|
392
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
393
|
+
Event: _TelemetryConstants.TelemetryEvent.MidConversationAuthReset,
|
|
394
|
+
Description: "Mid-auth configureMidAuthState: CASE 1 - unauthenticated, deferInitialAuth=true",
|
|
395
|
+
Data: {
|
|
396
|
+
isReconnect: String(isReconnect),
|
|
397
|
+
wasPreviousSessionAuthenticated: String(wasPreviousSessionAuthenticated),
|
|
398
|
+
shouldClearReconnectParams: String(shouldClear)
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
return {
|
|
402
|
+
shouldClearReconnectParams: shouldClear
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// CASE 2: Authenticated with valid token
|
|
407
|
+
if (this.isTokenSet() && !this.isTokenExpired()) {
|
|
408
|
+
this.handleAuthenticatedState(isReconnect, wasPreviousSessionAuthenticated);
|
|
409
|
+
}
|
|
410
|
+
return {
|
|
411
|
+
shouldClearReconnectParams: false
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* CASE 1 handler: Returns true if reconnect params should be cleared (Auth -> Unauth transition)
|
|
417
|
+
*/
|
|
418
|
+
}, {
|
|
419
|
+
key: "handlePendingUnauthenticatedState",
|
|
420
|
+
value: function handlePendingUnauthenticatedState(wasPreviousSessionAuthenticated) {
|
|
421
|
+
if (wasPreviousSessionAuthenticated) {
|
|
422
|
+
// Auth -> Unauth: user logged out, clear state for fresh chat
|
|
423
|
+
this.setMidAuthUnauthenticatedState();
|
|
424
|
+
return true;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// Unauth -> Unauth: keep liveChatContext for reconnection
|
|
428
|
+
this.isAuthenticated = false;
|
|
429
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
430
|
+
this.chatSDK.authenticatedUserToken = null;
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* CASE 2 handler: Sets deferInitialAuth only for reconnects to unauthenticated sessions (need migration).
|
|
436
|
+
* For new chats or reconnects to authenticated sessions, SDK handles auth internally.
|
|
437
|
+
*/
|
|
438
|
+
}, {
|
|
439
|
+
key: "handleAuthenticatedState",
|
|
440
|
+
value: function handleAuthenticatedState(isReconnect, wasPreviousSessionAuthenticated) {
|
|
441
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
442
|
+
const sdk = this.chatSDK;
|
|
443
|
+
sdk.authenticatedUserToken = this.token;
|
|
444
|
+
if (isReconnect && !wasPreviousSessionAuthenticated) {
|
|
445
|
+
sdk.deferInitialAuth = true;
|
|
446
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
447
|
+
Event: _TelemetryConstants.TelemetryEvent.MidConversationAuthSucceeded,
|
|
448
|
+
Description: "Mid-auth handleAuthenticatedState: CASE 2 - reconnect to unauth session, deferInitialAuth=true (migration needed)"
|
|
449
|
+
});
|
|
450
|
+
} else {
|
|
451
|
+
// Reset to prevent inheriting deferInitialAuth=true from a previous unauthenticated chat
|
|
452
|
+
sdk.deferInitialAuth = false;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
276
455
|
}, {
|
|
277
456
|
key: "validateAndExecuteCall",
|
|
278
457
|
value: async function validateAndExecuteCall(functionName, fn) {
|
|
@@ -307,7 +486,52 @@ let FacadeChatSDK = exports.FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
307
486
|
key: "startChat",
|
|
308
487
|
value: async function startChat() {
|
|
309
488
|
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
310
|
-
|
|
489
|
+
const midAuthEnabled = (0, _authHelper.isMidAuthEnabled)(this.chatConfig);
|
|
490
|
+
const isReconnect = !!optionalParams.liveChatContext || !!optionalParams.reconnectId;
|
|
491
|
+
const wasPreviousSessionAuthenticated = optionalParams.wasAuthenticated === true;
|
|
492
|
+
return this.validateAndExecuteCall("startChat", async () => {
|
|
493
|
+
if (midAuthEnabled) {
|
|
494
|
+
const _this$configureMidAut = this.configureMidAuthState(isReconnect, wasPreviousSessionAuthenticated),
|
|
495
|
+
shouldClearReconnectParams = _this$configureMidAut.shouldClearReconnectParams;
|
|
496
|
+
if (shouldClearReconnectParams) {
|
|
497
|
+
delete optionalParams.liveChatContext;
|
|
498
|
+
delete optionalParams.reconnectId;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
await this.chatSDK.startChat(optionalParams);
|
|
502
|
+
|
|
503
|
+
// Migrate to authenticated if needed (reconnects to unauthenticated sessions only)
|
|
504
|
+
if (midAuthEnabled) {
|
|
505
|
+
const shouldMigrateToAuth = isReconnect && this.isTokenSet() && !this.isTokenExpired() && !wasPreviousSessionAuthenticated;
|
|
506
|
+
if (shouldMigrateToAuth) {
|
|
507
|
+
_TelemetryHelper.TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
508
|
+
Event: _TelemetryConstants.TelemetryEvent.MidConversationAuthSucceeded,
|
|
509
|
+
Description: "Mid-auth startChat: initiating migration to authenticated",
|
|
510
|
+
Data: {
|
|
511
|
+
isReconnect: String(isReconnect),
|
|
512
|
+
wasPreviousSessionAuthenticated: String(wasPreviousSessionAuthenticated)
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
await this.migrateConversationToAuthenticated();
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// Broadcast final auth state after startChat completes (only on state change)
|
|
520
|
+
if (midAuthEnabled) {
|
|
521
|
+
const isAuthenticatedAfterStart = this.isTokenSet() && !this.isTokenExpired();
|
|
522
|
+
const authStateChanged = !isReconnect || isAuthenticatedAfterStart !== wasPreviousSessionAuthenticated;
|
|
523
|
+
if (authStateChanged) {
|
|
524
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
525
|
+
eventName: isAuthenticatedAfterStart ? _TelemetryConstants.BroadcastEvent.MidConversationAuthSucceeded : _TelemetryConstants.BroadcastEvent.MidConversationAuthReset,
|
|
526
|
+
payload: {
|
|
527
|
+
isAuthenticated: isAuthenticatedAfterStart,
|
|
528
|
+
isStartChatComplete: true,
|
|
529
|
+
isReconnect
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
});
|
|
311
535
|
}
|
|
312
536
|
}, {
|
|
313
537
|
key: "endChat",
|
|
@@ -445,6 +669,7 @@ let FacadeChatSDK = exports.FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
445
669
|
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
446
670
|
return this.validateAndExecuteCall("getAgentAvailability", () => this.chatSDK.getAgentAvailability(optionalParams));
|
|
447
671
|
}
|
|
672
|
+
|
|
448
673
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
449
674
|
}, {
|
|
450
675
|
key: "getReconnectableChats",
|
|
@@ -71,6 +71,9 @@ let BroadcastEvent = exports.BroadcastEvent = /*#__PURE__*/function (BroadcastEv
|
|
|
71
71
|
BroadcastEvent["FMLTrackingCompletedAck"] = "FMLTrackingCompletedAck";
|
|
72
72
|
BroadcastEvent["FMLTrackingCompleted"] = "FMLTrackingCompleted";
|
|
73
73
|
BroadcastEvent["PersistentConversationReset"] = "PersistentConversationReset";
|
|
74
|
+
BroadcastEvent["MidConversationAuthSucceeded"] = "MidConversationAuthSucceeded";
|
|
75
|
+
// Emitted when mid-conversation auth succeeds (for reconnect support)
|
|
76
|
+
BroadcastEvent["MidConversationAuthReset"] = "MidConversationAuthReset"; // Emitted when mid-auth falls back to unauthenticated mode (token null/empty)
|
|
74
77
|
return BroadcastEvent;
|
|
75
78
|
}({}); // Events being logged
|
|
76
79
|
let TelemetryEvent = exports.TelemetryEvent = /*#__PURE__*/function (TelemetryEvent) {
|
|
@@ -105,6 +108,9 @@ let TelemetryEvent = exports.TelemetryEvent = /*#__PURE__*/function (TelemetryEv
|
|
|
105
108
|
TelemetryEvent["CallingSDKInitFailed"] = "CallingSDKInitFailed";
|
|
106
109
|
TelemetryEvent["CallingSDKLoadSuccess"] = "CallingSDKLoadSuccess";
|
|
107
110
|
TelemetryEvent["CallingSDKLoadFailed"] = "CallingSDKLoadFailed";
|
|
111
|
+
TelemetryEvent["MidConversationAuthSucceeded"] = "MidConversationAuthSucceeded";
|
|
112
|
+
TelemetryEvent["MidConversationAuthFailed"] = "MidConversationAuthFailed";
|
|
113
|
+
TelemetryEvent["MidConversationAuthReset"] = "MidConversationAuthReset";
|
|
108
114
|
TelemetryEvent["GetConversationDetailsCallStarted"] = "GetConversationDetailsCallStarted";
|
|
109
115
|
TelemetryEvent["GetConversationDetailsCallFailed"] = "GetConversationDetailsCallFailed";
|
|
110
116
|
TelemetryEvent["EndChatSDKCallFailed"] = "EndChatSDKCallFailed";
|
|
@@ -195,6 +201,7 @@ let TelemetryEvent = exports.TelemetryEvent = /*#__PURE__*/function (TelemetryEv
|
|
|
195
201
|
//WebChat Middleware Events
|
|
196
202
|
TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
|
|
197
203
|
TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
|
|
204
|
+
TelemetryEvent["HTMLSanitized"] = "HTMLSanitized";
|
|
198
205
|
TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
|
|
199
206
|
TelemetryEvent["AttachmentUploadValidatorMiddlewareFailed"] = "AttachmentUploadValidatorMiddlewareFailed";
|
|
200
207
|
TelemetryEvent["CitationMiddlewareFailed"] = "CitationMiddlewareFailed";
|
|
@@ -321,11 +328,19 @@ let TelemetryEvent = exports.TelemetryEvent = /*#__PURE__*/function (TelemetryEv
|
|
|
321
328
|
TelemetryEvent["LCWLazyLoadNoMoreHistory"] = "LCWLazyLoadNoMoreHistory";
|
|
322
329
|
TelemetryEvent["LCWLazyLoadHistoryError"] = "LCWLazyLoadHistoryError";
|
|
323
330
|
TelemetryEvent["LCWLazyLoadDestroyed"] = "LCWLazyLoadDestroyed";
|
|
331
|
+
TelemetryEvent["LCWLazyLoadTriggerFired"] = "LCWLazyLoadTriggerFired";
|
|
332
|
+
TelemetryEvent["LCWLazyLoadBatchReceived"] = "LCWLazyLoadBatchReceived";
|
|
333
|
+
TelemetryEvent["LCWLazyLoadInitialLoadComplete"] = "LCWLazyLoadInitialLoadComplete";
|
|
334
|
+
TelemetryEvent["LCWLazyLoadScrollAnchorApplied"] = "LCWLazyLoadScrollAnchorApplied";
|
|
324
335
|
// SecureEventBus events
|
|
325
336
|
TelemetryEvent["SecureEventBusUnauthorizedDispatch"] = "SecureEventBusUnauthorizedDispatch";
|
|
326
337
|
TelemetryEvent["SecureEventBusListenerError"] = "SecureEventBusListenerError";
|
|
327
338
|
TelemetryEvent["SecureEventBusDispatchError"] = "SecureEventBusDispatchError";
|
|
328
339
|
TelemetryEvent["StartChatComplete"] = "StartChatComplete";
|
|
340
|
+
// Queue & Agent Assignment
|
|
341
|
+
TelemetryEvent["AgentJoinedConversation"] = "AgentJoinedConversation";
|
|
342
|
+
// Browser Close Detection
|
|
343
|
+
TelemetryEvent["BrowserTabHidden"] = "BrowserTabHidden";
|
|
329
344
|
return TelemetryEvent;
|
|
330
345
|
}({});
|
|
331
346
|
let TelemetryConstants = exports.TelemetryConstants = /*#__PURE__*/function () {
|
|
@@ -397,6 +412,8 @@ let TelemetryConstants = exports.TelemetryConstants = /*#__PURE__*/function () {
|
|
|
397
412
|
case TelemetryEvent.SecureEventBusUnauthorizedDispatch:
|
|
398
413
|
case TelemetryEvent.SecureEventBusListenerError:
|
|
399
414
|
case TelemetryEvent.SecureEventBusDispatchError:
|
|
415
|
+
case TelemetryEvent.AgentJoinedConversation:
|
|
416
|
+
case TelemetryEvent.BrowserTabHidden:
|
|
400
417
|
return ScenarioType.ACTIONS;
|
|
401
418
|
case TelemetryEvent.StartChatSDKCall:
|
|
402
419
|
case TelemetryEvent.StartChatEventReceived:
|
|
@@ -11,6 +11,7 @@ var _appInsightsLogger = require("./loggers/appInsightsLogger");
|
|
|
11
11
|
var _ariaTelemetryLogger = require("./loggers/ariaTelemetryLogger");
|
|
12
12
|
var _consoleLogger = require("./loggers/consoleLogger");
|
|
13
13
|
var _defaultAriaConfig = require("./defaultConfigs/defaultAriaConfig");
|
|
14
|
+
var _sanitizeSasInPayload = require("./sanitizeSasInPayload");
|
|
14
15
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
15
16
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
16
17
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
@@ -79,11 +80,15 @@ const RegisterLoggers = () => {
|
|
|
79
80
|
};
|
|
80
81
|
};
|
|
81
82
|
const logTelemetry = telemetryEvent => {
|
|
83
|
+
// Redact Azure SAS credentials in any URL embedded in the payload (e.g.
|
|
84
|
+
// customer-supplied blob asset URLs in widget customization props) before
|
|
85
|
+
// it fans out to console, Aria, AppInsights, or any custom logger.
|
|
86
|
+
const sanitizedPayload = (0, _sanitizeSasInPayload.sanitizeSasInPayload)(telemetryEvent === null || telemetryEvent === void 0 ? void 0 : telemetryEvent.payload);
|
|
82
87
|
loggers.map(logger => {
|
|
83
88
|
var _payload, _telemetryInput$paylo;
|
|
84
89
|
const logLevel = telemetryEvent.logLevel ?? _TelemetryConstants.LogLevel.INFO;
|
|
85
90
|
const scenarioType = ((_payload = telemetryEvent.payload) === null || _payload === void 0 ? void 0 : _payload.scenarioType) ?? _TelemetryConstants.ScenarioType.UNDEFINED;
|
|
86
|
-
const telemetryInput = parseInput(
|
|
91
|
+
const telemetryInput = parseInput(sanitizedPayload, scenarioType);
|
|
87
92
|
telemetryInput.telemetryInfo = {
|
|
88
93
|
telemetryInfo: _TelemetryHelper.TelemetryHelper.buildTelemetryEvent(logLevel, telemetryInput)
|
|
89
94
|
};
|
|
@@ -42,9 +42,8 @@ const appInsightsLogger = appInsightsKey => {
|
|
|
42
42
|
}
|
|
43
43
|
try {
|
|
44
44
|
// Dynamically import Application Insights
|
|
45
|
-
const
|
|
46
|
-
ApplicationInsights
|
|
47
|
-
} = await Promise.resolve().then(() => _interopRequireWildcard(require("@microsoft/applicationinsights-web")));
|
|
45
|
+
const _await$import = await Promise.resolve().then(() => _interopRequireWildcard(require("@microsoft/applicationinsights-web"))),
|
|
46
|
+
ApplicationInsights = _await$import.ApplicationInsights;
|
|
48
47
|
const config = {
|
|
49
48
|
...(appInsightsKey.includes("IngestionEndpoint") ? {
|
|
50
49
|
connectionString: appInsightsKey
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.sanitizeSasInPayload = void 0;
|
|
7
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
10
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
13
|
+
/**
|
|
14
|
+
* Redacts the values of Azure Shared Access Signature (SAS) query parameters in any
|
|
15
|
+
* URL embedded in a telemetry payload, so customer-supplied SAS URLs (e.g. blob asset
|
|
16
|
+
* URLs in widget customization props) cannot leak credentials through Aria/AppInsights.
|
|
17
|
+
*
|
|
18
|
+
* Trigger: any URL whose query string contains `sig=`. When detected, every well-known
|
|
19
|
+
* SAS parameter value in that query is replaced with `[REDACTED]`. Other URLs and other
|
|
20
|
+
* substrings of the payload pass through unchanged.
|
|
21
|
+
*
|
|
22
|
+
* Coverage of SAS parameter names:
|
|
23
|
+
* - Service/Blob SAS: sig, sv, se, st, sp, spr, sr, sip
|
|
24
|
+
* - Account SAS: ss, srt
|
|
25
|
+
* - User-delegation key SAS: skoid, sktid, skt, ske, sks, skv, saoid, suoid, sce, sdd
|
|
26
|
+
* - Response header overrides: rscc, rscd, rsce, rscl, rsct
|
|
27
|
+
*
|
|
28
|
+
* Reference: https://learn.microsoft.com/en-us/rest/api/storageservices/create-service-sas
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
const SAS_PARAM_NAMES = new Set(["sig", "sv", "se", "st", "sp", "spr", "sr", "sip", "ss", "srt", "skoid", "sktid", "skt", "ske", "sks", "skv", "saoid", "suoid", "sce", "sdd", "rscc", "rscd", "rsce", "rscl", "rsct"]);
|
|
32
|
+
const REDACTED_VALUE = "[REDACTED]";
|
|
33
|
+
|
|
34
|
+
// Matches any http(s) URL substring up to whitespace / closing quote / angle-bracket / paren.
|
|
35
|
+
const URL_REGEX = /\bhttps?:\/\/[^\s"'<>)]+/gi;
|
|
36
|
+
const redactQueryIfSas = url => {
|
|
37
|
+
const queryIdx = url.indexOf("?");
|
|
38
|
+
if (queryIdx < 0) {
|
|
39
|
+
return url;
|
|
40
|
+
}
|
|
41
|
+
// Separate the fragment (#...) before processing the query — fragments come
|
|
42
|
+
// after the query string in URL syntax and must not be folded into the last
|
|
43
|
+
// query parameter's value when we split on `&`.
|
|
44
|
+
const afterQuestionMark = url.slice(queryIdx + 1);
|
|
45
|
+
const fragIdx = afterQuestionMark.indexOf("#");
|
|
46
|
+
const query = fragIdx < 0 ? afterQuestionMark : afterQuestionMark.slice(0, fragIdx);
|
|
47
|
+
const fragment = fragIdx < 0 ? "" : afterQuestionMark.slice(fragIdx); // includes the leading '#'
|
|
48
|
+
if (!/(^|&)sig=/i.test(query)) {
|
|
49
|
+
// No SAS signature present — leave the URL alone so legitimate non-SAS query
|
|
50
|
+
// strings (e.g. ?utm_source=...) are not mangled.
|
|
51
|
+
return url;
|
|
52
|
+
}
|
|
53
|
+
const base = url.slice(0, queryIdx);
|
|
54
|
+
const sanitizedQuery = query.split("&").map(pair => {
|
|
55
|
+
const eqIdx = pair.indexOf("=");
|
|
56
|
+
if (eqIdx < 0) {
|
|
57
|
+
return pair;
|
|
58
|
+
}
|
|
59
|
+
const name = pair.slice(0, eqIdx).toLowerCase();
|
|
60
|
+
return SAS_PARAM_NAMES.has(name) ? `${pair.slice(0, eqIdx)}=${REDACTED_VALUE}` : pair;
|
|
61
|
+
}).join("&");
|
|
62
|
+
return `${base}?${sanitizedQuery}${fragment}`;
|
|
63
|
+
};
|
|
64
|
+
const sanitizeString = s => s.replace(URL_REGEX, redactQueryIfSas);
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Deep-walk a value and redact SAS credentials in any string it contains.
|
|
68
|
+
* Returns a new object/array (originals are not mutated); non-string leaves are
|
|
69
|
+
* passed through. Tree-shaped, JSON-like values only — not designed for class
|
|
70
|
+
* instances, prototype-bound objects, or cyclic graphs.
|
|
71
|
+
*/
|
|
72
|
+
const sanitizeSasInPayload = value => {
|
|
73
|
+
if (typeof value === "string") {
|
|
74
|
+
return sanitizeString(value);
|
|
75
|
+
}
|
|
76
|
+
if (Array.isArray(value)) {
|
|
77
|
+
return value.map(sanitizeSasInPayload);
|
|
78
|
+
}
|
|
79
|
+
if (value !== null && typeof value === "object") {
|
|
80
|
+
const out = {};
|
|
81
|
+
for (const _ref of Object.entries(value)) {
|
|
82
|
+
var _ref2 = _slicedToArray(_ref, 2);
|
|
83
|
+
const k = _ref2[0];
|
|
84
|
+
const v = _ref2[1];
|
|
85
|
+
out[k] = sanitizeSasInPayload(v);
|
|
86
|
+
}
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
return value;
|
|
90
|
+
};
|
|
91
|
+
exports.sanitizeSasInPayload = sanitizeSasInPayload;
|