@microsoft/omnichannel-chat-widget 1.7.3-main.aa696dc → 1.7.3-main.c5e352d
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/lib/cjs/common/telemetry/TelemetryConstants.js +1 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +15 -6
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +77 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +15 -2
- package/lib/cjs/components/livechatwidget/common/startChat.js +5 -6
- package/lib/cjs/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotAuthConfig.js +1 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +1 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +15 -6
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.js +70 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +14 -2
- package/lib/esm/components/livechatwidget/common/startChat.js +5 -6
- package/lib/esm/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IBotAuthConfig.js +1 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +2 -1
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +4 -1
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/createAdapter.d.ts +2 -1
- package/lib/types/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotAuthConfig.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
- package/package.json +2 -2
|
@@ -215,6 +215,7 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
215
215
|
TelemetryEvent["PostChatSurveyLoadingPaneLoaded"] = "PostChatSurveyLoadingPaneLoaded";
|
|
216
216
|
TelemetryEvent["PostChatSurveyLoaded"] = "PostChatSurveyLoaded";
|
|
217
217
|
TelemetryEvent["ChatDisconnectThreadEventReceived"] = "ChatDisconnectThreadEventReceived";
|
|
218
|
+
TelemetryEvent["HiddenAdaptiveCardMessageReceived"] = "HiddenAdaptiveCardMessageReceived";
|
|
218
219
|
})(TelemetryEvent || (exports.TelemetryEvent = TelemetryEvent = {}));
|
|
219
220
|
class TelemetryConstants {
|
|
220
221
|
static map(eventTypeOrScenarioType) {
|
package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js
CHANGED
|
@@ -13,8 +13,6 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
13
13
|
const supportedSignInCardContentTypes = ["application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"];
|
|
14
14
|
const botOauthUrlRegex = /[\S]+.botframework.com\/api\/oauth\/signin\?signin=([\S]+)/;
|
|
15
15
|
const delay = t => new Promise(resolve => setTimeout(resolve, t));
|
|
16
|
-
const fetchBotAuthConfigRetries = 3;
|
|
17
|
-
const fetchBotAuthConfigRetryInterval = 1000;
|
|
18
16
|
let response;
|
|
19
17
|
const extractSignInId = signInUrl => {
|
|
20
18
|
const result = botOauthUrlRegex.exec(signInUrl);
|
|
@@ -43,7 +41,7 @@ const extractSasUrl = async attachment => {
|
|
|
43
41
|
}
|
|
44
42
|
return sasUrl;
|
|
45
43
|
};
|
|
46
|
-
const fetchBotAuthConfig = async retries => {
|
|
44
|
+
const fetchBotAuthConfig = async (retries, interval) => {
|
|
47
45
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
48
46
|
Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderFetchConfig
|
|
49
47
|
});
|
|
@@ -64,14 +62,25 @@ const fetchBotAuthConfig = async retries => {
|
|
|
64
62
|
// Base Case
|
|
65
63
|
throw new Error();
|
|
66
64
|
}
|
|
67
|
-
await delay(
|
|
68
|
-
return await fetchBotAuthConfig(--retries);
|
|
65
|
+
await delay(interval);
|
|
66
|
+
return await fetchBotAuthConfig(--retries, interval);
|
|
69
67
|
};
|
|
70
68
|
class BotAuthActivitySubscriber {
|
|
71
69
|
constructor() {
|
|
70
|
+
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
72
71
|
_defineProperty(this, "observer", void 0);
|
|
73
72
|
_defineProperty(this, "signInCardSeen", void 0);
|
|
73
|
+
_defineProperty(this, "fetchBotAuthConfigRetries", void 0);
|
|
74
|
+
_defineProperty(this, "fetchBotAuthConfigRetryInterval", void 0);
|
|
74
75
|
this.signInCardSeen = new Set();
|
|
76
|
+
this.fetchBotAuthConfigRetries = 3;
|
|
77
|
+
this.fetchBotAuthConfigRetryInterval = 1000;
|
|
78
|
+
if (optionalParams.fetchBotAuthConfigRetries) {
|
|
79
|
+
this.fetchBotAuthConfigRetries = optionalParams.fetchBotAuthConfigRetries;
|
|
80
|
+
}
|
|
81
|
+
if (optionalParams.fetchBotAuthConfigRetryInterval) {
|
|
82
|
+
this.fetchBotAuthConfigRetryInterval = optionalParams.fetchBotAuthConfigRetryInterval;
|
|
83
|
+
}
|
|
75
84
|
}
|
|
76
85
|
applicable(activity) {
|
|
77
86
|
var _activity$attachments;
|
|
@@ -110,7 +119,7 @@ class BotAuthActivitySubscriber {
|
|
|
110
119
|
_omnichannelChatComponents.BroadcastService.postMessage(event);
|
|
111
120
|
}
|
|
112
121
|
try {
|
|
113
|
-
const response = await fetchBotAuthConfig(fetchBotAuthConfigRetries);
|
|
122
|
+
const response = await fetchBotAuthConfig(this.fetchBotAuthConfigRetries, this.fetchBotAuthConfigRetryInterval);
|
|
114
123
|
if (response === false) {
|
|
115
124
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
116
125
|
Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderHideCard
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.HiddenAdaptiveCardActivitySubscriber = void 0;
|
|
7
|
+
var _Constants = require("../../../../common/Constants");
|
|
8
|
+
var _TelemetryConstants = require("../../../../common/telemetry/TelemetryConstants");
|
|
9
|
+
var _TelemetryHelper = require("../../../../common/telemetry/TelemetryHelper");
|
|
10
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
11
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
13
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
14
|
+
class HiddenAdaptiveCardActivitySubscriber {
|
|
15
|
+
constructor() {
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
_defineProperty(this, "observer", void 0);
|
|
18
|
+
}
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
async apply(activity) {
|
|
21
|
+
const {
|
|
22
|
+
attachments,
|
|
23
|
+
attachment
|
|
24
|
+
} = activity;
|
|
25
|
+
this.observer.next(false);
|
|
26
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
27
|
+
eventName: _TelemetryConstants.BroadcastEvent.NewMessageReceived,
|
|
28
|
+
payload: {
|
|
29
|
+
attachments: attachments || [attachment],
|
|
30
|
+
text: "Custom Event"
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
37
|
+
applicable(activity) {
|
|
38
|
+
const {
|
|
39
|
+
attachments,
|
|
40
|
+
attachment
|
|
41
|
+
} = activity;
|
|
42
|
+
|
|
43
|
+
// Use `attachments` or `attachment` (whichever exists)
|
|
44
|
+
const cards = attachments || [attachment];
|
|
45
|
+
|
|
46
|
+
// Check if contentType is "AdaptiveCard"
|
|
47
|
+
const adaptiveCard = cards === null || cards === void 0 ? void 0 : cards.find(
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
+
item => _Constants.Constants.supportedAdaptiveCardContentTypes.indexOf(item === null || item === void 0 ? void 0 : item.contentType) >= 0);
|
|
50
|
+
if (adaptiveCard && adaptiveCard.content) {
|
|
51
|
+
const {
|
|
52
|
+
body
|
|
53
|
+
} = adaptiveCard.content;
|
|
54
|
+
if (Array.isArray(body)) {
|
|
55
|
+
// Check if all elements in `body` have `isVisible: false`
|
|
56
|
+
const allInvisible = body.every(item => item.isVisible === false);
|
|
57
|
+
if (allInvisible) {
|
|
58
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
59
|
+
Event: _TelemetryConstants.TelemetryEvent.HiddenAdaptiveCardMessageReceived,
|
|
60
|
+
Description: "All elements in AdaptiveCard are invisible"
|
|
61
|
+
});
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
70
|
+
async next(activity) {
|
|
71
|
+
if (this.applicable(activity)) {
|
|
72
|
+
return await this.apply(activity);
|
|
73
|
+
}
|
|
74
|
+
return activity;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.HiddenAdaptiveCardActivitySubscriber = HiddenAdaptiveCardActivitySubscriber;
|
|
@@ -11,8 +11,14 @@ var _defaultMiddlewareLocalizedTexts = require("../../webchatcontainerstateful/c
|
|
|
11
11
|
var _ChatAdapterShim = require("./ChatAdapterShim");
|
|
12
12
|
var _PauseActivitySubscriber = require("./ActivitySubscriber/PauseActivitySubscriber");
|
|
13
13
|
var _BotAuthActivitySubscriber = require("./ActivitySubscriber/BotAuthActivitySubscriber");
|
|
14
|
+
var _HiddenAdaptiveCardActivitySubscriber = require("./ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber");
|
|
15
|
+
const defaultBotAuthConfig = {
|
|
16
|
+
fetchBotAuthConfigRetries: 3,
|
|
17
|
+
fetchBotAuthConfigRetryInterval: 1000
|
|
18
|
+
};
|
|
19
|
+
|
|
14
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
-
const createAdapter = async chatSDK => {
|
|
21
|
+
const createAdapter = async (chatSDK, props) => {
|
|
16
22
|
const chatAdapterOptionalParams = {
|
|
17
23
|
IC3Adapter: {
|
|
18
24
|
options: {
|
|
@@ -38,9 +44,16 @@ const createAdapter = async chatSDK => {
|
|
|
38
44
|
let adapter = await chatSDK.createChatAdapter(chatAdapterOptionalParams);
|
|
39
45
|
//so far, there is no need to convert to the shim adapter when using visual tests
|
|
40
46
|
if (chatSDK.isMockModeOn !== true) {
|
|
47
|
+
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4;
|
|
48
|
+
const botAuthActivitySubscriberOptionalParams = {
|
|
49
|
+
fetchBotAuthConfigRetries: (props === null || props === void 0 ? void 0 : (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.botAuthConfig) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.fetchBotAuthConfigRetries) || defaultBotAuthConfig.fetchBotAuthConfigRetries,
|
|
50
|
+
fetchBotAuthConfigRetryInterval: (props === null || props === void 0 ? void 0 : (_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : (_props$webChatContain4 = _props$webChatContain3.botAuthConfig) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.fetchBotAuthConfigRetryInterval) || defaultBotAuthConfig.fetchBotAuthConfigRetryInterval
|
|
51
|
+
};
|
|
41
52
|
adapter = new _ChatAdapterShim.ChatAdapterShim(adapter);
|
|
42
53
|
adapter.addSubscriber(new _PauseActivitySubscriber.PauseActivitySubscriber());
|
|
43
|
-
adapter.addSubscriber(new _BotAuthActivitySubscriber.BotAuthActivitySubscriber());
|
|
54
|
+
adapter.addSubscriber(new _BotAuthActivitySubscriber.BotAuthActivitySubscriber(botAuthActivitySubscriberOptionalParams));
|
|
55
|
+
// Remove this code after ICM ID:544623085 is fixed
|
|
56
|
+
adapter.addSubscriber(new _HiddenAdaptiveCardActivitySubscriber.HiddenAdaptiveCardActivitySubscriber());
|
|
44
57
|
return adapter.chatAdapter;
|
|
45
58
|
}
|
|
46
59
|
return adapter;
|
|
@@ -209,6 +209,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
209
209
|
isStartChatSuccessful = false;
|
|
210
210
|
throw error;
|
|
211
211
|
}
|
|
212
|
+
await createAdapterAndSubscribe(chatSDK, dispatch, setAdapter, props);
|
|
212
213
|
|
|
213
214
|
// Set app state to Active
|
|
214
215
|
if (isStartChatSuccessful) {
|
|
@@ -233,12 +234,12 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
233
234
|
(0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch, true);
|
|
234
235
|
return;
|
|
235
236
|
}
|
|
236
|
-
await createAdapterAndSubscribe(chatSDK, dispatch, setAdapter);
|
|
237
237
|
|
|
238
238
|
// Persistent Chat relies on the `reconnectId` retrieved from reconnectablechats API to reconnect upon start chat and not `liveChatContext`
|
|
239
239
|
if (!persistentChatEnabled) {
|
|
240
240
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
241
241
|
const liveChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
|
|
242
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
242
243
|
dispatch({
|
|
243
244
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
244
245
|
payload: liveChatContext
|
|
@@ -259,14 +260,12 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
259
260
|
|
|
260
261
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
261
262
|
exports.initStartChat = initStartChat;
|
|
262
|
-
const createAdapterAndSubscribe = async (chatSDK, dispatch, setAdapter) => {
|
|
263
|
+
const createAdapterAndSubscribe = async (chatSDK, dispatch, setAdapter, props) => {
|
|
263
264
|
var _newAdapter$activity$;
|
|
264
265
|
// New adapter creation
|
|
265
|
-
const newAdapter = await (0, _createAdapter.createAdapter)(chatSDK);
|
|
266
|
+
const newAdapter = await (0, _createAdapter.createAdapter)(chatSDK, props);
|
|
266
267
|
setAdapter(newAdapter);
|
|
267
|
-
|
|
268
|
-
//start chat is already seeding the chat token, so no need to get it again
|
|
269
|
-
const chatToken = await chatSDK.getChatToken(true);
|
|
268
|
+
const chatToken = await chatSDK.getChatToken();
|
|
270
269
|
dispatch({
|
|
271
270
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
272
271
|
payload: chatToken
|
package/lib/cjs/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -209,6 +209,7 @@ export let TelemetryEvent;
|
|
|
209
209
|
TelemetryEvent["PostChatSurveyLoadingPaneLoaded"] = "PostChatSurveyLoadingPaneLoaded";
|
|
210
210
|
TelemetryEvent["PostChatSurveyLoaded"] = "PostChatSurveyLoaded";
|
|
211
211
|
TelemetryEvent["ChatDisconnectThreadEventReceived"] = "ChatDisconnectThreadEventReceived";
|
|
212
|
+
TelemetryEvent["HiddenAdaptiveCardMessageReceived"] = "HiddenAdaptiveCardMessageReceived";
|
|
212
213
|
})(TelemetryEvent || (TelemetryEvent = {}));
|
|
213
214
|
export class TelemetryConstants {
|
|
214
215
|
static map(eventTypeOrScenarioType) {
|
package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js
CHANGED
|
@@ -9,8 +9,6 @@ import { TelemetryHelper } from "../../../../common/telemetry/TelemetryHelper";
|
|
|
9
9
|
const supportedSignInCardContentTypes = ["application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"];
|
|
10
10
|
const botOauthUrlRegex = /[\S]+.botframework.com\/api\/oauth\/signin\?signin=([\S]+)/;
|
|
11
11
|
const delay = t => new Promise(resolve => setTimeout(resolve, t));
|
|
12
|
-
const fetchBotAuthConfigRetries = 3;
|
|
13
|
-
const fetchBotAuthConfigRetryInterval = 1000;
|
|
14
12
|
let response;
|
|
15
13
|
const extractSignInId = signInUrl => {
|
|
16
14
|
const result = botOauthUrlRegex.exec(signInUrl);
|
|
@@ -39,7 +37,7 @@ const extractSasUrl = async attachment => {
|
|
|
39
37
|
}
|
|
40
38
|
return sasUrl;
|
|
41
39
|
};
|
|
42
|
-
const fetchBotAuthConfig = async retries => {
|
|
40
|
+
const fetchBotAuthConfig = async (retries, interval) => {
|
|
43
41
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
44
42
|
Event: TelemetryEvent.SetBotAuthProviderFetchConfig
|
|
45
43
|
});
|
|
@@ -60,14 +58,25 @@ const fetchBotAuthConfig = async retries => {
|
|
|
60
58
|
// Base Case
|
|
61
59
|
throw new Error();
|
|
62
60
|
}
|
|
63
|
-
await delay(
|
|
64
|
-
return await fetchBotAuthConfig(--retries);
|
|
61
|
+
await delay(interval);
|
|
62
|
+
return await fetchBotAuthConfig(--retries, interval);
|
|
65
63
|
};
|
|
66
64
|
export class BotAuthActivitySubscriber {
|
|
67
65
|
constructor() {
|
|
66
|
+
let optionalParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
68
67
|
_defineProperty(this, "observer", void 0);
|
|
69
68
|
_defineProperty(this, "signInCardSeen", void 0);
|
|
69
|
+
_defineProperty(this, "fetchBotAuthConfigRetries", void 0);
|
|
70
|
+
_defineProperty(this, "fetchBotAuthConfigRetryInterval", void 0);
|
|
70
71
|
this.signInCardSeen = new Set();
|
|
72
|
+
this.fetchBotAuthConfigRetries = 3;
|
|
73
|
+
this.fetchBotAuthConfigRetryInterval = 1000;
|
|
74
|
+
if (optionalParams.fetchBotAuthConfigRetries) {
|
|
75
|
+
this.fetchBotAuthConfigRetries = optionalParams.fetchBotAuthConfigRetries;
|
|
76
|
+
}
|
|
77
|
+
if (optionalParams.fetchBotAuthConfigRetryInterval) {
|
|
78
|
+
this.fetchBotAuthConfigRetryInterval = optionalParams.fetchBotAuthConfigRetryInterval;
|
|
79
|
+
}
|
|
71
80
|
}
|
|
72
81
|
applicable(activity) {
|
|
73
82
|
var _activity$attachments;
|
|
@@ -106,7 +115,7 @@ export class BotAuthActivitySubscriber {
|
|
|
106
115
|
BroadcastService.postMessage(event);
|
|
107
116
|
}
|
|
108
117
|
try {
|
|
109
|
-
const response = await fetchBotAuthConfig(fetchBotAuthConfigRetries);
|
|
118
|
+
const response = await fetchBotAuthConfig(this.fetchBotAuthConfigRetries, this.fetchBotAuthConfigRetryInterval);
|
|
110
119
|
if (response === false) {
|
|
111
120
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
112
121
|
Event: TelemetryEvent.SetBotAuthProviderHideCard
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
+
import { Constants } from "../../../../common/Constants";
|
|
5
|
+
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../../common/telemetry/TelemetryConstants";
|
|
6
|
+
import { TelemetryHelper } from "../../../../common/telemetry/TelemetryHelper";
|
|
7
|
+
import { BroadcastService } from "@microsoft/omnichannel-chat-components";
|
|
8
|
+
export class HiddenAdaptiveCardActivitySubscriber {
|
|
9
|
+
constructor() {
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
_defineProperty(this, "observer", void 0);
|
|
12
|
+
}
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
async apply(activity) {
|
|
15
|
+
const {
|
|
16
|
+
attachments,
|
|
17
|
+
attachment
|
|
18
|
+
} = activity;
|
|
19
|
+
this.observer.next(false);
|
|
20
|
+
BroadcastService.postMessage({
|
|
21
|
+
eventName: BroadcastEvent.NewMessageReceived,
|
|
22
|
+
payload: {
|
|
23
|
+
attachments: attachments || [attachment],
|
|
24
|
+
text: "Custom Event"
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
31
|
+
applicable(activity) {
|
|
32
|
+
const {
|
|
33
|
+
attachments,
|
|
34
|
+
attachment
|
|
35
|
+
} = activity;
|
|
36
|
+
|
|
37
|
+
// Use `attachments` or `attachment` (whichever exists)
|
|
38
|
+
const cards = attachments || [attachment];
|
|
39
|
+
|
|
40
|
+
// Check if contentType is "AdaptiveCard"
|
|
41
|
+
const adaptiveCard = cards === null || cards === void 0 ? void 0 : cards.find(
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
item => Constants.supportedAdaptiveCardContentTypes.indexOf(item === null || item === void 0 ? void 0 : item.contentType) >= 0);
|
|
44
|
+
if (adaptiveCard && adaptiveCard.content) {
|
|
45
|
+
const {
|
|
46
|
+
body
|
|
47
|
+
} = adaptiveCard.content;
|
|
48
|
+
if (Array.isArray(body)) {
|
|
49
|
+
// Check if all elements in `body` have `isVisible: false`
|
|
50
|
+
const allInvisible = body.every(item => item.isVisible === false);
|
|
51
|
+
if (allInvisible) {
|
|
52
|
+
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
53
|
+
Event: TelemetryEvent.HiddenAdaptiveCardMessageReceived,
|
|
54
|
+
Description: "All elements in AdaptiveCard are invisible"
|
|
55
|
+
});
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
|
+
async next(activity) {
|
|
65
|
+
if (this.applicable(activity)) {
|
|
66
|
+
return await this.apply(activity);
|
|
67
|
+
}
|
|
68
|
+
return activity;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -5,9 +5,14 @@ import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/
|
|
|
5
5
|
import { ChatAdapterShim } from "./ChatAdapterShim";
|
|
6
6
|
import { PauseActivitySubscriber } from "./ActivitySubscriber/PauseActivitySubscriber";
|
|
7
7
|
import { BotAuthActivitySubscriber } from "./ActivitySubscriber/BotAuthActivitySubscriber";
|
|
8
|
+
import { HiddenAdaptiveCardActivitySubscriber } from "./ActivitySubscriber/HiddenAdaptiveCardActivitySubscriber";
|
|
9
|
+
const defaultBotAuthConfig = {
|
|
10
|
+
fetchBotAuthConfigRetries: 3,
|
|
11
|
+
fetchBotAuthConfigRetryInterval: 1000
|
|
12
|
+
};
|
|
8
13
|
|
|
9
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
-
export const createAdapter = async chatSDK => {
|
|
15
|
+
export const createAdapter = async (chatSDK, props) => {
|
|
11
16
|
const chatAdapterOptionalParams = {
|
|
12
17
|
IC3Adapter: {
|
|
13
18
|
options: {
|
|
@@ -33,9 +38,16 @@ export const createAdapter = async chatSDK => {
|
|
|
33
38
|
let adapter = await chatSDK.createChatAdapter(chatAdapterOptionalParams);
|
|
34
39
|
//so far, there is no need to convert to the shim adapter when using visual tests
|
|
35
40
|
if (chatSDK.isMockModeOn !== true) {
|
|
41
|
+
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4;
|
|
42
|
+
const botAuthActivitySubscriberOptionalParams = {
|
|
43
|
+
fetchBotAuthConfigRetries: (props === null || props === void 0 ? void 0 : (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.botAuthConfig) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.fetchBotAuthConfigRetries) || defaultBotAuthConfig.fetchBotAuthConfigRetries,
|
|
44
|
+
fetchBotAuthConfigRetryInterval: (props === null || props === void 0 ? void 0 : (_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : (_props$webChatContain4 = _props$webChatContain3.botAuthConfig) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.fetchBotAuthConfigRetryInterval) || defaultBotAuthConfig.fetchBotAuthConfigRetryInterval
|
|
45
|
+
};
|
|
36
46
|
adapter = new ChatAdapterShim(adapter);
|
|
37
47
|
adapter.addSubscriber(new PauseActivitySubscriber());
|
|
38
|
-
adapter.addSubscriber(new BotAuthActivitySubscriber());
|
|
48
|
+
adapter.addSubscriber(new BotAuthActivitySubscriber(botAuthActivitySubscriberOptionalParams));
|
|
49
|
+
// Remove this code after ICM ID:544623085 is fixed
|
|
50
|
+
adapter.addSubscriber(new HiddenAdaptiveCardActivitySubscriber());
|
|
39
51
|
return adapter.chatAdapter;
|
|
40
52
|
}
|
|
41
53
|
return adapter;
|
|
@@ -202,6 +202,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
202
202
|
isStartChatSuccessful = false;
|
|
203
203
|
throw error;
|
|
204
204
|
}
|
|
205
|
+
await createAdapterAndSubscribe(chatSDK, dispatch, setAdapter, props);
|
|
205
206
|
|
|
206
207
|
// Set app state to Active
|
|
207
208
|
if (isStartChatSuccessful) {
|
|
@@ -226,12 +227,12 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
226
227
|
setPostChatContextAndLoadSurvey(chatSDK, dispatch, true);
|
|
227
228
|
return;
|
|
228
229
|
}
|
|
229
|
-
await createAdapterAndSubscribe(chatSDK, dispatch, setAdapter);
|
|
230
230
|
|
|
231
231
|
// Persistent Chat relies on the `reconnectId` retrieved from reconnectablechats API to reconnect upon start chat and not `liveChatContext`
|
|
232
232
|
if (!persistentChatEnabled) {
|
|
233
233
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
234
234
|
const liveChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
|
|
235
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
235
236
|
dispatch({
|
|
236
237
|
type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
237
238
|
payload: liveChatContext
|
|
@@ -251,14 +252,12 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, state, props, params
|
|
|
251
252
|
};
|
|
252
253
|
|
|
253
254
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
254
|
-
const createAdapterAndSubscribe = async (chatSDK, dispatch, setAdapter) => {
|
|
255
|
+
const createAdapterAndSubscribe = async (chatSDK, dispatch, setAdapter, props) => {
|
|
255
256
|
var _newAdapter$activity$;
|
|
256
257
|
// New adapter creation
|
|
257
|
-
const newAdapter = await createAdapter(chatSDK);
|
|
258
|
+
const newAdapter = await createAdapter(chatSDK, props);
|
|
258
259
|
setAdapter(newAdapter);
|
|
259
|
-
|
|
260
|
-
//start chat is already seeding the chat token, so no need to get it again
|
|
261
|
-
const chatToken = await chatSDK.getChatToken(true);
|
|
260
|
+
const chatToken = await chatSDK.getChatToken();
|
|
262
261
|
dispatch({
|
|
263
262
|
type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
264
263
|
payload: chatToken
|
package/lib/esm/components/livechatwidget/interfaces/IBotAuthActivitySubscriberOptionalParams.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -201,7 +201,8 @@ export declare enum TelemetryEvent {
|
|
|
201
201
|
PostChatContextCallFailed = "PostChatContextCallFailed",
|
|
202
202
|
PostChatSurveyLoadingPaneLoaded = "PostChatSurveyLoadingPaneLoaded",
|
|
203
203
|
PostChatSurveyLoaded = "PostChatSurveyLoaded",
|
|
204
|
-
ChatDisconnectThreadEventReceived = "ChatDisconnectThreadEventReceived"
|
|
204
|
+
ChatDisconnectThreadEventReceived = "ChatDisconnectThreadEventReceived",
|
|
205
|
+
HiddenAdaptiveCardMessageReceived = "HiddenAdaptiveCardMessageReceived"
|
|
205
206
|
}
|
|
206
207
|
export interface TelemetryInput {
|
|
207
208
|
scenarioType: ScenarioType;
|
package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { IActivitySubscriber } from "./IActivitySubscriber";
|
|
2
|
+
import { IBotAuthActivitySubscriberOptionalParams } from "../../interfaces/IBotAuthActivitySubscriberOptionalParams";
|
|
2
3
|
export declare class BotAuthActivitySubscriber implements IActivitySubscriber {
|
|
3
4
|
observer: any;
|
|
4
5
|
private signInCardSeen;
|
|
5
|
-
|
|
6
|
+
private fetchBotAuthConfigRetries;
|
|
7
|
+
private fetchBotAuthConfigRetryInterval;
|
|
8
|
+
constructor(optionalParams?: IBotAuthActivitySubscriberOptionalParams);
|
|
6
9
|
applicable(activity: any): boolean;
|
|
7
10
|
apply(activity: any): Promise<any>;
|
|
8
11
|
next(activity: any): Promise<any>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IActivitySubscriber } from "./IActivitySubscriber";
|
|
2
|
+
export declare class HiddenAdaptiveCardActivitySubscriber implements IActivitySubscriber {
|
|
3
|
+
observer: any;
|
|
4
|
+
apply(activity: any): Promise<void>;
|
|
5
|
+
applicable(activity: any): boolean;
|
|
6
|
+
next(activity: any): Promise<any>;
|
|
7
|
+
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { ILiveChatWidgetProps } from "../interfaces/ILiveChatWidgetProps";
|
|
2
|
+
export declare const createAdapter: (chatSDK: any, props?: ILiveChatWidgetProps | undefined) => Promise<any>;
|
package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { IStyle } from "@fluentui/react";
|
|
|
5
5
|
import { IWebChatProps } from "./IWebChatProps";
|
|
6
6
|
import { StyleOptions } from "botframework-webchat-api";
|
|
7
7
|
import { IAdaptiveCardStyles } from "./IAdaptiveCardStyles";
|
|
8
|
+
import { IBotAuthConfig } from "./IBotAuthConfig";
|
|
8
9
|
export interface IWebChatContainerStatefulProps {
|
|
9
10
|
containerStyles?: IStyle;
|
|
10
11
|
disableNewLineMarkdownSupport?: boolean;
|
|
@@ -16,6 +17,7 @@ export interface IWebChatContainerStatefulProps {
|
|
|
16
17
|
renderingMiddlewareProps?: IRenderingMiddlewareProps;
|
|
17
18
|
localizedTexts?: ILiveChatWidgetLocalizedTexts;
|
|
18
19
|
botMagicCode?: IBotMagicCodeConfig;
|
|
20
|
+
botAuthConfig?: IBotAuthConfig;
|
|
19
21
|
hyperlinkTextOverride?: boolean;
|
|
20
22
|
adaptiveCardStyles?: IAdaptiveCardStyles;
|
|
21
23
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/omnichannel-chat-widget",
|
|
3
|
-
"version": "1.7.3-main.
|
|
3
|
+
"version": "1.7.3-main.c5e352d",
|
|
4
4
|
"description": "Microsoft Omnichannel Chat Widget",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@microsoft/omnichannel-chat-components": "1.1.5",
|
|
78
|
-
"@microsoft/omnichannel-chat-sdk": "^1.9.
|
|
78
|
+
"@microsoft/omnichannel-chat-sdk": "^1.9.9",
|
|
79
79
|
"abort-controller-es5": "^2.0.1",
|
|
80
80
|
"dompurify": "^2.5.4",
|
|
81
81
|
"markdown-it": "^12.3.2",
|