@microsoft/omnichannel-chat-sdk 1.0.1-main.7615829 → 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 +9 -0
- package/README.md +69 -59
- package/lib/OmnichannelChatSDK.d.ts +3 -1
- package/lib/OmnichannelChatSDK.js +239 -174
- 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/tsconfig.tsbuildinfo +104 -24
- package/lib/utils/WebUtils.d.ts +3 -1
- package/lib/utils/WebUtils.js +8 -2
- package/lib/utils/WebUtils.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");
|
@@ -298,47 +300,55 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
298
300
|
});
|
299
301
|
};
|
300
302
|
OmnichannelChatSDK.prototype.startChat = function (optionalParams) {
|
301
|
-
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;
|
302
304
|
if (optionalParams === void 0) { optionalParams = {}; }
|
303
305
|
return __awaiter(this, void 0, void 0, function () {
|
304
|
-
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;
|
305
307
|
var _this = this;
|
306
|
-
return __generator(this, function (
|
307
|
-
switch (
|
308
|
+
return __generator(this, function (_w) {
|
309
|
+
switch (_w.label) {
|
308
310
|
case 0:
|
309
311
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
|
310
312
|
RequestId: this.requestId
|
311
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:
|
312
322
|
if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
|
313
323
|
this.reconnectId = optionalParams.reconnectId;
|
314
324
|
}
|
315
|
-
if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/,
|
316
|
-
|
317
|
-
case
|
318
|
-
|
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]);
|
319
329
|
reconnectableChatsParams = {
|
320
330
|
authenticatedUserToken: this.authenticatedUserToken
|
321
331
|
};
|
322
332
|
return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
|
323
|
-
case
|
324
|
-
reconnectableChatsResponse =
|
333
|
+
case 4:
|
334
|
+
reconnectableChatsResponse = _w.sent();
|
325
335
|
if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
|
326
336
|
this.reconnectId = reconnectableChatsResponse.reconnectid;
|
327
337
|
}
|
328
|
-
return [3 /*break*/,
|
329
|
-
case
|
330
|
-
|
338
|
+
return [3 /*break*/, 6];
|
339
|
+
case 5:
|
340
|
+
_t = _w.sent();
|
331
341
|
exceptionDetails = {
|
332
342
|
response: "OCClientGetReconnectableChatsFailed"
|
333
343
|
};
|
334
344
|
throw Error(exceptionDetails.response);
|
335
|
-
case
|
336
|
-
if (!(optionalParams.liveChatContext && !this.reconnectId)) return [3 /*break*/,
|
345
|
+
case 6:
|
346
|
+
if (!(optionalParams.liveChatContext && !this.reconnectId)) return [3 /*break*/, 8];
|
337
347
|
this.chatToken = optionalParams.liveChatContext.chatToken || {};
|
338
348
|
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
|
339
349
|
return [4 /*yield*/, this.getConversationDetails()];
|
340
|
-
case
|
341
|
-
conversationDetails =
|
350
|
+
case 7:
|
351
|
+
conversationDetails = _w.sent();
|
342
352
|
if (Object.keys(conversationDetails).length === 0) {
|
343
353
|
exceptionDetails = {
|
344
354
|
response: "InvalidConversation"
|
@@ -363,14 +373,14 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
363
373
|
console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
|
364
374
|
throw Error(exceptionDetails.response);
|
365
375
|
}
|
366
|
-
|
367
|
-
case 6:
|
368
|
-
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 8];
|
369
|
-
return [4 /*yield*/, this.getChatToken(false)];
|
370
|
-
case 7:
|
371
|
-
_s.sent();
|
372
|
-
_s.label = 8;
|
376
|
+
_w.label = 8;
|
373
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:
|
374
384
|
(_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
|
375
385
|
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
|
376
386
|
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
|
@@ -410,28 +420,33 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
410
420
|
if (this.authenticatedUserToken) {
|
411
421
|
sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
412
422
|
}
|
413
|
-
if (!!optionalParams.liveChatContext) return [3 /*break*/,
|
414
|
-
|
415
|
-
case 9:
|
416
|
-
_s.trys.push([9, 11, , 12]);
|
417
|
-
return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
|
418
|
-
case 10:
|
419
|
-
_s.sent();
|
420
|
-
return [3 /*break*/, 12];
|
423
|
+
if (!!optionalParams.liveChatContext) return [3 /*break*/, 14];
|
424
|
+
_w.label = 11;
|
421
425
|
case 11:
|
422
|
-
|
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();
|
423
433
|
exceptionDetails = {
|
424
434
|
response: "OCClientSessionInitFailed"
|
425
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
|
+
}
|
426
442
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
427
443
|
RequestId: this.requestId,
|
428
444
|
ChatId: this.chatToken.chatId,
|
429
445
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
430
446
|
});
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
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];
|
435
450
|
chatAdapterConfig = {
|
436
451
|
token: this.chatToken.token,
|
437
452
|
id: this.chatToken.visitorId || 'teamsvisitor',
|
@@ -439,18 +454,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
439
454
|
environmentUrl: this.chatToken.acsEndpoint,
|
440
455
|
pollingInterval: 1000
|
441
456
|
};
|
442
|
-
|
443
|
-
case
|
444
|
-
|
445
|
-
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({
|
446
461
|
token: chatAdapterConfig.token,
|
447
462
|
environmentUrl: chatAdapterConfig.environmentUrl
|
448
463
|
}))];
|
449
|
-
case
|
450
|
-
|
451
|
-
return [3 /*break*/,
|
452
|
-
case
|
453
|
-
error_4 =
|
464
|
+
case 16:
|
465
|
+
_w.sent();
|
466
|
+
return [3 /*break*/, 18];
|
467
|
+
case 17:
|
468
|
+
error_4 = _w.sent();
|
454
469
|
exceptionDetails = {
|
455
470
|
response: "ACSClientInitializeFailed"
|
456
471
|
};
|
@@ -461,23 +476,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
461
476
|
});
|
462
477
|
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_4);
|
463
478
|
return [2 /*return*/, error_4];
|
464
|
-
case
|
465
|
-
|
466
|
-
|
467
|
-
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({
|
468
483
|
id: chatAdapterConfig.id,
|
469
484
|
threadId: chatAdapterConfig.threadId,
|
470
485
|
pollingInterval: chatAdapterConfig.pollingInterval
|
471
486
|
}))];
|
472
|
-
case
|
473
|
-
|
487
|
+
case 19:
|
488
|
+
_u.conversation = (_w.sent());
|
474
489
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
475
490
|
RequestId: this.requestId,
|
476
491
|
ChatId: this.chatToken.chatId
|
477
492
|
});
|
478
|
-
return [3 /*break*/,
|
479
|
-
case
|
480
|
-
error_5 =
|
493
|
+
return [3 /*break*/, 21];
|
494
|
+
case 20:
|
495
|
+
error_5 = _w.sent();
|
481
496
|
exceptionDetails = {
|
482
497
|
response: "ACSClientJoinConversationFailed"
|
483
498
|
};
|
@@ -488,16 +503,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
488
503
|
});
|
489
504
|
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_5);
|
490
505
|
throw Error(exceptionDetails.response);
|
491
|
-
case
|
492
|
-
|
493
|
-
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({
|
494
509
|
chatToken: this.chatToken
|
495
510
|
}))];
|
496
|
-
case
|
497
|
-
|
498
|
-
return [3 /*break*/,
|
499
|
-
case
|
500
|
-
error_6 =
|
511
|
+
case 22:
|
512
|
+
_w.sent();
|
513
|
+
return [3 /*break*/, 24];
|
514
|
+
case 23:
|
515
|
+
error_6 = _w.sent();
|
501
516
|
exceptionDetails = {
|
502
517
|
response: "AMSClientInitializeFailed"
|
503
518
|
};
|
@@ -507,19 +522,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
507
522
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
508
523
|
});
|
509
524
|
throw Error(exceptionDetails.response);
|
510
|
-
case
|
511
|
-
case
|
512
|
-
|
525
|
+
case 24: return [3 /*break*/, 31];
|
526
|
+
case 25:
|
527
|
+
_w.trys.push([25, 27, , 28]);
|
513
528
|
return [4 /*yield*/, this.IC3Client.initialize({
|
514
529
|
token: this.chatToken.token,
|
515
530
|
regionGtms: this.chatToken.regionGTMS,
|
516
531
|
visitor: true
|
517
532
|
})];
|
518
|
-
case
|
519
|
-
|
520
|
-
return [3 /*break*/,
|
521
|
-
case
|
522
|
-
error_7 =
|
533
|
+
case 26:
|
534
|
+
_w.sent();
|
535
|
+
return [3 /*break*/, 28];
|
536
|
+
case 27:
|
537
|
+
error_7 = _w.sent();
|
523
538
|
exceptionDetails = {
|
524
539
|
response: "IC3ClientInitializeFailed"
|
525
540
|
};
|
@@ -530,19 +545,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
530
545
|
});
|
531
546
|
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_7);
|
532
547
|
return [2 /*return*/, error_7];
|
533
|
-
case
|
534
|
-
|
535
|
-
|
548
|
+
case 28:
|
549
|
+
_w.trys.push([28, 30, , 31]);
|
550
|
+
_v = this;
|
536
551
|
return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
|
537
|
-
case
|
538
|
-
|
552
|
+
case 29:
|
553
|
+
_v.conversation = _w.sent();
|
539
554
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
540
555
|
RequestId: this.requestId,
|
541
556
|
ChatId: this.chatToken.chatId
|
542
557
|
});
|
543
|
-
return [3 /*break*/,
|
544
|
-
case
|
545
|
-
error_8 =
|
558
|
+
return [3 /*break*/, 31];
|
559
|
+
case 30:
|
560
|
+
error_8 = _w.sent();
|
546
561
|
exceptionDetails = {
|
547
562
|
response: "IC3ClientJoinConversationFailed"
|
548
563
|
};
|
@@ -553,8 +568,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
553
568
|
});
|
554
569
|
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_8);
|
555
570
|
return [2 /*return*/, error_8];
|
556
|
-
case
|
557
|
-
if (this.isPersistentChat && !((
|
571
|
+
case 31:
|
572
|
+
if (this.isPersistentChat && !((_q = this.chatSDKConfig.persistentChat) === null || _q === void 0 ? void 0 : _q.disable)) {
|
558
573
|
this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
559
574
|
return __generator(this, function (_a) {
|
560
575
|
switch (_a.label) {
|
@@ -565,7 +580,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
565
580
|
return [2 /*return*/];
|
566
581
|
}
|
567
582
|
});
|
568
|
-
}); }, (
|
583
|
+
}); }, (_r = this.chatSDKConfig.persistentChat) === null || _r === void 0 ? void 0 : _r.tokenUpdateTime);
|
569
584
|
}
|
570
585
|
return [2 /*return*/];
|
571
586
|
}
|
@@ -612,6 +627,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
612
627
|
this.requestId = ocsdk_1.uuidv4();
|
613
628
|
this.chatToken = {};
|
614
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
|
+
}
|
615
635
|
(_d = this.ic3ClientLogger) === null || _d === void 0 ? void 0 : _d.setRequestId(this.requestId);
|
616
636
|
(_e = this.ic3ClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId('');
|
617
637
|
(_f = this.ocSdkLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
|
@@ -673,22 +693,32 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
673
693
|
});
|
674
694
|
};
|
675
695
|
OmnichannelChatSDK.prototype.getConversationDetails = function () {
|
676
|
-
var _a, _b;
|
696
|
+
var _a, _b, _c, _d;
|
677
697
|
return __awaiter(this, void 0, void 0, function () {
|
678
|
-
var lwiDetails, state, conversationId, agentAcceptedOn, liveWorkItemDetails, error_10;
|
679
|
-
return __generator(this, function (
|
680
|
-
switch (
|
698
|
+
var getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, liveWorkItemDetails, error_10;
|
699
|
+
return __generator(this, function (_e) {
|
700
|
+
switch (_e.label) {
|
681
701
|
case 0:
|
682
702
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
683
703
|
RequestId: this.requestId,
|
684
704
|
ChatId: ((_a = this.chatToken) === null || _a === void 0 ? void 0 : _a.chatId) || '',
|
685
705
|
});
|
686
|
-
|
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;
|
687
717
|
case 1:
|
688
|
-
|
689
|
-
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)];
|
690
720
|
case 2:
|
691
|
-
lwiDetails =
|
721
|
+
lwiDetails = _e.sent();
|
692
722
|
state = lwiDetails.State, conversationId = lwiDetails.ConversationId, agentAcceptedOn = lwiDetails.AgentAcceptedOn;
|
693
723
|
liveWorkItemDetails = {
|
694
724
|
state: state,
|
@@ -699,11 +729,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
699
729
|
}
|
700
730
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
701
731
|
RequestId: this.requestId,
|
702
|
-
ChatId: ((
|
732
|
+
ChatId: ((_d = this.chatToken) === null || _d === void 0 ? void 0 : _d.chatId) || '',
|
703
733
|
});
|
704
734
|
return [2 /*return*/, liveWorkItemDetails];
|
705
735
|
case 3:
|
706
|
-
error_10 =
|
736
|
+
error_10 = _e.sent();
|
707
737
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
708
738
|
RequestId: this.requestId,
|
709
739
|
ChatId: this.chatToken.chatId || '',
|
@@ -1459,7 +1489,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1459
1489
|
ChatId: this.chatToken.chatId,
|
1460
1490
|
EmailAddress: body.emailAddress,
|
1461
1491
|
DefaultAttachmentMessage: body.attachmentMessage,
|
1462
|
-
CustomerLocale: body.locale
|
1492
|
+
CustomerLocale: body.locale || locale_1.getLocaleStringFromId(this.localeId)
|
1463
1493
|
};
|
1464
1494
|
emailResponse = this.OCClient.emailTranscript(this.requestId, this.chatToken.token, emailRequestBody, emailTranscriptOptionalParams);
|
1465
1495
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EmailLiveChatTranscript, {
|
@@ -1509,36 +1539,36 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1509
1539
|
});
|
1510
1540
|
});
|
1511
1541
|
};
|
1512
|
-
OmnichannelChatSDK.prototype.createChatAdapter = function (
|
1513
|
-
if (
|
1542
|
+
OmnichannelChatSDK.prototype.createChatAdapter = function (optionalParams) {
|
1543
|
+
if (optionalParams === void 0) { optionalParams = {}; }
|
1514
1544
|
return __awaiter(this, void 0, void 0, function () {
|
1515
|
-
var supportedChatAdapterProtocols;
|
1545
|
+
var protocol, supportedChatAdapterProtocols;
|
1516
1546
|
var _this = this;
|
1517
1547
|
return __generator(this, function (_a) {
|
1518
1548
|
if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
|
1519
1549
|
return [2 /*return*/, Promise.reject('ChatAdapter is only supported on browser')];
|
1520
1550
|
}
|
1551
|
+
protocol = optionalParams.protocol;
|
1521
1552
|
supportedChatAdapterProtocols = [ChatAdapterProtocols_1.default.ACS, ChatAdapterProtocols_1.default.IC3];
|
1522
1553
|
if (protocol && !supportedChatAdapterProtocols.includes(protocol)) {
|
1523
1554
|
return [2 /*return*/, Promise.reject("ChatAdapter for protocol " + protocol + " currently not supported")];
|
1524
1555
|
}
|
1525
1556
|
if (protocol === ChatAdapterProtocols_1.default.ACS || this.liveChatVersion === LiveChatVersion_1.default.V2) {
|
1526
1557
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1527
|
-
var
|
1558
|
+
var options, defaultEgressMiddlewares, defaultIngressMiddlewares, egressMiddleware, ingressMiddleware, featuresOption, acsAdapterCDNUrl;
|
1528
1559
|
var _this = this;
|
1529
1560
|
var _a;
|
1530
1561
|
return __generator(this, function (_b) {
|
1531
1562
|
switch (_b.label) {
|
1532
1563
|
case 0:
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
};
|
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 });
|
1542
1572
|
acsAdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.ACS);
|
1543
1573
|
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1544
1574
|
ACSAdapter: acsAdapterCDNUrl
|
@@ -1549,7 +1579,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1549
1579
|
try {
|
1550
1580
|
var ChatAdapter = window.ChatAdapter; // eslint-disable-line @typescript-eslint/no-explicit-any
|
1551
1581
|
var fileManager = new AMSFileManager_1.default(_this.AMSClient, _this.acsAdapterLogger);
|
1552
|
-
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
|
1553
1584
|
featuresOption);
|
1554
1585
|
resolve(adapter);
|
1555
1586
|
}
|
@@ -1568,12 +1599,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1568
1599
|
}
|
1569
1600
|
else if (protocol === ChatAdapterProtocols_1.default.IC3 || this.liveChatVersion === LiveChatVersion_1.default.V1) {
|
1570
1601
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1571
|
-
var ic3AdapterCDNUrl;
|
1602
|
+
var options, ic3AdapterCDNUrl;
|
1572
1603
|
var _this = this;
|
1573
1604
|
var _a;
|
1574
1605
|
return __generator(this, function (_b) {
|
1575
1606
|
switch (_b.label) {
|
1576
1607
|
case 0:
|
1608
|
+
options = optionalParams.IC3Adapter ? optionalParams.IC3Adapter.options : {};
|
1577
1609
|
ic3AdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.IC3);
|
1578
1610
|
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1579
1611
|
IC3Adapter: ic3AdapterCDNUrl
|
@@ -1582,17 +1614,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1582
1614
|
return [4 /*yield*/, WebUtils_1.loadScript(ic3AdapterCDNUrl, function () {
|
1583
1615
|
/* istanbul ignore next */
|
1584
1616
|
_this.debug && console.debug('IC3Adapter loaded!');
|
1585
|
-
var adapterConfig = {
|
1586
|
-
|
1587
|
-
userDisplayName: 'Customer',
|
1588
|
-
userId: 'teamsvisitor',
|
1589
|
-
sdkURL: _this.resolveIC3ClientUrl(),
|
1590
|
-
sdk: _this.IC3Client
|
1591
|
-
};
|
1617
|
+
var adapterConfig = __assign({ chatToken: _this.chatToken, userDisplayName: 'Customer', userId: _this.chatToken.visitorId || 'teamsvisitor', sdkURL: _this.resolveIC3ClientUrl(), sdk: _this.IC3Client }, options // overrides
|
1618
|
+
);
|
1592
1619
|
var adapter = new window.Microsoft.BotFramework.WebChat.IC3Adapter(adapterConfig);
|
1593
1620
|
adapter.logger = _this.ic3ClientLogger;
|
1594
|
-
// Keep iframe communication alive to reuse the same IC3Client instance
|
1595
|
-
window.Microsoft.BotFramework.WebChat.IC3SDKProvider.disposeSdk = function () { }; // eslint-disable-line @typescript-eslint/no-empty-function
|
1596
1621
|
_this.scenarioMarker.completeScenario(TelemetryEvent_1.default.CreateIC3Adapter);
|
1597
1622
|
resolve(adapter);
|
1598
1623
|
}, function () {
|
@@ -1613,16 +1638,31 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1613
1638
|
OmnichannelChatSDK.prototype.getVoiceVideoCalling = function (params) {
|
1614
1639
|
if (params === void 0) { params = {}; }
|
1615
1640
|
return __awaiter(this, void 0, void 0, function () {
|
1616
|
-
var chatConfig, liveWSAndLiveChatEngJoin, msdyn_widgetsnippet, widgetSnippetSourceRegex, result;
|
1641
|
+
var exceptionDetails, exceptionDetails, chatConfig, liveWSAndLiveChatEngJoin, msdyn_widgetsnippet, widgetSnippetSourceRegex, result;
|
1617
1642
|
var _this = this;
|
1618
1643
|
return __generator(this, function (_a) {
|
1619
1644
|
switch (_a.label) {
|
1620
1645
|
case 0:
|
1646
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
|
1621
1647
|
if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
|
1622
|
-
|
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);
|
1623
1656
|
}
|
1624
1657
|
if (this.callingOption.toString() === CallingOptionsOptionSetNumber_1.default.NoCalling.toString()) {
|
1625
|
-
|
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);
|
1626
1666
|
}
|
1627
1667
|
return [4 /*yield*/, this.getChatConfig()];
|
1628
1668
|
case 1:
|
@@ -1632,14 +1672,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1632
1672
|
widgetSnippetSourceRegex = new RegExp("src=\"(https:\\/\\/[\\w-.]+)[\\w-.\\/]+\"");
|
1633
1673
|
result = msdyn_widgetsnippet.match(widgetSnippetSourceRegex);
|
1634
1674
|
if (result && result.length) {
|
1635
|
-
return [2 /*return*/, new Promise(function (resolve
|
1675
|
+
return [2 /*return*/, new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
|
1636
1676
|
var LiveChatWidgetLibCDNUrl;
|
1637
1677
|
var _this = this;
|
1638
1678
|
var _a;
|
1639
1679
|
return __generator(this, function (_b) {
|
1640
1680
|
switch (_b.label) {
|
1641
1681
|
case 0:
|
1642
|
-
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
|
1643
1682
|
LiveChatWidgetLibCDNUrl = result[1] + "/livechatwidget/WebChatControl/lib/CallingBundle.js";
|
1644
1683
|
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1645
1684
|
VoiceVideoCalling: LiveChatWidgetLibCDNUrl
|
@@ -1663,13 +1702,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1663
1702
|
var exceptionDetails;
|
1664
1703
|
return __generator(this, function (_a) {
|
1665
1704
|
exceptionDetails = {
|
1666
|
-
response: "VoiceVideoCallingLoadFailed"
|
1705
|
+
response: "VoiceVideoCallingLoadFailed",
|
1706
|
+
message: "Failed to load VoiceVideoCalling"
|
1667
1707
|
};
|
1668
1708
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
|
1669
1709
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1670
1710
|
});
|
1671
|
-
|
1672
|
-
return [2 /*return*/];
|
1711
|
+
throw new Error(exceptionDetails.response);
|
1673
1712
|
});
|
1674
1713
|
}); })];
|
1675
1714
|
case 1:
|
@@ -1796,7 +1835,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1796
1835
|
this.debug && console.debug('IC3Client');
|
1797
1836
|
// Use IC3Client if browser is detected
|
1798
1837
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1799
|
-
var ic3ClientCDNUrl;
|
1838
|
+
var ic3ClientCDNUrl, IC3Client;
|
1800
1839
|
var _this = this;
|
1801
1840
|
var _a;
|
1802
1841
|
return __generator(this, function (_b) {
|
@@ -1807,6 +1846,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1807
1846
|
IC3Client: ic3ClientCDNUrl
|
1808
1847
|
});
|
1809
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:
|
1810
1859
|
window.addEventListener("ic3:sdk:load", function () { return __awaiter(_this, void 0, void 0, function () {
|
1811
1860
|
var ic3sdk, IC3SDKProvider, IC3Client;
|
1812
1861
|
return __generator(this, function (_a) {
|
@@ -1843,7 +1892,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1843
1892
|
});
|
1844
1893
|
reject('Failed to load IC3Client');
|
1845
1894
|
})];
|
1846
|
-
case
|
1895
|
+
case 3:
|
1847
1896
|
_b.sent();
|
1848
1897
|
return [2 /*return*/];
|
1849
1898
|
}
|
@@ -1855,14 +1904,14 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1855
1904
|
};
|
1856
1905
|
OmnichannelChatSDK.prototype.getChatConfig = function () {
|
1857
1906
|
return __awaiter(this, void 0, void 0, function () {
|
1858
|
-
var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled,
|
1859
|
-
return __generator(this, function (
|
1860
|
-
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) {
|
1861
1910
|
case 0:
|
1862
|
-
|
1911
|
+
_a.trys.push([0, 4, , 5]);
|
1863
1912
|
return [4 /*yield*/, this.OCClient.getChatConfig()];
|
1864
1913
|
case 1:
|
1865
|
-
liveChatConfig =
|
1914
|
+
liveChatConfig = _a.sent();
|
1866
1915
|
dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
|
1867
1916
|
msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
|
1868
1917
|
this.localeId = msdyn_localeid || locale_1.defaultLocaleId;
|
@@ -1888,47 +1937,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1888
1937
|
if (isPreChatEnabled && preChatSurvey && preChatSurvey.trim().length > 0) {
|
1889
1938
|
this.preChatSurvey = preChatSurvey;
|
1890
1939
|
}
|
1891
|
-
if (!this.authSettings) return [3 /*break*/,
|
1892
|
-
this.
|
1893
|
-
if (!this.chatSDKConfig.getAuthToken) return [3 /*break*/, 6];
|
1894
|
-
_b.label = 2;
|
1940
|
+
if (!this.authSettings) return [3 /*break*/, 3];
|
1941
|
+
return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
|
1895
1942
|
case 2:
|
1896
|
-
|
1897
|
-
|
1943
|
+
_a.sent();
|
1944
|
+
_a.label = 3;
|
1898
1945
|
case 3:
|
1899
|
-
token = _b.sent();
|
1900
|
-
if (token) {
|
1901
|
-
this.authenticatedUserToken = token;
|
1902
|
-
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetAuthToken);
|
1903
|
-
}
|
1904
|
-
else {
|
1905
|
-
exceptionDetails = {
|
1906
|
-
response: "UndefinedAuthToken"
|
1907
|
-
};
|
1908
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
1909
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1910
|
-
});
|
1911
|
-
}
|
1912
|
-
return [3 /*break*/, 5];
|
1913
|
-
case 4:
|
1914
|
-
_a = _b.sent();
|
1915
|
-
exceptionDetails = {
|
1916
|
-
response: "GetAuthTokenFailed"
|
1917
|
-
};
|
1918
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
1919
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1920
|
-
});
|
1921
|
-
return [3 /*break*/, 5];
|
1922
|
-
case 5: return [3 /*break*/, 7];
|
1923
|
-
case 6:
|
1924
|
-
exceptionDetails = {
|
1925
|
-
response: "GetAuthTokenNotFound"
|
1926
|
-
};
|
1927
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
1928
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1929
|
-
});
|
1930
|
-
_b.label = 7;
|
1931
|
-
case 7:
|
1932
1946
|
if (this.preChatSurvey) {
|
1933
1947
|
/* istanbul ignore next */
|
1934
1948
|
this.debug && console.log('Prechat Survey!');
|
@@ -1936,11 +1950,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1936
1950
|
this.callingOption = msdyn_callingoptions;
|
1937
1951
|
this.liveChatConfig = liveChatConfig;
|
1938
1952
|
return [2 /*return*/, this.liveChatConfig];
|
1939
|
-
case
|
1940
|
-
error_18 =
|
1953
|
+
case 4:
|
1954
|
+
error_18 = _a.sent();
|
1941
1955
|
console.error("OmnichannelChatSDK/getChatConfig/error " + error_18);
|
1942
1956
|
return [2 /*return*/, error_18];
|
1943
|
-
case
|
1957
|
+
case 5: return [2 /*return*/];
|
1944
1958
|
}
|
1945
1959
|
});
|
1946
1960
|
});
|
@@ -2022,6 +2036,57 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2022
2036
|
});
|
2023
2037
|
});
|
2024
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
|
+
};
|
2025
2090
|
return OmnichannelChatSDK;
|
2026
2091
|
}());
|
2027
2092
|
exports.default = OmnichannelChatSDK;
|