@microsoft/omnichannel-chat-sdk 1.11.2-main.9c92d7e → 1.11.3-main.12b9a51

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.
package/README.md CHANGED
@@ -150,7 +150,11 @@ npm install @microsoft/omnichannel-chat-sdk --save
150
150
 
151
151
  ## Installation on React Native
152
152
 
153
- The following steps will be required to run Omnichannel Chat SDK on React Native:
153
+ ***Important Note:***
154
+ - For React Native versions **0.71 and above**: Steps 1, 2, 3 are **required only for iOS**. Not needed for Android.
155
+ - For React Native versions **below 0.71**: Steps 1, 2, 3 are **required for both Android and iOS**.
156
+
157
+ ### Steps
154
158
 
155
159
  1. Install `node-libs-react-native`
156
160
 
@@ -158,46 +162,69 @@ The following steps will be required to run Omnichannel Chat SDK on React Native
158
162
  npm install node-libs-react-native --save-dev
159
163
  ```
160
164
 
161
- 1. Install `react-native-randomBytes`
162
-
165
+ 2. Install `react-native-randombytes`
163
166
  ```console
164
167
  npm install react-native-randombytes --save-dev
165
168
  ```
166
169
 
167
- 1. Install `react-native-get-random-values`
168
-
170
+ 3. Install `react-native-get-random-values`
169
171
  ```console
170
172
  npm install react-native-get-random-values --save-dev
171
173
  ```
172
-
173
- 1. Install `react-native-url-polyfill`
174
+
175
+ 4. Install `react-native-url-polyfill`
174
176
 
175
177
  ```console
176
178
  npm install react-native-url-polyfill --save-dev
177
179
  ```
178
180
 
179
- 1. Install `@azure/core-asynciterator-polyfill`
181
+ 5. Install `@azure/core-asynciterator-polyfill`
180
182
 
181
183
  ```console
182
184
  npm install @azure/core-asynciterator-polyfill --save-dev
183
185
  ```
184
-
185
- 1. Update *metro.config.js* to use React Native compatible Node Core modules
186
-
186
+ **iOS and Android Platforms**
187
+
188
+ | React Native Version | Libraries | iOS | Android |
189
+ | ----------------------- | -------------------------------- | --------- | ----------- |
190
+ | 0.71 and above | | | |
191
+ | | node-libs-react-native | ✅ Yes | ❌ No |
192
+ | | react-native-randombytes | ✅ Yes | ❌ No |
193
+ | | react-native-get-random-values | ✅ Yes | ❌ No |
194
+ | | react-native-url-polyfill | ✅ Yes | ✅ Yes |
195
+ | | @azure/core-asynciterator-polyfill | ✅ Yes | ✅ Yes |
196
+
197
+ Below 0.71 version you need to add all above libraries.
198
+
199
+ **Required file changes**
200
+ 1. In metro.config.js
201
+ - Update *metro.config.js* to use React Native compatible Node Core modules.
187
202
  ```ts
