@microsoft/omnichannel-chat-sdk 1.11.7-main.b4e455c → 1.11.7-main.f31f9b6
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/OmnichannelChatSDK.d.ts +9 -1
- package/lib/OmnichannelChatSDK.js +158 -99
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/config/settings.d.ts +3 -2
- package/lib/config/settings.js +4 -2
- package/lib/config/settings.js.map +1 -1
- package/lib/core/ChatSDKError.d.ts +3 -1
- package/lib/core/ChatSDKError.js +2 -0
- package/lib/core/ChatSDKError.js.map +1 -1
- package/lib/core/GetPersistentChatHistoryOptionalParams.d.ts +10 -0
- package/lib/core/GetPersistentChatHistoryOptionalParams.js +3 -0
- package/lib/core/GetPersistentChatHistoryOptionalParams.js.map +1 -0
- package/lib/core/messaging/OmnichannelMessage.d.ts +6 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js.map +1 -1
- package/lib/telemetry/TelemetryEvent.d.ts +2 -1
- package/lib/telemetry/TelemetryEvent.js +1 -0
- package/lib/telemetry/TelemetryEvent.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/createOcSDKConfiguration.d.ts +2 -2
- package/lib/utils/createOcSDKConfiguration.js +16 -2
- package/lib/utils/createOcSDKConfiguration.js.map +1 -1
- package/lib/utils/createOmnichannelMessage.js +9 -0
- package/lib/utils/createOmnichannelMessage.js.map +1 -1
- package/lib/utils/exceptionThrowers.d.ts +6 -0
- package/lib/utils/exceptionThrowers.js +8 -2
- package/lib/utils/exceptionThrowers.js.map +1 -1
- package/lib/utils/setOcUserAgent.js +2 -1
- package/lib/utils/setOcUserAgent.js.map +1 -1
- package/lib/utils/version.d.ts +9 -0
- package/lib/utils/version.js +28 -0
- package/lib/utils/version.js.map +1 -0
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ACSClient from "./core/messaging/ACSClient";
|
|
2
2
|
import { VoiceVideoCallingOptionalParams } from "./types/config";
|
|
3
|
-
import { ChatAdapter, GetAgentAvailabilityResponse, GetCurrentLiveChatContextResponse, GetLiveChatTranscriptResponse, GetMessagesResponse, GetPreChatSurveyResponse, GetVoiceVideoCallingResponse, MaskingRules, UploadFileAttachmentResponse } from "./types/response";
|
|
3
|
+
import { ChatAdapter, GetAgentAvailabilityResponse, GetCurrentLiveChatContextResponse, GetLiveChatTranscriptResponse, GetMessagesResponse, GetPersistentChatHistoryResponse, GetPreChatSurveyResponse, GetVoiceVideoCallingResponse, MaskingRules, UploadFileAttachmentResponse } from "./types/response";
|
|
4
4
|
import { ParticipantsRemovedEvent } from '@azure/communication-signaling';
|
|
5
5
|
import ChatAdapterOptionalParams from "./core/messaging/ChatAdapterOptionalParams";
|
|
6
6
|
import ChatConfig from "./core/ChatConfig";
|
|
@@ -21,6 +21,7 @@ import GetChatTokenOptionalParams from "./core/GetChatTokenOptionalParams";
|
|
|
21
21
|
import GetConversationDetailsOptionalParams from "./core/GetConversationDetailsOptionalParams";
|
|
22
22
|
import GetLiveChatConfigOptionalParams from "./core/GetLiveChatConfigOptionalParams";
|
|
23
23
|
import GetLiveChatTranscriptOptionalParams from "./core/GetLiveChatTranscriptOptionalParams";
|
|
24
|
+
import GetPersistentChatHistoryOptionalParams from "./core/GetPersistentChatHistoryOptionalParams";
|
|
24
25
|
import IChatToken from "./external/IC3Adapter/IChatToken";
|
|
25
26
|
import IFileInfo from "@microsoft/omnichannel-ic3core/lib/interfaces/IFileInfo";
|
|
26
27
|
import IFileMetadata from "@microsoft/omnichannel-ic3core/lib/model/IFileMetadata";
|
|
@@ -83,6 +84,7 @@ declare class OmnichannelChatSDK {
|
|
|
83
84
|
private debugAMS;
|
|
84
85
|
private debugACS;
|
|
85
86
|
private detailedDebugEnabled;
|
|
87
|
+
private regexCompiledForDataMasking;
|
|
86
88
|
constructor(omnichannelConfig: OmnichannelConfig, chatSDKConfig?: ChatSDKConfig);
|
|
87
89
|
/**
|
|
88
90
|
* Executes an operation with mutual exclusion to prevent race conditions
|
|
@@ -164,6 +166,7 @@ declare class OmnichannelChatSDK {
|
|
|
164
166
|
private getIC3Client;
|
|
165
167
|
private setPrechatConfigurations;
|
|
166
168
|
private setDataMaskingConfiguration;
|
|
169
|
+
private compileDataMaskingRegex;
|
|
167
170
|
private setAuthSettingConfig;
|
|
168
171
|
private setPersistentChatConfiguration;
|
|
169
172
|
private setLocaleIdConfiguration;
|
|
@@ -186,5 +189,10 @@ declare class OmnichannelChatSDK {
|
|
|
186
189
|
* @private
|
|
187
190
|
*/
|
|
188
191
|
private handleConversationJoinFailure;
|
|
192
|
+
/**
|
|
193
|
+
* Get persistent chat history for authenticated users.
|
|
194
|
+
* @param getPersistentChatHistoryOptionalParams Optional parameters for persistent chat history retrieval.
|
|
195
|
+
*/
|
|
196
|
+
getPersistentChatHistory(getPersistentChatHistoryOptionalParams?: GetPersistentChatHistoryOptionalParams): Promise<GetPersistentChatHistoryResponse | undefined>;
|
|
189
197
|
}
|
|
190
198
|
export default OmnichannelChatSDK;
|
|
@@ -105,7 +105,6 @@ var loggerUtils_1 = require("./utils/loggerUtils");
|
|
|
105
105
|
var parsers_1 = require("./utils/parsers");
|
|
106
106
|
var platform_1 = require("./utils/platform");
|
|
107
107
|
var retrieveCollectorUri_1 = require("./telemetry/retrieveCollectorUri");
|
|
108
|
-
var setOcUserAgent_1 = require("./utils/setOcUserAgent");
|
|
109
108
|
var startPolling_1 = require("./commands/startPolling");
|
|
110
109
|
var stopPolling_1 = require("./commands/stopPolling");
|
|
111
110
|
var urlResolvers_1 = require("./utils/urlResolvers");
|
|
@@ -150,6 +149,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
150
149
|
this.debugAMS = false;
|
|
151
150
|
this.debugACS = false;
|
|
152
151
|
this.detailedDebugEnabled = false;
|
|
152
|
+
this.regexCompiledForDataMasking = [];
|
|
153
153
|
this.populateInitChatOptionalParam = function (requestOptionalParams, optionalParams, telemetryEvent) {
|
|
154
154
|
requestOptionalParams.initContext.locale = (0, locale_1.getLocaleStringFromId)(_this.localeId);
|
|
155
155
|
if (optionalParams === null || optionalParams === void 0 ? void 0 : optionalParams.customContext) {
|
|
@@ -551,10 +551,9 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
551
551
|
_j.trys.push([1, 3, , 4]);
|
|
552
552
|
this.OCSDKProvider = ocsdk_1.SDKProvider;
|
|
553
553
|
_a = this;
|
|
554
|
-
return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, (0, createOcSDKConfiguration_1.default)(useCoreServices), this.ocSdkLogger)];
|
|
554
|
+
return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, (0, createOcSDKConfiguration_1.default)(useCoreServices, (_d = this.chatSDKConfig) === null || _d === void 0 ? void 0 : _d.ocUserAgent), this.ocSdkLogger)];
|
|
555
555
|
case 2:
|
|
556
556
|
_a.OCClient = _j.sent();
|
|
557
|
-
(0, setOcUserAgent_1.default)(this.OCClient, (_d = this.chatSDKConfig) === null || _d === void 0 ? void 0 : _d.ocUserAgent);
|
|
558
557
|
return [3 /*break*/, 4];
|
|
559
558
|
case 3:
|
|
560
559
|
e_2 = _j.sent();
|
|
@@ -657,8 +656,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
657
656
|
useCoreServices = (0, CoreServicesUtils_1.isCoreServicesOrgUrl)(this.omnichannelConfig.orgUrl);
|
|
658
657
|
try {
|
|
659
658
|
this.OCSDKProvider = ocsdk_1.SDKProvider;
|
|
660
|
-
this.OCClient = ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, (0, createOcSDKConfiguration_1.default)(useCoreServices), this.ocSdkLogger);
|
|
661
|
-
(0, setOcUserAgent_1.default)(this.OCClient, (_a = this.chatSDKConfig) === null || _a === void 0 ? void 0 : _a.ocUserAgent);
|
|
659
|
+
this.OCClient = ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, (0, createOcSDKConfiguration_1.default)(useCoreServices, (_a = this.chatSDKConfig) === null || _a === void 0 ? void 0 : _a.ocUserAgent), this.ocSdkLogger);
|
|
662
660
|
}
|
|
663
661
|
catch (e) {
|
|
664
662
|
exceptionThrowers_1.default.throwOmnichannelClientInitializationFailure(e, this.scenarioMarker, TelemetryEvent_1.default.InitializeLoadChatConfig);
|
|
@@ -1204,13 +1202,24 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
1204
1202
|
case 26:
|
|
1205
1203
|
if (this.isPersistentChat && !((_l = this.chatSDKConfig.persistentChat) === null || _l === void 0 ? void 0 : _l.disable)) {
|
|
1206
1204
|
this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1205
|
+
var error_13;
|
|
1207
1206
|
return __generator(this, function (_a) {
|
|
1208
1207
|
switch (_a.label) {
|
|
1209
|
-
case 0:
|
|
1208
|
+
case 0:
|
|
1209
|
+
_a.trys.push([0, 2, , 3]);
|
|
1210
|
+
return [4 /*yield*/, this.getChatToken(false)];
|
|
1210
1211
|
case 1:
|
|
1211
1212
|
_a.sent();
|
|
1212
1213
|
this.updateChatToken(this.chatToken.token, this.chatToken.regionGTMS);
|
|
1213
|
-
return [
|
|
1214
|
+
return [3 /*break*/, 3];
|
|
1215
|
+
case 2:
|
|
1216
|
+
error_13 = _a.sent();
|
|
1217
|
+
if (this.refreshTokenTimer !== null) {
|
|
1218
|
+
clearInterval(this.refreshTokenTimer);
|
|
1219
|
+
this.refreshTokenTimer = null;
|
|
1220
|
+
}
|
|
1221
|
+
return [3 /*break*/, 3];
|
|
1222
|
+
case 3: return [2 /*return*/];
|
|
1214
1223
|
}
|
|
1215
1224
|
});
|
|
1216
1225
|
}); }, (_m = this.chatSDKConfig.persistentChat) === null || _m === void 0 ? void 0 : _m.tokenUpdateTime);
|
|
@@ -1222,7 +1231,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
1222
1231
|
};
|
|
1223
1232
|
OmnichannelChatSDK.prototype.closeChat = function (endChatOptionalParams) {
|
|
1224
1233
|
return __awaiter(this, void 0, void 0, function () {
|
|
1225
|
-
var cleanupMetadata, sessionCloseOptionalParams, isReconnectChat, isChatReconnect,
|
|
1234
|
+
var cleanupMetadata, sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_14;
|
|
1226
1235
|
var _a, _b;
|
|
1227
1236
|
return __generator(this, function (_c) {
|
|
1228
1237
|
switch (_c.label) {
|
|
@@ -1257,8 +1266,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
1257
1266
|
_c.sent();
|
|
1258
1267
|
return [3 /*break*/, 4];
|
|
1259
1268
|
case 3:
|
|
1260
|
-
|
|
1261
|
-
exceptionThrowers_1.default.throwConversationClosureFailure(
|
|
1269
|
+
error_14 = _c.sent();
|
|
1270
|
+
exceptionThrowers_1.default.throwConversationClosureFailure(error_14, this.scenarioMarker, TelemetryEvent_1.default.CloseChatSession, __assign(__assign({}, cleanupMetadata), { isSessionEnded: String(!(endChatOptionalParams === null || endChatOptionalParams === void 0 ? void 0 : endChatOptionalParams.isSessionEnded)) }));
|
|
1262
1271
|
return [3 /*break*/, 4];
|
|
1263
1272
|
case 4:
|
|
1264
1273
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.CloseChatSession, cleanupMetadata);
|
|
@@ -1279,7 +1288,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
1279
1288
|
};
|
|
1280
1289
|
OmnichannelChatSDK.prototype.internalEndChat = function () {
|
|
1281
1290
|
return __awaiter(this, arguments, void 0, function (endChatOptionalParams) {
|
|
1282
|
-
var cleanupMetadata,
|
|
1291
|
+
var cleanupMetadata, error_15, telemetryData;
|
|
1283
1292
|
var _a;
|
|
1284
1293
|
if (endChatOptionalParams === void 0) { endChatOptionalParams = {}; }
|
|
1285
1294
|
return __generator(this, function (_b) {
|
|
@@ -1329,15 +1338,15 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
1329
1338
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, cleanupMetadata);
|
|
1330
1339
|
return [3 /*break*/, 7];
|
|
1331
1340
|
case 6:
|
|
1332
|
-
|
|
1341
|
+
error_15 = _b.sent();
|
|
1333
1342
|
telemetryData = {
|
|
1334
1343
|
RequestId: this.requestId,
|
|
1335
1344
|
ChatId: this.chatToken.chatId
|
|
1336
1345
|
};
|
|
1337
|
-
if (
|
|
1338
|
-
exceptionThrowers_1.default.throwConversationClosureFailure(new Error(JSON.stringify(
|
|
1346
|
+
if (error_15 instanceof ChatSDKError_1.ChatSDKError) {
|
|
1347
|
+
exceptionThrowers_1.default.throwConversationClosureFailure(new Error(JSON.stringify(error_15.exceptionDetails)), this.scenarioMarker, TelemetryEvent_1.default.EndChat, telemetryData);
|
|
1339
1348
|
}
|
|
1340
|
-
exceptionThrowers_1.default.throwConversationClosureFailure(
|
|
1349
|
+
exceptionThrowers_1.default.throwConversationClosureFailure(error_15, this.scenarioMarker, TelemetryEvent_1.default.EndChat, telemetryData);
|
|
1341
1350
|
return [3 /*break*/, 7];
|
|
1342
1351
|
case 7: return [2 /*return*/];
|
|
1343
1352
|
}
|
|
@@ -1384,7 +1393,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
1384
1393
|
};
|
|
1385
1394
|
OmnichannelChatSDK.prototype.getConversationDetails = function () {
|
|
1386
1395
|
return __awaiter(this, arguments, void 0, function (optionalParams) {
|
|
1387
|
-
var requestId, chatToken, chatId, reconnectId, sessionId, getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, canRenderPostChat, participantType, liveWorkItemDetails,
|
|
1396
|
+
var requestId, chatToken, chatId, reconnectId, sessionId, getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, canRenderPostChat, participantType, liveWorkItemDetails, error_16, telemetryData;
|
|
1388
1397
|
var _a, _b, _c, _d;
|
|
1389
1398
|
if (optionalParams === void 0) { optionalParams = {}; }
|
|
1390
1399
|
return __generator(this, function (_e) {
|
|
@@ -1457,15 +1466,15 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
1457
1466
|
});
|
|
1458
1467
|
return [2 /*return*/, liveWorkItemDetails];
|
|
1459
1468
|
case 3:
|
|
1460
|
-
|
|
1469
|
+
error_16 = _e.sent();
|
|
1461
1470
|
telemetryData = {
|
|
1462
1471
|
RequestId: requestId,
|
|
1463
1472
|
ChatId: chatId
|
|
1464
1473
|
};
|
|
1465
|
-
if ((0, utilities_1.isClientIdNotFoundErrorMessage)(
|
|
1466
|
-
exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(
|
|
1474
|
+
if ((0, utilities_1.isClientIdNotFoundErrorMessage)(error_16)) {
|
|
1475
|
+
exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(error_16, this.scenarioMarker, TelemetryEvent_1.default.GetConversationDetails, telemetryData);
|
|
1467
1476
|
}
|
|
1468
|
-
exceptionSuppressors_1.default.suppressConversationDetailsRetrievalFailure(
|
|
1477
|
+
exceptionSuppressors_1.default.suppressConversationDetailsRetrievalFailure(error_16, this.scenarioMarker, TelemetryEvent_1.default.GetConversationDetails, telemetryData);
|
|
1469
1478
|
return [3 /*break*/, 4];
|
|
1470
1479
|
case 4: return [2 /*return*/, {}];
|
|
1471
1480
|
}
|
|
@@ -1506,7 +1515,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
1506
1515
|
};
|
|
1507
1516
|
OmnichannelChatSDK.prototype.getChatToken = function () {
|
|
1508
1517
|
return __awaiter(this, arguments, void 0, function (cached, optionalParams) {
|
|
1509
|
-
var getChatTokenOptionalParams, chatToken,
|
|
1518
|
+
var getChatTokenOptionalParams, chatToken, error_17, telemetryData;
|
|
1510
1519
|
var _a, _b, _c;
|
|
1511
1520
|
if (cached === void 0) { cached = true; }
|
|
1512
1521
|
return __generator(this, function (_d) {
|
|
@@ -1548,16 +1557,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
1548
1557
|
});
|
|
1549
1558
|
return [3 /*break*/, 4];
|
|
1550
1559
|
case 3:
|
|
1551
|
-
|
|
1560
|
+
error_17 = _d.sent();
|
|
1552
1561
|
telemetryData = {
|
|
1553
1562
|
RequestId: this.requestId,
|
|
1554
1563
|
ChatId: (_c = this.chatToken) === null || _c === void 0 ? void 0 : _c.chatId,
|
|
1555
1564
|
};
|
|
1556
|
-
if ((0, utilities_1.isClientIdNotFoundErrorMessage)(
|
|
1557
|
-
exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(
|
|
1565
|
+
if ((0, utilities_1.isClientIdNotFoundErrorMessage)(error_17)) {
|
|
1566
|
+
exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(error_17, this.scenarioMarker, TelemetryEvent_1.default.GetChatToken, telemetryData);
|
|
1558
1567
|
}
|
|
1559
1568
|
else {
|
|
1560
|
-
exceptionThrowers_1.default.throwChatTokenRetrievalFailure(
|
|
1569
|
+
exceptionThrowers_1.default.throwChatTokenRetrievalFailure(error_17, this.scenarioMarker, TelemetryEvent_1.default.GetChatToken, telemetryData);
|
|
1561
1570
|
}
|
|
1562
1571
|
return [3 /*break*/, 4];
|
|
1563
1572
|
case 4: return [3 /*break*/, 6];
|
|
@@ -1687,21 +1696,36 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
1687
1696
|
}
|
|
1688
1697
|
var content = message.content;
|
|
1689
1698
|
var match;
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1699
|
+
if (this.regexCompiledForDataMasking.length === 0) {
|
|
1700
|
+
return message;
|
|
1701
|
+
}
|
|
1702
|
+
for (var _i = 0, _a = this.regexCompiledForDataMasking; _i < _a.length; _i++) {
|
|
1703
|
+
var regex = _a[_i];
|
|
1704
|
+
try {
|
|
1705
|
+
var lastIndex = -1;
|
|
1706
|
+
while ((match = regex.exec(content)) !== null) {
|
|
1707
|
+
// Prevent infinite loop from zero-width matches
|
|
1708
|
+
if (regex.lastIndex === lastIndex) {
|
|
1709
|
+
this.debug && console.warn("[OmnichannelChatSDK][transformMessage] Data masking regex caused zero-width match, skipping rule ".concat(regex));
|
|
1710
|
+
break;
|
|
1711
|
+
}
|
|
1712
|
+
lastIndex = regex.lastIndex;
|
|
1713
|
+
var replaceStr = match[0].replace(/./g, this.maskingCharacter);
|
|
1714
|
+
content = content.replace(match[0], replaceStr);
|
|
1715
|
+
}
|
|
1716
|
+
match = null;
|
|
1717
|
+
}
|
|
1718
|
+
catch (error) {
|
|
1719
|
+
// Log error for invalid regex but continue processing other rules
|
|
1720
|
+
this.debug && console.error("[OmnichannelChatSDK][transformMessage] Data masking regex failed for rule ".concat(regex, ": ").concat(error));
|
|
1696
1721
|
}
|
|
1697
|
-
match = null;
|
|
1698
1722
|
}
|
|
1699
1723
|
message.content = content;
|
|
1700
1724
|
return message;
|
|
1701
1725
|
};
|
|
1702
1726
|
OmnichannelChatSDK.prototype.sendMessage = function (message) {
|
|
1703
1727
|
return __awaiter(this, void 0, void 0, function () {
|
|
1704
|
-
var sendMessageRequest, chatMessage,
|
|
1728
|
+
var sendMessageRequest, chatMessage, error_18, exceptionDetails;
|
|
1705
1729
|
var _a;
|
|
1706
1730
|
return __generator(this, function (_b) {
|
|
1707
1731
|
switch (_b.label) {
|
|
@@ -1714,7 +1738,6 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
1714
1738
|
exceptionThrowers_1.default.throwUninitializedChatSDK(this.scenarioMarker, TelemetryEvent_1.default.SendMessages);
|
|
1715
1739
|
}
|
|
1716
1740
|
this.transformMessage(message);
|
|
1717
|
-
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 5];
|
|
1718
1741
|
sendMessageRequest = {
|
|
1719
1742
|
content: message.content,
|
|
1720
1743
|
};
|
|
@@ -1737,10 +1760,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
1737
1760
|
});
|
|
1738
1761
|
return [2 /*return*/, chatMessage];
|
|
1739
1762
|
case 3:
|
|
1740
|
-
|
|
1763
|
+
error_18 = _b.sent();
|
|
1741
1764
|
exceptionDetails = {
|
|
1742
1765
|
response: ChatSDKError_1.ChatSDKErrorName.ChatSDKSendMessageFailed,
|
|
1743
|
-
errorObject: "".concat(
|
|
1766
|
+
errorObject: "".concat(error_18)
|
|
1744
1767
|
};
|
|
1745
1768
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendMessages, {
|
|
1746
1769
|
RequestId: this.requestId,
|
|
@@ -1748,55 +1771,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
1748
1771
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
|
1749
1772
|
});
|
|
1750
1773
|
throw new ChatSDKError_1.ChatSDKError(ChatSDKError_1.ChatSDKErrorName.ChatSDKSendMessageFailed, undefined, {
|
|
1751
|
-
response: ChatSDKError_1.ChatSDKErrorName.ChatSDKSendMessageFailed,
|
|
1752
|
-
errorObject: "".concat(error_17)
|
|
1753
|
-
});
|
|
1754
|
-
case 4: return [3 /*break*/, 9];
|
|
1755
|
-
case 5:
|
|
1756
|
-
messageToSend = {
|
|
1757
|
-
content: message.content,
|
|
1758
|
-
timestamp: new Date(),
|
|
1759
|
-
contentType: MessageContentType_1.default.Text,
|
|
1760
|
-
deliveryMode: DeliveryMode_1.default.Bridged,
|
|
1761
|
-
messageType: MessageType_1.default.UserMessage,
|
|
1762
|
-
properties: undefined,
|
|
1763
|
-
tags: __spreadArray([], MessageTags_1.defaultMessageTags, true),
|
|
1764
|
-
sender: {
|
|
1765
|
-
displayName: "Customer",
|
|
1766
|
-
id: "customer",
|
|
1767
|
-
type: PersonType_1.default.User
|
|
1768
|
-
}
|
|
1769
|
-
};
|
|
1770
|
-
if (message.tags) {
|
|
1771
|
-
messageToSend.tags = message.tags;
|
|
1772
|
-
}
|
|
1773
|
-
if (message.timestamp) {
|
|
1774
|
-
messageToSend.timestamp = message.timestamp;
|
|
1775
|
-
}
|
|
1776
|
-
_b.label = 6;
|
|
1777
|
-
case 6:
|
|
1778
|
-
_b.trys.push([6, 8, , 9]);
|
|
1779
|
-
return [4 /*yield*/, this.conversation.sendMessage(messageToSend)];
|
|
1780
|
-
case 7:
|
|
1781
|
-
_b.sent();
|
|
1782
|
-
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.SendMessages, {
|
|
1783
|
-
RequestId: this.requestId,
|
|
1784
|
-
ChatId: this.chatToken.chatId
|
|
1785
|
-
});
|
|
1786
|
-
return [3 /*break*/, 9];
|
|
1787
|
-
case 8:
|
|
1788
|
-
error_18 = _b.sent();
|
|
1789
|
-
exceptionDetails = {
|
|
1790
1774
|
response: ChatSDKError_1.ChatSDKErrorName.ChatSDKSendMessageFailed,
|
|
1791
1775
|
errorObject: "".concat(error_18)
|
|
1792
|
-
};
|
|
1793
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendMessages, {
|
|
1794
|
-
RequestId: this.requestId,
|
|
1795
|
-
ChatId: this.chatToken.chatId,
|
|
1796
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
|
1797
1776
|
});
|
|
1798
|
-
|
|
1799
|
-
case 9: return [2 /*return*/];
|
|
1777
|
+
case 4: return [2 /*return*/];
|
|
1800
1778
|
}
|
|
1801
1779
|
});
|
|
1802
1780
|
});
|
|
@@ -1847,12 +1825,17 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
1847
1825
|
}
|
|
1848
1826
|
(_b = this.conversation) === null || _b === void 0 ? void 0 : _b.registerOnNewMessage(function (event) {
|
|
1849
1827
|
var id = event.id;
|
|
1828
|
+
var isChatMessageEditedEvent = Object.keys(event).includes("editedOn");
|
|
1829
|
+
console.log("[OmnichannelChatSDK][onNewMessage] New message received", event);
|
|
1830
|
+
console.log("[OmnichannelChatSDK][onNewMessage] isChatMessageEditedEvent=>", isChatMessageEditedEvent);
|
|
1850
1831
|
var omnichannelMessage = (0, createOmnichannelMessage_1.default)(event, {
|
|
1851
1832
|
liveChatVersion: _this.liveChatVersion,
|
|
1852
1833
|
debug: (_this.detailedDebugEnabled ? _this.debugACS : _this.debug),
|
|
1853
1834
|
});
|
|
1854
|
-
|
|
1835
|
+
// send callback for new messages or edited existent messages
|
|
1836
|
+
if (!postedMessages_1.has(id) || isChatMessageEditedEvent) {
|
|
1855
1837
|
onNewMessageCallback(omnichannelMessage);
|
|
1838
|
+
console.log("[OmnichannelChatSDK][onNewMessage] Message posted");
|
|
1856
1839
|
postedMessages_1.add(id);
|
|
1857
1840
|
}
|
|
1858
1841
|
}, registerOnNewMessageOptionalParams);
|
|
@@ -2142,9 +2125,9 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
2142
2125
|
};
|
|
2143
2126
|
OmnichannelChatSDK.prototype.downloadFileAttachment = function (fileMetadata) {
|
|
2144
2127
|
return __awaiter(this, void 0, void 0, function () {
|
|
2145
|
-
var amsClient, response, view_location, viewResponse,
|
|
2146
|
-
return __generator(this, function (
|
|
2147
|
-
switch (
|
|
2128
|
+
var amsClient, response, view_location, viewResponse, ex_1, downloadedFile, error_22;
|
|
2129
|
+
return __generator(this, function (_a) {
|
|
2130
|
+
switch (_a.label) {
|
|
2148
2131
|
case 0:
|
|
2149
2132
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
|
2150
2133
|
RequestId: this.requestId,
|
|
@@ -2154,9 +2137,9 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
2154
2137
|
exceptionThrowers_1.default.throwUninitializedChatSDK(this.scenarioMarker, TelemetryEvent_1.default.DownloadFileAttachment);
|
|
2155
2138
|
}
|
|
2156
2139
|
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 7];
|
|
2157
|
-
|
|
2140
|
+
_a.label = 1;
|
|
2158
2141
|
case 1:
|
|
2159
|
-
|
|
2142
|
+
_a.trys.push([1, 5, , 6]);
|
|
2160
2143
|
if (this.isAMSClientAllowed === false) {
|
|
2161
2144
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
|
2162
2145
|
RequestId: this.requestId,
|
|
@@ -2167,24 +2150,25 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
2167
2150
|
}
|
|
2168
2151
|
return [4 /*yield*/, this.getAMSClient()];
|
|
2169
2152
|
case 2:
|
|
2170
|
-
amsClient =
|
|
2153
|
+
amsClient = _a.sent();
|
|
2171
2154
|
if (amsClient === null || amsClient === undefined) {
|
|
2172
2155
|
(0, exceptionThrowers_1.throwAMSLoadFailure)(this.scenarioMarker, TelemetryEvent_1.default.DownloadFileAttachment, "Attachment handler is null, no action can be performed");
|
|
2173
2156
|
}
|
|
2174
2157
|
return [4 /*yield*/, (amsClient === null || amsClient === void 0 ? void 0 : amsClient.getViewStatus(fileMetadata))];
|
|
2175
2158
|
case 3:
|
|
2176
|
-
response =
|
|
2159
|
+
response = _a.sent();
|
|
2177
2160
|
view_location = response.view_location;
|
|
2178
2161
|
return [4 /*yield*/, (amsClient === null || amsClient === void 0 ? void 0 : amsClient.getView(fileMetadata, view_location))];
|
|
2179
2162
|
case 4:
|
|
2180
|
-
viewResponse =
|
|
2163
|
+
viewResponse = _a.sent();
|
|
2181
2164
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
|
2182
2165
|
RequestId: this.requestId,
|
|
2183
2166
|
ChatId: this.chatToken.chatId
|
|
2184
2167
|
});
|
|
2185
2168
|
return [2 /*return*/, viewResponse];
|
|
2186
2169
|
case 5:
|
|
2187
|
-
|
|
2170
|
+
ex_1 = _a.sent();
|
|
2171
|
+
console.error("OmnichannelChatSDK/downloadFileAttachment/error: ".concat(ex_1));
|
|
2188
2172
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
|
2189
2173
|
RequestId: this.requestId,
|
|
2190
2174
|
ChatId: this.chatToken.chatId
|
|
@@ -2192,17 +2176,17 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
2192
2176
|
throw new Error('DownloadFileAttachmentFailed');
|
|
2193
2177
|
case 6: return [3 /*break*/, 10];
|
|
2194
2178
|
case 7:
|
|
2195
|
-
|
|
2179
|
+
_a.trys.push([7, 9, , 10]);
|
|
2196
2180
|
return [4 /*yield*/, this.conversation.downloadFile(fileMetadata)];
|
|
2197
2181
|
case 8:
|
|
2198
|
-
downloadedFile =
|
|
2182
|
+
downloadedFile = _a.sent();
|
|
2199
2183
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
|
2200
2184
|
RequestId: this.requestId,
|
|
2201
2185
|
ChatId: this.chatToken.chatId
|
|
2202
2186
|
});
|
|
2203
2187
|
return [2 /*return*/, downloadedFile];
|
|
2204
2188
|
case 9:
|
|
2205
|
-
error_22 =
|
|
2189
|
+
error_22 = _a.sent();
|
|
2206
2190
|
console.error("OmnichannelChatSDK/downloadFileAttachment/error: ".concat(error_22));
|
|
2207
2191
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
|
2208
2192
|
RequestId: this.requestId,
|
|
@@ -2458,7 +2442,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
2458
2442
|
};
|
|
2459
2443
|
OmnichannelChatSDK.prototype.getPostChatSurveyContext = function () {
|
|
2460
2444
|
return __awaiter(this, void 0, void 0, function () {
|
|
2461
|
-
var conversationId, chatConfig, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId, postConversationBotSurveyOwnerId, msdyn_surveyprovider, surveyProvider, liveWorkItemDetails, participantJoined, participantType, agentSurveyInviteLinkRequest, botSurveyInviteLinkRequest, optionalParams, _a, agentSurveyInviteLinkResponse, botSurveyInviteLinkResponse, agentSurveyInviteLink, agentFormsProLocale, botSurveyInviteLink, botFormsProLocale, postChatContext,
|
|
2445
|
+
var conversationId, chatConfig, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId, postConversationBotSurveyOwnerId, msdyn_surveyprovider, surveyProvider, liveWorkItemDetails, participantJoined, participantType, agentSurveyInviteLinkRequest, botSurveyInviteLinkRequest, optionalParams, _a, agentSurveyInviteLinkResponse, botSurveyInviteLinkResponse, agentSurveyInviteLink, agentFormsProLocale, botSurveyInviteLink, botFormsProLocale, postChatContext, ex_2;
|
|
2462
2446
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
2463
2447
|
return __generator(this, function (_o) {
|
|
2464
2448
|
switch (_o.label) {
|
|
@@ -2594,14 +2578,14 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
2594
2578
|
return [2 /*return*/, Promise.reject("Post Chat is disabled from admin side, or chat doesnt have a survey as part of their configuration.")];
|
|
2595
2579
|
case 5: return [3 /*break*/, 7];
|
|
2596
2580
|
case 6:
|
|
2597
|
-
|
|
2581
|
+
ex_2 = _o.sent();
|
|
2598
2582
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
|
|
2599
2583
|
ConversationId: conversationId !== null && conversationId !== void 0 ? conversationId : "",
|
|
2600
2584
|
RequestId: this.requestId,
|
|
2601
2585
|
ChatId: (_m = this.chatToken) === null || _m === void 0 ? void 0 : _m.chatId,
|
|
2602
|
-
ExceptionDetails: JSON.stringify(
|
|
2586
|
+
ExceptionDetails: JSON.stringify(ex_2)
|
|
2603
2587
|
});
|
|
2604
|
-
return [2 /*return*/, Promise.reject("Retrieving post chat context failed " + JSON.stringify(
|
|
2588
|
+
return [2 /*return*/, Promise.reject("Retrieving post chat context failed " + JSON.stringify(ex_2))];
|
|
2605
2589
|
case 7: return [2 /*return*/];
|
|
2606
2590
|
}
|
|
2607
2591
|
});
|
|
@@ -2795,12 +2779,26 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
2795
2779
|
regex: value
|
|
2796
2780
|
});
|
|
2797
2781
|
}
|
|
2782
|
+
this.compileDataMaskingRegex();
|
|
2798
2783
|
}
|
|
2799
2784
|
}
|
|
2800
2785
|
return [2 /*return*/];
|
|
2801
2786
|
});
|
|
2802
2787
|
});
|
|
2803
2788
|
};
|
|
2789
|
+
OmnichannelChatSDK.prototype.compileDataMaskingRegex = function () {
|
|
2790
|
+
this.regexCompiledForDataMasking = [];
|
|
2791
|
+
for (var _i = 0, _a = this.dataMaskingRules.rules; _i < _a.length; _i++) {
|
|
2792
|
+
var rule = _a[_i];
|
|
2793
|
+
try {
|
|
2794
|
+
var regex = new RegExp(rule.regex, 'g');
|
|
2795
|
+
this.regexCompiledForDataMasking.push(regex);
|
|
2796
|
+
}
|
|
2797
|
+
catch (e) {
|
|
2798
|
+
console.error("Error compiling regex for data masking rule id ".concat(rule.id, ": ").concat(e));
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
};
|
|
2804
2802
|
OmnichannelChatSDK.prototype.setAuthSettingConfig = function (authSettings) {
|
|
2805
2803
|
return __awaiter(this, void 0, void 0, function () {
|
|
2806
2804
|
return __generator(this, function (_a) {
|
|
@@ -3126,6 +3124,67 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
|
3126
3124
|
});
|
|
3127
3125
|
});
|
|
3128
3126
|
};
|
|
3127
|
+
/**
|
|
3128
|
+
* Get persistent chat history for authenticated users.
|
|
3129
|
+
* @param getPersistentChatHistoryOptionalParams Optional parameters for persistent chat history retrieval.
|
|
3130
|
+
*/
|
|
3131
|
+
OmnichannelChatSDK.prototype.getPersistentChatHistory = function () {
|
|
3132
|
+
return __awaiter(this, arguments, void 0, function (getPersistentChatHistoryOptionalParams) {
|
|
3133
|
+
var params, result, error_28, telemetryData;
|
|
3134
|
+
var _a, _b, _c, _d, _e;
|
|
3135
|
+
if (getPersistentChatHistoryOptionalParams === void 0) { getPersistentChatHistoryOptionalParams = {}; }
|
|
3136
|
+
return __generator(this, function (_f) {
|
|
3137
|
+
switch (_f.label) {
|
|
3138
|
+
case 0:
|
|
3139
|
+
if (!this.requestId) {
|
|
3140
|
+
this.requestId = (0, ocsdk_1.uuidv4)();
|
|
3141
|
+
}
|
|
3142
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetPersistentChatHistory, {
|
|
3143
|
+
RequestId: this.requestId
|
|
3144
|
+
});
|
|
3145
|
+
if (!this.isInitialized) {
|
|
3146
|
+
exceptionThrowers_1.default.throwUninitializedChatSDK(this.scenarioMarker, TelemetryEvent_1.default.GetPersistentChatHistory);
|
|
3147
|
+
}
|
|
3148
|
+
if (!this.isPersistentChat || ((_a = this.chatSDKConfig.persistentChat) === null || _a === void 0 ? void 0 : _a.disable) === true) {
|
|
3149
|
+
exceptionThrowers_1.default.throwNotPersistentChatEnabled(this.scenarioMarker, TelemetryEvent_1.default.GetPersistentChatHistory, {
|
|
3150
|
+
RequestId: this.requestId,
|
|
3151
|
+
ChatId: (_b = this.chatToken) === null || _b === void 0 ? void 0 : _b.chatId
|
|
3152
|
+
});
|
|
3153
|
+
}
|
|
3154
|
+
if (!this.authenticatedUserToken) {
|
|
3155
|
+
exceptionThrowers_1.default.throwChatSDKError(ChatSDKError_1.ChatSDKErrorName.AuthenticatedUserTokenNotFound, new Error('Authenticated user token not found'), this.scenarioMarker, TelemetryEvent_1.default.GetPersistentChatHistory, {
|
|
3156
|
+
RequestId: this.requestId,
|
|
3157
|
+
ChatId: (_c = this.chatToken) === null || _c === void 0 ? void 0 : _c.chatId
|
|
3158
|
+
});
|
|
3159
|
+
}
|
|
3160
|
+
_f.label = 1;
|
|
3161
|
+
case 1:
|
|
3162
|
+
_f.trys.push([1, 3, , 4]);
|
|
3163
|
+
params = {};
|
|
3164
|
+
params.pageSize = getPersistentChatHistoryOptionalParams.pageSize || undefined;
|
|
3165
|
+
params.pageToken = getPersistentChatHistoryOptionalParams.pageToken || undefined;
|
|
3166
|
+
return [4 /*yield*/, this.OCClient.getPersistentChatHistory(this.requestId, __assign(__assign({}, params), { authenticatedUserToken: this.authenticatedUserToken }))];
|
|
3167
|
+
case 2:
|
|
3168
|
+
result = _f.sent();
|
|
3169
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetPersistentChatHistory, {
|
|
3170
|
+
RequestId: this.requestId,
|
|
3171
|
+
ChatId: (_d = this.chatToken) === null || _d === void 0 ? void 0 : _d.chatId
|
|
3172
|
+
});
|
|
3173
|
+
return [2 /*return*/, result];
|
|
3174
|
+
case 3:
|
|
3175
|
+
error_28 = _f.sent();
|
|
3176
|
+
telemetryData = {
|
|
3177
|
+
RequestId: this.requestId,
|
|
3178
|
+
ChatId: (_e = this.chatToken) === null || _e === void 0 ? void 0 : _e.chatId,
|
|
3179
|
+
ErrorMessage: (error_28 === null || error_28 === void 0 ? void 0 : error_28.message) || 'Unknown error' // Added error message for better debugging
|
|
3180
|
+
};
|
|
3181
|
+
exceptionThrowers_1.default.throwPersistentChatConversationRetrievalFailure(error_28, this.scenarioMarker, TelemetryEvent_1.default.GetPersistentChatHistory, telemetryData);
|
|
3182
|
+
return [3 /*break*/, 4];
|
|
3183
|
+
case 4: return [2 /*return*/];
|
|
3184
|
+
}
|
|
3185
|
+
});
|
|
3186
|
+
});
|
|
3187
|
+
};
|
|
3129
3188
|
return OmnichannelChatSDK;
|
|
3130
3189
|
}());
|
|
3131
3190
|
exports.default = OmnichannelChatSDK;
|