@microsoft/omnichannel-chat-sdk 1.10.15-main.4f0c880 → 1.10.15-main.c99012c

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.
@@ -686,12 +686,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
686
686
  };
687
687
  OmnichannelChatSDK.prototype.startChat = function () {
688
688
  return __awaiter(this, arguments, void 0, function (optionalParams) {
689
- var shouldReinitIC3Client, _a, reconnectableChatsParams, reconnectableChatsResponse, e_6, telemetryData, conversationDetails, telemetryData, telemetryData, e_7, telemetryData, sessionInitOptionalParams, location_2, sessionInitPromise, messagingClientPromise, attachmentClientPromise;
689
+ var shouldReinitIC3Client, _a, reconnectableChatsParams, reconnectableChatsResponse, e_6, telemetryData, conversationDetails, telemetryData, telemetryData, e_7, telemetryData, sessionInitOptionalParams, location_2, sessionInitPromise, createConversationPromise, messagingClientPromise, attachmentClientPromise;
690
690
  var _this = this;
691
- var _b, _c, _d, _e, _f, _g, _h, _j;
691
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
692
692
  if (optionalParams === void 0) { optionalParams = {}; }
693
- return __generator(this, function (_k) {
694
- switch (_k.label) {
693
+ return __generator(this, function (_o) {
694
+ switch (_o.label) {
695
695
  case 0:
696
696
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
697
697
  RequestId: this.requestId
@@ -704,29 +704,29 @@ var OmnichannelChatSDK = /** @class */ (function () {
704
704
  _a = this;
705
705
  return [4 /*yield*/, this.getIC3Client()];
706
706
  case 1:
707
- _a.IC3Client = _k.sent();
708
- _k.label = 2;
707
+ _a.IC3Client = _o.sent();
708
+ _o.label = 2;
709
709
  case 2:
710
710
  if (this.isChatReconnect && !((_b = this.chatSDKConfig.chatReconnect) === null || _b === void 0 ? void 0 : _b.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
711
711
  this.reconnectId = optionalParams.reconnectId;
712
712
  }
713
713
  if (!(this.isPersistentChat && !((_c = this.chatSDKConfig.persistentChat) === null || _c === void 0 ? void 0 : _c.disable))) return [3 /*break*/, 6];
714
- _k.label = 3;
714
+ _o.label = 3;
715
715
  case 3:
716
- _k.trys.push([3, 5, , 6]);
716
+ _o.trys.push([3, 5, , 6]);
717
717
  reconnectableChatsParams = {
718
718
  authenticatedUserToken: this.authenticatedUserToken,
719
719
  requestId: this.requestId
720
720
  };
721
721
  return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
722
722
  case 4:
723
- reconnectableChatsResponse = _k.sent();
723
+ reconnectableChatsResponse = _o.sent();
724
724
  if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
725
725
  this.reconnectId = reconnectableChatsResponse.reconnectid;
726
726
  }
727
727
  return [3 /*break*/, 6];
728
728
  case 5:
729
- e_6 = _k.sent();
729
+ e_6 = _o.sent();
730
730
  telemetryData = {
731
731
  RequestId: this.requestId,
732
732
  ChatId: this.chatToken.chatId,
@@ -740,7 +740,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
740
740
  this.sessionId = optionalParams.liveChatContext.sessionId || null;
741
741
  return [4 /*yield*/, this.getConversationDetails()];
742
742
  case 7:
743
- conversationDetails = _k.sent();
743
+ conversationDetails = _o.sent();
744
744
  if (Object.keys(conversationDetails).length === 0) {
745
745
  telemetryData = {
746
746
  RequestId: this.requestId,
@@ -756,30 +756,30 @@ var OmnichannelChatSDK = /** @class */ (function () {
756
756
  };
757
757
  exceptionThrowers_1.default.throwClosedConversation(this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
758
758
  }
759
- _k.label = 8;
759
+ _o.label = 8;
760
760
  case 8:
761
761
  if (!this.authSettings) return [3 /*break*/, 14];
762
762
  if (!!this.authenticatedUserToken) return [3 /*break*/, 10];
763
763
  return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken, { throwError: true })];
764
764
  case 9:
765
- _k.sent();
766
- _k.label = 10;
765
+ _o.sent();
766
+ _o.label = 10;
767
767
  case 10:
768
768
  if (!(optionalParams.liveChatContext && Object.keys(optionalParams.liveChatContext).length > 0)) return [3 /*break*/, 14];
769
769
  this.chatToken = optionalParams.liveChatContext.chatToken || {};
770
770
  this.requestId = optionalParams.liveChatContext.requestId || (0, ocsdk_1.uuidv4)();
771
- _k.label = 11;
771
+ _o.label = 11;
772
772
  case 11:
773
- _k.trys.push([11, 13, , 14]);
773
+ _o.trys.push([11, 13, , 14]);
774
774
  return [4 /*yield*/, this.OCClient.validateAuthChatRecord(this.requestId, {
775
775
  authenticatedUserToken: this.authenticatedUserToken,
776
776
  chatId: this.chatToken.chatId
777
777
  })];
778
778
  case 12:
779
- _k.sent();
779
+ _o.sent();
780
780
  return [3 /*break*/, 14];
781
781
  case 13:
782
- e_7 = _k.sent();
782
+ e_7 = _o.sent();
783
783
  telemetryData = {
784
784
  RequestId: this.requestId,
785
785
  ChatId: this.chatToken.chatId,
@@ -787,13 +787,15 @@ var OmnichannelChatSDK = /** @class */ (function () {
787
787
  exceptionThrowers_1.default.throwAuthenticatedChatConversationRetrievalFailure(e_7, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
788
788
  return [3 /*break*/, 14];
789
789
  case 14:
790
- if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 16];
790
+ if (!(((_d = this.chatSDKConfig.useCreateConversation) === null || _d === void 0 ? void 0 : _d.disable) && this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 16];
791
791
  return [4 /*yield*/, this.getChatToken(false)];
792
792
  case 15:
793
- _k.sent();
794
- _k.label = 16;
793
+ _o.sent();
794
+ _o.label = 16;
795
795
  case 16:
796
- loggerUtils_1.default.setChatId(this.chatToken.chatId || '', this.ocSdkLogger, this.acsClientLogger, this.acsAdapterLogger, this.callingSdkLogger, this.amsClientLogger, this.ic3ClientLogger);
796
+ if ((_e = this.chatToken) === null || _e === void 0 ? void 0 : _e.chatId) {
797
+ loggerUtils_1.default.setChatId(this.chatToken.chatId || '', this.ocSdkLogger, this.acsClientLogger, this.acsAdapterLogger, this.callingSdkLogger, this.amsClientLogger, this.ic3ClientLogger);
798
+ }
797
799
  sessionInitOptionalParams = {
798
800
  initContext: {}
799
801
  };
@@ -805,19 +807,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
805
807
  if (optionalParams.handle) {
806
808
  sessionInitOptionalParams.initContext.handle = optionalParams.handle;
807
809
  }
808
- if (this.isPersistentChat && !((_d = this.chatSDKConfig.persistentChat) === null || _d === void 0 ? void 0 : _d.disable)) {
810
+ if (this.isPersistentChat && !((_f = this.chatSDKConfig.persistentChat) === null || _f === void 0 ? void 0 : _f.disable)) {
809
811
  sessionInitOptionalParams.reconnectId = this.reconnectId;
810
812
  }
811
- else if (this.isChatReconnect && !((_e = this.chatSDKConfig.chatReconnect) === null || _e === void 0 ? void 0 : _e.disable) && !this.isPersistentChat) {
813
+ else if (this.isChatReconnect && !((_g = this.chatSDKConfig.chatReconnect) === null || _g === void 0 ? void 0 : _g.disable) && !this.isPersistentChat) {
812
814
  sessionInitOptionalParams.reconnectId = this.reconnectId;
813
815
  }
814
- if (!((0, parsers_1.parseLowerCaseString)((_g = (_f = this.liveChatConfig) === null || _f === void 0 ? void 0 : _f.LiveWSAndLiveChatEngJoin) === null || _g === void 0 ? void 0 : _g.msdyn_requestvisitorlocation) === "true")) return [3 /*break*/, 18];
816
+ if (!((0, parsers_1.parseLowerCaseString)((_j = (_h = this.liveChatConfig) === null || _h === void 0 ? void 0 : _h.LiveWSAndLiveChatEngJoin) === null || _j === void 0 ? void 0 : _j.msdyn_requestvisitorlocation) === "true")) return [3 /*break*/, 18];
815
817
  return [4 /*yield*/, (0, location_1.getLocationInfo)(this.scenarioMarker, this.chatToken.chatId, this.requestId)];
816
818
  case 17:
817
- location_2 = _k.sent();
819
+ location_2 = _o.sent();
818
820
  sessionInitOptionalParams.initContext.latitude = location_2.latitude;
819
821
  sessionInitOptionalParams.initContext.longitude = location_2.longitude;
820
- _k.label = 18;
822
+ _o.label = 18;
821
823
  case 18:
822
824
  sessionInitPromise = function () { return __awaiter(_this, void 0, void 0, function () {
823
825
  var error_4, telemetryData;
@@ -849,8 +851,42 @@ var OmnichannelChatSDK = /** @class */ (function () {
849
851
  }
850
852
  });
851
853
  }); };
854
+ createConversationPromise = function () { return __awaiter(_this, void 0, void 0, function () {
855
+ var chatToken, error_5, telemetryData;
856
+ var _a, _b, _c;
857
+ return __generator(this, function (_d) {
858
+ switch (_d.label) {
859
+ case 0:
860
+ if (!!optionalParams.liveChatContext) return [3 /*break*/, 4];
861
+ _d.label = 1;
862
+ case 1:
863
+ _d.trys.push([1, 3, , 4]);
864
+ return [4 /*yield*/, this.OCClient.createConversation(this.requestId, sessionInitOptionalParams)];
865
+ case 2:
866
+ chatToken = _d.sent();
867
+ if (chatToken) {
868
+ this.setChatToken(chatToken);
869
+ loggerUtils_1.default.setChatId(this.chatToken.chatId || '', this.ocSdkLogger, this.acsClientLogger, this.acsAdapterLogger, this.callingSdkLogger, this.amsClientLogger, this.ic3ClientLogger);
870
+ }
871
+ return [3 /*break*/, 4];
872
+ case 3:
873
+ error_5 = _d.sent();
874
+ telemetryData = {
875
+ RequestId: this.requestId,
876
+ ChatId: this.chatToken.chatId,
877
+ };
878
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
879
+ if ((error_5 === null || error_5 === void 0 ? void 0 : error_5.isAxiosError) && ((_c = (_b = (_a = error_5.response) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? void 0 : _b.errorcode) === null || _c === void 0 ? void 0 : _c.toString()) === OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour.toString()) {
880
+ exceptionThrowers_1.default.throwWidgetUseOutsideOperatingHour(error_5, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
881
+ }
882
+ exceptionThrowers_1.default.throwConversationInitializationFailure(error_5, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
883
+ return [3 /*break*/, 4];
884
+ case 4: return [2 /*return*/];
885
+ }
886
+ });
887
+ }); };
852
888
  messagingClientPromise = function () { return __awaiter(_this, void 0, void 0, function () {
853
- var chatAdapterConfig, error_5, telemetryData, _a, error_6, telemetryData, error_7, telemetryData, _b, error_8, telemetryData;
889
+ var chatAdapterConfig, error_6, telemetryData, _a, error_7, telemetryData, error_8, telemetryData, _b, error_9, telemetryData;
854
890
  var _c, _d;
855
891
  return __generator(this, function (_e) {
856
892
  switch (_e.label) {
@@ -874,12 +910,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
874
910
  _e.sent();
875
911
  return [3 /*break*/, 4];
876
912
  case 3:
877
- error_5 = _e.sent();
913
+ error_6 = _e.sent();
878
914
  telemetryData = {
879
915
  RequestId: this.requestId,
880
916
  ChatId: this.chatToken.chatId,
881
917
  };
882
- exceptionThrowers_1.default.throwMessagingClientInitializationFailure(error_5, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
918
+ exceptionThrowers_1.default.throwMessagingClientInitializationFailure(error_6, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
883
919
  return [3 /*break*/, 4];
884
920
  case 4:
885
921
  _e.trys.push([4, 6, , 7]);
@@ -897,12 +933,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
897
933
  });
898
934
  return [3 /*break*/, 7];
899
935
  case 6:
900
- error_6 = _e.sent();
936
+ error_7 = _e.sent();
901
937
  telemetryData = {
902
938
  RequestId: this.requestId,
903
939
  ChatId: this.chatToken.chatId,
904
940
  };
905
- exceptionThrowers_1.default.throwMessagingClientConversationJoinFailure(error_6, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
941
+ exceptionThrowers_1.default.throwMessagingClientConversationJoinFailure(error_7, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
906
942
  return [3 /*break*/, 7];
907
943
  case 7: return [3 /*break*/, 14];
908
944
  case 8:
@@ -916,12 +952,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
916
952
  _e.sent();
917
953
  return [3 /*break*/, 11];
918
954
  case 10:
919
- error_7 = _e.sent();
955
+ error_8 = _e.sent();
920
956
  telemetryData = {
921
957
  RequestId: this.requestId,
922
958
  ChatId: this.chatToken.chatId,
923
959
  };
924
- exceptionThrowers_1.default.throwMessagingClientInitializationFailure(error_7, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
960
+ exceptionThrowers_1.default.throwMessagingClientInitializationFailure(error_8, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
925
961
  return [3 /*break*/, 11];
926
962
  case 11:
927
963
  _e.trys.push([11, 13, , 14]);
@@ -935,19 +971,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
935
971
  });
936
972
  return [3 /*break*/, 14];
937
973
  case 13:
938
- error_8 = _e.sent();
974
+ error_9 = _e.sent();
939
975
  telemetryData = {
940
976
  RequestId: this.requestId,
941
977
  ChatId: this.chatToken.chatId,
942
978
  };
943
- exceptionThrowers_1.default.throwMessagingClientConversationJoinFailure(error_8, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
979
+ exceptionThrowers_1.default.throwMessagingClientConversationJoinFailure(error_9, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
944
980
  return [3 /*break*/, 14];
945
981
  case 14: return [2 /*return*/];
946
982
  }
947
983
  });
948
984
  }); };
949
985
  attachmentClientPromise = function () { return __awaiter(_this, void 0, void 0, function () {
950
- var amsClient, error_9, telemetryData;
986
+ var amsClient, error_10, telemetryData;
951
987
  return __generator(this, function (_a) {
952
988
  switch (_a.label) {
953
989
  case 0:
@@ -962,21 +998,31 @@ var OmnichannelChatSDK = /** @class */ (function () {
962
998
  _a.label = 3;
963
999
  case 3: return [3 /*break*/, 5];
964
1000
  case 4:
965
- error_9 = _a.sent();
1001
+ error_10 = _a.sent();
966
1002
  telemetryData = {
967
1003
  RequestId: this.requestId,
968
1004
  ChatId: this.chatToken.chatId,
969
1005
  };
970
- exceptionThrowers_1.default.throwMessagingClientInitializationFailure(error_9, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
1006
+ exceptionThrowers_1.default.throwMessagingClientInitializationFailure(error_10, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
971
1007
  return [3 /*break*/, 5];
972
1008
  case 5: return [2 /*return*/];
973
1009
  }
974
1010
  });
975
1011
  }); };
976
- return [4 /*yield*/, Promise.all([sessionInitPromise(), messagingClientPromise(), attachmentClientPromise()])];
1012
+ if (!!((_k = this.chatSDKConfig.useCreateConversation) === null || _k === void 0 ? void 0 : _k.disable)) return [3 /*break*/, 21];
1013
+ return [4 /*yield*/, createConversationPromise()];
977
1014
  case 19:
978
- _k.sent();
979
- if (this.isPersistentChat && !((_h = this.chatSDKConfig.persistentChat) === null || _h === void 0 ? void 0 : _h.disable)) {
1015
+ _o.sent();
1016
+ return [4 /*yield*/, Promise.all([messagingClientPromise(), attachmentClientPromise()])];
1017
+ case 20:
1018
+ _o.sent();
1019
+ return [3 /*break*/, 23];
1020
+ case 21: return [4 /*yield*/, Promise.all([sessionInitPromise(), messagingClientPromise(), attachmentClientPromise()])];
1021
+ case 22:
1022
+ _o.sent();
1023
+ _o.label = 23;
1024
+ case 23:
1025
+ if (this.isPersistentChat && !((_l = this.chatSDKConfig.persistentChat) === null || _l === void 0 ? void 0 : _l.disable)) {
980
1026
  this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
981
1027
  return __generator(this, function (_a) {
982
1028
  switch (_a.label) {
@@ -987,7 +1033,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
987
1033
  return [2 /*return*/];
988
1034
  }
989
1035
  });
990
- }); }, (_j = this.chatSDKConfig.persistentChat) === null || _j === void 0 ? void 0 : _j.tokenUpdateTime);
1036
+ }); }, (_m = this.chatSDKConfig.persistentChat) === null || _m === void 0 ? void 0 : _m.tokenUpdateTime);
991
1037
  }
992
1038
  return [2 /*return*/];
993
1039
  }
@@ -996,7 +1042,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
996
1042
  };
997
1043
  OmnichannelChatSDK.prototype.closeChat = function (endChatOptionalParams) {
998
1044
  return __awaiter(this, void 0, void 0, function () {
999
- var cleanupMetadata, sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_10;
1045
+ var cleanupMetadata, sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_11;
1000
1046
  var _a, _b;
1001
1047
  return __generator(this, function (_c) {
1002
1048
  switch (_c.label) {
@@ -1031,8 +1077,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
1031
1077
  _c.sent();
1032
1078
  return [3 /*break*/, 4];
1033
1079
  case 3:
1034
- error_10 = _c.sent();
1035
- exceptionThrowers_1.default.throwConversationClosureFailure(error_10, this.scenarioMarker, TelemetryEvent_1.default.CloseChatSession, __assign(__assign({}, cleanupMetadata), { isSessionEnded: String(!(endChatOptionalParams === null || endChatOptionalParams === void 0 ? void 0 : endChatOptionalParams.isSessionEnded)) }));
1080
+ error_11 = _c.sent();
1081
+ exceptionThrowers_1.default.throwConversationClosureFailure(error_11, this.scenarioMarker, TelemetryEvent_1.default.CloseChatSession, __assign(__assign({}, cleanupMetadata), { isSessionEnded: String(!(endChatOptionalParams === null || endChatOptionalParams === void 0 ? void 0 : endChatOptionalParams.isSessionEnded)) }));
1036
1082
  return [3 /*break*/, 4];
1037
1083
  case 4:
1038
1084
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.CloseChatSession, cleanupMetadata);
@@ -1044,7 +1090,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1044
1090
  };
1045
1091
  OmnichannelChatSDK.prototype.endChat = function () {
1046
1092
  return __awaiter(this, arguments, void 0, function (endChatOptionalParams) {
1047
- var cleanupMetadata, error_11, telemetryData;
1093
+ var cleanupMetadata, error_12, telemetryData;
1048
1094
  var _a;
1049
1095
  if (endChatOptionalParams === void 0) { endChatOptionalParams = {}; }
1050
1096
  return __generator(this, function (_b) {
@@ -1089,12 +1135,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
1089
1135
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, cleanupMetadata);
1090
1136
  return [3 /*break*/, 4];
1091
1137
  case 3:
1092
- error_11 = _b.sent();
1138
+ error_12 = _b.sent();
1093
1139
  telemetryData = {
1094
1140
  RequestId: this.requestId,
1095
1141
  ChatId: this.chatToken.chatId
1096
1142
  };
1097
- exceptionThrowers_1.default.throwConversationClosureFailure(error_11, this.scenarioMarker, TelemetryEvent_1.default.EndChat, telemetryData);
1143
+ exceptionThrowers_1.default.throwConversationClosureFailure(error_12, this.scenarioMarker, TelemetryEvent_1.default.EndChat, telemetryData);
1098
1144
  return [3 /*break*/, 4];
1099
1145
  case 4: return [2 /*return*/];
1100
1146
  }
@@ -1141,7 +1187,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1141
1187
  };
1142
1188
  OmnichannelChatSDK.prototype.getConversationDetails = function () {
1143
1189
  return __awaiter(this, arguments, void 0, function (optionalParams) {
1144
- var requestId, chatToken, chatId, reconnectId, sessionId, getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, canRenderPostChat, participantType, liveWorkItemDetails, error_12, telemetryData;
1190
+ var requestId, chatToken, chatId, reconnectId, sessionId, getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, canRenderPostChat, participantType, liveWorkItemDetails, error_13, telemetryData;
1145
1191
  var _a, _b, _c, _d;
1146
1192
  if (optionalParams === void 0) { optionalParams = {}; }
1147
1193
  return __generator(this, function (_e) {
@@ -1210,15 +1256,15 @@ var OmnichannelChatSDK = /** @class */ (function () {
1210
1256
  });
1211
1257
  return [2 /*return*/, liveWorkItemDetails];
1212
1258
  case 3:
1213
- error_12 = _e.sent();
1259
+ error_13 = _e.sent();
1214
1260
  telemetryData = {
1215
1261
  RequestId: requestId,
1216
1262
  ChatId: chatId || ''
1217
1263
  };
1218
- if ((0, utilities_1.isClientIdNotFoundErrorMessage)(error_12)) {
1219
- exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(error_12, this.scenarioMarker, TelemetryEvent_1.default.GetConversationDetails, telemetryData);
1264
+ if ((0, utilities_1.isClientIdNotFoundErrorMessage)(error_13)) {
1265
+ exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(error_13, this.scenarioMarker, TelemetryEvent_1.default.GetConversationDetails, telemetryData);
1220
1266
  }
1221
- exceptionSuppressors_1.default.suppressConversationDetailsRetrievalFailure(error_12, this.scenarioMarker, TelemetryEvent_1.default.GetConversationDetails, telemetryData);
1267
+ exceptionSuppressors_1.default.suppressConversationDetailsRetrievalFailure(error_13, this.scenarioMarker, TelemetryEvent_1.default.GetConversationDetails, telemetryData);
1222
1268
  return [3 /*break*/, 4];
1223
1269
  case 4: return [2 /*return*/, {}];
1224
1270
  }
@@ -1259,7 +1305,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1259
1305
  };
1260
1306
  OmnichannelChatSDK.prototype.getChatToken = function () {
1261
1307
  return __awaiter(this, arguments, void 0, function (cached, optionalParams) {
1262
- var getChatTokenOptionalParams, chatToken, chatId, token, regionGtms, expiresIn, visitorId, voiceVideoCallToken, acsEndpoint, attachmentConfiguration, error_13, telemetryData;
1308
+ var getChatTokenOptionalParams, chatToken, error_14, telemetryData;
1263
1309
  var _a, _b, _c;
1264
1310
  if (cached === void 0) { cached = true; }
1265
1311
  return __generator(this, function (_d) {
@@ -1291,39 +1337,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
1291
1337
  return [4 /*yield*/, this.OCClient.getChatToken(this.requestId, getChatTokenOptionalParams)];
1292
1338
  case 2:
1293
1339
  chatToken = _d.sent();
1294
- chatId = chatToken.ChatId, token = chatToken.Token, regionGtms = chatToken.RegionGtms, expiresIn = chatToken.ExpiresIn, visitorId = chatToken.VisitorId, voiceVideoCallToken = chatToken.VoiceVideoCallToken, acsEndpoint = chatToken.ACSEndpoint, attachmentConfiguration = chatToken.AttachmentConfiguration;
1295
- this.chatToken = {
1296
- chatId: chatId,
1297
- regionGTMS: JSON.parse(regionGtms),
1298
- requestId: this.requestId,
1299
- token: token,
1300
- expiresIn: expiresIn,
1301
- visitorId: visitorId,
1302
- voiceVideoCallToken: voiceVideoCallToken,
1303
- acsEndpoint: acsEndpoint,
1304
- };
1305
- if (attachmentConfiguration && attachmentConfiguration.AttachmentServiceEndpoint) {
1306
- this.chatToken.amsEndpoint = attachmentConfiguration.AttachmentServiceEndpoint;
1307
- }
1308
- if (this.OCClient.sessionId) {
1309
- this.sessionId = this.OCClient.sessionId;
1310
- }
1340
+ this.setChatToken(chatToken);
1311
1341
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetChatToken, {
1312
1342
  RequestId: this.requestId,
1313
1343
  ChatId: this.chatToken.chatId
1314
1344
  });
1315
1345
  return [3 /*break*/, 4];
1316
1346
  case 3:
1317
- error_13 = _d.sent();
1347
+ error_14 = _d.sent();
1318
1348
  telemetryData = {
1319
1349
  RequestId: this.requestId,
1320
1350
  ChatId: (_c = this.chatToken) === null || _c === void 0 ? void 0 : _c.chatId,
1321
1351
  };
1322
- if ((0, utilities_1.isClientIdNotFoundErrorMessage)(error_13)) {
1323
- exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(error_13, this.scenarioMarker, TelemetryEvent_1.default.GetChatToken, telemetryData);
1352
+ if ((0, utilities_1.isClientIdNotFoundErrorMessage)(error_14)) {
1353
+ exceptionThrowers_1.default.throwAuthContactIdNotFoundFailure(error_14, this.scenarioMarker, TelemetryEvent_1.default.GetChatToken, telemetryData);
1324
1354
  }
1325
1355
  else {
1326
- exceptionThrowers_1.default.throwChatTokenRetrievalFailure(error_13, this.scenarioMarker, TelemetryEvent_1.default.GetChatToken, telemetryData);
1356
+ exceptionThrowers_1.default.throwChatTokenRetrievalFailure(error_14, this.scenarioMarker, TelemetryEvent_1.default.GetChatToken, telemetryData);
1327
1357
  }
1328
1358
  return [3 /*break*/, 4];
1329
1359
  case 4: return [3 /*break*/, 6];
@@ -1338,6 +1368,25 @@ var OmnichannelChatSDK = /** @class */ (function () {
1338
1368
  });
1339
1369
  });
1340
1370
  };
1371
+ OmnichannelChatSDK.prototype.setChatToken = function (chatToken) {
1372
+ var chatId = chatToken.ChatId, token = chatToken.Token, regionGtms = chatToken.RegionGtms, expiresIn = chatToken.ExpiresIn, visitorId = chatToken.VisitorId, voiceVideoCallToken = chatToken.VoiceVideoCallToken, acsEndpoint = chatToken.ACSEndpoint, attachmentConfiguration = chatToken.AttachmentConfiguration;
1373
+ this.chatToken = {
1374
+ chatId: chatId,
1375
+ regionGTMS: JSON.parse(regionGtms),
1376
+ requestId: this.requestId,
1377
+ token: token,
1378
+ expiresIn: expiresIn,
1379
+ visitorId: visitorId,
1380
+ voiceVideoCallToken: voiceVideoCallToken,
1381
+ acsEndpoint: acsEndpoint,
1382
+ };
1383
+ if (attachmentConfiguration && attachmentConfiguration.AttachmentServiceEndpoint) {
1384
+ this.chatToken.amsEndpoint = attachmentConfiguration.AttachmentServiceEndpoint;
1385
+ }
1386
+ if (this.OCClient.sessionId) {
1387
+ this.sessionId = this.OCClient.sessionId;
1388
+ }
1389
+ };
1341
1390
  OmnichannelChatSDK.prototype.getCallingToken = function () {
1342
1391
  return __awaiter(this, void 0, void 0, function () {
1343
1392
  return __generator(this, function (_a) {
@@ -1448,7 +1497,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1448
1497
  };
1449
1498
  OmnichannelChatSDK.prototype.sendMessage = function (message) {
1450
1499
  return __awaiter(this, void 0, void 0, function () {
1451
- var sendMessageRequest, error_14, messageToSend, _a;
1500
+ var sendMessageRequest, error_15, messageToSend, _a;
1452
1501
  var _b;
1453
1502
  return __generator(this, function (_c) {
1454
1503
  switch (_c.label) {
@@ -1484,7 +1533,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1484
1533
  });
1485
1534
  return [3 /*break*/, 4];
1486
1535
  case 3:
1487
- error_14 = _c.sent();
1536
+ error_15 = _c.sent();
1488
1537
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendMessages, {
1489
1538
  RequestId: this.requestId,
1490
1539
  ChatId: this.chatToken.chatId,
@@ -1609,7 +1658,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1609
1658
  };
1610
1659
  OmnichannelChatSDK.prototype.sendTypingEvent = function () {
1611
1660
  return __awaiter(this, void 0, void 0, function () {
1612
- var error_15, typingPayload, members, botMembers, error_16;
1661
+ var error_16, typingPayload, members, botMembers, error_17;
1613
1662
  return __generator(this, function (_a) {
1614
1663
  switch (_a.label) {
1615
1664
  case 0:
@@ -1638,7 +1687,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1638
1687
  });
1639
1688
  return [3 /*break*/, 5];
1640
1689
  case 4:
1641
- error_15 = _a.sent();
1690
+ error_16 = _a.sent();
1642
1691
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendTypingEvent, {
1643
1692
  RequestId: this.requestId,
1644
1693
  ChatId: this.chatToken.chatId
@@ -1666,7 +1715,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1666
1715
  });
1667
1716
  return [3 /*break*/, 12];
1668
1717
  case 11:
1669
- error_16 = _a.sent();
1718
+ error_17 = _a.sent();
1670
1719
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendTypingEvent, {
1671
1720
  RequestId: this.requestId,
1672
1721
  ChatId: this.chatToken.chatId
@@ -1803,7 +1852,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1803
1852
  };
1804
1853
  OmnichannelChatSDK.prototype.uploadFileAttachment = function (fileInfo) {
1805
1854
  return __awaiter(this, void 0, void 0, function () {
1806
- var amsClient, createObjectResponse, documentId, uploadDocumentResponse, fileIdsProperty, fileMetaProperty, sendMessageRequest, messageToSend, error_17, fileMetadata, messageToSend, error_18;
1855
+ var amsClient, createObjectResponse, documentId, uploadDocumentResponse, fileIdsProperty, fileMetaProperty, sendMessageRequest, messageToSend, error_18, fileMetadata, messageToSend, error_19;
1807
1856
  var _a, _b;
1808
1857
  return __generator(this, function (_c) {
1809
1858
  switch (_c.label) {
@@ -1865,7 +1914,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1865
1914
  });
1866
1915
  return [2 /*return*/, messageToSend];
1867
1916
  case 6:
1868
- error_17 = _c.sent();
1917
+ error_18 = _c.sent();
1869
1918
  console.error("OmnichannelChatSDK/uploadFileAttachment/sendMessage/error");
1870
1919
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
1871
1920
  RequestId: this.requestId,
@@ -1911,8 +1960,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
1911
1960
  });
1912
1961
  return [2 /*return*/, messageToSend];
1913
1962
  case 15:
1914
- error_18 = _c.sent();
1915
- console.error("OmnichannelChatSDK/uploadFileAttachment/error: ".concat(error_18));
1963
+ error_19 = _c.sent();
1964
+ console.error("OmnichannelChatSDK/uploadFileAttachment/error: ".concat(error_19));
1916
1965
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
1917
1966
  RequestId: this.requestId,
1918
1967
  ChatId: this.chatToken.chatId
@@ -1925,7 +1974,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1925
1974
  };
1926
1975
  OmnichannelChatSDK.prototype.downloadFileAttachment = function (fileMetadata) {
1927
1976
  return __awaiter(this, void 0, void 0, function () {
1928
- var amsClient, response, view_location, viewResponse, _a, downloadedFile, error_19;
1977
+ var amsClient, response, view_location, viewResponse, _a, downloadedFile, error_20;
1929
1978
  return __generator(this, function (_b) {
1930
1979
  switch (_b.label) {
1931
1980
  case 0: return [4 /*yield*/, this.getAMSClient()];
@@ -1973,8 +2022,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
1973
2022
  });
1974
2023
  return [2 /*return*/, downloadedFile];
1975
2024
  case 9:
1976
- error_19 = _b.sent();
1977
- console.error("OmnichannelChatSDK/downloadFileAttachment/error: ".concat(error_19));
2025
+ error_20 = _b.sent();
2026
+ console.error("OmnichannelChatSDK/downloadFileAttachment/error: ".concat(error_20));
1978
2027
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
1979
2028
  RequestId: this.requestId,
1980
2029
  ChatId: this.chatToken.chatId
@@ -1987,7 +2036,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1987
2036
  };
1988
2037
  OmnichannelChatSDK.prototype.emailLiveChatTranscript = function (body_1) {
1989
2038
  return __awaiter(this, arguments, void 0, function (body, optionalParams) {
1990
- var emailTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, emailRequestBody, error_20;
2039
+ var emailTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, emailRequestBody, error_21;
1991
2040
  var _a;
1992
2041
  if (optionalParams === void 0) { optionalParams = {}; }
1993
2042
  return __generator(this, function (_b) {
@@ -2038,8 +2087,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
2038
2087
  });
2039
2088
  return [3 /*break*/, 4];
2040
2089
  case 3:
2041
- error_20 = _b.sent();
2042
- console.error("OmnichannelChatSDK/emailLiveChatTranscript/error: ".concat(error_20));
2090
+ error_21 = _b.sent();
2091
+ console.error("OmnichannelChatSDK/emailLiveChatTranscript/error: ".concat(error_21));
2043
2092
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.EmailLiveChatTranscript, {
2044
2093
  RequestId: requestId,
2045
2094
  ChatId: chatId
@@ -2052,7 +2101,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2052
2101
  };
2053
2102
  OmnichannelChatSDK.prototype.getLiveChatTranscript = function () {
2054
2103
  return __awaiter(this, arguments, void 0, function (optionalParams) {
2055
- var getChatTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, transcriptResponse, error_21, telemetryData;
2104
+ var getChatTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, transcriptResponse, error_22, telemetryData;
2056
2105
  var _a, _b;
2057
2106
  if (optionalParams === void 0) { optionalParams = {}; }
2058
2107
  return __generator(this, function (_c) {
@@ -2103,12 +2152,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
2103
2152
  });
2104
2153
  return [2 /*return*/, transcriptResponse];
2105
2154
  case 3:
2106
- error_21 = _c.sent();
2155
+ error_22 = _c.sent();
2107
2156
  telemetryData = {
2108
2157
  RequestId: requestId,
2109
2158
  ChatId: chatId
2110
2159
  };
2111
- exceptionThrowers_1.default.throwLiveChatTranscriptRetrievalFailure(error_21, this.scenarioMarker, TelemetryEvent_1.default.GetLiveChatTranscript, telemetryData);
2160
+ exceptionThrowers_1.default.throwLiveChatTranscriptRetrievalFailure(error_22, this.scenarioMarker, TelemetryEvent_1.default.GetLiveChatTranscript, telemetryData);
2112
2161
  return [3 /*break*/, 4];
2113
2162
  case 4: return [2 /*return*/];
2114
2163
  }
@@ -2624,7 +2673,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2624
2673
  };
2625
2674
  OmnichannelChatSDK.prototype.getChatConfig = function () {
2626
2675
  return __awaiter(this, arguments, void 0, function (optionalParams) {
2627
- var sendCacheHeaders, bypassCache, liveChatConfig, error_22, _a;
2676
+ var sendCacheHeaders, bypassCache, liveChatConfig, error_23, _a;
2628
2677
  var _b, _c;
2629
2678
  if (optionalParams === void 0) { optionalParams = {}; }
2630
2679
  return __generator(this, function (_d) {
@@ -2644,8 +2693,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
2644
2693
  this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] ".concat(this.liveChatVersion));
2645
2694
  return [2 /*return*/, this.liveChatConfig];
2646
2695
  case 3:
2647
- error_22 = _d.sent();
2648
- if (!(0, internalUtils_1.isCoreServicesOrgUrlDNSError)(error_22, this.coreServicesOrgUrl, this.dynamicsLocationCode)) return [3 /*break*/, 6];
2696
+ error_23 = _d.sent();
2697
+ if (!(0, internalUtils_1.isCoreServicesOrgUrlDNSError)(error_23, this.coreServicesOrgUrl, this.dynamicsLocationCode)) return [3 /*break*/, 6];
2649
2698
  this.omnichannelConfig.orgUrl = this.unqServicesOrgUrl;
2650
2699
  _a = this;
2651
2700
  return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, (0, createOcSDKConfiguration_1.default)(false), this.ocSdkLogger)];
@@ -2657,10 +2706,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
2657
2706
  return [3 /*break*/, 7];
2658
2707
  case 6:
2659
2708
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2660
- if (((_c = (_b = error_22.response) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c.errorcode) && parseInt(error_22.response.headers.errorcode) === OmnichannelErrorCodes_1.default.WidgetNotFound) {
2709
+ if (((_c = (_b = error_23.response) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c.errorcode) && parseInt(error_23.response.headers.errorcode) === OmnichannelErrorCodes_1.default.WidgetNotFound) {
2661
2710
  console.warn("No widget with the given app id is present in the system.");
2662
2711
  }
2663
- throw error_22; // Bubble up error by default to throw ChatConfigRetrievalFailure
2712
+ throw error_23; // Bubble up error by default to throw ChatConfigRetrievalFailure
2664
2713
  case 7: return [3 /*break*/, 8];
2665
2714
  case 8: return [2 /*return*/, this.liveChatConfig];
2666
2715
  }
@@ -2694,7 +2743,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2694
2743
  };
2695
2744
  OmnichannelChatSDK.prototype.updateChatToken = function (newToken, newRegionGTMS) {
2696
2745
  return __awaiter(this, void 0, void 0, function () {
2697
- var sessionInfo, error_23, exceptionDetails;
2746
+ var sessionInfo, error_24, exceptionDetails;
2698
2747
  return __generator(this, function (_a) {
2699
2748
  switch (_a.label) {
2700
2749
  case 0:
@@ -2722,7 +2771,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2722
2771
  });
2723
2772
  return [3 /*break*/, 5];
2724
2773
  case 4:
2725
- error_23 = _a.sent();
2774
+ error_24 = _a.sent();
2726
2775
  exceptionDetails = {
2727
2776
  response: "UpdateChatTokenFailed"
2728
2777
  };
@@ -2739,7 +2788,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2739
2788
  };
2740
2789
  OmnichannelChatSDK.prototype.setAuthTokenProvider = function (provider_1) {
2741
2790
  return __awaiter(this, arguments, void 0, function (provider, optionalParams) {
2742
- var token, exceptionDetails, error_24, exceptionDetails, exceptionDetails;
2791
+ var token, exceptionDetails, error_25, exceptionDetails, exceptionDetails;
2743
2792
  if (optionalParams === void 0) { optionalParams = {}; }
2744
2793
  return __generator(this, function (_a) {
2745
2794
  switch (_a.label) {
@@ -2771,12 +2820,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
2771
2820
  }
2772
2821
  return [3 /*break*/, 4];
2773
2822
  case 3:
2774
- error_24 = _a.sent();
2823
+ error_25 = _a.sent();
2775
2824
  exceptionDetails = {
2776
2825
  response: ChatSDKError_1.ChatSDKErrorName.GetAuthTokenFailed
2777
2826
  };
2778
- if (error_24.message == ChatSDKError_1.ChatSDKErrorName.UndefinedAuthToken) {
2779
- exceptionDetails.response = error_24.message;
2827
+ if (error_25.message == ChatSDKError_1.ChatSDKErrorName.UndefinedAuthToken) {
2828
+ exceptionDetails.response = error_25.message;
2780
2829
  }
2781
2830
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
2782
2831
  ExceptionDetails: JSON.stringify(exceptionDetails)