@microsoft/omnichannel-chat-sdk 1.0.1-main.67b480d → 1.0.1-main.77251b7
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/CHANGELOG.md +12 -0
- package/README.md +69 -59
- package/lib/OmnichannelChatSDK.d.ts +5 -1
- package/lib/OmnichannelChatSDK.js +254 -181
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/core/ChatConfig.d.ts +1 -0
- package/lib/core/ChatSDKExceptionDetails.d.ts +5 -0
- package/lib/core/ChatSDKExceptionDetails.js +3 -0
- package/lib/core/ChatSDKExceptionDetails.js.map +1 -0
- package/lib/core/ChatTranscriptBody.d.ts +1 -1
- package/lib/core/OmnichannelErrorCodes.d.ts +4 -0
- package/lib/core/OmnichannelErrorCodes.js +8 -0
- package/lib/core/OmnichannelErrorCodes.js.map +1 -0
- package/lib/core/messaging/ChatAdapterOptionalParams.d.ts +14 -0
- package/lib/core/messaging/ChatAdapterOptionalParams.js +3 -0
- package/lib/core/messaging/ChatAdapterOptionalParams.js.map +1 -0
- package/lib/core/messaging/MessageTags.d.ts +2 -0
- package/lib/core/messaging/MessageTags.js +4 -2
- package/lib/core/messaging/MessageTags.js.map +1 -1
- package/lib/external/ACSAdapter/createChannelDataEgressMiddleware.d.ts +5 -0
- package/lib/external/ACSAdapter/createChannelDataEgressMiddleware.js +34 -0
- package/lib/external/ACSAdapter/createChannelDataEgressMiddleware.js.map +1 -0
- package/lib/external/IC3Adapter/IIC3AdapterOptions.d.ts +12 -0
- package/lib/telemetry/AriaTelemetry.js +5 -0
- package/lib/telemetry/AriaTelemetry.js.map +1 -1
- package/lib/telemetry/ScenarioMarker.d.ts +2 -0
- package/lib/telemetry/ScenarioMarker.js +7 -3
- package/lib/telemetry/ScenarioMarker.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +111 -31
- package/lib/utils/WebUtils.d.ts +3 -1
- package/lib/utils/WebUtils.js +8 -2
- package/lib/utils/WebUtils.js.map +1 -1
- package/lib/utils/locale.d.ts +1 -0
- package/lib/utils/locale.js +2 -1
- package/lib/utils/locale.js.map +1 -1
- package/lib/utils/loggers.d.ts +8 -0
- package/lib/utils/loggers.js +24 -0
- package/lib/utils/loggers.js.map +1 -1
- package/package.json +1 -1
@@ -65,6 +65,7 @@ var AMSFileManager_1 = require("./external/ACSAdapter/AMSFileManager");
|
|
65
65
|
var CallingOptionsOptionSetNumber_1 = require("./core/CallingOptionsOptionSetNumber");
|
66
66
|
var ChatAdapterProtocols_1 = require("./core/messaging/ChatAdapterProtocols");
|
67
67
|
var ConversationMode_1 = require("./core/ConversationMode");
|
68
|
+
var createChannelDataEgressMiddleware_1 = require("./external/ACSAdapter/createChannelDataEgressMiddleware");
|
68
69
|
var createFormatEgressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatEgressTagsMiddleware");
|
69
70
|
var createFormatIngressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatIngressTagsMiddleware");
|
70
71
|
var DeliveryMode_1 = require("@microsoft/omnichannel-ic3core/lib/model/DeliveryMode");
|
@@ -75,6 +76,7 @@ var LiveChatVersion_1 = require("./core/LiveChatVersion");
|
|
75
76
|
var LiveWorkItemState_1 = require("./core/LiveWorkItemState");
|
76
77
|
var MessageContentType_1 = require("@microsoft/omnichannel-ic3core/lib/model/MessageContentType");
|
77
78
|
var MessageType_1 = require("@microsoft/omnichannel-ic3core/lib/model/MessageType");
|
79
|
+
var OmnichannelErrorCodes_1 = require("./core/OmnichannelErrorCodes");
|
78
80
|
var PersonType_1 = require("@microsoft/omnichannel-ic3core/lib/model/PersonType");
|
79
81
|
var ProtocoleType_1 = require("@microsoft/omnichannel-ic3core/lib/interfaces/ProtocoleType");
|
80
82
|
var ScenarioMarker_1 = require("./telemetry/ScenarioMarker");
|
@@ -109,11 +111,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
109
111
|
this.reconnectId = null;
|
110
112
|
this.refreshTokenTimer = null;
|
111
113
|
this.debug = false;
|
114
|
+
this.runtimeId = ocsdk_1.uuidv4();
|
112
115
|
this.omnichannelConfig = omnichannelConfig;
|
113
116
|
this.chatSDKConfig = __assign(__assign({}, SDKConfigValidators_1.defaultChatSDKConfig), chatSDKConfig // overrides
|
114
117
|
);
|
115
118
|
this.isInitialized = false;
|
116
119
|
this.liveChatVersion = LiveChatVersion_1.default.V1;
|
120
|
+
this.localeId = locale_1.defaultLocaleId;
|
117
121
|
this.requestId = ocsdk_1.uuidv4();
|
118
122
|
this.chatToken = {};
|
119
123
|
this.liveChatConfig = {};
|
@@ -131,6 +135,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
131
135
|
this.ocSdkLogger.useTelemetry(this.telemetry);
|
132
136
|
this.acsClientLogger.useTelemetry(this.telemetry);
|
133
137
|
this.acsAdapterLogger.useTelemetry(this.telemetry);
|
138
|
+
this.scenarioMarker.setRuntimeId(this.runtimeId);
|
139
|
+
this.ic3ClientLogger.setRuntimeId(this.runtimeId);
|
140
|
+
this.ocSdkLogger.setRuntimeId(this.runtimeId);
|
141
|
+
this.acsClientLogger.setRuntimeId(this.runtimeId);
|
142
|
+
this.acsAdapterLogger.setRuntimeId(this.runtimeId);
|
134
143
|
OmnichannelConfigValidator_1.default(omnichannelConfig);
|
135
144
|
SDKConfigValidators_1.default(chatSDKConfig);
|
136
145
|
((_a = this.chatSDKConfig.telemetry) === null || _a === void 0 ? void 0 : _a.disable) && ((_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.disable());
|
@@ -291,47 +300,55 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
291
300
|
});
|
292
301
|
};
|
293
302
|
OmnichannelChatSDK.prototype.startChat = function (optionalParams) {
|
294
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
303
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
295
304
|
if (optionalParams === void 0) { optionalParams = {}; }
|
296
305
|
return __awaiter(this, void 0, void 0, function () {
|
297
|
-
var reconnectableChatsParams, reconnectableChatsResponse,
|
306
|
+
var shouldReinitIC3Client, _s, reconnectableChatsParams, reconnectableChatsResponse, _t, exceptionDetails, conversationDetails, exceptionDetails, exceptionDetails, sessionInitOptionalParams, error_3, exceptionDetails, chatAdapterConfig, error_4, exceptionDetails, _u, error_5, exceptionDetails, error_6, exceptionDetails, error_7, exceptionDetails, _v, error_8, exceptionDetails;
|
298
307
|
var _this = this;
|
299
|
-
return __generator(this, function (
|
300
|
-
switch (
|
308
|
+
return __generator(this, function (_w) {
|
309
|
+
switch (_w.label) {
|
301
310
|
case 0:
|
302
311
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
|
303
312
|
RequestId: this.requestId
|
304
313
|
});
|
314
|
+
shouldReinitIC3Client = !platform_1.default.isNode() && !platform_1.default.isReactNative() && !this.IC3Client && this.liveChatVersion === LiveChatVersion_1.default.V1;
|
315
|
+
if (!shouldReinitIC3Client) return [3 /*break*/, 2];
|
316
|
+
_s = this;
|
317
|
+
return [4 /*yield*/, this.getIC3Client()];
|
318
|
+
case 1:
|
319
|
+
_s.IC3Client = _w.sent();
|
320
|
+
_w.label = 2;
|
321
|
+
case 2:
|
305
322
|
if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
|
306
323
|
this.reconnectId = optionalParams.reconnectId;
|
307
324
|
}
|
308
|
-
if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/,
|
309
|
-
|
310
|
-
case
|
311
|
-
|
325
|
+
if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 6];
|
326
|
+
_w.label = 3;
|
327
|
+
case 3:
|
328
|
+
_w.trys.push([3, 5, , 6]);
|
312
329
|
reconnectableChatsParams = {
|
313
330
|
authenticatedUserToken: this.authenticatedUserToken
|
314
331
|
};
|
315
332
|
return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
|
316
|
-
case
|
317
|
-
reconnectableChatsResponse =
|
333
|
+
case 4:
|
334
|
+
reconnectableChatsResponse = _w.sent();
|
318
335
|
if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
|
319
336
|
this.reconnectId = reconnectableChatsResponse.reconnectid;
|
320
337
|
}
|
321
|
-
return [3 /*break*/,
|
322
|
-
case
|
323
|
-
|
338
|
+
return [3 /*break*/, 6];
|
339
|
+
case 5:
|
340
|
+
_t = _w.sent();
|
324
341
|
exceptionDetails = {
|
325
342
|
response: "OCClientGetReconnectableChatsFailed"
|
326
343
|
};
|
327
344
|
throw Error(exceptionDetails.response);
|
328
|
-
case
|
329
|
-
if (!(optionalParams.liveChatContext && !this.reconnectId)) return [3 /*break*/,
|
345
|
+
case 6:
|
346
|
+
if (!(optionalParams.liveChatContext && !this.reconnectId)) return [3 /*break*/, 8];
|
330
347
|
this.chatToken = optionalParams.liveChatContext.chatToken || {};
|
331
348
|
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
|
332
349
|
return [4 /*yield*/, this.getConversationDetails()];
|
333
|
-
case
|
334
|
-
conversationDetails =
|
350
|
+
case 7:
|
351
|
+
conversationDetails = _w.sent();
|
335
352
|
if (Object.keys(conversationDetails).length === 0) {
|
336
353
|
exceptionDetails = {
|
337
354
|
response: "InvalidConversation"
|
@@ -356,14 +373,14 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
356
373
|
console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
|
357
374
|
throw Error(exceptionDetails.response);
|
358
375
|
}
|
359
|
-
|
360
|
-
case 6:
|
361
|
-
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 8];
|
362
|
-
return [4 /*yield*/, this.getChatToken(false)];
|
363
|
-
case 7:
|
364
|
-
_s.sent();
|
365
|
-
_s.label = 8;
|
376
|
+
_w.label = 8;
|
366
377
|
case 8:
|
378
|
+
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 10];
|
379
|
+
return [4 /*yield*/, this.getChatToken(false)];
|
380
|
+
case 9:
|
381
|
+
_w.sent();
|
382
|
+
_w.label = 10;
|
383
|
+
case 10:
|
367
384
|
(_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
|
368
385
|
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
|
369
386
|
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
|
@@ -371,6 +388,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
371
388
|
sessionInitOptionalParams = {
|
372
389
|
initContext: {}
|
373
390
|
};
|
391
|
+
sessionInitOptionalParams.initContext.locale = locale_1.getLocaleStringFromId(this.localeId);
|
374
392
|
if (this.isPersistentChat && !((_g = this.chatSDKConfig.persistentChat) === null || _g === void 0 ? void 0 : _g.disable)) {
|
375
393
|
sessionInitOptionalParams.reconnectId = this.reconnectId;
|
376
394
|
}
|
@@ -402,28 +420,33 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
402
420
|
if (this.authenticatedUserToken) {
|
403
421
|
sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
404
422
|
}
|
405
|
-
if (!!optionalParams.liveChatContext) return [3 /*break*/,
|
406
|
-
|
407
|
-
case 9:
|
408
|
-
_s.trys.push([9, 11, , 12]);
|
409
|
-
return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
|
410
|
-
case 10:
|
411
|
-
_s.sent();
|
412
|
-
return [3 /*break*/, 12];
|
423
|
+
if (!!optionalParams.liveChatContext) return [3 /*break*/, 14];
|
424
|
+
_w.label = 11;
|
413
425
|
case 11:
|
414
|
-
|
426
|
+
_w.trys.push([11, 13, , 14]);
|
427
|
+
return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
|
428
|
+
case 12:
|
429
|
+
_w.sent();
|
430
|
+
return [3 /*break*/, 14];
|
431
|
+
case 13:
|
432
|
+
error_3 = _w.sent();
|
415
433
|
exceptionDetails = {
|
416
434
|
response: "OCClientSessionInitFailed"
|
417
435
|
};
|
436
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
437
|
+
if (((_j = error_3) === null || _j === void 0 ? void 0 : _j.isAxiosError) && ((_l = (_k = error_3.response) === null || _k === void 0 ? void 0 : _k.headers) === null || _l === void 0 ? void 0 : _l.errorcode.toString()) === OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour.toString()) {
|
438
|
+
exceptionDetails.response = OmnichannelErrorCodes_1.default[OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour].toString();
|
439
|
+
exceptionDetails.message = 'Widget used outside of operating hours';
|
440
|
+
console.error(exceptionDetails.message);
|
441
|
+
}
|
418
442
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
419
443
|
RequestId: this.requestId,
|
420
444
|
ChatId: this.chatToken.chatId,
|
421
445
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
422
446
|
});
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 23];
|
447
|
+
throw new Error(exceptionDetails.response);
|
448
|
+
case 14:
|
449
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 25];
|
427
450
|
chatAdapterConfig = {
|
428
451
|
token: this.chatToken.token,
|
429
452
|
id: this.chatToken.visitorId || 'teamsvisitor',
|
@@ -431,18 +454,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
431
454
|
environmentUrl: this.chatToken.acsEndpoint,
|
432
455
|
pollingInterval: 1000
|
433
456
|
};
|
434
|
-
|
435
|
-
case
|
436
|
-
|
437
|
-
return [4 /*yield*/, ((
|
457
|
+
_w.label = 15;
|
458
|
+
case 15:
|
459
|
+
_w.trys.push([15, 17, , 18]);
|
460
|
+
return [4 /*yield*/, ((_m = this.ACSClient) === null || _m === void 0 ? void 0 : _m.initialize({
|
438
461
|
token: chatAdapterConfig.token,
|
439
462
|
environmentUrl: chatAdapterConfig.environmentUrl
|
440
463
|
}))];
|
441
|
-
case
|
442
|
-
|
443
|
-
return [3 /*break*/,
|
444
|
-
case
|
445
|
-
error_4 =
|
464
|
+
case 16:
|
465
|
+
_w.sent();
|
466
|
+
return [3 /*break*/, 18];
|
467
|
+
case 17:
|
468
|
+
error_4 = _w.sent();
|
446
469
|
exceptionDetails = {
|
447
470
|
response: "ACSClientInitializeFailed"
|
448
471
|
};
|
@@ -453,23 +476,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
453
476
|
});
|
454
477
|
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_4);
|
455
478
|
return [2 /*return*/, error_4];
|
456
|
-
case
|
457
|
-
|
458
|
-
|
459
|
-
return [4 /*yield*/, ((
|
479
|
+
case 18:
|
480
|
+
_w.trys.push([18, 20, , 21]);
|
481
|
+
_u = this;
|
482
|
+
return [4 /*yield*/, ((_o = this.ACSClient) === null || _o === void 0 ? void 0 : _o.joinConversation({
|
460
483
|
id: chatAdapterConfig.id,
|
461
484
|
threadId: chatAdapterConfig.threadId,
|
462
485
|
pollingInterval: chatAdapterConfig.pollingInterval
|
463
486
|
}))];
|
464
|
-
case
|
465
|
-
|
487
|
+
case 19:
|
488
|
+
_u.conversation = (_w.sent());
|
466
489
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
467
490
|
RequestId: this.requestId,
|
468
491
|
ChatId: this.chatToken.chatId
|
469
492
|
});
|
470
|
-
return [3 /*break*/,
|
471
|
-
case
|
472
|
-
error_5 =
|
493
|
+
return [3 /*break*/, 21];
|
494
|
+
case 20:
|
495
|
+
error_5 = _w.sent();
|
473
496
|
exceptionDetails = {
|
474
497
|
response: "ACSClientJoinConversationFailed"
|
475
498
|
};
|
@@ -480,16 +503,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
480
503
|
});
|
481
504
|
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_5);
|
482
505
|
throw Error(exceptionDetails.response);
|
483
|
-
case
|
484
|
-
|
485
|
-
return [4 /*yield*/, ((
|
506
|
+
case 21:
|
507
|
+
_w.trys.push([21, 23, , 24]);
|
508
|
+
return [4 /*yield*/, ((_p = this.AMSClient) === null || _p === void 0 ? void 0 : _p.initialize({
|
486
509
|
chatToken: this.chatToken
|
487
510
|
}))];
|
488
|
-
case
|
489
|
-
|
490
|
-
return [3 /*break*/,
|
491
|
-
case
|
492
|
-
error_6 =
|
511
|
+
case 22:
|
512
|
+
_w.sent();
|
513
|
+
return [3 /*break*/, 24];
|
514
|
+
case 23:
|
515
|
+
error_6 = _w.sent();
|
493
516
|
exceptionDetails = {
|
494
517
|
response: "AMSClientInitializeFailed"
|
495
518
|
};
|
@@ -499,19 +522,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
499
522
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
500
523
|
});
|
501
524
|
throw Error(exceptionDetails.response);
|
502
|
-
case
|
503
|
-
case
|
504
|
-
|
525
|
+
case 24: return [3 /*break*/, 31];
|
526
|
+
case 25:
|
527
|
+
_w.trys.push([25, 27, , 28]);
|
505
528
|
return [4 /*yield*/, this.IC3Client.initialize({
|
506
529
|
token: this.chatToken.token,
|
507
530
|
regionGtms: this.chatToken.regionGTMS,
|
508
531
|
visitor: true
|
509
532
|
})];
|
510
|
-
case
|
511
|
-
|
512
|
-
return [3 /*break*/,
|
513
|
-
case
|
514
|
-
error_7 =
|
533
|
+
case 26:
|
534
|
+
_w.sent();
|
535
|
+
return [3 /*break*/, 28];
|
536
|
+
case 27:
|
537
|
+
error_7 = _w.sent();
|
515
538
|
exceptionDetails = {
|
516
539
|
response: "IC3ClientInitializeFailed"
|
517
540
|
};
|
@@ -522,19 +545,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
522
545
|
});
|
523
546
|
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_7);
|
524
547
|
return [2 /*return*/, error_7];
|
525
|
-
case
|
526
|
-
|
527
|
-
|
548
|
+
case 28:
|
549
|
+
_w.trys.push([28, 30, , 31]);
|
550
|
+
_v = this;
|
528
551
|
return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
|
529
|
-
case
|
530
|
-
|
552
|
+
case 29:
|
553
|
+
_v.conversation = _w.sent();
|
531
554
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
532
555
|
RequestId: this.requestId,
|
533
556
|
ChatId: this.chatToken.chatId
|
534
557
|
});
|
535
|
-
return [3 /*break*/,
|
536
|
-
case
|
537
|
-
error_8 =
|
558
|
+
return [3 /*break*/, 31];
|
559
|
+
case 30:
|
560
|
+
error_8 = _w.sent();
|
538
561
|
exceptionDetails = {
|
539
562
|
response: "IC3ClientJoinConversationFailed"
|
540
563
|
};
|
@@ -545,8 +568,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
545
568
|
});
|
546
569
|
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_8);
|
547
570
|
return [2 /*return*/, error_8];
|
548
|
-
case
|
549
|
-
if (this.isPersistentChat && !((
|
571
|
+
case 31:
|
572
|
+
if (this.isPersistentChat && !((_q = this.chatSDKConfig.persistentChat) === null || _q === void 0 ? void 0 : _q.disable)) {
|
550
573
|
this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
551
574
|
return __generator(this, function (_a) {
|
552
575
|
switch (_a.label) {
|
@@ -557,7 +580,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
557
580
|
return [2 /*return*/];
|
558
581
|
}
|
559
582
|
});
|
560
|
-
}); }, (
|
583
|
+
}); }, (_r = this.chatSDKConfig.persistentChat) === null || _r === void 0 ? void 0 : _r.tokenUpdateTime);
|
561
584
|
}
|
562
585
|
return [2 /*return*/];
|
563
586
|
}
|
@@ -583,6 +606,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
583
606
|
}
|
584
607
|
if (this.isChatReconnect && !((_b = this.chatSDKConfig.chatReconnect) === null || _b === void 0 ? void 0 : _b.disable) && !this.isPersistentChat) {
|
585
608
|
isChatReconnect = this.reconnectId !== null ? true : false;
|
609
|
+
this.requestId = isChatReconnect ? this.reconnectId : this.requestId; // Chat Reconnect session to close
|
586
610
|
sessionCloseOptionalParams.isReconnectChat = isChatReconnect;
|
587
611
|
}
|
588
612
|
if (this.authenticatedUserToken) {
|
@@ -603,6 +627,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
603
627
|
this.requestId = ocsdk_1.uuidv4();
|
604
628
|
this.chatToken = {};
|
605
629
|
this.reconnectId = null;
|
630
|
+
if (this.IC3Client) {
|
631
|
+
this.IC3Client.dispose();
|
632
|
+
!platform_1.default.isNode() && !platform_1.default.isReactNative() && WebUtils_1.removeElementById(this.IC3Client.id);
|
633
|
+
this.IC3Client = null;
|
634
|
+
}
|
606
635
|
(_d = this.ic3ClientLogger) === null || _d === void 0 ? void 0 : _d.setRequestId(this.requestId);
|
607
636
|
(_e = this.ic3ClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId('');
|
608
637
|
(_f = this.ocSdkLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
|
@@ -664,22 +693,32 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
664
693
|
});
|
665
694
|
};
|
666
695
|
OmnichannelChatSDK.prototype.getConversationDetails = function () {
|
667
|
-
var _a, _b;
|
696
|
+
var _a, _b, _c, _d;
|
668
697
|
return __awaiter(this, void 0, void 0, function () {
|
669
|
-
var lwiDetails, state, conversationId, agentAcceptedOn, liveWorkItemDetails, error_10;
|
670
|
-
return __generator(this, function (
|
671
|
-
switch (
|
698
|
+
var getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, liveWorkItemDetails, error_10;
|
699
|
+
return __generator(this, function (_e) {
|
700
|
+
switch (_e.label) {
|
672
701
|
case 0:
|
673
702
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
674
703
|
RequestId: this.requestId,
|
675
704
|
ChatId: ((_a = this.chatToken) === null || _a === void 0 ? void 0 : _a.chatId) || '',
|
676
705
|
});
|
677
|
-
|
706
|
+
getLWIDetailsOptionalParams = {};
|
707
|
+
if (this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable) && this.reconnectId) {
|
708
|
+
getLWIDetailsOptionalParams.reconnectId = this.reconnectId;
|
709
|
+
}
|
710
|
+
if (this.isChatReconnect && !((_c = this.chatSDKConfig.chatReconnect) === null || _c === void 0 ? void 0 : _c.disable) && !this.isPersistentChat && this.reconnectId) {
|
711
|
+
getLWIDetailsOptionalParams.reconnectId = this.reconnectId;
|
712
|
+
}
|
713
|
+
if (this.authenticatedUserToken) {
|
714
|
+
getLWIDetailsOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
715
|
+
}
|
716
|
+
_e.label = 1;
|
678
717
|
case 1:
|
679
|
-
|
680
|
-
return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId)];
|
718
|
+
_e.trys.push([1, 3, , 4]);
|
719
|
+
return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId, getLWIDetailsOptionalParams)];
|
681
720
|
case 2:
|
682
|
-
lwiDetails =
|
721
|
+
lwiDetails = _e.sent();
|
683
722
|
state = lwiDetails.State, conversationId = lwiDetails.ConversationId, agentAcceptedOn = lwiDetails.AgentAcceptedOn;
|
684
723
|
liveWorkItemDetails = {
|
685
724
|
state: state,
|
@@ -690,11 +729,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
690
729
|
}
|
691
730
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
692
731
|
RequestId: this.requestId,
|
693
|
-
ChatId: ((
|
732
|
+
ChatId: ((_d = this.chatToken) === null || _d === void 0 ? void 0 : _d.chatId) || '',
|
694
733
|
});
|
695
734
|
return [2 /*return*/, liveWorkItemDetails];
|
696
735
|
case 3:
|
697
|
-
error_10 =
|
736
|
+
error_10 = _e.sent();
|
698
737
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
699
738
|
RequestId: this.requestId,
|
700
739
|
ChatId: this.chatToken.chatId || '',
|
@@ -1450,7 +1489,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1450
1489
|
ChatId: this.chatToken.chatId,
|
1451
1490
|
EmailAddress: body.emailAddress,
|
1452
1491
|
DefaultAttachmentMessage: body.attachmentMessage,
|
1453
|
-
CustomerLocale: body.locale
|
1492
|
+
CustomerLocale: body.locale || locale_1.getLocaleStringFromId(this.localeId)
|
1454
1493
|
};
|
1455
1494
|
emailResponse = this.OCClient.emailTranscript(this.requestId, this.chatToken.token, emailRequestBody, emailTranscriptOptionalParams);
|
1456
1495
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EmailLiveChatTranscript, {
|
@@ -1500,36 +1539,36 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1500
1539
|
});
|
1501
1540
|
});
|
1502
1541
|
};
|
1503
|
-
OmnichannelChatSDK.prototype.createChatAdapter = function (
|
1504
|
-
if (
|
1542
|
+
OmnichannelChatSDK.prototype.createChatAdapter = function (optionalParams) {
|
1543
|
+
if (optionalParams === void 0) { optionalParams = {}; }
|
1505
1544
|
return __awaiter(this, void 0, void 0, function () {
|
1506
|
-
var supportedChatAdapterProtocols;
|
1545
|
+
var protocol, supportedChatAdapterProtocols;
|
1507
1546
|
var _this = this;
|
1508
1547
|
return __generator(this, function (_a) {
|
1509
1548
|
if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
|
1510
1549
|
return [2 /*return*/, Promise.reject('ChatAdapter is only supported on browser')];
|
1511
1550
|
}
|
1551
|
+
protocol = optionalParams.protocol;
|
1512
1552
|
supportedChatAdapterProtocols = [ChatAdapterProtocols_1.default.ACS, ChatAdapterProtocols_1.default.IC3];
|
1513
1553
|
if (protocol && !supportedChatAdapterProtocols.includes(protocol)) {
|
1514
1554
|
return [2 /*return*/, Promise.reject("ChatAdapter for protocol " + protocol + " currently not supported")];
|
1515
1555
|
}
|
1516
1556
|
if (protocol === ChatAdapterProtocols_1.default.ACS || this.liveChatVersion === LiveChatVersion_1.default.V2) {
|
1517
1557
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1518
|
-
var
|
1558
|
+
var options, defaultEgressMiddlewares, defaultIngressMiddlewares, egressMiddleware, ingressMiddleware, featuresOption, acsAdapterCDNUrl;
|
1519
1559
|
var _this = this;
|
1520
1560
|
var _a;
|
1521
1561
|
return __generator(this, function (_b) {
|
1522
1562
|
switch (_b.label) {
|
1523
1563
|
case 0:
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
};
|
1564
|
+
options = optionalParams.ACSAdapter ? optionalParams.ACSAdapter.options : {};
|
1565
|
+
defaultEgressMiddlewares = [createChannelDataEgressMiddleware_1.default({ widgetId: this.omnichannelConfig.widgetId }), createFormatEgressTagsMiddleware_1.default()];
|
1566
|
+
defaultIngressMiddlewares = [createFormatIngressTagsMiddleware_1.default()];
|
1567
|
+
egressMiddleware = (options === null || options === void 0 ? void 0 : options.egressMiddleware) ? __spreadArrays(options.egressMiddleware, defaultEgressMiddlewares) : __spreadArrays(defaultEgressMiddlewares);
|
1568
|
+
ingressMiddleware = (options === null || options === void 0 ? void 0 : options.ingressMiddleware) ? __spreadArrays(options.egressMiddleware, defaultIngressMiddlewares) : __spreadArrays(defaultIngressMiddlewares);
|
1569
|
+
featuresOption = __assign(__assign({ enableAdaptiveCards: true, enableThreadMemberUpdateNotification: true, enableLeaveThreadOnWindowClosed: false }, options), { // overrides
|
1570
|
+
ingressMiddleware: ingressMiddleware,
|
1571
|
+
egressMiddleware: egressMiddleware });
|
1533
1572
|
acsAdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.ACS);
|
1534
1573
|
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1535
1574
|
ACSAdapter: acsAdapterCDNUrl
|
@@ -1540,7 +1579,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1540
1579
|
try {
|
1541
1580
|
var ChatAdapter = window.ChatAdapter; // eslint-disable-line @typescript-eslint/no-explicit-any
|
1542
1581
|
var fileManager = new AMSFileManager_1.default(_this.AMSClient, _this.acsAdapterLogger);
|
1543
|
-
var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager, 1000, ACSParticipantDisplayName_1.default.Customer, undefined,
|
1582
|
+
var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager, 1000, ACSParticipantDisplayName_1.default.Customer, undefined, // chatClient
|
1583
|
+
undefined, // logger
|
1544
1584
|
featuresOption);
|
1545
1585
|
resolve(adapter);
|
1546
1586
|
}
|
@@ -1559,12 +1599,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1559
1599
|
}
|
1560
1600
|
else if (protocol === ChatAdapterProtocols_1.default.IC3 || this.liveChatVersion === LiveChatVersion_1.default.V1) {
|
1561
1601
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1562
|
-
var ic3AdapterCDNUrl;
|
1602
|
+
var options, ic3AdapterCDNUrl;
|
1563
1603
|
var _this = this;
|
1564
1604
|
var _a;
|
1565
1605
|
return __generator(this, function (_b) {
|
1566
1606
|
switch (_b.label) {
|
1567
1607
|
case 0:
|
1608
|
+
options = optionalParams.IC3Adapter ? optionalParams.IC3Adapter.options : {};
|
1568
1609
|
ic3AdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.IC3);
|
1569
1610
|
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1570
1611
|
IC3Adapter: ic3AdapterCDNUrl
|
@@ -1573,17 +1614,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1573
1614
|
return [4 /*yield*/, WebUtils_1.loadScript(ic3AdapterCDNUrl, function () {
|
1574
1615
|
/* istanbul ignore next */
|
1575
1616
|
_this.debug && console.debug('IC3Adapter loaded!');
|
1576
|
-
var adapterConfig = {
|
1577
|
-
|
1578
|
-
userDisplayName: 'Customer',
|
1579
|
-
userId: 'teamsvisitor',
|
1580
|
-
sdkURL: _this.resolveIC3ClientUrl(),
|
1581
|
-
sdk: _this.IC3Client
|
1582
|
-
};
|
1617
|
+
var adapterConfig = __assign({ chatToken: _this.chatToken, userDisplayName: 'Customer', userId: _this.chatToken.visitorId || 'teamsvisitor', sdkURL: _this.resolveIC3ClientUrl(), sdk: _this.IC3Client }, options // overrides
|
1618
|
+
);
|
1583
1619
|
var adapter = new window.Microsoft.BotFramework.WebChat.IC3Adapter(adapterConfig);
|
1584
1620
|
adapter.logger = _this.ic3ClientLogger;
|
1585
|
-
// Keep iframe communication alive to reuse the same IC3Client instance
|
1586
|
-
window.Microsoft.BotFramework.WebChat.IC3SDKProvider.disposeSdk = function () { }; // eslint-disable-line @typescript-eslint/no-empty-function
|
1587
1621
|
_this.scenarioMarker.completeScenario(TelemetryEvent_1.default.CreateIC3Adapter);
|
1588
1622
|
resolve(adapter);
|
1589
1623
|
}, function () {
|
@@ -1604,16 +1638,31 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1604
1638
|
OmnichannelChatSDK.prototype.getVoiceVideoCalling = function (params) {
|
1605
1639
|
if (params === void 0) { params = {}; }
|
1606
1640
|
return __awaiter(this, void 0, void 0, function () {
|
1607
|
-
var chatConfig, liveWSAndLiveChatEngJoin, msdyn_widgetsnippet, widgetSnippetSourceRegex, result;
|
1641
|
+
var exceptionDetails, exceptionDetails, chatConfig, liveWSAndLiveChatEngJoin, msdyn_widgetsnippet, widgetSnippetSourceRegex, result;
|
1608
1642
|
var _this = this;
|
1609
1643
|
return __generator(this, function (_a) {
|
1610
1644
|
switch (_a.label) {
|
1611
1645
|
case 0:
|
1646
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
|
1612
1647
|
if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
|
1613
|
-
|
1648
|
+
exceptionDetails = {
|
1649
|
+
response: "UnsupportedPlatform",
|
1650
|
+
message: "VoiceVideoCalling is only supported on browser"
|
1651
|
+
};
|
1652
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
|
1653
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1654
|
+
});
|
1655
|
+
throw new Error(exceptionDetails.response);
|
1614
1656
|
}
|
1615
1657
|
if (this.callingOption.toString() === CallingOptionsOptionSetNumber_1.default.NoCalling.toString()) {
|
1616
|
-
|
1658
|
+
exceptionDetails = {
|
1659
|
+
response: "FeatureDisabled",
|
1660
|
+
message: "Voice and video call is not enabled"
|
1661
|
+
};
|
1662
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
|
1663
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1664
|
+
});
|
1665
|
+
throw new Error(exceptionDetails.response);
|
1617
1666
|
}
|
1618
1667
|
return [4 /*yield*/, this.getChatConfig()];
|
1619
1668
|
case 1:
|
@@ -1623,14 +1672,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1623
1672
|
widgetSnippetSourceRegex = new RegExp("src=\"(https:\\/\\/[\\w-.]+)[\\w-.\\/]+\"");
|
1624
1673
|
result = msdyn_widgetsnippet.match(widgetSnippetSourceRegex);
|
1625
1674
|
if (result && result.length) {
|
1626
|
-
return [2 /*return*/, new Promise(function (resolve
|
1675
|
+
return [2 /*return*/, new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
|
1627
1676
|
var LiveChatWidgetLibCDNUrl;
|
1628
1677
|
var _this = this;
|
1629
1678
|
var _a;
|
1630
1679
|
return __generator(this, function (_b) {
|
1631
1680
|
switch (_b.label) {
|
1632
1681
|
case 0:
|
1633
|
-
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
|
1634
1682
|
LiveChatWidgetLibCDNUrl = result[1] + "/livechatwidget/WebChatControl/lib/CallingBundle.js";
|
1635
1683
|
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1636
1684
|
VoiceVideoCalling: LiveChatWidgetLibCDNUrl
|
@@ -1654,13 +1702,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1654
1702
|
var exceptionDetails;
|
1655
1703
|
return __generator(this, function (_a) {
|
1656
1704
|
exceptionDetails = {
|
1657
|
-
response: "VoiceVideoCallingLoadFailed"
|
1705
|
+
response: "VoiceVideoCallingLoadFailed",
|
1706
|
+
message: "Failed to load VoiceVideoCalling"
|
1658
1707
|
};
|
1659
1708
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
|
1660
1709
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1661
1710
|
});
|
1662
|
-
|
1663
|
-
return [2 /*return*/];
|
1711
|
+
throw new Error(exceptionDetails.response);
|
1664
1712
|
});
|
1665
1713
|
}); })];
|
1666
1714
|
case 1:
|
@@ -1677,7 +1725,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1677
1725
|
};
|
1678
1726
|
OmnichannelChatSDK.prototype.getPostChatSurveyContext = function () {
|
1679
1727
|
return __awaiter(this, void 0, void 0, function () {
|
1680
|
-
var conversationId,
|
1728
|
+
var conversationId, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, postConversationSurveyOwnerId, liveWorkItemDetails, participantJoined, surveyInviteLinkRequest, optionalParams, surveyInviteLinkResponse, surveyInviteLink, formsProLocale, postChatContext, ex_1;
|
1681
1729
|
return __generator(this, function (_a) {
|
1682
1730
|
switch (_a.label) {
|
1683
1731
|
case 0:
|
@@ -1687,11 +1735,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1687
1735
|
_a.label = 1;
|
1688
1736
|
case 1:
|
1689
1737
|
_a.trys.push([1, 6, , 7]);
|
1690
|
-
|
1691
|
-
liveWSAndLiveChatEngJoin = chatConfig.LiveWSAndLiveChatEngJoin, chatWidgetLanguage = chatConfig.ChatWidgetLanguage;
|
1738
|
+
liveWSAndLiveChatEngJoin = this.liveChatConfig.LiveWSAndLiveChatEngJoin;
|
1692
1739
|
msdyn_postconversationsurveyenable = liveWSAndLiveChatEngJoin.msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_sourcesurveyidentifier, postConversationSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationSurveyOwnerId;
|
1693
|
-
msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
|
1694
|
-
localeId = msdyn_localeid !== null && msdyn_localeid !== void 0 ? msdyn_localeid : "1033";
|
1695
1740
|
if (!msdyn_postconversationsurveyenable) return [3 /*break*/, 4];
|
1696
1741
|
return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId)];
|
1697
1742
|
case 2:
|
@@ -1701,7 +1746,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1701
1746
|
surveyInviteLinkRequest = {
|
1702
1747
|
"FormId": msfp_sourcesurveyidentifier,
|
1703
1748
|
"ConversationId": conversationId,
|
1704
|
-
"OCLocaleCode": locale_1.getLocaleStringFromId(localeId)
|
1749
|
+
"OCLocaleCode": locale_1.getLocaleStringFromId(this.localeId) || locale_1.getLocaleStringFromId(locale_1.defaultLocaleId)
|
1705
1750
|
};
|
1706
1751
|
optionalParams = {
|
1707
1752
|
"requestId": this.requestId
|
@@ -1790,7 +1835,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1790
1835
|
this.debug && console.debug('IC3Client');
|
1791
1836
|
// Use IC3Client if browser is detected
|
1792
1837
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1793
|
-
var ic3ClientCDNUrl;
|
1838
|
+
var ic3ClientCDNUrl, IC3Client;
|
1794
1839
|
var _this = this;
|
1795
1840
|
var _a;
|
1796
1841
|
return __generator(this, function (_b) {
|
@@ -1801,6 +1846,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1801
1846
|
IC3Client: ic3ClientCDNUrl
|
1802
1847
|
});
|
1803
1848
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetIC3Client);
|
1849
|
+
if (!this.IC3SDKProvider) return [3 /*break*/, 2];
|
1850
|
+
return [4 /*yield*/, this.IC3SDKProvider.getSDK({
|
1851
|
+
hostType: HostType_1.default.IFrame,
|
1852
|
+
protocolType: ProtocoleType_1.default.IC3V1SDK,
|
1853
|
+
logger: this.ic3ClientLogger // eslint-disable-line @typescript-eslint/no-explicit-any
|
1854
|
+
})];
|
1855
|
+
case 1:
|
1856
|
+
IC3Client = _b.sent();
|
1857
|
+
return [2 /*return*/, resolve(IC3Client)];
|
1858
|
+
case 2:
|
1804
1859
|
window.addEventListener("ic3:sdk:load", function () { return __awaiter(_this, void 0, void 0, function () {
|
1805
1860
|
var ic3sdk, IC3SDKProvider, IC3Client;
|
1806
1861
|
return __generator(this, function (_a) {
|
@@ -1837,7 +1892,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1837
1892
|
});
|
1838
1893
|
reject('Failed to load IC3Client');
|
1839
1894
|
})];
|
1840
|
-
case
|
1895
|
+
case 3:
|
1841
1896
|
_b.sent();
|
1842
1897
|
return [2 /*return*/];
|
1843
1898
|
}
|
@@ -1849,15 +1904,17 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1849
1904
|
};
|
1850
1905
|
OmnichannelChatSDK.prototype.getChatConfig = function () {
|
1851
1906
|
return __awaiter(this, void 0, void 0, function () {
|
1852
|
-
var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled,
|
1853
|
-
return __generator(this, function (
|
1854
|
-
switch (
|
1907
|
+
var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled, error_18;
|
1908
|
+
return __generator(this, function (_a) {
|
1909
|
+
switch (_a.label) {
|
1855
1910
|
case 0:
|
1856
|
-
|
1911
|
+
_a.trys.push([0, 4, , 5]);
|
1857
1912
|
return [4 /*yield*/, this.OCClient.getChatConfig()];
|
1858
1913
|
case 1:
|
1859
|
-
liveChatConfig =
|
1860
|
-
dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion;
|
1914
|
+
liveChatConfig = _a.sent();
|
1915
|
+
dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
|
1916
|
+
msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
|
1917
|
+
this.localeId = msdyn_localeid || locale_1.defaultLocaleId;
|
1861
1918
|
this.liveChatVersion = liveChatVersion || LiveChatVersion_1.default.V1;
|
1862
1919
|
/* istanbul ignore next */
|
1863
1920
|
this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] " + this.liveChatVersion);
|
@@ -1880,47 +1937,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1880
1937
|
if (isPreChatEnabled && preChatSurvey && preChatSurvey.trim().length > 0) {
|
1881
1938
|
this.preChatSurvey = preChatSurvey;
|
1882
1939
|
}
|
1883
|
-
if (!this.authSettings) return [3 /*break*/,
|
1884
|
-
this.
|
1885
|
-
if (!this.chatSDKConfig.getAuthToken) return [3 /*break*/, 6];
|
1886
|
-
_b.label = 2;
|
1940
|
+
if (!this.authSettings) return [3 /*break*/, 3];
|
1941
|
+
return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
|
1887
1942
|
case 2:
|
1888
|
-
|
1889
|
-
|
1943
|
+
_a.sent();
|
1944
|
+
_a.label = 3;
|
1890
1945
|
case 3:
|
1891
|
-
token = _b.sent();
|
1892
|
-
if (token) {
|
1893
|
-
this.authenticatedUserToken = token;
|
1894
|
-
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetAuthToken);
|
1895
|
-
}
|
1896
|
-
else {
|
1897
|
-
exceptionDetails = {
|
1898
|
-
response: "UndefinedAuthToken"
|
1899
|
-
};
|
1900
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
1901
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1902
|
-
});
|
1903
|
-
}
|
1904
|
-
return [3 /*break*/, 5];
|
1905
|
-
case 4:
|
1906
|
-
_a = _b.sent();
|
1907
|
-
exceptionDetails = {
|
1908
|
-
response: "GetAuthTokenFailed"
|
1909
|
-
};
|
1910
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
1911
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1912
|
-
});
|
1913
|
-
return [3 /*break*/, 5];
|
1914
|
-
case 5: return [3 /*break*/, 7];
|
1915
|
-
case 6:
|
1916
|
-
exceptionDetails = {
|
1917
|
-
response: "GetAuthTokenNotFound"
|
1918
|
-
};
|
1919
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
1920
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1921
|
-
});
|
1922
|
-
_b.label = 7;
|
1923
|
-
case 7:
|
1924
1946
|
if (this.preChatSurvey) {
|
1925
1947
|
/* istanbul ignore next */
|
1926
1948
|
this.debug && console.log('Prechat Survey!');
|
@@ -1928,11 +1950,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1928
1950
|
this.callingOption = msdyn_callingoptions;
|
1929
1951
|
this.liveChatConfig = liveChatConfig;
|
1930
1952
|
return [2 /*return*/, this.liveChatConfig];
|
1931
|
-
case
|
1932
|
-
error_18 =
|
1953
|
+
case 4:
|
1954
|
+
error_18 = _a.sent();
|
1933
1955
|
console.error("OmnichannelChatSDK/getChatConfig/error " + error_18);
|
1934
1956
|
return [2 /*return*/, error_18];
|
1935
|
-
case
|
1957
|
+
case 5: return [2 /*return*/];
|
1936
1958
|
}
|
1937
1959
|
});
|
1938
1960
|
});
|
@@ -2014,6 +2036,57 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2014
2036
|
});
|
2015
2037
|
});
|
2016
2038
|
};
|
2039
|
+
OmnichannelChatSDK.prototype.setAuthTokenProvider = function (provider) {
|
2040
|
+
return __awaiter(this, void 0, void 0, function () {
|
2041
|
+
var token, exceptionDetails, _a, exceptionDetails, exceptionDetails;
|
2042
|
+
return __generator(this, function (_b) {
|
2043
|
+
switch (_b.label) {
|
2044
|
+
case 0:
|
2045
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetAuthToken);
|
2046
|
+
this.chatSDKConfig.getAuthToken = provider;
|
2047
|
+
if (!this.chatSDKConfig.getAuthToken) return [3 /*break*/, 5];
|
2048
|
+
_b.label = 1;
|
2049
|
+
case 1:
|
2050
|
+
_b.trys.push([1, 3, , 4]);
|
2051
|
+
return [4 /*yield*/, this.chatSDKConfig.getAuthToken()];
|
2052
|
+
case 2:
|
2053
|
+
token = _b.sent();
|
2054
|
+
if (token) {
|
2055
|
+
this.authenticatedUserToken = token;
|
2056
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetAuthToken);
|
2057
|
+
}
|
2058
|
+
else {
|
2059
|
+
exceptionDetails = {
|
2060
|
+
response: "UndefinedAuthToken"
|
2061
|
+
};
|
2062
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2063
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2064
|
+
});
|
2065
|
+
}
|
2066
|
+
return [3 /*break*/, 4];
|
2067
|
+
case 3:
|
2068
|
+
_a = _b.sent();
|
2069
|
+
exceptionDetails = {
|
2070
|
+
response: "GetAuthTokenFailed"
|
2071
|
+
};
|
2072
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2073
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2074
|
+
});
|
2075
|
+
return [3 /*break*/, 4];
|
2076
|
+
case 4: return [3 /*break*/, 6];
|
2077
|
+
case 5:
|
2078
|
+
exceptionDetails = {
|
2079
|
+
response: "GetAuthTokenNotFound"
|
2080
|
+
};
|
2081
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2082
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2083
|
+
});
|
2084
|
+
_b.label = 6;
|
2085
|
+
case 6: return [2 /*return*/];
|
2086
|
+
}
|
2087
|
+
});
|
2088
|
+
});
|
2089
|
+
};
|
2017
2090
|
return OmnichannelChatSDK;
|
2018
2091
|
}());
|
2019
2092
|
exports.default = OmnichannelChatSDK;
|