@microsoft/omnichannel-chat-sdk 1.9.5 → 1.9.7-main.2a56ce4

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.
@@ -66,6 +66,7 @@ var WebUtils_1 = require("./utils/WebUtils");
66
66
  var platform_1 = require("./utils/platform");
67
67
  var SDKConfigValidators_1 = require("./validators/SDKConfigValidators");
68
68
  var ACSParticipantDisplayName_1 = require("./core/messaging/ACSParticipantDisplayName");
69
+ var AMSClientLoadStates_1 = require("./utils/AMSClientLoadStates");
69
70
  var AMSFileManager_1 = require("./external/ACSAdapter/AMSFileManager");
70
71
  var CallingOptionsOptionSetNumber_1 = require("./core/CallingOptionsOptionSetNumber");
71
72
  var ChatAdapterProtocols_1 = require("./core/messaging/ChatAdapterProtocols");
@@ -100,6 +101,7 @@ var retrieveCollectorUri_1 = require("./telemetry/retrieveCollectorUri");
100
101
  var setOcUserAgent_1 = require("./utils/setOcUserAgent");
101
102
  var urlResolvers_1 = require("./utils/urlResolvers");
102
103
  var OmnichannelConfigValidator_1 = require("./validators/OmnichannelConfigValidator");
104
+ var settings_1 = require("./config/settings");
103
105
  var OmnichannelChatSDK = /** @class */ (function () {
104
106
  function OmnichannelChatSDK(omnichannelConfig, chatSDKConfig) {
105
107
  var _this = this;
@@ -126,6 +128,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
126
128
  this.isChatReconnect = false;
127
129
  this.reconnectId = null;
128
130
  this.refreshTokenTimer = null;
131
+ this.AMSClientLoadCurrentState = AMSClientLoadStates_1.AMSClientLoadStates.NOT_LOADED;
129
132
  this.populateInitChatOptionalParam = function (requestOptionalParams, optionalParams, telemetryEvent) {
130
133
  requestOptionalParams.initContext.locale = locale_1.getLocaleStringFromId(_this.localeId);
131
134
  if (optionalParams === null || optionalParams === void 0 ? void 0 : optionalParams.customContext) {
@@ -225,18 +228,164 @@ var OmnichannelChatSDK = /** @class */ (function () {
225
228
  }
226
229
  /* istanbul ignore next */
227
230
  OmnichannelChatSDK.prototype.setDebug = function (flag) {
228
- var _a, _b;
231
+ var _a;
229
232
  this.debug = flag;
230
- (_a = this.AMSClient) === null || _a === void 0 ? void 0 : _a.setDebug(flag);
231
- (_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.setDebug(flag);
233
+ this.getAMSClient().then(function (client) { return client === null || client === void 0 ? void 0 : client.setDebug(flag); });
234
+ (_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setDebug(flag);
232
235
  this.scenarioMarker.setDebug(flag);
233
236
  loggerUtils_1.default.setDebug(flag, this.ocSdkLogger, this.acsClientLogger, this.acsAdapterLogger, this.callingSdkLogger, this.amsClientLogger, this.ic3ClientLogger);
234
237
  };
235
- OmnichannelChatSDK.prototype.initialize = function (optionalParams) {
238
+ OmnichannelChatSDK.prototype.retryLoadAMSClient = function () {
239
+ return __awaiter(this, void 0, void 0, function () {
240
+ var RETRY_DELAY_MS, MAX_RETRY_COUNT, retryCount;
241
+ return __generator(this, function (_a) {
242
+ switch (_a.label) {
243
+ case 0:
244
+ RETRY_DELAY_MS = 1000;
245
+ MAX_RETRY_COUNT = 5;
246
+ retryCount = 0;
247
+ _a.label = 1;
248
+ case 1:
249
+ if (!(retryCount < MAX_RETRY_COUNT)) return [3 /*break*/, 3];
250
+ if (this.AMSClient) {
251
+ return [2 /*return*/, this.AMSClient];
252
+ }
253
+ return [4 /*yield*/, WebUtils_1.sleep(RETRY_DELAY_MS)];
254
+ case 2:
255
+ _a.sent();
256
+ retryCount++;
257
+ return [3 /*break*/, 1];
258
+ case 3: return [2 /*return*/, null];
259
+ }
260
+ });
261
+ });
262
+ };
263
+ OmnichannelChatSDK.prototype.getAMSClient = function () {
264
+ return __awaiter(this, void 0, void 0, function () {
265
+ var _a;
266
+ return __generator(this, function (_b) {
267
+ switch (_b.label) {
268
+ case 0:
269
+ if (this.AMSClientLoadCurrentState === AMSClientLoadStates_1.AMSClientLoadStates.NOT_LOADED && this.liveChatVersion === LiveChatVersion_1.default.V1) {
270
+ return [2 /*return*/, null];
271
+ }
272
+ _a = this.AMSClientLoadCurrentState;
273
+ switch (_a) {
274
+ case AMSClientLoadStates_1.AMSClientLoadStates.LOADED: return [3 /*break*/, 1];
275
+ case AMSClientLoadStates_1.AMSClientLoadStates.LOADING: return [3 /*break*/, 2];
276
+ case AMSClientLoadStates_1.AMSClientLoadStates.ERROR: return [3 /*break*/, 4];
277
+ case AMSClientLoadStates_1.AMSClientLoadStates.NOT_LOADED: return [3 /*break*/, 4];
278
+ }
279
+ return [3 /*break*/, 6];
280
+ case 1: return [2 /*return*/, this.AMSClient];
281
+ case 2: return [4 /*yield*/, this.retryLoadAMSClient()];
282
+ case 3: return [2 /*return*/, _b.sent()];
283
+ case 4: return [4 /*yield*/, this.loadAmsClient()];
284
+ case 5:
285
+ _b.sent();
286
+ return [2 /*return*/, this.AMSClient];
287
+ case 6: return [2 /*return*/, null];
288
+ }
289
+ });
290
+ });
291
+ };
292
+ OmnichannelChatSDK.prototype.loadInitComponents = function () {
293
+ return __awaiter(this, void 0, void 0, function () {
294
+ var supportedLiveChatVersions;
295
+ return __generator(this, function (_a) {
296
+ this.scenarioMarker.startScenario(TelemetryEvent_1.default.InitializeComponents);
297
+ supportedLiveChatVersions = [LiveChatVersion_1.default.V1, LiveChatVersion_1.default.V2];
298
+ if (!supportedLiveChatVersions.includes(this.liveChatVersion)) {
299
+ exceptionThrowers_1.default.throwUnsupportedLiveChatVersionFailure(new Error(ChatSDKError_1.ChatSDKErrorName.UnsupportedLiveChatVersion), this.scenarioMarker, TelemetryEvent_1.default.InitializeComponents);
300
+ }
301
+ this.isInitialized = true;
302
+ this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeComponents);
303
+ return [2 /*return*/];
304
+ });
305
+ });
306
+ };
307
+ OmnichannelChatSDK.prototype.loadAmsClient = function () {
308
+ return __awaiter(this, void 0, void 0, function () {
309
+ var _a, _b, e_1;
310
+ return __generator(this, function (_c) {
311
+ switch (_c.label) {
312
+ case 0:
313
+ this.scenarioMarker.startScenario(TelemetryEvent_1.default.InitializeMessagingClient);
314
+ _c.label = 1;
315
+ case 1:
316
+ _c.trys.push([1, 6, , 7]);
317
+ if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 3];
318
+ this.ACSClient = new ACSClient_1.default(this.acsClientLogger);
319
+ this.AMSClientLoadCurrentState = AMSClientLoadStates_1.AMSClientLoadStates.LOADING;
320
+ _a = this;
321
+ return [4 /*yield*/, omnichannel_amsclient_1.default({
322
+ framedMode: platform_1.isBrowser(),
323
+ multiClient: true,
324
+ debug: false,
325
+ logger: this.amsClientLogger
326
+ })];
327
+ case 2:
328
+ _a.AMSClient = _c.sent();
329
+ this.AMSClientLoadCurrentState = AMSClientLoadStates_1.AMSClientLoadStates.LOADED;
330
+ return [3 /*break*/, 5];
331
+ case 3:
332
+ if (!(this.liveChatVersion === LiveChatVersion_1.default.V1)) return [3 /*break*/, 5];
333
+ _b = this;
334
+ return [4 /*yield*/, this.getIC3Client()];
335
+ case 4:
336
+ _b.IC3Client = _c.sent();
337
+ _c.label = 5;
338
+ case 5:
339
+ this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeMessagingClient);
340
+ return [3 /*break*/, 7];
341
+ case 6:
342
+ e_1 = _c.sent();
343
+ this.AMSClientLoadCurrentState = AMSClientLoadStates_1.AMSClientLoadStates.ERROR;
344
+ exceptionThrowers_1.default.throwMessagingClientCreationFailure(e_1, this.scenarioMarker, TelemetryEvent_1.default.InitializeMessagingClient);
345
+ return [3 /*break*/, 7];
346
+ case 7: return [2 /*return*/];
347
+ }
348
+ });
349
+ });
350
+ };
351
+ OmnichannelChatSDK.prototype.parallelInitialization = function (optionalParams) {
352
+ if (optionalParams === void 0) { optionalParams = {}; }
353
+ return __awaiter(this, void 0, void 0, function () {
354
+ var error_1;
355
+ return __generator(this, function (_a) {
356
+ switch (_a.label) {
357
+ case 0:
358
+ _a.trys.push([0, 2, , 3]);
359
+ this.scenarioMarker.startScenario(TelemetryEvent_1.default.InitializeChatSDKParallel);
360
+ if (this.isInitialized) {
361
+ this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDKParallel);
362
+ return [2 /*return*/, this.liveChatConfig];
363
+ }
364
+ this.useCoreServicesOrgUrlIfNotSet();
365
+ return [4 /*yield*/, Promise.all([this.loadInitComponents(), this.loadChatConfig(optionalParams)])];
366
+ case 1:
367
+ _a.sent();
368
+ // this will load ams in the background, without holding the load
369
+ this.loadAmsClient();
370
+ this.isInitialized = true;
371
+ this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDKParallel);
372
+ return [3 /*break*/, 3];
373
+ case 2:
374
+ error_1 = _a.sent();
375
+ // Handle the error appropriately
376
+ this.scenarioMarker.failScenario(TelemetryEvent_1.default.InitializeChatSDKParallel);
377
+ throw error_1;
378
+ case 3: return [2 /*return*/, this.liveChatConfig];
379
+ }
380
+ });
381
+ });
382
+ };
383
+ // We will keep this logic for backward compatibility for customers with unknown implementation, so they can test before fully adoption
384
+ OmnichannelChatSDK.prototype.sequentialInitialization = function (optionalParams) {
236
385
  var _a;
237
386
  if (optionalParams === void 0) { optionalParams = {}; }
238
387
  return __awaiter(this, void 0, void 0, function () {
239
- var useCoreServices, _b, e_1, getLiveChatConfigOptionalParams, e_2, supportedLiveChatVersions, _c, _d, e_3;
388
+ var useCoreServices, _b, e_2, getLiveChatConfigOptionalParams, e_3, supportedLiveChatVersions, _c, _d, e_4;
240
389
  return __generator(this, function (_e) {
241
390
  switch (_e.label) {
242
391
  case 0:
@@ -258,8 +407,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
258
407
  setOcUserAgent_1.default(this.OCClient, (_a = this.chatSDKConfig) === null || _a === void 0 ? void 0 : _a.ocUserAgent);
259
408
  return [3 /*break*/, 4];
260
409
  case 3:
261
- e_1 = _e.sent();
262
- exceptionThrowers_1.default.throwOmnichannelClientInitializationFailure(e_1, this.scenarioMarker, TelemetryEvent_1.default.InitializeChatSDK);
410
+ e_2 = _e.sent();
411
+ exceptionThrowers_1.default.throwOmnichannelClientInitializationFailure(e_2, this.scenarioMarker, TelemetryEvent_1.default.InitializeChatSDK);
263
412
  return [3 /*break*/, 4];
264
413
  case 4:
265
414
  _e.trys.push([4, 6, , 7]);
@@ -269,8 +418,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
269
418
  _e.sent();
270
419
  return [3 /*break*/, 7];
271
420
  case 6:
272
- e_2 = _e.sent();
273
- exceptionThrowers_1.default.throwChatConfigRetrievalFailure(e_2, this.scenarioMarker, TelemetryEvent_1.default.InitializeChatSDK);
421
+ e_3 = _e.sent();
422
+ exceptionThrowers_1.default.throwChatConfigRetrievalFailure(e_3, this.scenarioMarker, TelemetryEvent_1.default.InitializeChatSDK);
274
423
  return [3 /*break*/, 7];
275
424
  case 7:
276
425
  supportedLiveChatVersions = [LiveChatVersion_1.default.V1, LiveChatVersion_1.default.V2];
@@ -291,6 +440,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
291
440
  })];
292
441
  case 9:
293
442
  _c.AMSClient = _e.sent();
443
+ this.AMSClientLoadCurrentState = AMSClientLoadStates_1.AMSClientLoadStates.LOADED;
294
444
  return [3 /*break*/, 12];
295
445
  case 10:
296
446
  if (!(this.liveChatVersion === LiveChatVersion_1.default.V1)) return [3 /*break*/, 12];
@@ -304,17 +454,78 @@ var OmnichannelChatSDK = /** @class */ (function () {
304
454
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDK);
305
455
  return [3 /*break*/, 14];
306
456
  case 13:
307
- e_3 = _e.sent();
308
- exceptionThrowers_1.default.throwMessagingClientCreationFailure(e_3, this.scenarioMarker, TelemetryEvent_1.default.InitializeChatSDK);
457
+ e_4 = _e.sent();
458
+ this.AMSClientLoadCurrentState = AMSClientLoadStates_1.AMSClientLoadStates.ERROR;
459
+ exceptionThrowers_1.default.throwMessagingClientCreationFailure(e_4, this.scenarioMarker, TelemetryEvent_1.default.InitializeChatSDK);
309
460
  return [3 /*break*/, 14];
310
461
  case 14: return [2 /*return*/, this.liveChatConfig];
311
462
  }
312
463
  });
313
464
  });
314
465
  };
466
+ /**
467
+ *
468
+ * @param optionalParams
469
+ * @param parallel if true , it will run in parallel (fastest version) with components loaded in the background
470
+ * @returns livechatConfig
471
+ */
472
+ OmnichannelChatSDK.prototype.initialize = function (optionalParams) {
473
+ if (optionalParams === void 0) { optionalParams = {}; }
474
+ return __awaiter(this, void 0, void 0, function () {
475
+ var useParallelLoad;
476
+ return __generator(this, function (_a) {
477
+ switch (_a.label) {
478
+ case 0:
479
+ useParallelLoad = optionalParams.useParallelLoad;
480
+ if (!(useParallelLoad === true)) return [3 /*break*/, 2];
481
+ return [4 /*yield*/, this.parallelInitialization(optionalParams)];
482
+ case 1: return [2 /*return*/, _a.sent()];
483
+ case 2: return [4 /*yield*/, this.sequentialInitialization(optionalParams)];
484
+ case 3: return [2 /*return*/, _a.sent()];
485
+ }
486
+ });
487
+ });
488
+ };
489
+ OmnichannelChatSDK.prototype.loadChatConfig = function (optionalParams) {
490
+ var _a;
491
+ if (optionalParams === void 0) { optionalParams = {}; }
492
+ return __awaiter(this, void 0, void 0, function () {
493
+ var useCoreServices, getLiveChatConfigOptionalParams, e_5;
494
+ return __generator(this, function (_b) {
495
+ switch (_b.label) {
496
+ case 0:
497
+ this.scenarioMarker.startScenario(TelemetryEvent_1.default.InitializeLoadChatConfig);
498
+ useCoreServices = CoreServicesUtils_1.isCoreServicesOrgUrl(this.omnichannelConfig.orgUrl);
499
+ try {
500
+ this.OCSDKProvider = ocsdk_1.SDKProvider;
501
+ this.OCClient = ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, createOcSDKConfiguration_1.default(useCoreServices), this.ocSdkLogger);
502
+ setOcUserAgent_1.default(this.OCClient, (_a = this.chatSDKConfig) === null || _a === void 0 ? void 0 : _a.ocUserAgent);
503
+ }
504
+ catch (e) {
505
+ exceptionThrowers_1.default.throwOmnichannelClientInitializationFailure(e, this.scenarioMarker, TelemetryEvent_1.default.InitializeLoadChatConfig);
506
+ }
507
+ _b.label = 1;
508
+ case 1:
509
+ _b.trys.push([1, 3, , 4]);
510
+ getLiveChatConfigOptionalParams = optionalParams.getLiveChatConfigOptionalParams;
511
+ return [4 /*yield*/, this.getChatConfig(getLiveChatConfigOptionalParams || {})];
512
+ case 2:
513
+ _b.sent();
514
+ return [3 /*break*/, 4];
515
+ case 3:
516
+ e_5 = _b.sent();
517
+ exceptionThrowers_1.default.throwChatConfigRetrievalFailure(e_5, this.scenarioMarker, TelemetryEvent_1.default.InitializeLoadChatConfig);
518
+ return [3 /*break*/, 4];
519
+ case 4:
520
+ this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeLoadChatConfig);
521
+ return [2 /*return*/];
522
+ }
523
+ });
524
+ });
525
+ };
315
526
  OmnichannelChatSDK.prototype.getChatReconnectContextWithAuthToken = function () {
316
527
  return __awaiter(this, void 0, void 0, function () {
317
- var context, reconnectableChatsParams, reconnectableChatsResponse, error_1, exceptionDetails, telemetryData;
528
+ var context, reconnectableChatsParams, reconnectableChatsResponse, error_2, exceptionDetails, telemetryData;
318
529
  return __generator(this, function (_a) {
319
530
  switch (_a.label) {
320
531
  case 0:
@@ -344,7 +555,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
344
555
  });
345
556
  return [3 /*break*/, 4];
346
557
  case 3:
347
- error_1 = _a.sent();
558
+ error_2 = _a.sent();
348
559
  exceptionDetails = {
349
560
  response: "OCClientGetReconnectableChatsFailed"
350
561
  };
@@ -353,11 +564,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
353
564
  ChatId: this.chatToken.chatId,
354
565
  ExceptionDetails: JSON.stringify(exceptionDetails)
355
566
  };
356
- if (utilities_1.isClientIdNotFoundErrorMessage(error_1)) {
357
- exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(error_1, this.scenarioMarker, TelemetryEvent_1.default.GetChatReconnectContextWithAuthToken, telemetryData);
567
+ if (utilities_1.isClientIdNotFoundErrorMessage(error_2)) {
568
+ exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(error_2, this.scenarioMarker, TelemetryEvent_1.default.GetChatReconnectContextWithAuthToken, telemetryData);
358
569
  }
359
570
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetChatReconnectContextWithAuthToken, telemetryData);
360
- console.error("OmnichannelChatSDK/GetChatReconnectContextWithAuthToken/error " + error_1);
571
+ console.error("OmnichannelChatSDK/GetChatReconnectContextWithAuthToken/error " + error_2);
361
572
  return [3 /*break*/, 4];
362
573
  case 4: return [2 /*return*/, context];
363
574
  }
@@ -367,7 +578,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
367
578
  OmnichannelChatSDK.prototype.getChatReconnectContextWithReconnectId = function (optionalParams) {
368
579
  if (optionalParams === void 0) { optionalParams = {}; }
369
580
  return __awaiter(this, void 0, void 0, function () {
370
- var context, reconnectAvailabilityResponse, error_2, exceptionDetails;
581
+ var context, reconnectAvailabilityResponse, error_3, exceptionDetails;
371
582
  return __generator(this, function (_a) {
372
583
  switch (_a.label) {
373
584
  case 0:
@@ -401,7 +612,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
401
612
  });
402
613
  return [3 /*break*/, 4];
403
614
  case 3:
404
- error_2 = _a.sent();
615
+ error_3 = _a.sent();
405
616
  exceptionDetails = {
406
617
  response: "OCClientGetReconnectAvailabilityFailed"
407
618
  };
@@ -410,7 +621,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
410
621
  ChatId: this.chatToken.chatId,
411
622
  ExceptionDetails: JSON.stringify(exceptionDetails)
412
623
  });
413
- console.error("OmnichannelChatSDK/GetChatReconnectContextWithReconnectId/error " + error_2);
624
+ console.error("OmnichannelChatSDK/GetChatReconnectContextWithReconnectId/error " + error_3);
414
625
  return [3 /*break*/, 4];
415
626
  case 4:
416
627
  //here the context contains recconnectionId if valid, or redirectionURL if not valid
@@ -461,7 +672,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
461
672
  var _a, _b, _c, _d, _e, _f, _g, _h;
462
673
  if (optionalParams === void 0) { optionalParams = {}; }
463
674
  return __awaiter(this, void 0, void 0, function () {
464
- var shouldReinitIC3Client, _j, reconnectableChatsParams, reconnectableChatsResponse, e_4, telemetryData, conversationDetails, telemetryData, telemetryData, e_5, telemetryData, sessionInitOptionalParams, location_2, sessionInitPromise, messagingClientPromise, attachmentClientPromise;
675
+ var shouldReinitIC3Client, _j, reconnectableChatsParams, reconnectableChatsResponse, e_6, telemetryData, conversationDetails, telemetryData, telemetryData, e_7, telemetryData, sessionInitOptionalParams, location_2, sessionInitPromise, messagingClientPromise, attachmentClientPromise;
465
676
  var _this = this;
466
677
  return __generator(this, function (_k) {
467
678
  switch (_k.label) {
@@ -498,12 +709,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
498
709
  }
499
710
  return [3 /*break*/, 6];
500
711
  case 5:
501
- e_4 = _k.sent();
712
+ e_6 = _k.sent();
502
713
  telemetryData = {
503
714
  RequestId: this.requestId,
504
715
  ChatId: this.chatToken.chatId,
505
716
  };
506
- exceptionThrowers_1.default.throwPersistentChatConversationRetrievalFailure(e_4, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
717
+ exceptionThrowers_1.default.throwPersistentChatConversationRetrievalFailure(e_6, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
507
718
  return [3 /*break*/, 6];
508
719
  case 6:
509
720
  if (!(optionalParams.liveChatContext && Object.keys(optionalParams.liveChatContext).length > 0 && !this.reconnectId)) return [3 /*break*/, 8];
@@ -551,12 +762,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
551
762
  _k.sent();
552
763
  return [3 /*break*/, 14];
553
764
  case 13:
554
- e_5 = _k.sent();
765
+ e_7 = _k.sent();
555
766
  telemetryData = {
556
767
  RequestId: this.requestId,
557
768
  ChatId: this.chatToken.chatId,
558
769
  };
559
- exceptionThrowers_1.default.throwAuthenticatedChatConversationRetrievalFailure(e_5, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
770
+ exceptionThrowers_1.default.throwAuthenticatedChatConversationRetrievalFailure(e_7, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
560
771
  return [3 /*break*/, 14];
561
772
  case 14:
562
773
  if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 16];
@@ -586,7 +797,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
586
797
  _k.label = 18;
587
798
  case 18:
588
799
  sessionInitPromise = function () { return __awaiter(_this, void 0, void 0, function () {
589
- var error_3, telemetryData;
800
+ var error_4, telemetryData;
590
801
  var _a, _b, _c, _d;
591
802
  return __generator(this, function (_e) {
592
803
  switch (_e.label) {
@@ -600,23 +811,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
600
811
  _e.sent();
601
812
  return [3 /*break*/, 4];
602
813
  case 3:
603
- error_3 = _e.sent();
814
+ error_4 = _e.sent();
604
815
  telemetryData = {
605
816
  RequestId: this.requestId,
606
817
  ChatId: this.chatToken.chatId,
607
818
  };
608
819
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
609
- if (((_a = error_3) === null || _a === void 0 ? void 0 : _a.isAxiosError) && ((_d = (_c = (_b = error_3.response) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c.errorcode) === null || _d === void 0 ? void 0 : _d.toString()) === OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour.toString()) {
610
- exceptionThrowers_1.default.throwWidgetUseOutsideOperatingHour(error_3, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
820
+ if (((_a = error_4) === null || _a === void 0 ? void 0 : _a.isAxiosError) && ((_d = (_c = (_b = error_4.response) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c.errorcode) === null || _d === void 0 ? void 0 : _d.toString()) === OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour.toString()) {
821
+ exceptionThrowers_1.default.throwWidgetUseOutsideOperatingHour(error_4, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
611
822
  }
612
- exceptionThrowers_1.default.throwConversationInitializationFailure(error_3, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
823
+ exceptionThrowers_1.default.throwConversationInitializationFailure(error_4, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
613
824
  return [3 /*break*/, 4];
614
825
  case 4: return [2 /*return*/];
615
826
  }
616
827
  });
617
828
  }); };
618
829
  messagingClientPromise = function () { return __awaiter(_this, void 0, void 0, function () {
619
- var chatAdapterConfig, error_4, telemetryData, _a, error_5, telemetryData, error_6, telemetryData, _b, error_7, telemetryData;
830
+ var chatAdapterConfig, error_5, telemetryData, _a, error_6, telemetryData, error_7, telemetryData, _b, error_8, telemetryData;
620
831
  var _c, _d;
621
832
  return __generator(this, function (_e) {
622
833
  switch (_e.label) {
@@ -640,12 +851,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
640
851
  _e.sent();
641
852
  return [3 /*break*/, 4];
642
853
  case 3:
643
- error_4 = _e.sent();
854
+ error_5 = _e.sent();
644
855
  telemetryData = {
645
856
  RequestId: this.requestId,
646
857
  ChatId: this.chatToken.chatId,
647
858
  };
648
- exceptionThrowers_1.default.throwMessagingClientInitializationFailure(error_4, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
859
+ exceptionThrowers_1.default.throwMessagingClientInitializationFailure(error_5, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
649
860
  return [3 /*break*/, 4];
650
861
  case 4:
651
862
  _e.trys.push([4, 6, , 7]);
@@ -663,12 +874,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
663
874
  });
664
875
  return [3 /*break*/, 7];
665
876
  case 6:
666
- error_5 = _e.sent();
877
+ error_6 = _e.sent();
667
878
  telemetryData = {
668
879
  RequestId: this.requestId,
669
880
  ChatId: this.chatToken.chatId,
670
881
  };
671
- exceptionThrowers_1.default.throwMessagingClientConversationJoinFailure(error_5, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
882
+ exceptionThrowers_1.default.throwMessagingClientConversationJoinFailure(error_6, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
672
883
  return [3 /*break*/, 7];
673
884
  case 7: return [3 /*break*/, 14];
674
885
  case 8:
@@ -682,12 +893,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
682
893
  _e.sent();
683
894
  return [3 /*break*/, 11];
684
895
  case 10:
685
- error_6 = _e.sent();
896
+ error_7 = _e.sent();
686
897
  telemetryData = {
687
898
  RequestId: this.requestId,
688
899
  ChatId: this.chatToken.chatId,
689
900
  };
690
- exceptionThrowers_1.default.throwMessagingClientInitializationFailure(error_6, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
901
+ exceptionThrowers_1.default.throwMessagingClientInitializationFailure(error_7, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
691
902
  return [3 /*break*/, 11];
692
903
  case 11:
693
904
  _e.trys.push([11, 13, , 14]);
@@ -701,39 +912,41 @@ var OmnichannelChatSDK = /** @class */ (function () {
701
912
  });
702
913
  return [3 /*break*/, 14];
703
914
  case 13:
704
- error_7 = _e.sent();
915
+ error_8 = _e.sent();
705
916
  telemetryData = {
706
917
  RequestId: this.requestId,
707
918
  ChatId: this.chatToken.chatId,
708
919
  };
709
- exceptionThrowers_1.default.throwMessagingClientConversationJoinFailure(error_7, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
920
+ exceptionThrowers_1.default.throwMessagingClientConversationJoinFailure(error_8, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
710
921
  return [3 /*break*/, 14];
711
922
  case 14: return [2 /*return*/];
712
923
  }
713
924
  });
714
925
  }); };
715
926
  attachmentClientPromise = function () { return __awaiter(_this, void 0, void 0, function () {
716
- var error_8, telemetryData;
717
- var _a;
718
- return __generator(this, function (_b) {
719
- switch (_b.label) {
927
+ var amsClient, error_9, telemetryData;
928
+ return __generator(this, function (_a) {
929
+ switch (_a.label) {
720
930
  case 0:
721
- _b.trys.push([0, 3, , 4]);
722
- if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 2];
723
- return [4 /*yield*/, ((_a = this.AMSClient) === null || _a === void 0 ? void 0 : _a.initialize({ chatToken: this.chatToken }))];
931
+ _a.trys.push([0, 4, , 5]);
932
+ return [4 /*yield*/, this.getAMSClient()];
724
933
  case 1:
725
- _b.sent();
726
- _b.label = 2;
727
- case 2: return [3 /*break*/, 4];
728
- case 3:
729
- error_8 = _b.sent();
934
+ amsClient = _a.sent();
935
+ if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 3];
936
+ return [4 /*yield*/, (amsClient === null || amsClient === void 0 ? void 0 : amsClient.initialize({ chatToken: this.chatToken }))];
937
+ case 2:
938
+ _a.sent();
939
+ _a.label = 3;
940
+ case 3: return [3 /*break*/, 5];
941
+ case 4:
942
+ error_9 = _a.sent();
730
943
  telemetryData = {
731
944
  RequestId: this.requestId,
732
945
  ChatId: this.chatToken.chatId,
733
946
  };
734
- exceptionThrowers_1.default.throwMessagingClientInitializationFailure(error_8, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
735
- return [3 /*break*/, 4];
736
- case 4: return [2 /*return*/];
947
+ exceptionThrowers_1.default.throwMessagingClientInitializationFailure(error_9, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
948
+ return [3 /*break*/, 5];
949
+ case 5: return [2 /*return*/];
737
950
  }
738
951
  });
739
952
  }); };
@@ -761,7 +974,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
761
974
  OmnichannelChatSDK.prototype.endChat = function () {
762
975
  var _a, _b, _c;
763
976
  return __awaiter(this, void 0, void 0, function () {
764
- var sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_9, telemetryData;
977
+ var sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_10, telemetryData;
765
978
  return __generator(this, function (_d) {
766
979
  switch (_d.label) {
767
980
  case 0:
@@ -811,12 +1024,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
811
1024
  loggerUtils_1.default.setChatId('', this.ocSdkLogger, this.acsClientLogger, this.acsAdapterLogger, this.callingSdkLogger, this.amsClientLogger, this.ic3ClientLogger);
812
1025
  return [3 /*break*/, 4];
813
1026
  case 3:
814
- error_9 = _d.sent();
1027
+ error_10 = _d.sent();
815
1028
  telemetryData = {
816
1029
  RequestId: this.requestId,
817
1030
  ChatId: this.chatToken.chatId
818
1031
  };
819
- exceptionThrowers_1.default.throwConversationClosureFailure(error_9, this.scenarioMarker, TelemetryEvent_1.default.EndChat, telemetryData);
1032
+ exceptionThrowers_1.default.throwConversationClosureFailure(error_10, this.scenarioMarker, TelemetryEvent_1.default.EndChat, telemetryData);
820
1033
  return [3 /*break*/, 4];
821
1034
  case 4:
822
1035
  if (this.refreshTokenTimer !== null) {
@@ -867,7 +1080,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
867
1080
  var _a, _b, _c, _d;
868
1081
  if (optionalParams === void 0) { optionalParams = {}; }
869
1082
  return __awaiter(this, void 0, void 0, function () {
870
- var requestId, chatToken, chatId, reconnectId, sessionId, getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, canRenderPostChat, participantType, liveWorkItemDetails, error_10, telemetryData;
1083
+ var requestId, chatToken, chatId, reconnectId, sessionId, getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, canRenderPostChat, participantType, liveWorkItemDetails, error_11, telemetryData;
871
1084
  return __generator(this, function (_e) {
872
1085
  switch (_e.label) {
873
1086
  case 0:
@@ -931,15 +1144,15 @@ var OmnichannelChatSDK = /** @class */ (function () {
931
1144
  });
932
1145
  return [2 /*return*/, liveWorkItemDetails];
933
1146
  case 3:
934
- error_10 = _e.sent();
1147
+ error_11 = _e.sent();
935
1148
  telemetryData = {
936
1149
  RequestId: requestId,
937
1150
  ChatId: chatId || ''
938
1151
  };
939
- if (utilities_1.isClientIdNotFoundErrorMessage(error_10)) {
940
- exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(error_10, this.scenarioMarker, TelemetryEvent_1.default.GetConversationDetails, telemetryData);
1152
+ if (utilities_1.isClientIdNotFoundErrorMessage(error_11)) {
1153
+ exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(error_11, this.scenarioMarker, TelemetryEvent_1.default.GetConversationDetails, telemetryData);
941
1154
  }
942
- exceptionSuppressors_1.default.suppressConversationDetailsRetrievalFailure(error_10, this.scenarioMarker, TelemetryEvent_1.default.GetConversationDetails, telemetryData);
1155
+ exceptionSuppressors_1.default.suppressConversationDetailsRetrievalFailure(error_11, this.scenarioMarker, TelemetryEvent_1.default.GetConversationDetails, telemetryData);
943
1156
  return [3 /*break*/, 4];
944
1157
  case 4: return [2 /*return*/, {}];
945
1158
  }
@@ -982,7 +1195,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
982
1195
  var _a, _b, _c;
983
1196
  if (cached === void 0) { cached = true; }
984
1197
  return __awaiter(this, void 0, void 0, function () {
985
- var getChatTokenOptionalParams, chatToken, chatId, token, regionGtms, expiresIn, visitorId, voiceVideoCallToken, acsEndpoint, attachmentConfiguration, error_11, telemetryData;
1198
+ var getChatTokenOptionalParams, chatToken, chatId, token, regionGtms, expiresIn, visitorId, voiceVideoCallToken, acsEndpoint, attachmentConfiguration, error_12, telemetryData;
986
1199
  return __generator(this, function (_d) {
987
1200
  switch (_d.label) {
988
1201
  case 0:
@@ -1032,16 +1245,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
1032
1245
  });
1033
1246
  return [3 /*break*/, 4];
1034
1247
  case 3:
1035
- error_11 = _d.sent();
1248
+ error_12 = _d.sent();
1036
1249
  telemetryData = {
1037
1250
  RequestId: this.requestId,
1038
1251
  ChatId: (_c = this.chatToken) === null || _c === void 0 ? void 0 : _c.chatId,
1039
1252
  };
1040
- if (utilities_1.isClientIdNotFoundErrorMessage(error_11)) {
1041
- exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(error_11, this.scenarioMarker, TelemetryEvent_1.default.GetChatToken, telemetryData);
1253
+ if (utilities_1.isClientIdNotFoundErrorMessage(error_12)) {
1254
+ exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(error_12, this.scenarioMarker, TelemetryEvent_1.default.GetChatToken, telemetryData);
1042
1255
  }
1043
1256
  else {
1044
- exceptionThrowers_1.default.throwChatTokenRetrievalFailure(error_11, this.scenarioMarker, TelemetryEvent_1.default.GetChatToken, telemetryData);
1257
+ exceptionThrowers_1.default.throwChatTokenRetrievalFailure(error_12, this.scenarioMarker, TelemetryEvent_1.default.GetChatToken, telemetryData);
1045
1258
  }
1046
1259
  return [3 /*break*/, 4];
1047
1260
  case 4: return [3 /*break*/, 6];
@@ -1120,7 +1333,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1120
1333
  OmnichannelChatSDK.prototype.sendMessage = function (message) {
1121
1334
  var _a;
1122
1335
  return __awaiter(this, void 0, void 0, function () {
1123
- var _b, disable, maskingCharacter, content, _i, _c, maskingRule, regex, match, replaceStr, sendMessageRequest, error_12, messageToSend, _d;
1336
+ var _b, disable, maskingCharacter, content, _i, _c, maskingRule, regex, match, replaceStr, sendMessageRequest, error_13, messageToSend, _d;
1124
1337
  return __generator(this, function (_e) {
1125
1338
  switch (_e.label) {
1126
1339
  case 0:
@@ -1165,7 +1378,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1165
1378
  });
1166
1379
  return [3 /*break*/, 4];
1167
1380
  case 3:
1168
- error_12 = _e.sent();
1381
+ error_13 = _e.sent();
1169
1382
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendMessages, {
1170
1383
  RequestId: this.requestId,
1171
1384
  ChatId: this.chatToken.chatId
@@ -1333,7 +1546,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1333
1546
  };
1334
1547
  OmnichannelChatSDK.prototype.sendTypingEvent = function () {
1335
1548
  return __awaiter(this, void 0, void 0, function () {
1336
- var error_13, typingPayload, members, botMembers, error_14;
1549
+ var error_14, typingPayload, members, botMembers, error_15;
1337
1550
  return __generator(this, function (_a) {
1338
1551
  switch (_a.label) {
1339
1552
  case 0:
@@ -1359,7 +1572,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1359
1572
  });
1360
1573
  return [3 /*break*/, 5];
1361
1574
  case 4:
1362
- error_13 = _a.sent();
1575
+ error_14 = _a.sent();
1363
1576
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendTypingEvent, {
1364
1577
  RequestId: this.requestId,
1365
1578
  ChatId: this.chatToken.chatId
@@ -1387,7 +1600,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1387
1600
  });
1388
1601
  return [3 /*break*/, 12];
1389
1602
  case 11:
1390
- error_14 = _a.sent();
1603
+ error_15 = _a.sent();
1391
1604
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendTypingEvent, {
1392
1605
  RequestId: this.requestId,
1393
1606
  ChatId: this.chatToken.chatId
@@ -1505,24 +1718,26 @@ var OmnichannelChatSDK = /** @class */ (function () {
1505
1718
  });
1506
1719
  };
1507
1720
  OmnichannelChatSDK.prototype.uploadFileAttachment = function (fileInfo) {
1508
- var _a, _b, _c, _d;
1721
+ var _a, _b;
1509
1722
  return __awaiter(this, void 0, void 0, function () {
1510
- var createObjectResponse, documentId, uploadDocumentResponse, fileIdsProperty, fileMetaProperty, sendMessageRequest, messageToSend, error_15, fileMetadata, messageToSend, error_16;
1511
- return __generator(this, function (_e) {
1512
- switch (_e.label) {
1513
- case 0:
1723
+ var amsClient, createObjectResponse, documentId, uploadDocumentResponse, fileIdsProperty, fileMetaProperty, sendMessageRequest, messageToSend, error_16, fileMetadata, messageToSend, error_17;
1724
+ return __generator(this, function (_c) {
1725
+ switch (_c.label) {
1726
+ case 0: return [4 /*yield*/, this.getAMSClient()];
1727
+ case 1:
1728
+ amsClient = _c.sent();
1514
1729
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.UploadFileAttachment, {
1515
1730
  RequestId: this.requestId,
1516
1731
  ChatId: this.chatToken.chatId
1517
1732
  });
1518
- if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 7];
1519
- return [4 /*yield*/, ((_a = this.AMSClient) === null || _a === void 0 ? void 0 : _a.createObject((_b = this.chatToken) === null || _b === void 0 ? void 0 : _b.chatId, fileInfo))];
1520
- case 1:
1521
- createObjectResponse = _e.sent();
1522
- documentId = createObjectResponse.id;
1523
- return [4 /*yield*/, ((_c = this.AMSClient) === null || _c === void 0 ? void 0 : _c.uploadDocument(documentId, fileInfo))];
1733
+ if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 8];
1734
+ return [4 /*yield*/, (amsClient === null || amsClient === void 0 ? void 0 : amsClient.createObject((_a = this.chatToken) === null || _a === void 0 ? void 0 : _a.chatId, fileInfo))];
1524
1735
  case 2:
1525
- uploadDocumentResponse = _e.sent();
1736
+ createObjectResponse = _c.sent();
1737
+ documentId = createObjectResponse.id;
1738
+ return [4 /*yield*/, (amsClient === null || amsClient === void 0 ? void 0 : amsClient.uploadDocument(documentId, fileInfo))];
1739
+ case 3:
1740
+ uploadDocumentResponse = _c.sent();
1526
1741
  fileIdsProperty = {
1527
1742
  amsReferences: JSON.stringify([documentId]),
1528
1743
  amsreferences: JSON.stringify([documentId])
@@ -1551,38 +1766,38 @@ var OmnichannelChatSDK = /** @class */ (function () {
1551
1766
  },
1552
1767
  fileMetadata: uploadDocumentResponse
1553
1768
  };
1554
- _e.label = 3;
1555
- case 3:
1556
- _e.trys.push([3, 5, , 6]);
1557
- return [4 /*yield*/, ((_d = this.conversation) === null || _d === void 0 ? void 0 : _d.sendMessage(sendMessageRequest))];
1769
+ _c.label = 4;
1558
1770
  case 4:
1559
- _e.sent();
1771
+ _c.trys.push([4, 6, , 7]);
1772
+ return [4 /*yield*/, ((_b = this.conversation) === null || _b === void 0 ? void 0 : _b.sendMessage(sendMessageRequest))];
1773
+ case 5:
1774
+ _c.sent();
1560
1775
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.UploadFileAttachment, {
1561
1776
  RequestId: this.requestId,
1562
1777
  ChatId: this.chatToken.chatId
1563
1778
  });
1564
1779
  return [2 /*return*/, messageToSend];
1565
- case 5:
1566
- error_15 = _e.sent();
1780
+ case 6:
1781
+ error_16 = _c.sent();
1567
1782
  console.error("OmnichannelChatSDK/uploadFileAttachment/sendMessage/error");
1568
1783
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
1569
1784
  RequestId: this.requestId,
1570
1785
  ChatId: this.chatToken.chatId
1571
1786
  });
1572
- return [3 /*break*/, 6];
1573
- case 6: return [2 /*return*/, {}];
1574
- case 7:
1787
+ return [3 /*break*/, 7];
1788
+ case 7: return [2 /*return*/, {}];
1789
+ case 8:
1575
1790
  fileMetadata = void 0;
1576
- if (!(platform_1.default.isReactNative() || platform_1.default.isNode())) return [3 /*break*/, 9];
1791
+ if (!(platform_1.default.isReactNative() || platform_1.default.isNode())) return [3 /*break*/, 10];
1577
1792
  return [4 /*yield*/, this.conversation.sendFileData(fileInfo, FileSharingProtocolType_1.default.AmsBasedFileSharing)];
1578
- case 8:
1579
- fileMetadata = _e.sent();
1580
- return [3 /*break*/, 11];
1581
- case 9: return [4 /*yield*/, this.conversation.uploadFile(fileInfo, FileSharingProtocolType_1.default.AmsBasedFileSharing)];
1582
- case 10:
1583
- fileMetadata = _e.sent();
1584
- _e.label = 11;
1793
+ case 9:
1794
+ fileMetadata = _c.sent();
1795
+ return [3 /*break*/, 12];
1796
+ case 10: return [4 /*yield*/, this.conversation.uploadFile(fileInfo, FileSharingProtocolType_1.default.AmsBasedFileSharing)];
1585
1797
  case 11:
1798
+ fileMetadata = _c.sent();
1799
+ _c.label = 12;
1800
+ case 12:
1586
1801
  messageToSend = {
1587
1802
  content: "",
1588
1803
  timestamp: new Date(),
@@ -1597,84 +1812,85 @@ var OmnichannelChatSDK = /** @class */ (function () {
1597
1812
  },
1598
1813
  fileMetadata: fileMetadata
1599
1814
  };
1600
- _e.label = 12;
1601
- case 12:
1602
- _e.trys.push([12, 14, , 15]);
1603
- return [4 /*yield*/, this.conversation.sendFileMessage(fileMetadata, messageToSend)];
1815
+ _c.label = 13;
1604
1816
  case 13:
1605
- _e.sent();
1817
+ _c.trys.push([13, 15, , 16]);
1818
+ return [4 /*yield*/, this.conversation.sendFileMessage(fileMetadata, messageToSend)];
1819
+ case 14:
1820
+ _c.sent();
1606
1821
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.UploadFileAttachment, {
1607
1822
  RequestId: this.requestId,
1608
1823
  ChatId: this.chatToken.chatId
1609
1824
  });
1610
1825
  return [2 /*return*/, messageToSend];
1611
- case 14:
1612
- error_16 = _e.sent();
1613
- console.error("OmnichannelChatSDK/uploadFileAttachment/error: " + error_16);
1826
+ case 15:
1827
+ error_17 = _c.sent();
1828
+ console.error("OmnichannelChatSDK/uploadFileAttachment/error: " + error_17);
1614
1829
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
1615
1830
  RequestId: this.requestId,
1616
1831
  ChatId: this.chatToken.chatId
1617
1832
  });
1618
- return [3 /*break*/, 15];
1619
- case 15: return [2 /*return*/, {}];
1833
+ return [3 /*break*/, 16];
1834
+ case 16: return [2 /*return*/, {}];
1620
1835
  }
1621
1836
  });
1622
1837
  });
1623
1838
  };
1624
1839
  OmnichannelChatSDK.prototype.downloadFileAttachment = function (fileMetadata) {
1625
- var _a, _b;
1626
1840
  return __awaiter(this, void 0, void 0, function () {
1627
- var response, view_location, viewResponse, _c, downloadedFile, error_17;
1628
- return __generator(this, function (_d) {
1629
- switch (_d.label) {
1630
- case 0:
1841
+ var amsClient, response, view_location, viewResponse, _a, downloadedFile, error_18;
1842
+ return __generator(this, function (_b) {
1843
+ switch (_b.label) {
1844
+ case 0: return [4 /*yield*/, this.getAMSClient()];
1845
+ case 1:
1846
+ amsClient = _b.sent();
1631
1847
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
1632
1848
  RequestId: this.requestId,
1633
1849
  ChatId: this.chatToken.chatId
1634
1850
  });
1635
- if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 6];
1636
- _d.label = 1;
1637
- case 1:
1638
- _d.trys.push([1, 4, , 5]);
1639
- return [4 /*yield*/, ((_a = this.AMSClient) === null || _a === void 0 ? void 0 : _a.getViewStatus(fileMetadata))];
1851
+ if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 7];
1852
+ _b.label = 2;
1640
1853
  case 2:
1641
- response = _d.sent();
1642
- view_location = response.view_location;
1643
- return [4 /*yield*/, ((_b = this.AMSClient) === null || _b === void 0 ? void 0 : _b.getView(fileMetadata, view_location))];
1854
+ _b.trys.push([2, 5, , 6]);
1855
+ return [4 /*yield*/, (amsClient === null || amsClient === void 0 ? void 0 : amsClient.getViewStatus(fileMetadata))];
1644
1856
  case 3:
1645
- viewResponse = _d.sent();
1857
+ response = _b.sent();
1858
+ view_location = response.view_location;
1859
+ return [4 /*yield*/, (amsClient === null || amsClient === void 0 ? void 0 : amsClient.getView(fileMetadata, view_location))];
1860
+ case 4:
1861
+ viewResponse = _b.sent();
1646
1862
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
1647
1863
  RequestId: this.requestId,
1648
1864
  ChatId: this.chatToken.chatId
1649
1865
  });
1650
1866
  return [2 /*return*/, viewResponse];
1651
- case 4:
1652
- _c = _d.sent();
1867
+ case 5:
1868
+ _a = _b.sent();
1653
1869
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
1654
1870
  RequestId: this.requestId,
1655
1871
  ChatId: this.chatToken.chatId
1656
1872
  });
1657
1873
  throw new Error('DownloadFileAttachmentFailed');
1658
- case 5: return [3 /*break*/, 9];
1659
- case 6:
1660
- _d.trys.push([6, 8, , 9]);
1661
- return [4 /*yield*/, this.conversation.downloadFile(fileMetadata)];
1874
+ case 6: return [3 /*break*/, 10];
1662
1875
  case 7:
1663
- downloadedFile = _d.sent();
1876
+ _b.trys.push([7, 9, , 10]);
1877
+ return [4 /*yield*/, this.conversation.downloadFile(fileMetadata)];
1878
+ case 8:
1879
+ downloadedFile = _b.sent();
1664
1880
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
1665
1881
  RequestId: this.requestId,
1666
1882
  ChatId: this.chatToken.chatId
1667
1883
  });
1668
1884
  return [2 /*return*/, downloadedFile];
1669
- case 8:
1670
- error_17 = _d.sent();
1671
- console.error("OmnichannelChatSDK/downloadFileAttachment/error: " + error_17);
1885
+ case 9:
1886
+ error_18 = _b.sent();
1887
+ console.error("OmnichannelChatSDK/downloadFileAttachment/error: " + error_18);
1672
1888
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
1673
1889
  RequestId: this.requestId,
1674
1890
  ChatId: this.chatToken.chatId
1675
1891
  });
1676
1892
  throw new Error('DownloadFileAttachmentFailed');
1677
- case 9: return [2 /*return*/];
1893
+ case 10: return [2 /*return*/];
1678
1894
  }
1679
1895
  });
1680
1896
  });
@@ -1683,7 +1899,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1683
1899
  var _a;
1684
1900
  if (optionalParams === void 0) { optionalParams = {}; }
1685
1901
  return __awaiter(this, void 0, void 0, function () {
1686
- var emailTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, emailRequestBody, emailResponse, error_18;
1902
+ var emailTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, emailRequestBody, emailResponse, error_19;
1687
1903
  return __generator(this, function (_b) {
1688
1904
  switch (_b.label) {
1689
1905
  case 0:
@@ -1729,8 +1945,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
1729
1945
  });
1730
1946
  return [2 /*return*/, emailResponse];
1731
1947
  case 3:
1732
- error_18 = _b.sent();
1733
- console.error("OmnichannelChatSDK/emailLiveChatTranscript/error: " + error_18);
1948
+ error_19 = _b.sent();
1949
+ console.error("OmnichannelChatSDK/emailLiveChatTranscript/error: " + error_19);
1734
1950
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.EmailLiveChatTranscript, {
1735
1951
  RequestId: requestId,
1736
1952
  ChatId: chatId
@@ -1745,7 +1961,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1745
1961
  var _a;
1746
1962
  if (optionalParams === void 0) { optionalParams = {}; }
1747
1963
  return __awaiter(this, void 0, void 0, function () {
1748
- var getChatTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, transcriptResponse, error_19, telemetryData;
1964
+ var getChatTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, transcriptResponse, error_20, telemetryData;
1749
1965
  return __generator(this, function (_b) {
1750
1966
  switch (_b.label) {
1751
1967
  case 0:
@@ -1785,12 +2001,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
1785
2001
  });
1786
2002
  return [2 /*return*/, transcriptResponse];
1787
2003
  case 3:
1788
- error_19 = _b.sent();
2004
+ error_20 = _b.sent();
1789
2005
  telemetryData = {
1790
2006
  RequestId: requestId,
1791
2007
  ChatId: chatId
1792
2008
  };
1793
- exceptionThrowers_1.default.throwLiveChatTranscriptRetrievalFailure(error_19, this.scenarioMarker, TelemetryEvent_1.default.GetLiveChatTranscript, telemetryData);
2009
+ exceptionThrowers_1.default.throwLiveChatTranscriptRetrievalFailure(error_20, this.scenarioMarker, TelemetryEvent_1.default.GetLiveChatTranscript, telemetryData);
1794
2010
  return [3 /*break*/, 4];
1795
2011
  case 4: return [2 /*return*/];
1796
2012
  }
@@ -1863,7 +2079,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1863
2079
  return __generator(this, function (_b) {
1864
2080
  switch (_b.label) {
1865
2081
  case 0:
1866
- LiveChatWidgetLibCDNUrl = result[1] + "/livechatwidget/WebChatControl/lib/CallingBundle.js";
2082
+ LiveChatWidgetLibCDNUrl = result[1] + "/livechatwidget/v2scripts/callingsdk/" + settings_1.callingBundleVersion + "/CallingBundle.js";
1867
2083
  (_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
1868
2084
  VoiceVideoCalling: LiveChatWidgetLibCDNUrl
1869
2085
  });
@@ -2043,7 +2259,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2043
2259
  OmnichannelChatSDK.prototype.getAgentAvailability = function (optionalParams) {
2044
2260
  if (optionalParams === void 0) { optionalParams = {}; }
2045
2261
  return __awaiter(this, void 0, void 0, function () {
2046
- var reportError, getAgentAvailabilityOptionalParams, response, e_6;
2262
+ var reportError, getAgentAvailabilityOptionalParams, response, e_8;
2047
2263
  var _this = this;
2048
2264
  return __generator(this, function (_a) {
2049
2265
  switch (_a.label) {
@@ -2079,9 +2295,9 @@ var OmnichannelChatSDK = /** @class */ (function () {
2079
2295
  response = _a.sent();
2080
2296
  return [2 /*return*/, response];
2081
2297
  case 3:
2082
- e_6 = _a.sent();
2298
+ e_8 = _a.sent();
2083
2299
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2084
- reportError("GetAgentAvailabilityFailed", e_6.message);
2300
+ reportError("GetAgentAvailabilityFailed", e_8.message);
2085
2301
  return [3 /*break*/, 4];
2086
2302
  case 4: return [2 /*return*/];
2087
2303
  }
@@ -2184,7 +2400,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2184
2400
  OmnichannelChatSDK.prototype.getChatConfig = function (optionalParams) {
2185
2401
  if (optionalParams === void 0) { optionalParams = {}; }
2186
2402
  return __awaiter(this, void 0, void 0, function () {
2187
- var sendCacheHeaders, bypassCache, liveChatConfig, error_20, _a, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled;
2403
+ var sendCacheHeaders, bypassCache, liveChatConfig, error_21, _a, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled;
2188
2404
  return __generator(this, function (_b) {
2189
2405
  switch (_b.label) {
2190
2406
  case 0:
@@ -2198,8 +2414,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
2198
2414
  liveChatConfig = _b.sent();
2199
2415
  return [3 /*break*/, 8];
2200
2416
  case 3:
2201
- error_20 = _b.sent();
2202
- if (!internalUtils_1.isCoreServicesOrgUrlDNSError(error_20, this.coreServicesOrgUrl, this.dynamicsLocationCode)) return [3 /*break*/, 6];
2417
+ error_21 = _b.sent();
2418
+ if (!internalUtils_1.isCoreServicesOrgUrlDNSError(error_21, this.coreServicesOrgUrl, this.dynamicsLocationCode)) return [3 /*break*/, 6];
2203
2419
  this.omnichannelConfig.orgUrl = this.unqServicesOrgUrl;
2204
2420
  _a = this;
2205
2421
  return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, createOcSDKConfiguration_1.default(false), this.ocSdkLogger)];
@@ -2209,7 +2425,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2209
2425
  case 5:
2210
2426
  liveChatConfig = _b.sent(); // Bubble up error by default to throw ChatConfigRetrievalFailure
2211
2427
  return [3 /*break*/, 7];
2212
- case 6: throw error_20; // Bubble up error by default to throw ChatConfigRetrievalFailure
2428
+ case 6: throw error_21; // Bubble up error by default to throw ChatConfigRetrievalFailure
2213
2429
  case 7: return [3 /*break*/, 8];
2214
2430
  case 8:
2215
2431
  dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
@@ -2262,7 +2478,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2262
2478
  };
2263
2479
  OmnichannelChatSDK.prototype.updateChatToken = function (newToken, newRegionGTMS) {
2264
2480
  return __awaiter(this, void 0, void 0, function () {
2265
- var sessionInfo, error_21, exceptionDetails;
2481
+ var sessionInfo, error_22, exceptionDetails;
2266
2482
  return __generator(this, function (_a) {
2267
2483
  switch (_a.label) {
2268
2484
  case 0:
@@ -2290,7 +2506,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2290
2506
  });
2291
2507
  return [3 /*break*/, 5];
2292
2508
  case 4:
2293
- error_21 = _a.sent();
2509
+ error_22 = _a.sent();
2294
2510
  exceptionDetails = {
2295
2511
  response: "UpdateChatTokenFailed"
2296
2512
  };
@@ -2308,7 +2524,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2308
2524
  OmnichannelChatSDK.prototype.setAuthTokenProvider = function (provider, optionalParams) {
2309
2525
  if (optionalParams === void 0) { optionalParams = {}; }
2310
2526
  return __awaiter(this, void 0, void 0, function () {
2311
- var token, exceptionDetails, error_22, exceptionDetails, exceptionDetails;
2527
+ var token, exceptionDetails, error_23, exceptionDetails, exceptionDetails;
2312
2528
  return __generator(this, function (_a) {
2313
2529
  switch (_a.label) {
2314
2530
  case 0:
@@ -2339,12 +2555,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
2339
2555
  }
2340
2556
  return [3 /*break*/, 4];
2341
2557
  case 3:
2342
- error_22 = _a.sent();
2558
+ error_23 = _a.sent();
2343
2559
  exceptionDetails = {
2344
2560
  response: ChatSDKError_1.ChatSDKErrorName.GetAuthTokenFailed
2345
2561
  };
2346
- if (error_22.message == ChatSDKError_1.ChatSDKErrorName.UndefinedAuthToken) {
2347
- exceptionDetails.response = error_22.message;
2562
+ if (error_23.message == ChatSDKError_1.ChatSDKErrorName.UndefinedAuthToken) {
2563
+ exceptionDetails.response = error_23.message;
2348
2564
  }
2349
2565
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
2350
2566
  ExceptionDetails: JSON.stringify(exceptionDetails)