@microsoft/omnichannel-chat-widget 0.1.0-main.b59a07c → 0.1.0-main.c2417f9
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 +12 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +9 -4
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +5 -1
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +10 -1
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +4 -0
- package/lib/cjs/components/livechatwidget/common/endChat.js +3 -3
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +8 -3
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +99 -44
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +80 -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/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/messageTimestampMiddleware.js +117 -0
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +2 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
- package/lib/cjs/contexts/createReducer.js +8 -0
- package/lib/esm/common/Constants.js +12 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +9 -4
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +7 -4
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +8 -2
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +4 -0
- package/lib/esm/components/livechatwidget/common/endChat.js +3 -2
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +7 -4
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +92 -41
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +72 -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/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/messageTimestampMiddleware.js +107 -0
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +2 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
- package/lib/esm/contexts/createReducer.js +8 -0
- package/lib/types/common/Constants.d.ts +6 -0
- package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +10 -5
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
- 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/messageTimestampMiddleware.d.ts +5 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
1. [Installation](#installation)
|
|
12
12
|
1. [Example Usage](#example-usage)
|
|
13
13
|
1. [Components](#components)
|
|
14
|
+
1. [Common Scenarios](#common-scenarios)
|
|
15
|
+
- [Disable Bot Magic Code](#disable-bot-magic-code)
|
|
14
16
|
1. [See Also](#see-also)
|
|
15
17
|
|
|
16
18
|
## Introduction
|
|
@@ -218,6 +220,36 @@ const customizedFooterProp: IFooterProps = {
|
|
|
218
220
|
|
|
219
221
|
> :pushpin: Note that [WebChat hooks](https://github.com/microsoft/BotFramework-WebChat/blob/main/docs/HOOKS.md) can also be used in any custom components.
|
|
220
222
|
|
|
223
|
+
## Common Scenarios
|
|
224
|
+
|
|
225
|
+
### Disable Bot Magic Code
|
|
226
|
+
|
|
227
|
+
Configuration to disable the default behaviour of having to type the magic code in the conversation to complete the sign-in proccess with a bot. Instead, the magic code will be sent to the bot behind the scenes.
|
|
228
|
+
|
|
229
|
+
1. Add [MagicCodeForwarder.html](sample/MagicCodeForwarder.html) in the same location as the chat widget
|
|
230
|
+
|
|
231
|
+
2. Add `botMagicCode` configuration to disable default magic code feature
|
|
232
|
+
|
|
233
|
+
> :exclamation: `fwdUrl` **MUST** have the same `origin` as the chat widget URL
|
|
234
|
+
|
|
235
|
+
```js
|
|
236
|
+
const liveChatWidgetProps = {
|
|
237
|
+
chatSDK: chatSDK, // mandatory
|
|
238
|
+
chatConfig: chatConfig, // mandatory
|
|
239
|
+
webChatContainerProps: {
|
|
240
|
+
botMagicCode: {
|
|
241
|
+
disabled: true,
|
|
242
|
+
fwdUrl: 'http://localhost:8000/sample/MagicCodeForwarder.html'
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
ReactDOM.render(
|
|
248
|
+
<LiveChatWidget {...liveChatWidgetProps}/>,
|
|
249
|
+
document.getElementById("my-container")
|
|
250
|
+
);
|
|
251
|
+
```
|
|
252
|
+
|
|
221
253
|
## See Also
|
|
222
254
|
|
|
223
255
|
[Telemetry](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/Telemetry.md)\
|
|
@@ -13,6 +13,10 @@ class Constants {}
|
|
|
13
13
|
|
|
14
14
|
exports.Constants = Constants;
|
|
15
15
|
|
|
16
|
+
_defineProperty(Constants, "magicCodeBroadcastChannel", "MagicCodeChannel");
|
|
17
|
+
|
|
18
|
+
_defineProperty(Constants, "magicCodeResponseBroadcastChannel", "MagicCodeResponseChannel");
|
|
19
|
+
|
|
16
20
|
_defineProperty(Constants, "systemMessageTag", "system");
|
|
17
21
|
|
|
18
22
|
_defineProperty(Constants, "userMessageTag", "user");
|
|
@@ -79,6 +83,14 @@ _defineProperty(Constants, "averageWaitTimeMessageTag", "averagewaittime");
|
|
|
79
83
|
|
|
80
84
|
_defineProperty(Constants, "message", "message");
|
|
81
85
|
|
|
86
|
+
_defineProperty(Constants, "hiddenTag", "Hidden");
|
|
87
|
+
|
|
88
|
+
_defineProperty(Constants, "prefixTimestampTag", "ServerMessageTimestamp_");
|
|
89
|
+
|
|
90
|
+
_defineProperty(Constants, "acsChannel", "ACS_CHANNEL");
|
|
91
|
+
|
|
92
|
+
_defineProperty(Constants, "publicMessageTag", "public");
|
|
93
|
+
|
|
82
94
|
_defineProperty(Constants, "supportedAdaptiveCardContentTypes", ["application/vnd.microsoft.card.adaptive", "application/vnd.microsoft.card.audio", "application/vnd.microsoft.card.hero", "application/vnd.microsoft.card.receipt", "application/vnd.microsoft.card.thumbnail", "application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"]);
|
|
83
95
|
|
|
84
96
|
_defineProperty(Constants, "maxUploadFileSize", "500000");
|
|
@@ -44,7 +44,7 @@ exports.BroadcastEvent = BroadcastEvent;
|
|
|
44
44
|
BroadcastEvent["ProactiveChatStartChat"] = "ProactiveChatStartChat";
|
|
45
45
|
BroadcastEvent["ProactiveChatStartPopoutChat"] = "ProactiveChatStartPopoutChat";
|
|
46
46
|
BroadcastEvent["ProactiveChatIsInPopoutMode"] = "ProactiveChatIsInPopoutMode";
|
|
47
|
-
BroadcastEvent["
|
|
47
|
+
BroadcastEvent["ResetProactiveChatParams"] = "ResetProactiveChatParams";
|
|
48
48
|
BroadcastEvent["InvalidAdaptiveCardFormat"] = "InvalidAdaptiveCardFormat";
|
|
49
49
|
BroadcastEvent["NewMessageSent"] = "NewMessageSent";
|
|
50
50
|
BroadcastEvent["NewMessageReceived"] = "NewMessageReceived";
|
|
@@ -52,9 +52,12 @@ exports.BroadcastEvent = BroadcastEvent;
|
|
|
52
52
|
BroadcastEvent["StartChat"] = "StartChat";
|
|
53
53
|
BroadcastEvent["StartChatSkippingChatButtonRendering"] = "StartChatSkippingChatButtonRendering";
|
|
54
54
|
BroadcastEvent["StartUnauthenticatedReconnectChat"] = "StartUnauthenticatedReconnectChat";
|
|
55
|
-
BroadcastEvent["
|
|
55
|
+
BroadcastEvent["InitiateEndChat"] = "InitiateEndChat";
|
|
56
56
|
BroadcastEvent["SetCustomContext"] = "SetCustomContext";
|
|
57
57
|
BroadcastEvent["ChatRetrievedFromCache"] = "ChatRetrievedFromCache";
|
|
58
|
+
BroadcastEvent["MaximizeChat"] = "MaximizeChat";
|
|
59
|
+
BroadcastEvent["ChatInitiated"] = "ChatInitiated";
|
|
60
|
+
BroadcastEvent["CloseChat"] = "CloseChat";
|
|
58
61
|
})(BroadcastEvent || (exports.BroadcastEvent = BroadcastEvent = {}));
|
|
59
62
|
|
|
60
63
|
let TelemetryEvent;
|
|
@@ -107,9 +110,9 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
107
110
|
TelemetryEvent["PrechatSubmitted"] = "PrechatSubmitted";
|
|
108
111
|
TelemetryEvent["StartChatSDKCall"] = "StartChatCall";
|
|
109
112
|
TelemetryEvent["StartChatEventRecevied"] = "StartChatEventReceived";
|
|
110
|
-
TelemetryEvent["EndChatSDKCall"] = "
|
|
113
|
+
TelemetryEvent["EndChatSDKCall"] = "EndChatSDKCall";
|
|
111
114
|
TelemetryEvent["EndChatEventReceived"] = "EndChatEventReceived";
|
|
112
|
-
TelemetryEvent["
|
|
115
|
+
TelemetryEvent["WindowClosed"] = "WindowClosed";
|
|
113
116
|
TelemetryEvent["OnNewMessageFailed"] = "OnNewMessageFailed";
|
|
114
117
|
TelemetryEvent["OnNewMessageAudioNotificationFailed"] = "OnNewMessageAudioNotificationFailed";
|
|
115
118
|
TelemetryEvent["DownloadTranscriptResponseNullOrUndefined"] = "DownloadTranscriptResponseNullOrUndefined";
|
|
@@ -134,6 +137,8 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
134
137
|
TelemetryEvent["EmailTranscriptButtonClicked"] = "EmailTranscriptButtonClicked";
|
|
135
138
|
TelemetryEvent["EmailTranscriptCancelButtonClicked"] = "EmailTranscriptCancelButtonClicked";
|
|
136
139
|
TelemetryEvent["AudioToggleButtonClicked"] = "AudioToggleButtonClicked";
|
|
140
|
+
TelemetryEvent["SuppressBotMagicCodeSucceeded"] = "SuppressBotMagicCodeSucceeded";
|
|
141
|
+
TelemetryEvent["SuppressBotMagicCodeFailed"] = "SuppressBotMagicCodeFailed";
|
|
137
142
|
TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
|
|
138
143
|
TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
|
|
139
144
|
TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
|
|
@@ -44,6 +44,7 @@ const ChatButtonStateful = props => {
|
|
|
44
44
|
} = props; //Setting OutOfOperatingHours Flag
|
|
45
45
|
|
|
46
46
|
const [outOfOperatingHours, setOutOfOperatingHours] = (0, _react.useState)(((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.OutOfOperatingHours) === "True");
|
|
47
|
+
const proactiveChatInNewWindow = (0, _react.useRef)(state.appStates.proactiveChatStates.proactiveChatInNewWindow);
|
|
47
48
|
const outOfOfficeStyleProps = Object.assign({}, _defaultOutOfOfficeChatButtonStyleProps.defaultOutOfOfficeChatButtonStyleProps, outOfOfficeButtonProps === null || outOfOfficeButtonProps === void 0 ? void 0 : outOfOfficeButtonProps.styleProps);
|
|
48
49
|
const controlProps = {
|
|
49
50
|
id: "oc-lcw-chat-button",
|
|
@@ -57,7 +58,7 @@ const ChatButtonStateful = props => {
|
|
|
57
58
|
Event: _TelemetryConstants.TelemetryEvent.LCWChatButtonClicked
|
|
58
59
|
});
|
|
59
60
|
|
|
60
|
-
if (
|
|
61
|
+
if (proactiveChatInNewWindow.current) {
|
|
61
62
|
const proactiveChatIsInPopoutModeEvent = {
|
|
62
63
|
eventName: _TelemetryConstants.BroadcastEvent.ProactiveChatIsInPopoutMode
|
|
63
64
|
};
|
|
@@ -115,6 +116,9 @@ const ChatButtonStateful = props => {
|
|
|
115
116
|
});
|
|
116
117
|
}
|
|
117
118
|
}, []);
|
|
119
|
+
(0, _react.useEffect)(() => {
|
|
120
|
+
proactiveChatInNewWindow.current = state.appStates.proactiveChatStates.proactiveChatInNewWindow;
|
|
121
|
+
}, [state.appStates.proactiveChatStates.proactiveChatInNewWindow]);
|
|
118
122
|
return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.ChatButton, {
|
|
119
123
|
componentOverrides: buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.componentOverrides,
|
|
120
124
|
controlProps: outOfOperatingHours ? outOfOfficeControlProps : controlProps,
|
package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js
CHANGED
|
@@ -116,8 +116,17 @@ const beautifyChatTranscripts = (chatTranscripts, renderMarkDown, attachmentMess
|
|
|
116
116
|
let fileAttachmentName = _Constants.TranscriptConstants.DefaultFileAttachmentName;
|
|
117
117
|
let dialogColor = _Constants.TranscriptConstants.CustomerDialogColor;
|
|
118
118
|
let fontColor = _Constants.TranscriptConstants.CustomerFontColor;
|
|
119
|
+
const isSystemMessage = value.tags && value.tags.toLowerCase().indexOf(_Constants.Constants.systemMessageTag) !== -1;
|
|
120
|
+
const isControlMessage = value.isControlMessage && value.isControlMessage === true;
|
|
119
121
|
|
|
120
|
-
|
|
122
|
+
const isAdaptiveCard = value.contentType && value.contentType.toLowerCase() === _Constants.TranscriptConstants.AdaptiveCardType;
|
|
123
|
+
|
|
124
|
+
const isInternalMessage = value.deliveryMode && value.deliveryMode.toLowerCase() === _Constants.TranscriptConstants.InternalMode;
|
|
125
|
+
|
|
126
|
+
const isHiddenMessage = value.tags && value.tags.toLowerCase().indexOf(_Constants.Constants.hiddenTag.toLowerCase()) !== -1;
|
|
127
|
+
const shouldIgnoreMessage = isSystemMessage || isControlMessage || isAdaptiveCard || isInternalMessage || isHiddenMessage;
|
|
128
|
+
|
|
129
|
+
if (shouldIgnoreMessage) {
|
|
121
130
|
return;
|
|
122
131
|
} else if (value.from) {
|
|
123
132
|
if (value.from.application) {
|
|
@@ -1699,6 +1699,10 @@ const dummyDefaultProps = {
|
|
|
1699
1699
|
MIDDLEWARE_MESSAGE_RETRY: "Retry",
|
|
1700
1700
|
PRECHAT_REQUIRED_FIELD_MISSING_MESSAGE: "{0} field is required",
|
|
1701
1701
|
MARKDOWN_EXTERNAL_LINK_ALT: "Opens in a new window; external."
|
|
1702
|
+
},
|
|
1703
|
+
botMagicCode: {
|
|
1704
|
+
disabled: false,
|
|
1705
|
+
fwdUrl: ""
|
|
1702
1706
|
}
|
|
1703
1707
|
},
|
|
1704
1708
|
telemetryConfig: undefined
|
|
@@ -113,9 +113,9 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
113
113
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
|
|
114
114
|
payload: null
|
|
115
115
|
});
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
dispatch({
|
|
117
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
|
|
118
|
+
payload: 0
|
|
119
119
|
});
|
|
120
120
|
|
|
121
121
|
if (postMessageToOtherTab) {
|
|
@@ -63,11 +63,15 @@ var _preProcessingMiddleware = _interopRequireDefault(require("../../webchatcont
|
|
|
63
63
|
|
|
64
64
|
var _sanitizationMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"));
|
|
65
65
|
|
|
66
|
+
var _cardActionMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware");
|
|
67
|
+
|
|
68
|
+
var _messageTimestampMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware"));
|
|
69
|
+
|
|
66
70
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
67
71
|
|
|
68
72
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
73
|
const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
|
|
70
|
-
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21;
|
|
74
|
+
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21, _props$webChatContain22;
|
|
71
75
|
|
|
72
76
|
const localizedTexts = { ..._defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts,
|
|
73
77
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
|
|
@@ -130,7 +134,7 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
|
|
|
130
134
|
};
|
|
131
135
|
|
|
132
136
|
webChatStore = (0, _botframeworkWebchat.createStore)({}, //initial state
|
|
133
|
-
_preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), _channelDataMiddleware.default, (0, _conversationEndMiddleware.default)(conversationEndCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, _htmlTextMiddleware.default, (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
137
|
+
_preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), _channelDataMiddleware.default, (0, _conversationEndMiddleware.default)(conversationEndCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), _messageTimestampMiddleware.default, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, _htmlTextMiddleware.default, (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
134
138
|
...(((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.storeMiddlewares) ?? []));
|
|
135
139
|
_WebChatStoreLoader.WebChatStoreLoader.store = webChatStore;
|
|
136
140
|
} // Initialize the remaining Web Chat props
|
|
@@ -148,7 +152,8 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
|
|
|
148
152
|
groupActivitiesMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai2 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
|
|
149
153
|
typingIndicatorMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
|
|
150
154
|
onTelemetry: (0, _WebChatLogger.createWebChatTelemetry)(),
|
|
151
|
-
|
|
155
|
+
cardActionMiddleware: (0, _cardActionMiddleware.createCardActionMiddleware)(((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.botMagicCode) || undefined),
|
|
156
|
+
...((_props$webChatContain22 = props.webChatContainerProps) === null || _props$webChatContain22 === void 0 ? void 0 : _props$webChatContain22.webChatProps)
|
|
152
157
|
};
|
|
153
158
|
return webChatProps;
|
|
154
159
|
};
|
|
@@ -122,6 +122,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
122
122
|
_TelemetryManager.TelemetryTimers.LcwLoadToChatButtonTimer = (0, _utils.createTimer)();
|
|
123
123
|
const widgetElementId = ((_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.id) || "oc-lcw";
|
|
124
124
|
const currentMessageCountRef = (0, _react2.useRef)(0);
|
|
125
|
+
let widgetStateEventName = "";
|
|
125
126
|
(0, _react2.useEffect)(() => {
|
|
126
127
|
var _props$controlProps2, _props$controlProps3, _props$reconnectChatP, _props$controlProps4, _props$chatConfig, _props$chatConfig$Cha, _state$domainStates;
|
|
127
128
|
|
|
@@ -168,7 +169,8 @@ const LiveChatWidgetStateful = props => {
|
|
|
168
169
|
};
|
|
169
170
|
(0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, optionalParams);
|
|
170
171
|
}
|
|
171
|
-
}, []);
|
|
172
|
+
}, []); // useEffect for when skip chat button rendering
|
|
173
|
+
|
|
172
174
|
(0, _react2.useEffect)(() => {
|
|
173
175
|
if (state.appStates.skipChatButtonRendering) {
|
|
174
176
|
var _props$reconnectChatP3;
|
|
@@ -204,9 +206,10 @@ const LiveChatWidgetStateful = props => {
|
|
|
204
206
|
});
|
|
205
207
|
}
|
|
206
208
|
}
|
|
207
|
-
}, [state.appStates.skipChatButtonRendering]);
|
|
209
|
+
}, [state.appStates.skipChatButtonRendering]); // useEffect for when skip chat button rendering
|
|
210
|
+
|
|
208
211
|
(0, _react2.useEffect)(() => {
|
|
209
|
-
var _chatSDK$
|
|
212
|
+
var _chatSDK$omnichannelC3, _chatSDK$omnichannelC4;
|
|
210
213
|
|
|
211
214
|
// Add the custom context on receiving the SetCustomContext event
|
|
212
215
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
@@ -237,55 +240,84 @@ const LiveChatWidgetStateful = props => {
|
|
|
237
240
|
Description: "Start proactive chat method called, when chat was already triggered."
|
|
238
241
|
});
|
|
239
242
|
}
|
|
240
|
-
}); //
|
|
243
|
+
}); // Start chat from SDK Event
|
|
241
244
|
|
|
242
245
|
|
|
243
246
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(() => {
|
|
247
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _DataStoreManager$cli;
|
|
248
|
+
|
|
244
249
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
245
250
|
Event: _TelemetryConstants.TelemetryEvent.StartChatEventRecevied,
|
|
246
251
|
Description: "Start chat event received."
|
|
247
|
-
});
|
|
252
|
+
}); // Getting updated state from cache
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
const widgetStateEventName = (0, _utils.getWidgetCacheId)((chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId) ?? "", (chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId) ?? "");
|
|
256
|
+
const widgetStateFromCache = (_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateEventName, "localStorage");
|
|
257
|
+
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
258
|
+
|
|
259
|
+
if (persistedState.appStates.conversationState === _ConversationState.ConversationState.Closed || persistedState.appStates.conversationState === _ConversationState.ConversationState.InActive || persistedState.appStates.conversationState === _ConversationState.ConversationState.Postchat) {
|
|
260
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
261
|
+
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
(0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
|
|
265
|
+
} else {
|
|
266
|
+
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4;
|
|
248
267
|
|
|
249
|
-
if (state.appStates.isMinimized) {
|
|
250
268
|
dispatch({
|
|
251
269
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
252
270
|
payload: false
|
|
253
271
|
});
|
|
254
|
-
|
|
255
|
-
|
|
272
|
+
|
|
273
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
274
|
+
eventName: _TelemetryConstants.BroadcastEvent.MaximizeChat,
|
|
275
|
+
payload: {
|
|
276
|
+
height: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : (_persistedState$domai2 = _persistedState$domai.widgetSize) === null || _persistedState$domai2 === void 0 ? void 0 : _persistedState$domai2.height,
|
|
277
|
+
width: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai3 = persistedState.domainStates) === null || _persistedState$domai3 === void 0 ? void 0 : (_persistedState$domai4 = _persistedState$domai3.widgetSize) === null || _persistedState$domai4 === void 0 ? void 0 : _persistedState$domai4.width
|
|
278
|
+
}
|
|
279
|
+
});
|
|
256
280
|
}
|
|
257
|
-
}); //
|
|
281
|
+
}); // End chat
|
|
282
|
+
|
|
258
283
|
|
|
284
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChat).subscribe(async msg => {
|
|
285
|
+
var _msg$payload4, _msg$payload5;
|
|
286
|
+
|
|
287
|
+
const isChatUnloading = ((_msg$payload4 = msg.payload) === null || _msg$payload4 === void 0 ? void 0 : _msg$payload4.chatUnloading) ?? false;
|
|
288
|
+
const isSdkCall = ((_msg$payload5 = msg.payload) === null || _msg$payload5 === void 0 ? void 0 : _msg$payload5.isSdkCall) ?? false;
|
|
289
|
+
const eventDescription = isChatUnloading ? "End chat event received from unload." : "End chat event received.";
|
|
259
290
|
|
|
260
|
-
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.EndChat).subscribe(async () => {
|
|
261
291
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
262
292
|
Event: _TelemetryConstants.TelemetryEvent.EndChatEventReceived,
|
|
263
|
-
Description:
|
|
293
|
+
Description: eventDescription
|
|
264
294
|
});
|
|
265
295
|
|
|
266
|
-
if (
|
|
296
|
+
if (isChatUnloading) {
|
|
297
|
+
var _DataStoreManager$cli2;
|
|
298
|
+
|
|
299
|
+
//Browser close scenario/no room for PCS/so just end chat and notify agent immidiately
|
|
300
|
+
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false); // Clean local storage
|
|
301
|
+
|
|
302
|
+
(_DataStoreManager$cli2 = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli2 === void 0 ? void 0 : _DataStoreManager$cli2.removeData(widgetStateEventName, "localStorage");
|
|
303
|
+
} else if (canEndChat.current) {
|
|
267
304
|
(0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
268
305
|
} else {
|
|
269
306
|
const skipEndChatSDK = true;
|
|
270
307
|
const skipCloseChat = false;
|
|
271
308
|
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
|
|
272
|
-
}
|
|
273
|
-
}); // Listen to end chat event from other tabs
|
|
309
|
+
} // Raise chatClose for SDK events
|
|
274
310
|
|
|
275
311
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
312
|
+
if (isSdkCall) {
|
|
313
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
314
|
+
eventName: _TelemetryConstants.BroadcastEvent.CloseChat
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}); // reset proactive chat params
|
|
282
318
|
|
|
283
|
-
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.ClosePopoutWindow).subscribe(() => {
|
|
284
|
-
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
285
|
-
Event: _TelemetryConstants.TelemetryEvent.ClosePopoutWindowEventRecevied,
|
|
286
|
-
Description: "Close popout window event received."
|
|
287
|
-
});
|
|
288
319
|
|
|
320
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.ResetProactiveChatParams).subscribe(async () => {
|
|
289
321
|
dispatch({
|
|
290
322
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
291
323
|
payload: {
|
|
@@ -294,18 +326,38 @@ const LiveChatWidgetStateful = props => {
|
|
|
294
326
|
proactiveChatInNewWindow: false
|
|
295
327
|
}
|
|
296
328
|
});
|
|
297
|
-
});
|
|
329
|
+
}); // Listen to end chat event from other tabs
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.widgetId);
|
|
333
|
+
|
|
334
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
|
|
335
|
+
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
336
|
+
}); // Close popout window
|
|
337
|
+
|
|
298
338
|
|
|
299
339
|
window.addEventListener("beforeunload", () => {
|
|
340
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
341
|
+
Event: _TelemetryConstants.TelemetryEvent.WindowClosed,
|
|
342
|
+
Description: "Closed window."
|
|
343
|
+
});
|
|
344
|
+
|
|
300
345
|
(0, _disposeTelemetryLoggers.disposeTelemetryLoggers)();
|
|
301
346
|
});
|
|
302
347
|
|
|
303
348
|
if (state.appStates.conversationEndedByAgent) {
|
|
304
349
|
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
|
|
305
|
-
}
|
|
350
|
+
} //Listen to WidgetSize
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName("WidgetSize").subscribe(msg => {
|
|
354
|
+
dispatch({
|
|
355
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_SIZE,
|
|
356
|
+
payload: msg === null || msg === void 0 ? void 0 : msg.payload
|
|
357
|
+
});
|
|
358
|
+
});
|
|
306
359
|
}, []);
|
|
307
360
|
(0, _react2.useEffect)(() => {
|
|
308
|
-
canStartProactiveChat.current = state.appStates.conversationState === _ConversationState.ConversationState.Closed;
|
|
309
361
|
canEndChat.current = state.appStates.conversationState === _ConversationState.ConversationState.Active;
|
|
310
362
|
|
|
311
363
|
if (state.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
@@ -326,7 +378,10 @@ const LiveChatWidgetStateful = props => {
|
|
|
326
378
|
});
|
|
327
379
|
});
|
|
328
380
|
}
|
|
329
|
-
}, [state.appStates.conversationState]);
|
|
381
|
+
}, [state.appStates.conversationState]);
|
|
382
|
+
(0, _react2.useEffect)(() => {
|
|
383
|
+
canStartProactiveChat.current = state.appStates.conversationState === _ConversationState.ConversationState.Closed && !state.appStates.proactiveChatStates.proactiveChatInNewWindow;
|
|
384
|
+
}, [state.appStates.conversationState, state.appStates.proactiveChatStates.proactiveChatInNewWindow]); // Reset the UnreadMessageCount when minimized is toggled and broadcast it.
|
|
330
385
|
|
|
331
386
|
(0, _react2.useEffect)(() => {
|
|
332
387
|
currentMessageCountRef.current = -1;
|
|
@@ -360,7 +415,20 @@ const LiveChatWidgetStateful = props => {
|
|
|
360
415
|
setWebChatStyles({ ...webChatStyles,
|
|
361
416
|
...((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.webChatStyles)
|
|
362
417
|
});
|
|
363
|
-
}, [(_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.webChatStyles]);
|
|
418
|
+
}, [(_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.webChatStyles]); // Publish chat widget state
|
|
419
|
+
|
|
420
|
+
(0, _react2.useEffect)(() => {
|
|
421
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic;
|
|
422
|
+
|
|
423
|
+
widgetStateEventName = (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);
|
|
424
|
+
const chatWidgetStateChangeEvent = {
|
|
425
|
+
eventName: widgetStateEventName,
|
|
426
|
+
payload: { ...state
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
_omnichannelChatComponents.BroadcastService.postMessage(chatWidgetStateChangeEvent);
|
|
431
|
+
}, [state]);
|
|
364
432
|
const webChatProps = (0, _initWebChatComposer.initWebChatComposer)(props, chatSDK, state, dispatch, setWebChatStyles);
|
|
365
433
|
|
|
366
434
|
const setPostChatContextRelay = () => (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -376,20 +444,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
376
444
|
|
|
377
445
|
const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
|
|
378
446
|
|
|
379
|
-
const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props);
|
|
380
|
-
|
|
381
|
-
(0, _react2.useEffect)(() => {
|
|
382
|
-
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic;
|
|
383
|
-
|
|
384
|
-
const widgetStateEventName = (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);
|
|
385
|
-
const chatWidgetStateChangeEvent = {
|
|
386
|
-
eventName: widgetStateEventName,
|
|
387
|
-
payload: { ...state
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
_omnichannelChatComponents.BroadcastService.postMessage(chatWidgetStateChangeEvent);
|
|
392
|
-
}, [state]);
|
|
447
|
+
const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props);
|
|
393
448
|
return /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
|
|
394
449
|
styleOptions: webChatStyles,
|
|
395
450
|
directLine: ((_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.directLine) ?? adapter ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.directLine
|
|
@@ -25,15 +25,53 @@ 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
|
+
|
|
28
36
|
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
37
|
|
|
30
38
|
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
39
|
|
|
40
|
+
const broadcastChannelMessageEvent = "message";
|
|
41
|
+
|
|
42
|
+
const postActivity = activity => {
|
|
43
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
44
|
+
return {
|
|
45
|
+
type: _WebChatActionType.WebChatActionType.DIRECT_LINE_POST_ACTIVITY,
|
|
46
|
+
meta: {
|
|
47
|
+
method: "keyboard"
|
|
48
|
+
},
|
|
49
|
+
payload: {
|
|
50
|
+
activity: {
|
|
51
|
+
channelData: undefined,
|
|
52
|
+
text: "",
|
|
53
|
+
textFormat: "plain",
|
|
54
|
+
type: _Constants.Constants.message,
|
|
55
|
+
...activity
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const createMagicCodeSuccessResponse = signin => {
|
|
62
|
+
return {
|
|
63
|
+
signin,
|
|
64
|
+
result: "Success"
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
32
68
|
const WebChatContainerStateful = props => {
|
|
33
69
|
const {
|
|
34
70
|
BasicWebChat
|
|
35
71
|
} = _botframeworkWebchat.Components;
|
|
36
72
|
const [state, dispatch] = (0, _.useChatContextStore)();
|
|
73
|
+
const magicCodeBroadcastChannel = new BroadcastChannel(_Constants.Constants.magicCodeBroadcastChannel);
|
|
74
|
+
const magicCodeResponseBroadcastChannel = new BroadcastChannel(_Constants.Constants.magicCodeResponseBroadcastChannel);
|
|
37
75
|
const containerStyles = {
|
|
38
76
|
root: Object.assign({}, _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.containerStyles, props === null || props === void 0 ? void 0 : props.containerStyles, {
|
|
39
77
|
display: state.appStates.isMinimized ? "none" : ""
|
|
@@ -58,6 +96,48 @@ const WebChatContainerStateful = props => {
|
|
|
58
96
|
Event: _TelemetryConstants.TelemetryEvent.WebChatLoaded
|
|
59
97
|
});
|
|
60
98
|
}, []);
|
|
99
|
+
(0, _react2.useEffect)(() => {
|
|
100
|
+
const eventListener = event => {
|
|
101
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-function
|
|
102
|
+
const {
|
|
103
|
+
data
|
|
104
|
+
} = event;
|
|
105
|
+
|
|
106
|
+
if (_BotMagicCodeStore.BotMagicCodeStore.botOAuthSignInId === data.signin) {
|
|
107
|
+
const {
|
|
108
|
+
signin,
|
|
109
|
+
code
|
|
110
|
+
} = data;
|
|
111
|
+
const text = `${code}`;
|
|
112
|
+
const action = postActivity({
|
|
113
|
+
text,
|
|
114
|
+
channelData: {
|
|
115
|
+
tags: [_Constants.Constants.hiddenTag]
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
_WebChatStoreLoader.WebChatStoreLoader.store.dispatch(action);
|
|
120
|
+
|
|
121
|
+
const response = createMagicCodeSuccessResponse(signin);
|
|
122
|
+
magicCodeResponseBroadcastChannel.postMessage(response);
|
|
123
|
+
|
|
124
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
125
|
+
Event: _TelemetryConstants.TelemetryEvent.SuppressBotMagicCodeSucceeded
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
_BotMagicCodeStore.BotMagicCodeStore.botOAuthSignInId = "";
|
|
129
|
+
magicCodeBroadcastChannel.close();
|
|
130
|
+
magicCodeResponseBroadcastChannel.close();
|
|
131
|
+
} else {
|
|
132
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
133
|
+
Event: _TelemetryConstants.TelemetryEvent.SuppressBotMagicCodeFailed,
|
|
134
|
+
Description: "Signin does not match"
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
magicCodeBroadcastChannel.addEventListener(broadcastChannelMessageEvent, eventListener);
|
|
140
|
+
}, []);
|
|
61
141
|
return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement("style", null, `
|
|
62
142
|
.ms_lcw_webchat_received_message img.webchat__markdown__external-link-icon {
|
|
63
143
|
background-image : url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIzIDMgMTggMTgiICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik03LjI1MDEgNC41MDAxN0gxMC43NDk1QzExLjE2MzcgNC41MDAxNyAxMS40OTk1IDQuODM1OTYgMTEuNDk5NSA1LjI1MDE3QzExLjQ5OTUgNS42Mjk4NiAxMS4yMTczIDUuOTQzNjYgMTAuODUxMyA1Ljk5MzMyTDEwLjc0OTUgNi4wMDAxN0g3LjI0OTc0QzYuMDcwNzkgNS45OTk2MSA1LjEwMzQ5IDYuOTA2NTYgNS4wMDc4NiA4LjA2MTEyTDUuMDAwMjggOC4yMjAwM0w1LjAwMzEyIDE2Ljc1MDdDNS4wMDM0MyAxNy45NDE1IDUuOTI4ODUgMTguOTE2MSA3LjA5OTY2IDE4Ljk5NDlMNy4yNTM3MSAxOS4wMDAxTDE1Ljc1MTggMTguOTg4NEMxNi45NDE1IDE4Ljk4NjggMTcuOTE0NSAxOC4wNjIgMTcuOTkzNSAxNi44OTIzTDE3Ljk5ODcgMTYuNzM4NFYxMy4yMzIxQzE3Ljk5ODcgMTIuODE3OSAxOC4zMzQ1IDEyLjQ4MjEgMTguNzQ4NyAxMi40ODIxQzE5LjEyODQgMTIuNDgyMSAxOS40NDIyIDEyLjc2NDMgMTkuNDkxOCAxMy4xMzAzTDE5LjQ5ODcgMTMuMjMyMVYxNi43Mzg0QzE5LjQ5ODcgMTguNzQwNyAxNy45MjkzIDIwLjM3NjkgMTUuOTUyOCAyMC40ODI5TDE1Ljc1MzggMjAuNDg4NEw3LjI1ODI3IDIwLjUwMDFMNy4wNTQ5NSAyMC40OTQ5QzUuMTQyMzkgMjAuMzk1NCAzLjYwODk1IDE4Ljg2MjcgMy41MDgzNyAxNi45NTAyTDMuNTAzMTIgMTYuNzUxMUwzLjUwMDg5IDguMjUyN0wzLjUwNTI5IDguMDUwMkMzLjYwNTM5IDYuMTM3NDkgNS4xMzg2NyA0LjYwNDQ5IDcuMDUwOTYgNC41MDUyN0w3LjI1MDEgNC41MDAxN0gxMC43NDk1SDcuMjUwMVpNMTMuNzQ4MSAzLjAwMTQ2TDIwLjMwMTggMy4wMDE5N0wyMC40MDE0IDMuMDE1NzVMMjAuNTAyMiAzLjA0MzkzTDIwLjU1OSAzLjA2ODAzQzIwLjYxMjIgMy4wOTEyMiAyMC42NjM0IDMuMTIxNjMgMjAuNzExMSAzLjE1ODg1TDIwLjc4MDQgMy4yMjE1NkwyMC44NjQxIDMuMzIwMTRMMjAuOTE4MyAzLjQxMDI1TDIwLjk1NyAzLjUwMDU3TDIwLjk3NjIgMy41NjQ3NkwyMC45ODk4IDMuNjI4NjJMMjAuOTk5MiAzLjcyMjgyTDIwLjk5OTcgMTAuMjU1NEMyMC45OTk3IDEwLjY2OTYgMjAuNjYzOSAxMS4wMDU0IDIwLjI0OTcgMTEuMDA1NEMxOS44NyAxMS4wMDU0IDE5LjU1NjIgMTAuNzIzMiAxOS41MDY1IDEwLjM1NzFMMTkuNDk5NyAxMC4yNTU0TDE5LjQ5ODkgNS41NjE0N0wxMi4yNzk3IDEyLjc4NDdDMTIuMDEzNCAxMy4wNTEgMTEuNTk2OCAxMy4wNzUzIDExLjMwMzEgMTIuODU3NUwxMS4yMTkgMTIuNzg0OUMxMC45NTI3IDEyLjUxODcgMTAuOTI4NCAxMi4xMDIxIDExLjE0NjIgMTEuODA4NEwxMS4yMTg4IDExLjcyNDNMMTguNDM2OSA0LjUwMTQ2SDEzLjc0ODFDMTMuMzY4NCA0LjUwMTQ2IDEzLjA1NDYgNC4yMTkzMSAxMy4wMDUgMy44NTMyNEwxMi45OTgxIDMuNzUxNDZDMTIuOTk4MSAzLjM3MTc3IDEzLjI4MDMgMy4wNTc5NyAxMy42NDY0IDMuMDA4MzFMMTMuNzQ4MSAzLjAwMTQ2WiIgZmlsbD0iI0ZGRkZGRiIgLz48L3N2Zz4) !important;
|
|
@@ -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) {
|