@microsoft/omnichannel-chat-sdk 1.1.1-main.93f1eed → 1.1.1-main.b7a985d

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.
@@ -10,10 +10,12 @@ import ChatTranscriptBody from "./core/ChatTranscriptBody";
10
10
  import FileMetadata from "@microsoft/omnichannel-amsclient/lib/FileMetadata";
11
11
  import FramedClient from "@microsoft/omnichannel-amsclient/lib/FramedClient";
12
12
  import FramedlessClient from "@microsoft/omnichannel-amsclient/lib/FramedlessClient";
13
+ import GetLiveChatConfigOptionalParams from "./core/GetLiveChatConfigOptionalParams";
13
14
  import IChatToken from "./external/IC3Adapter/IChatToken";
14
15
  import IFileInfo from "@microsoft/omnichannel-ic3core/lib/interfaces/IFileInfo";
15
16
  import IFileMetadata from "@microsoft/omnichannel-ic3core/lib/model/IFileMetadata";
16
17
  import IMessage from "@microsoft/omnichannel-ic3core/lib/model/IMessage";
18
+ import InitializeOptionalParams from "./core/InitializeOptionalParams";
17
19
  import IRawMessage from "@microsoft/omnichannel-ic3core/lib/model/IRawMessage";
18
20
  import IRawThread from "@microsoft/omnichannel-ic3core/lib/interfaces/IRawThread";
19
21
  import LiveChatContext from "./core/LiveChatContext";
