@microsoft/omnichannel-chat-widget 0.1.0-main.2d7913d → 0.1.0-main.34fc37e
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/Constants.js +2 -0
- package/lib/cjs/common/telemetry/TelemetryConstants.js +2 -0
- package/lib/cjs/common/utils.js +20 -7
- package/lib/cjs/components/headerstateful/HeaderStateful.js +2 -1
- package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +44 -0
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +39 -0
- package/lib/cjs/components/livechatwidget/common/Deferred.js +42 -0
- package/lib/cjs/components/livechatwidget/common/authHelper.js +52 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +4 -0
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +8 -6
- package/lib/cjs/components/livechatwidget/common/endChat.js +3 -3
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +4 -0
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +55 -35
- package/lib/cjs/components/livechatwidget/common/startChat.js +44 -25
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +110 -47
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +11 -0
- 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/{livechatwidget/interfaces/IAuthProps.js → webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js} +0 -0
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
- package/lib/cjs/contexts/createReducer.js +8 -0
- package/lib/esm/common/Constants.js +2 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +2 -0
- package/lib/esm/common/utils.js +14 -5
- package/lib/esm/components/headerstateful/HeaderStateful.js +2 -1
- package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +34 -0
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +29 -0
- package/lib/esm/components/livechatwidget/common/Deferred.js +33 -0
- package/lib/esm/components/livechatwidget/common/authHelper.js +39 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +4 -1
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +8 -6
- package/lib/esm/components/livechatwidget/common/endChat.js +3 -3
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +4 -0
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +55 -37
- package/lib/esm/components/livechatwidget/common/startChat.js +40 -26
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +109 -49
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +10 -0
- 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/{livechatwidget/interfaces/IAuthProps.js → webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js} +0 -0
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -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 +1 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +2 -0
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -1
- package/lib/types/common/utils.d.ts +5 -4
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +1 -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/PauseActivitySubscriber.d.ts +7 -0
- package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/authHelper.d.ts +4 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -5
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/startChat.d.ts +3 -3
- package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -2
- package/lib/types/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.d.ts +1 -1
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/package.json +4 -3
- package/lib/types/components/livechatwidget/interfaces/IAuthProps.d.ts +0 -4
|
@@ -169,6 +169,8 @@ _defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChang
|
|
|
169
169
|
|
|
170
170
|
_defineProperty(Constants, "PostChatLoadingDurationInMs", 2000);
|
|
171
171
|
|
|
172
|
+
_defineProperty(Constants, "BrowserUnloadConfirmationMessage", "Do you want to leave chat?");
|
|
173
|
+
|
|
172
174
|
const Regex = (_class = class Regex {}, _defineProperty(_class, "EmailRegex", "(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"), _class);
|
|
173
175
|
exports.Regex = Regex;
|
|
174
176
|
|
|
@@ -143,6 +143,8 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
143
143
|
TelemetryEvent["SuppressBotMagicCodeFailed"] = "SuppressBotMagicCodeFailed";
|
|
144
144
|
TelemetryEvent["GetConversationDetailsException"] = "GetConversationDetailsException";
|
|
145
145
|
TelemetryEvent["BrowserUnloadEventStarted"] = "BrowserUnloadEventStarted";
|
|
146
|
+
TelemetryEvent["GetAuthTokenCalled"] = "GetAuthTokenCalled";
|
|
147
|
+
TelemetryEvent["ReceivedNullOrEmptyToken"] = "ReceivedNullOrEmptyToken";
|
|
146
148
|
TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
|
|
147
149
|
TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
|
|
148
150
|
TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
|
package/lib/cjs/common/utils.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.setTabIndices = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isUndefinedOrEmpty = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.createTimer = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
|
|
6
|
+
exports.setTabIndices = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isUndefinedOrEmpty = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.getBroadcastChannelName = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.createTimer = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
|
|
7
7
|
|
|
8
8
|
var _Constants = require("./Constants");
|
|
9
9
|
|
|
@@ -13,6 +13,8 @@ var _KeyCodes = require("./KeyCodes");
|
|
|
13
13
|
|
|
14
14
|
var _TelemetryConstants = require("./telemetry/TelemetryConstants");
|
|
15
15
|
|
|
16
|
+
var _md5Typescript = require("md5-typescript");
|
|
17
|
+
|
|
16
18
|
const getElementBySelector = selector => {
|
|
17
19
|
let element;
|
|
18
20
|
|
|
@@ -354,26 +356,31 @@ const getDomain = hostValue => {
|
|
|
354
356
|
|
|
355
357
|
exports.getDomain = getDomain;
|
|
356
358
|
|
|
357
|
-
const getWidgetCacheId = (orgId, widgetId) => {
|
|
358
|
-
|
|
359
|
+
const getWidgetCacheId = (orgId, widgetId, widgetInstanceId) => {
|
|
360
|
+
const widgetCacheId = `${widgetInstanceId}_${orgId}_${widgetId}`;
|
|
361
|
+
return _md5Typescript.Md5.init(widgetCacheId);
|
|
359
362
|
};
|
|
360
363
|
|
|
361
364
|
exports.getWidgetCacheId = getWidgetCacheId;
|
|
362
365
|
|
|
363
|
-
const getWidgetEndChatEventName = (orgId, widgetId) => {
|
|
366
|
+
const getWidgetEndChatEventName = (orgId, widgetId, widgetInstanceId) => {
|
|
367
|
+
if (!isNullOrEmptyString(widgetInstanceId)) {
|
|
368
|
+
return `${_TelemetryConstants.BroadcastEvent.ChatEnded}_${widgetInstanceId}_${orgId}_${widgetId}`;
|
|
369
|
+
}
|
|
370
|
+
|
|
364
371
|
return `${_TelemetryConstants.BroadcastEvent.ChatEnded}_${orgId}_${widgetId}`;
|
|
365
372
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
366
373
|
|
|
367
374
|
|
|
368
375
|
exports.getWidgetEndChatEventName = getWidgetEndChatEventName;
|
|
369
376
|
|
|
370
|
-
const getStateFromCache = (orgId, widgetId) => {
|
|
377
|
+
const getStateFromCache = (orgId, widgetId, widgetInstanceId) => {
|
|
371
378
|
// Getting updated state from cache
|
|
372
379
|
try {
|
|
373
380
|
if (_DataStoreManager.DataStoreManager.clientDataStore) {
|
|
374
381
|
var _DataStoreManager$cli;
|
|
375
382
|
|
|
376
|
-
const widgetStateEventName = getWidgetCacheId(orgId, widgetId);
|
|
383
|
+
const widgetStateEventName = getWidgetCacheId(orgId, widgetId, widgetInstanceId);
|
|
377
384
|
const widgetStateFromCache = (_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateEventName, "localStorage");
|
|
378
385
|
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
379
386
|
return persistedState;
|
|
@@ -408,4 +415,10 @@ const addDelayInMs = ms => {
|
|
|
408
415
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
409
416
|
};
|
|
410
417
|
|
|
411
|
-
exports.addDelayInMs = addDelayInMs;
|
|
418
|
+
exports.addDelayInMs = addDelayInMs;
|
|
419
|
+
|
|
420
|
+
const getBroadcastChannelName = (widgetId, widgetInstanceId) => {
|
|
421
|
+
return widgetInstanceId && !isNullOrEmptyString(widgetInstanceId) ? `${widgetInstanceId}_${widgetId}` : widgetId;
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
exports.getBroadcastChannelName = getBroadcastChannelName;
|
|
@@ -72,7 +72,8 @@ const HeaderStateful = props => {
|
|
|
72
72
|
} else {
|
|
73
73
|
const skipEndChatSDK = true;
|
|
74
74
|
const skipCloseChat = false;
|
|
75
|
-
|
|
75
|
+
const postMessageToOtherTabs = true;
|
|
76
|
+
await endChat(adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTabs);
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
dispatch({
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ActivityStreamHandler = void 0;
|
|
7
|
+
|
|
8
|
+
var _Deferred = require("./Deferred");
|
|
9
|
+
|
|
10
|
+
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; }
|
|
11
|
+
|
|
12
|
+
class ActivityStreamHandler {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Use of a deferred pattern, to hold the execution of the activity.
|
|
18
|
+
*
|
|
19
|
+
* */
|
|
20
|
+
static cork() {
|
|
21
|
+
ActivityStreamHandler.restoreDeferred = new _Deferred.Deferred();
|
|
22
|
+
ActivityStreamHandler.restorePromise = ActivityStreamHandler.restoreDeferred.promise;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Resolve the promise, releasing it to continue with the execution of the activity.
|
|
26
|
+
*
|
|
27
|
+
* */
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
static uncork() {
|
|
31
|
+
ActivityStreamHandler.restoreDeferred.resolve();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
exports.ActivityStreamHandler = ActivityStreamHandler;
|
|
37
|
+
|
|
38
|
+
_defineProperty(ActivityStreamHandler, "restoreDeferred", {
|
|
39
|
+
resolve: () => {
|
|
40
|
+
return "initialState";
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
_defineProperty(ActivityStreamHandler, "restorePromise", void 0);
|
package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PauseActivitySubscriber = void 0;
|
|
7
|
+
|
|
8
|
+
var _ActivityStreamHandler = require("../ActivityStreamHandler");
|
|
9
|
+
|
|
10
|
+
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; }
|
|
11
|
+
|
|
12
|
+
class PauseActivitySubscriber {
|
|
13
|
+
constructor() {
|
|
14
|
+
_defineProperty(this, "observer", void 0);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
async apply(activity) {
|
|
19
|
+
await _ActivityStreamHandler.ActivityStreamHandler.restorePromise;
|
|
20
|
+
return activity;
|
|
21
|
+
} // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
applicable(activity) {
|
|
25
|
+
return true;
|
|
26
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
async next(activity) {
|
|
30
|
+
if (this.applicable(activity)) {
|
|
31
|
+
return await this.apply(activity);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return activity;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
exports.PauseActivitySubscriber = PauseActivitySubscriber;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Deferred = 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 Deferred {
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
constructor() {
|
|
13
|
+
_defineProperty(this, "_promise", void 0);
|
|
14
|
+
|
|
15
|
+
_defineProperty(this, "_resolve", void 0);
|
|
16
|
+
|
|
17
|
+
_defineProperty(this, "_reject", () => {
|
|
18
|
+
return;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
_defineProperty(this, "resolve", value => {
|
|
22
|
+
this._resolve(value);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
_defineProperty(this, "reject", value => {
|
|
26
|
+
this._reject(value);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
this._promise = new Promise((resolve, reject) => {
|
|
30
|
+
this._resolve = resolve;
|
|
31
|
+
this._reject = reject;
|
|
32
|
+
});
|
|
33
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
get promise() {
|
|
37
|
+
return this._promise;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
exports.Deferred = Deferred;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.removeAuthTokenProvider = exports.handleAuthentication = void 0;
|
|
7
|
+
|
|
8
|
+
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
9
|
+
|
|
10
|
+
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
11
|
+
|
|
12
|
+
var _utils = require("../../../common/utils");
|
|
13
|
+
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
const handleAuthentication = async (chatSDK, chatConfig, getAuthToken) => {
|
|
16
|
+
let authClientFunction = undefined;
|
|
17
|
+
|
|
18
|
+
if (chatConfig !== null && chatConfig !== void 0 && chatConfig.LiveChatConfigAuthSettings) {
|
|
19
|
+
var _chatConfig$LiveChatC;
|
|
20
|
+
|
|
21
|
+
authClientFunction = (chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig$LiveChatC = chatConfig.LiveChatConfigAuthSettings) === null || _chatConfig$LiveChatC === void 0 ? void 0 : _chatConfig$LiveChatC.msdyn_javascriptclientfunction) ?? undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (getAuthToken && authClientFunction) {
|
|
25
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
26
|
+
Event: _TelemetryConstants.TelemetryEvent.GetAuthTokenCalled
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const token = await getAuthToken(authClientFunction);
|
|
30
|
+
|
|
31
|
+
if (!(0, _utils.isNullOrEmptyString)(token)) {
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
+
chatSDK.setAuthTokenProvider(async () => {
|
|
34
|
+
return token;
|
|
35
|
+
});
|
|
36
|
+
} else {
|
|
37
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
38
|
+
Event: _TelemetryConstants.TelemetryEvent.ReceivedNullOrEmptyToken
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
exports.handleAuthentication = handleAuthentication;
|
|
46
|
+
|
|
47
|
+
const removeAuthTokenProvider = chatSDK => {
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
+
chatSDK.authenticatedUserToken = null;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
exports.removeAuthTokenProvider = removeAuthTokenProvider;
|
|
@@ -15,6 +15,8 @@ var _defaultMiddlewareLocalizedTexts = require("../../webchatcontainerstateful/c
|
|
|
15
15
|
|
|
16
16
|
var _ChatAdapterShim = require("./ChatAdapterShim");
|
|
17
17
|
|
|
18
|
+
var _PauseActivitySubscriber = require("./ActivitySubscriber/PauseActivitySubscriber");
|
|
19
|
+
|
|
18
20
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
21
|
const createAdapter = async chatSDK => {
|
|
20
22
|
const chatAdapterOptionalParams = {
|
|
@@ -40,6 +42,8 @@ const createAdapter = async chatSDK => {
|
|
|
40
42
|
|
|
41
43
|
if (chatSDK.isMockModeOn !== true) {
|
|
42
44
|
adapter = new _ChatAdapterShim.ChatAdapterShim(adapter);
|
|
45
|
+
adapter.addSubscriber(new _PauseActivitySubscriber.PauseActivitySubscriber());
|
|
46
|
+
return adapter.chatAdapter;
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
return adapter;
|
|
@@ -339,7 +339,8 @@ const dummyDefaultProps = {
|
|
|
339
339
|
hideChatTitle: false,
|
|
340
340
|
hideNotificationBubble: true,
|
|
341
341
|
unreadMessageString: "new messages",
|
|
342
|
-
largeUnreadMessageString: "99+"
|
|
342
|
+
largeUnreadMessageString: "99+",
|
|
343
|
+
ariaLabelUnreadMessageString: "you have new messages"
|
|
343
344
|
},
|
|
344
345
|
styleProps: {
|
|
345
346
|
generalStyleProps: {
|
|
@@ -1702,12 +1703,13 @@ const dummyDefaultProps = {
|
|
|
1702
1703
|
botMagicCode: {
|
|
1703
1704
|
disabled: false,
|
|
1704
1705
|
fwdUrl: ""
|
|
1706
|
+
},
|
|
1707
|
+
adaptiveCardStyles: {
|
|
1708
|
+
background: "white",
|
|
1709
|
+
color: "black"
|
|
1705
1710
|
}
|
|
1706
1711
|
},
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
setAuthTokenProviderToChatSdk: undefined
|
|
1710
|
-
},
|
|
1711
|
-
telemetryConfig: undefined
|
|
1712
|
+
telemetryConfig: undefined,
|
|
1713
|
+
getAuthToken: undefined
|
|
1712
1714
|
};
|
|
1713
1715
|
exports.dummyDefaultProps = dummyDefaultProps;
|
|
@@ -48,7 +48,7 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
|
|
|
48
48
|
if (isPostChatEnabled === "true" && ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.canRenderPostChat) === _Constants.Constants.truePascal) {
|
|
49
49
|
const skipEndChatSDK = false;
|
|
50
50
|
const skipCloseChat = true;
|
|
51
|
-
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat,
|
|
51
|
+
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, false);
|
|
52
52
|
|
|
53
53
|
if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
|
|
54
54
|
dispatch({
|
|
@@ -151,9 +151,9 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
151
151
|
});
|
|
152
152
|
|
|
153
153
|
if (postMessageToOtherTab) {
|
|
154
|
-
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2;
|
|
154
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$controlProps;
|
|
155
155
|
|
|
156
|
-
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(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);
|
|
156
|
+
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(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, (props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.widgetInstanceId) ?? "");
|
|
157
157
|
|
|
158
158
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
159
159
|
eventName: endChatEventName
|
|
@@ -125,6 +125,10 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
|
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
} else {
|
|
128
|
+
dispatch({
|
|
129
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
130
|
+
payload: _ConversationState.ConversationState.InActive
|
|
131
|
+
});
|
|
128
132
|
dispatch({
|
|
129
133
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
|
|
130
134
|
payload: true
|
|
@@ -17,24 +17,34 @@ var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidget
|
|
|
17
17
|
|
|
18
18
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
19
19
|
|
|
20
|
+
var _authHelper = require("./authHelper");
|
|
21
|
+
|
|
20
22
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
-
const getChatReconnectContext = async (chatSDK, reconnectId) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
const getChatReconnectContext = async (chatSDK, chatConfig, getAuthToken, isReconnectEnabled, reconnectId) => {
|
|
24
|
+
if (isReconnectEnabled) {
|
|
25
|
+
try {
|
|
26
|
+
if (reconnectId) {
|
|
27
|
+
const chatReconnectOptionalParams = {
|
|
28
|
+
reconnectId: reconnectId
|
|
29
|
+
};
|
|
30
|
+
return await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatReconnectContext(chatReconnectOptionalParams));
|
|
31
|
+
} else {
|
|
32
|
+
// set auth token to chat sdk to get reconnectId for auth chat
|
|
33
|
+
await (0, _authHelper.handleAuthentication)(chatSDK, chatConfig, getAuthToken);
|
|
34
|
+
const reconnectChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatReconnectContext()); // remove auth token after reconnectId is fetched
|
|
35
|
+
// this will be reset later at start chat
|
|
36
|
+
|
|
37
|
+
(0, _authHelper.removeAuthTokenProvider)(chatSDK);
|
|
38
|
+
return reconnectChatContext;
|
|
36
39
|
}
|
|
37
|
-
})
|
|
40
|
+
} catch (ex) {
|
|
41
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
42
|
+
Event: _TelemetryConstants.TelemetryEvent.GetChatReconnectContextSDKCallFailed,
|
|
43
|
+
ExceptionDetails: {
|
|
44
|
+
exception: ex
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
return null;
|
|
@@ -44,13 +54,23 @@ const getChatReconnectContext = async (chatSDK, reconnectId) => {
|
|
|
44
54
|
exports.getChatReconnectContext = getChatReconnectContext;
|
|
45
55
|
|
|
46
56
|
const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
|
|
47
|
-
var _props$
|
|
57
|
+
var _props$chatConfig, _props$reconnectChatP;
|
|
58
|
+
|
|
59
|
+
let authClientFunction = undefined;
|
|
48
60
|
|
|
49
|
-
if ((_props$
|
|
61
|
+
if ((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && _props$chatConfig.LiveChatConfigAuthSettings) {
|
|
62
|
+
var _props$chatConfig2, _props$chatConfig2$Li;
|
|
63
|
+
|
|
64
|
+
authClientFunction = ((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveChatConfigAuthSettings) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_javascriptclientfunction) ?? undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && authClientFunction // TODO: Implement this after storage is in place
|
|
50
68
|
|
|
51
69
|
/* && !isLoadWithState() */
|
|
52
70
|
) {
|
|
53
|
-
|
|
71
|
+
var _props$reconnectChatP2;
|
|
72
|
+
|
|
73
|
+
const previousActiveSessionResponse = await getChatReconnectContext(chatSDK, props.chatConfig, props.getAuthToken, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.isReconnectEnabled);
|
|
54
74
|
|
|
55
75
|
if (previousActiveSessionResponse && previousActiveSessionResponse.reconnectId) {
|
|
56
76
|
return previousActiveSessionResponse.reconnectId;
|
|
@@ -63,31 +83,31 @@ const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
|
|
|
63
83
|
|
|
64
84
|
exports.getReconnectIdForAuthenticatedChat = getReconnectIdForAuthenticatedChat;
|
|
65
85
|
|
|
66
|
-
const handleUnauthenticatedReconnectChat = async (chatSDK,
|
|
67
|
-
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
86
|
+
const handleUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, isReconnectEnabled, reconnectId, initStartChat, redirectInSameWindow) => {
|
|
87
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, chatConfig, getAuthToken, isReconnectEnabled, reconnectId);
|
|
68
88
|
|
|
69
89
|
if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
70
|
-
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK,
|
|
90
|
+
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
71
91
|
} else {
|
|
72
|
-
await setReconnectIdAndStartChat(chatSDK,
|
|
92
|
+
await setReconnectIdAndStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat);
|
|
73
93
|
}
|
|
74
94
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
95
|
|
|
76
96
|
|
|
77
97
|
exports.handleUnauthenticatedReconnectChat = handleUnauthenticatedReconnectChat;
|
|
78
98
|
|
|
79
|
-
const startUnauthenticatedReconnectChat = async (chatSDK,
|
|
80
|
-
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
99
|
+
const startUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, isReconnectEnabled, reconnectId, initStartChat) => {
|
|
100
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, chatConfig, getAuthToken, isReconnectEnabled, reconnectId);
|
|
81
101
|
|
|
82
102
|
if (!shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
83
|
-
await setReconnectIdAndStartChat(chatSDK,
|
|
103
|
+
await setReconnectIdAndStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat);
|
|
84
104
|
}
|
|
85
105
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
106
|
|
|
87
107
|
|
|
88
108
|
exports.startUnauthenticatedReconnectChat = startUnauthenticatedReconnectChat;
|
|
89
109
|
|
|
90
|
-
const setReconnectIdAndStartChat = async (chatSDK,
|
|
110
|
+
const setReconnectIdAndStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
91
111
|
const startUnauthenticatedReconnectChat = {
|
|
92
112
|
eventName: _TelemetryConstants.BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
93
113
|
};
|
|
@@ -105,7 +125,7 @@ const setReconnectIdAndStartChat = async (chatSDK, authProps, dispatch, setAdapt
|
|
|
105
125
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
106
126
|
payload: _ConversationState.ConversationState.Loading
|
|
107
127
|
});
|
|
108
|
-
await initStartChat(chatSDK,
|
|
128
|
+
await initStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, optionalParams);
|
|
109
129
|
};
|
|
110
130
|
|
|
111
131
|
const redirectPage = (redirectURL, redirectInSameWindow) => {
|
|
@@ -128,7 +148,7 @@ const shouldRedirectOrStartNewChat = reconnectAvailabilityResponse => {
|
|
|
128
148
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
129
149
|
|
|
130
150
|
|
|
131
|
-
const startNewChatEmptyRedirectionUrl = async (chatSDK,
|
|
151
|
+
const startNewChatEmptyRedirectionUrl = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat) => {
|
|
132
152
|
const startUnauthenticatedReconnectChat = {
|
|
133
153
|
eventName: _TelemetryConstants.BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
134
154
|
};
|
|
@@ -153,26 +173,26 @@ const startNewChatEmptyRedirectionUrl = async (chatSDK, authProps, dispatch, set
|
|
|
153
173
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
154
174
|
payload: _ConversationState.ConversationState.Loading
|
|
155
175
|
});
|
|
156
|
-
await initStartChat(chatSDK,
|
|
176
|
+
await initStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter);
|
|
157
177
|
}
|
|
158
178
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
159
179
|
|
|
160
180
|
|
|
161
|
-
const handleRedirectUnauthenticatedReconnectChat = async (chatSDK,
|
|
162
|
-
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
181
|
+
const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, isReconnectEnabled, reconnectId, redirectInSameWindow) => {
|
|
182
|
+
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, chatConfig, getAuthToken, isReconnectEnabled, reconnectId);
|
|
163
183
|
|
|
164
184
|
if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
165
|
-
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK,
|
|
185
|
+
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
166
186
|
}
|
|
167
187
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
168
188
|
|
|
169
189
|
|
|
170
190
|
exports.handleRedirectUnauthenticatedReconnectChat = handleRedirectUnauthenticatedReconnectChat;
|
|
171
191
|
|
|
172
|
-
const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK,
|
|
192
|
+
const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
|
|
173
193
|
if (reconnectAvailabilityResponse.redirectURL) {
|
|
174
194
|
redirectPage(reconnectAvailabilityResponse.redirectURL, redirectInSameWindow);
|
|
175
195
|
} else {
|
|
176
|
-
await startNewChatEmptyRedirectionUrl(chatSDK,
|
|
196
|
+
await startNewChatEmptyRedirectionUrl(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat);
|
|
177
197
|
}
|
|
178
198
|
};
|