@microsoft/omnichannel-chat-sdk 1.11.7-main.6fd4ccf → 1.11.7-main.80a4f46

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.
@@ -1,6 +1,6 @@
1
1
  import ACSClient from "./core/messaging/ACSClient";
2
2
  import { VoiceVideoCallingOptionalParams } from "./types/config";
3
- import { ChatAdapter, GetAgentAvailabilityResponse, GetCurrentLiveChatContextResponse, GetLiveChatTranscriptResponse, GetMessagesResponse, GetPreChatSurveyResponse, GetVoiceVideoCallingResponse, MaskingRules, UploadFileAttachmentResponse } from "./types/response";
3
+ import { ChatAdapter, GetAgentAvailabilityResponse, GetCurrentLiveChatContextResponse, GetLiveChatTranscriptResponse, GetMessagesResponse, GetPersistentChatHistoryResponse, GetPreChatSurveyResponse, GetVoiceVideoCallingResponse, MaskingRules, UploadFileAttachmentResponse } from "./types/response";
4
4
  import { ParticipantsRemovedEvent } from '@azure/communication-signaling';
5
5
  import ChatAdapterOptionalParams from "./core/messaging/ChatAdapterOptionalParams";
6
6
  import ChatConfig from "./core/ChatConfig";
@@ -21,6 +21,7 @@ import GetChatTokenOptionalParams from "./core/GetChatTokenOptionalParams";
21
21
  import GetConversationDetailsOptionalParams from "./core/GetConversationDetailsOptionalParams";
22
22
  import GetLiveChatConfigOptionalParams from "./core/GetLiveChatConfigOptionalParams";
23
23
  import GetLiveChatTranscriptOptionalParams from "./core/GetLiveChatTranscriptOptionalParams";
24
+ import GetPersistentChatHistoryOptionalParams from "./core/GetPersistentChatHistoryOptionalParams";
24
25
  import IChatToken from "./external/IC3Adapter/IChatToken";
25
26
  import IFileInfo from "@microsoft/omnichannel-ic3core/lib/interfaces/IFileInfo";
26
27
  import IFileMetadata from "@microsoft/omnichannel-ic3core/lib/model/IFileMetadata";
@@ -83,6 +84,7 @@ declare class OmnichannelChatSDK {
83
84
  private debugAMS;
84
85
  private debugACS;
85
86
  private detailedDebugEnabled;
87
+ private regexCompiledForDataMasking;
86
88
  constructor(omnichannelConfig: OmnichannelConfig, chatSDKConfig?: ChatSDKConfig);
87
89
  /**
88
90
  * Executes an operation with mutual exclusion to prevent race conditions
@@ -164,6 +166,7 @@ declare class OmnichannelChatSDK {
164
166
  private getIC3Client;
165
167
  private setPrechatConfigurations;
166
168
  private setDataMaskingConfiguration;
169
+ private compileDataMaskingRegex;
167
170
  private setAuthSettingConfig;
168
171
  private setPersistentChatConfiguration;
169
172
  private setLocaleIdConfiguration;
@@ -186,5 +189,10 @@ declare class OmnichannelChatSDK {
186
189
  * @private
187
190
  */
188
191
  private handleConversationJoinFailure;
192
+ /**
193
+ * Get persistent chat history for authenticated users.
194
+ * @param getPersistentChatHistoryOptionalParams Optional parameters for persistent chat history retrieval.
195
+ */
196
+ getPersistentChatHistory(getPersistentChatHistoryOptionalParams?: GetPersistentChatHistoryOptionalParams): Promise<GetPersistentChatHistoryResponse | undefined>;
189
197
  }
190
198
  export default OmnichannelChatSDK;
@@ -150,6 +150,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
150
150
  this.debugAMS = false;
151
151
  this.debugACS = false;
152
152
  this.detailedDebugEnabled = false;
