@microsoft/omnichannel-chat-sdk 1.11.3-main.9b6b5bc → 1.11.3-main.9c4974d
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 +45 -29
- package/lib/OmnichannelChatSDK.js +27 -55
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
@@ -150,16 +150,16 @@ npm install @microsoft/omnichannel-chat-sdk --save
|
|
150
150
|
|
151
151
|
## Installation on React Native
|
152
152
|
|
153
|
-
|
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.
|
154
155
|
- For React Native versions **below 0.71**: Steps 1, 2, 3 are **required for both Android and iOS**.
|
155
|
-
|
156
|
-
|
156
|
+
|
157
157
|
### Steps
|
158
158
|
|
159
|
-
1. Install `react-native
|
159
|
+
1. Install `node-libs-react-native`
|
160
160
|
|
161
161
|
```console
|
162
|
-
npm install react-native
|
162
|
+
npm install node-libs-react-native --save-dev
|
163
163
|
```
|
164
164
|
|
165
165
|
2. Install `react-native-randombytes`
|
@@ -171,16 +171,7 @@ npm install @microsoft/omnichannel-chat-sdk --save
|
|
171
171
|
```console
|
172
172
|
npm install react-native-get-random-values --save-dev
|
173
173
|
```
|
174
|
-
|
175
|
-
**Summary Table:**
|
176
|
-
|
177
|
-
| React Native Version | Platform | Are these steps required? |
|
178
|
-
|-------------------------|-----------|--------------------------|
|
179
|
-
| Below 0.71 | Android | ✅ Yes |
|
180
|
-
| Below 0.71 | iOS | ✅ Yes |
|
181
|
-
| 0.71 and above | Android | ❌ No |
|
182
|
-
| 0.71 and above | iOS | ✅ Yes |
|
183
|
-
|
174
|
+
|
184
175
|
4. Install `react-native-url-polyfill`
|
185
176
|
|
186
177
|
```console
|
@@ -192,23 +183,48 @@ npm install @microsoft/omnichannel-chat-sdk --save
|
|
192
183
|
```console
|
193
184
|
npm install @azure/core-asynciterator-polyfill --save-dev
|
194
185
|
```
|
195
|
-
|
196
|
-
|
197
|
-
|
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.
|
198
202
|
```ts
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
}
|
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
|
+
},
|
208
213
|
};
|
209
214
|
```
|
210
|
-
|
211
|
-
|
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
|
212
228
|
|
213
229
|
```ts
|
214
230
|
import 'node-libs-react-native/globals';
|
@@ -1785,7 +1785,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1785
1785
|
};
|
1786
1786
|
OmnichannelChatSDK.prototype.sendTypingEvent = function () {
|
1787
1787
|
return __awaiter(this, void 0, void 0, function () {
|
1788
|
-
var error_17
|
1788
|
+
var error_17;
|
1789
1789
|
return __generator(this, function (_a) {
|
1790
1790
|
switch (_a.label) {
|
1791
1791
|
case 0:
|
@@ -1796,7 +1796,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1796
1796
|
if (!this.isInitialized) {
|
1797
1797
|
exceptionThrowers_1.default.throwUninitializedChatSDK(this.scenarioMarker, TelemetryEvent_1.default.SendTypingEvent);
|
1798
1798
|
}
|
1799
|
-
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/,
|
1799
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 5];
|
1800
1800
|
_a.label = 1;
|
1801
1801
|
case 1:
|
1802
1802
|
_a.trys.push([1, 4, , 5]);
|
@@ -1820,35 +1820,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1820
1820
|
ChatId: this.chatToken.chatId
|
1821
1821
|
});
|
1822
1822
|
throw new Error('SendTypingFailure');
|
1823
|
-
case 5: return [
|
1824
|
-
case 6:
|
1825
|
-
typingPayload = "{isTyping: 0}";
|
1826
|
-
_a.label = 7;
|
1827
|
-
case 7:
|
1828
|
-
_a.trys.push([7, 11, , 12]);
|
1829
|
-
return [4 /*yield*/, this.conversation.indicateTypingStatus(0)];
|
1830
|
-
case 8:
|
1831
|
-
_a.sent();
|
1832
|
-
return [4 /*yield*/, this.conversation.getMembers()];
|
1833
|
-
case 9:
|
1834
|
-
members = _a.sent();
|
1835
|
-
botMembers = members.filter(function (member) { return member.type === PersonType_1.default.Bot; });
|
1836
|
-
return [4 /*yield*/, this.conversation.sendMessageToBot(botMembers[0].id, { payload: typingPayload })];
|
1837
|
-
case 10:
|
1838
|
-
_a.sent();
|
1839
|
-
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.SendTypingEvent, {
|
1840
|
-
RequestId: this.requestId,
|
1841
|
-
ChatId: this.chatToken.chatId
|
1842
|
-
});
|
1843
|
-
return [3 /*break*/, 12];
|
1844
|
-
case 11:
|
1845
|
-
error_18 = _a.sent();
|
1846
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.SendTypingEvent, {
|
1847
|
-
RequestId: this.requestId,
|
1848
|
-
ChatId: this.chatToken.chatId
|
1849
|
-
});
|
1850
|
-
throw new Error('SendTypingFailure');
|
1851
|
-
case 12: return [2 /*return*/];
|
1823
|
+
case 5: return [2 /*return*/];
|
1852
1824
|
}
|
1853
1825
|
});
|
1854
1826
|
});
|
@@ -1979,7 +1951,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1979
1951
|
};
|
1980
1952
|
OmnichannelChatSDK.prototype.uploadFileAttachment = function (fileInfo) {
|
1981
1953
|
return __awaiter(this, void 0, void 0, function () {
|
1982
|
-
var amsClient, createObjectResponse, documentId, uploadDocumentResponse, fileIdsProperty, fileMetaProperty, sendMessageRequest, messageToSend,
|
1954
|
+
var amsClient, createObjectResponse, documentId, uploadDocumentResponse, fileIdsProperty, fileMetaProperty, sendMessageRequest, messageToSend, error_18, fileMetadata, messageToSend, error_19;
|
1983
1955
|
var _a, _b;
|
1984
1956
|
return __generator(this, function (_c) {
|
1985
1957
|
switch (_c.label) {
|
@@ -2048,7 +2020,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2048
2020
|
});
|
2049
2021
|
return [2 /*return*/, messageToSend];
|
2050
2022
|
case 6:
|
2051
|
-
|
2023
|
+
error_18 = _c.sent();
|
2052
2024
|
console.error("OmnichannelChatSDK/uploadFileAttachment/sendMessage/error");
|
2053
2025
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
|
2054
2026
|
RequestId: this.requestId,
|
@@ -2094,8 +2066,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2094
2066
|
});
|
2095
2067
|
return [2 /*return*/, messageToSend];
|
2096
2068
|
case 15:
|
2097
|
-
|
2098
|
-
console.error("OmnichannelChatSDK/uploadFileAttachment/error: ".concat(
|
2069
|
+
error_19 = _c.sent();
|
2070
|
+
console.error("OmnichannelChatSDK/uploadFileAttachment/error: ".concat(error_19));
|
2099
2071
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.UploadFileAttachment, {
|
2100
2072
|
RequestId: this.requestId,
|
2101
2073
|
ChatId: this.chatToken.chatId
|
@@ -2108,7 +2080,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2108
2080
|
};
|
2109
2081
|
OmnichannelChatSDK.prototype.downloadFileAttachment = function (fileMetadata) {
|
2110
2082
|
return __awaiter(this, void 0, void 0, function () {
|
2111
|
-
var amsClient, response, view_location, viewResponse, _a, downloadedFile,
|
2083
|
+
var amsClient, response, view_location, viewResponse, _a, downloadedFile, error_20;
|
2112
2084
|
return __generator(this, function (_b) {
|
2113
2085
|
switch (_b.label) {
|
2114
2086
|
case 0:
|
@@ -2168,8 +2140,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2168
2140
|
});
|
2169
2141
|
return [2 /*return*/, downloadedFile];
|
2170
2142
|
case 9:
|
2171
|
-
|
2172
|
-
console.error("OmnichannelChatSDK/downloadFileAttachment/error: ".concat(
|
2143
|
+
error_20 = _b.sent();
|
2144
|
+
console.error("OmnichannelChatSDK/downloadFileAttachment/error: ".concat(error_20));
|
2173
2145
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.DownloadFileAttachment, {
|
2174
2146
|
RequestId: this.requestId,
|
2175
2147
|
ChatId: this.chatToken.chatId
|
@@ -2182,7 +2154,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2182
2154
|
};
|
2183
2155
|
OmnichannelChatSDK.prototype.emailLiveChatTranscript = function (body_1) {
|
2184
2156
|
return __awaiter(this, arguments, void 0, function (body, optionalParams) {
|
2185
|
-
var emailTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, emailRequestBody,
|
2157
|
+
var emailTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, emailRequestBody, error_21;
|
2186
2158
|
var _a;
|
2187
2159
|
if (optionalParams === void 0) { optionalParams = {}; }
|
2188
2160
|
return __generator(this, function (_b) {
|
@@ -2233,8 +2205,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2233
2205
|
});
|
2234
2206
|
return [3 /*break*/, 4];
|
2235
2207
|
case 3:
|
2236
|
-
|
2237
|
-
console.error("OmnichannelChatSDK/emailLiveChatTranscript/error: ".concat(
|
2208
|
+
error_21 = _b.sent();
|
2209
|
+
console.error("OmnichannelChatSDK/emailLiveChatTranscript/error: ".concat(error_21));
|
2238
2210
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.EmailLiveChatTranscript, {
|
2239
2211
|
RequestId: requestId,
|
2240
2212
|
ChatId: chatId
|
@@ -2247,7 +2219,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2247
2219
|
};
|
2248
2220
|
OmnichannelChatSDK.prototype.getLiveChatTranscript = function () {
|
2249
2221
|
return __awaiter(this, arguments, void 0, function (optionalParams) {
|
2250
|
-
var getChatTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, transcriptResponse,
|
2222
|
+
var getChatTranscriptOptionalParams, requestId, chatToken, chatId, sessionId, transcriptResponse, error_22, telemetryData;
|
2251
2223
|
var _a, _b;
|
2252
2224
|
if (optionalParams === void 0) { optionalParams = {}; }
|
2253
2225
|
return __generator(this, function (_c) {
|
@@ -2304,12 +2276,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2304
2276
|
});
|
2305
2277
|
return [2 /*return*/, transcriptResponse];
|
2306
2278
|
case 3:
|
2307
|
-
|
2279
|
+
error_22 = _c.sent();
|
2308
2280
|
telemetryData = {
|
2309
2281
|
RequestId: requestId,
|
2310
2282
|
ChatId: chatId
|
2311
2283
|
};
|
2312
|
-
exceptionThrowers_1.default.throwLiveChatTranscriptRetrievalFailure(
|
2284
|
+
exceptionThrowers_1.default.throwLiveChatTranscriptRetrievalFailure(error_22, this.scenarioMarker, TelemetryEvent_1.default.GetLiveChatTranscript, telemetryData);
|
2313
2285
|
return [3 /*break*/, 4];
|
2314
2286
|
case 4: return [2 /*return*/];
|
2315
2287
|
}
|
@@ -2831,7 +2803,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2831
2803
|
};
|
2832
2804
|
OmnichannelChatSDK.prototype.getChatConfig = function () {
|
2833
2805
|
return __awaiter(this, arguments, void 0, function (optionalParams) {
|
2834
|
-
var sendCacheHeaders, bypassCache, liveChatConfig,
|
2806
|
+
var sendCacheHeaders, bypassCache, liveChatConfig, error_23, _a;
|
2835
2807
|
var _b, _c;
|
2836
2808
|
if (optionalParams === void 0) { optionalParams = {}; }
|
2837
2809
|
return __generator(this, function (_d) {
|
@@ -2852,8 +2824,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2852
2824
|
this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] ".concat(this.liveChatVersion));
|
2853
2825
|
return [2 /*return*/, this.liveChatConfig];
|
2854
2826
|
case 3:
|
2855
|
-
|
2856
|
-
if (!(0, internalUtils_1.isCoreServicesOrgUrlDNSError)(
|
2827
|
+
error_23 = _d.sent();
|
2828
|
+
if (!(0, internalUtils_1.isCoreServicesOrgUrlDNSError)(error_23, this.coreServicesOrgUrl, this.dynamicsLocationCode)) return [3 /*break*/, 6];
|
2857
2829
|
this.omnichannelConfig.orgUrl = this.unqServicesOrgUrl;
|
2858
2830
|
_a = this;
|
2859
2831
|
return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, (0, createOcSDKConfiguration_1.default)(false), this.ocSdkLogger)];
|
@@ -2865,10 +2837,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2865
2837
|
return [3 /*break*/, 7];
|
2866
2838
|
case 6:
|
2867
2839
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
2868
|
-
if (((_c = (_b =
|
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) {
|
2869
2841
|
console.warn("No widget with the given app id is present in the system.");
|
2870
2842
|
}
|
2871
|
-
throw
|
2843
|
+
throw error_23; // Bubble up error by default to throw ChatConfigRetrievalFailure
|
2872
2844
|
case 7: return [3 /*break*/, 8];
|
2873
2845
|
case 8: return [2 /*return*/, this.liveChatConfig];
|
2874
2846
|
}
|
@@ -2903,7 +2875,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2903
2875
|
};
|
2904
2876
|
OmnichannelChatSDK.prototype.updateChatToken = function (newToken, newRegionGTMS) {
|
2905
2877
|
return __awaiter(this, void 0, void 0, function () {
|
2906
|
-
var sessionInfo,
|
2878
|
+
var sessionInfo, error_24, exceptionDetails;
|
2907
2879
|
return __generator(this, function (_a) {
|
2908
2880
|
switch (_a.label) {
|
2909
2881
|
case 0:
|
@@ -2931,7 +2903,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2931
2903
|
});
|
2932
2904
|
return [3 /*break*/, 5];
|
2933
2905
|
case 4:
|
2934
|
-
|
2906
|
+
error_24 = _a.sent();
|
2935
2907
|
exceptionDetails = {
|
2936
2908
|
response: "UpdateChatTokenFailed"
|
2937
2909
|
};
|
@@ -2948,7 +2920,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2948
2920
|
};
|
2949
2921
|
OmnichannelChatSDK.prototype.setAuthTokenProvider = function (provider_1) {
|
2950
2922
|
return __awaiter(this, arguments, void 0, function (provider, optionalParams) {
|
2951
|
-
var token, exceptionDetails,
|
2923
|
+
var token, exceptionDetails, error_25, exceptionDetails, exceptionDetails;
|
2952
2924
|
if (optionalParams === void 0) { optionalParams = {}; }
|
2953
2925
|
return __generator(this, function (_a) {
|
2954
2926
|
switch (_a.label) {
|
@@ -2980,12 +2952,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2980
2952
|
}
|
2981
2953
|
return [3 /*break*/, 4];
|
2982
2954
|
case 3:
|
2983
|
-
|
2955
|
+
error_25 = _a.sent();
|
2984
2956
|
exceptionDetails = {
|
2985
2957
|
response: ChatSDKError_1.ChatSDKErrorName.GetAuthTokenFailed
|
2986
2958
|
};
|
2987
|
-
if (
|
2988
|
-
exceptionDetails.response =
|
2959
|
+
if (error_25.message == ChatSDKError_1.ChatSDKErrorName.UndefinedAuthToken) {
|
2960
|
+
exceptionDetails.response = error_25.message;
|
2989
2961
|
}
|
2990
2962
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2991
2963
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|