@@ -58,7 +60,7 @@ declare class OmnichannelChatSDK {
58
60
  private refreshTokenTimer;
59
61
  constructor(omnichannelConfig: OmnichannelConfig, chatSDKConfig?: ChatSDKConfig);
60
62
  setDebug(flag: boolean): void;
61
- initialize(): Promise<ChatConfig>;
63
+ initialize(optionalParams?: InitializeOptionalParams): Promise<ChatConfig>;
62
64
  getChatReconnectContext(optionalParams?: ChatReconnectOptionalParams): Promise<ChatReconnectContext>;
63
65
  startChat(optionalParams?: StartChatOptionalParams): Promise<void>;
64
66
  endChat(): Promise<void>;
@@ -69,7 +71,7 @@ declare class OmnichannelChatSDK {
69
71
  * @param parse Whether to parse PreChatSurvey to JSON or not.
70
72
  */
71
73
  getPreChatSurvey(parse?: boolean): Promise<any>;
72
- getLiveChatConfig(cached?: boolean): Promise<ChatConfig>;
74
+ getLiveChatConfig(optionalParams?: GetLiveChatConfigOptionalParams): Promise<ChatConfig>;
73
75
  getChatToken(cached?: boolean): Promise<IChatToken>;
74
76
  getCallingToken(): Promise<string>;
75
77
  getMessages(): Promise<IMessage[] | OmnichannelMessage[] | undefined>;
@@ -169,9 +169,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
169
169
  (_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setDebug(flag);
170
170
  (_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setDebug(flag);
171
171
  };
172
- OmnichannelChatSDK.prototype.initialize = function () {
172
+ OmnichannelChatSDK.prototype.initialize = function (optionalParams) {
173
+ if (optionalParams === void 0) { optionalParams = {}; }
173
174
  return __awaiter(this, void 0, void 0, function () {
174
- var _a, _b, _c, _d;
175
+ var _a, getLiveChatConfigOptionalParams, _b, _c, _d;
175
176
  return __generator(this, function (_e) {
176
177
  switch (_e.label) {
177
178
  case 0:
@@ -188,7 +189,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
188
189
  return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, {}, this.ocSdkLogger)];
189
190
  case 2:
190
191
  _a.OCClient = _e.sent();
191
- return [4 /*yield*/, this.getChatConfig()];
192
+ getLiveChatConfigOptionalParams = optionalParams.getLiveChatConfigOptionalParams;
193
+ return [4 /*yield*/, this.getChatConfig(getLiveChatConfigOptionalParams || {})];
192
194
  case 3:
193
195
  _e.sent();
194
196
  if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 5];
@@ -309,10 +311,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
309
311
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
310
312
  if (optionalParams === void 0) { optionalParams = {}; }
311
313
  return __awaiter(this, void 0, void 0, function () {
312
- var shouldReinitIC3Client, _t, reconnectableChatsParams, reconnectableChatsResponse, _u, exceptionDetails, conversationDetails, exceptionDetails, exceptionDetails, sessionInitOptionalParams, error_3, exceptionDetails, chatAdapterConfig, error_4, exceptionDetails, _v, error_5, exceptionDetails, error_6, exceptionDetails, error_7, exceptionDetails, _w, error_8, exceptionDetails;
314
+ var shouldReinitIC3Client, _t, reconnectableChatsParams, reconnectableChatsResponse, _u, exceptionDetails, conversationDetails, exceptionDetails, exceptionDetails, _v, exceptionDetails, sessionInitOptionalParams, exceptionDetails, error_3, exceptionDetails, chatAdapterConfig, error_4, exceptionDetails, _w, error_5, exceptionDetails, error_6, exceptionDetails, error_7, exceptionDetails, _x, error_8, exceptionDetails;
313
315
  var _this = this;
314
- return __generator(this, function (_x) {
315
- switch (_x.label) {
316
+ return __generator(this, function (_y) {
317
+ switch (_y.label) {
316
318
  case 0:
317
319
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
318
320
  RequestId: this.requestId
@@ -322,39 +324,39 @@ var OmnichannelChatSDK = /** @class */ (function () {
322
324
  _t = this;
323
325
  return [4 /*yield*/, this.getIC3Client()];
324
326
  case 1:
325
- _t.IC3Client = _x.sent();
326
- _x.label = 2;
327
+ _t.IC3Client = _y.sent();
328
+ _y.label = 2;
327
329
  case 2:
328
330
  if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
329
331
  this.reconnectId = optionalParams.reconnectId;
330
332
  }
331
333
  if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 6];
332
- _x.label = 3;
334
+ _y.label = 3;
333
335
  case 3:
334
- _x.trys.push([3, 5, , 6]);
336
+ _y.trys.push([3, 5, , 6]);
335
337
  reconnectableChatsParams = {
336
338
  authenticatedUserToken: this.authenticatedUserToken
337
339
  };
338
340
  return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
339
341
  case 4:
340
- reconnectableChatsResponse = _x.sent();
342
+ reconnectableChatsResponse = _y.sent();
341
343
  if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
342
344
  this.reconnectId = reconnectableChatsResponse.reconnectid;
343
345
  }
344
346
  return [3 /*break*/, 6];
345
347
  case 5:
346
- _u = _x.sent();
348
+ _u = _y.sent();
347
349
  exceptionDetails = {
348
350
  response: "OCClientGetReconnectableChatsFailed"
349
351
  };
350
352
  throw Error(exceptionDetails.response);
351
353
  case 6:
352
- if (!(optionalParams.liveChatContext && !this.reconnectId)) return [3 /*break*/, 8];
354
+ if (!(optionalParams.liveChatContext && Object.keys(optionalParams.liveChatContext).length > 0 && !this.reconnectId)) return [3 /*break*/, 8];
353
355
  this.chatToken = optionalParams.liveChatContext.chatToken || {};
354
356
  this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
355
357
  return [4 /*yield*/, this.getConversationDetails()];
356
358
  case 7:
357
- conversationDetails = _x.sent();
359
+ conversationDetails = _y.sent();
358
360
  if (Object.keys(conversationDetails).length === 0) {
359
361
  exceptionDetails = {
360
362
  response: "InvalidConversation"
@@ -379,14 +381,47 @@ var OmnichannelChatSDK = /** @class */ (function () {
379
381
  console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
380
382
  throw Error(exceptionDetails.response);
381
383
  }
382
- _x.label = 8;
384
+ _y.label = 8;
383
385
  case 8:
384
- if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 10];
385
- return [4 /*yield*/, this.getChatToken(false)];
386
+ if (!this.authSettings) return [3 /*break*/, 14];
387
+ if (!!this.authenticatedUserToken) return [3 /*break*/, 10];
388
+ return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
386
389
  case 9:
387
- _x.sent();
388
- _x.label = 10;
390
+ _y.sent();
391
+ _y.label = 10;
389
392
  case 10:
393
+ if (!(optionalParams.liveChatContext && Object.keys(optionalParams.liveChatContext).length > 0)) return [3 /*break*/, 14];
394
+ this.chatToken = optionalParams.liveChatContext.chatToken || {};
395
+ this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
396
+ _y.label = 11;
397
+ case 11:
398
+ _y.trys.push([11, 13, , 14]);
399
+ return [4 /*yield*/, this.OCClient.validateAuthChatRecord(this.requestId, {
400
+ authenticatedUserToken: this.authenticatedUserToken,
401
+ chatId: this.chatToken.chatId
402
+ })];
403
+ case 12:
404
+ _y.sent();
405
+ return [3 /*break*/, 14];
406
+ case 13:
407
+ _v = _y.sent();
408
+ exceptionDetails = {
409
+ response: "OCClientValidateAuthChatRecordFailed",
410
+ message: "InvalidAuthChatRecord"
411
+ };
412
+ this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
413
+ RequestId: this.requestId,
414
+ ChatId: this.chatToken.chatId,
415
+ ExceptionDetails: JSON.stringify(exceptionDetails)
416
+ });
417
+ throw Error(exceptionDetails.response);
418
+ case 14:
419
+ if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 16];
420
+ return [4 /*yield*/, this.getChatToken(false)];
421
+ case 15:
422
+ _y.sent();
423
+ _y.label = 16;
424
+ case 16:
390
425
  (_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
391
426
  (_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
392
427
  (_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
@@ -420,6 +455,22 @@ var OmnichannelChatSDK = /** @class */ (function () {
420
455
  if (optionalParams.preChatResponse) {
421
456
  sessionInitOptionalParams.initContext.preChatResponse = optionalParams.preChatResponse;
422
457
  }
458
+ if (optionalParams.sendDefaultInitContext) {
459
+ if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
460
+ exceptionDetails = {
461
+ response: "UnsupportedPlatform",
462
+ message: "sendDefaultInitContext is only supported on browser"
463
+ };
464
+ console.error(exceptionDetails.message);
465
+ this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
466
+ RequestId: this.requestId,
467
+ ChatId: this.chatToken.chatId,
468
+ ExceptionDetails: JSON.stringify(exceptionDetails)
469
+ });
470
+ throw new Error(exceptionDetails.response);
471
+ }
472
+ sessionInitOptionalParams.getContext = true;
473
+ }
423
474
  // Override initContext completely
424
475
  if (optionalParams.initContext) {
425
476
  sessionInitOptionalParams.initContext = optionalParams.initContext;
@@ -427,16 +478,20 @@ var OmnichannelChatSDK = /** @class */ (function () {
427
478
  if (this.authenticatedUserToken) {
428
479
  sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
429
480
  }
430
- if (!!optionalParams.liveChatContext) return [3 /*break*/, 14];
431
- _x.label = 11;
432
- case 11:
433
- _x.trys.push([11, 13, , 14]);
481
+ if (this.chatToken.chatId) {
482
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
483
+ sessionInitOptionalParams.initContext.chatId = this.chatToken.chatId;
484
+ }
485
+ if (!!optionalParams.liveChatContext) return [3 /*break*/, 20];
486
+ _y.label = 17;
487
+ case 17:
488
+ _y.trys.push([17, 19, , 20]);
434
489
  return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
435
- case 12:
436
- _x.sent();
437
- return [3 /*break*/, 14];
438
- case 13:
439
- error_3 = _x.sent();
490
+ case 18:
491
+ _y.sent();
492
+ return [3 /*break*/, 20];
493
+ case 19:
494
+ error_3 = _y.sent();
440
495
  exceptionDetails = {
441
496
  response: "OCClientSessionInitFailed"
442
497
  };
@@ -452,27 +507,27 @@ var OmnichannelChatSDK = /** @class */ (function () {
452
507
  ExceptionDetails: JSON.stringify(exceptionDetails)
453
508
  });
454
509
  throw new Error(exceptionDetails.response);
455
- case 14:
456
- if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 25];
510
+ case 20:
511
+ if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 31];
457
512
  chatAdapterConfig = {
458
513
  token: this.chatToken.token,
459
514
  id: this.chatToken.visitorId || 'teamsvisitor',
460
515
  threadId: this.chatToken.chatId,
461
516
  environmentUrl: this.chatToken.acsEndpoint,
462
- pollingInterval: 1000
517
+ pollingInterval: 30000
463
518
  };
464
- _x.label = 15;
465
- case 15:
466
- _x.trys.push([15, 17, , 18]);
519
+ _y.label = 21;
520
+ case 21:
521
+ _y.trys.push([21, 23, , 24]);
467
522
  return [4 /*yield*/, ((_o = this.ACSClient) === null || _o === void 0 ? void 0 : _o.initialize({
468
523
  token: chatAdapterConfig.token,
469
524
  environmentUrl: chatAdapterConfig.environmentUrl
470
525
  }))];
471
- case 16:
472
- _x.sent();
473
- return [3 /*break*/, 18];
474
- case 17:
475
- error_4 = _x.sent();
526
+ case 22:
527
+ _y.sent();
528
+ return [3 /*break*/, 24];
529
+ case 23:
530
+ error_4 = _y.sent();
476
531
  exceptionDetails = {
477
532
  response: "ACSClientInitializeFailed"
478
533
  };
@@ -483,23 +538,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
483
538
  });
484
539
  console.error("OmnichannelChatSDK/startChat/initialize/error " + error_4);
485
540
  return [2 /*return*/, error_4];
486
- case 18:
487
- _x.trys.push([18, 20, , 21]);
488
- _v = this;
541
+ case 24:
542
+ _y.trys.push([24, 26, , 27]);
543
+ _w = this;
489
544
  return [4 /*yield*/, ((_p = this.ACSClient) === null || _p === void 0 ? void 0 : _p.joinConversation({
490
545
  id: chatAdapterConfig.id,
491
546
  threadId: chatAdapterConfig.threadId,
492
547
  pollingInterval: chatAdapterConfig.pollingInterval
493
548
  }))];
494
- case 19:
495
- _v.conversation = (_x.sent());
549
+ case 25:
550
+ _w.conversation = (_y.sent());
496
551
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
497
552
  RequestId: this.requestId,
498
553
  ChatId: this.chatToken.chatId
499
554
  });
500
- return [3 /*break*/, 21];
501
- case 20:
502
- error_5 = _x.sent();
555
+ return [3 /*break*/, 27];
556
+ case 26:
557
+ error_5 = _y.sent();
503
558
  exceptionDetails = {
504
559
  response: "ACSClientJoinConversationFailed"
505
560
  };
@@ -510,16 +565,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
510
565
  });
511
566
  console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_5);
512
567
  throw Error(exceptionDetails.response);
513
- case 21:
514
- _x.trys.push([21, 23, , 24]);
568
+ case 27:
569
+ _y.trys.push([27, 29, , 30]);
515
570
  return [4 /*yield*/, ((_q = this.AMSClient) === null || _q === void 0 ? void 0 : _q.initialize({
516
571
  chatToken: this.chatToken
517
572
  }))];
518
- case 22:
519
- _x.sent();
520
- return [3 /*break*/, 24];
521
- case 23:
522
- error_6 = _x.sent();
573
+ case 28:
574
+ _y.sent();
575
+ return [3 /*break*/, 30];
576
+ case 29:
577
+ error_6 = _y.sent();
523
578
  exceptionDetails = {
524
579
  response: "AMSClientInitializeFailed"
525
580
  };
@@ -529,19 +584,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
529
584
  ExceptionDetails: JSON.stringify(exceptionDetails)
530
585
  });
531
586
  throw Error(exceptionDetails.response);
532
- case 24: return [3 /*break*/, 31];
533
- case 25:
534
- _x.trys.push([25, 27, , 28]);
587
+ case 30: return [3 /*break*/, 37];
588
+ case 31:
589
+ _y.trys.push([31, 33, , 34]);
535
590
  return [4 /*yield*/, this.IC3Client.initialize({
536
591
  token: this.chatToken.token,
537
592
  regionGtms: this.chatToken.regionGTMS,
538
593
  visitor: true
539
594
  })];
540
- case 26:
541
- _x.sent();
542
- return [3 /*break*/, 28];
543
- case 27:
544
- error_7 = _x.sent();
595
+ case 32:
596
+ _y.sent();
597
+ return [3 /*break*/, 34];
598
+ case 33:
599
+ error_7 = _y.sent();
545
600
  exceptionDetails = {
546
601
  response: "IC3ClientInitializeFailed"
547
602
  };
@@ -552,19 +607,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
552
607
  });
553
608
  console.error("OmnichannelChatSDK/startChat/initialize/error " + error_7);
554
609
  return [2 /*return*/, error_7];
555
- case 28:
556
- _x.trys.push([28, 30, , 31]);
557
- _w = this;
610
+ case 34:
611
+ _y.trys.push([34, 36, , 37]);
612
+ _x = this;
558
613
  return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
559
- case 29:
560
- _w.conversation = _x.sent();
614
+ case 35:
615
+ _x.conversation = _y.sent();
561
616
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
562
617
  RequestId: this.requestId,
563
618
  ChatId: this.chatToken.chatId
564
619
  });
565
- return [3 /*break*/, 31];
566
- case 30:
567
- error_8 = _x.sent();
620
+ return [3 /*break*/, 37];
621
+ case 36:
622
+ error_8 = _y.sent();
568
623
  exceptionDetails = {
569
624
  response: "IC3ClientJoinConversationFailed"
570
625
  };
@@ -575,7 +630,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
575
630
  });
576
631
  console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_8);
