@microsoft/omnichannel-chat-sdk 1.0.1-main.c6dccf8 → 1.0.1-main.eec1463

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +15 -3
  2. package/README.md +41 -20
  3. package/lib/OmnichannelChatSDK.d.ts +5 -4
  4. package/lib/OmnichannelChatSDK.js +204 -248
  5. package/lib/OmnichannelChatSDK.js.map +1 -1
  6. package/lib/config/settings.d.ts +1 -1
  7. package/lib/config/settings.js +1 -1
  8. package/lib/config/settings.js.map +1 -1
  9. package/lib/core/ChatConfig.d.ts +3 -0
  10. package/lib/core/messaging/ACSClient.js +1 -1
  11. package/lib/core/messaging/ACSClient.js.map +1 -1
  12. package/lib/core/messaging/ChatAdapterOptionalParams.d.ts +14 -0
  13. package/lib/core/messaging/ChatAdapterOptionalParams.js +3 -0
  14. package/lib/core/messaging/ChatAdapterOptionalParams.js.map +1 -0
  15. package/lib/external/ACSAdapter/createFormatEgressTagsMiddleware.d.ts +2 -0
  16. package/lib/external/ACSAdapter/createFormatEgressTagsMiddleware.js +31 -0
  17. package/lib/external/ACSAdapter/createFormatEgressTagsMiddleware.js.map +1 -0
  18. package/lib/external/ACSAdapter/createFormatIngressTagsMiddleware.d.ts +2 -0
  19. package/lib/external/ACSAdapter/createFormatIngressTagsMiddleware.js +25 -0
  20. package/lib/external/ACSAdapter/createFormatIngressTagsMiddleware.js.map +1 -0
  21. package/lib/external/IC3Adapter/IIC3AdapterOptions.d.ts +12 -0
  22. package/lib/telemetry/AriaTelemetry.js +5 -0
  23. package/lib/telemetry/AriaTelemetry.js.map +1 -1
  24. package/lib/telemetry/ScenarioMarker.d.ts +2 -0
  25. package/lib/telemetry/ScenarioMarker.js +7 -3
  26. package/lib/telemetry/ScenarioMarker.js.map +1 -1
  27. package/lib/telemetry/TelemetryEvent.d.ts +1 -3
  28. package/lib/telemetry/TelemetryEvent.js +0 -2
  29. package/lib/telemetry/TelemetryEvent.js.map +1 -1
  30. package/lib/tsconfig.tsbuildinfo +794 -1089
  31. package/lib/utils/WebUtils.d.ts +3 -1
  32. package/lib/utils/WebUtils.js +8 -2
  33. package/lib/utils/WebUtils.js.map +1 -1
  34. package/lib/utils/libraries.d.ts +1 -3
  35. package/lib/utils/libraries.js +2 -11
  36. package/lib/utils/libraries.js.map +1 -1
  37. package/lib/utils/locale.d.ts +1 -0
  38. package/lib/utils/locale.js +2 -1
  39. package/lib/utils/locale.js.map +1 -1
  40. package/lib/utils/loggers.d.ts +8 -0
  41. package/lib/utils/loggers.js +24 -0
  42. package/lib/utils/loggers.js.map +1 -1
  43. package/package.json +2 -2
@@ -58,7 +58,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
58
58
  var loggers_1 = require("./utils/loggers");
59
59
  var ACSClient_1 = require("./core/messaging/ACSClient");
60
60
  var ocsdk_1 = require("@microsoft/ocsdk");
61
- var libraries_1 = require("./utils/libraries");
62
61
  var platform_1 = require("./utils/platform");
63
62
  var SDKConfigValidators_1 = require("./validators/SDKConfigValidators");
64
63
  var ACSParticipantDisplayName_1 = require("./core/messaging/ACSParticipantDisplayName");
@@ -66,6 +65,8 @@ var AMSFileManager_1 = require("./external/ACSAdapter/AMSFileManager");
66
65
  var CallingOptionsOptionSetNumber_1 = require("./core/CallingOptionsOptionSetNumber");
67
66
  var ChatAdapterProtocols_1 = require("./core/messaging/ChatAdapterProtocols");
68
67
  var ConversationMode_1 = require("./core/ConversationMode");
68
+ var createFormatEgressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatEgressTagsMiddleware");
69
+ var createFormatIngressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatIngressTagsMiddleware");
69
70
  var DeliveryMode_1 = require("@microsoft/omnichannel-ic3core/lib/model/DeliveryMode");
70
71
  var FileSharingProtocolType_1 = require("@microsoft/omnichannel-ic3core/lib/model/FileSharingProtocolType");
71
72
  var HostType_1 = require("@microsoft/omnichannel-ic3core/lib/interfaces/HostType");
@@ -85,6 +86,7 @@ var createVoiceVideoCalling_1 = require("./api/createVoiceVideoCalling");
85
86
  var MessageTags_1 = require("./core/messaging/MessageTags");
86
87
  var locale_1 = require("./utils/locale");
87
88
  var utilities_1 = require("./utils/utilities");
89
+ var libraries_1 = require("./utils/libraries");
88
90
  var WebUtils_1 = require("./utils/WebUtils");
89
91
  var OmnichannelConfigValidator_1 = require("./validators/OmnichannelConfigValidator");
