@microsoft/omnichannel-chat-widget 0.1.0-main.e170704 → 0.1.0-main.e312ecd
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 +32 -0
- package/lib/cjs/common/Constants.js +18 -2
- package/lib/cjs/common/storage/default/defaultCacheManager.js +34 -0
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +114 -0
- package/lib/cjs/common/storage/default/defaultInMemoryDataStore.js +86 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +34 -3
- package/lib/cjs/common/telemetry/TelemetryManager.js +7 -1
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +33 -21
- package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/cjs/common/utils.js +76 -2
- package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +19 -3
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
- package/lib/cjs/components/footerstateful/FooterStateful.js +1 -8
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +11 -2
- package/lib/cjs/components/headerstateful/HeaderStateful.js +4 -3
- package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +44 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +23 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +39 -0
- package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +70 -0
- package/lib/cjs/components/livechatwidget/common/Deferred.js +42 -0
- package/lib/cjs/components/livechatwidget/common/authHelper.js +65 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +13 -1
- package/lib/cjs/components/livechatwidget/common/createFooter.js +7 -16
- package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +12 -0
- package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +29 -17
- package/lib/cjs/components/livechatwidget/common/endChat.js +63 -16
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +24 -3
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +55 -35
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/cjs/components/livechatwidget/common/shareObservable.js +45 -0
- package/lib/cjs/components/livechatwidget/common/startChat.js +179 -72
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +273 -91
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -10
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +96 -2
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +4 -1
- package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +11 -0
- package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +10 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +1 -0
- package/lib/cjs/contexts/common/ConversationState.js +3 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +3 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +13 -5
- package/lib/cjs/contexts/createReducer.js +17 -0
- package/lib/cjs/controller/componentController.js +3 -3
- package/lib/cjs/plugins/newMessageEventHandler.js +10 -13
- package/lib/esm/common/Constants.js +18 -2
- package/lib/esm/common/storage/default/defaultCacheManager.js +19 -0
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +102 -0
- package/lib/esm/common/storage/default/defaultInMemoryDataStore.js +71 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +34 -3
- package/lib/esm/common/telemetry/TelemetryManager.js +6 -1
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +30 -12
- package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/esm/common/utils.js +53 -0
- package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +21 -6
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
- package/lib/esm/components/footerstateful/FooterStateful.js +1 -8
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +9 -3
- package/lib/esm/components/headerstateful/HeaderStateful.js +4 -3
- package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +34 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +14 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +29 -0
- package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +59 -0
- package/lib/esm/components/livechatwidget/common/Deferred.js +33 -0
- package/lib/esm/components/livechatwidget/common/authHelper.js +50 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -2
- package/lib/esm/components/livechatwidget/common/createFooter.js +4 -15
- package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +8 -0
- package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +29 -17
- package/lib/esm/components/livechatwidget/common/endChat.js +61 -17
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +23 -5
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +56 -37
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/esm/components/livechatwidget/common/shareObservable.js +38 -0
- package/lib/esm/components/livechatwidget/common/startChat.js +174 -75
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +265 -94
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +7 -11
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +86 -2
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -1
- package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +4 -0
- package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +1 -0
- package/lib/esm/contexts/common/ConversationState.js +3 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +3 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +11 -5
- package/lib/esm/contexts/createReducer.js +17 -0
- package/lib/esm/controller/componentController.js +3 -3
- package/lib/esm/plugins/newMessageEventHandler.js +10 -12
- package/lib/types/common/Constants.d.ts +9 -1
- package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
- package/lib/types/common/storage/default/defaultCacheManager.d.ts +4 -0
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -0
- package/lib/types/common/storage/default/defaultInMemoryDataStore.d.ts +6 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +27 -5
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
- package/lib/types/common/telemetry/definitions/Payload.d.ts +12 -9
- package/lib/types/common/utils.d.ts +7 -1
- package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/authHelper.d.ts +5 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -4
- package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
- package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -0
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -1
- package/lib/types/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
- package/lib/types/contexts/common/ConversationState.d.ts +3 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +4 -1
- package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +1 -2
- package/package.json +4 -3
|
@@ -46,6 +46,14 @@ const ProactiveChatPaneStateful = props => {
|
|
|
46
46
|
const handleProactiveChatInviteTimeout = () => {
|
|
47
47
|
if (!timeoutRemoved) {
|
|
48
48
|
setTimeoutRemoved(true);
|
|
49
|
+
dispatch({
|
|
50
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
51
|
+
payload: {
|
|
52
|
+
proactiveChatBodyTitle: "",
|
|
53
|
+
proactiveChatEnablePrechat: false,
|
|
54
|
+
proactiveChatInNewWindow: false
|
|
55
|
+
}
|
|
56
|
+
});
|
|
49
57
|
dispatch({
|
|
50
58
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
51
59
|
payload: _ConversationState.ConversationState.Closed
|
|
@@ -111,13 +119,21 @@ const ProactiveChatPaneStateful = props => {
|
|
|
111
119
|
Description: "Proactive chat closed."
|
|
112
120
|
});
|
|
113
121
|
|
|
122
|
+
dispatch({
|
|
123
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
124
|
+
payload: {
|
|
125
|
+
proactiveChatBodyTitle: "",
|
|
126
|
+
proactiveChatEnablePrechat: false,
|
|
127
|
+
proactiveChatInNewWindow: false
|
|
128
|
+
}
|
|
129
|
+
});
|
|
114
130
|
dispatch({
|
|
115
131
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
116
132
|
payload: _ConversationState.ConversationState.Closed
|
|
117
133
|
});
|
|
118
134
|
},
|
|
119
135
|
...(proactiveChatProps === null || proactiveChatProps === void 0 ? void 0 : proactiveChatProps.controlProps),
|
|
120
|
-
bodyTitleText: state.appStates.proactiveChatStates.proactiveChatBodyTitle
|
|
136
|
+
bodyTitleText: state.appStates.proactiveChatStates.proactiveChatBodyTitle ? state.appStates.proactiveChatStates.proactiveChatBodyTitle : proactiveChatProps === null || proactiveChatProps === void 0 ? void 0 : (_proactiveChatProps$c = proactiveChatProps.controlProps) === null || _proactiveChatProps$c === void 0 ? void 0 : _proactiveChatProps$c.bodyTitleText
|
|
121
137
|
};
|
|
122
138
|
(0, _react.useEffect)(() => {
|
|
123
139
|
(0, _utils.setFocusOnElement)(document.getElementById(controlProps.id + "-startbutton"));
|
|
@@ -25,15 +25,59 @@ var _utils = require("../../common/utils");
|
|
|
25
25
|
|
|
26
26
|
var _ = require("../..");
|
|
27
27
|
|
|
28
|
+
var _WebChatActionType = require("./webchatcontroller/enums/WebChatActionType");
|
|
29
|
+
|
|
30
|
+
var _WebChatStoreLoader = require("./webchatcontroller/WebChatStoreLoader");
|
|
31
|
+
|
|
32
|
+
var _Constants = require("../../common/Constants");
|
|
33
|
+
|
|
34
|
+
var _BotMagicCodeStore = require("./webchatcontroller/BotMagicCodeStore");
|
|
35
|
+
|
|
36
|
+
var _defaultAdaptiveCardStyles = require("./common/defaultStyles/defaultAdaptiveCardStyles");
|
|
37
|
+
|
|
38
|
+
var _defaultReceivedMessageAnchorStyles = require("./webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles");
|
|
39
|
+
|
|
28
40
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
41
|
|
|
30
42
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
43
|
|
|
44
|
+
const broadcastChannelMessageEvent = "message";
|
|
45
|
+
|
|
46
|
+
const postActivity = activity => {
|
|
47
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
48
|
+
return {
|
|
49
|
+
type: _WebChatActionType.WebChatActionType.DIRECT_LINE_POST_ACTIVITY,
|
|
50
|
+
meta: {
|
|
51
|
+
method: "keyboard"
|
|
52
|
+
},
|
|
53
|
+
payload: {
|
|
54
|
+
activity: {
|
|
55
|
+
channelData: undefined,
|
|
56
|
+
text: "",
|
|
57
|
+
textFormat: "plain",
|
|
58
|
+
type: _Constants.Constants.message,
|
|
59
|
+
...activity
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const createMagicCodeSuccessResponse = signin => {
|
|
66
|
+
return {
|
|
67
|
+
signin,
|
|
68
|
+
result: "Success"
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
|
|
32
72
|
const WebChatContainerStateful = props => {
|
|
73
|
+
var _props$adaptiveCardSt, _props$adaptiveCardSt2, _props$renderingMiddl, _props$renderingMiddl2, _props$renderingMiddl3, _props$renderingMiddl4;
|
|
74
|
+
|
|
33
75
|
const {
|
|
34
76
|
BasicWebChat
|
|
35
77
|
} = _botframeworkWebchat.Components;
|
|
36
78
|
const [state, dispatch] = (0, _.useChatContextStore)();
|
|
79
|
+
const magicCodeBroadcastChannel = new BroadcastChannel(_Constants.Constants.magicCodeBroadcastChannel);
|
|
80
|
+
const magicCodeResponseBroadcastChannel = new BroadcastChannel(_Constants.Constants.magicCodeResponseBroadcastChannel);
|
|
37
81
|
const containerStyles = {
|
|
38
82
|
root: Object.assign({}, _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.containerStyles, props === null || props === void 0 ? void 0 : props.containerStyles, {
|
|
39
83
|
display: state.appStates.isMinimized ? "none" : ""
|
|
@@ -58,11 +102,61 @@ const WebChatContainerStateful = props => {
|
|
|
58
102
|
Event: _TelemetryConstants.TelemetryEvent.WebChatLoaded
|
|
59
103
|
});
|
|
60
104
|
}, []);
|
|
105
|
+
(0, _react2.useEffect)(() => {
|
|
106
|
+
const eventListener = event => {
|
|
107
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-function
|
|
108
|
+
const {
|
|
109
|
+
data
|
|
110
|
+
} = event;
|
|
111
|
+
|
|
112
|
+
if (_BotMagicCodeStore.BotMagicCodeStore.botOAuthSignInId === data.signin) {
|
|
113
|
+
const {
|
|
114
|
+
signin,
|
|
115
|
+
code
|
|
116
|
+
} = data;
|
|
117
|
+
const text = `${code}`;
|
|
118
|
+
const action = postActivity({
|
|
119
|
+
text,
|
|
120
|
+
channelData: {
|
|
121
|
+
tags: [_Constants.Constants.hiddenTag]
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
_WebChatStoreLoader.WebChatStoreLoader.store.dispatch(action);
|
|
126
|
+
|
|
127
|
+
const response = createMagicCodeSuccessResponse(signin);
|
|
128
|
+
magicCodeResponseBroadcastChannel.postMessage(response);
|
|
129
|
+
|
|
130
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
131
|
+
Event: _TelemetryConstants.TelemetryEvent.SuppressBotMagicCodeSucceeded
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
_BotMagicCodeStore.BotMagicCodeStore.botOAuthSignInId = "";
|
|
135
|
+
magicCodeBroadcastChannel.close();
|
|
136
|
+
magicCodeResponseBroadcastChannel.close();
|
|
137
|
+
} else {
|
|
138
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
139
|
+
Event: _TelemetryConstants.TelemetryEvent.SuppressBotMagicCodeFailed,
|
|
140
|
+
Description: "Signin does not match"
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
magicCodeBroadcastChannel.addEventListener(broadcastChannelMessageEvent, eventListener);
|
|
146
|
+
}, []);
|
|
61
147
|
return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement("style", null, `
|
|
148
|
+
|
|
149
|
+
.webchat__bubble__content>div#ms_lcw_webchat_adaptive_card {
|
|
150
|
+
background: ${(props === null || props === void 0 ? void 0 : (_props$adaptiveCardSt = props.adaptiveCardStyles) === null || _props$adaptiveCardSt === void 0 ? void 0 : _props$adaptiveCardSt.background) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.background};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
div[class="ac-textBlock"]>p{color:${(props === null || props === void 0 ? void 0 : (_props$adaptiveCardSt2 = props.adaptiveCardStyles) === null || _props$adaptiveCardSt2 === void 0 ? void 0 : _props$adaptiveCardSt2.color) ?? _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles.color};}
|
|
154
|
+
|
|
62
155
|
.ms_lcw_webchat_received_message img.webchat__markdown__external-link-icon {
|
|
63
156
|
background-image : url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIzIDMgMTggMTgiICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik03LjI1MDEgNC41MDAxN0gxMC43NDk1QzExLjE2MzcgNC41MDAxNyAxMS40OTk1IDQuODM1OTYgMTEuNDk5NSA1LjI1MDE3QzExLjQ5OTUgNS42Mjk4NiAxMS4yMTczIDUuOTQzNjYgMTAuODUxMyA1Ljk5MzMyTDEwLjc0OTUgNi4wMDAxN0g3LjI0OTc0QzYuMDcwNzkgNS45OTk2MSA1LjEwMzQ5IDYuOTA2NTYgNS4wMDc4NiA4LjA2MTEyTDUuMDAwMjggOC4yMjAwM0w1LjAwMzEyIDE2Ljc1MDdDNS4wMDM0MyAxNy45NDE1IDUuOTI4ODUgMTguOTE2MSA3LjA5OTY2IDE4Ljk5NDlMNy4yNTM3MSAxOS4wMDAxTDE1Ljc1MTggMTguOTg4NEMxNi45NDE1IDE4Ljk4NjggMTcuOTE0NSAxOC4wNjIgMTcuOTkzNSAxNi44OTIzTDE3Ljk5ODcgMTYuNzM4NFYxMy4yMzIxQzE3Ljk5ODcgMTIuODE3OSAxOC4zMzQ1IDEyLjQ4MjEgMTguNzQ4NyAxMi40ODIxQzE5LjEyODQgMTIuNDgyMSAxOS40NDIyIDEyLjc2NDMgMTkuNDkxOCAxMy4xMzAzTDE5LjQ5ODcgMTMuMjMyMVYxNi43Mzg0QzE5LjQ5ODcgMTguNzQwNyAxNy45MjkzIDIwLjM3NjkgMTUuOTUyOCAyMC40ODI5TDE1Ljc1MzggMjAuNDg4NEw3LjI1ODI3IDIwLjUwMDFMNy4wNTQ5NSAyMC40OTQ5QzUuMTQyMzkgMjAuMzk1NCAzLjYwODk1IDE4Ljg2MjcgMy41MDgzNyAxNi45NTAyTDMuNTAzMTIgMTYuNzUxMUwzLjUwMDg5IDguMjUyN0wzLjUwNTI5IDguMDUwMkMzLjYwNTM5IDYuMTM3NDkgNS4xMzg2NyA0LjYwNDQ5IDcuMDUwOTYgNC41MDUyN0w3LjI1MDEgNC41MDAxN0gxMC43NDk1SDcuMjUwMVpNMTMuNzQ4MSAzLjAwMTQ2TDIwLjMwMTggMy4wMDE5N0wyMC40MDE0IDMuMDE1NzVMMjAuNTAyMiAzLjA0MzkzTDIwLjU1OSAzLjA2ODAzQzIwLjYxMjIgMy4wOTEyMiAyMC42NjM0IDMuMTIxNjMgMjAuNzExMSAzLjE1ODg1TDIwLjc4MDQgMy4yMjE1NkwyMC44NjQxIDMuMzIwMTRMMjAuOTE4MyAzLjQxMDI1TDIwLjk1NyAzLjUwMDU3TDIwLjk3NjIgMy41NjQ3NkwyMC45ODk4IDMuNjI4NjJMMjAuOTk5MiAzLjcyMjgyTDIwLjk5OTcgMTAuMjU1NEMyMC45OTk3IDEwLjY2OTYgMjAuNjYzOSAxMS4wMDU0IDIwLjI0OTcgMTEuMDA1NEMxOS44NyAxMS4wMDU0IDE5LjU1NjIgMTAuNzIzMiAxOS41MDY1IDEwLjM1NzFMMTkuNDk5NyAxMC4yNTU0TDE5LjQ5ODkgNS41NjE0N0wxMi4yNzk3IDEyLjc4NDdDMTIuMDEzNCAxMy4wNTEgMTEuNTk2OCAxMy4wNzUzIDExLjMwMzEgMTIuODU3NUwxMS4yMTkgMTIuNzg0OUMxMC45NTI3IDEyLjUxODcgMTAuOTI4NCAxMi4xMDIxIDExLjE0NjIgMTEuODA4NEwxMS4yMTg4IDExLjcyNDNMMTguNDM2OSA0LjUwMTQ2SDEzLjc0ODFDMTMuMzY4NCA0LjUwMTQ2IDEzLjA1NDYgNC4yMTkzMSAxMy4wMDUgMy44NTMyNEwxMi45OTgxIDMuNzUxNDZDMTIuOTk4MSAzLjM3MTc3IDEzLjI4MDMgMy4wNTc5NyAxMy42NDY0IDMuMDA4MzFMMTMuNzQ4MSAzLjAwMTQ2WiIgZmlsbD0iI0ZGRkZGRiIgLz48L3N2Zz4) !important;
|
|
64
157
|
height: '.75em';
|
|
65
|
-
marginLeft: '.25em';
|
|
158
|
+
marginLeft: '.25em';
|
|
159
|
+
filter:${(props === null || props === void 0 ? void 0 : (_props$renderingMiddl = props.renderingMiddlewareProps) === null || _props$renderingMiddl === void 0 ? void 0 : (_props$renderingMiddl2 = _props$renderingMiddl.receivedMessageAnchorStyles) === null || _props$renderingMiddl2 === void 0 ? void 0 : _props$renderingMiddl2.filter) ?? "none"};
|
|
66
160
|
}
|
|
67
161
|
pre {
|
|
68
162
|
white-space: pre-wrap;
|
|
@@ -75,7 +169,7 @@ const WebChatContainerStateful = props => {
|
|
|
75
169
|
.ms_lcw_webchat_received_message a:visited,
|
|
76
170
|
.ms_lcw_webchat_received_message a:hover,
|
|
77
171
|
.ms_lcw_webchat_received_message a:active {
|
|
78
|
-
color:
|
|
172
|
+
color: ${(props === null || props === void 0 ? void 0 : (_props$renderingMiddl3 = props.renderingMiddlewareProps) === null || _props$renderingMiddl3 === void 0 ? void 0 : (_props$renderingMiddl4 = _props$renderingMiddl3.receivedMessageAnchorStyles) === null || _props$renderingMiddl4 === void 0 ? void 0 : _props$renderingMiddl4.color) ?? (_defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles === null || _defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles === void 0 ? void 0 : _defaultReceivedMessageAnchorStyles.defaultReceivedMessageAnchorStyles.color)};
|
|
79
173
|
} `), /*#__PURE__*/_react2.default.createElement(_react.Stack, {
|
|
80
174
|
styles: containerStyles
|
|
81
175
|
}, /*#__PURE__*/_react2.default.createElement(BasicWebChat, null)));
|
|
@@ -13,6 +13,8 @@ var _defaultWebChatStatefulProps = require("./defaultWebChatStatefulProps");
|
|
|
13
13
|
|
|
14
14
|
var _defaultWebChatContainerStatefulStyles = require("../defaultStyles/defaultWebChatContainerStatefulStyles");
|
|
15
15
|
|
|
16
|
+
var _defaultAdaptiveCardStyles = require("../defaultStyles/defaultAdaptiveCardStyles");
|
|
17
|
+
|
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
19
|
|
|
18
20
|
const defaultWebChatContainerStatefulProps = {
|
|
@@ -21,6 +23,7 @@ const defaultWebChatContainerStatefulProps = {
|
|
|
21
23
|
containerStyles: _defaultWebChatStatefulContainerStyles.defaultWebChatStatefulContainerStyles,
|
|
22
24
|
disableNewLineMarkdownSupport: false,
|
|
23
25
|
disableMarkdownMessageFormatting: false,
|
|
24
|
-
directLine: new _mockadapter.default()
|
|
26
|
+
directLine: new _mockadapter.default(),
|
|
27
|
+
adaptiveCardStyles: _defaultAdaptiveCardStyles.defaultAdaptiveCardStyles
|
|
25
28
|
};
|
|
26
29
|
exports.defaultWebChatContainerStatefulProps = defaultWebChatContainerStatefulProps;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultAdaptiveCardStyles = void 0;
|
|
7
|
+
const defaultAdaptiveCardStyles = {
|
|
8
|
+
background: "white",
|
|
9
|
+
color: "black"
|
|
10
|
+
};
|
|
11
|
+
exports.defaultAdaptiveCardStyles = defaultAdaptiveCardStyles;
|
|
@@ -14,6 +14,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
14
14
|
class MockChatSDK {
|
|
15
15
|
constructor() {
|
|
16
16
|
_defineProperty(this, "sleep", ms => new Promise(r => setTimeout(r, ms)));
|
|
17
|
+
|
|
18
|
+
_defineProperty(this, "isMockModeOn", true);
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
async startChat() {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BotMagicCodeStore = void 0;
|
|
7
|
+
|
|
8
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
|
|
10
|
+
class BotMagicCodeStore {}
|
|
11
|
+
|
|
12
|
+
exports.BotMagicCodeStore = BotMagicCodeStore;
|
|
13
|
+
|
|
14
|
+
_defineProperty(BotMagicCodeStore, "botOAuthSignInId", "");
|
|
@@ -75,6 +75,16 @@ const handleSystemMessage = (next, args, card, systemMessageStyleProps) => {
|
|
|
75
75
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
76
|
|
|
77
77
|
|
|
78
|
+
const isTagIncluded = (card, tag) => {
|
|
79
|
+
return isDataTagsPresent(card) && card.activity.channelData.tags.includes(tag);
|
|
80
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
const isDataTagsPresent = card => {
|
|
84
|
+
return card && card.activity && card.activity.channelData && card.activity.channelData.tags && card.activity.channelData.tags.length > 0;
|
|
85
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
+
|
|
87
|
+
|
|
78
88
|
const createActivityMiddleware = (systemMessageStyleProps, userMessageStyleProps) => () => next => function () {
|
|
79
89
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
80
90
|
args[_key] = arguments[_key];
|
|
@@ -83,7 +93,7 @@ const createActivityMiddleware = (systemMessageStyleProps, userMessageStyleProps
|
|
|
83
93
|
const [card] = args;
|
|
84
94
|
|
|
85
95
|
if (card.activity) {
|
|
86
|
-
var _card$activity$from
|
|
96
|
+
var _card$activity$from;
|
|
87
97
|
|
|
88
98
|
if (((_card$activity$from = card.activity.from) === null || _card$activity$from === void 0 ? void 0 : _card$activity$from.role) === _DirectLineSenderRole.DirectLineSenderRole.Channel) {
|
|
89
99
|
var _card$activity$channe3;
|
|
@@ -98,7 +108,11 @@ const createActivityMiddleware = (systemMessageStyleProps, userMessageStyleProps
|
|
|
98
108
|
return () => false;
|
|
99
109
|
}
|
|
100
110
|
|
|
101
|
-
if ((
|
|
111
|
+
if (isTagIncluded(card, _Constants.Constants.hiddenTag)) {
|
|
112
|
+
return () => false;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (isTagIncluded(card, _Constants.Constants.systemMessageTag)) {
|
|
102
116
|
return handleSystemMessage(next, args, card, systemMessageStyleProps);
|
|
103
117
|
} else if (card.activity.text && card.activity.type === _DirectLineActivityType.DirectLineActivityType.Message) {
|
|
104
118
|
if (!card.activity.channelData.isHtmlEncoded && card.activity.channelId === _Constants.Constants.webchatChannelId) {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createCardActionMiddleware = void 0;
|
|
7
|
+
|
|
8
|
+
var _BotMagicCodeStore = require("../../BotMagicCodeStore");
|
|
9
|
+
|
|
10
|
+
var CardActionType;
|
|
11
|
+
|
|
12
|
+
(function (CardActionType) {
|
|
13
|
+
CardActionType["OpenUrl"] = "openUrl";
|
|
14
|
+
CardActionType["SignIn"] = "signin";
|
|
15
|
+
})(CardActionType || (CardActionType = {}));
|
|
16
|
+
|
|
17
|
+
const validCardActionTypes = [CardActionType.OpenUrl, CardActionType.SignIn];
|
|
18
|
+
const botOauthUrlRegex = /[\S]+.botframework.com\/api\/oauth\/signin\?signin=([\S]+)/;
|
|
19
|
+
|
|
20
|
+
const createCardActionMiddleware = botMagicCodeConfig => {
|
|
21
|
+
const cardActionMiddleware = () => next => function () {
|
|
22
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
23
|
+
args[_key] = arguments[_key];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
27
|
+
const [card] = args;
|
|
28
|
+
|
|
29
|
+
if (card.cardAction && validCardActionTypes.indexOf(card.cardAction.type) >= 0 && card.cardAction.value) {
|
|
30
|
+
// Override signin url only if fwdUrl is valid & feature is enabled
|
|
31
|
+
if ((botMagicCodeConfig === null || botMagicCodeConfig === void 0 ? void 0 : botMagicCodeConfig.disabled) === true && botMagicCodeConfig !== null && botMagicCodeConfig !== void 0 && botMagicCodeConfig.fwdUrl) {
|
|
32
|
+
const baseUrl = window.location.origin;
|
|
33
|
+
const result = botOauthUrlRegex.exec(card.cardAction.value);
|
|
34
|
+
|
|
35
|
+
if (result) {
|
|
36
|
+
_BotMagicCodeStore.BotMagicCodeStore.botOAuthSignInId = `${result[1]}`;
|
|
37
|
+
} // fwdUrl must be on the same domain as the chat widget
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
if (botMagicCodeConfig !== null && botMagicCodeConfig !== void 0 && botMagicCodeConfig.fwdUrl.startsWith(baseUrl)) {
|
|
41
|
+
card.cardAction.value += `&fwdUrl=${botMagicCodeConfig.fwdUrl}`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return next(...args);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return cardActionMiddleware;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
exports.createCardActionMiddleware = createCardActionMiddleware;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("@testing-library/jest-dom/extend-expect");
|
|
4
|
+
|
|
5
|
+
var _cardActionMiddleware = require("./cardActionMiddleware");
|
|
6
|
+
|
|
7
|
+
describe("cardActionMiddleware test", () => {
|
|
8
|
+
it("createCardActionMiddleware() with undefined botMagicCodeConfig should not change the sign in card url", () => {
|
|
9
|
+
const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
|
|
13
|
+
const args = {
|
|
14
|
+
cardAction: {
|
|
15
|
+
type: "signin",
|
|
16
|
+
value: signInUrl
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const results = (0, _cardActionMiddleware.createCardActionMiddleware)(undefined)()(next)(args);
|
|
20
|
+
expect(signInUrl).toEqual(results.cardAction.value);
|
|
21
|
+
});
|
|
22
|
+
it("createCardActionMiddleware() with botMagicCode enabled should not change the sign in card url", () => {
|
|
23
|
+
const botMagicCodeConfig = {
|
|
24
|
+
disabled: false
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
|
|
31
|
+
const args = {
|
|
32
|
+
cardAction: {
|
|
33
|
+
type: "signin",
|
|
34
|
+
value: signInUrl
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const results = (0, _cardActionMiddleware.createCardActionMiddleware)(botMagicCodeConfig)()(next)(args);
|
|
38
|
+
expect(args.cardAction.value).toEqual(results.cardAction.value);
|
|
39
|
+
});
|
|
40
|
+
it("createCardActionMiddleware() with botMagicCode disabled & no fwdUrl should not change the sign in card url", () => {
|
|
41
|
+
const botMagicCodeConfig = {
|
|
42
|
+
disabled: true
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
|
|
49
|
+
const args = {
|
|
50
|
+
cardAction: {
|
|
51
|
+
type: "signin",
|
|
52
|
+
value: signInUrl
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const results = (0, _cardActionMiddleware.createCardActionMiddleware)(botMagicCodeConfig)()(next)(args);
|
|
56
|
+
expect(args.cardAction.value).toEqual(results.cardAction.value);
|
|
57
|
+
});
|
|
58
|
+
it("createCardActionMiddleware() with botMagicCode disabled & fwdUrl should append the fwdUrl in the sign in card url", () => {
|
|
59
|
+
const botMagicCodeConfig = {
|
|
60
|
+
disabled: true,
|
|
61
|
+
fwdUrl: "http://localhost/forwarder.html"
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
|
|
68
|
+
const args = {
|
|
69
|
+
cardAction: {
|
|
70
|
+
type: "signin",
|
|
71
|
+
value: signInUrl
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const results = (0, _cardActionMiddleware.createCardActionMiddleware)(botMagicCodeConfig)()(next)(args);
|
|
75
|
+
expect(signInUrl === results.cardAction.value).toBe(false);
|
|
76
|
+
expect(results.cardAction.value === `${signInUrl}&fwdUrl=${botMagicCodeConfig.fwdUrl}`).toBe(true);
|
|
77
|
+
});
|
|
78
|
+
it("createCardActionMiddleware() should not append fwdUrl if fwdUrl & sign in card url are not in the same domain", () => {
|
|
79
|
+
const botMagicCodeConfig = {
|
|
80
|
+
disabled: true,
|
|
81
|
+
fwdUrl: "https://localhost/forwarder.html"
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
|
|
88
|
+
const args = {
|
|
89
|
+
cardAction: {
|
|
90
|
+
type: "signin",
|
|
91
|
+
value: signInUrl
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
const results = (0, _cardActionMiddleware.createCardActionMiddleware)(botMagicCodeConfig)()(next)(args);
|
|
95
|
+
expect(signInUrl === results.cardAction.value).toBe(true);
|
|
96
|
+
expect(results.cardAction.value === `${signInUrl}&fwdUrl=${botMagicCodeConfig.fwdUrl}`).toBe(false);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defaultReceivedMessageAnchorStyles = void 0;
|
|
7
|
+
const defaultReceivedMessageAnchorStyles = {
|
|
8
|
+
color: "white"
|
|
9
|
+
};
|
|
10
|
+
exports.defaultReceivedMessageAnchorStyles = defaultReceivedMessageAnchorStyles;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _WebChatActionType = require("../../enums/WebChatActionType");
|
|
9
|
+
|
|
10
|
+
var _Constants = require("../../../../../common/Constants");
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
13
|
+
const createMessageTimeStampMiddleware = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
dispatch
|
|
16
|
+
} = _ref;
|
|
17
|
+
return next => action => {
|
|
18
|
+
if (isApplicable(action)) {
|
|
19
|
+
return next(evaluateTagsAndOverrideTimeStamp(action));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return next(action);
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const isApplicable = action => {
|
|
27
|
+
return action.type === _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && isPVAConversation(action) && isPayloadValid(action) && isValidChannel(action);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const isPayloadValid = action => {
|
|
31
|
+
var _action$payload;
|
|
32
|
+
|
|
33
|
+
return action === null || action === void 0 ? void 0 : (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : _action$payload.activity;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const isValidChannel = action => {
|
|
37
|
+
var _action$payload2, _action$payload2$acti;
|
|
38
|
+
|
|
39
|
+
return (action === null || action === void 0 ? void 0 : (_action$payload2 = action.payload) === null || _action$payload2 === void 0 ? void 0 : (_action$payload2$acti = _action$payload2.activity) === null || _action$payload2$acti === void 0 ? void 0 : _action$payload2$acti.channelId) === _Constants.Constants.acsChannel;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const isPVAConversation = action => {
|
|
43
|
+
return !isTagIncluded(action, _Constants.Constants.systemMessageTag) && !isTagIncluded(action, _Constants.Constants.publicMessageTag) && !isRoleUserOn(action);
|
|
44
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
const isTagIncluded = (action, tag) => {
|
|
48
|
+
return isDataTagsPresent(action) && action.payload.activity.channelData.tags.includes(tag);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const isRoleUserOn = action => {
|
|
52
|
+
var _action$payload3, _action$payload3$acti, _action$payload3$acti2;
|
|
53
|
+
|
|
54
|
+
return (action === null || action === void 0 ? void 0 : (_action$payload3 = action.payload) === null || _action$payload3 === void 0 ? void 0 : (_action$payload3$acti = _action$payload3.activity) === null || _action$payload3$acti === void 0 ? void 0 : (_action$payload3$acti2 = _action$payload3$acti.from) === null || _action$payload3$acti2 === void 0 ? void 0 : _action$payload3$acti2.role) === _Constants.Constants.userMessageTag;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const overrideTimeStamp = (timestampOriginal, timeStampNew) => {
|
|
58
|
+
return isTimestampValid(timeStampNew) ? timeStampNew : timestampOriginal;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const isTimestampValid = timeStamp => {
|
|
62
|
+
const regex = /(\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])(T)(\d{2})(:{1})(\d{2})(:{1})(\d{2})(.\d+)([Z]{1}))/;
|
|
63
|
+
return regex.test(timeStamp);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const isDataTagsPresent = action => {
|
|
67
|
+
var _action$payload4, _action$payload4$acti, _action$payload4$acti2;
|
|
68
|
+
|
|
69
|
+
return (action === null || action === void 0 ? void 0 : (_action$payload4 = action.payload) === null || _action$payload4 === void 0 ? void 0 : (_action$payload4$acti = _action$payload4.activity) === null || _action$payload4$acti === void 0 ? void 0 : (_action$payload4$acti2 = _action$payload4$acti.channelData) === null || _action$payload4$acti2 === void 0 ? void 0 : _action$payload4$acti2.tags) && action.payload.activity.channelData.tags.length > 0;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const evaluateTagsAndOverrideTimeStamp = action => {
|
|
73
|
+
const tagValue = tagLookup(action, _Constants.Constants.prefixTimestampTag);
|
|
74
|
+
|
|
75
|
+
if (tagValue) {
|
|
76
|
+
const newTimestamp = extractTimeStamp(tagValue);
|
|
77
|
+
action.payload.activity.timestamp = overrideTimeStamp(action.payload.activity.timestamp, newTimestamp);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return action;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const extractTimeStamp = timeStamp => {
|
|
84
|
+
if (timeStamp && timeStamp.length > 0) {
|
|
85
|
+
const ts = timeStamp.split(_Constants.Constants.prefixTimestampTag);
|
|
86
|
+
|
|
87
|
+
if (ts && ts.length > 1) {
|
|
88
|
+
return ts[1];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return timeStamp;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const tagLookup = (action, tag) => {
|
|
96
|
+
if (!isDataTagsPresent(action)) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const tags = action.payload.activity.channelData.tags;
|
|
101
|
+
let value;
|
|
102
|
+
|
|
103
|
+
if (tags && tags.length > 0) {
|
|
104
|
+
for (let i = 0; i < tags.length; i++) {
|
|
105
|
+
value = tags[i];
|
|
106
|
+
|
|
107
|
+
if (value && value.indexOf(tag) > -1) {
|
|
108
|
+
return value;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return null;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
var _default = createMessageTimeStampMiddleware;
|
|
117
|
+
exports.default = _default;
|
|
@@ -10,6 +10,7 @@ var _TelemetryConstants = require("../../../../common/telemetry/TelemetryConstan
|
|
|
10
10
|
var _TelemetryHelper = require("../../../../common/telemetry/TelemetryHelper");
|
|
11
11
|
|
|
12
12
|
function createWebChatTelemetry() {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
14
|
const handleTelemetry = event => {
|
|
14
15
|
const {
|
|
15
16
|
level
|
|
@@ -15,6 +15,7 @@ exports.ConversationState = ConversationState;
|
|
|
15
15
|
ConversationState[ConversationState["ProactiveChat"] = 4] = "ProactiveChat";
|
|
16
16
|
ConversationState[ConversationState["Active"] = 5] = "Active";
|
|
17
17
|
ConversationState[ConversationState["InActive"] = 6] = "InActive";
|
|
18
|
-
ConversationState[ConversationState["
|
|
19
|
-
ConversationState[ConversationState["
|
|
18
|
+
ConversationState[ConversationState["PostchatLoading"] = 7] = "PostchatLoading";
|
|
19
|
+
ConversationState[ConversationState["Postchat"] = 8] = "Postchat";
|
|
20
|
+
ConversationState[ConversationState["Closed"] = 9] = "Closed";
|
|
20
21
|
})(ConversationState || (exports.ConversationState = ConversationState = {}));
|
|
@@ -39,4 +39,7 @@ exports.LiveChatWidgetActionType = LiveChatWidgetActionType;
|
|
|
39
39
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY_AGENT"] = 28] = "SET_CONVERSATION_ENDED_BY_AGENT";
|
|
40
40
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_STATE"] = 29] = "SET_WIDGET_STATE";
|
|
41
41
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONTEXT"] = 30] = "SET_LIVE_CHAT_CONTEXT";
|
|
42
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_BOT_OAUTH_SIGNIN_ID"] = 31] = "SET_BOT_OAUTH_SIGNIN_ID";
|
|
43
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_SIZE"] = 32] = "SET_WIDGET_SIZE";
|
|
44
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_INSTANCE_ID"] = 33] = "SET_WIDGET_INSTANCE_ID";
|
|
42
45
|
})(LiveChatWidgetActionType || (exports.LiveChatWidgetActionType = LiveChatWidgetActionType = {}));
|
|
@@ -9,11 +9,18 @@ var _ConversationState = require("./ConversationState");
|
|
|
9
9
|
|
|
10
10
|
var _defaultMiddlewareLocalizedTexts = require("../../components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
11
11
|
|
|
12
|
+
var _utils = require("../../common/utils");
|
|
13
|
+
|
|
14
|
+
var _defaultClientDataStoreProvider = require("../../common/storage/default/defaultClientDataStoreProvider");
|
|
15
|
+
|
|
12
16
|
const getLiveChatWidgetContextInitialState = props => {
|
|
13
|
-
var _props$webChatContain;
|
|
17
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$controlProps, _props$webChatContain;
|
|
18
|
+
|
|
19
|
+
const widgetCacheId = (0, _utils.getWidgetCacheId)(props === null || props === void 0 ? void 0 : (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId, props === null || props === void 0 ? void 0 : (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.widgetInstanceId) ?? "");
|
|
20
|
+
const initialState = (0, _defaultClientDataStoreProvider.defaultClientDataStoreProvider)().getData(widgetCacheId, "localStorage");
|
|
14
21
|
|
|
15
|
-
if (
|
|
16
|
-
return
|
|
22
|
+
if (!(0, _utils.isNullOrUndefined)(initialState)) {
|
|
23
|
+
return JSON.parse(initialState);
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
const LiveChatWidgetContextInitialState = {
|
|
@@ -28,14 +35,15 @@ const getLiveChatWidgetContextInitialState = props => {
|
|
|
28
35
|
telemetryInternalData: {},
|
|
29
36
|
globalDir: "ltr",
|
|
30
37
|
liveChatContext: undefined,
|
|
31
|
-
customContext: undefined
|
|
38
|
+
customContext: undefined,
|
|
39
|
+
widgetSize: undefined,
|
|
40
|
+
widgetInstanceId: ""
|
|
32
41
|
},
|
|
33
42
|
appStates: {
|
|
34
43
|
conversationState: _ConversationState.ConversationState.Closed,
|
|
35
44
|
isMinimized: false,
|
|
36
45
|
previousElementOnFocusBeforeModalOpen: null,
|
|
37
46
|
outsideOperatingHours: false,
|
|
38
|
-
shouldShowPostChat: false,
|
|
39
47
|
preChatResponseEmail: "",
|
|
40
48
|
isAudioMuted: null,
|
|
41
49
|
newMessage: false,
|