577
632
  return [2 /*return*/, error_8];
578
- case 31:
633
+ case 37:
579
634
  if (this.isPersistentChat && !((_r = this.chatSDKConfig.persistentChat) === null || _r === void 0 ? void 0 : _r.disable)) {
580
635
  this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
581
636
  return __generator(this, function (_a) {
@@ -782,14 +837,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
782
837
  });
783
838
  });
784
839
  };
785
- OmnichannelChatSDK.prototype.getLiveChatConfig = function (cached) {
786
- if (cached === void 0) { cached = true; }
840
+ OmnichannelChatSDK.prototype.getLiveChatConfig = function (optionalParams) {
787
841
  return __awaiter(this, void 0, void 0, function () {
788
842
  return __generator(this, function (_a) {
789
- if (cached) {
843
+ if (!optionalParams || optionalParams.useRuntimeCache === true) {
790
844
  return [2 /*return*/, this.liveChatConfig];
791
845
  }
792
- return [2 /*return*/, this.getChatConfig()];
846
+ return [2 /*return*/, this.getChatConfig({ sendCacheHeaders: (optionalParams === null || optionalParams === void 0 ? void 0 : optionalParams.sendCacheHeaders) || false })];
793
847
  });
794
848
  });
795
849
  };
@@ -1333,7 +1387,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
1333
1387
  case 2:
1334
1388
  uploadDocumentResponse = _e.sent();
1335
1389
  fileIdsProperty = {
1336
- amsReferences: JSON.stringify([documentId])
1390
+ amsReferences: JSON.stringify([documentId]),
1391
+ amsreferences: JSON.stringify([documentId])
1337
1392
  };
1338
1393
  fileMetaProperty = {
1339
1394
  amsMetadata: JSON.stringify([{
@@ -1589,17 +1644,17 @@ var OmnichannelChatSDK = /** @class */ (function () {
1589
1644
  ACSAdapter: acsAdapterCDNUrl
1590
1645
  });
1591
1646
  return [4 /*yield*/, WebUtils_1.loadScript(acsAdapterCDNUrl, function () {
1647
+ var _a;
1592
1648
  /* istanbul ignore next */
1593
1649
  _this.debug && console.debug('ACSAdapter loaded!');
1594
1650
  try {
1595
1651
  var ChatAdapter = window.ChatAdapter; // eslint-disable-line @typescript-eslint/no-explicit-any
1596
1652
  var fileManager = new AMSFileManager_1.default(_this.AMSClient, _this.acsAdapterLogger);
1597
- var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager, ACSParticipantDisplayName_1.default.Customer, undefined, // chatClient
1598
- _this.acsAdapterLogger, // logger
1653
+ var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager, 30000, ACSParticipantDisplayName_1.default.Customer, (_a = _this.ACSClient) === null || _a === void 0 ? void 0 : _a.getChatClient(), _this.acsAdapterLogger, // logger
1599
1654
  featuresOption);
1600
1655
  resolve(adapter);
1601
1656
  }
1602
- catch (_a) {
1657
+ catch (_b) {
1603
1658
  throw new Error('Failed to load ACSAdapter');
1604
1659
  }
1605
1660
  }, function () {
@@ -1924,15 +1979,20 @@ var OmnichannelChatSDK = /** @class */ (function () {
1924
1979
  });
1925
1980
  });
1926
1981
  };
1927
- OmnichannelChatSDK.prototype.getChatConfig = function () {
1982
+ OmnichannelChatSDK.prototype.getChatConfig = function (optionalParams) {
1983
+ if (optionalParams === void 0) { optionalParams = {}; }
1928
1984
  return __awaiter(this, void 0, void 0, function () {
1929
- var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled, error_18;
1985
+ var sendCacheHeaders, bypassCache, liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled, error_18;
1930
1986
  return __generator(this, function (_a) {
1931
1987
  switch (_a.label) {
1932
1988
  case 0:
1933
- _a.trys.push([0, 4, , 5]);
1934
- return [4 /*yield*/, this.OCClient.getChatConfig()];
1989
+ sendCacheHeaders = optionalParams.sendCacheHeaders;
1990
+ _a.label = 1;
1935
1991
  case 1:
1992
+ _a.trys.push([1, 5, , 6]);
1993
+ bypassCache = sendCacheHeaders === true;
1994
+ return [4 /*yield*/, this.OCClient.getChatConfig(this.requestId, bypassCache)];
1995
+ case 2:
1936
1996
  liveChatConfig = _a.sent();
1937
1997
  dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
1938
1998
  msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
@@ -1959,12 +2019,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
1959
2019
  if (isPreChatEnabled && preChatSurvey && preChatSurvey.trim().length > 0) {
1960
2020
  this.preChatSurvey = preChatSurvey;
1961
2021
  }
1962
- if (!this.authSettings) return [3 /*break*/, 3];
2022
+ if (!this.authSettings) return [3 /*break*/, 4];
1963
2023
  return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
1964
- case 2:
1965
- _a.sent();
1966
- _a.label = 3;
1967
2024
  case 3:
2025
+ _a.sent();
2026
+ _a.label = 4;
2027
+ case 4:
1968
2028
  if (this.preChatSurvey) {
1969
2029
  /* istanbul ignore next */
1970
2030
  this.debug && console.log('Prechat Survey!');
@@ -1972,11 +2032,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
1972
2032
  this.callingOption = msdyn_callingoptions;
1973
2033
  this.liveChatConfig = liveChatConfig;
1974
2034
  return [2 /*return*/, this.liveChatConfig];
1975
- case 4:
2035
+ case 5:
1976
2036
  error_18 = _a.sent();
1977
2037
  console.error("OmnichannelChatSDK/getChatConfig/error " + error_18);
1978
2038
  return [2 /*return*/, error_18];
1979
- case 5: return [2 /*return*/];
2039
+ case 6: return [2 /*return*/];
1980
2040
  }
1981
2041
  });
1982
2042
  });
@@ -2027,21 +2087,24 @@ var OmnichannelChatSDK = /** @class */ (function () {
2027
2087
  });
2028
2088
  _a.label = 1;
2029
2089
  case 1:
2030
- _a.trys.push([1, 3, , 4]);
2090
+ _a.trys.push([1, 4, , 5]);
2031
2091
  sessionInfo = {
2032
2092
  token: newToken,
2033
2093
  regionGtms: newRegionGTMS,
2034
2094
  visitor: true
2035
2095
  };
2096
+ if (!(this.liveChatVersion === LiveChatVersion_1.default.V1)) return [3 /*break*/, 3];
2036
2097
  return [4 /*yield*/, this.IC3Client.initialize(sessionInfo)];
2037
2098
  case 2:
2038
2099
  _a.sent();
2100
+ _a.label = 3;
2101
+ case 3:
2039
2102
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.UpdateChatToken, {
2040
2103
  RequestId: this.requestId,
2041
2104
  ChatId: this.chatToken.chatId
2042
2105
  });
2043
- return [3 /*break*/, 4];
2044
- case 3:
2106
+ return [3 /*break*/, 5];
2107
+ case 4:
2045
2108
  error_19 = _a.sent();
2046
2109
  exceptionDetails = {
2047
2110
  response: "UpdateChatTokenFailed"
@@ -2052,8 +2115,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
2052
2115
  ExceptionDetails: JSON.stringify(exceptionDetails)
2053
2116
  });
2054
2117
  console.error("OmnichannelChatSDK/updateChatToken/error " + error_19);
2055
- return [3 /*break*/, 4];
2056
- case 4: return [2 /*return*/];
2118
+ return [3 /*break*/, 5];
2119
+ case 5: return [2 /*return*/];
2057
2120
  }
2058
2121
  });
2059
2122
  });