90
92
  var OmnichannelChatSDK = /** @class */ (function () {
@@ -107,11 +109,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
107
109
  this.reconnectId = null;
108
110
  this.refreshTokenTimer = null;
109
111
  this.debug = false;
112
+ this.runtimeId = ocsdk_1.uuidv4();
110
113
  this.omnichannelConfig = omnichannelConfig;
111
114
  this.chatSDKConfig = __assign(__assign({}, SDKConfigValidators_1.defaultChatSDKConfig), chatSDKConfig // overrides
112
115
  );
113
116
  this.isInitialized = false;
114
117
  this.liveChatVersion = LiveChatVersion_1.default.V1;
118
+ this.localeId = locale_1.defaultLocaleId;
115
119
  this.requestId = ocsdk_1.uuidv4();
116
120
  this.chatToken = {};
117
121
  this.liveChatConfig = {};
@@ -129,6 +133,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
129
133
  this.ocSdkLogger.useTelemetry(this.telemetry);
130
134
  this.acsClientLogger.useTelemetry(this.telemetry);
131
135
  this.acsAdapterLogger.useTelemetry(this.telemetry);
136
+ this.scenarioMarker.setRuntimeId(this.runtimeId);
137
+ this.ic3ClientLogger.setRuntimeId(this.runtimeId);
138
+ this.ocSdkLogger.setRuntimeId(this.runtimeId);
139
+ this.acsClientLogger.setRuntimeId(this.runtimeId);
140
+ this.acsAdapterLogger.setRuntimeId(this.runtimeId);
132
141
  OmnichannelConfigValidator_1.default(omnichannelConfig);
133
142
  SDKConfigValidators_1.default(chatSDKConfig);
134
143
  ((_a = this.chatSDKConfig.telemetry) === null || _a === void 0 ? void 0 : _a.disable) && ((_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.disable());
@@ -292,44 +301,52 @@ var OmnichannelChatSDK = /** @class */ (function () {
292
301
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
293
302
  if (optionalParams === void 0) { optionalParams = {}; }
294
303
  return __awaiter(this, void 0, void 0, function () {
295
- var reconnectableChatsParams, reconnectableChatsResponse, _p, exceptionDetails, conversationDetails, exceptionDetails, exceptionDetails, sessionInitOptionalParams, error_3, exceptionDetails, chatAdapterConfig, error_4, exceptionDetails, _q, error_5, exceptionDetails, error_6, exceptionDetails, error_7, exceptionDetails, _r, error_8, exceptionDetails;
304
+ var shouldReinitIC3Client, _p, reconnectableChatsParams, reconnectableChatsResponse, _q, exceptionDetails, conversationDetails, exceptionDetails, exceptionDetails, sessionInitOptionalParams, error_3, exceptionDetails, chatAdapterConfig, error_4, exceptionDetails, _r, error_5, exceptionDetails, error_6, exceptionDetails, error_7, exceptionDetails, _s, error_8, exceptionDetails;
296
305
  var _this = this;
297
- return __generator(this, function (_s) {
298
- switch (_s.label) {
306
+ return __generator(this, function (_t) {
307
+ switch (_t.label) {
299
308
  case 0:
300
309
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
301
310
  RequestId: this.requestId
302
311
  });
312
+ shouldReinitIC3Client = !platform_1.default.isNode() && !platform_1.default.isReactNative() && !this.IC3Client && this.liveChatVersion === LiveChatVersion_1.default.V1;
313
+ if (!shouldReinitIC3Client) return [3 /*break*/, 2];
314
+ _p = this;
315
+ return [4 /*yield*/, this.getIC3Client()];
316
+ case 1:
317
+ _p.IC3Client = _t.sent();
318
+ _t.label = 2;
319
+ case 2:
303
320
  if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
304
321
  this.reconnectId = optionalParams.reconnectId;
305
322
  }
306
- if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 4];
307
- _s.label = 1;
308
- case 1:
309
- _s.trys.push([1, 3, , 4]);
323
+ if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 6];
324
+ _t.label = 3;
325
+ case 3:
326
+ _t.trys.push([3, 5, , 6]);
310
327
  reconnectableChatsParams = {
311
328
  authenticatedUserToken: this.authenticatedUserToken
312
329
  };
313
330
  return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
314
- case 2:
315
- reconnectableChatsResponse = _s.sent();
331
+ case 4:
332
+ reconnectableChatsResponse = _t.sent();
316
333
  if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
317
334
  this.reconnectId = reconnectableChatsResponse.reconnectid;
318
335
  }
319
- return [3 /*break*/, 4];
320
- case 3:
321
- _p = _s.sent();
336
+ return [3 /*break*/, 6];
337
+ case 5:
338
+ _q = _t.sent();
322
339
  exceptionDetails = {
323
340
  response: "OCClientGetReconnectableChatsFailed"
324
341
  };
325
342
  throw Error(exceptionDetails.response);
326
- case 4:
327
- if (!(optionalParams.liveChatContext && !this.isPersistentChat && !this.isChatReconnect)) return [3 /*break*/, 6];
343
+ case 6:
344
+ if (!(optionalParams.liveChatContext && !this.reconnectId)) return [3 /*break*/, 8];
328
345
  this.chatToken = optionalParams.liveChatContext.chatToken || {};
329
346
  this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
330
347
  return [4 /*yield*/, this.getConversationDetails()];
331
- case 5:
332
- conversationDetails = _s.sent();
348
+ case 7:
349
+ conversationDetails = _t.sent();
333
350
  if (Object.keys(conversationDetails).length === 0) {
334
351
  exceptionDetails = {
335
352
  response: "InvalidConversation"
@@ -354,14 +371,14 @@ var OmnichannelChatSDK = /** @class */ (function () {
354
371
  console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
355
372
  throw Error(exceptionDetails.response);
356
373
  }
357
- _s.label = 6;
358
- case 6:
359
- if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 8];
360
- return [4 /*yield*/, this.getChatToken(false)];
361
- case 7:
362
- _s.sent();
363
- _s.label = 8;
374
+ _t.label = 8;
364
375
  case 8:
376
+ if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 10];
377
+ return [4 /*yield*/, this.getChatToken(false)];
378
+ case 9:
379
+ _t.sent();
380
+ _t.label = 10;
381
+ case 10:
365
382
  (_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
366
383
  (_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
367
384
  (_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
@@ -369,6 +386,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
369
386
  sessionInitOptionalParams = {
370
387
  initContext: {}
371
388
  };
389
+ sessionInitOptionalParams.initContext.locale = locale_1.getLocaleStringFromId(this.localeId);
372
390
  if (this.isPersistentChat && !((_g = this.chatSDKConfig.persistentChat) === null || _g === void 0 ? void 0 : _g.disable)) {
373
391
  sessionInitOptionalParams.reconnectId = this.reconnectId;
374
392
  }
@@ -400,15 +418,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
400
418
  if (this.authenticatedUserToken) {
401
419
  sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
402
420
  }
403
- _s.label = 9;
404
- case 9:
405
- _s.trys.push([9, 11, , 12]);
406
- return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
407
- case 10:
408
- _s.sent();
409
- return [3 /*break*/, 12];
421
+ if (!!optionalParams.liveChatContext) return [3 /*break*/, 14];
422
+ _t.label = 11;
410
423
  case 11:
411
- error_3 = _s.sent();
424
+ _t.trys.push([11, 13, , 14]);
425
+ return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
426
+ case 12:
427
+ _t.sent();
428
+ return [3 /*break*/, 14];
429
+ case 13:
430
+ error_3 = _t.sent();
412
431
  exceptionDetails = {
413
432
  response: "OCClientSessionInitFailed"
414
433
  };
@@ -419,8 +438,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
419
438
  });
420
439
  console.error("OmnichannelChatSDK/startChat/sessionInit/error " + error_3);
421
440
  return [2 /*return*/, error_3];
422
- case 12:
423
- if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 23];
441
+ case 14:
442
+ if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 25];
424
443
  chatAdapterConfig = {
425
444
  token: this.chatToken.token,
426
445
  id: this.chatToken.visitorId || 'teamsvisitor',
@@ -428,18 +447,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
428
447
  environmentUrl: this.chatToken.acsEndpoint,
429
448
  pollingInterval: 1000
430
449
  };
431
- _s.label = 13;
432
- case 13:
433
- _s.trys.push([13, 15, , 16]);
450
+ _t.label = 15;
451
+ case 15:
452
+ _t.trys.push([15, 17, , 18]);
434
453
  return [4 /*yield*/, ((_j = this.ACSClient) === null || _j === void 0 ? void 0 : _j.initialize({
435
454
  token: chatAdapterConfig.token,
436
455
  environmentUrl: chatAdapterConfig.environmentUrl
437
456
  }))];
438
- case 14:
439
- _s.sent();
440
- return [3 /*break*/, 16];
441
- case 15:
442
- error_4 = _s.sent();
457
+ case 16:
458
+ _t.sent();
459
+ return [3 /*break*/, 18];
460
+ case 17:
461
+ error_4 = _t.sent();
443
462
  exceptionDetails = {
444
463
  response: "ACSClientInitializeFailed"
445
464
  };
@@ -450,23 +469,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
450
469
  });
451
470
  console.error("OmnichannelChatSDK/startChat/initialize/error " + error_4);
452
471
  return [2 /*return*/, error_4];
453
- case 16:
454
- _s.trys.push([16, 18, , 19]);
455
- _q = this;
472
+ case 18:
473
+ _t.trys.push([18, 20, , 21]);
474
+ _r = this;
456
475
  return [4 /*yield*/, ((_k = this.ACSClient) === null || _k === void 0 ? void 0 : _k.joinConversation({
457
476
  id: chatAdapterConfig.id,
458
477
  threadId: chatAdapterConfig.threadId,
459
478
  pollingInterval: chatAdapterConfig.pollingInterval
460
479
  }))];
461
- case 17:
462
- _q.conversation = (_s.sent());
480
+ case 19:
481
+ _r.conversation = (_t.sent());
463
482
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
464
483
  RequestId: this.requestId,
465
484
  ChatId: this.chatToken.chatId
466
485
  });
467
- return [3 /*break*/, 19];
468
- case 18:
469
- error_5 = _s.sent();
486
+ return [3 /*break*/, 21];
487
+ case 20:
488
+ error_5 = _t.sent();
470
489
  exceptionDetails = {
471
490
  response: "ACSClientJoinConversationFailed"
472
491
  };
@@ -477,16 +496,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
477
496
  });
478
497
  console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_5);
