@microsoft/omnichannel-chat-sdk 1.0.1-main.90a4f94 → 1.0.1-main.9e71fa6
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 +10 -0
- package/README.md +2 -3
- package/lib/OmnichannelChatSDK.d.ts +5 -1
- package/lib/OmnichannelChatSDK.js +232 -173
- 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/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 +109 -29
- 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 () {
|
@@ -1677,7 +1711,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1677
1711
|
};
|
1678
1712
|
OmnichannelChatSDK.prototype.getPostChatSurveyContext = function () {
|
1679
1713
|
return __awaiter(this, void 0, void 0, function () {
|
1680
|
-
var conversationId,
|
1714
|
+
var conversationId, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, postConversationSurveyOwnerId, liveWorkItemDetails, participantJoined, surveyInviteLinkRequest, optionalParams, surveyInviteLinkResponse, surveyInviteLink, formsProLocale, postChatContext, ex_1;
|
1681
1715
|
return __generator(this, function (_a) {
|
1682
1716
|
switch (_a.label) {
|
1683
1717
|
case 0:
|
@@ -1687,11 +1721,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1687
1721
|
_a.label = 1;
|
1688
1722
|
case 1:
|
1689
1723
|
_a.trys.push([1, 6, , 7]);
|
1690
|
-
|
1691
|
-
liveWSAndLiveChatEngJoin = chatConfig.LiveWSAndLiveChatEngJoin, chatWidgetLanguage = chatConfig.ChatWidgetLanguage;
|
1724
|
+
liveWSAndLiveChatEngJoin = this.liveChatConfig.LiveWSAndLiveChatEngJoin;
|
1692
1725
|
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
1726
|
if (!msdyn_postconversationsurveyenable) return [3 /*break*/, 4];
|
1696
1727
|
return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId)];
|
1697
1728
|
case 2:
|
@@ -1701,7 +1732,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1701
1732
|
surveyInviteLinkRequest = {
|
1702
1733
|
"FormId": msfp_sourcesurveyidentifier,
|
1703
1734
|
"ConversationId": conversationId,
|
1704
|
-
"OCLocaleCode": locale_1.getLocaleStringFromId(localeId)
|
1735
|
+
"OCLocaleCode": locale_1.getLocaleStringFromId(this.localeId) || locale_1.getLocaleStringFromId(locale_1.defaultLocaleId)
|
1705
1736
|
};
|
1706
1737
|
optionalParams = {
|
1707
1738
|
"requestId": this.requestId
|
@@ -1790,7 +1821,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1790
1821
|
this.debug && console.debug('IC3Client');
|
1791
1822
|
// Use IC3Client if browser is detected
|
1792
1823
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1793
|
-
var ic3ClientCDNUrl;
|
1824
|
+
var ic3ClientCDNUrl, IC3Client;
|
1794
1825
|
var _this = this;
|
1795
1826
|
var _a;
|
1796
1827
|
return __generator(this, function (_b) {
|
@@ -1801,6 +1832,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1801
1832
|
IC3Client: ic3ClientCDNUrl
|
1802
1833
|
});
|
1803
1834
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetIC3Client);
|
1835
|
+
if (!this.IC3SDKProvider) return [3 /*break*/, 2];
|
1836
|
+
return [4 /*yield*/, this.IC3SDKProvider.getSDK({
|
1837
|
+
hostType: HostType_1.default.IFrame,
|
1838
|
+
protocolType: ProtocoleType_1.default.IC3V1SDK,
|
1839
|
+
logger: this.ic3ClientLogger // eslint-disable-line @typescript-eslint/no-explicit-any
|
1840
|
+
})];
|
1841
|
+
case 1:
|
1842
|
+
IC3Client = _b.sent();
|
1843
|
+
return [2 /*return*/, resolve(IC3Client)];
|
1844
|
+
case 2:
|
1804
1845
|
window.addEventListener("ic3:sdk:load", function () { return __awaiter(_this, void 0, void 0, function () {
|
1805
1846
|
var ic3sdk, IC3SDKProvider, IC3Client;
|
1806
1847
|
return __generator(this, function (_a) {
|
@@ -1837,7 +1878,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1837
1878
|
});
|
1838
1879
|
reject('Failed to load IC3Client');
|
1839
1880
|
})];
|
1840
|
-
case
|
1881
|
+
case 3:
|
1841
1882
|
_b.sent();
|
1842
1883
|
return [2 /*return*/];
|
1843
1884
|
}
|
@@ -1849,15 +1890,17 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1849
1890
|
};
|
1850
1891
|
OmnichannelChatSDK.prototype.getChatConfig = function () {
|
1851
1892
|
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 (
|
1893
|
+
var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled, error_18;
|
1894
|
+
return __generator(this, function (_a) {
|
1895
|
+
switch (_a.label) {
|
1855
1896
|
case 0:
|
1856
|
-
|
1897
|
+
_a.trys.push([0, 4, , 5]);
|
1857
1898
|
return [4 /*yield*/, this.OCClient.getChatConfig()];
|
1858
1899
|
case 1:
|
1859
|
-
liveChatConfig =
|
1860
|
-
dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion;
|
1900
|
+
liveChatConfig = _a.sent();
|
1901
|
+
dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
|
1902
|
+
msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
|
1903
|
+
this.localeId = msdyn_localeid || locale_1.defaultLocaleId;
|
1861
1904
|
this.liveChatVersion = liveChatVersion || LiveChatVersion_1.default.V1;
|
1862
1905
|
/* istanbul ignore next */
|
1863
1906
|
this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] " + this.liveChatVersion);
|
@@ -1880,47 +1923,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1880
1923
|
if (isPreChatEnabled && preChatSurvey && preChatSurvey.trim().length > 0) {
|
1881
1924
|
this.preChatSurvey = preChatSurvey;
|
1882
1925
|
}
|
1883
|
-
if (!this.authSettings) return [3 /*break*/,
|
1884
|
-
this.
|
1885
|
-
if (!this.chatSDKConfig.getAuthToken) return [3 /*break*/, 6];
|
1886
|
-
_b.label = 2;
|
1926
|
+
if (!this.authSettings) return [3 /*break*/, 3];
|
1927
|
+
return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
|
1887
1928
|
case 2:
|
1888
|
-
|
1889
|
-
|
1929
|
+
_a.sent();
|
1930
|
+
_a.label = 3;
|
1890
1931
|
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
1932
|
if (this.preChatSurvey) {
|
1925
1933
|
/* istanbul ignore next */
|
1926
1934
|
this.debug && console.log('Prechat Survey!');
|
@@ -1928,11 +1936,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1928
1936
|
this.callingOption = msdyn_callingoptions;
|
1929
1937
|
this.liveChatConfig = liveChatConfig;
|
1930
1938
|
return [2 /*return*/, this.liveChatConfig];
|
1931
|
-
case
|
1932
|
-
error_18 =
|
1939
|
+
case 4:
|
1940
|
+
error_18 = _a.sent();
|
1933
1941
|
console.error("OmnichannelChatSDK/getChatConfig/error " + error_18);
|
1934
1942
|
return [2 /*return*/, error_18];
|
1935
|
-
case
|
1943
|
+
case 5: return [2 /*return*/];
|
1936
1944
|
}
|
1937
1945
|
});
|
1938
1946
|
});
|
@@ -2014,6 +2022,57 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2014
2022
|
});
|
2015
2023
|
});
|
2016
2024
|
};
|
2025
|
+
OmnichannelChatSDK.prototype.setAuthTokenProvider = function (provider) {
|
2026
|
+
return __awaiter(this, void 0, void 0, function () {
|
2027
|
+
var token, exceptionDetails, _a, exceptionDetails, exceptionDetails;
|
2028
|
+
return __generator(this, function (_b) {
|
2029
|
+
switch (_b.label) {
|
2030
|
+
case 0:
|
2031
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetAuthToken);
|
2032
|
+
this.chatSDKConfig.getAuthToken = provider;
|
2033
|
+
if (!this.chatSDKConfig.getAuthToken) return [3 /*break*/, 5];
|
2034
|
+
_b.label = 1;
|
2035
|
+
case 1:
|
2036
|
+
_b.trys.push([1, 3, , 4]);
|
2037
|
+
return [4 /*yield*/, this.chatSDKConfig.getAuthToken()];
|
2038
|
+
case 2:
|
2039
|
+
token = _b.sent();
|
2040
|
+
if (token) {
|
2041
|
+
this.authenticatedUserToken = token;
|
2042
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetAuthToken);
|
2043
|
+
}
|
2044
|
+
else {
|
2045
|
+
exceptionDetails = {
|
2046
|
+
response: "UndefinedAuthToken"
|
2047
|
+
};
|
2048
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2049
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2050
|
+
});
|
2051
|
+
}
|
2052
|
+
return [3 /*break*/, 4];
|
2053
|
+
case 3:
|
2054
|
+
_a = _b.sent();
|
2055
|
+
exceptionDetails = {
|
2056
|
+
response: "GetAuthTokenFailed"
|
2057
|
+
};
|
2058
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2059
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2060
|
+
});
|
2061
|
+
return [3 /*break*/, 4];
|
2062
|
+
case 4: return [3 /*break*/, 6];
|
2063
|
+
case 5:
|
2064
|
+
exceptionDetails = {
|
2065
|
+
response: "GetAuthTokenNotFound"
|
2066
|
+
};
|
2067
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2068
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2069
|
+
});
|
2070
|
+
_b.label = 6;
|
2071
|
+
case 6: return [2 /*return*/];
|
2072
|
+
}
|
2073
|
+
});
|
2074
|
+
});
|
2075
|
+
};
|
2017
2076
|
return OmnichannelChatSDK;
|
2018
2077
|
}());
|
2019
2078
|
exports.default = OmnichannelChatSDK;
|