@microsoft/omnichannel-chat-widget 1.8.4-main.cbab5fc → 1.8.4-main.cc63f01
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -3
- package/lib/cjs/common/Constants.js +5 -0
- package/lib/cjs/common/facades/FacadeChatSDK.js +235 -9
- package/lib/cjs/common/telemetry/TelemetryConstants.js +14 -0
- package/lib/cjs/common/telemetry/TelemetryManager.js +6 -1
- package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +7 -7
- package/lib/cjs/common/telemetry/sanitizeSasInPayload.js +82 -0
- package/lib/cjs/common/utils/xssUtils.js +23 -51
- package/lib/cjs/common/utils.js +106 -17
- package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +8 -1
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -1
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +36 -13
- package/lib/cjs/components/errorboundary/ErrorBoundary.js +2 -1
- package/lib/cjs/components/livechatwidget/LiveChatWidget.js +9 -1
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +23 -6
- package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +1 -0
- package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +9 -0
- package/lib/cjs/components/livechatwidget/common/authHelper.js +44 -4
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +3 -2
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +98 -5
- package/lib/cjs/components/livechatwidget/common/endChat.js +6 -0
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +186 -1
- package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +36 -4
- package/lib/cjs/components/livechatwidget/common/startChat.js +31 -14
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +124 -5
- package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +15 -3
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +7 -4
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +68 -2
- package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +2 -1
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +0 -1
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +157 -34
- package/lib/cjs/components/webchatcontainerstateful/common/DesignerChatAdapter.js +10 -0
- package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +117 -16
- 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 +5 -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/webchatcontroller/WebChatEventSubscribers.js +13 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +160 -167
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +27 -8
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.js +203 -0
- 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/timestamps/NotDeliveredTimestamp.js +5 -13
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.js +81 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +29 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +52 -8
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +55 -1
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -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/plugins/newMessageEventHandler.js +20 -3
- package/lib/esm/common/Constants.js +5 -0
- package/lib/esm/common/facades/FacadeChatSDK.js +236 -10
- package/lib/esm/common/telemetry/TelemetryConstants.js +14 -0
- package/lib/esm/common/telemetry/TelemetryManager.js +6 -1
- package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +7 -7
- package/lib/esm/common/telemetry/sanitizeSasInPayload.js +75 -0
- package/lib/esm/common/utils/xssUtils.js +23 -51
- package/lib/esm/common/utils.js +99 -14
- package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +8 -1
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -1
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +37 -14
- package/lib/esm/components/errorboundary/ErrorBoundary.js +4 -2
- package/lib/esm/components/livechatwidget/LiveChatWidget.js +9 -1
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +23 -6
- package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +1 -0
- package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +9 -0
- package/lib/esm/components/livechatwidget/common/authHelper.js +44 -4
- package/lib/esm/components/livechatwidget/common/createAdapter.js +3 -2
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +98 -5
- package/lib/esm/components/livechatwidget/common/endChat.js +6 -0
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +186 -1
- package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +33 -2
- package/lib/esm/components/livechatwidget/common/startChat.js +31 -14
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +125 -6
- package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +16 -4
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +7 -4
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +69 -3
- package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +2 -1
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +1 -2
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +158 -35
- package/lib/esm/components/webchatcontainerstateful/common/DesignerChatAdapter.js +10 -0
- package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +117 -16
- 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 +5 -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/webchatcontroller/WebChatEventSubscribers.js +13 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +160 -171
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +24 -6
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachments/AdaptiveCardAccessibilityWrapper.js +195 -0
- 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/timestamps/NotDeliveredTimestamp.js +5 -13
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentSentAnnouncementMiddleware.js +74 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +29 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +52 -8
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/notification/NotificationHandler.js +55 -1
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -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/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/xssUtils.d.ts +5 -21
- package/lib/types/common/utils.d.ts +12 -2
- package/lib/types/components/errorboundary/ErrorBoundary.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +1 -0
- 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/livechatwidget/common/liveChatConfigUtils.d.ts +11 -0
- package/lib/types/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.d.ts +1 -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 +3 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotAuthConfig.d.ts +7 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.d.ts +1 -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/storemiddlewares/attachmentSentAnnouncementMiddleware.d.ts +12 -0
- 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 +37 -9
|
@@ -716,6 +716,21 @@ const reducer = (state, action) => {
|
|
|
716
716
|
isConversationalSurvey: action.payload
|
|
717
717
|
}
|
|
718
718
|
};
|
|
719
|
+
case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_USER_AUTHENTICATED:
|
|
720
|
+
inMemory = {
|
|
721
|
+
...inMemory,
|
|
722
|
+
appStates: {
|
|
723
|
+
...inMemory.appStates,
|
|
724
|
+
isUserAuthenticated: action.payload
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
|
+
return {
|
|
728
|
+
...state,
|
|
729
|
+
appStates: {
|
|
730
|
+
...state.appStates,
|
|
731
|
+
isUserAuthenticated: action.payload
|
|
732
|
+
}
|
|
733
|
+
};
|
|
719
734
|
case _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE:
|
|
720
735
|
return inMemory;
|
|
721
736
|
default:
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.shouldShowWebChatContainer = exports.shouldShowStartChatErrorPane = exports.shouldShowReconnectChatPane = exports.shouldShowProactiveChatPane = exports.shouldShowPreChatSurveyPane = exports.shouldShowPostChatSurveyPane = exports.shouldShowPostChatLoadingPane = exports.shouldShowOutOfOfficeHoursPane = exports.shouldShowLoadingPane = exports.shouldShowHeader = exports.shouldShowFooter = exports.shouldShowEmailTranscriptPane = exports.shouldShowConfirmationPane = exports.shouldShowChatButton = exports.shouldShowCallingContainer = void 0;
|
|
7
7
|
var _ConversationState = require("../contexts/common/ConversationState");
|
|
8
|
+
var _liveChatConfigUtils = require("../components/livechatwidget/common/liveChatConfigUtils");
|
|
8
9
|
const shouldShowChatButton = state => {
|
|
9
10
|
var _state$appStates;
|
|
10
11
|
return (state.appStates.isMinimized || state.appStates.conversationState === _ConversationState.ConversationState.Closed) && (state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.hideStartChatButton) === false; // Do not show chat button in case of popout
|
|
@@ -27,7 +28,18 @@ const shouldShowEmailTranscriptPane = state => {
|
|
|
27
28
|
};
|
|
28
29
|
exports.shouldShowEmailTranscriptPane = shouldShowEmailTranscriptPane;
|
|
29
30
|
const shouldShowWebChatContainer = state => {
|
|
30
|
-
|
|
31
|
+
var _state$domainStates;
|
|
32
|
+
const extendedChatConfig = state === null || state === void 0 ? void 0 : (_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : _state$domainStates.liveChatConfig;
|
|
33
|
+
const persistentHistoryEnabled = (0, _liveChatConfigUtils.shouldLoadPersistentChatHistory)(extendedChatConfig);
|
|
34
|
+
const isActiveOrInactive = state.appStates.conversationState === _ConversationState.ConversationState.Active || state.appStates.conversationState === _ConversationState.ConversationState.InActive;
|
|
35
|
+
const isPostchatSurvey = state.appStates.conversationState === _ConversationState.ConversationState.Postchat && state.appStates.isConversationalSurveyEnabled && state.appStates.isConversationalSurvey;
|
|
36
|
+
if (persistentHistoryEnabled) {
|
|
37
|
+
// Keep WebChat in DOM even when minimized (CSS hides it via visibility)
|
|
38
|
+
// This preserves scroll position across minimize/maximize cycles
|
|
39
|
+
return isActiveOrInactive || isPostchatSurvey;
|
|
40
|
+
}
|
|
41
|
+
// Original behavior - hide WebChat when minimized
|
|
42
|
+
return !state.appStates.isMinimized && (isActiveOrInactive || isPostchatSurvey);
|
|
31
43
|
};
|
|
32
44
|
exports.shouldShowWebChatContainer = shouldShowWebChatContainer;
|
|
33
45
|
const shouldShowLoadingPane = state => {
|
|
@@ -20,6 +20,8 @@ const createOnNewAdapterActivityHandler = (chatId, userId, startTime) => {
|
|
|
20
20
|
// this is a workaround for the fact that we dont have a way to identify if a message is history or new, and it will provide consistency across different scenarios
|
|
21
21
|
|
|
22
22
|
let isHistoryMessageReceivedEventRaised = false;
|
|
23
|
+
let isInQueue = false;
|
|
24
|
+
let agentJoinLogged = false;
|
|
23
25
|
const onNewAdapterActivityHandler = activity => {
|
|
24
26
|
raiseMessageEvent(activity);
|
|
25
27
|
};
|
|
@@ -41,9 +43,14 @@ const createOnNewAdapterActivityHandler = (chatId, userId, startTime) => {
|
|
|
41
43
|
});
|
|
42
44
|
};
|
|
43
45
|
const systemMessageStrategy = activity => {
|
|
44
|
-
var _TelemetryManager$Int3;
|
|
46
|
+
var _activity$channelData, _activity$channelData2, _TelemetryManager$Int3;
|
|
45
47
|
const payload = (0, _util.buildMessagePayload)(activity, userId);
|
|
46
48
|
payload.messageType = _Constants2.Constants.systemMessageTag;
|
|
49
|
+
|
|
50
|
+
// Track queue entry for agent-join detection
|
|
51
|
+
if (activity !== null && activity !== void 0 && (_activity$channelData = activity.channelData) !== null && _activity$channelData !== void 0 && (_activity$channelData2 = _activity$channelData.tags) !== null && _activity$channelData2 !== void 0 && _activity$channelData2.includes(_Constants2.Constants.queuePositionMessageTag)) {
|
|
52
|
+
isInQueue = true;
|
|
53
|
+
}
|
|
47
54
|
if ((0, _util.isHistoryMessage)(activity, startTime)) {
|
|
48
55
|
var _TelemetryManager$Int2;
|
|
49
56
|
historyMessageStrategy((0, _util.polyfillMessagePayloadForEvent)(activity, payload, (_TelemetryManager$Int2 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int2 === void 0 ? void 0 : _TelemetryManager$Int2.conversationId));
|
|
@@ -76,11 +83,11 @@ const createOnNewAdapterActivityHandler = (chatId, userId, startTime) => {
|
|
|
76
83
|
}
|
|
77
84
|
};
|
|
78
85
|
const isValidMessage = activity => {
|
|
79
|
-
var _activity$
|
|
86
|
+
var _activity$channelData3, _activity$channelData4, _activity$channelData5;
|
|
80
87
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
88
|
const messageHasNoText = !(activity !== null && activity !== void 0 && activity.text);
|
|
82
89
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
83
|
-
const messageHasNoTags = !(activity !== null && activity !== void 0 && activity.channelData) || !(activity !== null && activity !== void 0 && (_activity$
|
|
90
|
+
const messageHasNoTags = !(activity !== null && activity !== void 0 && activity.channelData) || !(activity !== null && activity !== void 0 && (_activity$channelData3 = activity.channelData) !== null && _activity$channelData3 !== void 0 && _activity$channelData3.tags) || (activity === null || activity === void 0 ? void 0 : (_activity$channelData4 = activity.channelData) === null || _activity$channelData4 === void 0 ? void 0 : (_activity$channelData5 = _activity$channelData4.tags) === null || _activity$channelData5 === void 0 ? void 0 : _activity$channelData5.length) === 0;
|
|
84
91
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
85
92
|
const messageHasNoAttachments = !(activity !== null && activity !== void 0 && activity.attachments) || (activity === null || activity === void 0 ? void 0 : activity.attachments.length) === 0;
|
|
86
93
|
if (messageHasNoTags && messageHasNoText && messageHasNoAttachments) {
|
|
@@ -102,6 +109,16 @@ const createOnNewAdapterActivityHandler = (chatId, userId, startTime) => {
|
|
|
102
109
|
historyMessageStrategy((0, _util.polyfillMessagePayloadForEvent)(activity, payload, (_TelemetryManager$Int4 = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int4 === void 0 ? void 0 : _TelemetryManager$Int4.conversationId));
|
|
103
110
|
return;
|
|
104
111
|
}
|
|
112
|
+
|
|
113
|
+
// Log agent joining when first non-history message is received after queue
|
|
114
|
+
if (isInQueue && !agentJoinLogged) {
|
|
115
|
+
agentJoinLogged = true;
|
|
116
|
+
isInQueue = false;
|
|
117
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
118
|
+
Event: _TelemetryConstants.TelemetryEvent.AgentJoinedConversation,
|
|
119
|
+
Description: "First message received from agent after queue"
|
|
120
|
+
});
|
|
121
|
+
}
|
|
105
122
|
firstResponseLatencyTracker.stopClock(payload);
|
|
106
123
|
const newMessageReceivedEvent = {
|
|
107
124
|
eventName: _TelemetryConstants.BroadcastEvent.NewMessageReceived,
|
|
@@ -75,6 +75,8 @@ _defineProperty(Constants, "audioMediaRegex", /(\.)(aac|aiff|alac|amr|flac|mp2|m
|
|
|
75
75
|
_defineProperty(Constants, "videoMediaRegex", /(\.)(avchd|avi|flv|mpe|mpeg|mpg|mpv|mp4|m4p|m4v|mov|qt|swf|webm|wmv)$/i);
|
|
76
76
|
_defineProperty(Constants, "chromeSupportedInlineMediaRegex", /(\.)(aac|mp3|wav|mp4)$/i);
|
|
77
77
|
_defineProperty(Constants, "firefoxSupportedInlineMediaRegex", /(\.)(aac|flac|mp3|wav|mp4|mov)$/i);
|
|
78
|
+
_defineProperty(Constants, "AdaptiveCardType", "adaptivecard");
|
|
79
|
+
_defineProperty(Constants, "SuggestedActionsType", "suggestedactions");
|
|
78
80
|
// calling container event names
|
|
79
81
|
_defineProperty(Constants, "CallAdded", "callAdded");
|
|
80
82
|
_defineProperty(Constants, "LocalVideoStreamAdded", "localVideoStreamAdded");
|
|
@@ -137,6 +139,9 @@ _defineProperty(Constants, "customEventValue", "customEventValue");
|
|
|
137
139
|
_defineProperty(Constants, "Hidden", "Hidden");
|
|
138
140
|
_defineProperty(Constants, "EndConversationDueToOverflow", "endconversationduetooverflow");
|
|
139
141
|
_defineProperty(Constants, "SkipSessionCloseForPersistentChatFlag", "skipSessionCloseForPersistentChat");
|
|
142
|
+
// Minimum font-size for input fields to prevent iOS Safari auto-zoom on focus
|
|
143
|
+
_defineProperty(Constants, "minInputFontSizePx", 16);
|
|
144
|
+
_defineProperty(Constants, "minInputFontSize", "16px");
|
|
140
145
|
export const Regex = (_class = /*#__PURE__*/_createClass(function Regex() {
|
|
141
146
|
_classCallCheck(this, Regex);
|
|
142
147
|
}), _defineProperty(_class, "EmailRegex", "^(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\")@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\])$"), _class);
|
|
@@ -5,7 +5,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
5
5
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
6
6
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
7
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../telemetry/TelemetryConstants";
|
|
8
|
-
import { getAuthClientFunction, handleAuthentication } from "../../components/livechatwidget/common/authHelper";
|
|
8
|
+
import { getAuthClientFunction, handleAuthentication, isMidAuthEnabled } from "../../components/livechatwidget/common/authHelper";
|
|
9
9
|
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
10
10
|
import { TelemetryHelper } from "../telemetry/TelemetryHelper";
|
|
11
11
|
import { isNullOrEmptyString } from "../utils";
|
|
@@ -20,6 +20,8 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
20
20
|
_defineProperty(this, "getAuthToken", void 0);
|
|
21
21
|
_defineProperty(this, "sdkMocked", void 0);
|
|
22
22
|
_defineProperty(this, "disableReauthentication", void 0);
|
|
23
|
+
// Stays true so CASE 1 re-triggers on every startChat to set deferInitialAuth
|
|
24
|
+
_defineProperty(this, "pendingMidAuthUnauthenticatedState", false);
|
|
23
25
|
this.chatSDK = input.chatSDK;
|
|
24
26
|
this.chatConfig = input.chatConfig;
|
|
25
27
|
this.getAuthToken = input.getAuthToken;
|
|
@@ -44,6 +46,12 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
44
46
|
value: function destroy() {
|
|
45
47
|
this.token = null;
|
|
46
48
|
this.expiration = 0;
|
|
49
|
+
if (isMidAuthEnabled(this.chatConfig)) {
|
|
50
|
+
this.pendingMidAuthUnauthenticatedState = false;
|
|
51
|
+
this.isAuthenticated = true;
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
+
this.chatSDK.deferInitialAuth = false;
|
|
54
|
+
}
|
|
47
55
|
}
|
|
48
56
|
}, {
|
|
49
57
|
key: "isTokenSet",
|
|
@@ -208,6 +216,10 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
208
216
|
message: "Token is valid"
|
|
209
217
|
};
|
|
210
218
|
}
|
|
219
|
+
|
|
220
|
+
// Token missing or expired - need to get a new one via getAuthToken
|
|
221
|
+
// For mid-auth: getAuthToken receives { isMidAuthEnabled: true } so customer implementations
|
|
222
|
+
// can check portal state and return null for logged-out users
|
|
211
223
|
TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.INFO, {
|
|
212
224
|
Event: TelemetryEvent.NewTokenValidationStarted,
|
|
213
225
|
Description: "Token validation started."
|
|
@@ -228,6 +240,7 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
228
240
|
this.token = "";
|
|
229
241
|
this.expiration = 0;
|
|
230
242
|
try {
|
|
243
|
+
var _ring$error, _ring$error2;
|
|
231
244
|
const ring = await handleAuthentication(this.chatSDK, this.chatConfig, this.getAuthToken);
|
|
232
245
|
if ((ring === null || ring === void 0 ? void 0 : ring.result) === true && ring !== null && ring !== void 0 && ring.token) {
|
|
233
246
|
await this.setToken(ring.token);
|
|
@@ -242,18 +255,35 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
242
255
|
result: true,
|
|
243
256
|
message: "New Token obtained"
|
|
244
257
|
};
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Mid-auth: no token available - set pending flag for startChat to handle
|
|
261
|
+
const isEmptyTokenWithoutError = isNullOrEmptyString(ring === null || ring === void 0 ? void 0 : ring.token) && ((ring === null || ring === void 0 ? void 0 : ring.result) === true || (ring === null || ring === void 0 ? void 0 : ring.result) === false && !(ring !== null && ring !== void 0 && ring.error));
|
|
262
|
+
if (isMidAuthEnabled(this.chatConfig) && isEmptyTokenWithoutError) {
|
|
263
|
+
// Clear Facade and SDK token state so API calls use unauthenticated endpoints
|
|
264
|
+
this.token = "";
|
|
265
|
+
this.expiration = 0;
|
|
266
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
267
|
+
this.chatSDK.authenticatedUserToken = null;
|
|
268
|
+
this.pendingMidAuthUnauthenticatedState = true;
|
|
269
|
+
TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.INFO, {
|
|
270
|
+
Event: TelemetryEvent.NewTokenValidationCompleted,
|
|
271
|
+
Description: "Mid-auth enabled: no token returned; proceeding as unauthenticated"
|
|
251
272
|
});
|
|
252
273
|
return {
|
|
253
|
-
result:
|
|
254
|
-
message:
|
|
274
|
+
result: true,
|
|
275
|
+
message: "Mid-auth: proceeding as unauthenticated"
|
|
255
276
|
};
|
|
256
277
|
}
|
|
278
|
+
TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.ERROR, {
|
|
279
|
+
Event: TelemetryEvent.NewTokenValidationFailed,
|
|
280
|
+
Description: (_ring$error = ring.error) === null || _ring$error === void 0 ? void 0 : _ring$error.message,
|
|
281
|
+
ExceptionDetails: ring === null || ring === void 0 ? void 0 : ring.error
|
|
282
|
+
});
|
|
283
|
+
return {
|
|
284
|
+
result: false,
|
|
285
|
+
message: (ring === null || ring === void 0 ? void 0 : (_ring$error2 = ring.error) === null || _ring$error2 === void 0 ? void 0 : _ring$error2.message) || "Failed to get token"
|
|
286
|
+
};
|
|
257
287
|
} catch (e) {
|
|
258
288
|
console.error("Unexpected error while getting token", e);
|
|
259
289
|
TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.ERROR, {
|
|
@@ -267,6 +297,155 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
267
297
|
};
|
|
268
298
|
}
|
|
269
299
|
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Sets unauthenticated state for mid-auth flow.
|
|
303
|
+
* Clears SDK internal state to prevent reconnection to previous authenticated session.
|
|
304
|
+
*/
|
|
305
|
+
}, {
|
|
306
|
+
key: "setMidAuthUnauthenticatedState",
|
|
307
|
+
value: function setMidAuthUnauthenticatedState() {
|
|
308
|
+
var _sdk$chatToken, _sdk$chatToken2;
|
|
309
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
310
|
+
const sdk = this.chatSDK;
|
|
311
|
+
const hadExistingChat = !!((_sdk$chatToken = sdk.chatToken) !== null && _sdk$chatToken !== void 0 && _sdk$chatToken.chatId);
|
|
312
|
+
const previousChatId = (_sdk$chatToken2 = sdk.chatToken) === null || _sdk$chatToken2 === void 0 ? void 0 : _sdk$chatToken2.chatId;
|
|
313
|
+
this.clearAuthState();
|
|
314
|
+
|
|
315
|
+
// Clear SDK internal state for fresh unauthenticated chat
|
|
316
|
+
sdk.chatToken = {};
|
|
317
|
+
sdk.reconnectId = null;
|
|
318
|
+
sdk.requestId = null;
|
|
319
|
+
sdk.sessionId = null;
|
|
320
|
+
sdk.conversation = null;
|
|
321
|
+
TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.INFO, {
|
|
322
|
+
Event: TelemetryEvent.MidConversationAuthReset,
|
|
323
|
+
Description: hadExistingChat ? "Mid-auth without token: local state cleared" : "Mid-auth: initialized as unauthenticated (no prior chat)",
|
|
324
|
+
Data: hadExistingChat ? {
|
|
325
|
+
previousChatId
|
|
326
|
+
} : undefined
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/** Clears authentication state in both FacadeChatSDK and underlying SDK */
|
|
331
|
+
}, {
|
|
332
|
+
key: "clearAuthState",
|
|
333
|
+
value: function clearAuthState() {
|
|
334
|
+
this.token = "";
|
|
335
|
+
this.expiration = 0;
|
|
336
|
+
this.isAuthenticated = false;
|
|
337
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
338
|
+
this.chatSDK.authenticatedUserToken = null;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Migrates conversation from unauthenticated to authenticated via authenticateChat.
|
|
343
|
+
* Called after startChat() when user has a valid token but the backend conversation
|
|
344
|
+
* was started as unauthenticated.
|
|
345
|
+
*/
|
|
346
|
+
}, {
|
|
347
|
+
key: "migrateConversationToAuthenticated",
|
|
348
|
+
value: async function migrateConversationToAuthenticated() {
|
|
349
|
+
try {
|
|
350
|
+
await this.chatSDK.authenticateChat(this.token, {
|
|
351
|
+
refreshChatToken: true
|
|
352
|
+
});
|
|
353
|
+
this.isAuthenticated = true;
|
|
354
|
+
TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.INFO, {
|
|
355
|
+
Event: TelemetryEvent.MidConversationAuthSucceeded,
|
|
356
|
+
Description: "Mid-auth: authenticateChat completed, conversation migrated to authenticated"
|
|
357
|
+
});
|
|
358
|
+
} catch (e) {
|
|
359
|
+
// Non-fatal: Chat is already active via startChat, will retry on next reconnect
|
|
360
|
+
TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.WARN, {
|
|
361
|
+
Event: TelemetryEvent.MidConversationAuthFailed,
|
|
362
|
+
Description: "Mid-auth: authenticateChat returned error after startChat, chat still active",
|
|
363
|
+
ExceptionDetails: {
|
|
364
|
+
message: e === null || e === void 0 ? void 0 : e.message
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Configures SDK auth state before startChat.
|
|
372
|
+
* CASE 1: Pending unauthenticated (no token) - sets deferInitialAuth=true
|
|
373
|
+
* CASE 2: Authenticated with valid token - sets SDK token and deferInitialAuth based on scenario
|
|
374
|
+
*/
|
|
375
|
+
}, {
|
|
376
|
+
key: "configureMidAuthState",
|
|
377
|
+
value: function configureMidAuthState(isReconnect, wasPreviousSessionAuthenticated) {
|
|
378
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
379
|
+
const sdk = this.chatSDK;
|
|
380
|
+
|
|
381
|
+
// CASE 1: No token available (user not logged in)
|
|
382
|
+
// pendingMidAuthUnauthenticatedState stays true until user logs in (cleared in tokenRing)
|
|
383
|
+
if (this.pendingMidAuthUnauthenticatedState) {
|
|
384
|
+
const shouldClear = this.handlePendingUnauthenticatedState(wasPreviousSessionAuthenticated);
|
|
385
|
+
sdk.deferInitialAuth = true;
|
|
386
|
+
TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.INFO, {
|
|
387
|
+
Event: TelemetryEvent.MidConversationAuthReset,
|
|
388
|
+
Description: "Mid-auth configureMidAuthState: CASE 1 - unauthenticated, deferInitialAuth=true",
|
|
389
|
+
Data: {
|
|
390
|
+
isReconnect: String(isReconnect),
|
|
391
|
+
wasPreviousSessionAuthenticated: String(wasPreviousSessionAuthenticated),
|
|
392
|
+
shouldClearReconnectParams: String(shouldClear)
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
return {
|
|
396
|
+
shouldClearReconnectParams: shouldClear
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// CASE 2: Authenticated with valid token
|
|
401
|
+
if (this.isTokenSet() && !this.isTokenExpired()) {
|
|
402
|
+
this.handleAuthenticatedState(isReconnect, wasPreviousSessionAuthenticated);
|
|
403
|
+
}
|
|
404
|
+
return {
|
|
405
|
+
shouldClearReconnectParams: false
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* CASE 1 handler: Returns true if reconnect params should be cleared (Auth -> Unauth transition)
|
|
411
|
+
*/
|
|
412
|
+
}, {
|
|
413
|
+
key: "handlePendingUnauthenticatedState",
|
|
414
|
+
value: function handlePendingUnauthenticatedState(wasPreviousSessionAuthenticated) {
|
|
415
|
+
if (wasPreviousSessionAuthenticated) {
|
|
416
|
+
// Auth -> Unauth: user logged out, clear state for fresh chat
|
|
417
|
+
this.setMidAuthUnauthenticatedState();
|
|
418
|
+
return true;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// Unauth -> Unauth: keep liveChatContext for reconnection
|
|
422
|
+
this.isAuthenticated = false;
|
|
423
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
424
|
+
this.chatSDK.authenticatedUserToken = null;
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* CASE 2 handler: Sets deferInitialAuth only for reconnects to unauthenticated sessions (need migration).
|
|
430
|
+
* For new chats or reconnects to authenticated sessions, SDK handles auth internally.
|
|
431
|
+
*/
|
|
432
|
+
}, {
|
|
433
|
+
key: "handleAuthenticatedState",
|
|
434
|
+
value: function handleAuthenticatedState(isReconnect, wasPreviousSessionAuthenticated) {
|
|
435
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
436
|
+
const sdk = this.chatSDK;
|
|
437
|
+
sdk.authenticatedUserToken = this.token;
|
|
438
|
+
if (isReconnect && !wasPreviousSessionAuthenticated) {
|
|
439
|
+
sdk.deferInitialAuth = true;
|
|
440
|
+
TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.INFO, {
|
|
441
|
+
Event: TelemetryEvent.MidConversationAuthSucceeded,
|
|
442
|
+
Description: "Mid-auth handleAuthenticatedState: CASE 2 - reconnect to unauth session, deferInitialAuth=true (migration needed)"
|
|
443
|
+
});
|
|
444
|
+
} else {
|
|
445
|
+
// Reset to prevent inheriting deferInitialAuth=true from a previous unauthenticated chat
|
|
446
|
+
sdk.deferInitialAuth = false;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
270
449
|
}, {
|
|
271
450
|
key: "validateAndExecuteCall",
|
|
272
451
|
value: async function validateAndExecuteCall(functionName, fn) {
|
|
@@ -301,7 +480,53 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
301
480
|
key: "startChat",
|
|
302
481
|
value: async function startChat() {
|
|
303
482
|
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
304
|
-
|
|
483
|
+
const midAuthEnabled = isMidAuthEnabled(this.chatConfig);
|
|
484
|
+
const isReconnect = !!optionalParams.liveChatContext || !!optionalParams.reconnectId;
|
|
485
|
+
const wasPreviousSessionAuthenticated = optionalParams.wasAuthenticated === true;
|
|
486
|
+
return this.validateAndExecuteCall("startChat", async () => {
|
|
487
|
+
if (midAuthEnabled) {
|
|
488
|
+
const {
|
|
489
|
+
shouldClearReconnectParams
|
|
490
|
+
} = this.configureMidAuthState(isReconnect, wasPreviousSessionAuthenticated);
|
|
491
|
+
if (shouldClearReconnectParams) {
|
|
492
|
+
delete optionalParams.liveChatContext;
|
|
493
|
+
delete optionalParams.reconnectId;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
await this.chatSDK.startChat(optionalParams);
|
|
497
|
+
|
|
498
|
+
// Migrate to authenticated if needed (reconnects to unauthenticated sessions only)
|
|
499
|
+
if (midAuthEnabled) {
|
|
500
|
+
const shouldMigrateToAuth = isReconnect && this.isTokenSet() && !this.isTokenExpired() && !wasPreviousSessionAuthenticated;
|
|
501
|
+
if (shouldMigrateToAuth) {
|
|
502
|
+
TelemetryHelper.logFacadeChatSDKEventToAllTelemetry(LogLevel.INFO, {
|
|
503
|
+
Event: TelemetryEvent.MidConversationAuthSucceeded,
|
|
504
|
+
Description: "Mid-auth startChat: initiating migration to authenticated",
|
|
505
|
+
Data: {
|
|
506
|
+
isReconnect: String(isReconnect),
|
|
507
|
+
wasPreviousSessionAuthenticated: String(wasPreviousSessionAuthenticated)
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
await this.migrateConversationToAuthenticated();
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// Broadcast final auth state after startChat completes (only on state change)
|
|
515
|
+
if (midAuthEnabled) {
|
|
516
|
+
const isAuthenticatedAfterStart = this.isTokenSet() && !this.isTokenExpired();
|
|
517
|
+
const authStateChanged = !isReconnect || isAuthenticatedAfterStart !== wasPreviousSessionAuthenticated;
|
|
518
|
+
if (authStateChanged) {
|
|
519
|
+
BroadcastService.postMessage({
|
|
520
|
+
eventName: isAuthenticatedAfterStart ? BroadcastEvent.MidConversationAuthSucceeded : BroadcastEvent.MidConversationAuthReset,
|
|
521
|
+
payload: {
|
|
522
|
+
isAuthenticated: isAuthenticatedAfterStart,
|
|
523
|
+
isStartChatComplete: true,
|
|
524
|
+
isReconnect
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
});
|
|
305
530
|
}
|
|
306
531
|
}, {
|
|
307
532
|
key: "endChat",
|
|
@@ -439,6 +664,7 @@ export let FacadeChatSDK = /*#__PURE__*/function () {
|
|
|
439
664
|
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
440
665
|
return this.validateAndExecuteCall("getAgentAvailability", () => this.chatSDK.getAgentAvailability(optionalParams));
|
|
441
666
|
}
|
|
667
|
+
|
|
442
668
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
443
669
|
}, {
|
|
444
670
|
key: "getReconnectableChats",
|
|
@@ -69,6 +69,8 @@ export let BroadcastEvent;
|
|
|
69
69
|
BroadcastEvent["FMLTrackingCompletedAck"] = "FMLTrackingCompletedAck";
|
|
70
70
|
BroadcastEvent["FMLTrackingCompleted"] = "FMLTrackingCompleted";
|
|
71
71
|
BroadcastEvent["PersistentConversationReset"] = "PersistentConversationReset";
|
|
72
|
+
BroadcastEvent["MidConversationAuthSucceeded"] = "MidConversationAuthSucceeded";
|
|
73
|
+
BroadcastEvent["MidConversationAuthReset"] = "MidConversationAuthReset";
|
|
72
74
|
})(BroadcastEvent || (BroadcastEvent = {}));
|
|
73
75
|
export let TelemetryEvent;
|
|
74
76
|
(function (TelemetryEvent) {
|
|
@@ -102,6 +104,9 @@ export let TelemetryEvent;
|
|
|
102
104
|
TelemetryEvent["CallingSDKInitFailed"] = "CallingSDKInitFailed";
|
|
103
105
|
TelemetryEvent["CallingSDKLoadSuccess"] = "CallingSDKLoadSuccess";
|
|
104
106
|
TelemetryEvent["CallingSDKLoadFailed"] = "CallingSDKLoadFailed";
|
|
107
|
+
TelemetryEvent["MidConversationAuthSucceeded"] = "MidConversationAuthSucceeded";
|
|
108
|
+
TelemetryEvent["MidConversationAuthFailed"] = "MidConversationAuthFailed";
|
|
109
|
+
TelemetryEvent["MidConversationAuthReset"] = "MidConversationAuthReset";
|
|
105
110
|
TelemetryEvent["GetConversationDetailsCallStarted"] = "GetConversationDetailsCallStarted";
|
|
106
111
|
TelemetryEvent["GetConversationDetailsCallFailed"] = "GetConversationDetailsCallFailed";
|
|
107
112
|
TelemetryEvent["EndChatSDKCallFailed"] = "EndChatSDKCallFailed";
|
|
@@ -191,6 +196,7 @@ export let TelemetryEvent;
|
|
|
191
196
|
TelemetryEvent["QueueOverflowEvent"] = "QueueOverflowEvent";
|
|
192
197
|
TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
|
|
193
198
|
TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
|
|
199
|
+
TelemetryEvent["HTMLSanitized"] = "HTMLSanitized";
|
|
194
200
|
TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
|
|
195
201
|
TelemetryEvent["AttachmentUploadValidatorMiddlewareFailed"] = "AttachmentUploadValidatorMiddlewareFailed";
|
|
196
202
|
TelemetryEvent["CitationMiddlewareFailed"] = "CitationMiddlewareFailed";
|
|
@@ -312,10 +318,16 @@ export let TelemetryEvent;
|
|
|
312
318
|
TelemetryEvent["LCWLazyLoadNoMoreHistory"] = "LCWLazyLoadNoMoreHistory";
|
|
313
319
|
TelemetryEvent["LCWLazyLoadHistoryError"] = "LCWLazyLoadHistoryError";
|
|
314
320
|
TelemetryEvent["LCWLazyLoadDestroyed"] = "LCWLazyLoadDestroyed";
|
|
321
|
+
TelemetryEvent["LCWLazyLoadTriggerFired"] = "LCWLazyLoadTriggerFired";
|
|
322
|
+
TelemetryEvent["LCWLazyLoadBatchReceived"] = "LCWLazyLoadBatchReceived";
|
|
323
|
+
TelemetryEvent["LCWLazyLoadInitialLoadComplete"] = "LCWLazyLoadInitialLoadComplete";
|
|
324
|
+
TelemetryEvent["LCWLazyLoadScrollAnchorApplied"] = "LCWLazyLoadScrollAnchorApplied";
|
|
315
325
|
TelemetryEvent["SecureEventBusUnauthorizedDispatch"] = "SecureEventBusUnauthorizedDispatch";
|
|
316
326
|
TelemetryEvent["SecureEventBusListenerError"] = "SecureEventBusListenerError";
|
|
317
327
|
TelemetryEvent["SecureEventBusDispatchError"] = "SecureEventBusDispatchError";
|
|
318
328
|
TelemetryEvent["StartChatComplete"] = "StartChatComplete";
|
|
329
|
+
TelemetryEvent["AgentJoinedConversation"] = "AgentJoinedConversation";
|
|
330
|
+
TelemetryEvent["BrowserTabHidden"] = "BrowserTabHidden";
|
|
319
331
|
})(TelemetryEvent || (TelemetryEvent = {}));
|
|
320
332
|
export let TelemetryConstants = /*#__PURE__*/function () {
|
|
321
333
|
function TelemetryConstants() {
|
|
@@ -386,6 +398,8 @@ export let TelemetryConstants = /*#__PURE__*/function () {
|
|
|
386
398
|
case TelemetryEvent.SecureEventBusUnauthorizedDispatch:
|
|
387
399
|
case TelemetryEvent.SecureEventBusListenerError:
|
|
388
400
|
case TelemetryEvent.SecureEventBusDispatchError:
|
|
401
|
+
case TelemetryEvent.AgentJoinedConversation:
|
|
402
|
+
case TelemetryEvent.BrowserTabHidden:
|
|
389
403
|
return ScenarioType.ACTIONS;
|
|
390
404
|
case TelemetryEvent.StartChatSDKCall:
|
|
391
405
|
case TelemetryEvent.StartChatEventReceived:
|
|
@@ -11,6 +11,7 @@ import { appInsightsLogger } from "./loggers/appInsightsLogger";
|
|
|
11
11
|
import { ariaTelemetryLogger } from "./loggers/ariaTelemetryLogger";
|
|
12
12
|
import { consoleLogger } from "./loggers/consoleLogger";
|
|
13
13
|
import { defaultAriaConfig } from "./defaultConfigs/defaultAriaConfig";
|
|
14
|
+
import { sanitizeSasInPayload } from "./sanitizeSasInPayload";
|
|
14
15
|
export let TelemetryTimers = /*#__PURE__*/_createClass(function TelemetryTimers() {
|
|
15
16
|
_classCallCheck(this, TelemetryTimers);
|
|
16
17
|
});
|
|
@@ -72,11 +73,15 @@ export const RegisterLoggers = () => {
|
|
|
72
73
|
};
|
|
73
74
|
};
|
|
74
75
|
const logTelemetry = telemetryEvent => {
|
|
76
|
+
// Redact Azure SAS credentials in any URL embedded in the payload (e.g.
|
|
77
|
+
// customer-supplied blob asset URLs in widget customization props) before
|
|
78
|
+
// it fans out to console, Aria, AppInsights, or any custom logger.
|
|
79
|
+
const sanitizedPayload = sanitizeSasInPayload(telemetryEvent === null || telemetryEvent === void 0 ? void 0 : telemetryEvent.payload);
|
|
75
80
|
loggers.map(logger => {
|
|
76
81
|
var _payload, _telemetryInput$paylo;
|
|
77
82
|
const logLevel = telemetryEvent.logLevel ?? LogLevel.INFO;
|
|
78
83
|
const scenarioType = ((_payload = telemetryEvent.payload) === null || _payload === void 0 ? void 0 : _payload.scenarioType) ?? ScenarioType.UNDEFINED;
|
|
79
|
-
const telemetryInput = parseInput(
|
|
84
|
+
const telemetryInput = parseInput(sanitizedPayload, scenarioType);
|
|
80
85
|
telemetryInput.telemetryInfo = {
|
|
81
86
|
telemetryInfo: TelemetryHelper.buildTelemetryEvent(logLevel, telemetryInput)
|
|
82
87
|
};
|
|
@@ -5,11 +5,11 @@ import { AppInsightsTelemetryMessage } from "../../Constants";
|
|
|
5
5
|
import { AppInsightsEventMapping } from "../AppInsightsEvents";
|
|
6
6
|
var AllowedKeys;
|
|
7
7
|
(function (AllowedKeys) {
|
|
8
|
-
AllowedKeys["OrganizationId"] = "
|
|
9
|
-
AllowedKeys["ConversationId"] = "
|
|
8
|
+
AllowedKeys["OrganizationId"] = "powerplatform.analytics.resource.organization.id";
|
|
9
|
+
AllowedKeys["ConversationId"] = "powerplatform.analytics.resource.id";
|
|
10
10
|
AllowedKeys["ElapsedTimeInMilliseconds"] = "Duration";
|
|
11
|
-
AllowedKeys["Description"] = "
|
|
12
|
-
AllowedKeys["ChannelId"] = "
|
|
11
|
+
AllowedKeys["Description"] = "omnichannel.description";
|
|
12
|
+
AllowedKeys["ChannelId"] = "omnichannel.channel.type";
|
|
13
13
|
AllowedKeys["LCWRuntimeId"] = "ClientSessionId";
|
|
14
14
|
})(AllowedKeys || (AllowedKeys = {}));
|
|
15
15
|
let initializationPromise = null;
|
|
@@ -86,8 +86,8 @@ export const appInsightsLogger = appInsightsKey => {
|
|
|
86
86
|
if (eventName) {
|
|
87
87
|
const trackingEventName = getTrackingEventName(logLevel, eventName);
|
|
88
88
|
const eventProperties = setEventProperties(trackingEventName, telemetryInfo);
|
|
89
|
-
_logger.
|
|
90
|
-
|
|
89
|
+
_logger.trackTrace({
|
|
90
|
+
message: trackingEventName,
|
|
91
91
|
properties: eventProperties
|
|
92
92
|
});
|
|
93
93
|
}
|
|
@@ -133,7 +133,7 @@ export const appInsightsLogger = appInsightsKey => {
|
|
|
133
133
|
// Additional properties
|
|
134
134
|
eventProperties["ConversationStage"] = customProperties.ConversationStage ?? ConversationStage.CSREngagement;
|
|
135
135
|
eventProperties["Scenario"] = "Conversation Diagnostics";
|
|
136
|
-
eventProperties["
|
|
136
|
+
eventProperties["powerplatform.analytics.subscenario"] = eventName.includes(": ") ? eventName.split(": ")[1] : eventName;
|
|
137
137
|
return eventProperties;
|
|
138
138
|
}
|
|
139
139
|
function getTrackingEventName(logLevel, eventName) {
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redacts the values of Azure Shared Access Signature (SAS) query parameters in any
|
|
3
|
+
* URL embedded in a telemetry payload, so customer-supplied SAS URLs (e.g. blob asset
|
|
4
|
+
* URLs in widget customization props) cannot leak credentials through Aria/AppInsights.
|
|
5
|
+
*
|
|
6
|
+
* Trigger: any URL whose query string contains `sig=`. When detected, every well-known
|
|
7
|
+
* SAS parameter value in that query is replaced with `[REDACTED]`. Other URLs and other
|
|
8
|
+
* substrings of the payload pass through unchanged.
|
|
9
|
+
*
|
|
10
|
+
* Coverage of SAS parameter names:
|
|
11
|
+
* - Service/Blob SAS: sig, sv, se, st, sp, spr, sr, sip
|
|
12
|
+
* - Account SAS: ss, srt
|
|
13
|
+
* - User-delegation key SAS: skoid, sktid, skt, ske, sks, skv, saoid, suoid, sce, sdd
|
|
14
|
+
* - Response header overrides: rscc, rscd, rsce, rscl, rsct
|
|
15
|
+
*
|
|
16
|
+
* Reference: https://learn.microsoft.com/en-us/rest/api/storageservices/create-service-sas
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
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"]);
|
|
20
|
+
const REDACTED_VALUE = "[REDACTED]";
|
|
21
|
+
|
|
22
|
+
// Matches any http(s) URL substring up to whitespace / closing quote / angle-bracket / paren.
|
|
23
|
+
const URL_REGEX = /\bhttps?:\/\/[^\s"'<>)]+/gi;
|
|
24
|
+
const redactQueryIfSas = url => {
|
|
25
|
+
const queryIdx = url.indexOf("?");
|
|
26
|
+
if (queryIdx < 0) {
|
|
27
|
+
return url;
|
|
28
|
+
}
|
|
29
|
+
// Separate the fragment (#...) before processing the query — fragments come
|
|
30
|
+
// after the query string in URL syntax and must not be folded into the last
|
|
31
|
+
// query parameter's value when we split on `&`.
|
|
32
|
+
const afterQuestionMark = url.slice(queryIdx + 1);
|
|
33
|
+
const fragIdx = afterQuestionMark.indexOf("#");
|
|
34
|
+
const query = fragIdx < 0 ? afterQuestionMark : afterQuestionMark.slice(0, fragIdx);
|
|
35
|
+
const fragment = fragIdx < 0 ? "" : afterQuestionMark.slice(fragIdx); // includes the leading '#'
|
|
36
|
+
if (!/(^|&)sig=/i.test(query)) {
|
|
37
|
+
// No SAS signature present — leave the URL alone so legitimate non-SAS query
|
|
38
|
+
// strings (e.g. ?utm_source=...) are not mangled.
|
|
39
|
+
return url;
|
|
40
|
+
}
|
|
41
|
+
const base = url.slice(0, queryIdx);
|
|
42
|
+
const sanitizedQuery = query.split("&").map(pair => {
|
|
43
|
+
const eqIdx = pair.indexOf("=");
|
|
44
|
+
if (eqIdx < 0) {
|
|
45
|
+
return pair;
|
|
46
|
+
}
|
|
47
|
+
const name = pair.slice(0, eqIdx).toLowerCase();
|
|
48
|
+
return SAS_PARAM_NAMES.has(name) ? `${pair.slice(0, eqIdx)}=${REDACTED_VALUE}` : pair;
|
|
49
|
+
}).join("&");
|
|
50
|
+
return `${base}?${sanitizedQuery}${fragment}`;
|
|
51
|
+
};
|
|
52
|
+
const sanitizeString = s => s.replace(URL_REGEX, redactQueryIfSas);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Deep-walk a value and redact SAS credentials in any string it contains.
|
|
56
|
+
* Returns a new object/array (originals are not mutated); non-string leaves are
|
|
57
|
+
* passed through. Tree-shaped, JSON-like values only — not designed for class
|
|
58
|
+
* instances, prototype-bound objects, or cyclic graphs.
|
|
59
|
+
*/
|
|
60
|
+
export const sanitizeSasInPayload = value => {
|
|
61
|
+
if (typeof value === "string") {
|
|
62
|
+
return sanitizeString(value);
|
|
63
|
+
}
|
|
64
|
+
if (Array.isArray(value)) {
|
|
65
|
+
return value.map(sanitizeSasInPayload);
|
|
66
|
+
}
|
|
67
|
+
if (value !== null && typeof value === "object") {
|
|
68
|
+
const out = {};
|
|
69
|
+
for (const [k, v] of Object.entries(value)) {
|
|
70
|
+
out[k] = sanitizeSasInPayload(v);
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
return value;
|
|
75
|
+
};
|