479
498
  throw Error(exceptionDetails.response);
480
- case 19:
481
- _s.trys.push([19, 21, , 22]);
499
+ case 21:
500
+ _t.trys.push([21, 23, , 24]);
482
501
  return [4 /*yield*/, ((_l = this.AMSClient) === null || _l === void 0 ? void 0 : _l.initialize({
483
502
  chatToken: this.chatToken
484
503
  }))];
485
- case 20:
486
- _s.sent();
487
- return [3 /*break*/, 22];
488
- case 21:
489
- error_6 = _s.sent();
504
+ case 22:
505
+ _t.sent();
506
+ return [3 /*break*/, 24];
507
+ case 23:
508
+ error_6 = _t.sent();
490
509
  exceptionDetails = {
491
510
  response: "AMSClientInitializeFailed"
492
511
  };
@@ -496,19 +515,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
496
515
  ExceptionDetails: JSON.stringify(exceptionDetails)
497
516
  });
498
517
  throw Error(exceptionDetails.response);
499
- case 22: return [3 /*break*/, 29];
500
- case 23:
501
- _s.trys.push([23, 25, , 26]);
518
+ case 24: return [3 /*break*/, 31];
519
+ case 25:
520
+ _t.trys.push([25, 27, , 28]);
502
521
  return [4 /*yield*/, this.IC3Client.initialize({
503
522
  token: this.chatToken.token,
504
523
  regionGtms: this.chatToken.regionGTMS,
505
524
  visitor: true
506
525
  })];
