@microsoft/omnichannel-chat-widget 1.0.4-main.6e79f24 → 1.0.4-main.ade1159
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 +3 -0
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +0 -4
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +0 -3
- package/lib/cjs/components/livechatwidget/common/startChat.js +41 -4
- package/lib/esm/common/Constants.js +3 -0
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +0 -3
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +0 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +41 -4
- package/lib/types/common/Constants.d.ts +1 -0
- package/package.json +1 -1
|
@@ -112,6 +112,9 @@ _defineProperty(Constants, "SessionCacheSuffix", "session");
|
|
|
112
112
|
_defineProperty(Constants, "PopoutCacheSuffix", "popout");
|
|
113
113
|
// Visibility timeout for conversation details
|
|
114
114
|
_defineProperty(Constants, "LWICheckOnVisibilityTimeout", 3 * 60 * 1000);
|
|
115
|
+
// 3 minute
|
|
116
|
+
// Popup mode custom context response event message name
|
|
117
|
+
_defineProperty(Constants, "InitContextParamsResponse", "initContextParamsResponse");
|
|
115
118
|
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);
|
|
116
119
|
exports.Regex = Regex;
|
|
117
120
|
class HtmlIdNames {}
|
package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js
CHANGED
|
@@ -9,8 +9,6 @@ var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcont
|
|
|
9
9
|
var _NotificationHandler = require("../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler");
|
|
10
10
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
11
11
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
12
|
-
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
12
|
const processDisplayName = displayName => {
|
|
15
13
|
// if displayname matches "teamsvisitor:<some alphanumeric string>", we replace it with "Customer"
|
|
16
14
|
const displayNameRegex = ".+:.+";
|
|
@@ -66,8 +64,6 @@ const processContent = (transcriptContent, isAgentChat, renderMarkDown) => {
|
|
|
66
64
|
}
|
|
67
65
|
if (renderMarkDown) {
|
|
68
66
|
transcriptContent = renderMarkDown(transcriptContent);
|
|
69
|
-
} else {
|
|
70
|
-
transcriptContent = _dompurify.default.sanitize(transcriptContent);
|
|
71
67
|
}
|
|
72
68
|
return transcriptContent;
|
|
73
69
|
};
|
|
@@ -35,7 +35,6 @@ var _messageTimestampMiddleware = _interopRequireDefault(require("../../webchatc
|
|
|
35
35
|
var _Constants = require("../../../common/Constants");
|
|
36
36
|
var _endChat = require("./endChat");
|
|
37
37
|
var _HyperlinkTextOverrideRenderer = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer"));
|
|
38
|
-
var _dompurify = _interopRequireDefault(require("dompurify"));
|
|
39
38
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
40
39
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
40
|
const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
@@ -92,8 +91,6 @@ const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
|
92
91
|
markdownRenderers.forEach(renderer => {
|
|
93
92
|
text = renderer.render(text);
|
|
94
93
|
});
|
|
95
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
96
|
-
text = _dompurify.default.sanitize(text);
|
|
97
94
|
return text;
|
|
98
95
|
};
|
|
99
96
|
|
|
@@ -130,7 +130,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
130
130
|
try {
|
|
131
131
|
var _window$Microsoft, _window$Microsoft$Dyn, _window$Microsoft$Dyn2, _window$Microsoft$Dyn3;
|
|
132
132
|
// Set custom context params
|
|
133
|
-
setCustomContextParams(props);
|
|
133
|
+
await setCustomContextParams(props);
|
|
134
134
|
const defaultOptionalParams = {
|
|
135
135
|
sendDefaultInitContext: true,
|
|
136
136
|
isProactiveChat: !!(params !== null && params !== void 0 && params.isProactiveChat),
|
|
@@ -286,7 +286,7 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
|
|
|
286
286
|
};
|
|
287
287
|
|
|
288
288
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
289
|
-
const setCustomContextParams = props => {
|
|
289
|
+
const setCustomContextParams = async props => {
|
|
290
290
|
var _props$chatConfig, _props$chatConfig$Liv, _persistedState$domai8;
|
|
291
291
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
292
292
|
const isAuthenticatedChat = props !== null && props !== void 0 && (_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction ? true : false;
|
|
@@ -303,11 +303,18 @@ const setCustomContextParams = props => {
|
|
|
303
303
|
var _persistedState$domai9;
|
|
304
304
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
305
305
|
Event: _TelemetryConstants.TelemetryEvent.SetCustomContext,
|
|
306
|
-
Description: "Setting custom context for
|
|
306
|
+
Description: "Setting custom context for unauthenticated chat"
|
|
307
307
|
});
|
|
308
308
|
optionalParams = Object.assign({}, optionalParams, {
|
|
309
309
|
customContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai9 = persistedState.domainStates) === null || _persistedState$domai9 === void 0 ? void 0 : _persistedState$domai9.customContext
|
|
310
310
|
});
|
|
311
|
+
} else {
|
|
312
|
+
const customContextFromParent = await getInitContextParamsForPopout();
|
|
313
|
+
if (!(0, _utils.isUndefinedOrEmpty)(customContextFromParent === null || customContextFromParent === void 0 ? void 0 : customContextFromParent.contextVariables)) {
|
|
314
|
+
optionalParams = Object.assign({}, optionalParams, {
|
|
315
|
+
customContext: customContextFromParent.contextVariables
|
|
316
|
+
});
|
|
317
|
+
}
|
|
311
318
|
}
|
|
312
319
|
};
|
|
313
320
|
const canStartPopoutChat = async props => {
|
|
@@ -369,4 +376,34 @@ const checkIfConversationStillValid = async (chatSDK, dispatch, state) => {
|
|
|
369
376
|
return false;
|
|
370
377
|
}
|
|
371
378
|
};
|
|
372
|
-
|
|
379
|
+
|
|
380
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
381
|
+
exports.checkIfConversationStillValid = checkIfConversationStillValid;
|
|
382
|
+
const getInitContextParamsForPopout = async () => {
|
|
383
|
+
return window.opener ? await getInitContextParamForPopoutFromOuterScope(window.opener) : null;
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
387
|
+
const getInitContextParamForPopoutFromOuterScope = async scope => {
|
|
388
|
+
let payload;
|
|
389
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
390
|
+
let waitPromiseResolve;
|
|
391
|
+
const waitPromise = new Promise((res, rej) => {
|
|
392
|
+
waitPromiseResolve = res;
|
|
393
|
+
setTimeout(() => rej("Failed to find method in outer scope"), 5000);
|
|
394
|
+
}).catch(rej => console.warn(rej));
|
|
395
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
396
|
+
const getInitContextParamsFromParent = e => {
|
|
397
|
+
if (e.data && e.data.messageName == _Constants.Constants.InitContextParamsResponse) {
|
|
398
|
+
payload = e.data.payload;
|
|
399
|
+
waitPromiseResolve();
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
window.addEventListener("message", getInitContextParamsFromParent, false);
|
|
403
|
+
scope.postMessage({
|
|
404
|
+
messageName: _Constants.Constants.InitContextParamsResponse
|
|
405
|
+
}, "*");
|
|
406
|
+
await waitPromise;
|
|
407
|
+
window.removeEventListener("message", getInitContextParamsFromParent, false);
|
|
408
|
+
return payload;
|
|
409
|
+
};
|
|
@@ -105,6 +105,9 @@ _defineProperty(Constants, "SessionCacheSuffix", "session");
|
|
|
105
105
|
_defineProperty(Constants, "PopoutCacheSuffix", "popout");
|
|
106
106
|
// Visibility timeout for conversation details
|
|
107
107
|
_defineProperty(Constants, "LWICheckOnVisibilityTimeout", 3 * 60 * 1000);
|
|
108
|
+
// 3 minute
|
|
109
|
+
// Popup mode custom context response event message name
|
|
110
|
+
_defineProperty(Constants, "InitContextParamsResponse", "initContextParamsResponse");
|
|
108
111
|
export 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);
|
|
109
112
|
export class HtmlIdNames {}
|
|
110
113
|
_defineProperty(HtmlIdNames, "MSLiveChatWidget", "MSLiveChatWidget");
|
package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js
CHANGED
|
@@ -3,7 +3,6 @@ import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcon
|
|
|
3
3
|
import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
|
|
4
4
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
5
5
|
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
6
|
-
import DOMPurify from "dompurify";
|
|
7
6
|
const processDisplayName = displayName => {
|
|
8
7
|
// if displayname matches "teamsvisitor:<some alphanumeric string>", we replace it with "Customer"
|
|
9
8
|
const displayNameRegex = ".+:.+";
|
|
@@ -59,8 +58,6 @@ const processContent = (transcriptContent, isAgentChat, renderMarkDown) => {
|
|
|
59
58
|
}
|
|
60
59
|
if (renderMarkDown) {
|
|
61
60
|
transcriptContent = renderMarkDown(transcriptContent);
|
|
62
|
-
} else {
|
|
63
|
-
transcriptContent = DOMPurify.sanitize(transcriptContent);
|
|
64
61
|
}
|
|
65
62
|
return transcriptContent;
|
|
66
63
|
};
|
|
@@ -29,7 +29,6 @@ import createMessageTimeStampMiddleware from "../../webchatcontainerstateful/web
|
|
|
29
29
|
import { ConversationEndEntity, ParticipantType } from "../../../common/Constants";
|
|
30
30
|
import { getConversationDetails } from "./endChat";
|
|
31
31
|
import HyperlinkTextOverrideRenderer from "../../webchatcontainerstateful/webchatcontroller/markdownrenderers/HyperlinkTextOverrideRenderer";
|
|
32
|
-
import DOMPurify from "dompurify";
|
|
33
32
|
|
|
34
33
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
34
|
export const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
@@ -86,8 +85,6 @@ export const initWebChatComposer = (props, state, dispatch, chatSDK) => {
|
|
|
86
85
|
markdownRenderers.forEach(renderer => {
|
|
87
86
|
text = renderer.render(text);
|
|
88
87
|
});
|
|
89
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
90
|
-
text = DOMPurify.sanitize(text);
|
|
91
88
|
return text;
|
|
92
89
|
};
|
|
93
90
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
2
|
-
import { ChatSDKError, LiveWorkItemState } from "../../../common/Constants";
|
|
2
|
+
import { ChatSDKError, Constants, LiveWorkItemState } from "../../../common/Constants";
|
|
3
3
|
import { createTimer, getStateFromCache, getWidgetCacheIdfromProps, isNullOrEmptyString, isUndefinedOrEmpty } from "../../../common/utils";
|
|
4
4
|
import { getAuthClientFunction, handleAuthentication } from "./authHelper";
|
|
5
5
|
import { ActivityStreamHandler } from "./ActivityStreamHandler";
|
|
@@ -123,7 +123,7 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, props, params, persi
|
|
|
123
123
|
try {
|
|
124
124
|
var _window$Microsoft, _window$Microsoft$Dyn, _window$Microsoft$Dyn2, _window$Microsoft$Dyn3;
|
|
125
125
|
// Set custom context params
|
|
126
|
-
setCustomContextParams(props);
|
|
126
|
+
await setCustomContextParams(props);
|
|
127
127
|
const defaultOptionalParams = {
|
|
128
128
|
sendDefaultInitContext: true,
|
|
129
129
|
isProactiveChat: !!(params !== null && params !== void 0 && params.isProactiveChat),
|
|
@@ -278,7 +278,7 @@ const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdap
|
|
|
278
278
|
};
|
|
279
279
|
|
|
280
280
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
281
|
-
const setCustomContextParams = props => {
|
|
281
|
+
const setCustomContextParams = async props => {
|
|
282
282
|
var _props$chatConfig, _props$chatConfig$Liv, _persistedState$domai8;
|
|
283
283
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
284
284
|
const isAuthenticatedChat = props !== null && props !== void 0 && (_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && (_props$chatConfig$Liv = _props$chatConfig.LiveChatConfigAuthSettings) !== null && _props$chatConfig$Liv !== void 0 && _props$chatConfig$Liv.msdyn_javascriptclientfunction ? true : false;
|
|
@@ -295,11 +295,18 @@ const setCustomContextParams = props => {
|
|
|
295
295
|
var _persistedState$domai9;
|
|
296
296
|
TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
|
|
297
297
|
Event: TelemetryEvent.SetCustomContext,
|
|
298
|
-
Description: "Setting custom context for
|
|
298
|
+
Description: "Setting custom context for unauthenticated chat"
|
|
299
299
|
});
|
|
300
300
|
optionalParams = Object.assign({}, optionalParams, {
|
|
301
301
|
customContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai9 = persistedState.domainStates) === null || _persistedState$domai9 === void 0 ? void 0 : _persistedState$domai9.customContext
|
|
302
302
|
});
|
|
303
|
+
} else {
|
|
304
|
+
const customContextFromParent = await getInitContextParamsForPopout();
|
|
305
|
+
if (!isUndefinedOrEmpty(customContextFromParent === null || customContextFromParent === void 0 ? void 0 : customContextFromParent.contextVariables)) {
|
|
306
|
+
optionalParams = Object.assign({}, optionalParams, {
|
|
307
|
+
customContext: customContextFromParent.contextVariables
|
|
308
|
+
});
|
|
309
|
+
}
|
|
303
310
|
}
|
|
304
311
|
};
|
|
305
312
|
const canStartPopoutChat = async props => {
|
|
@@ -361,4 +368,34 @@ const checkIfConversationStillValid = async (chatSDK, dispatch, state) => {
|
|
|
361
368
|
return false;
|
|
362
369
|
}
|
|
363
370
|
};
|
|
371
|
+
|
|
372
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
373
|
+
const getInitContextParamsForPopout = async () => {
|
|
374
|
+
return window.opener ? await getInitContextParamForPopoutFromOuterScope(window.opener) : null;
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
378
|
+
const getInitContextParamForPopoutFromOuterScope = async scope => {
|
|
379
|
+
let payload;
|
|
380
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
381
|
+
let waitPromiseResolve;
|
|
382
|
+
const waitPromise = new Promise((res, rej) => {
|
|
383
|
+
waitPromiseResolve = res;
|
|
384
|
+
setTimeout(() => rej("Failed to find method in outer scope"), 5000);
|
|
385
|
+
}).catch(rej => console.warn(rej));
|
|
386
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
387
|
+
const getInitContextParamsFromParent = e => {
|
|
388
|
+
if (e.data && e.data.messageName == Constants.InitContextParamsResponse) {
|
|
389
|
+
payload = e.data.payload;
|
|
390
|
+
waitPromiseResolve();
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
window.addEventListener("message", getInitContextParamsFromParent, false);
|
|
394
|
+
scope.postMessage({
|
|
395
|
+
messageName: Constants.InitContextParamsResponse
|
|
396
|
+
}, "*");
|
|
397
|
+
await waitPromise;
|
|
398
|
+
window.removeEventListener("message", getInitContextParamsFromParent, false);
|
|
399
|
+
return payload;
|
|
400
|
+
};
|
|
364
401
|
export { prepareStartChat, initStartChat, setPreChatAndInitiateChat, checkIfConversationStillValid };
|
|
@@ -84,6 +84,7 @@ export declare class Constants {
|
|
|
84
84
|
static readonly SessionCacheSuffix = "session";
|
|
85
85
|
static readonly PopoutCacheSuffix = "popout";
|
|
86
86
|
static readonly LWICheckOnVisibilityTimeout: number;
|
|
87
|
+
static readonly InitContextParamsResponse = "initContextParamsResponse";
|
|
87
88
|
}
|
|
88
89
|
export declare const Regex: {
|
|
89
90
|
new (): {};
|