153
+ this.regexCompiledForDataMasking = [];
153
154
  this.populateInitChatOptionalParam = function (requestOptionalParams, optionalParams, telemetryEvent) {
154
155
  requestOptionalParams.initContext.locale = (0, locale_1.getLocaleStringFromId)(_this.localeId);
155
156
  if (optionalParams === null || optionalParams === void 0 ? void 0 : optionalParams.customContext) {
@@ -1687,21 +1688,36 @@ var OmnichannelChatSDK = /** @class */ (function () {
1687
1688
  }
1688
1689
  var content = message.content;
1689
1690
  var match;
1690
- for (var _i = 0, _a = this.dataMaskingRules.rules; _i < _a.length; _i++) {
1691
- var maskingRule = _a[_i];
1692
- var regex = new RegExp(maskingRule.regex, 'g');
1693
- while ((match = regex.exec(content)) !== null) {
1694
- var replaceStr = match[0].replace(/./g, this.maskingCharacter);
1695
- content = content.replace(match[0], replaceStr);
1691
+ if (this.regexCompiledForDataMasking.length === 0) {
1692
+ return message;
1693
+ }
1694
+ for (var _i = 0, _a = this.regexCompiledForDataMasking; _i < _a.length; _i++) {
1695
+ var regex = _a[_i];
1696
+ try {
1697
+ var lastIndex = -1;
1698
+ while ((match = regex.exec(content)) !== null) {
1699
+ // Prevent infinite loop from zero-width matches
1700
+ if (regex.lastIndex === lastIndex) {
1701
+ this.debug && console.warn("[OmnichannelChatSDK][transformMessage] Data masking regex caused zero-width match, skipping rule ".concat(regex));
1702
+ break;
1703
+ }
1704
+ lastIndex = regex.lastIndex;
1705
+ var replaceStr = match[0].replace(/./g, this.maskingCharacter);
1706
+ content = content.replace(match[0], replaceStr);
1707
+ }
1708
+ match = null;
1709
+ }
1710
+ catch (error) {
1711
+ // Log error for invalid regex but continue processing other rules
1712
+ this.debug && console.error("[OmnichannelChatSDK][transformMessage] Data masking regex failed for rule ".concat(regex, ": ").concat(error));
1696
1713
  }
1697
- match = null;
1698
1714
  }
1699
1715
  message.content = content;
1700
1716
  return message;
1701
1717
  };
1702
1718
  OmnichannelChatSDK.prototype.sendMessage = function (message) {
1703
1719
  return __awaiter(this, void 0, void 0, function () {
1704
- var sendMessageRequest, chatMessage, error_17, exceptionDetails, messageToSend, error_18, exceptionDetails;
1720
+ var sendMessageRequest, chatMessage, error_17, exceptionDetails;
1705
1721
  var _a;
1706
1722
  return __generator(this, function (_b) {
1707
1723
  switch (_b.label) {
@@ -1714,7 +1730,6 @@ var OmnichannelChatSDK = /** @class */ (function () {
1714
1730
  exceptionThrowers_1.default.throwUninitializedChatSDK(this.scenarioMarker, TelemetryEvent_1.default.SendMessages);
1715
1731
  }
1716
1732
  this.transformMessage(message);
1717
- if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 5];
1718
1733
  sendMessageRequest = {
1719
1734
  content: message.content,
1720
1735
  };
@@ -1751,52 +1766,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1751
1766
  response: ChatSDKError_1.ChatSDKErrorName.ChatSDKSendMessageFailed,
1752
1767
  errorObject: "".concat(error_17)
1753
1768
  });
1754
- case 4: return [3 /*break*/, 9];
1755
- case 5:
1756
- messageToSend = {
1757
- content: message.content,
1758
- timestamp: new Date(),
1759
- contentType: MessageContentType_1.default.Text,
1760
- deliveryMode: DeliveryMode_1.default.Bridged,
1761
- messageType: MessageType_1.default.UserMessage,
1762
- properties: undefined,
1763
- tags: __spreadArray([], MessageTags_1.defaultMessageTags, true),
1764
- sender: {
1765
- displayName: "Customer",
1766
- id: "customer",
1767
- type: PersonType_1.default.User
1768
- }
1769
- };
1770
- if (message.tags) {
1771
- messageToSend.tags = message.tags;
1772
- }
1773
- if (message.timestamp) {
1774
- messageToSend.timestamp = message.timestamp;
1775
- }
1776
- _b.label = 6;
1777
- case 6:
1778
- _b.trys.push([6, 8, , 9]);
1779
- return [4 /*yield*/, this.conversation.sendMessage(messageToSend)];
1780
- case 7:
1781
- _b.sent();
1782
- this.scenarioMarker.completeScenario(TelemetryEvent_1.default.SendMessages, {
1783
- RequestId: this.requestId,
1784
- ChatId: this.chatToken.chatId
1785
- });
1786
- return [3 /*break*/, 9];
1787
- case 8:
1788
- error_18 = _b.sent();
1789
- exceptionDetails = {
1790
- response: ChatSDKError_1.ChatSDKErrorName.ChatSDKSendMessageFailed,
1791
- errorObject: "".concat(error_18)
1792
- };
1793
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendMessages, {
1794
- RequestId: this.requestId,
1795
- ChatId: this.chatToken.chatId,
1796
- ExceptionDetails: JSON.stringify(exceptionDetails)
1797
- });
1798
- throw new Error(ChatSDKError_1.ChatSDKErrorName.ChatSDKSendMessageFailed);
1799
- case 9: return [2 /*return*/];
1769
+ case 4: return [2 /*return*/];
1800
1770
  }
1801
1771
  });
1802
1772
  });
@@ -1875,7 +1845,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1875
1845
  };
1876
1846
  OmnichannelChatSDK.prototype.sendTypingEvent = function () {
1877
1847
  return __awaiter(this, void 0, void 0, function () {
1878
- var error_19;
1848
+ var error_18;
1879
1849
  return __generator(this, function (_a) {
1880
1850
  switch (_a.label) {
1881
1851
  case 0:
@@ -1904,7 +1874,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1904
1874
  });
1905
1875
  return [3 /*break*/, 5];
1906
1876
  case 4:
1907
- error_19 = _a.sent();
1877
+ error_18 = _a.sent();
1908
1878
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendTypingEvent, {
1909
1879
  RequestId: this.requestId,
1910
1880
  ChatId: this.chatToken.chatId
@@ -1972,8 +1942,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1972
1942
  OmnichannelChatSDK.prototype.onAgentEndSession = function (onAgentEndSessionCallback) {
1973
1943
  return __awaiter(this, void 0, void 0, function () {
1974
1944
  var _this = this;
1975
- var _a;
1976
- return __generator(this, function (_b) {
1945
+ return __generator(this, function (_a) {
1977
1946
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.OnAgentEndSession, {
1978
1947
  RequestId: this.requestId,
1979
1948
  ChatId: this.chatToken.chatId
@@ -1981,59 +1950,32 @@ var OmnichannelChatSDK = /** @class */ (function () {
1981
1950
  if (!this.isInitialized) {
1982
1951
  exceptionThrowers_1.default.throwUninitializedChatSDK(this.scenarioMarker, TelemetryEvent_1.default.OnAgentEndSession);
1983
1952
  }
1984
- if (this.liveChatVersion === LiveChatVersion_1.default.V2) {
1985
- try {
1986
- this.conversation.registerOnThreadUpdate(function (event) { return __awaiter(_this, void 0, void 0, function () {
1987
- var liveWorkItemDetails;
1988
- return __generator(this, function (_a) {
1989
- switch (_a.label) {
1990
- case 0: return [4 /*yield*/, this.getConversationDetails()];
1991
- case 1:
1992
- liveWorkItemDetails = _a.sent();
1993
- if (Object.keys(liveWorkItemDetails).length === 0 || liveWorkItemDetails.state == LiveWorkItemState_1.default.WrapUp || liveWorkItemDetails.state == LiveWorkItemState_1.default.Closed) {
1994
- onAgentEndSessionCallback(event);
1995
- this.stopPolling();
1996
- }
1997
- return [2 /*return*/];
1998
- }
1999
- });
2000
- }); });
2001
- this.scenarioMarker.completeScenario(TelemetryEvent_1.default.OnAgentEndSession, {
2002
- RequestId: this.requestId,
2003
- ChatId: this.chatToken.chatId
2004
- });
2005
- }
2006
- catch (error) {
2007
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.OnAgentEndSession, {
2008
- RequestId: this.requestId,
2009
- ChatId: this.chatToken.chatId
2010
- });
2011
- }
2012
- }
2013
- else {
2014
- try {
2015
- (_a = this.conversation) === null || _a === void 0 ? void 0 : _a.registerOnThreadUpdate(function (message) {
2016
- var members = message.members;
2017
- // Agent ending conversation would have 1 member left in the chat thread
2018
- if (members.length === 1) {
2019
- onAgentEndSessionCallback(message);
2020
- if (_this.refreshTokenTimer !== null) {
2021
- clearInterval(_this.refreshTokenTimer);
2022
- _this.refreshTokenTimer = null;
2023
- }
1953
+ try {
1954
+ this.conversation.registerOnThreadUpdate(function (event) { return __awaiter(_this, void 0, void 0, function () {
1955
+ var liveWorkItemDetails;
1956
+ return __generator(this, function (_a) {
1957
+ switch (_a.label) {
1958
+ case 0: return [4 /*yield*/, this.getConversationDetails()];
1959
+ case 1:
1960
+ liveWorkItemDetails = _a.sent();
1961
+ if (Object.keys(liveWorkItemDetails).length === 0 || liveWorkItemDetails.state == LiveWorkItemState_1.default.WrapUp || liveWorkItemDetails.state == LiveWorkItemState_1.default.Closed) {
1962
+ onAgentEndSessionCallback(event);
1963
+ this.stopPolling();
1964
+ }
1965
+ return [2 /*return*/];
2024
1966
  }
2025
1967
  });
2026
- this.scenarioMarker.completeScenario(TelemetryEvent_1.default.OnAgentEndSession, {
2027
- RequestId: this.requestId,
2028
- ChatId: this.chatToken.chatId
2029
- });
2030
- }
2031
- catch (error) {
2032
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.OnAgentEndSession, {
2033
- RequestId: this.requestId,
2034
- ChatId: this.chatToken.chatId
2035
- });
2036
- }
1968
+ }); });
1969
+ this.scenarioMarker.completeScenario(TelemetryEvent_1.default.OnAgentEndSession, {
1970
+ RequestId: this.requestId,
1971
+ ChatId: this.chatToken.chatId
1972
+ });
1973
+ }
1974
+ catch (error) {
1975
+ this.scenarioMarker.failScenario(TelemetryEvent_1.default.OnAgentEndSession, {
1976
+ RequestId: this.requestId,
1977
+ ChatId: this.chatToken.chatId
1978
+ });
2037
1979
  }
2038
1980
  return [2 /*return*/];
2039
1981
  });
@@ -2041,7 +1983,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2041
1983
  };
2042
1984
  OmnichannelChatSDK.prototype.uploadFileAttachment = function (fileInfo) {
2043
1985
  return __awaiter(this, void 0, void 0, function () {
2044
- var amsClient, createObjectResponse, documentId, uploadDocumentResponse, fileIdsProperty, fileMetaProperty, sendMessageRequest, messageToSend, error_20, fileMetadata, messageToSend, error_21;
1986
+ var amsClient, createObjectResponse, documentId, uploadDocumentResponse, fileIdsProperty, fileMetaProperty, sendMessageRequest, messageToSend, error_19, fileMetadata, messageToSend, error_20;
2045
1987
  var _a, _b;
2046
1988
  return __generator(this, function (_c) {
2047
1989
  switch (_c.label) {
@@ -2110,7 +2052,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2110
2052
  });
2111
2053
  return [2 /*return*/, messageToSend];
2112
2054
  case 6:
2113
- error_20 = _c.sent();
2055
+ error_19 = _c.sent();
2114
2056
  console.error("OmnichannelChatSDK/uploadFileAttachment/sendMessage/error");
2115
2057
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
2116
2058
  RequestId: this.requestId,
@@ -2156,8 +2098,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
2156
2098
  });
2157
2099
  return [2 /*return*/, messageToSend];
2158
2100
  case 15:
2159
- error_21 = _c.sent();
2160
- console.error("OmnichannelChatSDK/uploadFileAttachment/error: ".concat(error_21));
2101
+ error_20 = _c.sent();
2102
+ console.error("OmnichannelChatSDK/uploadFileAttachment/error: ".concat(error_20));
2161
2103
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
2162
2104
  RequestId: this.requestId,
2163
2105
  ChatId: this.chatToken.chatId
@@ -2170,7 +2112,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2170
2112
  };
2171
2113
  OmnichannelChatSDK.prototype.downloadFileAttachment = function (fileMetadata) {
2172
2114
  return __awaiter(this, void 0, void 0, function () {
2173
- var amsClient, response, view_location, viewResponse, _a, downloadedFile, error_22;
2115
+ var amsClient, response, view_location, viewResponse, _a, downloadedFile, error_21;
2174
2116
  return __generator(this, function (_b) {
2175
2117
  switch (_b.label) {
2176
2118
  case 0:
@@ -2230,8 +2172,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
2230
2172
  });
2231
2173
  return [2 /*return*/, downloadedFile];
2232
2174
  case 9:
2233
- error_22 = _b.sent();
2234
- console.error("OmnichannelChatSDK/downloadFileAttachment/error: ".concat(error_22));
2175
+ error_21 = _b.sent();
2176
+ console.error("OmnichannelChatSDK/downloadFileAttachment/error: ".concat(error_21));
2235
2177
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
2236
2178
  RequestId: this.requestId,
2237
2179
  ChatId: this.chatToken.chatId
@@ -2244,7 +2186,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2244
2186
  };
2245
2187
  OmnichannelChatSDK.prototype.emailLiveChatTranscript = function (body_1) {
2246
2188
  return __awaiter(this, arguments, void 0, function (body, optionalParams) {
2247
- var emailTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, emailRequestBody, error_23;
2189
+ var emailTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, emailRequestBody, error_22;
2248
2190
  var _a;
2249
2191
  if (optionalParams === void 0) { optionalParams = {}; }
2250
2192
  return __generator(this, function (_b) {
@@ -2295,8 +2237,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
2295
2237
  });
2296
2238
  return [3 /*break*/, 4];
2297
2239
  case 3:
2298
- error_23 = _b.sent();
2299
- console.error("OmnichannelChatSDK/emailLiveChatTranscript/error: ".concat(error_23));
2240
+ error_22 = _b.sent();
2241
+ console.error("OmnichannelChatSDK/emailLiveChatTranscript/error: ".concat(error_22));
2300
2242
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.EmailLiveChatTranscript, {
2301
2243
  RequestId: requestId,
2302
2244
  ChatId: chatId
@@ -2309,7 +2251,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2309
2251
  };
2310
2252
  OmnichannelChatSDK.prototype.getLiveChatTranscript = function () {
2311
2253
  return __awaiter(this, arguments, void 0, function (optionalParams) {
2312
- var getChatTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, transcriptResponse, error_24, telemetryData;
2254
+ var getChatTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, transcriptResponse, error_23, telemetryData;
2313
2255
  var _a, _b;
2314
2256
  if (optionalParams === void 0) { optionalParams = {}; }
2315
2257
  return __generator(this, function (_c) {
@@ -2366,12 +2308,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
2366
2308
  });
2367
2309
  return [2 /*return*/, transcriptResponse];
2368
2310
  case 3:
2369
- error_24 = _c.sent();
2311
+ error_23 = _c.sent();
2370
2312
  telemetryData = {
2371
2313
  RequestId: requestId,
2372
2314
  ChatId: chatId
2373
2315
  };
2374
- exceptionThrowers_1.default.throwLiveChatTranscriptRetrievalFailure(error_24, this.scenarioMarker, TelemetryEvent_1.default.GetLiveChatTranscript, telemetryData);
2316
+ exceptionThrowers_1.default.throwLiveChatTranscriptRetrievalFailure(error_23, this.scenarioMarker, TelemetryEvent_1.default.GetLiveChatTranscript, telemetryData);
2375
2317
  return [3 /*break*/, 4];
2376
2318
  case 4: return [2 /*return*/];
2377
2319
  }
@@ -2823,12 +2765,26 @@ var OmnichannelChatSDK = /** @class */ (function () {
2823
2765
  regex: value
2824
2766
  });
2825
2767
  }
2768
+ this.compileDataMaskingRegex();
2826
2769
  }
2827
2770
  }
2828
2771
  return [2 /*return*/];
2829
2772
  });
2830
2773
  });
2831
2774
  };
2775
+ OmnichannelChatSDK.prototype.compileDataMaskingRegex = function () {
2776
+ this.regexCompiledForDataMasking = [];
2777
+ for (var _i = 0, _a = this.dataMaskingRules.rules; _i < _a.length; _i++) {
2778
+ var rule = _a[_i];
2779
+ try {
2780
+ var regex = new RegExp(rule.regex, 'g');
2781
+ this.regexCompiledForDataMasking.push(regex);
2782
+ }
2783
+ catch (e) {
2784
+ console.error("Error compiling regex for data masking rule id ".concat(rule.id, ": ").concat(e));
2785
+ }
2786
+ }
2787
+ };
2832
2788
  OmnichannelChatSDK.prototype.setAuthSettingConfig = function (authSettings) {
2833
2789
  return __awaiter(this, void 0, void 0, function () {
2834
2790
  return __generator(this, function (_a) {
@@ -2907,7 +2863,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2907
2863
  };
2908
2864
  OmnichannelChatSDK.prototype.getChatConfig = function () {
2909
2865
  return __awaiter(this, arguments, void 0, function (optionalParams) {
2910
- var sendCacheHeaders, bypassCache, liveChatConfig, error_25, _a;
2866
+ var sendCacheHeaders, bypassCache, liveChatConfig, error_24, _a;
2911
2867
  var _b, _c;
2912
2868
  if (optionalParams === void 0) { optionalParams = {}; }
2913
2869
  return __generator(this, function (_d) {
@@ -2928,8 +2884,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
2928
2884
  this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] ".concat(this.liveChatVersion));
2929
2885
  return [2 /*return*/, this.liveChatConfig];
2930
2886
  case 3:
2931
- error_25 = _d.sent();
2932
- if (!(0, internalUtils_1.isCoreServicesOrgUrlDNSError)(error_25, this.coreServicesOrgUrl, this.dynamicsLocationCode)) return [3 /*break*/, 6];
2887
+ error_24 = _d.sent();
2888
+ if (!(0, internalUtils_1.isCoreServicesOrgUrlDNSError)(error_24, this.coreServicesOrgUrl, this.dynamicsLocationCode)) return [3 /*break*/, 6];
2933
2889
  this.omnichannelConfig.orgUrl = this.unqServicesOrgUrl;
2934
2890
  _a = this;
2935
2891
  return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, (0, createOcSDKConfiguration_1.default)(false), this.ocSdkLogger)];
@@ -2941,10 +2897,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
2941
2897
  return [3 /*break*/, 7];
2942
2898
  case 6:
2943
2899
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2944
- if (((_c = (_b = error_25.response) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c.errorcode) && parseInt(error_25.response.headers.errorcode) === OmnichannelErrorCodes_1.default.WidgetNotFound) {
2900
+ if (((_c = (_b = error_24.response) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c.errorcode) && parseInt(error_24.response.headers.errorcode) === OmnichannelErrorCodes_1.default.WidgetNotFound) {
2945
2901
  console.warn("No widget with the given app id is present in the system.");
2946
2902
  }
2947
- throw error_25; // Bubble up error by default to throw ChatConfigRetrievalFailure
2903
+ throw error_24; // Bubble up error by default to throw ChatConfigRetrievalFailure
2948
2904
  case 7: return [3 /*break*/, 8];
2949
2905
  case 8: return [2 /*return*/, this.liveChatConfig];
2950
2906
  }
@@ -2979,7 +2935,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2979
2935
  };
2980
2936
  OmnichannelChatSDK.prototype.updateChatToken = function (newToken, newRegionGTMS) {
2981
2937
  return __awaiter(this, void 0, void 0, function () {
2982
- var sessionInfo, error_26, exceptionDetails;
2938
+ var sessionInfo, error_25, exceptionDetails;
2983
2939
  return __generator(this, function (_a) {
2984
2940
  switch (_a.label) {
2985
2941
  case 0:
@@ -3007,7 +2963,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
3007
2963
  });
3008
2964
  return [3 /*break*/, 5];
3009
2965
  case 4:
3010
- error_26 = _a.sent();
2966
+ error_25 = _a.sent();
3011
2967
  exceptionDetails = {
3012
2968
  response: "UpdateChatTokenFailed"
3013
2969
  };
@@ -3024,7 +2980,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
3024
2980
  };
3025
2981
  OmnichannelChatSDK.prototype.setAuthTokenProvider = function (provider_1) {
3026
2982
  return __awaiter(this, arguments, void 0, function (provider, optionalParams) {
3027
- var token, exceptionDetails, error_27, exceptionDetails, exceptionDetails;
2983
+ var token, exceptionDetails, error_26, exceptionDetails, exceptionDetails;
3028
2984
  if (optionalParams === void 0) { optionalParams = {}; }
3029
2985
  return __generator(this, function (_a) {
3030
2986
  switch (_a.label) {
@@ -3056,12 +3012,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
3056
3012
  }
3057
3013
  return [3 /*break*/, 4];
3058
3014
  case 3:
3059
- error_27 = _a.sent();
3015
+ error_26 = _a.sent();
3060
3016
  exceptionDetails = {
3061
3017
  response: ChatSDKError_1.ChatSDKErrorName.GetAuthTokenFailed
3062
3018
  };
3063
- if (error_27.message == ChatSDKError_1.ChatSDKErrorName.UndefinedAuthToken) {
3064
- exceptionDetails.response = error_27.message;
3019
+ if (error_26.message == ChatSDKError_1.ChatSDKErrorName.UndefinedAuthToken) {
3020
+ exceptionDetails.response = error_26.message;
3065
3021
  }
3066
3022
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
3067
3023
  ExceptionDetails: JSON.stringify(exceptionDetails)
@@ -3154,6 +3110,67 @@ var OmnichannelChatSDK = /** @class */ (function () {
3154
3110
  });
3155
3111
  });
3156
3112
  };
3113
+ /**
3114
+ * Get persistent chat history for authenticated users.
3115
+ * @param getPersistentChatHistoryOptionalParams Optional parameters for persistent chat history retrieval.
3116
+ */
3117
+ OmnichannelChatSDK.prototype.getPersistentChatHistory = function () {
3118
+ return __awaiter(this, arguments, void 0, function (getPersistentChatHistoryOptionalParams) {
3119
+ var params, result, error_27, telemetryData;
3120
+ var _a, _b, _c, _d, _e;
3121
+ if (getPersistentChatHistoryOptionalParams === void 0) { getPersistentChatHistoryOptionalParams = {}; }
3122
+ return __generator(this, function (_f) {
3123
+ switch (_f.label) {
3124
+ case 0:
3125
+ if (!this.requestId) {
3126
+ this.requestId = (0, ocsdk_1.uuidv4)();
3127
+ }
3128
+ this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetPersistentChatHistory, {
3129
+ RequestId: this.requestId
3130
+ });
3131
+ if (!this.isInitialized) {
3132
+ exceptionThrowers_1.default.throwUninitializedChatSDK(this.scenarioMarker, TelemetryEvent_1.default.GetPersistentChatHistory);
3133
+ }
3134
+ if (!this.isPersistentChat || ((_a = this.chatSDKConfig.persistentChat) === null || _a === void 0 ? void 0 : _a.disable) === true) {
3135
+ exceptionThrowers_1.default.throwNotPersistentChatEnabled(this.scenarioMarker, TelemetryEvent_1.default.GetPersistentChatHistory, {
3136
+ RequestId: this.requestId,
3137
+ ChatId: (_b = this.chatToken) === null || _b === void 0 ? void 0 : _b.chatId
3138
+ });
3139
+ }
3140
+ if (!this.authenticatedUserToken) {
3141
+ exceptionThrowers_1.default.throwChatSDKError(ChatSDKError_1.ChatSDKErrorName.AuthenticatedUserTokenNotFound, new Error('Authenticated user token not found'), this.scenarioMarker, TelemetryEvent_1.default.GetPersistentChatHistory, {
3142
+ RequestId: this.requestId,
3143
+ ChatId: (_c = this.chatToken) === null || _c === void 0 ? void 0 : _c.chatId
3144
+ });
3145
+ }
3146
+ _f.label = 1;
3147
+ case 1:
3148
+ _f.trys.push([1, 3, , 4]);
3149
+ params = {};
3150
+ params.pageSize = getPersistentChatHistoryOptionalParams.pageSize || undefined;
3151
+ params.pageToken = getPersistentChatHistoryOptionalParams.pageToken || undefined;
3152
+ return [4 /*yield*/, this.OCClient.getPersistentChatHistory(this.requestId, __assign(__assign({}, params), { authenticatedUserToken: this.authenticatedUserToken }))];
3153
+ case 2:
3154
+ result = _f.sent();
3155
+ this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetPersistentChatHistory, {
3156
+ RequestId: this.requestId,
3157
+ ChatId: (_d = this.chatToken) === null || _d === void 0 ? void 0 : _d.chatId
3158
+ });
3159
+ return [2 /*return*/, result];
3160
+ case 3:
3161
+ error_27 = _f.sent();
3162
+ telemetryData = {
3163
+ RequestId: this.requestId,
3164
+ ChatId: (_e = this.chatToken) === null || _e === void 0 ? void 0 : _e.chatId,
3165
+ ErrorMessage: (error_27 === null || error_27 === void 0 ? void 0 : error_27.message) || 'Unknown error' // Added error message for better debugging
3166
+ };
3167
+ exceptionThrowers_1.default.throwPersistentChatConversationRetrievalFailure(error_27, this.scenarioMarker, TelemetryEvent_1.default.GetPersistentChatHistory, telemetryData);
3168
+ return [3 /*break*/, 4];
3169
+ case 4: return [2 /*return*/];
3170
+ }
3171
+ });
3172
+ });
3173
+ };
3157
3174
  return OmnichannelChatSDK;
3158
3175
  }());
3159
3176
  exports.default = OmnichannelChatSDK;