507
- case 24:
508
- _s.sent();
509
- return [3 /*break*/, 26];
510
- case 25:
511
- error_7 = _s.sent();
526
+ case 26:
527
+ _t.sent();
528
+ return [3 /*break*/, 28];
529
+ case 27:
530
+ error_7 = _t.sent();
512
531
  exceptionDetails = {
513
532
  response: "IC3ClientInitializeFailed"
514
533
  };
@@ -519,19 +538,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
519
538
  });
520
539
  console.error("OmnichannelChatSDK/startChat/initialize/error " + error_7);
521
540
  return [2 /*return*/, error_7];
522
- case 26:
523
- _s.trys.push([26, 28, , 29]);
524
- _r = this;
541
+ case 28:
542
+ _t.trys.push([28, 30, , 31]);
543
+ _s = this;
525
544
  return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
526
- case 27:
527
- _r.conversation = _s.sent();
545
+ case 29:
546
+ _s.conversation = _t.sent();
528
547
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
529
548
  RequestId: this.requestId,
530
549
  ChatId: this.chatToken.chatId
531
550
  });
532
- return [3 /*break*/, 29];
533
- case 28:
534
- error_8 = _s.sent();
551
+ return [3 /*break*/, 31];
552
+ case 30:
553
+ error_8 = _t.sent();
535
554
  exceptionDetails = {
536
555
  response: "IC3ClientJoinConversationFailed"
537
556
  };
@@ -542,7 +561,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
542
561
  });
543
562
  console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_8);
544
563
  return [2 /*return*/, error_8];