188
- module.exports = {
189
- // ...
190
- resolver: {
191
- extraNodeModules: {
192
- ...require('node-libs-react-native'),
193
- net: require.resolve('node-libs-react-native/mock/net'),
194
- tls: require.resolve('node-libs-react-native/mock/tls')
195
- }
196
- }
203
+ const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
204
+ const nodeLibs = require('node-libs-react-native'); // Import node-libs-react-native
205
+ const config = {
206
+ resolver: {
207
+ extraNodeModules: {
208
+ ...nodeLibs,
209
+ net: require.resolve('node-libs-react-native/mock/net'),
210
+ tls: require.resolve('node-libs-react-native/mock/tls'),
211
+ },
212
+ },
197
213
  };
198
214
  ```
199
-
200
- 1. Add the following *import* on top of your entry point file
215
+ - If you encounter a crypto issue for iOS (e.g. error "crypto.getRandomValues() not supported") you should install crypto-browserify and stream-browserify, then add the following lines to your *metro.config.js* file.
216
+
217
+ ```ts
218
+ const config = {
219
+ resolver: {
220
+ extraNodeModules: {
221
+ crypto: require.resolve("crypto-browserify"),
222
+ stream: require.resolve("stream-browserify"),
223
+ },
224
+ },
225
+ };
226
+ ```
227
+ 2. Add the following *import* on top of your entry point file
201
228
 
202
229
  ```ts
203
230
  import 'node-libs-react-native/globals';
@@ -409,7 +409,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
409
409
  this.AMSClientLoadCurrentState = AMSClientLoadStates_1.AMSClientLoadStates.LOADING;
410
410
  this.debug && console.time("ams_creation");
411
411
  disableAMSWhitelistedUrls = ((_c = (_b = this.chatSDKConfig) === null || _b === void 0 ? void 0 : _b.internalConfig) === null || _c === void 0 ? void 0 : _c.disableAMSWhitelistedUrls) !== false;
412
- disableAMSRegionBasedUrl = ((_e = (_d = this.chatSDKConfig) === null || _d === void 0 ? void 0 : _d.internalConfig) === null || _e === void 0 ? void 0 : _e.disableAMSRegionBasedUrl) !== false;
412
+ disableAMSRegionBasedUrl = ((_e = (_d = this.chatSDKConfig) === null || _d === void 0 ? void 0 : _d.internalConfig) === null || _e === void 0 ? void 0 : _e.disableAMSRegionBasedUrl) === true;
413
413
  framedMode = (0, AMSClientUtils_1.shouldUseFramedMode)(disableAMSWhitelistedUrls);
414
414
  _a = this;
415
415
  return [4 /*yield*/, (0, omnichannel_amsclient_1.default)({
@@ -475,7 +475,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
475
475
  // We will keep this logic for backward compatibility for customers with unknown implementation, so they can test before fully adoption
476
476
  OmnichannelChatSDK.prototype.sequentialInitialization = function () {
477
477
  return __awaiter(this, arguments, void 0, function (optionalParams) {
478
- var useCoreServices, _a, e_2, getLiveChatConfigOptionalParams, e_3, supportedLiveChatVersions, disableAMSWhitelistedUrls, disableAMSRegionBasedUrl, _b, _c, e_4;
478
+ var useCoreServices, _a, e_2, getLiveChatConfigOptionalParams, e_3, supportedLiveChatVersions, disableAMSWhitelistedUrls, disableAMSRegionBasedUrl, framedMode, _b, _c, e_4;
479
479
  var _d, _e, _f, _g, _h;
480
480
  if (optionalParams === void 0) { optionalParams = {}; }
481
481
  return __generator(this, function (_j) {
@@ -526,15 +526,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
526
526
  if (!(this.isAMSClientAllowed && this.AMSClientLoadCurrentState === AMSClientLoadStates_1.AMSClientLoadStates.NOT_LOADED)) return [3 /*break*/, 10];
527
527
  this.AMSClientLoadCurrentState = AMSClientLoadStates_1.AMSClientLoadStates.LOADING;
528
528
  this.debug && console.time("ams_seq_creation");
529
- disableAMSWhitelistedUrls = ((_f = (_e = this.chatSDKConfig) === null || _e === void 0 ? void 0 : _e.internalConfig) === null || _f === void 0 ? void 0 : _f.disableAMSWhitelistedUrls) === false ? false : true;
530
- disableAMSRegionBasedUrl = ((_h = (_g = this.chatSDKConfig) === null || _g === void 0 ? void 0 : _g.internalConfig) === null || _h === void 0 ? void 0 : _h.disableAMSRegionBasedUrl) === false ? false : true;
529
+ disableAMSWhitelistedUrls = ((_f = (_e = this.chatSDKConfig) === null || _e === void 0 ? void 0 : _e.internalConfig) === null || _f === void 0 ? void 0 : _f.disableAMSWhitelistedUrls) !== false;
530
+ disableAMSRegionBasedUrl = ((_h = (_g = this.chatSDKConfig) === null || _g === void 0 ? void 0 : _g.internalConfig) === null || _h === void 0 ? void 0 : _h.disableAMSRegionBasedUrl) === true;
531
+ framedMode = (0, AMSClientUtils_1.shouldUseFramedMode)(disableAMSWhitelistedUrls);
531
532
  _b = this;
532
533
  return [4 /*yield*/, (0, omnichannel_amsclient_1.default)({
533
- framedMode: (0, AMSClientUtils_1.shouldUseFramedMode)(disableAMSWhitelistedUrls),
534
+ framedMode: framedMode,
534
535
  multiClient: true,
535
536
  debug: (this.detailedDebugEnabled ? this.debugAMS : this.debug),
536
537
  logger: this.amsClientLogger,
537
- baseUrl: (0, AMSClientUtils_1.shouldUseFramedMode)(disableAMSWhitelistedUrls) && !disableAMSRegionBasedUrl ? (0, AMSClientUtils_1.retrieveRegionBasedUrl)(this.widgetSnippetBaseUrl) : ''
538
+ baseUrl: framedMode && !disableAMSRegionBasedUrl ? (0, AMSClientUtils_1.retrieveRegionBasedUrl)(this.widgetSnippetBaseUrl) : ''
538
539
  })];
539
540
  case 9:
540
541
  _b.AMSClient = _j.sent();
@@ -1784,7 +1785,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1784
1785
  };
1785
1786
  OmnichannelChatSDK.prototype.sendTypingEvent = function () {
1786
1787
  return __awaiter(this, void 0, void 0, function () {
1787
- var error_17, typingPayload, members, botMembers, error_18;
1788
+ var error_17;
1788
1789
  return __generator(this, function (_a) {
1789
1790
  switch (_a.label) {
1790
1791
  case 0:
@@ -1795,7 +1796,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1795
1796
  if (!this.isInitialized) {
1796
1797
  exceptionThrowers_1.default.throwUninitializedChatSDK(this.scenarioMarker, TelemetryEvent_1.default.SendTypingEvent);
1797
1798
  }
1798
- if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 6];
1799
+ if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 5];
1799
1800
  _a.label = 1;
1800
1801
  case 1:
1801
1802
  _a.trys.push([1, 4, , 5]);
@@ -1819,35 +1820,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1819
1820
  ChatId: this.chatToken.chatId
1820
1821
  });
1821
1822
  throw new Error('SendTypingFailure');
1822
- case 5: return [3 /*break*/, 12];
1823
- case 6:
1824
- typingPayload = "{isTyping: 0}";
1825
- _a.label = 7;
1826
- case 7:
1827
- _a.trys.push([7, 11, , 12]);
1828
- return [4 /*yield*/, this.conversation.indicateTypingStatus(0)];
1829
- case 8:
1830
- _a.sent();
1831
- return [4 /*yield*/, this.conversation.getMembers()];
1832
- case 9:
1833
- members = _a.sent();
1834
- botMembers = members.filter(function (member) { return member.type === PersonType_1.default.Bot; });
1835
- return [4 /*yield*/, this.conversation.sendMessageToBot(botMembers[0].id, { payload: typingPayload })];
1836
- case 10:
1837
- _a.sent();
1838
- this.scenarioMarker.completeScenario(TelemetryEvent_1.default.SendTypingEvent, {
1839
- RequestId: this.requestId,
1840
- ChatId: this.chatToken.chatId
1841
- });
1842
- return [3 /*break*/, 12];
1843
- case 11:
1844
- error_18 = _a.sent();
1845
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendTypingEvent, {
1846
- RequestId: this.requestId,
1847
- ChatId: this.chatToken.chatId
1848
- });
1849
- throw new Error('SendTypingFailure');
1850
- case 12: return [2 /*return*/];
1823
+ case 5: return [2 /*return*/];
1851
1824
  }
1852
1825
  });
1853
1826
  });
@@ -1978,7 +1951,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1978
1951
  };
1979
1952
  OmnichannelChatSDK.prototype.uploadFileAttachment = function (fileInfo) {
1980
1953
  return __awaiter(this, void 0, void 0, function () {
1981
- var amsClient, createObjectResponse, documentId, uploadDocumentResponse, fileIdsProperty, fileMetaProperty, sendMessageRequest, messageToSend, error_19, fileMetadata, messageToSend, error_20;
1954
+ var amsClient, createObjectResponse, documentId, uploadDocumentResponse, fileIdsProperty, fileMetaProperty, sendMessageRequest, messageToSend, error_18, fileMetadata, messageToSend, error_19;
1982
1955
  var _a, _b;
1983
1956
  return __generator(this, function (_c) {
1984
1957
  switch (_c.label) {
@@ -2047,7 +2020,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2047
2020
  });
2048
2021
  return [2 /*return*/, messageToSend];
2049
2022
  case 6:
2050
- error_19 = _c.sent();
2023
+ error_18 = _c.sent();
2051
2024
  console.error("OmnichannelChatSDK/uploadFileAttachment/sendMessage/error");
2052
2025
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
2053
2026
  RequestId: this.requestId,
@@ -2093,8 +2066,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
2093
2066
  });
2094
2067
  return [2 /*return*/, messageToSend];
2095
2068
  case 15:
2096
- error_20 = _c.sent();
2097
- console.error("OmnichannelChatSDK/uploadFileAttachment/error: ".concat(error_20));
2069
+ error_19 = _c.sent();
2070
+ console.error("OmnichannelChatSDK/uploadFileAttachment/error: ".concat(error_19));
2098
2071
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
2099
2072
  RequestId: this.requestId,
2100
2073
  ChatId: this.chatToken.chatId
@@ -2107,7 +2080,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2107
2080
  };
2108
2081
  OmnichannelChatSDK.prototype.downloadFileAttachment = function (fileMetadata) {
2109
2082
  return __awaiter(this, void 0, void 0, function () {
2110
- var amsClient, response, view_location, viewResponse, _a, downloadedFile, error_21;
2083
+ var amsClient, response, view_location, viewResponse, _a, downloadedFile, error_20;
2111
2084
  return __generator(this, function (_b) {
2112
2085
  switch (_b.label) {
2113
2086
  case 0:
@@ -2167,8 +2140,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
2167
2140
  });
2168
2141
  return [2 /*return*/, downloadedFile];
2169
2142
  case 9:
2170
- error_21 = _b.sent();
2171
- console.error("OmnichannelChatSDK/downloadFileAttachment/error: ".concat(error_21));
2143
+ error_20 = _b.sent();
2144
+ console.error("OmnichannelChatSDK/downloadFileAttachment/error: ".concat(error_20));
2172
2145
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
2173
2146
  RequestId: this.requestId,
2174
2147
  ChatId: this.chatToken.chatId
@@ -2181,7 +2154,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2181
2154
  };
2182
2155
  OmnichannelChatSDK.prototype.emailLiveChatTranscript = function (body_1) {
2183
2156
  return __awaiter(this, arguments, void 0, function (body, optionalParams) {
2184
- var emailTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, emailRequestBody, error_22;
2157
+ var emailTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, emailRequestBody, error_21;
2185
2158
  var _a;
2186
2159
  if (optionalParams === void 0) { optionalParams = {}; }
2187
2160
  return __generator(this, function (_b) {
@@ -2232,8 +2205,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
2232
2205
  });
2233
2206
  return [3 /*break*/, 4];
2234
2207
  case 3:
2235
- error_22 = _b.sent();
2236
- console.error("OmnichannelChatSDK/emailLiveChatTranscript/error: ".concat(error_22));
2208
+ error_21 = _b.sent();
2209
+ console.error("OmnichannelChatSDK/emailLiveChatTranscript/error: ".concat(error_21));
2237
2210
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.EmailLiveChatTranscript, {
2238
2211
  RequestId: requestId,
2239
2212
  ChatId: chatId
@@ -2246,7 +2219,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2246
2219
  };
2247
2220
  OmnichannelChatSDK.prototype.getLiveChatTranscript = function () {
2248
2221
  return __awaiter(this, arguments, void 0, function (optionalParams) {
2249
- var getChatTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, transcriptResponse, error_23, telemetryData;
2222
+ var getChatTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, transcriptResponse, error_22, telemetryData;
2250
2223
  var _a, _b;
2251
2224
  if (optionalParams === void 0) { optionalParams = {}; }
2252
2225
  return __generator(this, function (_c) {
@@ -2303,12 +2276,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
2303
2276
  });
2304
2277
  return [2 /*return*/, transcriptResponse];
2305
2278
  case 3:
2306
- error_23 = _c.sent();
2279
+ error_22 = _c.sent();
2307
2280
  telemetryData = {
2308
2281
  RequestId: requestId,
2309
2282
  ChatId: chatId
2310
2283
  };
2311
- exceptionThrowers_1.default.throwLiveChatTranscriptRetrievalFailure(error_23, this.scenarioMarker, TelemetryEvent_1.default.GetLiveChatTranscript, telemetryData);
2284
+ exceptionThrowers_1.default.throwLiveChatTranscriptRetrievalFailure(error_22, this.scenarioMarker, TelemetryEvent_1.default.GetLiveChatTranscript, telemetryData);
2312
2285
  return [3 /*break*/, 4];
2313
2286
  case 4: return [2 /*return*/];
2314
2287
  }
@@ -2830,7 +2803,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2830
2803
  };
2831
2804
  OmnichannelChatSDK.prototype.getChatConfig = function () {
2832
2805
  return __awaiter(this, arguments, void 0, function (optionalParams) {
2833
- var sendCacheHeaders, bypassCache, liveChatConfig, error_24, _a;
2806
+ var sendCacheHeaders, bypassCache, liveChatConfig, error_23, _a;
2834
2807
  var _b, _c;
2835
2808
  if (optionalParams === void 0) { optionalParams = {}; }
2836
2809
  return __generator(this, function (_d) {
@@ -2851,8 +2824,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
2851
2824
  this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] ".concat(this.liveChatVersion));
2852
2825
  return [2 /*return*/, this.liveChatConfig];
2853
2826
  case 3:
2854
- error_24 = _d.sent();
2855
- if (!(0, internalUtils_1.isCoreServicesOrgUrlDNSError)(error_24, this.coreServicesOrgUrl, this.dynamicsLocationCode)) return [3 /*break*/, 6];
2827
+ error_23 = _d.sent();
2828
+ if (!(0, internalUtils_1.isCoreServicesOrgUrlDNSError)(error_23, this.coreServicesOrgUrl, this.dynamicsLocationCode)) return [3 /*break*/, 6];
2856
2829
  this.omnichannelConfig.orgUrl = this.unqServicesOrgUrl;
2857
2830
  _a = this;
2858
2831
  return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, (0, createOcSDKConfiguration_1.default)(false), this.ocSdkLogger)];
@@ -2864,10 +2837,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
2864
2837
  return [3 /*break*/, 7];
2865
2838
  case 6:
2866
2839
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2867
- 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) {
2840
+ 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) {
2868
2841
  console.warn("No widget with the given app id is present in the system.");
2869
2842
  }
2870
- throw error_24; // Bubble up error by default to throw ChatConfigRetrievalFailure
2843
+ throw error_23; // Bubble up error by default to throw ChatConfigRetrievalFailure
2871
2844
  case 7: return [3 /*break*/, 8];
2872
2845
  case 8: return [2 /*return*/, this.liveChatConfig];
2873
2846
  }
@@ -2902,7 +2875,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2902
2875
  };
2903
2876
  OmnichannelChatSDK.prototype.updateChatToken = function (newToken, newRegionGTMS) {
2904
2877
  return __awaiter(this, void 0, void 0, function () {
2905
- var sessionInfo, error_25, exceptionDetails;
2878
+ var sessionInfo, error_24, exceptionDetails;
2906
2879
  return __generator(this, function (_a) {
2907
2880
  switch (_a.label) {
2908
2881
  case 0:
@@ -2930,7 +2903,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2930
2903
  });
2931
2904
  return [3 /*break*/, 5];
2932
2905
  case 4:
2933
- error_25 = _a.sent();
2906
+ error_24 = _a.sent();
2934
2907
  exceptionDetails = {
2935
2908
  response: "UpdateChatTokenFailed"
2936
2909
  };
@@ -2947,7 +2920,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2947
2920
  };
2948
2921
  OmnichannelChatSDK.prototype.setAuthTokenProvider = function (provider_1) {
2949
2922
  return __awaiter(this, arguments, void 0, function (provider, optionalParams) {
2950
- var token, exceptionDetails, error_26, exceptionDetails, exceptionDetails;
2923
+ var token, exceptionDetails, error_25, exceptionDetails, exceptionDetails;
2951
2924
  if (optionalParams === void 0) { optionalParams = {}; }
2952
2925
  return __generator(this, function (_a) {
2953
2926
  switch (_a.label) {
@@ -2979,12 +2952,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
2979
2952
  }
2980
2953
  return [3 /*break*/, 4];
2981
2954
  case 3:
2982
- error_26 = _a.sent();
2955
+ error_25 = _a.sent();
2983
2956
  exceptionDetails = {
2984
2957
  response: ChatSDKError_1.ChatSDKErrorName.GetAuthTokenFailed
2985
2958
  };
2986
- if (error_26.message == ChatSDKError_1.ChatSDKErrorName.UndefinedAuthToken) {
2987
- exceptionDetails.response = error_26.message;
2959
+ if (error_25.message == ChatSDKError_1.ChatSDKErrorName.UndefinedAuthToken) {
2960
+ exceptionDetails.response = error_25.message;
2988
2961
  }
2989
2962
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
2990
2963
  ExceptionDetails: JSON.stringify(exceptionDetails)