545
- case 29:
564
+ case 31:
546
565
  if (this.isPersistentChat && !((_m = this.chatSDKConfig.persistentChat) === null || _m === void 0 ? void 0 : _m.disable)) {
547
566
  this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
548
567
  return __generator(this, function (_a) {
@@ -580,6 +599,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
580
599
  }
581
600
  if (this.isChatReconnect && !((_b = this.chatSDKConfig.chatReconnect) === null || _b === void 0 ? void 0 : _b.disable) && !this.isPersistentChat) {
582
601
  isChatReconnect = this.reconnectId !== null ? true : false;
602
+ this.requestId = isChatReconnect ? this.reconnectId : this.requestId; // Chat Reconnect session to close
583
603
  sessionCloseOptionalParams.isReconnectChat = isChatReconnect;
584
604
  }
585
605
  if (this.authenticatedUserToken) {
@@ -600,6 +620,9 @@ var OmnichannelChatSDK = /** @class */ (function () {
600
620
  this.requestId = ocsdk_1.uuidv4();
601
621
  this.chatToken = {};
602
622
  this.reconnectId = null;
623
+ this.IC3Client.dispose();
624
+ !platform_1.default.isNode() && !platform_1.default.isReactNative() && WebUtils_1.removeElementById(this.IC3Client.id);
625
+ this.IC3Client = null;
603
626
  (_d = this.ic3ClientLogger) === null || _d === void 0 ? void 0 : _d.setRequestId(this.requestId);
604
627
  (_e = this.ic3ClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId('');
605
628
  (_f = this.ocSdkLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
@@ -897,6 +920,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
897
920
  sendMessageRequest = {
898
921
  content: message.content,
899
922
  };
923
+ sendMessageRequest.metadata = {
924
+ widgetId: this.omnichannelConfig.widgetId,
925
+ clientMessageId: Date.now().toString()
926
+ };
927
+ if (message.metadata) {
928
+ sendMessageRequest.metadata = __assign(__assign({}, sendMessageRequest.metadata), message.metadata);
929
+ }
900
930
  _e.label = 1;
901
931
  case 1:
902
932
  _e.trys.push([1, 3, , 4]);
@@ -1279,7 +1309,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1279
1309
  };
1280
1310
  sendMessageRequest = {
1281
1311
  content: '',
1282
- metadata: __assign(__assign({}, fileIdsProperty), fileMetaProperty)
1312
+ metadata: __assign(__assign({ widgetId: this.omnichannelConfig.widgetId, clientMessageId: Date.now().toString() }, fileIdsProperty), fileMetaProperty)
1283
1313
  };
1284
1314
  messageToSend = {
1285
1315
  content: "",
@@ -1440,7 +1470,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1440
1470
  ChatId: this.chatToken.chatId,
1441
1471
  EmailAddress: body.emailAddress,
1442
1472
  DefaultAttachmentMessage: body.attachmentMessage,
1443
- CustomerLocale: body.locale
1473
+ CustomerLocale: body.locale || locale_1.getLocaleStringFromId(this.localeId)
1444
1474
  };
1445
1475
  emailResponse = this.OCClient.emailTranscript(this.requestId, this.chatToken.token, emailRequestBody, emailTranscriptOptionalParams);
1446
1476
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EmailLiveChatTranscript, {
@@ -1490,32 +1520,33 @@ var OmnichannelChatSDK = /** @class */ (function () {
1490
1520
  });
1491
1521
  });
1492
1522
  };
1493
- OmnichannelChatSDK.prototype.createChatAdapter = function (protocol) {
1494
- if (protocol === void 0) { protocol = null; }
1523
+ OmnichannelChatSDK.prototype.createChatAdapter = function (optionalParams) {
1524
+ if (optionalParams === void 0) { optionalParams = {}; }
1495
1525
  return __awaiter(this, void 0, void 0, function () {
1496
- var supportedChatAdapterProtocols;
1526
+ var protocol, supportedChatAdapterProtocols;
1497
1527
  var _this = this;
1498
1528
  return __generator(this, function (_a) {
1499
1529
  if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
1500
1530
  return [2 /*return*/, Promise.reject('ChatAdapter is only supported on browser')];
1501
1531
  }
1532
+ protocol = optionalParams.protocol;
1502
1533
  supportedChatAdapterProtocols = [ChatAdapterProtocols_1.default.ACS, ChatAdapterProtocols_1.default.IC3];
1503
1534
  if (protocol && !supportedChatAdapterProtocols.includes(protocol)) {
1504
1535
  return [2 /*return*/, Promise.reject("ChatAdapter for protocol " + protocol + " currently not supported")];
1505
1536
  }
1506
1537
  if (protocol === ChatAdapterProtocols_1.default.ACS || this.liveChatVersion === LiveChatVersion_1.default.V2) {
1507
1538
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
1508
- var featuresOption, acsAdapterCDNUrl;
1539
+ var options, egressMiddlewares, ingressMiddlewares, featuresOption, acsAdapterCDNUrl;
1509
1540
  var _this = this;
1510
1541
  var _a;
1511
1542
  return __generator(this, function (_b) {
1512
1543
  switch (_b.label) {
1513
1544
  case 0:
1514
- featuresOption = {
1515
- enableAdaptiveCards: false,
1516
- enableThreadMemberUpdateNotification: true,
1517
- enableLeaveThreadOnWindowClosed: false
1518
- };
1545
+ options = optionalParams.ACSAdapter ? optionalParams.ACSAdapter.options : {};
1546
+ egressMiddlewares = [createFormatEgressTagsMiddleware_1.default()];
1547
+ ingressMiddlewares = [createFormatIngressTagsMiddleware_1.default()];
1548
+ featuresOption = __assign({ enableAdaptiveCards: true, enableThreadMemberUpdateNotification: true, enableLeaveThreadOnWindowClosed: false, egressMiddleware: egressMiddlewares, ingressMiddleware: ingressMiddlewares }, options // overrides
1549
+ );
1519
1550
  acsAdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.ACS);
1520
1551
  (_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
1521
1552
  ACSAdapter: acsAdapterCDNUrl
@@ -1526,7 +1557,9 @@ var OmnichannelChatSDK = /** @class */ (function () {
1526
1557
  try {
1527
1558
  var ChatAdapter = window.ChatAdapter; // eslint-disable-line @typescript-eslint/no-explicit-any
1528
1559
  var fileManager = new AMSFileManager_1.default(_this.AMSClient, _this.acsAdapterLogger);
1529
- var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager, 1000, ACSParticipantDisplayName_1.default.Customer, undefined, featuresOption);
1560
+ 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
1561
+ undefined, // logger
1562
+ featuresOption);
1530
1563
  resolve(adapter);
1531
1564
  }
1532
1565
  catch (_a) {
@@ -1544,12 +1577,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
1544
1577
  }
1545
1578
  else if (protocol === ChatAdapterProtocols_1.default.IC3 || this.liveChatVersion === LiveChatVersion_1.default.V1) {
1546
1579
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
1547
- var ic3AdapterCDNUrl;
1580
+ var options, ic3AdapterCDNUrl;
1548
1581
  var _this = this;
1549
1582
  var _a;
1550
1583
  return __generator(this, function (_b) {
1551
1584
  switch (_b.label) {
1552
1585
  case 0:
1586
+ options = optionalParams.IC3Adapter ? optionalParams.IC3Adapter.options : {};
1553
1587
  ic3AdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.IC3);
1554
1588
  (_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
1555
1589
  IC3Adapter: ic3AdapterCDNUrl
@@ -1558,17 +1592,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
1558
1592
  return [4 /*yield*/, WebUtils_1.loadScript(ic3AdapterCDNUrl, function () {
1559
1593
  /* istanbul ignore next */
1560
1594
  _this.debug && console.debug('IC3Adapter loaded!');
1561
- var adapterConfig = {
1562
- chatToken: _this.chatToken,
1563
- userDisplayName: 'Customer',
1564
- userId: 'teamsvisitor',
1565
- sdkURL: _this.resolveIC3ClientUrl(),
1566
- sdk: _this.IC3Client
1567
- };
1595
+ var adapterConfig = __assign({ chatToken: _this.chatToken, userDisplayName: 'Customer', userId: _this.chatToken.visitorId || 'teamsvisitor', sdkURL: _this.resolveIC3ClientUrl(), sdk: _this.IC3Client }, options // overrides
1596
+ );
1568
1597
  var adapter = new window.Microsoft.BotFramework.WebChat.IC3Adapter(adapterConfig);
1569
1598
  adapter.logger = _this.ic3ClientLogger;
1570
- // Keep iframe communication alive to reuse the same IC3Client instance
1571
- window.Microsoft.BotFramework.WebChat.IC3SDKProvider.disposeSdk = function () { }; // eslint-disable-line @typescript-eslint/no-empty-function
1572
1599
  _this.scenarioMarker.completeScenario(TelemetryEvent_1.default.CreateIC3Adapter);
1573
1600
  resolve(adapter);
1574
1601
  }, function () {
@@ -1662,7 +1689,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1662
1689
  };
1663
1690
  OmnichannelChatSDK.prototype.getPostChatSurveyContext = function () {
1664
1691
  return __awaiter(this, void 0, void 0, function () {
1665
- var conversationId, chatConfig, liveWSAndLiveChatEngJoin, chatWidgetLanguage, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, postConversationSurveyOwnerId, msdyn_localeid, localeId, liveWorkItemDetails, participantJoined, surveyInviteLinkRequest, optionalParams, surveyInviteLinkResponse, surveyInviteLink, formsProLocale, postChatContext, ex_1;
1692
+ var conversationId, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, postConversationSurveyOwnerId, liveWorkItemDetails, participantJoined, surveyInviteLinkRequest, optionalParams, surveyInviteLinkResponse, surveyInviteLink, formsProLocale, postChatContext, ex_1;
1666
1693
  return __generator(this, function (_a) {
1667
1694
  switch (_a.label) {
1668
1695
  case 0:
@@ -1672,11 +1699,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
1672
1699
  _a.label = 1;
1673
1700
  case 1:
1674
1701
  _a.trys.push([1, 6, , 7]);
1675
- chatConfig = this.liveChatConfig;
1676
- liveWSAndLiveChatEngJoin = chatConfig.LiveWSAndLiveChatEngJoin, chatWidgetLanguage = chatConfig.ChatWidgetLanguage;
1702
+ liveWSAndLiveChatEngJoin = this.liveChatConfig.LiveWSAndLiveChatEngJoin;
1677
1703
  msdyn_postconversationsurveyenable = liveWSAndLiveChatEngJoin.msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_sourcesurveyidentifier, postConversationSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationSurveyOwnerId;
1678
- msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
1679
- localeId = msdyn_localeid !== null && msdyn_localeid !== void 0 ? msdyn_localeid : "1033";
1680
1704
  if (!msdyn_postconversationsurveyenable) return [3 /*break*/, 4];
1681
1705
  return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId)];
1682
1706
  case 2:
@@ -1686,7 +1710,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1686
1710
  surveyInviteLinkRequest = {
1687
1711
  "FormId": msfp_sourcesurveyidentifier,
1688
1712
  "ConversationId": conversationId,
1689
- "OCLocaleCode": locale_1.getLocaleStringFromId(localeId)
1713
+ "OCLocaleCode": locale_1.getLocaleStringFromId(this.localeId) || locale_1.getLocaleStringFromId(locale_1.defaultLocaleId)
1690
1714
  };
1691
1715
  optionalParams = {
1692
1716
  "requestId": this.requestId
@@ -1749,102 +1773,6 @@ var OmnichannelChatSDK = /** @class */ (function () {
1749
1773
  });
1750
1774
  });
1751
1775
  };
1752
- OmnichannelChatSDK.prototype.initializePostChatRenderer = function () {
1753
- return __awaiter(this, void 0, void 0, function () {
1754
- var msfpEmbedScript, elm, scriptNodes, styleNodes, i, node, tmpNode, tmpNode, i, node, tmpNode;
1755
- return __generator(this, function (_a) {
1756
- if (!platform_1.isBrowser()) {
1757
- return [2 /*return*/, Promise.reject("In-line rendering is only supported on web browsers")];
1758
- }
1759
- this.scenarioMarker.startScenario(TelemetryEvent_1.default.InitializePostChatRenderer, {
1760
- RequestId: this.requestId
1761
- });
1762
- try {
1763
- msfpEmbedScript = libraries_1.getMsfpEmbedScript();
1764
- elm = document.createElement('div');
1765
- elm.innerHTML = msfpEmbedScript;
1766
- scriptNodes = elm.getElementsByTagName('script');
1767
- styleNodes = elm.getElementsByTagName('link');
1768
- for (i = 0; i < scriptNodes.length; i++) {
1769
- node = scriptNodes[i];
1770
- if (node.src) {
1771
- tmpNode = document.createElement('script');
1772
- tmpNode.type = node.type;
1773
- tmpNode.src = node.src;
1774
- tmpNode.async = false;
1775
- if (!window.document.head.contains(tmpNode)) {
1776
- document.getElementsByTagName('head')[0].appendChild(tmpNode);
1777
- }
1778
- }
1779
- if (node.innerHTML) {
1780
- tmpNode = document.createElement('script');
1781
- tmpNode.innerHTML = node.innerHTML;
1782
- tmpNode.async = false;
1783
- if (!window.document.head.contains(tmpNode)) {
1784
- window.document.head.appendChild(tmpNode);
1785
- }
1786
- }
1787
- }
1788
- for (i = 0; i < styleNodes.length; i++) {
1789
- node = styleNodes[i];
1790
- if (node.href) {
1791
- tmpNode = document.createElement('link');
1792
- tmpNode.type = node.type;
1793
- tmpNode.rel = node.rel;
1794
- tmpNode.href = node.href;
1795
- if (!window.document.head.contains(tmpNode)) {
1796
- document.getElementsByTagName('head')[0].appendChild(tmpNode);
1797
- }
1798
- }
1799
- }
1800
- }
1801
- catch (ex) {
1802
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.InitializePostChatRenderer, {
1803
- RequestId: this.requestId,
1804
- ExceptionDetails: JSON.stringify(ex)
1805
- });
1806
- return [2 /*return*/, Promise.reject("Error occurred when initializer post chat renderer. " + JSON.stringify(ex))];
1807
- }
1808
- return [2 /*return*/];
1809
- });
1810
- });
1811
- };
1812
- OmnichannelChatSDK.prototype.renderPostChatSurvey = function (containerId, postChatContext) {
1813
- return __awaiter(this, void 0, void 0, function () {
1814
- var ex_2;
1815
- return __generator(this, function (_a) {
1816
- switch (_a.label) {
1817
- case 0:
1818
- if (!platform_1.isBrowser()) {
1819
- return [2 /*return*/, Promise.reject("In-line rendering is only supported on web browsers")];
1820
- }
1821
- this.scenarioMarker.startScenario(TelemetryEvent_1.default.RenderPostChatSurvey, {
1822
- RequestId: this.requestId
1823
- });
1824
- _a.label = 1;
1825
- case 1:
1826
- _a.trys.push([1, 3, , 4]);
1827
- if (!postChatContext) {
1828
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.RenderPostChatSurvey, {
1829
- RequestId: this.requestId,
1830
- ExceptionDetails: "Post Chat Context is null."
1831
- });
1832
- return [2 /*return*/, Promise.reject("Post Chat Context is null.")];
1833
- }
1834
- return [4 /*yield*/, renderSurvey(containerId, postChatContext === null || postChatContext === void 0 ? void 0 : postChatContext.surveyInviteLink, "", "", postChatContext === null || postChatContext === void 0 ? void 0 : postChatContext.formsProLocale)];
1835
- case 2: return [2 /*return*/, _a.sent()];
1836
- case 3:
1837
- ex_2 = _a.sent();
1838
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.RenderPostChatSurvey, {
1839
- RequestId: this.requestId,
1840
- ExceptionDetails: JSON.stringify(ex_2)
1841
- });
1842
- return [2 /*return*/, Promise.reject("Error occurred when rendering post chat survey. " + JSON.stringify(ex_2))];
1843
- case 4: return [2 /*return*/];
1844
- }
1845
- });
1846
- });
1847
- };
1848
1776
  OmnichannelChatSDK.prototype.getIC3Client = function () {
1849
1777
  return __awaiter(this, void 0, void 0, function () {
1850
1778
  var IC3Client;
@@ -1871,7 +1799,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1871
1799
  this.debug && console.debug('IC3Client');
1872
1800
  // Use IC3Client if browser is detected
1873
1801
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
1874
- var ic3ClientCDNUrl;
1802
+ var ic3ClientCDNUrl, IC3Client;
1875
1803
  var _this = this;
1876
1804
  var _a;
1877
1805
  return __generator(this, function (_b) {
@@ -1882,6 +1810,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
1882
1810
  IC3Client: ic3ClientCDNUrl
1883
1811
  });
1884
1812
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetIC3Client);
1813
+ if (!this.IC3SDKProvider) return [3 /*break*/, 2];
1814
+ return [4 /*yield*/, this.IC3SDKProvider.getSDK({
1815
+ hostType: HostType_1.default.IFrame,
1816
+ protocolType: ProtocoleType_1.default.IC3V1SDK,
1817
+ logger: this.ic3ClientLogger // eslint-disable-line @typescript-eslint/no-explicit-any
1818
+ })];
1819
+ case 1:
1820
+ IC3Client = _b.sent();
1821
+ return [2 /*return*/, resolve(IC3Client)];
1822
+ case 2:
1885
1823
  window.addEventListener("ic3:sdk:load", function () { return __awaiter(_this, void 0, void 0, function () {
1886
1824
  var ic3sdk, IC3SDKProvider, IC3Client;
1887
1825
  return __generator(this, function (_a) {
@@ -1918,7 +1856,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1918
1856
  });
1919
1857
  reject('Failed to load IC3Client');
1920
1858
  })];
1921
- case 1:
1859
+ case 3:
1922
1860
  _b.sent();
1923
1861
  return [2 /*return*/];
1924
1862
  }
@@ -1930,15 +1868,17 @@ var OmnichannelChatSDK = /** @class */ (function () {
1930
1868
  };
1931
1869
  OmnichannelChatSDK.prototype.getChatConfig = function () {
1932
1870
  return __awaiter(this, void 0, void 0, function () {
1933
- var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled, token, exceptionDetails, _a, exceptionDetails, exceptionDetails, error_18;
1934
- return __generator(this, function (_b) {
1935
- switch (_b.label) {
1871
+ var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled, error_18;
1872
+ return __generator(this, function (_a) {
1873
+ switch (_a.label) {
1936
1874
  case 0:
1937
- _b.trys.push([0, 8, , 9]);
1875
+ _a.trys.push([0, 4, , 5]);
1938
1876
  return [4 /*yield*/, this.OCClient.getChatConfig()];
1939
1877
  case 1:
1940
- liveChatConfig = _b.sent();
1941
- dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion;
1878
+ liveChatConfig = _a.sent();
1879
+ dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
1880
+ msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
1881
+ this.localeId = msdyn_localeid || locale_1.defaultLocaleId;
1942
1882
  this.liveChatVersion = liveChatVersion || LiveChatVersion_1.default.V1;
1943
1883
  /* istanbul ignore next */
1944
1884
  this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] " + this.liveChatVersion);
@@ -1961,47 +1901,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
1961
1901
  if (isPreChatEnabled && preChatSurvey && preChatSurvey.trim().length > 0) {
1962
1902
  this.preChatSurvey = preChatSurvey;
1963
1903
  }
1964
- if (!this.authSettings) return [3 /*break*/, 7];
1965
- this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetAuthToken);
1966
- if (!this.chatSDKConfig.getAuthToken) return [3 /*break*/, 6];
1967
- _b.label = 2;
1904
+ if (!this.authSettings) return [3 /*break*/, 3];
1905
+ return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
1968
1906
  case 2:
1969
- _b.trys.push([2, 4, , 5]);
1970
- return [4 /*yield*/, this.chatSDKConfig.getAuthToken()];
1907
+ _a.sent();
1908
+ _a.label = 3;
1971
1909
  case 3:
1972
- token = _b.sent();
1973
- if (token) {
1974
- this.authenticatedUserToken = token;
1975
- this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetAuthToken);
1976
- }
1977
- else {
1978
- exceptionDetails = {
1979
- response: "UndefinedAuthToken"
1980
- };
1981
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
1982
- ExceptionDetails: JSON.stringify(exceptionDetails)
1983
- });
1984
- }
1985
- return [3 /*break*/, 5];
1986
- case 4:
1987
- _a = _b.sent();
1988
- exceptionDetails = {
1989
- response: "GetAuthTokenFailed"
1990
- };
1991
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
1992
- ExceptionDetails: JSON.stringify(exceptionDetails)
1993
- });
1994
- return [3 /*break*/, 5];
1995
- case 5: return [3 /*break*/, 7];
1996
- case 6:
1997
- exceptionDetails = {
1998
- response: "GetAuthTokenNotFound"
1999
- };
2000
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
2001
- ExceptionDetails: JSON.stringify(exceptionDetails)
2002
- });
2003
- _b.label = 7;
2004
- case 7:
2005
1910
  if (this.preChatSurvey) {
2006
1911
  /* istanbul ignore next */
2007
1912
  this.debug && console.log('Prechat Survey!');
@@ -2009,11 +1914,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
2009
1914
  this.callingOption = msdyn_callingoptions;
2010
1915
  this.liveChatConfig = liveChatConfig;
2011
1916
  return [2 /*return*/, this.liveChatConfig];
2012
- case 8:
2013
- error_18 = _b.sent();
1917
+ case 4:
1918
+ error_18 = _a.sent();
2014
1919
  console.error("OmnichannelChatSDK/getChatConfig/error " + error_18);
2015
1920
  return [2 /*return*/, error_18];
2016
- case 9: return [2 /*return*/];
1921
+ case 5: return [2 /*return*/];
2017
1922
  }
2018
1923
  });
2019
1924
  });
@@ -2095,6 +2000,57 @@ var OmnichannelChatSDK = /** @class */ (function () {
2095
2000
  });
2096
2001
  });
2097
2002
  };
2003
+ OmnichannelChatSDK.prototype.setAuthTokenProvider = function (provider) {
2004
+ return __awaiter(this, void 0, void 0, function () {
2005
+ var token, exceptionDetails, _a, exceptionDetails, exceptionDetails;
2006
+ return __generator(this, function (_b) {
2007
+ switch (_b.label) {
2008
+ case 0:
2009
+ this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetAuthToken);
2010
+ this.chatSDKConfig.getAuthToken = provider;
2011
+ if (!this.chatSDKConfig.getAuthToken) return [3 /*break*/, 5];
2012
+ _b.label = 1;
2013
+ case 1:
2014
+ _b.trys.push([1, 3, , 4]);
2015
+ return [4 /*yield*/, this.chatSDKConfig.getAuthToken()];
2016
+ case 2:
2017
+ token = _b.sent();
2018
+ if (token) {
2019
+ this.authenticatedUserToken = token;
2020
+ this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetAuthToken);
2021
+ }
2022
+ else {
2023
+ exceptionDetails = {
2024
+ response: "UndefinedAuthToken"
2025
+ };
2026
+ this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
2027
+ ExceptionDetails: JSON.stringify(exceptionDetails)
2028
+ });
2029
+ }
2030
+ return [3 /*break*/, 4];
2031
+ case 3:
2032
+ _a = _b.sent();
2033
+ exceptionDetails = {
2034
+ response: "GetAuthTokenFailed"
2035
+ };
2036
+ this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
2037
+ ExceptionDetails: JSON.stringify(exceptionDetails)
2038
+ });
2039
+ return [3 /*break*/, 4];
2040
+ case 4: return [3 /*break*/, 6];
2041
+ case 5:
2042
+ exceptionDetails = {
2043
+ response: "GetAuthTokenNotFound"
2044
+ };
2045
+ this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
2046
+ ExceptionDetails: JSON.stringify(exceptionDetails)
2047
+ });
2048
+ _b.label = 6;
2049
+ case 6: return [2 /*return*/];
2050
+ }
2051
+ });
2052
+ });
2053
+ };
2098
2054
  return OmnichannelChatSDK;
2099
2055
  }());
2100
2056
  exports.default = OmnichannelChatSDK;