stream-chat 4.4.3-dev.3 → 5.0.1
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 +4 -13
- package/dist/browser.es.js +1258 -722
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.full-bundle.min.js +1 -1
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/browser.js +1258 -721
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +1258 -722
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1258 -721
- package/dist/index.js.map +1 -1
- package/dist/types/base64.d.ts.map +1 -1
- package/dist/types/channel.d.ts +19 -15
- package/dist/types/channel.d.ts.map +1 -1
- package/dist/types/channel_state.d.ts +2 -2
- package/dist/types/channel_state.d.ts.map +1 -1
- package/dist/types/client.d.ts +25 -42
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/client_state.d.ts +2 -2
- package/dist/types/client_state.d.ts.map +1 -1
- package/dist/types/connection.d.ts +14 -49
- package/dist/types/connection.d.ts.map +1 -1
- package/dist/types/connection_fallback.d.ts +41 -0
- package/dist/types/connection_fallback.d.ts.map +1 -0
- package/dist/types/errors.d.ts +14 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/insights.d.ts +16 -9
- package/dist/types/insights.d.ts.map +1 -1
- package/dist/types/permissions.d.ts.map +1 -1
- package/dist/types/signing.d.ts +3 -3
- package/dist/types/signing.d.ts.map +1 -1
- package/dist/types/token_manager.d.ts +2 -2
- package/dist/types/token_manager.d.ts.map +1 -1
- package/dist/types/types.d.ts +95 -89
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +13 -3
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/base64.ts +1 -4
- package/src/channel.ts +133 -461
- package/src/channel_state.ts +31 -158
- package/src/client.ts +298 -712
- package/src/client_state.ts +2 -2
- package/src/connection.ts +146 -395
- package/src/connection_fallback.ts +209 -0
- package/src/errors.ts +58 -0
- package/src/insights.ts +37 -31
- package/src/permissions.ts +3 -24
- package/src/signing.ts +6 -17
- package/src/token_manager.ts +6 -18
- package/src/types.ts +269 -512
- package/src/utils.ts +58 -24
- package/CHANGELOG.md +0 -844
package/dist/index.js
CHANGED
|
@@ -112,9 +112,9 @@ var decodeBase64 = function decodeBase64(s) {
|
|
|
112
112
|
return r;
|
|
113
113
|
};
|
|
114
114
|
|
|
115
|
-
function ownKeys$
|
|
115
|
+
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
116
116
|
|
|
117
|
-
function _objectSpread$
|
|
117
|
+
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$7(Object(source), true).forEach(function (key) { _defineProperty__default['default'](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
120
|
* ChannelState - A container class for the channel state.
|
|
@@ -182,7 +182,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
182
182
|
var m = messages[i];
|
|
183
183
|
|
|
184
184
|
if (((_m$user = m.user) === null || _m$user === void 0 ? void 0 : _m$user.id) === user.id) {
|
|
185
|
-
messages[i] = _objectSpread$
|
|
185
|
+
messages[i] = _objectSpread$7(_objectSpread$7({}, m), {}, {
|
|
186
186
|
user: user
|
|
187
187
|
});
|
|
188
188
|
}
|
|
@@ -235,7 +235,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
235
235
|
user: m.user
|
|
236
236
|
};
|
|
237
237
|
} else {
|
|
238
|
-
messages[i] = _objectSpread$
|
|
238
|
+
messages[i] = _objectSpread$7(_objectSpread$7({}, m), {}, {
|
|
239
239
|
type: 'deleted',
|
|
240
240
|
deleted_at: user.deleted_at
|
|
241
241
|
});
|
|
@@ -303,7 +303,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
303
303
|
}, {
|
|
304
304
|
key: "formatMessage",
|
|
305
305
|
value: function formatMessage(message) {
|
|
306
|
-
return _objectSpread$
|
|
306
|
+
return _objectSpread$7(_objectSpread$7({}, message), {}, {
|
|
307
307
|
/**
|
|
308
308
|
* @deprecated please use `html`
|
|
309
309
|
*/
|
|
@@ -493,7 +493,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
493
493
|
var parseMessage = function parseMessage(m) {
|
|
494
494
|
var _m$pinned_at, _m$updated_at;
|
|
495
495
|
|
|
496
|
-
return _objectSpread$
|
|
496
|
+
return _objectSpread$7(_objectSpread$7({}, m), {}, {
|
|
497
497
|
created_at: m.created_at.toString(),
|
|
498
498
|
pinned_at: (_m$pinned_at = m.pinned_at) === null || _m$pinned_at === void 0 ? void 0 : _m$pinned_at.toString(),
|
|
499
499
|
updated_at: (_m$updated_at = m.updated_at) === null || _m$updated_at === void 0 ? void 0 : _m$updated_at.toString()
|
|
@@ -503,8 +503,8 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
503
503
|
var updatedMessages = this.messages.filter(function (msg) {
|
|
504
504
|
return msg.quoted_message_id === message.id;
|
|
505
505
|
}).map(parseMessage).map(function (msg) {
|
|
506
|
-
return _objectSpread$
|
|
507
|
-
quoted_message: _objectSpread$
|
|
506
|
+
return _objectSpread$7(_objectSpread$7({}, msg), {}, {
|
|
507
|
+
quoted_message: _objectSpread$7(_objectSpread$7({}, message), {}, {
|
|
508
508
|
attachments: []
|
|
509
509
|
})
|
|
510
510
|
});
|
|
@@ -724,9 +724,9 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
724
724
|
return ChannelState;
|
|
725
725
|
}();
|
|
726
726
|
|
|
727
|
-
function ownKeys$
|
|
727
|
+
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
728
728
|
|
|
729
|
-
function _objectSpread$
|
|
729
|
+
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$6(Object(source), true).forEach(function (key) { _defineProperty__default['default'](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
730
730
|
|
|
731
731
|
var EVENT_MAP = {
|
|
732
732
|
'channel.created': true,
|
|
@@ -773,7 +773,7 @@ var EVENT_MAP = {
|
|
|
773
773
|
'connection.recovered': true
|
|
774
774
|
};
|
|
775
775
|
|
|
776
|
-
var IS_VALID_EVENT_MAP_TYPE = _objectSpread$
|
|
776
|
+
var IS_VALID_EVENT_MAP_TYPE = _objectSpread$6(_objectSpread$6({}, EVENT_MAP), {}, {
|
|
777
777
|
all: true
|
|
778
778
|
});
|
|
779
779
|
|
|
@@ -781,7 +781,7 @@ var isValidEventType = function isValidEventType(eventType) {
|
|
|
781
781
|
return IS_VALID_EVENT_MAP_TYPE[eventType] || false;
|
|
782
782
|
};
|
|
783
783
|
|
|
784
|
-
function _createForOfIteratorHelper$3(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$3(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) {
|
|
784
|
+
function _createForOfIteratorHelper$3(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$3(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function (_e) { function e(_x) { return _e.apply(this, arguments); } e.toString = function () { return _e.toString(); }; return e; }(function (e) { throw e; }), f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function (_e2) { function e(_x2) { return _e2.apply(this, arguments); } e.toString = function () { return _e2.toString(); }; return e; }(function (e) { didErr = true; err = e; }), f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
785
785
|
|
|
786
786
|
function _unsupportedIterableToArray$3(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$3(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen); }
|
|
787
787
|
|
|
@@ -957,12 +957,55 @@ function getRandomBytes(length) {
|
|
|
957
957
|
function convertErrorToJson(err) {
|
|
958
958
|
var jsonObj = {};
|
|
959
959
|
if (!err) return jsonObj;
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
960
|
+
|
|
961
|
+
try {
|
|
962
|
+
Object.getOwnPropertyNames(err).forEach(function (key) {
|
|
963
|
+
jsonObj[key] = Object.getOwnPropertyDescriptor(err, key);
|
|
964
|
+
});
|
|
965
|
+
} catch (_) {
|
|
966
|
+
return {
|
|
967
|
+
error: 'failed to serialize the error'
|
|
968
|
+
};
|
|
969
|
+
}
|
|
970
|
+
|
|
964
971
|
return jsonObj;
|
|
965
972
|
}
|
|
973
|
+
/**
|
|
974
|
+
* isOnline safely return the navigator.online value for browser env
|
|
975
|
+
* if navigator is not in global object, it always return true
|
|
976
|
+
*/
|
|
977
|
+
|
|
978
|
+
function isOnline() {
|
|
979
|
+
var nav = typeof navigator !== 'undefined' ? navigator : typeof window !== 'undefined' && window.navigator ? window.navigator : undefined;
|
|
980
|
+
|
|
981
|
+
if (!nav) {
|
|
982
|
+
console.warn('isOnline failed to access window.navigator and assume browser is online');
|
|
983
|
+
return true;
|
|
984
|
+
} // RN navigator has undefined for onLine
|
|
985
|
+
|
|
986
|
+
|
|
987
|
+
if (typeof nav.onLine !== 'boolean') {
|
|
988
|
+
return true;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
return nav.onLine;
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* listenForConnectionChanges - Adds an event listener fired on browser going online or offline
|
|
995
|
+
*/
|
|
996
|
+
|
|
997
|
+
function addConnectionEventListeners(cb) {
|
|
998
|
+
if (typeof window !== 'undefined' && window.addEventListener) {
|
|
999
|
+
window.addEventListener('offline', cb);
|
|
1000
|
+
window.addEventListener('online', cb);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
function removeConnectionEventListeners(cb) {
|
|
1004
|
+
if (typeof window !== 'undefined' && window.removeEventListener) {
|
|
1005
|
+
window.removeEventListener('offline', cb);
|
|
1006
|
+
window.removeEventListener('online', cb);
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
966
1009
|
|
|
967
1010
|
function _createForOfIteratorHelper$2(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$2(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
968
1011
|
|
|
@@ -970,9 +1013,9 @@ function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o
|
|
|
970
1013
|
|
|
971
1014
|
function _arrayLikeToArray$2(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
972
1015
|
|
|
973
|
-
function ownKeys$
|
|
1016
|
+
function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
974
1017
|
|
|
975
|
-
function _objectSpread$
|
|
1018
|
+
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$5(Object(source), true).forEach(function (key) { _defineProperty__default['default'](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
976
1019
|
|
|
977
1020
|
/**
|
|
978
1021
|
* Channel - The Channel class manages it's own state.
|
|
@@ -1092,7 +1135,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1092
1135
|
|
|
1093
1136
|
this.data = data; // this._data is used for the requests...
|
|
1094
1137
|
|
|
1095
|
-
this._data = _objectSpread$
|
|
1138
|
+
this._data = _objectSpread$5({}, data);
|
|
1096
1139
|
this.cid = "".concat(type, ":").concat(id);
|
|
1097
1140
|
this.listeners = {}; // perhaps the state variable should be private
|
|
1098
1141
|
|
|
@@ -1150,7 +1193,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1150
1193
|
switch (_context2.prev = _context2.next) {
|
|
1151
1194
|
case 0:
|
|
1152
1195
|
_context2.next = 2;
|
|
1153
|
-
return this.getClient().post(this._channelURL() + '/message', _objectSpread$
|
|
1196
|
+
return this.getClient().post(this._channelURL() + '/message', _objectSpread$5({
|
|
1154
1197
|
message: message
|
|
1155
1198
|
}, options));
|
|
1156
1199
|
|
|
@@ -1269,7 +1312,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1269
1312
|
|
|
1270
1313
|
case 3:
|
|
1271
1314
|
// Return a list of channels
|
|
1272
|
-
payload = _objectSpread$
|
|
1315
|
+
payload = _objectSpread$5(_objectSpread$5({
|
|
1273
1316
|
filter_conditions: {
|
|
1274
1317
|
cid: this.cid
|
|
1275
1318
|
}
|
|
@@ -1366,7 +1409,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1366
1409
|
|
|
1367
1410
|
_context5.next = 6;
|
|
1368
1411
|
return this.getClient().get(this.getClient().baseURL + '/members', {
|
|
1369
|
-
payload: _objectSpread$
|
|
1412
|
+
payload: _objectSpread$5({
|
|
1370
1413
|
type: type,
|
|
1371
1414
|
id: id,
|
|
1372
1415
|
members: members,
|
|
@@ -1427,7 +1470,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1427
1470
|
|
|
1428
1471
|
case 4:
|
|
1429
1472
|
_context6.next = 6;
|
|
1430
|
-
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(messageID, "/reaction"), _objectSpread$
|
|
1473
|
+
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(messageID, "/reaction"), _objectSpread$5({
|
|
1431
1474
|
reaction: reaction
|
|
1432
1475
|
}, options));
|
|
1433
1476
|
|
|
@@ -1482,7 +1525,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1482
1525
|
*
|
|
1483
1526
|
* @param {ChannelData<ChannelType>} channelData The object to update the custom properties of this channel with
|
|
1484
1527
|
* @param {Message<AttachmentType, MessageType, UserType>} [updateMessage] Optional message object for channel members notification
|
|
1485
|
-
* @param {
|
|
1528
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1486
1529
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1487
1530
|
*/
|
|
1488
1531
|
|
|
@@ -1508,7 +1551,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1508
1551
|
delete channelData[key];
|
|
1509
1552
|
});
|
|
1510
1553
|
_context7.next = 7;
|
|
1511
|
-
return this._update(_objectSpread$
|
|
1554
|
+
return this._update(_objectSpread$5({
|
|
1512
1555
|
message: updateMessage,
|
|
1513
1556
|
data: channelData
|
|
1514
1557
|
}, options));
|
|
@@ -1681,25 +1724,28 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1681
1724
|
}()
|
|
1682
1725
|
/**
|
|
1683
1726
|
* truncate - Removes all messages from the channel
|
|
1684
|
-
*
|
|
1685
|
-
* @return {Promise<TruncateChannelAPIResponse<ChannelType, CommandType, UserType>>} The server response
|
|
1727
|
+
* @param {TruncateOptions<AttachmentType, MessageType, UserType>} [options] Defines truncation options
|
|
1728
|
+
* @return {Promise<TruncateChannelAPIResponse<ChannelType, CommandType, UserType, MessageType, ReactionType>>} The server response
|
|
1686
1729
|
*/
|
|
1687
1730
|
|
|
1688
1731
|
}, {
|
|
1689
1732
|
key: "truncate",
|
|
1690
1733
|
value: function () {
|
|
1691
1734
|
var _truncate = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee12() {
|
|
1735
|
+
var options,
|
|
1736
|
+
_args12 = arguments;
|
|
1692
1737
|
return _regeneratorRuntime__default['default'].wrap(function _callee12$(_context12) {
|
|
1693
1738
|
while (1) {
|
|
1694
1739
|
switch (_context12.prev = _context12.next) {
|
|
1695
1740
|
case 0:
|
|
1696
|
-
|
|
1697
|
-
|
|
1741
|
+
options = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
|
|
1742
|
+
_context12.next = 3;
|
|
1743
|
+
return this.getClient().post(this._channelURL() + '/truncate', options);
|
|
1698
1744
|
|
|
1699
|
-
case
|
|
1745
|
+
case 3:
|
|
1700
1746
|
return _context12.abrupt("return", _context12.sent);
|
|
1701
1747
|
|
|
1702
|
-
case
|
|
1748
|
+
case 4:
|
|
1703
1749
|
case "end":
|
|
1704
1750
|
return _context12.stop();
|
|
1705
1751
|
}
|
|
@@ -1733,7 +1779,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1733
1779
|
case 0:
|
|
1734
1780
|
options = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
|
|
1735
1781
|
_context13.next = 3;
|
|
1736
|
-
return this._update(_objectSpread$
|
|
1782
|
+
return this._update(_objectSpread$5({
|
|
1737
1783
|
accept_invite: true
|
|
1738
1784
|
}, options));
|
|
1739
1785
|
|
|
@@ -1774,7 +1820,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1774
1820
|
case 0:
|
|
1775
1821
|
options = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
|
|
1776
1822
|
_context14.next = 3;
|
|
1777
|
-
return this._update(_objectSpread$
|
|
1823
|
+
return this._update(_objectSpread$5({
|
|
1778
1824
|
reject_invite: true
|
|
1779
1825
|
}, options));
|
|
1780
1826
|
|
|
@@ -1800,6 +1846,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1800
1846
|
*
|
|
1801
1847
|
* @param {{user_id: string, channel_role?: Role}[]} members An array of members to add to the channel
|
|
1802
1848
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1849
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1803
1850
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1804
1851
|
*/
|
|
1805
1852
|
|
|
@@ -1807,20 +1854,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1807
1854
|
key: "addMembers",
|
|
1808
1855
|
value: function () {
|
|
1809
1856
|
var _addMembers = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee15(members, message) {
|
|
1857
|
+
var options,
|
|
1858
|
+
_args15 = arguments;
|
|
1810
1859
|
return _regeneratorRuntime__default['default'].wrap(function _callee15$(_context15) {
|
|
1811
1860
|
while (1) {
|
|
1812
1861
|
switch (_context15.prev = _context15.next) {
|
|
1813
1862
|
case 0:
|
|
1814
|
-
|
|
1815
|
-
|
|
1863
|
+
options = _args15.length > 2 && _args15[2] !== undefined ? _args15[2] : {};
|
|
1864
|
+
_context15.next = 3;
|
|
1865
|
+
return this._update(_objectSpread$5({
|
|
1816
1866
|
add_members: members,
|
|
1817
1867
|
message: message
|
|
1818
|
-
});
|
|
1868
|
+
}, options));
|
|
1819
1869
|
|
|
1820
|
-
case
|
|
1870
|
+
case 3:
|
|
1821
1871
|
return _context15.abrupt("return", _context15.sent);
|
|
1822
1872
|
|
|
1823
|
-
case
|
|
1873
|
+
case 4:
|
|
1824
1874
|
case "end":
|
|
1825
1875
|
return _context15.stop();
|
|
1826
1876
|
}
|
|
@@ -1839,6 +1889,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1839
1889
|
*
|
|
1840
1890
|
* @param {string[]} members An array of member identifiers
|
|
1841
1891
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1892
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1842
1893
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1843
1894
|
*/
|
|
1844
1895
|
|
|
@@ -1846,20 +1897,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1846
1897
|
key: "addModerators",
|
|
1847
1898
|
value: function () {
|
|
1848
1899
|
var _addModerators = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee16(members, message) {
|
|
1900
|
+
var options,
|
|
1901
|
+
_args16 = arguments;
|
|
1849
1902
|
return _regeneratorRuntime__default['default'].wrap(function _callee16$(_context16) {
|
|
1850
1903
|
while (1) {
|
|
1851
1904
|
switch (_context16.prev = _context16.next) {
|
|
1852
1905
|
case 0:
|
|
1853
|
-
|
|
1854
|
-
|
|
1906
|
+
options = _args16.length > 2 && _args16[2] !== undefined ? _args16[2] : {};
|
|
1907
|
+
_context16.next = 3;
|
|
1908
|
+
return this._update(_objectSpread$5({
|
|
1855
1909
|
add_moderators: members,
|
|
1856
1910
|
message: message
|
|
1857
|
-
});
|
|
1911
|
+
}, options));
|
|
1858
1912
|
|
|
1859
|
-
case
|
|
1913
|
+
case 3:
|
|
1860
1914
|
return _context16.abrupt("return", _context16.sent);
|
|
1861
1915
|
|
|
1862
|
-
case
|
|
1916
|
+
case 4:
|
|
1863
1917
|
case "end":
|
|
1864
1918
|
return _context16.stop();
|
|
1865
1919
|
}
|
|
@@ -1878,6 +1932,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1878
1932
|
*
|
|
1879
1933
|
* @param {{channel_role: Role, user_id: string}[]} roles List of role assignments
|
|
1880
1934
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1935
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1881
1936
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1882
1937
|
*/
|
|
1883
1938
|
|
|
@@ -1885,20 +1940,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1885
1940
|
key: "assignRoles",
|
|
1886
1941
|
value: function () {
|
|
1887
1942
|
var _assignRoles = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee17(roles, message) {
|
|
1943
|
+
var options,
|
|
1944
|
+
_args17 = arguments;
|
|
1888
1945
|
return _regeneratorRuntime__default['default'].wrap(function _callee17$(_context17) {
|
|
1889
1946
|
while (1) {
|
|
1890
1947
|
switch (_context17.prev = _context17.next) {
|
|
1891
1948
|
case 0:
|
|
1892
|
-
|
|
1893
|
-
|
|
1949
|
+
options = _args17.length > 2 && _args17[2] !== undefined ? _args17[2] : {};
|
|
1950
|
+
_context17.next = 3;
|
|
1951
|
+
return this._update(_objectSpread$5({
|
|
1894
1952
|
assign_roles: roles,
|
|
1895
1953
|
message: message
|
|
1896
|
-
});
|
|
1954
|
+
}, options));
|
|
1897
1955
|
|
|
1898
|
-
case
|
|
1956
|
+
case 3:
|
|
1899
1957
|
return _context17.abrupt("return", _context17.sent);
|
|
1900
1958
|
|
|
1901
|
-
case
|
|
1959
|
+
case 4:
|
|
1902
1960
|
case "end":
|
|
1903
1961
|
return _context17.stop();
|
|
1904
1962
|
}
|
|
@@ -1917,6 +1975,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1917
1975
|
*
|
|
1918
1976
|
* @param {{user_id: string, channel_role?: Role}[]} members An array of members to invite to the channel
|
|
1919
1977
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1978
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1920
1979
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1921
1980
|
*/
|
|
1922
1981
|
|
|
@@ -1924,20 +1983,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1924
1983
|
key: "inviteMembers",
|
|
1925
1984
|
value: function () {
|
|
1926
1985
|
var _inviteMembers = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee18(members, message) {
|
|
1986
|
+
var options,
|
|
1987
|
+
_args18 = arguments;
|
|
1927
1988
|
return _regeneratorRuntime__default['default'].wrap(function _callee18$(_context18) {
|
|
1928
1989
|
while (1) {
|
|
1929
1990
|
switch (_context18.prev = _context18.next) {
|
|
1930
1991
|
case 0:
|
|
1931
|
-
|
|
1932
|
-
|
|
1992
|
+
options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
|
|
1993
|
+
_context18.next = 3;
|
|
1994
|
+
return this._update(_objectSpread$5({
|
|
1933
1995
|
invites: members,
|
|
1934
1996
|
message: message
|
|
1935
|
-
});
|
|
1997
|
+
}, options));
|
|
1936
1998
|
|
|
1937
|
-
case
|
|
1999
|
+
case 3:
|
|
1938
2000
|
return _context18.abrupt("return", _context18.sent);
|
|
1939
2001
|
|
|
1940
|
-
case
|
|
2002
|
+
case 4:
|
|
1941
2003
|
case "end":
|
|
1942
2004
|
return _context18.stop();
|
|
1943
2005
|
}
|
|
@@ -1956,6 +2018,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1956
2018
|
*
|
|
1957
2019
|
* @param {string[]} members An array of member identifiers
|
|
1958
2020
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
2021
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1959
2022
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1960
2023
|
*/
|
|
1961
2024
|
|
|
@@ -1963,20 +2026,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1963
2026
|
key: "removeMembers",
|
|
1964
2027
|
value: function () {
|
|
1965
2028
|
var _removeMembers = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee19(members, message) {
|
|
2029
|
+
var options,
|
|
2030
|
+
_args19 = arguments;
|
|
1966
2031
|
return _regeneratorRuntime__default['default'].wrap(function _callee19$(_context19) {
|
|
1967
2032
|
while (1) {
|
|
1968
2033
|
switch (_context19.prev = _context19.next) {
|
|
1969
2034
|
case 0:
|
|
1970
|
-
|
|
1971
|
-
|
|
2035
|
+
options = _args19.length > 2 && _args19[2] !== undefined ? _args19[2] : {};
|
|
2036
|
+
_context19.next = 3;
|
|
2037
|
+
return this._update(_objectSpread$5({
|
|
1972
2038
|
remove_members: members,
|
|
1973
2039
|
message: message
|
|
1974
|
-
});
|
|
2040
|
+
}, options));
|
|
1975
2041
|
|
|
1976
|
-
case
|
|
2042
|
+
case 3:
|
|
1977
2043
|
return _context19.abrupt("return", _context19.sent);
|
|
1978
2044
|
|
|
1979
|
-
case
|
|
2045
|
+
case 4:
|
|
1980
2046
|
case "end":
|
|
1981
2047
|
return _context19.stop();
|
|
1982
2048
|
}
|
|
@@ -1995,6 +2061,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1995
2061
|
*
|
|
1996
2062
|
* @param {string[]} members An array of member identifiers
|
|
1997
2063
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
2064
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1998
2065
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1999
2066
|
*/
|
|
2000
2067
|
|
|
@@ -2002,20 +2069,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2002
2069
|
key: "demoteModerators",
|
|
2003
2070
|
value: function () {
|
|
2004
2071
|
var _demoteModerators = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee20(members, message) {
|
|
2072
|
+
var options,
|
|
2073
|
+
_args20 = arguments;
|
|
2005
2074
|
return _regeneratorRuntime__default['default'].wrap(function _callee20$(_context20) {
|
|
2006
2075
|
while (1) {
|
|
2007
2076
|
switch (_context20.prev = _context20.next) {
|
|
2008
2077
|
case 0:
|
|
2009
|
-
|
|
2010
|
-
|
|
2078
|
+
options = _args20.length > 2 && _args20[2] !== undefined ? _args20[2] : {};
|
|
2079
|
+
_context20.next = 3;
|
|
2080
|
+
return this._update(_objectSpread$5({
|
|
2011
2081
|
demote_moderators: members,
|
|
2012
2082
|
message: message
|
|
2013
|
-
});
|
|
2083
|
+
}, options));
|
|
2014
2084
|
|
|
2015
|
-
case
|
|
2085
|
+
case 3:
|
|
2016
2086
|
return _context20.abrupt("return", _context20.sent);
|
|
2017
2087
|
|
|
2018
|
-
case
|
|
2088
|
+
case 4:
|
|
2019
2089
|
case "end":
|
|
2020
2090
|
return _context20.stop();
|
|
2021
2091
|
}
|
|
@@ -2092,7 +2162,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2092
2162
|
case 0:
|
|
2093
2163
|
opts = _args22.length > 0 && _args22[0] !== undefined ? _args22[0] : {};
|
|
2094
2164
|
_context22.next = 3;
|
|
2095
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$
|
|
2165
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$5({
|
|
2096
2166
|
channel_cid: this.cid
|
|
2097
2167
|
}, opts));
|
|
2098
2168
|
|
|
@@ -2134,7 +2204,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2134
2204
|
case 0:
|
|
2135
2205
|
opts = _args23.length > 0 && _args23[0] !== undefined ? _args23[0] : {};
|
|
2136
2206
|
_context23.next = 3;
|
|
2137
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$
|
|
2207
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$5({
|
|
2138
2208
|
channel_cid: this.cid
|
|
2139
2209
|
}, opts));
|
|
2140
2210
|
|
|
@@ -2343,7 +2413,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2343
2413
|
|
|
2344
2414
|
case 4:
|
|
2345
2415
|
_context26.next = 6;
|
|
2346
|
-
return this.getClient().post(this._channelURL() + '/read', _objectSpread$
|
|
2416
|
+
return this.getClient().post(this._channelURL() + '/read', _objectSpread$5({}, data));
|
|
2347
2417
|
|
|
2348
2418
|
case 6:
|
|
2349
2419
|
return _context26.abrupt("return", _context26.sent);
|
|
@@ -2411,7 +2481,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2411
2481
|
defaultOptions.watch = false;
|
|
2412
2482
|
}
|
|
2413
2483
|
|
|
2414
|
-
combined = _objectSpread$
|
|
2484
|
+
combined = _objectSpread$5(_objectSpread$5({}, defaultOptions), options);
|
|
2415
2485
|
_context27.next = 7;
|
|
2416
2486
|
return this.query(combined);
|
|
2417
2487
|
|
|
@@ -2502,7 +2572,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2502
2572
|
switch (_context29.prev = _context29.next) {
|
|
2503
2573
|
case 0:
|
|
2504
2574
|
_context29.next = 2;
|
|
2505
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(parent_id, "/replies"), _objectSpread$
|
|
2575
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(parent_id, "/replies"), _objectSpread$5({}, options));
|
|
2506
2576
|
|
|
2507
2577
|
case 2:
|
|
2508
2578
|
data = _context29.sent;
|
|
@@ -2540,7 +2610,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2540
2610
|
}, {
|
|
2541
2611
|
key: "getReactions",
|
|
2542
2612
|
value: function getReactions(message_id, options) {
|
|
2543
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(message_id, "/reactions"), _objectSpread$
|
|
2613
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(message_id, "/reactions"), _objectSpread$5({}, options));
|
|
2544
2614
|
}
|
|
2545
2615
|
/**
|
|
2546
2616
|
* getMessagesById - Retrieves a list of messages by ID
|
|
@@ -2672,7 +2742,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2672
2742
|
}
|
|
2673
2743
|
|
|
2674
2744
|
_context30.next = 6;
|
|
2675
|
-
return this.getClient().post(queryURL + '/query', _objectSpread$
|
|
2745
|
+
return this.getClient().post(queryURL + '/query', _objectSpread$5({
|
|
2676
2746
|
data: this._data,
|
|
2677
2747
|
state: true
|
|
2678
2748
|
}, options));
|
|
@@ -2743,7 +2813,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2743
2813
|
this._checkInitialized();
|
|
2744
2814
|
|
|
2745
2815
|
_context31.next = 3;
|
|
2746
|
-
return this.getClient().banUser(targetUserID, _objectSpread$
|
|
2816
|
+
return this.getClient().banUser(targetUserID, _objectSpread$5(_objectSpread$5({}, options), {}, {
|
|
2747
2817
|
type: this.type,
|
|
2748
2818
|
id: this.id
|
|
2749
2819
|
}));
|
|
@@ -2915,7 +2985,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2915
2985
|
this._checkInitialized();
|
|
2916
2986
|
|
|
2917
2987
|
_context35.next = 3;
|
|
2918
|
-
return this.getClient().shadowBan(targetUserID, _objectSpread$
|
|
2988
|
+
return this.getClient().shadowBan(targetUserID, _objectSpread$5(_objectSpread$5({}, options), {}, {
|
|
2919
2989
|
type: this.type,
|
|
2920
2990
|
id: this.id
|
|
2921
2991
|
}));
|
|
@@ -3328,7 +3398,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3328
3398
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
3329
3399
|
var read = _step3.value;
|
|
3330
3400
|
|
|
3331
|
-
var parsedRead = _objectSpread$
|
|
3401
|
+
var parsedRead = _objectSpread$5(_objectSpread$5({}, read), {}, {
|
|
3332
3402
|
last_read: new Date(read.last_read)
|
|
3333
3403
|
});
|
|
3334
3404
|
|
|
@@ -3455,9 +3525,9 @@ var ClientState = /*#__PURE__*/function () {
|
|
|
3455
3525
|
return ClientState;
|
|
3456
3526
|
}();
|
|
3457
3527
|
|
|
3458
|
-
function ownKeys$
|
|
3528
|
+
function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
3459
3529
|
|
|
3460
|
-
function _objectSpread$
|
|
3530
|
+
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$4(Object(source), true).forEach(function (key) { _defineProperty__default['default'](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
3461
3531
|
var InsightMetrics = function InsightMetrics() {
|
|
3462
3532
|
_classCallCheck__default['default'](this, InsightMetrics);
|
|
3463
3533
|
|
|
@@ -3474,32 +3544,94 @@ var InsightMetrics = function InsightMetrics() {
|
|
|
3474
3544
|
this.wsConsecutiveFailures = 0;
|
|
3475
3545
|
this.instanceClientId = randomId();
|
|
3476
3546
|
};
|
|
3547
|
+
/**
|
|
3548
|
+
* postInsights is not supposed to be used by end users directly within chat application, and thus is kept isolated
|
|
3549
|
+
* from all the client/connection code/logic.
|
|
3550
|
+
*
|
|
3551
|
+
* @param insightType
|
|
3552
|
+
* @param insights
|
|
3553
|
+
*/
|
|
3554
|
+
|
|
3555
|
+
var postInsights = /*#__PURE__*/function () {
|
|
3556
|
+
var _ref = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(insightType, insights) {
|
|
3557
|
+
var maxAttempts, i;
|
|
3558
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
3559
|
+
while (1) {
|
|
3560
|
+
switch (_context.prev = _context.next) {
|
|
3561
|
+
case 0:
|
|
3562
|
+
maxAttempts = 3;
|
|
3563
|
+
i = 0;
|
|
3564
|
+
|
|
3565
|
+
case 2:
|
|
3566
|
+
if (!(i < maxAttempts)) {
|
|
3567
|
+
_context.next = 17;
|
|
3568
|
+
break;
|
|
3569
|
+
}
|
|
3570
|
+
|
|
3571
|
+
_context.prev = 3;
|
|
3572
|
+
_context.next = 6;
|
|
3573
|
+
return axios__default['default'].post("https://chat-insights.getstream.io/insights/".concat(insightType), insights);
|
|
3574
|
+
|
|
3575
|
+
case 6:
|
|
3576
|
+
_context.next = 13;
|
|
3577
|
+
break;
|
|
3578
|
+
|
|
3579
|
+
case 8:
|
|
3580
|
+
_context.prev = 8;
|
|
3581
|
+
_context.t0 = _context["catch"](3);
|
|
3582
|
+
_context.next = 12;
|
|
3583
|
+
return sleep((i + 1) * 3000);
|
|
3584
|
+
|
|
3585
|
+
case 12:
|
|
3586
|
+
return _context.abrupt("continue", 14);
|
|
3587
|
+
|
|
3588
|
+
case 13:
|
|
3589
|
+
return _context.abrupt("break", 17);
|
|
3590
|
+
|
|
3591
|
+
case 14:
|
|
3592
|
+
i++;
|
|
3593
|
+
_context.next = 2;
|
|
3594
|
+
break;
|
|
3595
|
+
|
|
3596
|
+
case 17:
|
|
3597
|
+
case "end":
|
|
3598
|
+
return _context.stop();
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
}, _callee, null, [[3, 8]]);
|
|
3602
|
+
}));
|
|
3603
|
+
|
|
3604
|
+
return function postInsights(_x, _x2) {
|
|
3605
|
+
return _ref.apply(this, arguments);
|
|
3606
|
+
};
|
|
3607
|
+
}();
|
|
3477
3608
|
function buildWsFatalInsight(connection, event) {
|
|
3478
|
-
return _objectSpread$
|
|
3609
|
+
return _objectSpread$4(_objectSpread$4({}, event), buildWsBaseInsight(connection));
|
|
3479
3610
|
}
|
|
3480
3611
|
|
|
3481
3612
|
function buildWsBaseInsight(connection) {
|
|
3482
3613
|
var _connection$ws, _navigator, _navigator2;
|
|
3483
3614
|
|
|
3615
|
+
var client = connection.client;
|
|
3484
3616
|
return {
|
|
3485
3617
|
ready_state: (_connection$ws = connection.ws) === null || _connection$ws === void 0 ? void 0 : _connection$ws.readyState,
|
|
3486
|
-
url: connection._buildUrl(
|
|
3487
|
-
api_key:
|
|
3488
|
-
start_ts:
|
|
3618
|
+
url: connection._buildUrl(),
|
|
3619
|
+
api_key: client.key,
|
|
3620
|
+
start_ts: client.insightMetrics.connectionStartTimestamp,
|
|
3489
3621
|
end_ts: new Date().getTime(),
|
|
3490
|
-
auth_type:
|
|
3491
|
-
token:
|
|
3492
|
-
user_id:
|
|
3493
|
-
user_details:
|
|
3494
|
-
device:
|
|
3622
|
+
auth_type: client.getAuthType(),
|
|
3623
|
+
token: client.tokenManager.token,
|
|
3624
|
+
user_id: client.userID,
|
|
3625
|
+
user_details: client._user,
|
|
3626
|
+
device: client.options.device,
|
|
3495
3627
|
client_id: connection.connectionID,
|
|
3496
3628
|
ws_details: connection.ws,
|
|
3497
|
-
ws_consecutive_failures:
|
|
3498
|
-
ws_total_failures:
|
|
3629
|
+
ws_consecutive_failures: client.insightMetrics.wsConsecutiveFailures,
|
|
3630
|
+
ws_total_failures: client.insightMetrics.wsTotalFailures,
|
|
3499
3631
|
request_id: connection.requestID,
|
|
3500
3632
|
online: typeof navigator !== 'undefined' ? (_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.onLine : null,
|
|
3501
3633
|
user_agent: typeof navigator !== 'undefined' ? (_navigator2 = navigator) === null || _navigator2 === void 0 ? void 0 : _navigator2.userAgent : null,
|
|
3502
|
-
instance_client_id:
|
|
3634
|
+
instance_client_id: client.insightMetrics.instanceClientId
|
|
3503
3635
|
};
|
|
3504
3636
|
}
|
|
3505
3637
|
|
|
@@ -3507,6 +3639,10 @@ function buildWsSuccessAfterFailureInsight(connection) {
|
|
|
3507
3639
|
return buildWsBaseInsight(connection);
|
|
3508
3640
|
}
|
|
3509
3641
|
|
|
3642
|
+
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
3643
|
+
|
|
3644
|
+
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(Object(source), true).forEach(function (key) { _defineProperty__default['default'](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
3645
|
+
|
|
3510
3646
|
// Type guards to check WebSocket error type
|
|
3511
3647
|
var isCloseEvent = function isCloseEvent(res) {
|
|
3512
3648
|
return res.code !== undefined;
|
|
@@ -3515,7 +3651,6 @@ var isCloseEvent = function isCloseEvent(res) {
|
|
|
3515
3651
|
var isErrorEvent = function isErrorEvent(res) {
|
|
3516
3652
|
return res.error !== undefined;
|
|
3517
3653
|
};
|
|
3518
|
-
|
|
3519
3654
|
/**
|
|
3520
3655
|
* StableWSConnection - A WS connection that reconnects upon failure.
|
|
3521
3656
|
* - the browser will sometimes report that you're online or offline
|
|
@@ -3533,53 +3668,19 @@ var isErrorEvent = function isErrorEvent(res) {
|
|
|
3533
3668
|
* - state can be recovered by querying the channel again
|
|
3534
3669
|
* - if the servers fails to publish a message to the client, the WS connection is destroyed
|
|
3535
3670
|
*/
|
|
3671
|
+
|
|
3672
|
+
|
|
3536
3673
|
var StableWSConnection = /*#__PURE__*/function () {
|
|
3674
|
+
// global from constructor
|
|
3675
|
+
// local vars
|
|
3537
3676
|
function StableWSConnection(_ref) {
|
|
3538
3677
|
var _this = this;
|
|
3539
3678
|
|
|
3540
|
-
var
|
|
3541
|
-
authType = _ref.authType,
|
|
3542
|
-
clientID = _ref.clientID,
|
|
3543
|
-
eventCallback = _ref.eventCallback,
|
|
3544
|
-
logger = _ref.logger,
|
|
3545
|
-
messageCallback = _ref.messageCallback,
|
|
3546
|
-
recoverCallback = _ref.recoverCallback,
|
|
3547
|
-
tokenManager = _ref.tokenManager,
|
|
3548
|
-
user = _ref.user,
|
|
3549
|
-
userAgent = _ref.userAgent,
|
|
3550
|
-
userID = _ref.userID,
|
|
3551
|
-
wsBaseURL = _ref.wsBaseURL,
|
|
3552
|
-
device = _ref.device,
|
|
3553
|
-
postInsights = _ref.postInsights,
|
|
3554
|
-
insightMetrics = _ref.insightMetrics;
|
|
3679
|
+
var client = _ref.client;
|
|
3555
3680
|
|
|
3556
3681
|
_classCallCheck__default['default'](this, StableWSConnection);
|
|
3557
3682
|
|
|
3558
|
-
_defineProperty__default['default'](this, "
|
|
3559
|
-
|
|
3560
|
-
_defineProperty__default['default'](this, "authType", void 0);
|
|
3561
|
-
|
|
3562
|
-
_defineProperty__default['default'](this, "clientID", void 0);
|
|
3563
|
-
|
|
3564
|
-
_defineProperty__default['default'](this, "eventCallback", void 0);
|
|
3565
|
-
|
|
3566
|
-
_defineProperty__default['default'](this, "logger", void 0);
|
|
3567
|
-
|
|
3568
|
-
_defineProperty__default['default'](this, "messageCallback", void 0);
|
|
3569
|
-
|
|
3570
|
-
_defineProperty__default['default'](this, "recoverCallback", void 0);
|
|
3571
|
-
|
|
3572
|
-
_defineProperty__default['default'](this, "tokenManager", void 0);
|
|
3573
|
-
|
|
3574
|
-
_defineProperty__default['default'](this, "user", void 0);
|
|
3575
|
-
|
|
3576
|
-
_defineProperty__default['default'](this, "userAgent", void 0);
|
|
3577
|
-
|
|
3578
|
-
_defineProperty__default['default'](this, "userID", void 0);
|
|
3579
|
-
|
|
3580
|
-
_defineProperty__default['default'](this, "wsBaseURL", void 0);
|
|
3581
|
-
|
|
3582
|
-
_defineProperty__default['default'](this, "device", void 0);
|
|
3683
|
+
_defineProperty__default['default'](this, "client", void 0);
|
|
3583
3684
|
|
|
3584
3685
|
_defineProperty__default['default'](this, "connectionID", void 0);
|
|
3585
3686
|
|
|
@@ -3593,6 +3694,8 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3593
3694
|
|
|
3594
3695
|
_defineProperty__default['default'](this, "isConnecting", void 0);
|
|
3595
3696
|
|
|
3697
|
+
_defineProperty__default['default'](this, "isDisconnected", void 0);
|
|
3698
|
+
|
|
3596
3699
|
_defineProperty__default['default'](this, "isHealthy", void 0);
|
|
3597
3700
|
|
|
3598
3701
|
_defineProperty__default['default'](this, "isResolved", void 0);
|
|
@@ -3607,8 +3710,6 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3607
3710
|
|
|
3608
3711
|
_defineProperty__default['default'](this, "requestID", void 0);
|
|
3609
3712
|
|
|
3610
|
-
_defineProperty__default['default'](this, "connectionStartTimestamp", void 0);
|
|
3611
|
-
|
|
3612
3713
|
_defineProperty__default['default'](this, "resolvePromise", void 0);
|
|
3613
3714
|
|
|
3614
3715
|
_defineProperty__default['default'](this, "totalFailures", void 0);
|
|
@@ -3617,32 +3718,18 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3617
3718
|
|
|
3618
3719
|
_defineProperty__default['default'](this, "wsID", void 0);
|
|
3619
3720
|
|
|
3620
|
-
_defineProperty__default['default'](this, "
|
|
3721
|
+
_defineProperty__default['default'](this, "_buildUrl", function () {
|
|
3722
|
+
var qs = encodeURIComponent(_this.client._buildWSPayload(_this.requestID));
|
|
3621
3723
|
|
|
3622
|
-
|
|
3724
|
+
var token = _this.client.tokenManager.getToken();
|
|
3623
3725
|
|
|
3624
|
-
|
|
3625
|
-
var params = {
|
|
3626
|
-
user_id: _this.user.id,
|
|
3627
|
-
user_details: _this.user,
|
|
3628
|
-
user_token: _this.tokenManager.getToken(),
|
|
3629
|
-
server_determines_connection_id: true,
|
|
3630
|
-
device: _this.device,
|
|
3631
|
-
client_request_id: reqID
|
|
3632
|
-
};
|
|
3633
|
-
var qs = encodeURIComponent(JSON.stringify(params));
|
|
3634
|
-
|
|
3635
|
-
var token = _this.tokenManager.getToken();
|
|
3636
|
-
|
|
3637
|
-
return "".concat(_this.wsBaseURL, "/connect?json=").concat(qs, "&api_key=").concat(_this.apiKey, "&authorization=").concat(token, "&stream-auth-type=").concat(_this.authType, "&X-Stream-Client=").concat(_this.userAgent);
|
|
3726
|
+
return "".concat(_this.client.wsBaseURL, "/connect?json=").concat(qs, "&api_key=").concat(_this.client.key, "&authorization=").concat(token, "&stream-auth-type=").concat(_this.client.getAuthType(), "&X-Stream-Client=").concat(_this.client.getUserAgent());
|
|
3638
3727
|
});
|
|
3639
3728
|
|
|
3640
3729
|
_defineProperty__default['default'](this, "onlineStatusChanged", function (event) {
|
|
3641
3730
|
if (event.type === 'offline') {
|
|
3642
3731
|
// mark the connection as down
|
|
3643
|
-
_this.
|
|
3644
|
-
tags: ['connection']
|
|
3645
|
-
});
|
|
3732
|
+
_this._log('onlineStatusChanged() - Status changing to offline');
|
|
3646
3733
|
|
|
3647
3734
|
_this._setHealth(false);
|
|
3648
3735
|
} else if (event.type === 'online') {
|
|
@@ -3650,9 +3737,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3650
3737
|
// We check this.isHealthy, not sure if it's always
|
|
3651
3738
|
// smart to create a new WS connection if the old one is still up and running.
|
|
3652
3739
|
// it's possible we didn't miss any messages, so this process is just expensive and not needed.
|
|
3653
|
-
_this.
|
|
3654
|
-
tags: ['connection']
|
|
3655
|
-
});
|
|
3740
|
+
_this._log("onlineStatusChanged() - Status changing to online. isHealthy: ".concat(_this.isHealthy));
|
|
3656
3741
|
|
|
3657
3742
|
if (!_this.isHealthy) {
|
|
3658
3743
|
_this._reconnect({
|
|
@@ -3665,8 +3750,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3665
3750
|
_defineProperty__default['default'](this, "onopen", function (wsID) {
|
|
3666
3751
|
if (_this.wsID !== wsID) return;
|
|
3667
3752
|
|
|
3668
|
-
_this.
|
|
3669
|
-
tags: ['connection'],
|
|
3753
|
+
_this._log('onopen() - onopen callback', {
|
|
3670
3754
|
wsID: wsID
|
|
3671
3755
|
});
|
|
3672
3756
|
});
|
|
@@ -3678,27 +3762,26 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3678
3762
|
// after that a ws.onclose..
|
|
3679
3763
|
|
|
3680
3764
|
if (!_this.isResolved && data) {
|
|
3765
|
+
var _this$resolvePromise;
|
|
3766
|
+
|
|
3681
3767
|
_this.isResolved = true;
|
|
3682
3768
|
|
|
3683
|
-
if (data.error
|
|
3769
|
+
if (data.error) {
|
|
3684
3770
|
var _this$rejectPromise;
|
|
3685
3771
|
|
|
3686
3772
|
(_this$rejectPromise = _this.rejectPromise) === null || _this$rejectPromise === void 0 ? void 0 : _this$rejectPromise.call(_this, _this._errorFromWSEvent(data, false));
|
|
3687
3773
|
return;
|
|
3688
|
-
}
|
|
3689
|
-
var _this$resolvePromise;
|
|
3774
|
+
}
|
|
3690
3775
|
|
|
3691
|
-
|
|
3776
|
+
(_this$resolvePromise = _this.resolvePromise) === null || _this$resolvePromise === void 0 ? void 0 : _this$resolvePromise.call(_this, data);
|
|
3692
3777
|
|
|
3693
|
-
|
|
3694
|
-
}
|
|
3778
|
+
_this._setHealth(true);
|
|
3695
3779
|
} // trigger the event..
|
|
3696
3780
|
|
|
3697
3781
|
|
|
3698
3782
|
_this.lastEvent = new Date();
|
|
3699
3783
|
|
|
3700
|
-
_this.
|
|
3701
|
-
tags: ['connection'],
|
|
3784
|
+
_this._log('onmessage() - onmessage callback', {
|
|
3702
3785
|
event: event,
|
|
3703
3786
|
wsID: wsID
|
|
3704
3787
|
});
|
|
@@ -3707,7 +3790,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3707
3790
|
_this.scheduleNextPing();
|
|
3708
3791
|
}
|
|
3709
3792
|
|
|
3710
|
-
_this.
|
|
3793
|
+
_this.client.handleEvent(event);
|
|
3711
3794
|
|
|
3712
3795
|
_this.scheduleConnectionCheck();
|
|
3713
3796
|
});
|
|
@@ -3715,8 +3798,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3715
3798
|
_defineProperty__default['default'](this, "onclose", function (wsID, event) {
|
|
3716
3799
|
if (_this.wsID !== wsID) return;
|
|
3717
3800
|
|
|
3718
|
-
_this.
|
|
3719
|
-
tags: ['connection'],
|
|
3801
|
+
_this._log('onclose() - onclose callback - ' + event.code, {
|
|
3720
3802
|
event: event,
|
|
3721
3803
|
wsID: wsID
|
|
3722
3804
|
});
|
|
@@ -3733,8 +3815,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3733
3815
|
error.target = event.target;
|
|
3734
3816
|
(_this$rejectPromise2 = _this.rejectPromise) === null || _this$rejectPromise2 === void 0 ? void 0 : _this$rejectPromise2.call(_this, error);
|
|
3735
3817
|
|
|
3736
|
-
_this.
|
|
3737
|
-
tags: ['connection'],
|
|
3818
|
+
_this._log("onclose() - WS connection reject with error ".concat(event.reason), {
|
|
3738
3819
|
event: event
|
|
3739
3820
|
});
|
|
3740
3821
|
} else {
|
|
@@ -3748,8 +3829,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3748
3829
|
_this.isConnecting = false;
|
|
3749
3830
|
(_this$rejectPromise3 = _this.rejectPromise) === null || _this$rejectPromise3 === void 0 ? void 0 : _this$rejectPromise3.call(_this, _this._errorFromWSEvent(event));
|
|
3750
3831
|
|
|
3751
|
-
_this.
|
|
3752
|
-
tags: ['connection'],
|
|
3832
|
+
_this._log("onclose() - WS connection closed. Calling reconnect ...", {
|
|
3753
3833
|
event: event
|
|
3754
3834
|
}); // reconnect if its an abnormal failure
|
|
3755
3835
|
|
|
@@ -3770,8 +3850,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3770
3850
|
_this.isConnecting = false;
|
|
3771
3851
|
(_this$rejectPromise4 = _this.rejectPromise) === null || _this$rejectPromise4 === void 0 ? void 0 : _this$rejectPromise4.call(_this, _this._errorFromWSEvent(event));
|
|
3772
3852
|
|
|
3773
|
-
_this.
|
|
3774
|
-
tags: ['connection'],
|
|
3853
|
+
_this._log("onerror() - WS connection resulted into error", {
|
|
3775
3854
|
event: event
|
|
3776
3855
|
});
|
|
3777
3856
|
|
|
@@ -3779,28 +3858,28 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3779
3858
|
});
|
|
3780
3859
|
|
|
3781
3860
|
_defineProperty__default['default'](this, "_setHealth", function (healthy) {
|
|
3782
|
-
if (healthy
|
|
3783
|
-
|
|
3784
|
-
_this.isHealthy = true;
|
|
3861
|
+
if (healthy === _this.isHealthy) return;
|
|
3862
|
+
_this.isHealthy = healthy;
|
|
3785
3863
|
|
|
3786
|
-
|
|
3864
|
+
if (_this.isHealthy) {
|
|
3865
|
+
//@ts-expect-error
|
|
3866
|
+
_this.client.dispatchEvent({
|
|
3787
3867
|
type: 'connection.changed',
|
|
3788
|
-
online:
|
|
3868
|
+
online: _this.isHealthy
|
|
3789
3869
|
});
|
|
3790
|
-
}
|
|
3791
3870
|
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
}
|
|
3803
|
-
}
|
|
3871
|
+
return;
|
|
3872
|
+
} // we're offline, wait few seconds and fire and event if still offline
|
|
3873
|
+
|
|
3874
|
+
|
|
3875
|
+
setTimeout(function () {
|
|
3876
|
+
if (_this.isHealthy) return; //@ts-expect-error
|
|
3877
|
+
|
|
3878
|
+
_this.client.dispatchEvent({
|
|
3879
|
+
type: 'connection.changed',
|
|
3880
|
+
online: _this.isHealthy
|
|
3881
|
+
});
|
|
3882
|
+
}, 5000);
|
|
3804
3883
|
});
|
|
3805
3884
|
|
|
3806
3885
|
_defineProperty__default['default'](this, "_errorFromWSEvent", function (event) {
|
|
@@ -3822,10 +3901,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3822
3901
|
} // Keeping this `warn` level log, to avoid cluttering of error logs from ws failures.
|
|
3823
3902
|
|
|
3824
3903
|
|
|
3825
|
-
_this.
|
|
3826
|
-
tags: ['connection'],
|
|
3904
|
+
_this._log("_errorFromWSEvent() - WS failed with code ".concat(code), {
|
|
3827
3905
|
event: event
|
|
3828
|
-
});
|
|
3906
|
+
}, 'warn');
|
|
3829
3907
|
|
|
3830
3908
|
var error = new Error("WS failed with code ".concat(code, " and reason - ").concat(message));
|
|
3831
3909
|
error.code = code;
|
|
@@ -3839,50 +3917,13 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3839
3917
|
return error;
|
|
3840
3918
|
});
|
|
3841
3919
|
|
|
3842
|
-
_defineProperty__default['default'](this, "_listenForConnectionChanges", function () {
|
|
3843
|
-
var _window;
|
|
3844
|
-
|
|
3845
|
-
// (typeof window !== 'undefined') check is for environments where window is not defined, such as nextjs environment,
|
|
3846
|
-
// and thus (window === undefined) will result in ReferenceError.
|
|
3847
|
-
if (typeof window !== 'undefined' && (_window = window) !== null && _window !== void 0 && _window.addEventListener) {
|
|
3848
|
-
window.addEventListener('offline', _this.onlineStatusChanged);
|
|
3849
|
-
window.addEventListener('online', _this.onlineStatusChanged);
|
|
3850
|
-
}
|
|
3851
|
-
});
|
|
3852
|
-
|
|
3853
|
-
_defineProperty__default['default'](this, "_removeConnectionListeners", function () {
|
|
3854
|
-
var _window2;
|
|
3855
|
-
|
|
3856
|
-
// (typeof window !== 'undefined') check is for environments where window is not defined, such as nextjs environment,
|
|
3857
|
-
// and thus (window === undefined) will result in ReferenceError.
|
|
3858
|
-
if (typeof window !== 'undefined' && (_window2 = window) !== null && _window2 !== void 0 && _window2.removeEventListener) {
|
|
3859
|
-
window.removeEventListener('offline', _this.onlineStatusChanged);
|
|
3860
|
-
window.removeEventListener('online', _this.onlineStatusChanged);
|
|
3861
|
-
}
|
|
3862
|
-
});
|
|
3863
|
-
|
|
3864
3920
|
_defineProperty__default['default'](this, "_setupConnectionPromise", function () {
|
|
3865
|
-
var that = _this;
|
|
3866
3921
|
_this.isResolved = false;
|
|
3867
3922
|
/** a promise that is resolved once ws.open is called */
|
|
3868
3923
|
|
|
3869
3924
|
_this.connectionOpen = new Promise(function (resolve, reject) {
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
}).then(function (e) {
|
|
3873
|
-
if (e.data && typeof e.data === 'string') {
|
|
3874
|
-
var data = JSON.parse(e.data);
|
|
3875
|
-
|
|
3876
|
-
if (data && data.error != null) {
|
|
3877
|
-
throw new Error(JSON.stringify(data.error));
|
|
3878
|
-
}
|
|
3879
|
-
|
|
3880
|
-
return data;
|
|
3881
|
-
} else {
|
|
3882
|
-
return undefined;
|
|
3883
|
-
}
|
|
3884
|
-
}, function (error) {
|
|
3885
|
-
throw error;
|
|
3925
|
+
_this.resolvePromise = resolve;
|
|
3926
|
+
_this.rejectPromise = reject;
|
|
3886
3927
|
});
|
|
3887
3928
|
});
|
|
3888
3929
|
|
|
@@ -3896,7 +3937,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3896
3937
|
// send the healthcheck.., server replies with a health check event
|
|
3897
3938
|
var data = [{
|
|
3898
3939
|
type: 'health.check',
|
|
3899
|
-
client_id: _this.clientID
|
|
3940
|
+
client_id: _this.client.clientID
|
|
3900
3941
|
}]; // try to send on the connection
|
|
3901
3942
|
|
|
3902
3943
|
try {
|
|
@@ -3917,9 +3958,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3917
3958
|
var now = new Date();
|
|
3918
3959
|
|
|
3919
3960
|
if (_this.lastEvent && now.getTime() - _this.lastEvent.getTime() > _this.connectionCheckTimeout) {
|
|
3920
|
-
_this.
|
|
3921
|
-
tags: ['connection']
|
|
3922
|
-
});
|
|
3961
|
+
_this._log('scheduleConnectionCheck - going to reconnect');
|
|
3923
3962
|
|
|
3924
3963
|
_this._setHealth(false);
|
|
3925
3964
|
|
|
@@ -3928,15 +3967,8 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3928
3967
|
}, _this.connectionCheckTimeout);
|
|
3929
3968
|
});
|
|
3930
3969
|
|
|
3931
|
-
|
|
3932
|
-
this.
|
|
3933
|
-
this.userID = userID;
|
|
3934
|
-
this.user = user;
|
|
3935
|
-
this.authType = authType;
|
|
3936
|
-
this.userAgent = userAgent;
|
|
3937
|
-
this.apiKey = apiKey;
|
|
3938
|
-
this.tokenManager = tokenManager;
|
|
3939
|
-
this.device = device;
|
|
3970
|
+
/** StreamChat client */
|
|
3971
|
+
this.client = client;
|
|
3940
3972
|
/** consecutive failures influence the duration of the timeout */
|
|
3941
3973
|
|
|
3942
3974
|
this.consecutiveFailures = 0;
|
|
@@ -3946,18 +3978,15 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3946
3978
|
/** We only make 1 attempt to reconnect at the same time.. */
|
|
3947
3979
|
|
|
3948
3980
|
this.isConnecting = false;
|
|
3981
|
+
/** To avoid reconnect if client is disconnected */
|
|
3982
|
+
|
|
3983
|
+
this.isDisconnected = false;
|
|
3949
3984
|
/** Boolean that indicates if the connection promise is resolved */
|
|
3950
3985
|
|
|
3951
3986
|
this.isResolved = false;
|
|
3952
3987
|
/** Boolean that indicates if we have a working connection to the server */
|
|
3953
3988
|
|
|
3954
3989
|
this.isHealthy = false;
|
|
3955
|
-
/** Callback when the connection fails and recovers */
|
|
3956
|
-
|
|
3957
|
-
this.recoverCallback = recoverCallback;
|
|
3958
|
-
this.messageCallback = messageCallback;
|
|
3959
|
-
this.eventCallback = eventCallback;
|
|
3960
|
-
this.logger = logger;
|
|
3961
3990
|
/** Incremented when a new WS connection is made */
|
|
3962
3991
|
|
|
3963
3992
|
this.wsID = 1;
|
|
@@ -3968,74 +3997,82 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3968
3997
|
|
|
3969
3998
|
this.pingInterval = 25 * 1000;
|
|
3970
3999
|
this.connectionCheckTimeout = this.pingInterval + 10 * 1000;
|
|
3971
|
-
|
|
3972
|
-
this._listenForConnectionChanges();
|
|
3973
|
-
|
|
3974
|
-
this.postInsights = postInsights;
|
|
3975
|
-
this.insightMetrics = insightMetrics;
|
|
4000
|
+
addConnectionEventListeners(this.onlineStatusChanged);
|
|
3976
4001
|
}
|
|
3977
|
-
/**
|
|
3978
|
-
* connect - Connect to the WS URL
|
|
3979
|
-
*
|
|
3980
|
-
* @return {ConnectAPIResponse<ChannelType, CommandType, UserType>} Promise that completes once the first health check message is received
|
|
3981
|
-
*/
|
|
3982
|
-
|
|
3983
4002
|
|
|
3984
4003
|
_createClass__default['default'](StableWSConnection, [{
|
|
4004
|
+
key: "_log",
|
|
4005
|
+
value: function _log(msg) {
|
|
4006
|
+
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
4007
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
4008
|
+
this.client.logger(level, 'connection:' + msg, _objectSpread$3({
|
|
4009
|
+
tags: ['connection']
|
|
4010
|
+
}, extra));
|
|
4011
|
+
}
|
|
4012
|
+
/**
|
|
4013
|
+
* connect - Connect to the WS URL
|
|
4014
|
+
* the default 15s timeout allows between 2~3 tries
|
|
4015
|
+
* @return {ConnectAPIResponse<ChannelType, CommandType, UserType>} Promise that completes once the first health check message is received
|
|
4016
|
+
*/
|
|
4017
|
+
|
|
4018
|
+
}, {
|
|
3985
4019
|
key: "connect",
|
|
3986
4020
|
value: function () {
|
|
3987
4021
|
var _connect2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
|
3988
|
-
var
|
|
4022
|
+
var timeout,
|
|
4023
|
+
healthCheck,
|
|
4024
|
+
_args = arguments;
|
|
3989
4025
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
3990
4026
|
while (1) {
|
|
3991
4027
|
switch (_context.prev = _context.next) {
|
|
3992
4028
|
case 0:
|
|
4029
|
+
timeout = _args.length > 0 && _args[0] !== undefined ? _args[0] : 15000;
|
|
4030
|
+
|
|
3993
4031
|
if (!this.isConnecting) {
|
|
3994
|
-
_context.next =
|
|
4032
|
+
_context.next = 3;
|
|
3995
4033
|
break;
|
|
3996
4034
|
}
|
|
3997
4035
|
|
|
3998
4036
|
throw Error("You've called connect twice, can only attempt 1 connection at the time");
|
|
3999
4037
|
|
|
4000
|
-
case
|
|
4001
|
-
|
|
4002
|
-
_context.
|
|
4038
|
+
case 3:
|
|
4039
|
+
this.isDisconnected = false;
|
|
4040
|
+
_context.prev = 4;
|
|
4041
|
+
_context.next = 7;
|
|
4003
4042
|
return this._connect();
|
|
4004
4043
|
|
|
4005
|
-
case
|
|
4044
|
+
case 7:
|
|
4006
4045
|
healthCheck = _context.sent;
|
|
4007
4046
|
this.consecutiveFailures = 0;
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
_context.next =
|
|
4047
|
+
|
|
4048
|
+
this._log("connect() - Established ws connection with healthcheck: ".concat(healthCheck));
|
|
4049
|
+
|
|
4050
|
+
_context.next = 23;
|
|
4012
4051
|
break;
|
|
4013
4052
|
|
|
4014
|
-
case
|
|
4015
|
-
_context.prev =
|
|
4016
|
-
_context.t0 = _context["catch"](
|
|
4053
|
+
case 12:
|
|
4054
|
+
_context.prev = 12;
|
|
4055
|
+
_context.t0 = _context["catch"](4);
|
|
4017
4056
|
this.isHealthy = false;
|
|
4018
4057
|
this.consecutiveFailures += 1;
|
|
4019
4058
|
|
|
4020
|
-
if (!(_context.t0.code === chatCodes.TOKEN_EXPIRED && !this.tokenManager.isStatic())) {
|
|
4021
|
-
_context.next =
|
|
4059
|
+
if (!(_context.t0.code === chatCodes.TOKEN_EXPIRED && !this.client.tokenManager.isStatic())) {
|
|
4060
|
+
_context.next = 21;
|
|
4022
4061
|
break;
|
|
4023
4062
|
}
|
|
4024
4063
|
|
|
4025
|
-
this.
|
|
4026
|
-
tags: ['connection']
|
|
4027
|
-
});
|
|
4064
|
+
this._log('connect() - WS failure due to expired token, so going to try to reload token and reconnect');
|
|
4028
4065
|
|
|
4029
4066
|
this._reconnect({
|
|
4030
4067
|
refreshToken: true
|
|
4031
4068
|
});
|
|
4032
4069
|
|
|
4033
|
-
_context.next =
|
|
4070
|
+
_context.next = 23;
|
|
4034
4071
|
break;
|
|
4035
4072
|
|
|
4036
|
-
case
|
|
4073
|
+
case 21:
|
|
4037
4074
|
if (_context.t0.isWSFailure) {
|
|
4038
|
-
_context.next =
|
|
4075
|
+
_context.next = 23;
|
|
4039
4076
|
break;
|
|
4040
4077
|
}
|
|
4041
4078
|
|
|
@@ -4046,19 +4083,19 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4046
4083
|
isWSFailure: _context.t0.isWSFailure
|
|
4047
4084
|
}));
|
|
4048
4085
|
|
|
4049
|
-
case 21:
|
|
4050
|
-
_context.next = 23;
|
|
4051
|
-
return this._waitForHealthy();
|
|
4052
|
-
|
|
4053
4086
|
case 23:
|
|
4087
|
+
_context.next = 25;
|
|
4088
|
+
return this._waitForHealthy(timeout);
|
|
4089
|
+
|
|
4090
|
+
case 25:
|
|
4054
4091
|
return _context.abrupt("return", _context.sent);
|
|
4055
4092
|
|
|
4056
|
-
case
|
|
4093
|
+
case 26:
|
|
4057
4094
|
case "end":
|
|
4058
4095
|
return _context.stop();
|
|
4059
4096
|
}
|
|
4060
4097
|
}
|
|
4061
|
-
}, _callee, this, [[
|
|
4098
|
+
}, _callee, this, [[4, 12]]);
|
|
4062
4099
|
}));
|
|
4063
4100
|
|
|
4064
4101
|
function connect() {
|
|
@@ -4149,6 +4186,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4149
4186
|
return sleep(timeout);
|
|
4150
4187
|
|
|
4151
4188
|
case 2:
|
|
4189
|
+
_this2.isConnecting = false;
|
|
4152
4190
|
throw new Error(JSON.stringify({
|
|
4153
4191
|
code: '',
|
|
4154
4192
|
StatusCode: '',
|
|
@@ -4156,7 +4194,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4156
4194
|
isWSFailure: true
|
|
4157
4195
|
}));
|
|
4158
4196
|
|
|
4159
|
-
case
|
|
4197
|
+
case 4:
|
|
4160
4198
|
case "end":
|
|
4161
4199
|
return _context3.stop();
|
|
4162
4200
|
}
|
|
@@ -4180,7 +4218,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4180
4218
|
}()
|
|
4181
4219
|
/**
|
|
4182
4220
|
* Builds and returns the url for websocket.
|
|
4183
|
-
* @
|
|
4221
|
+
* @private
|
|
4184
4222
|
* @returns url string
|
|
4185
4223
|
*/
|
|
4186
4224
|
|
|
@@ -4194,10 +4232,11 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4194
4232
|
function disconnect(timeout) {
|
|
4195
4233
|
var _this3 = this;
|
|
4196
4234
|
|
|
4197
|
-
this.
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
this.
|
|
4235
|
+
this._log("disconnect() - Closing the websocket connection for wsID ".concat(this.wsID));
|
|
4236
|
+
|
|
4237
|
+
this.wsID += 1;
|
|
4238
|
+
this.isConnecting = false;
|
|
4239
|
+
this.isDisconnected = true; // start by removing all the listeners
|
|
4201
4240
|
|
|
4202
4241
|
if (this.healthCheckTimeoutRef) {
|
|
4203
4242
|
clearInterval(this.healthCheckTimeoutRef);
|
|
@@ -4207,8 +4246,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4207
4246
|
clearInterval(this.connectionCheckTimeoutRef);
|
|
4208
4247
|
}
|
|
4209
4248
|
|
|
4210
|
-
this.
|
|
4211
|
-
|
|
4249
|
+
removeConnectionEventListeners(this.onlineStatusChanged);
|
|
4212
4250
|
this.isHealthy = false; // remove ws handlers...
|
|
4213
4251
|
|
|
4214
4252
|
if (this.ws && this.ws.removeAllListeners) {
|
|
@@ -4224,8 +4262,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4224
4262
|
if (ws && ws.close && ws.readyState === ws.OPEN) {
|
|
4225
4263
|
isClosedPromise = new Promise(function (resolve) {
|
|
4226
4264
|
var onclose = function onclose(event) {
|
|
4227
|
-
_this3.
|
|
4228
|
-
tags: ['connection'],
|
|
4265
|
+
_this3._log("disconnect() - resolving isClosedPromise ".concat(event ? 'with' : 'without', " close frame"), {
|
|
4229
4266
|
event: event
|
|
4230
4267
|
});
|
|
4231
4268
|
|
|
@@ -4237,14 +4274,13 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4237
4274
|
|
|
4238
4275
|
setTimeout(onclose, timeout != null ? timeout : 1000);
|
|
4239
4276
|
});
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4277
|
+
|
|
4278
|
+
this._log("disconnect() - Manually closed connection by calling client.disconnect()");
|
|
4279
|
+
|
|
4243
4280
|
ws.close(chatCodes.WS_CLOSED_SUCCESS, 'Manually closed connection by calling client.disconnect()');
|
|
4244
4281
|
} else {
|
|
4245
|
-
this.
|
|
4246
|
-
|
|
4247
|
-
});
|
|
4282
|
+
this._log("disconnect() - ws connection doesn't exist or it is already closed.");
|
|
4283
|
+
|
|
4248
4284
|
isClosedPromise = Promise.resolve();
|
|
4249
4285
|
}
|
|
4250
4286
|
|
|
@@ -4261,13 +4297,12 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4261
4297
|
key: "_connect",
|
|
4262
4298
|
value: function () {
|
|
4263
4299
|
var _connect3 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5() {
|
|
4264
|
-
var wsURL, response,
|
|
4265
|
-
|
|
4300
|
+
var wsURL, response, insights;
|
|
4266
4301
|
return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
|
|
4267
4302
|
while (1) {
|
|
4268
4303
|
switch (_context5.prev = _context5.next) {
|
|
4269
4304
|
case 0:
|
|
4270
|
-
if (!this.isConnecting) {
|
|
4305
|
+
if (!(this.isConnecting || this.isDisconnected)) {
|
|
4271
4306
|
_context5.next = 2;
|
|
4272
4307
|
break;
|
|
4273
4308
|
}
|
|
@@ -4278,15 +4313,15 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4278
4313
|
// simply ignore _connect if it's currently trying to connect
|
|
4279
4314
|
this.isConnecting = true;
|
|
4280
4315
|
this.requestID = randomId();
|
|
4281
|
-
this.insightMetrics.connectionStartTimestamp = new Date().getTime();
|
|
4316
|
+
this.client.insightMetrics.connectionStartTimestamp = new Date().getTime();
|
|
4282
4317
|
_context5.prev = 5;
|
|
4283
4318
|
_context5.next = 8;
|
|
4284
|
-
return this.tokenManager.tokenReady();
|
|
4319
|
+
return this.client.tokenManager.tokenReady();
|
|
4285
4320
|
|
|
4286
4321
|
case 8:
|
|
4287
4322
|
this._setupConnectionPromise();
|
|
4288
4323
|
|
|
4289
|
-
wsURL = this._buildUrl(
|
|
4324
|
+
wsURL = this._buildUrl();
|
|
4290
4325
|
this.ws = new WebSocket__default['default'](wsURL);
|
|
4291
4326
|
this.ws.onopen = this.onopen.bind(this, this.wsID);
|
|
4292
4327
|
this.ws.onclose = this.onclose.bind(this, this.wsID);
|
|
@@ -4306,9 +4341,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4306
4341
|
|
|
4307
4342
|
this.connectionID = response.connection_id;
|
|
4308
4343
|
|
|
4309
|
-
if (this.insightMetrics.wsConsecutiveFailures > 0 && this.
|
|
4310
|
-
|
|
4311
|
-
this.insightMetrics.wsConsecutiveFailures = 0;
|
|
4344
|
+
if (this.client.insightMetrics.wsConsecutiveFailures > 0 && this.client.options.enableInsights) {
|
|
4345
|
+
postInsights('ws_success_after_failure', buildWsSuccessAfterFailureInsight(this));
|
|
4346
|
+
this.client.insightMetrics.wsConsecutiveFailures = 0;
|
|
4312
4347
|
}
|
|
4313
4348
|
|
|
4314
4349
|
return _context5.abrupt("return", response);
|
|
@@ -4322,12 +4357,11 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4322
4357
|
_context5.t0 = _context5["catch"](5);
|
|
4323
4358
|
this.isConnecting = false;
|
|
4324
4359
|
|
|
4325
|
-
if (this.
|
|
4326
|
-
this.insightMetrics.wsConsecutiveFailures++;
|
|
4327
|
-
this.insightMetrics.wsTotalFailures++;
|
|
4328
|
-
|
|
4360
|
+
if (this.client.options.enableInsights) {
|
|
4361
|
+
this.client.insightMetrics.wsConsecutiveFailures++;
|
|
4362
|
+
this.client.insightMetrics.wsTotalFailures++;
|
|
4329
4363
|
insights = buildWsFatalInsight(this, convertErrorToJson(_context5.t0));
|
|
4330
|
-
|
|
4364
|
+
postInsights === null || postInsights === void 0 ? void 0 : postInsights('ws_fatal', insights);
|
|
4331
4365
|
}
|
|
4332
4366
|
|
|
4333
4367
|
throw _context5.t0;
|
|
@@ -4361,26 +4395,23 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4361
4395
|
var _reconnect2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee6() {
|
|
4362
4396
|
var options,
|
|
4363
4397
|
interval,
|
|
4364
|
-
_open,
|
|
4365
4398
|
_args6 = arguments;
|
|
4366
|
-
|
|
4367
4399
|
return _regeneratorRuntime__default['default'].wrap(function _callee6$(_context6) {
|
|
4368
4400
|
while (1) {
|
|
4369
4401
|
switch (_context6.prev = _context6.next) {
|
|
4370
4402
|
case 0:
|
|
4371
4403
|
options = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4404
|
+
|
|
4405
|
+
this._log('_reconnect() - Initiating the reconnect'); // only allow 1 connection at the time
|
|
4406
|
+
|
|
4375
4407
|
|
|
4376
4408
|
if (!(this.isConnecting || this.isHealthy)) {
|
|
4377
4409
|
_context6.next = 5;
|
|
4378
4410
|
break;
|
|
4379
4411
|
}
|
|
4380
4412
|
|
|
4381
|
-
this.
|
|
4382
|
-
|
|
4383
|
-
});
|
|
4413
|
+
this._log('_reconnect() - Abort (1) since already connecting or healthy');
|
|
4414
|
+
|
|
4384
4415
|
return _context6.abrupt("return");
|
|
4385
4416
|
|
|
4386
4417
|
case 5:
|
|
@@ -4402,95 +4433,86 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4402
4433
|
break;
|
|
4403
4434
|
}
|
|
4404
4435
|
|
|
4405
|
-
this.
|
|
4406
|
-
|
|
4407
|
-
});
|
|
4436
|
+
this._log('_reconnect() - Abort (2) since already connecting or healthy');
|
|
4437
|
+
|
|
4408
4438
|
return _context6.abrupt("return");
|
|
4409
4439
|
|
|
4410
4440
|
case 12:
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
}
|
|
4441
|
+
if (!this.isDisconnected) {
|
|
4442
|
+
_context6.next = 15;
|
|
4443
|
+
break;
|
|
4444
|
+
}
|
|
4445
|
+
|
|
4446
|
+
this._log('_reconnect() - Abort (3) since disconnect() is called');
|
|
4447
|
+
|
|
4448
|
+
return _context6.abrupt("return");
|
|
4449
|
+
|
|
4450
|
+
case 15:
|
|
4451
|
+
this._log('_reconnect() - Destroying current WS connection'); // cleanup the old connection
|
|
4452
|
+
|
|
4415
4453
|
|
|
4416
4454
|
this._destroyCurrentWSConnection();
|
|
4417
4455
|
|
|
4418
4456
|
if (!options.refreshToken) {
|
|
4419
|
-
_context6.next =
|
|
4457
|
+
_context6.next = 20;
|
|
4420
4458
|
break;
|
|
4421
4459
|
}
|
|
4422
4460
|
|
|
4423
|
-
_context6.next = 17;
|
|
4424
|
-
return this.tokenManager.loadToken();
|
|
4425
|
-
|
|
4426
|
-
case 17:
|
|
4427
|
-
_context6.prev = 17;
|
|
4428
4461
|
_context6.next = 20;
|
|
4429
|
-
return this.
|
|
4462
|
+
return this.client.tokenManager.loadToken();
|
|
4430
4463
|
|
|
4431
4464
|
case 20:
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
_context6.next = 26;
|
|
4436
|
-
break;
|
|
4437
|
-
}
|
|
4465
|
+
_context6.prev = 20;
|
|
4466
|
+
_context6.next = 23;
|
|
4467
|
+
return this._connect();
|
|
4438
4468
|
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
});
|
|
4442
|
-
_context6.next = 25;
|
|
4443
|
-
return this.recoverCallback(_open);
|
|
4469
|
+
case 23:
|
|
4470
|
+
this._log('_reconnect() - Waiting for recoverCallBack');
|
|
4444
4471
|
|
|
4445
|
-
|
|
4446
|
-
this.
|
|
4447
|
-
tags: ['connection']
|
|
4448
|
-
});
|
|
4472
|
+
_context6.next = 26;
|
|
4473
|
+
return this.client.recoverState();
|
|
4449
4474
|
|
|
4450
4475
|
case 26:
|
|
4476
|
+
this._log('_reconnect() - Finished recoverCallBack');
|
|
4477
|
+
|
|
4451
4478
|
this.consecutiveFailures = 0;
|
|
4452
|
-
_context6.next =
|
|
4479
|
+
_context6.next = 38;
|
|
4453
4480
|
break;
|
|
4454
4481
|
|
|
4455
|
-
case
|
|
4456
|
-
_context6.prev =
|
|
4457
|
-
_context6.t0 = _context6["catch"](
|
|
4482
|
+
case 30:
|
|
4483
|
+
_context6.prev = 30;
|
|
4484
|
+
_context6.t0 = _context6["catch"](20);
|
|
4458
4485
|
this.isHealthy = false;
|
|
4459
4486
|
this.consecutiveFailures += 1;
|
|
4460
4487
|
|
|
4461
|
-
if (!(_context6.t0.code === chatCodes.TOKEN_EXPIRED && !this.tokenManager.isStatic())) {
|
|
4462
|
-
_context6.next =
|
|
4488
|
+
if (!(_context6.t0.code === chatCodes.TOKEN_EXPIRED && !this.client.tokenManager.isStatic())) {
|
|
4489
|
+
_context6.next = 37;
|
|
4463
4490
|
break;
|
|
4464
4491
|
}
|
|
4465
4492
|
|
|
4466
|
-
this.
|
|
4467
|
-
|
|
4468
|
-
});
|
|
4493
|
+
this._log('_reconnect() - WS failure due to expired token, so going to try to reload token and reconnect');
|
|
4494
|
+
|
|
4469
4495
|
return _context6.abrupt("return", this._reconnect({
|
|
4470
4496
|
refreshToken: true
|
|
4471
4497
|
}));
|
|
4472
4498
|
|
|
4473
|
-
case
|
|
4499
|
+
case 37:
|
|
4474
4500
|
// reconnect on WS failures, don't reconnect if there is a code bug
|
|
4475
4501
|
if (_context6.t0.isWSFailure) {
|
|
4476
|
-
this.
|
|
4477
|
-
tags: ['connection']
|
|
4478
|
-
});
|
|
4502
|
+
this._log('_reconnect() - WS failure, so going to try to reconnect');
|
|
4479
4503
|
|
|
4480
4504
|
this._reconnect();
|
|
4481
4505
|
}
|
|
4482
4506
|
|
|
4483
|
-
case 37:
|
|
4484
|
-
this.logger('info', 'connection:_reconnect() - == END ==', {
|
|
4485
|
-
tags: ['connection']
|
|
4486
|
-
});
|
|
4487
|
-
|
|
4488
4507
|
case 38:
|
|
4508
|
+
this._log('_reconnect() - == END ==');
|
|
4509
|
+
|
|
4510
|
+
case 39:
|
|
4489
4511
|
case "end":
|
|
4490
4512
|
return _context6.stop();
|
|
4491
4513
|
}
|
|
4492
4514
|
}
|
|
4493
|
-
}, _callee6, this, [[
|
|
4515
|
+
}, _callee6, this, [[20, 30]]);
|
|
4494
4516
|
}));
|
|
4495
4517
|
|
|
4496
4518
|
function _reconnect() {
|
|
@@ -4519,13 +4541,10 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4519
4541
|
this.wsID += 1;
|
|
4520
4542
|
|
|
4521
4543
|
try {
|
|
4522
|
-
|
|
4523
|
-
this.ws.removeAllListeners();
|
|
4524
|
-
}
|
|
4544
|
+
var _this$ws2, _this$ws3;
|
|
4525
4545
|
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
}
|
|
4546
|
+
this === null || this === void 0 ? void 0 : (_this$ws2 = this.ws) === null || _this$ws2 === void 0 ? void 0 : _this$ws2.removeAllListeners();
|
|
4547
|
+
this === null || this === void 0 ? void 0 : (_this$ws3 = this.ws) === null || _this$ws3 === void 0 ? void 0 : _this$ws3.close();
|
|
4529
4548
|
} catch (e) {// we don't care
|
|
4530
4549
|
}
|
|
4531
4550
|
}
|
|
@@ -4538,9 +4557,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4538
4557
|
return StableWSConnection;
|
|
4539
4558
|
}();
|
|
4540
4559
|
|
|
4541
|
-
function ownKeys$
|
|
4560
|
+
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
4542
4561
|
|
|
4543
|
-
function _objectSpread$
|
|
4562
|
+
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(Object(source), true).forEach(function (key) { _defineProperty__default['default'](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
4544
4563
|
|
|
4545
4564
|
/**
|
|
4546
4565
|
* Creates the JWT token that can be used for a UserSession
|
|
@@ -4549,7 +4568,7 @@ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) {
|
|
|
4549
4568
|
* @private
|
|
4550
4569
|
* @param {Secret} apiSecret - API Secret key
|
|
4551
4570
|
* @param {string} userId - The user_id key in the JWT payload
|
|
4552
|
-
* @param {
|
|
4571
|
+
* @param {UR} [extraData] - Extra that should be part of the JWT token
|
|
4553
4572
|
* @param {SignOptions} [jwtOptions] - Options that can be past to jwt.sign
|
|
4554
4573
|
* @return {string} JWT Token
|
|
4555
4574
|
*/
|
|
@@ -4561,7 +4580,7 @@ function JWTUserToken(apiSecret, userId) {
|
|
|
4561
4580
|
throw new TypeError('userId should be a string');
|
|
4562
4581
|
}
|
|
4563
4582
|
|
|
4564
|
-
var payload = _objectSpread$
|
|
4583
|
+
var payload = _objectSpread$2({
|
|
4565
4584
|
user_id: userId
|
|
4566
4585
|
}, extraData); // make sure we return a clear error when jwt is shimmed (ie. browser build)
|
|
4567
4586
|
|
|
@@ -4748,76 +4767,586 @@ function TokenManager(secret) {
|
|
|
4748
4767
|
break;
|
|
4749
4768
|
}
|
|
4750
4769
|
|
|
4751
|
-
return _context2.abrupt("return", resolve(_this.token));
|
|
4770
|
+
return _context2.abrupt("return", resolve(_this.token));
|
|
4771
|
+
|
|
4772
|
+
case 2:
|
|
4773
|
+
if (!(_this.tokenProvider && typeof _this.tokenProvider !== 'string')) {
|
|
4774
|
+
_context2.next = 7;
|
|
4775
|
+
break;
|
|
4776
|
+
}
|
|
4777
|
+
|
|
4778
|
+
_context2.next = 5;
|
|
4779
|
+
return _this.tokenProvider();
|
|
4780
|
+
|
|
4781
|
+
case 5:
|
|
4782
|
+
_this.token = _context2.sent;
|
|
4783
|
+
resolve(_this.token);
|
|
4784
|
+
|
|
4785
|
+
case 7:
|
|
4786
|
+
case "end":
|
|
4787
|
+
return _context2.stop();
|
|
4788
|
+
}
|
|
4789
|
+
}
|
|
4790
|
+
}, _callee2);
|
|
4791
|
+
}));
|
|
4792
|
+
|
|
4793
|
+
return function (_x3) {
|
|
4794
|
+
return _ref2.apply(this, arguments);
|
|
4795
|
+
};
|
|
4796
|
+
}());
|
|
4797
|
+
return _this.loadTokenPromise;
|
|
4798
|
+
});
|
|
4799
|
+
|
|
4800
|
+
_defineProperty__default['default'](this, "getToken", function () {
|
|
4801
|
+
if (_this.token) {
|
|
4802
|
+
return _this.token;
|
|
4803
|
+
}
|
|
4804
|
+
|
|
4805
|
+
if (_this.user && _this.user.anon && !_this.token) {
|
|
4806
|
+
return _this.token;
|
|
4807
|
+
}
|
|
4808
|
+
|
|
4809
|
+
if (_this.secret) {
|
|
4810
|
+
return JWTServerToken(_this.secret);
|
|
4811
|
+
}
|
|
4812
|
+
|
|
4813
|
+
throw new Error("Both secret and user tokens are not set. Either client.connectUser wasn't called or client.disconnect was called");
|
|
4814
|
+
});
|
|
4815
|
+
|
|
4816
|
+
_defineProperty__default['default'](this, "isStatic", function () {
|
|
4817
|
+
return _this.type === 'static';
|
|
4818
|
+
});
|
|
4819
|
+
|
|
4820
|
+
this.loadTokenPromise = null;
|
|
4821
|
+
|
|
4822
|
+
if (secret) {
|
|
4823
|
+
this.secret = secret;
|
|
4824
|
+
}
|
|
4825
|
+
|
|
4826
|
+
this.type = 'static';
|
|
4827
|
+
|
|
4828
|
+
if (this.secret) {
|
|
4829
|
+
this.token = JWTServerToken(this.secret);
|
|
4830
|
+
}
|
|
4831
|
+
}
|
|
4832
|
+
/**
|
|
4833
|
+
* Set the static string token or token provider.
|
|
4834
|
+
* Token provider should return a token string or a promise which resolves to string token.
|
|
4835
|
+
*
|
|
4836
|
+
* @param {TokenOrProvider} tokenOrProvider
|
|
4837
|
+
* @param {UserResponse<UserType>} user
|
|
4838
|
+
*/
|
|
4839
|
+
;
|
|
4840
|
+
|
|
4841
|
+
var APIErrorCodes = {
|
|
4842
|
+
'-1': {
|
|
4843
|
+
name: 'InternalSystemError',
|
|
4844
|
+
retryable: true
|
|
4845
|
+
},
|
|
4846
|
+
'2': {
|
|
4847
|
+
name: 'AccessKeyError',
|
|
4848
|
+
retryable: false
|
|
4849
|
+
},
|
|
4850
|
+
'3': {
|
|
4851
|
+
name: 'AuthenticationFailedError',
|
|
4852
|
+
retryable: true
|
|
4853
|
+
},
|
|
4854
|
+
'4': {
|
|
4855
|
+
name: 'InputError',
|
|
4856
|
+
retryable: false
|
|
4857
|
+
},
|
|
4858
|
+
'6': {
|
|
4859
|
+
name: 'DuplicateUsernameError',
|
|
4860
|
+
retryable: false
|
|
4861
|
+
},
|
|
4862
|
+
'9': {
|
|
4863
|
+
name: 'RateLimitError',
|
|
4864
|
+
retryable: true
|
|
4865
|
+
},
|
|
4866
|
+
'16': {
|
|
4867
|
+
name: 'DoesNotExistError',
|
|
4868
|
+
retryable: false
|
|
4869
|
+
},
|
|
4870
|
+
'17': {
|
|
4871
|
+
name: 'NotAllowedError',
|
|
4872
|
+
retryable: false
|
|
4873
|
+
},
|
|
4874
|
+
'18': {
|
|
4875
|
+
name: 'EventNotSupportedError',
|
|
4876
|
+
retryable: false
|
|
4877
|
+
},
|
|
4878
|
+
'19': {
|
|
4879
|
+
name: 'ChannelFeatureNotSupportedError',
|
|
4880
|
+
retryable: false
|
|
4881
|
+
},
|
|
4882
|
+
'20': {
|
|
4883
|
+
name: 'MessageTooLongError',
|
|
4884
|
+
retryable: false
|
|
4885
|
+
},
|
|
4886
|
+
'21': {
|
|
4887
|
+
name: 'MultipleNestingLevelError',
|
|
4888
|
+
retryable: false
|
|
4889
|
+
},
|
|
4890
|
+
'22': {
|
|
4891
|
+
name: 'PayloadTooBigError',
|
|
4892
|
+
retryable: false
|
|
4893
|
+
},
|
|
4894
|
+
'23': {
|
|
4895
|
+
name: 'RequestTimeoutError',
|
|
4896
|
+
retryable: true
|
|
4897
|
+
},
|
|
4898
|
+
'24': {
|
|
4899
|
+
name: 'MaxHeaderSizeExceededError',
|
|
4900
|
+
retryable: false
|
|
4901
|
+
},
|
|
4902
|
+
'40': {
|
|
4903
|
+
name: 'AuthErrorTokenExpired',
|
|
4904
|
+
retryable: false
|
|
4905
|
+
},
|
|
4906
|
+
'41': {
|
|
4907
|
+
name: 'AuthErrorTokenNotValidYet',
|
|
4908
|
+
retryable: false
|
|
4909
|
+
},
|
|
4910
|
+
'42': {
|
|
4911
|
+
name: 'AuthErrorTokenUsedBeforeIssuedAt',
|
|
4912
|
+
retryable: false
|
|
4913
|
+
},
|
|
4914
|
+
'43': {
|
|
4915
|
+
name: 'AuthErrorTokenSignatureInvalid',
|
|
4916
|
+
retryable: false
|
|
4917
|
+
},
|
|
4918
|
+
'44': {
|
|
4919
|
+
name: 'CustomCommandEndpointMissingError',
|
|
4920
|
+
retryable: false
|
|
4921
|
+
},
|
|
4922
|
+
'45': {
|
|
4923
|
+
name: 'CustomCommandEndpointCallError',
|
|
4924
|
+
retryable: true
|
|
4925
|
+
},
|
|
4926
|
+
'46': {
|
|
4927
|
+
name: 'ConnectionIDNotFoundError',
|
|
4928
|
+
retryable: false
|
|
4929
|
+
},
|
|
4930
|
+
'60': {
|
|
4931
|
+
name: 'CoolDownError',
|
|
4932
|
+
retryable: true
|
|
4933
|
+
},
|
|
4934
|
+
'69': {
|
|
4935
|
+
name: 'ErrWrongRegion',
|
|
4936
|
+
retryable: false
|
|
4937
|
+
},
|
|
4938
|
+
'70': {
|
|
4939
|
+
name: 'ErrQueryChannelPermissions',
|
|
4940
|
+
retryable: false
|
|
4941
|
+
},
|
|
4942
|
+
'71': {
|
|
4943
|
+
name: 'ErrTooManyConnections',
|
|
4944
|
+
retryable: true
|
|
4945
|
+
},
|
|
4946
|
+
'99': {
|
|
4947
|
+
name: 'AppSuspendedError',
|
|
4948
|
+
retryable: false
|
|
4949
|
+
}
|
|
4950
|
+
};
|
|
4951
|
+
function isAPIError(error) {
|
|
4952
|
+
return error.code !== undefined;
|
|
4953
|
+
}
|
|
4954
|
+
function isErrorRetryable(error) {
|
|
4955
|
+
if (!error.code) return false;
|
|
4956
|
+
var err = APIErrorCodes["".concat(error.code)];
|
|
4957
|
+
if (!err) return false;
|
|
4958
|
+
return err.retryable;
|
|
4959
|
+
}
|
|
4960
|
+
function isConnectionIDError(error) {
|
|
4961
|
+
return error.code === 46; // ConnectionIDNotFoundError
|
|
4962
|
+
}
|
|
4963
|
+
function isWSFailure(err) {
|
|
4964
|
+
if (typeof err.isWSFailure === 'boolean') {
|
|
4965
|
+
return err.isWSFailure;
|
|
4966
|
+
}
|
|
4967
|
+
|
|
4968
|
+
try {
|
|
4969
|
+
return JSON.parse(err.message).isWSFailure;
|
|
4970
|
+
} catch (_) {
|
|
4971
|
+
return false;
|
|
4972
|
+
}
|
|
4973
|
+
}
|
|
4974
|
+
|
|
4975
|
+
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
4976
|
+
|
|
4977
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(Object(source), true).forEach(function (key) { _defineProperty__default['default'](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
4978
|
+
var ConnectionState;
|
|
4979
|
+
|
|
4980
|
+
(function (ConnectionState) {
|
|
4981
|
+
ConnectionState["Closed"] = "CLOSED";
|
|
4982
|
+
ConnectionState["Connected"] = "CONNECTED";
|
|
4983
|
+
ConnectionState["Connecting"] = "CONNECTING";
|
|
4984
|
+
ConnectionState["Disconnected"] = "DISCONNECTED";
|
|
4985
|
+
ConnectionState["Init"] = "INIT";
|
|
4986
|
+
})(ConnectionState || (ConnectionState = {}));
|
|
4987
|
+
|
|
4988
|
+
var WSConnectionFallback = /*#__PURE__*/function () {
|
|
4989
|
+
function WSConnectionFallback(_ref) {
|
|
4990
|
+
var _this = this;
|
|
4991
|
+
|
|
4992
|
+
var client = _ref.client;
|
|
4993
|
+
|
|
4994
|
+
_classCallCheck__default['default'](this, WSConnectionFallback);
|
|
4995
|
+
|
|
4996
|
+
_defineProperty__default['default'](this, "client", void 0);
|
|
4997
|
+
|
|
4998
|
+
_defineProperty__default['default'](this, "state", void 0);
|
|
4999
|
+
|
|
5000
|
+
_defineProperty__default['default'](this, "consecutiveFailures", void 0);
|
|
5001
|
+
|
|
5002
|
+
_defineProperty__default['default'](this, "connectionID", void 0);
|
|
5003
|
+
|
|
5004
|
+
_defineProperty__default['default'](this, "cancelToken", void 0);
|
|
5005
|
+
|
|
5006
|
+
_defineProperty__default['default'](this, "_onlineStatusChanged", function (event) {
|
|
5007
|
+
_this._log("_onlineStatusChanged() - ".concat(event.type));
|
|
5008
|
+
|
|
5009
|
+
if (event.type === 'offline') {
|
|
5010
|
+
var _this$cancelToken;
|
|
5011
|
+
|
|
5012
|
+
_this._setState(ConnectionState.Closed);
|
|
5013
|
+
|
|
5014
|
+
(_this$cancelToken = _this.cancelToken) === null || _this$cancelToken === void 0 ? void 0 : _this$cancelToken.cancel('disconnect() is called');
|
|
5015
|
+
_this.cancelToken = undefined;
|
|
5016
|
+
return;
|
|
5017
|
+
}
|
|
5018
|
+
|
|
5019
|
+
if (event.type === 'online' && _this.state === ConnectionState.Closed) {
|
|
5020
|
+
_this.connect(true);
|
|
5021
|
+
}
|
|
5022
|
+
});
|
|
5023
|
+
|
|
5024
|
+
_defineProperty__default['default'](this, "_req", /*#__PURE__*/function () {
|
|
5025
|
+
var _ref2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(params, config, retry) {
|
|
5026
|
+
var _this$cancelToken2, res;
|
|
5027
|
+
|
|
5028
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
5029
|
+
while (1) {
|
|
5030
|
+
switch (_context.prev = _context.next) {
|
|
5031
|
+
case 0:
|
|
5032
|
+
if (!_this.cancelToken && !params.close) {
|
|
5033
|
+
_this.cancelToken = axios__default['default'].CancelToken.source();
|
|
5034
|
+
}
|
|
5035
|
+
|
|
5036
|
+
_context.prev = 1;
|
|
5037
|
+
_context.next = 4;
|
|
5038
|
+
return _this.client.doAxiosRequest('get', _this.client.baseURL.replace(':3030', ':8900') + '/longpoll', // replace port if present for testing with local API
|
|
5039
|
+
undefined, {
|
|
5040
|
+
config: _objectSpread$1(_objectSpread$1({}, config), {}, {
|
|
5041
|
+
cancelToken: (_this$cancelToken2 = _this.cancelToken) === null || _this$cancelToken2 === void 0 ? void 0 : _this$cancelToken2.token
|
|
5042
|
+
}),
|
|
5043
|
+
params: params
|
|
5044
|
+
});
|
|
5045
|
+
|
|
5046
|
+
case 4:
|
|
5047
|
+
res = _context.sent;
|
|
5048
|
+
_this.consecutiveFailures = 0; // always reset in case of no error
|
|
5049
|
+
|
|
5050
|
+
return _context.abrupt("return", res);
|
|
5051
|
+
|
|
5052
|
+
case 9:
|
|
5053
|
+
_context.prev = 9;
|
|
5054
|
+
_context.t0 = _context["catch"](1);
|
|
5055
|
+
_this.consecutiveFailures += 1;
|
|
5056
|
+
|
|
5057
|
+
if (!(retry && isErrorRetryable(_context.t0))) {
|
|
5058
|
+
_context.next = 17;
|
|
5059
|
+
break;
|
|
5060
|
+
}
|
|
5061
|
+
|
|
5062
|
+
_this._log("_req() - Retryable error, retrying request");
|
|
5063
|
+
|
|
5064
|
+
_context.next = 16;
|
|
5065
|
+
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5066
|
+
|
|
5067
|
+
case 16:
|
|
5068
|
+
return _context.abrupt("return", _this._req(params, config, retry));
|
|
5069
|
+
|
|
5070
|
+
case 17:
|
|
5071
|
+
throw _context.t0;
|
|
5072
|
+
|
|
5073
|
+
case 18:
|
|
5074
|
+
case "end":
|
|
5075
|
+
return _context.stop();
|
|
5076
|
+
}
|
|
5077
|
+
}
|
|
5078
|
+
}, _callee, null, [[1, 9]]);
|
|
5079
|
+
}));
|
|
5080
|
+
|
|
5081
|
+
return function (_x, _x2, _x3) {
|
|
5082
|
+
return _ref2.apply(this, arguments);
|
|
5083
|
+
};
|
|
5084
|
+
}());
|
|
5085
|
+
|
|
5086
|
+
_defineProperty__default['default'](this, "_poll", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
|
|
5087
|
+
var _data$events, data, i;
|
|
5088
|
+
|
|
5089
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
5090
|
+
while (1) {
|
|
5091
|
+
switch (_context2.prev = _context2.next) {
|
|
5092
|
+
case 0:
|
|
5093
|
+
if (!(_this.state === ConnectionState.Connected)) {
|
|
5094
|
+
_context2.next = 25;
|
|
5095
|
+
break;
|
|
5096
|
+
}
|
|
5097
|
+
|
|
5098
|
+
_context2.prev = 1;
|
|
5099
|
+
_context2.next = 4;
|
|
5100
|
+
return _this._req({}, {
|
|
5101
|
+
timeout: 30000
|
|
5102
|
+
}, true);
|
|
5103
|
+
|
|
5104
|
+
case 4:
|
|
5105
|
+
data = _context2.sent;
|
|
5106
|
+
|
|
5107
|
+
// 30s => API responds in 20s if there is no event
|
|
5108
|
+
if ((_data$events = data.events) !== null && _data$events !== void 0 && _data$events.length) {
|
|
5109
|
+
for (i = 0; i < data.events.length; i++) {
|
|
5110
|
+
_this.client.dispatchEvent(data.events[i]);
|
|
5111
|
+
}
|
|
5112
|
+
}
|
|
5113
|
+
|
|
5114
|
+
_context2.next = 23;
|
|
5115
|
+
break;
|
|
5116
|
+
|
|
5117
|
+
case 8:
|
|
5118
|
+
_context2.prev = 8;
|
|
5119
|
+
_context2.t0 = _context2["catch"](1);
|
|
5120
|
+
|
|
5121
|
+
if (!axios__default['default'].isCancel(_context2.t0)) {
|
|
5122
|
+
_context2.next = 13;
|
|
5123
|
+
break;
|
|
5124
|
+
}
|
|
5125
|
+
|
|
5126
|
+
_this._log("_poll() - axios canceled request");
|
|
5127
|
+
|
|
5128
|
+
return _context2.abrupt("return");
|
|
5129
|
+
|
|
5130
|
+
case 13:
|
|
5131
|
+
if (!isConnectionIDError(_context2.t0)) {
|
|
5132
|
+
_context2.next = 18;
|
|
5133
|
+
break;
|
|
5134
|
+
}
|
|
5135
|
+
|
|
5136
|
+
_this._log("_poll() - ConnectionID error, connecting without ID...");
|
|
5137
|
+
|
|
5138
|
+
_this._setState(ConnectionState.Disconnected);
|
|
5139
|
+
|
|
5140
|
+
_this.connect(true);
|
|
5141
|
+
|
|
5142
|
+
return _context2.abrupt("return");
|
|
5143
|
+
|
|
5144
|
+
case 18:
|
|
5145
|
+
if (!(isAPIError(_context2.t0) && !isErrorRetryable(_context2.t0))) {
|
|
5146
|
+
_context2.next = 21;
|
|
5147
|
+
break;
|
|
5148
|
+
}
|
|
5149
|
+
|
|
5150
|
+
_this._setState(ConnectionState.Closed);
|
|
5151
|
+
|
|
5152
|
+
return _context2.abrupt("return");
|
|
5153
|
+
|
|
5154
|
+
case 21:
|
|
5155
|
+
_context2.next = 23;
|
|
5156
|
+
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5157
|
+
|
|
5158
|
+
case 23:
|
|
5159
|
+
_context2.next = 0;
|
|
5160
|
+
break;
|
|
5161
|
+
|
|
5162
|
+
case 25:
|
|
5163
|
+
case "end":
|
|
5164
|
+
return _context2.stop();
|
|
5165
|
+
}
|
|
5166
|
+
}
|
|
5167
|
+
}, _callee2, null, [[1, 8]]);
|
|
5168
|
+
})));
|
|
5169
|
+
|
|
5170
|
+
_defineProperty__default['default'](this, "connect", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
5171
|
+
var reconnect,
|
|
5172
|
+
_yield$_this$_req,
|
|
5173
|
+
event,
|
|
5174
|
+
_args3 = arguments;
|
|
5175
|
+
|
|
5176
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
5177
|
+
while (1) {
|
|
5178
|
+
switch (_context3.prev = _context3.next) {
|
|
5179
|
+
case 0:
|
|
5180
|
+
reconnect = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : false;
|
|
5181
|
+
|
|
5182
|
+
if (!(_this.state === ConnectionState.Connecting)) {
|
|
5183
|
+
_context3.next = 4;
|
|
5184
|
+
break;
|
|
5185
|
+
}
|
|
5186
|
+
|
|
5187
|
+
_this._log('connect() - connecting already in progress', {
|
|
5188
|
+
reconnect: reconnect
|
|
5189
|
+
}, 'warn');
|
|
5190
|
+
|
|
5191
|
+
return _context3.abrupt("return");
|
|
5192
|
+
|
|
5193
|
+
case 4:
|
|
5194
|
+
if (!(_this.state === ConnectionState.Connected)) {
|
|
5195
|
+
_context3.next = 7;
|
|
5196
|
+
break;
|
|
5197
|
+
}
|
|
5198
|
+
|
|
5199
|
+
_this._log('connect() - already connected and polling', {
|
|
5200
|
+
reconnect: reconnect
|
|
5201
|
+
}, 'warn');
|
|
5202
|
+
|
|
5203
|
+
return _context3.abrupt("return");
|
|
5204
|
+
|
|
5205
|
+
case 7:
|
|
5206
|
+
_this._setState(ConnectionState.Connecting);
|
|
5207
|
+
|
|
5208
|
+
_this.connectionID = undefined; // connect should be sent with empty connection_id so API creates one
|
|
5209
|
+
|
|
5210
|
+
_context3.prev = 9;
|
|
5211
|
+
_context3.next = 12;
|
|
5212
|
+
return _this._req({
|
|
5213
|
+
json: _this.client._buildWSPayload()
|
|
5214
|
+
}, {
|
|
5215
|
+
timeout: 8000
|
|
5216
|
+
}, // 8s
|
|
5217
|
+
reconnect);
|
|
5218
|
+
|
|
5219
|
+
case 12:
|
|
5220
|
+
_yield$_this$_req = _context3.sent;
|
|
5221
|
+
event = _yield$_this$_req.event;
|
|
5222
|
+
|
|
5223
|
+
_this._setState(ConnectionState.Connected);
|
|
5224
|
+
|
|
5225
|
+
_this.connectionID = event.connection_id;
|
|
5226
|
+
|
|
5227
|
+
_this._poll();
|
|
5228
|
+
|
|
5229
|
+
if (reconnect) {
|
|
5230
|
+
_this.client.recoverState();
|
|
5231
|
+
}
|
|
5232
|
+
|
|
5233
|
+
return _context3.abrupt("return", event);
|
|
5234
|
+
|
|
5235
|
+
case 21:
|
|
5236
|
+
_context3.prev = 21;
|
|
5237
|
+
_context3.t0 = _context3["catch"](9);
|
|
5238
|
+
|
|
5239
|
+
_this._setState(ConnectionState.Closed);
|
|
5240
|
+
|
|
5241
|
+
throw _context3.t0;
|
|
5242
|
+
|
|
5243
|
+
case 25:
|
|
5244
|
+
case "end":
|
|
5245
|
+
return _context3.stop();
|
|
5246
|
+
}
|
|
5247
|
+
}
|
|
5248
|
+
}, _callee3, null, [[9, 21]]);
|
|
5249
|
+
})));
|
|
5250
|
+
|
|
5251
|
+
_defineProperty__default['default'](this, "isHealthy", function () {
|
|
5252
|
+
return _this.connectionID && _this.state === ConnectionState.Connected;
|
|
5253
|
+
});
|
|
4752
5254
|
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
_context2.next = 7;
|
|
4756
|
-
break;
|
|
4757
|
-
}
|
|
5255
|
+
_defineProperty__default['default'](this, "disconnect", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4() {
|
|
5256
|
+
var _this$cancelToken3;
|
|
4758
5257
|
|
|
4759
|
-
|
|
4760
|
-
|
|
5258
|
+
var timeout,
|
|
5259
|
+
connection_id,
|
|
5260
|
+
_args4 = arguments;
|
|
5261
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
5262
|
+
while (1) {
|
|
5263
|
+
switch (_context4.prev = _context4.next) {
|
|
5264
|
+
case 0:
|
|
5265
|
+
timeout = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : 2000;
|
|
5266
|
+
removeConnectionEventListeners(_this._onlineStatusChanged);
|
|
5267
|
+
|
|
5268
|
+
_this._setState(ConnectionState.Disconnected);
|
|
5269
|
+
|
|
5270
|
+
(_this$cancelToken3 = _this.cancelToken) === null || _this$cancelToken3 === void 0 ? void 0 : _this$cancelToken3.cancel('disconnect() is called');
|
|
5271
|
+
_this.cancelToken = undefined;
|
|
5272
|
+
connection_id = _this.connectionID;
|
|
5273
|
+
_this.connectionID = undefined;
|
|
5274
|
+
_context4.prev = 7;
|
|
5275
|
+
_context4.next = 10;
|
|
5276
|
+
return _this._req({
|
|
5277
|
+
close: true,
|
|
5278
|
+
connection_id: connection_id
|
|
5279
|
+
}, {
|
|
5280
|
+
timeout: timeout
|
|
5281
|
+
}, false);
|
|
4761
5282
|
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
resolve(_this.token);
|
|
5283
|
+
case 10:
|
|
5284
|
+
_this._log("disconnect() - Closed connectionID");
|
|
4765
5285
|
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
return _context2.stop();
|
|
4769
|
-
}
|
|
4770
|
-
}
|
|
4771
|
-
}, _callee2);
|
|
4772
|
-
}));
|
|
5286
|
+
_context4.next = 16;
|
|
5287
|
+
break;
|
|
4773
5288
|
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
}());
|
|
4778
|
-
return _this.loadTokenPromise;
|
|
4779
|
-
});
|
|
5289
|
+
case 13:
|
|
5290
|
+
_context4.prev = 13;
|
|
5291
|
+
_context4.t0 = _context4["catch"](7);
|
|
4780
5292
|
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
}
|
|
5293
|
+
_this._log("disconnect() - Failed", {
|
|
5294
|
+
err: _context4.t0
|
|
5295
|
+
}, 'error');
|
|
4785
5296
|
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
5297
|
+
case 16:
|
|
5298
|
+
case "end":
|
|
5299
|
+
return _context4.stop();
|
|
5300
|
+
}
|
|
5301
|
+
}
|
|
5302
|
+
}, _callee4, null, [[7, 13]]);
|
|
5303
|
+
})));
|
|
4789
5304
|
|
|
4790
|
-
|
|
4791
|
-
|
|
5305
|
+
this.client = client;
|
|
5306
|
+
this.state = ConnectionState.Init;
|
|
5307
|
+
this.consecutiveFailures = 0;
|
|
5308
|
+
addConnectionEventListeners(this._onlineStatusChanged);
|
|
5309
|
+
}
|
|
5310
|
+
|
|
5311
|
+
_createClass__default['default'](WSConnectionFallback, [{
|
|
5312
|
+
key: "_log",
|
|
5313
|
+
value: function _log(msg) {
|
|
5314
|
+
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5315
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
5316
|
+
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$1({
|
|
5317
|
+
tags: ['connection_fallback', 'connection']
|
|
5318
|
+
}, extra));
|
|
4792
5319
|
}
|
|
5320
|
+
}, {
|
|
5321
|
+
key: "_setState",
|
|
5322
|
+
value: function _setState(state) {
|
|
5323
|
+
this._log("_setState() - ".concat(state)); // transition from connecting => connected
|
|
4793
5324
|
|
|
4794
|
-
throw new Error("Both secret and user tokens are not set. Either client.connectUser wasn't called or client.disconnect was called");
|
|
4795
|
-
});
|
|
4796
5325
|
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
5326
|
+
if (this.state === ConnectionState.Connecting && state === ConnectionState.Connected) {
|
|
5327
|
+
//@ts-expect-error
|
|
5328
|
+
this.client.dispatchEvent({
|
|
5329
|
+
type: 'connection.changed',
|
|
5330
|
+
online: true
|
|
5331
|
+
});
|
|
5332
|
+
}
|
|
4800
5333
|
|
|
4801
|
-
|
|
5334
|
+
if (state === ConnectionState.Closed || state === ConnectionState.Disconnected) {
|
|
5335
|
+
//@ts-expect-error
|
|
5336
|
+
this.client.dispatchEvent({
|
|
5337
|
+
type: 'connection.changed',
|
|
5338
|
+
online: false
|
|
5339
|
+
});
|
|
5340
|
+
}
|
|
4802
5341
|
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
5342
|
+
this.state = state;
|
|
5343
|
+
}
|
|
5344
|
+
/** @private */
|
|
4806
5345
|
|
|
4807
|
-
|
|
5346
|
+
}]);
|
|
4808
5347
|
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
}
|
|
4812
|
-
}
|
|
4813
|
-
/**
|
|
4814
|
-
* Set the static string token or token provider.
|
|
4815
|
-
* Token provider should return a token string or a promise which resolves to string token.
|
|
4816
|
-
*
|
|
4817
|
-
* @param {TokenOrProvider} tokenOrProvider
|
|
4818
|
-
* @param {UserResponse<UserType>} user
|
|
4819
|
-
*/
|
|
4820
|
-
;
|
|
5348
|
+
return WSConnectionFallback;
|
|
5349
|
+
}();
|
|
4821
5350
|
|
|
4822
5351
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
4823
5352
|
|
|
@@ -4857,10 +5386,6 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4857
5386
|
|
|
4858
5387
|
_defineProperty__default['default'](this, "configs", void 0);
|
|
4859
5388
|
|
|
4860
|
-
_defineProperty__default['default'](this, "connectionID", void 0);
|
|
4861
|
-
|
|
4862
|
-
_defineProperty__default['default'](this, "failures", void 0);
|
|
4863
|
-
|
|
4864
5389
|
_defineProperty__default['default'](this, "key", void 0);
|
|
4865
5390
|
|
|
4866
5391
|
_defineProperty__default['default'](this, "listeners", void 0);
|
|
@@ -4895,16 +5420,26 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4895
5420
|
|
|
4896
5421
|
_defineProperty__default['default'](this, "wsConnection", void 0);
|
|
4897
5422
|
|
|
5423
|
+
_defineProperty__default['default'](this, "wsFallback", void 0);
|
|
5424
|
+
|
|
4898
5425
|
_defineProperty__default['default'](this, "wsPromise", void 0);
|
|
4899
5426
|
|
|
4900
5427
|
_defineProperty__default['default'](this, "consecutiveFailures", void 0);
|
|
4901
5428
|
|
|
4902
5429
|
_defineProperty__default['default'](this, "insightMetrics", void 0);
|
|
4903
5430
|
|
|
4904
|
-
_defineProperty__default['default'](this, "
|
|
4905
|
-
var _this$wsConnection;
|
|
5431
|
+
_defineProperty__default['default'](this, "defaultWSTimeoutWithFallback", void 0);
|
|
4906
5432
|
|
|
4907
|
-
|
|
5433
|
+
_defineProperty__default['default'](this, "defaultWSTimeout", void 0);
|
|
5434
|
+
|
|
5435
|
+
_defineProperty__default['default'](this, "_getConnectionID", function () {
|
|
5436
|
+
var _this$wsConnection, _this$wsFallback;
|
|
5437
|
+
|
|
5438
|
+
return ((_this$wsConnection = _this.wsConnection) === null || _this$wsConnection === void 0 ? void 0 : _this$wsConnection.connectionID) || ((_this$wsFallback = _this.wsFallback) === null || _this$wsFallback === void 0 ? void 0 : _this$wsFallback.connectionID);
|
|
5439
|
+
});
|
|
5440
|
+
|
|
5441
|
+
_defineProperty__default['default'](this, "_hasConnectionID", function () {
|
|
5442
|
+
return Boolean(_this._getConnectionID());
|
|
4908
5443
|
});
|
|
4909
5444
|
|
|
4910
5445
|
_defineProperty__default['default'](this, "connectUser", /*#__PURE__*/function () {
|
|
@@ -4990,36 +5525,55 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4990
5525
|
return _this.tokenManager.setTokenOrProvider(userTokenOrProvider, user);
|
|
4991
5526
|
});
|
|
4992
5527
|
|
|
4993
|
-
_defineProperty__default['default'](this, "closeConnection", function (
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
_this.cleaningIntervalRef = undefined;
|
|
4997
|
-
}
|
|
5528
|
+
_defineProperty__default['default'](this, "closeConnection", /*#__PURE__*/function () {
|
|
5529
|
+
var _ref2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2(timeout) {
|
|
5530
|
+
var _this$wsConnection2, _this$wsFallback2;
|
|
4998
5531
|
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5532
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
5533
|
+
while (1) {
|
|
5534
|
+
switch (_context2.prev = _context2.next) {
|
|
5535
|
+
case 0:
|
|
5536
|
+
if (_this.cleaningIntervalRef != null) {
|
|
5537
|
+
clearInterval(_this.cleaningIntervalRef);
|
|
5538
|
+
_this.cleaningIntervalRef = undefined;
|
|
5539
|
+
}
|
|
5002
5540
|
|
|
5003
|
-
|
|
5004
|
-
|
|
5541
|
+
_context2.next = 3;
|
|
5542
|
+
return Promise.all([(_this$wsConnection2 = _this.wsConnection) === null || _this$wsConnection2 === void 0 ? void 0 : _this$wsConnection2.disconnect(timeout), (_this$wsFallback2 = _this.wsFallback) === null || _this$wsFallback2 === void 0 ? void 0 : _this$wsFallback2.disconnect(timeout)]);
|
|
5005
5543
|
|
|
5006
|
-
|
|
5007
|
-
|
|
5544
|
+
case 3:
|
|
5545
|
+
return _context2.abrupt("return", Promise.resolve());
|
|
5008
5546
|
|
|
5009
|
-
|
|
5547
|
+
case 4:
|
|
5548
|
+
case "end":
|
|
5549
|
+
return _context2.stop();
|
|
5550
|
+
}
|
|
5551
|
+
}
|
|
5552
|
+
}, _callee2);
|
|
5553
|
+
}));
|
|
5554
|
+
|
|
5555
|
+
return function (_x3) {
|
|
5556
|
+
return _ref2.apply(this, arguments);
|
|
5557
|
+
};
|
|
5558
|
+
}());
|
|
5559
|
+
|
|
5560
|
+
_defineProperty__default['default'](this, "openConnection", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
5561
|
+
var _this$wsConnection3, _this$wsFallback3;
|
|
5562
|
+
|
|
5563
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
5010
5564
|
while (1) {
|
|
5011
|
-
switch (
|
|
5565
|
+
switch (_context3.prev = _context3.next) {
|
|
5012
5566
|
case 0:
|
|
5013
5567
|
if (_this.userID) {
|
|
5014
|
-
|
|
5568
|
+
_context3.next = 2;
|
|
5015
5569
|
break;
|
|
5016
5570
|
}
|
|
5017
5571
|
|
|
5018
5572
|
throw Error('User is not set on client, use client.connectUser or client.connectAnonymousUser instead');
|
|
5019
5573
|
|
|
5020
5574
|
case 2:
|
|
5021
|
-
if (!((_this$
|
|
5022
|
-
|
|
5575
|
+
if (!(((_this$wsConnection3 = _this.wsConnection) !== null && _this$wsConnection3 !== void 0 && _this$wsConnection3.isHealthy || (_this$wsFallback3 = _this.wsFallback) !== null && _this$wsFallback3 !== void 0 && _this$wsFallback3.isHealthy()) && _this._hasConnectionID())) {
|
|
5576
|
+
_context3.next = 5;
|
|
5023
5577
|
break;
|
|
5024
5578
|
}
|
|
5025
5579
|
|
|
@@ -5027,7 +5581,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5027
5581
|
tags: ['connection', 'client']
|
|
5028
5582
|
});
|
|
5029
5583
|
|
|
5030
|
-
return
|
|
5584
|
+
return _context3.abrupt("return", Promise.resolve());
|
|
5031
5585
|
|
|
5032
5586
|
case 5:
|
|
5033
5587
|
_this.clientID = "".concat(_this.userID, "--").concat(randomId());
|
|
@@ -5035,14 +5589,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5035
5589
|
|
|
5036
5590
|
_this._startCleaning();
|
|
5037
5591
|
|
|
5038
|
-
return
|
|
5592
|
+
return _context3.abrupt("return", _this.wsPromise);
|
|
5039
5593
|
|
|
5040
5594
|
case 9:
|
|
5041
5595
|
case "end":
|
|
5042
|
-
return
|
|
5596
|
+
return _context3.stop();
|
|
5043
5597
|
}
|
|
5044
5598
|
}
|
|
5045
|
-
},
|
|
5599
|
+
}, _callee3);
|
|
5046
5600
|
})));
|
|
5047
5601
|
|
|
5048
5602
|
_defineProperty__default['default'](this, "_setupConnection", this.openConnection);
|
|
@@ -5060,12 +5614,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5060
5614
|
});
|
|
5061
5615
|
|
|
5062
5616
|
_defineProperty__default['default'](this, "disconnectUser", /*#__PURE__*/function () {
|
|
5063
|
-
var
|
|
5617
|
+
var _ref4 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4(timeout) {
|
|
5064
5618
|
var closePromise, _i, _Object$values, _channel;
|
|
5065
5619
|
|
|
5066
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
5620
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
5067
5621
|
while (1) {
|
|
5068
|
-
switch (
|
|
5622
|
+
switch (_context4.prev = _context4.next) {
|
|
5069
5623
|
case 0:
|
|
5070
5624
|
_this.logger('info', 'client:disconnect() - Disconnecting the client', {
|
|
5071
5625
|
tags: ['connection', 'client']
|
|
@@ -5089,21 +5643,21 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5089
5643
|
|
|
5090
5644
|
_this.state = new ClientState(); // reset token manager
|
|
5091
5645
|
|
|
5092
|
-
_this.tokenManager.reset
|
|
5093
|
-
|
|
5646
|
+
setTimeout(_this.tokenManager.reset); // delay reseting to use token for disconnect calls
|
|
5647
|
+
// close the WS connection
|
|
5094
5648
|
|
|
5095
|
-
return
|
|
5649
|
+
return _context4.abrupt("return", closePromise);
|
|
5096
5650
|
|
|
5097
5651
|
case 11:
|
|
5098
5652
|
case "end":
|
|
5099
|
-
return
|
|
5653
|
+
return _context4.stop();
|
|
5100
5654
|
}
|
|
5101
5655
|
}
|
|
5102
|
-
},
|
|
5656
|
+
}, _callee4);
|
|
5103
5657
|
}));
|
|
5104
5658
|
|
|
5105
|
-
return function (
|
|
5106
|
-
return
|
|
5659
|
+
return function (_x4) {
|
|
5660
|
+
return _ref4.apply(this, arguments);
|
|
5107
5661
|
};
|
|
5108
5662
|
}());
|
|
5109
5663
|
|
|
@@ -5131,78 +5685,78 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5131
5685
|
_defineProperty__default['default'](this, "setAnonymousUser", this.connectAnonymousUser);
|
|
5132
5686
|
|
|
5133
5687
|
_defineProperty__default['default'](this, "doAxiosRequest", /*#__PURE__*/function () {
|
|
5134
|
-
var
|
|
5688
|
+
var _ref5 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(type, url, data) {
|
|
5135
5689
|
var options,
|
|
5136
5690
|
requestConfig,
|
|
5137
5691
|
response,
|
|
5138
5692
|
_requestConfig$header,
|
|
5139
|
-
|
|
5693
|
+
_args5 = arguments;
|
|
5140
5694
|
|
|
5141
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
5695
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
|
|
5142
5696
|
while (1) {
|
|
5143
|
-
switch (
|
|
5697
|
+
switch (_context5.prev = _context5.next) {
|
|
5144
5698
|
case 0:
|
|
5145
|
-
options =
|
|
5146
|
-
|
|
5699
|
+
options = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : {};
|
|
5700
|
+
_context5.next = 3;
|
|
5147
5701
|
return _this.tokenManager.tokenReady();
|
|
5148
5702
|
|
|
5149
5703
|
case 3:
|
|
5150
5704
|
requestConfig = _this._enrichAxiosOptions(options);
|
|
5151
|
-
|
|
5705
|
+
_context5.prev = 4;
|
|
5152
5706
|
|
|
5153
5707
|
_this._logApiRequest(type, url, data, requestConfig);
|
|
5154
5708
|
|
|
5155
|
-
|
|
5156
|
-
|
|
5709
|
+
_context5.t0 = type;
|
|
5710
|
+
_context5.next = _context5.t0 === 'get' ? 9 : _context5.t0 === 'delete' ? 13 : _context5.t0 === 'post' ? 17 : _context5.t0 === 'put' ? 21 : _context5.t0 === 'patch' ? 25 : _context5.t0 === 'options' ? 29 : 33;
|
|
5157
5711
|
break;
|
|
5158
5712
|
|
|
5159
5713
|
case 9:
|
|
5160
|
-
|
|
5714
|
+
_context5.next = 11;
|
|
5161
5715
|
return _this.axiosInstance.get(url, requestConfig);
|
|
5162
5716
|
|
|
5163
5717
|
case 11:
|
|
5164
|
-
response =
|
|
5165
|
-
return
|
|
5718
|
+
response = _context5.sent;
|
|
5719
|
+
return _context5.abrupt("break", 34);
|
|
5166
5720
|
|
|
5167
5721
|
case 13:
|
|
5168
|
-
|
|
5722
|
+
_context5.next = 15;
|
|
5169
5723
|
return _this.axiosInstance.delete(url, requestConfig);
|
|
5170
5724
|
|
|
5171
5725
|
case 15:
|
|
5172
|
-
response =
|
|
5173
|
-
return
|
|
5726
|
+
response = _context5.sent;
|
|
5727
|
+
return _context5.abrupt("break", 34);
|
|
5174
5728
|
|
|
5175
5729
|
case 17:
|
|
5176
|
-
|
|
5730
|
+
_context5.next = 19;
|
|
5177
5731
|
return _this.axiosInstance.post(url, data, requestConfig);
|
|
5178
5732
|
|
|
5179
5733
|
case 19:
|
|
5180
|
-
response =
|
|
5181
|
-
return
|
|
5734
|
+
response = _context5.sent;
|
|
5735
|
+
return _context5.abrupt("break", 34);
|
|
5182
5736
|
|
|
5183
5737
|
case 21:
|
|
5184
|
-
|
|
5738
|
+
_context5.next = 23;
|
|
5185
5739
|
return _this.axiosInstance.put(url, data, requestConfig);
|
|
5186
5740
|
|
|
5187
5741
|
case 23:
|
|
5188
|
-
response =
|
|
5189
|
-
return
|
|
5742
|
+
response = _context5.sent;
|
|
5743
|
+
return _context5.abrupt("break", 34);
|
|
5190
5744
|
|
|
5191
5745
|
case 25:
|
|
5192
|
-
|
|
5746
|
+
_context5.next = 27;
|
|
5193
5747
|
return _this.axiosInstance.patch(url, data, requestConfig);
|
|
5194
5748
|
|
|
5195
5749
|
case 27:
|
|
5196
|
-
response =
|
|
5197
|
-
return
|
|
5750
|
+
response = _context5.sent;
|
|
5751
|
+
return _context5.abrupt("break", 34);
|
|
5198
5752
|
|
|
5199
5753
|
case 29:
|
|
5200
|
-
|
|
5754
|
+
_context5.next = 31;
|
|
5201
5755
|
return _this.axiosInstance.options(url, requestConfig);
|
|
5202
5756
|
|
|
5203
5757
|
case 31:
|
|
5204
|
-
response =
|
|
5205
|
-
return
|
|
5758
|
+
response = _context5.sent;
|
|
5759
|
+
return _context5.abrupt("break", 34);
|
|
5206
5760
|
|
|
5207
5761
|
case 33:
|
|
5208
5762
|
throw new Error('Invalid request type');
|
|
@@ -5211,65 +5765,66 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5211
5765
|
_this._logApiResponse(type, url, response);
|
|
5212
5766
|
|
|
5213
5767
|
_this.consecutiveFailures = 0;
|
|
5214
|
-
return
|
|
5768
|
+
return _context5.abrupt("return", _this.handleResponse(response));
|
|
5215
5769
|
|
|
5216
5770
|
case 39:
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5771
|
+
_context5.prev = 39;
|
|
5772
|
+
_context5.t1 = _context5["catch"](4);
|
|
5773
|
+
_context5.t1.client_request_id = (_requestConfig$header = requestConfig.headers) === null || _requestConfig$header === void 0 ? void 0 : _requestConfig$header['x-client-request-id'];
|
|
5220
5774
|
|
|
5221
|
-
_this._logApiError(type, url,
|
|
5775
|
+
_this._logApiError(type, url, _context5.t1);
|
|
5222
5776
|
|
|
5223
5777
|
_this.consecutiveFailures += 1;
|
|
5224
5778
|
|
|
5225
|
-
if (!
|
|
5226
|
-
|
|
5779
|
+
if (!_context5.t1.response) {
|
|
5780
|
+
_context5.next = 56;
|
|
5227
5781
|
break;
|
|
5228
5782
|
}
|
|
5229
5783
|
|
|
5230
|
-
if (!(
|
|
5231
|
-
|
|
5784
|
+
if (!(_context5.t1.response.data.code === chatCodes.TOKEN_EXPIRED && !_this.tokenManager.isStatic())) {
|
|
5785
|
+
_context5.next = 53;
|
|
5232
5786
|
break;
|
|
5233
5787
|
}
|
|
5234
5788
|
|
|
5235
5789
|
if (!(_this.consecutiveFailures > 1)) {
|
|
5236
|
-
|
|
5790
|
+
_context5.next = 49;
|
|
5237
5791
|
break;
|
|
5238
5792
|
}
|
|
5239
5793
|
|
|
5240
|
-
|
|
5794
|
+
_context5.next = 49;
|
|
5241
5795
|
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5242
5796
|
|
|
5243
5797
|
case 49:
|
|
5244
5798
|
_this.tokenManager.loadToken();
|
|
5245
5799
|
|
|
5246
|
-
|
|
5800
|
+
_context5.next = 52;
|
|
5247
5801
|
return _this.doAxiosRequest(type, url, data, options);
|
|
5248
5802
|
|
|
5249
5803
|
case 52:
|
|
5250
|
-
return
|
|
5804
|
+
return _context5.abrupt("return", _context5.sent);
|
|
5251
5805
|
|
|
5252
5806
|
case 53:
|
|
5253
|
-
return
|
|
5807
|
+
return _context5.abrupt("return", _this.handleResponse(_context5.t1.response));
|
|
5254
5808
|
|
|
5255
5809
|
case 56:
|
|
5256
|
-
throw
|
|
5810
|
+
throw _context5.t1;
|
|
5257
5811
|
|
|
5258
5812
|
case 57:
|
|
5259
5813
|
case "end":
|
|
5260
|
-
return
|
|
5814
|
+
return _context5.stop();
|
|
5261
5815
|
}
|
|
5262
5816
|
}
|
|
5263
|
-
},
|
|
5817
|
+
}, _callee5, null, [[4, 39]]);
|
|
5264
5818
|
}));
|
|
5265
5819
|
|
|
5266
|
-
return function (
|
|
5267
|
-
return
|
|
5820
|
+
return function (_x5, _x6, _x7) {
|
|
5821
|
+
return _ref5.apply(this, arguments);
|
|
5268
5822
|
};
|
|
5269
5823
|
}());
|
|
5270
5824
|
|
|
5271
5825
|
_defineProperty__default['default'](this, "dispatchEvent", function (event) {
|
|
5272
|
-
// client event handlers
|
|
5826
|
+
if (!event.received_at) event.received_at = new Date(); // client event handlers
|
|
5827
|
+
|
|
5273
5828
|
var postListenerCallbacks = _this._handleClientEvent(event); // channel event handlers
|
|
5274
5829
|
|
|
5275
5830
|
|
|
@@ -5295,7 +5850,6 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5295
5850
|
// dispatch the event to the channel listeners
|
|
5296
5851
|
var jsonString = messageEvent.data;
|
|
5297
5852
|
var event = JSON.parse(jsonString);
|
|
5298
|
-
event.received_at = new Date();
|
|
5299
5853
|
|
|
5300
5854
|
_this.dispatchEvent(event);
|
|
5301
5855
|
});
|
|
@@ -5416,22 +5970,20 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5416
5970
|
}
|
|
5417
5971
|
});
|
|
5418
5972
|
|
|
5419
|
-
_defineProperty__default['default'](this, "recoverState", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
5420
|
-
var _this$wsConnection3;
|
|
5421
|
-
|
|
5973
|
+
_defineProperty__default['default'](this, "recoverState", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee6() {
|
|
5422
5974
|
var cids;
|
|
5423
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
5975
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee6$(_context6) {
|
|
5424
5976
|
while (1) {
|
|
5425
|
-
switch (
|
|
5977
|
+
switch (_context6.prev = _context6.next) {
|
|
5426
5978
|
case 0:
|
|
5427
|
-
_this.logger('info', "client:recoverState() - Start of recoverState with connectionID ".concat(
|
|
5979
|
+
_this.logger('info', "client:recoverState() - Start of recoverState with connectionID ".concat(_this._getConnectionID()), {
|
|
5428
5980
|
tags: ['connection']
|
|
5429
5981
|
});
|
|
5430
5982
|
|
|
5431
5983
|
cids = Object.keys(_this.activeChannels);
|
|
5432
5984
|
|
|
5433
5985
|
if (!(cids.length && _this.recoverStateOnReconnect)) {
|
|
5434
|
-
|
|
5986
|
+
_context6.next = 10;
|
|
5435
5987
|
break;
|
|
5436
5988
|
}
|
|
5437
5989
|
|
|
@@ -5439,7 +5991,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5439
5991
|
tags: ['connection', 'client']
|
|
5440
5992
|
});
|
|
5441
5993
|
|
|
5442
|
-
|
|
5994
|
+
_context6.next = 6;
|
|
5443
5995
|
return _this.queryChannels({
|
|
5444
5996
|
cid: {
|
|
5445
5997
|
$in: cids
|
|
@@ -5459,7 +6011,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5459
6011
|
type: 'connection.recovered'
|
|
5460
6012
|
});
|
|
5461
6013
|
|
|
5462
|
-
|
|
6014
|
+
_context6.next = 11;
|
|
5463
6015
|
break;
|
|
5464
6016
|
|
|
5465
6017
|
case 10:
|
|
@@ -5473,10 +6025,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5473
6025
|
|
|
5474
6026
|
case 13:
|
|
5475
6027
|
case "end":
|
|
5476
|
-
return
|
|
6028
|
+
return _context6.stop();
|
|
5477
6029
|
}
|
|
5478
6030
|
}
|
|
5479
|
-
},
|
|
6031
|
+
}, _callee6);
|
|
5480
6032
|
})));
|
|
5481
6033
|
|
|
5482
6034
|
_defineProperty__default['default'](this, "getChannelByMembers", function (channelType, custom) {
|
|
@@ -5556,66 +6108,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5556
6108
|
return !!_this.secret;
|
|
5557
6109
|
});
|
|
5558
6110
|
|
|
5559
|
-
_defineProperty__default['default'](this, "
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
i = 0;
|
|
5568
|
-
|
|
5569
|
-
case 2:
|
|
5570
|
-
if (!(i < maxAttempts)) {
|
|
5571
|
-
_context6.next = 18;
|
|
5572
|
-
break;
|
|
5573
|
-
}
|
|
5574
|
-
|
|
5575
|
-
_context6.prev = 3;
|
|
5576
|
-
_context6.next = 6;
|
|
5577
|
-
return _this.axiosInstance.post("https://chat-insights.getstream.io/insights/".concat(insightType), insights);
|
|
5578
|
-
|
|
5579
|
-
case 6:
|
|
5580
|
-
_context6.next = 14;
|
|
5581
|
-
break;
|
|
5582
|
-
|
|
5583
|
-
case 8:
|
|
5584
|
-
_context6.prev = 8;
|
|
5585
|
-
_context6.t0 = _context6["catch"](3);
|
|
5586
|
-
|
|
5587
|
-
_this.logger('warn', "failed to send insights event ".concat(insightType), {
|
|
5588
|
-
tags: ['insights', 'connection'],
|
|
5589
|
-
error: _context6.t0,
|
|
5590
|
-
insights: insights
|
|
5591
|
-
});
|
|
5592
|
-
|
|
5593
|
-
_context6.next = 13;
|
|
5594
|
-
return sleep((i + 1) * 3000);
|
|
5595
|
-
|
|
5596
|
-
case 13:
|
|
5597
|
-
return _context6.abrupt("continue", 15);
|
|
5598
|
-
|
|
5599
|
-
case 14:
|
|
5600
|
-
return _context6.abrupt("break", 18);
|
|
5601
|
-
|
|
5602
|
-
case 15:
|
|
5603
|
-
i++;
|
|
5604
|
-
_context6.next = 2;
|
|
5605
|
-
break;
|
|
5606
|
-
|
|
5607
|
-
case 18:
|
|
5608
|
-
case "end":
|
|
5609
|
-
return _context6.stop();
|
|
5610
|
-
}
|
|
5611
|
-
}
|
|
5612
|
-
}, _callee6, null, [[3, 8]]);
|
|
5613
|
-
}));
|
|
5614
|
-
|
|
5615
|
-
return function (_x7, _x8) {
|
|
5616
|
-
return _ref6.apply(this, arguments);
|
|
5617
|
-
};
|
|
5618
|
-
}());
|
|
6111
|
+
_defineProperty__default['default'](this, "_buildWSPayload", function (client_request_id) {
|
|
6112
|
+
return JSON.stringify({
|
|
6113
|
+
user_id: _this.userID,
|
|
6114
|
+
user_details: _this._user,
|
|
6115
|
+
device: _this.options.device,
|
|
6116
|
+
client_request_id: client_request_id
|
|
6117
|
+
});
|
|
6118
|
+
});
|
|
5619
6119
|
|
|
5620
6120
|
// set the key
|
|
5621
6121
|
this.key = _key;
|
|
@@ -5673,6 +6173,8 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5673
6173
|
this.tokenManager = new TokenManager(this.secret);
|
|
5674
6174
|
this.consecutiveFailures = 0;
|
|
5675
6175
|
this.insightMetrics = new InsightMetrics();
|
|
6176
|
+
this.defaultWSTimeoutWithFallback = 6000;
|
|
6177
|
+
this.defaultWSTimeout = 15000;
|
|
5676
6178
|
/**
|
|
5677
6179
|
* logger function should accept 3 parameters:
|
|
5678
6180
|
* @param logLevel string
|
|
@@ -5846,7 +6348,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5846
6348
|
}, _callee7, this);
|
|
5847
6349
|
}));
|
|
5848
6350
|
|
|
5849
|
-
function updateAppSettings(
|
|
6351
|
+
function updateAppSettings(_x8) {
|
|
5850
6352
|
return _updateAppSettings.apply(this, arguments);
|
|
5851
6353
|
}
|
|
5852
6354
|
|
|
@@ -5880,7 +6382,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5880
6382
|
}, _callee8, this);
|
|
5881
6383
|
}));
|
|
5882
6384
|
|
|
5883
|
-
function revokeTokens(
|
|
6385
|
+
function revokeTokens(_x9) {
|
|
5884
6386
|
return _revokeTokens.apply(this, arguments);
|
|
5885
6387
|
}
|
|
5886
6388
|
|
|
@@ -5912,7 +6414,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5912
6414
|
}, _callee9, this);
|
|
5913
6415
|
}));
|
|
5914
6416
|
|
|
5915
|
-
function revokeUserToken(
|
|
6417
|
+
function revokeUserToken(_x10, _x11) {
|
|
5916
6418
|
return _revokeUserToken.apply(this, arguments);
|
|
5917
6419
|
}
|
|
5918
6420
|
|
|
@@ -5971,7 +6473,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5971
6473
|
}, _callee10, this);
|
|
5972
6474
|
}));
|
|
5973
6475
|
|
|
5974
|
-
function revokeUsersToken(
|
|
6476
|
+
function revokeUsersToken(_x12, _x13) {
|
|
5975
6477
|
return _revokeUsersToken.apply(this, arguments);
|
|
5976
6478
|
}
|
|
5977
6479
|
|
|
@@ -6063,7 +6565,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6063
6565
|
}, _callee12, this);
|
|
6064
6566
|
}));
|
|
6065
6567
|
|
|
6066
|
-
function testPushSettings(
|
|
6568
|
+
function testPushSettings(_x14) {
|
|
6067
6569
|
return _testPushSettings.apply(this, arguments);
|
|
6068
6570
|
}
|
|
6069
6571
|
|
|
@@ -6172,7 +6674,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6172
6674
|
}, _callee14, this, [[1, 7]]);
|
|
6173
6675
|
}));
|
|
6174
6676
|
|
|
6175
|
-
function setGuestUser(
|
|
6677
|
+
function setGuestUser(_x15) {
|
|
6176
6678
|
return _setGuestUser.apply(this, arguments);
|
|
6177
6679
|
}
|
|
6178
6680
|
|
|
@@ -6483,72 +6985,102 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6483
6985
|
*/
|
|
6484
6986
|
function () {
|
|
6485
6987
|
var _connect = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee15() {
|
|
6486
|
-
var client;
|
|
6487
6988
|
return _regeneratorRuntime__default['default'].wrap(function _callee15$(_context15) {
|
|
6488
6989
|
while (1) {
|
|
6489
6990
|
switch (_context15.prev = _context15.next) {
|
|
6490
6991
|
case 0:
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
if (!(client.userID == null || this._user == null)) {
|
|
6495
|
-
_context15.next = 4;
|
|
6992
|
+
if (!(!this.userID || !this._user)) {
|
|
6993
|
+
_context15.next = 2;
|
|
6496
6994
|
break;
|
|
6497
6995
|
}
|
|
6498
6996
|
|
|
6499
6997
|
throw Error('Call connectUser or connectAnonymousUser before starting the connection');
|
|
6500
6998
|
|
|
6501
|
-
case
|
|
6502
|
-
if (
|
|
6503
|
-
_context15.next =
|
|
6999
|
+
case 2:
|
|
7000
|
+
if (this.wsBaseURL) {
|
|
7001
|
+
_context15.next = 4;
|
|
6504
7002
|
break;
|
|
6505
7003
|
}
|
|
6506
7004
|
|
|
6507
7005
|
throw Error('Websocket base url not set');
|
|
6508
7006
|
|
|
6509
|
-
case
|
|
6510
|
-
if (
|
|
6511
|
-
_context15.next =
|
|
7007
|
+
case 4:
|
|
7008
|
+
if (this.clientID) {
|
|
7009
|
+
_context15.next = 6;
|
|
6512
7010
|
break;
|
|
6513
7011
|
}
|
|
6514
7012
|
|
|
6515
7013
|
throw Error('clientID is not set');
|
|
6516
7014
|
|
|
6517
|
-
case
|
|
7015
|
+
case 6:
|
|
6518
7016
|
if (!this.wsConnection && (this.options.warmUp || this.options.enableInsights)) {
|
|
6519
|
-
this.
|
|
7017
|
+
this._sayHi();
|
|
6520
7018
|
} // The StableWSConnection handles all the reconnection logic.
|
|
6521
7019
|
|
|
6522
7020
|
|
|
6523
7021
|
this.wsConnection = new StableWSConnection({
|
|
6524
|
-
|
|
6525
|
-
clientID: client.clientID,
|
|
6526
|
-
userID: client.userID,
|
|
6527
|
-
tokenManager: client.tokenManager,
|
|
6528
|
-
user: this._user,
|
|
6529
|
-
authType: this.getAuthType(),
|
|
6530
|
-
userAgent: this.getUserAgent(),
|
|
6531
|
-
apiKey: this.key,
|
|
6532
|
-
recoverCallback: this.recoverState,
|
|
6533
|
-
messageCallback: this.handleEvent,
|
|
6534
|
-
eventCallback: this.dispatchEvent,
|
|
6535
|
-
logger: this.logger,
|
|
6536
|
-
device: this.options.device,
|
|
6537
|
-
postInsights: this.options.enableInsights ? this.postInsights : undefined,
|
|
6538
|
-
insightMetrics: this.insightMetrics
|
|
7022
|
+
client: this
|
|
6539
7023
|
});
|
|
7024
|
+
_context15.prev = 8;
|
|
7025
|
+
|
|
7026
|
+
if (!this.wsFallback) {
|
|
7027
|
+
_context15.next = 13;
|
|
7028
|
+
break;
|
|
7029
|
+
}
|
|
7030
|
+
|
|
6540
7031
|
_context15.next = 12;
|
|
6541
|
-
return this.
|
|
7032
|
+
return this.wsFallback.connect();
|
|
6542
7033
|
|
|
6543
7034
|
case 12:
|
|
6544
7035
|
return _context15.abrupt("return", _context15.sent);
|
|
6545
7036
|
|
|
6546
7037
|
case 13:
|
|
7038
|
+
_context15.next = 15;
|
|
7039
|
+
return this.wsConnection.connect(this.options.enableWSFallback ? this.defaultWSTimeoutWithFallback : this.defaultWSTimeout);
|
|
7040
|
+
|
|
7041
|
+
case 15:
|
|
7042
|
+
return _context15.abrupt("return", _context15.sent);
|
|
7043
|
+
|
|
7044
|
+
case 18:
|
|
7045
|
+
_context15.prev = 18;
|
|
7046
|
+
_context15.t0 = _context15["catch"](8);
|
|
7047
|
+
|
|
7048
|
+
if (!(this.options.enableWSFallback && isWSFailure(_context15.t0) && isOnline())) {
|
|
7049
|
+
_context15.next = 29;
|
|
7050
|
+
break;
|
|
7051
|
+
}
|
|
7052
|
+
|
|
7053
|
+
this.logger('info', 'client:connect() - WS failed, fallback to longpoll', {
|
|
7054
|
+
tags: ['connection', 'client']
|
|
7055
|
+
}); // @ts-expect-error
|
|
7056
|
+
|
|
7057
|
+
this.dispatchEvent({
|
|
7058
|
+
type: 'transport.changed',
|
|
7059
|
+
mode: 'longpoll'
|
|
7060
|
+
});
|
|
7061
|
+
|
|
7062
|
+
this.wsConnection._destroyCurrentWSConnection();
|
|
7063
|
+
|
|
7064
|
+
this.wsConnection.disconnect().then(); // close WS so no retry
|
|
7065
|
+
|
|
7066
|
+
this.wsFallback = new WSConnectionFallback({
|
|
7067
|
+
client: this
|
|
7068
|
+
});
|
|
7069
|
+
_context15.next = 28;
|
|
7070
|
+
return this.wsFallback.connect();
|
|
7071
|
+
|
|
7072
|
+
case 28:
|
|
7073
|
+
return _context15.abrupt("return", _context15.sent);
|
|
7074
|
+
|
|
7075
|
+
case 29:
|
|
7076
|
+
throw _context15.t0;
|
|
7077
|
+
|
|
7078
|
+
case 30:
|
|
6547
7079
|
case "end":
|
|
6548
7080
|
return _context15.stop();
|
|
6549
7081
|
}
|
|
6550
7082
|
}
|
|
6551
|
-
}, _callee15, this);
|
|
7083
|
+
}, _callee15, this, [[8, 18]]);
|
|
6552
7084
|
}));
|
|
6553
7085
|
|
|
6554
7086
|
function connect() {
|
|
@@ -6557,9 +7089,15 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6557
7089
|
|
|
6558
7090
|
return connect;
|
|
6559
7091
|
}()
|
|
7092
|
+
/**
|
|
7093
|
+
* Check the connectivity with server for warmup purpose.
|
|
7094
|
+
*
|
|
7095
|
+
* @private
|
|
7096
|
+
*/
|
|
7097
|
+
|
|
6560
7098
|
}, {
|
|
6561
|
-
key: "
|
|
6562
|
-
value: function
|
|
7099
|
+
key: "_sayHi",
|
|
7100
|
+
value: function _sayHi() {
|
|
6563
7101
|
var _this4 = this;
|
|
6564
7102
|
|
|
6565
7103
|
var client_request_id = randomId();
|
|
@@ -6569,11 +7107,13 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6569
7107
|
}
|
|
6570
7108
|
};
|
|
6571
7109
|
this.doAxiosRequest('get', this.baseURL + '/hi', null, opts).catch(function (e) {
|
|
6572
|
-
_this4.
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
7110
|
+
if (_this4.options.enableInsights) {
|
|
7111
|
+
postInsights('http_hi_failed', {
|
|
7112
|
+
api_key: _this4.key,
|
|
7113
|
+
err: e,
|
|
7114
|
+
client_request_id: client_request_id
|
|
7115
|
+
});
|
|
7116
|
+
}
|
|
6577
7117
|
});
|
|
6578
7118
|
}
|
|
6579
7119
|
/**
|
|
@@ -6636,7 +7176,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6636
7176
|
}, _callee16, this);
|
|
6637
7177
|
}));
|
|
6638
7178
|
|
|
6639
|
-
function queryUsers(
|
|
7179
|
+
function queryUsers(_x16) {
|
|
6640
7180
|
return _queryUsers.apply(this, arguments);
|
|
6641
7181
|
}
|
|
6642
7182
|
|
|
@@ -6855,7 +7395,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6855
7395
|
}, _callee19, this);
|
|
6856
7396
|
}));
|
|
6857
7397
|
|
|
6858
|
-
function queryChannels(
|
|
7398
|
+
function queryChannels(_x17) {
|
|
6859
7399
|
return _queryChannels.apply(this, arguments);
|
|
6860
7400
|
}
|
|
6861
7401
|
|
|
@@ -6941,7 +7481,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6941
7481
|
}, _callee20, this);
|
|
6942
7482
|
}));
|
|
6943
7483
|
|
|
6944
|
-
function search(
|
|
7484
|
+
function search(_x18, _x19) {
|
|
6945
7485
|
return _search.apply(this, arguments);
|
|
6946
7486
|
}
|
|
6947
7487
|
|
|
@@ -6959,7 +7499,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6959
7499
|
}, {
|
|
6960
7500
|
key: "setLocalDevice",
|
|
6961
7501
|
value: function setLocalDevice(device) {
|
|
6962
|
-
if (this.wsConnection) {
|
|
7502
|
+
if (this.wsConnection || this.wsFallback) {
|
|
6963
7503
|
throw new Error('you can only set device before opening a websocket connection');
|
|
6964
7504
|
}
|
|
6965
7505
|
|
|
@@ -7001,7 +7541,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7001
7541
|
}, _callee21, this);
|
|
7002
7542
|
}));
|
|
7003
7543
|
|
|
7004
|
-
function addDevice(_x21, _x22
|
|
7544
|
+
function addDevice(_x20, _x21, _x22) {
|
|
7005
7545
|
return _addDevice.apply(this, arguments);
|
|
7006
7546
|
}
|
|
7007
7547
|
|
|
@@ -7039,7 +7579,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7039
7579
|
}, _callee22, this);
|
|
7040
7580
|
}));
|
|
7041
7581
|
|
|
7042
|
-
function getDevices(
|
|
7582
|
+
function getDevices(_x23) {
|
|
7043
7583
|
return _getDevices.apply(this, arguments);
|
|
7044
7584
|
}
|
|
7045
7585
|
|
|
@@ -7079,7 +7619,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7079
7619
|
}, _callee23, this);
|
|
7080
7620
|
}));
|
|
7081
7621
|
|
|
7082
|
-
function removeDevice(
|
|
7622
|
+
function removeDevice(_x24, _x25) {
|
|
7083
7623
|
return _removeDevice.apply(this, arguments);
|
|
7084
7624
|
}
|
|
7085
7625
|
|
|
@@ -7120,7 +7660,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7120
7660
|
}, _callee24, this);
|
|
7121
7661
|
}));
|
|
7122
7662
|
|
|
7123
|
-
function getRateLimits(
|
|
7663
|
+
function getRateLimits(_x26) {
|
|
7124
7664
|
return _getRateLimits.apply(this, arguments);
|
|
7125
7665
|
}
|
|
7126
7666
|
|
|
@@ -7221,7 +7761,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7221
7761
|
}, _callee25, this);
|
|
7222
7762
|
}));
|
|
7223
7763
|
|
|
7224
|
-
function partialUpdateUser(
|
|
7764
|
+
function partialUpdateUser(_x27) {
|
|
7225
7765
|
return _partialUpdateUser.apply(this, arguments);
|
|
7226
7766
|
}
|
|
7227
7767
|
|
|
@@ -7307,7 +7847,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7307
7847
|
}, _callee26, this, [[2, 13, 16, 19]]);
|
|
7308
7848
|
}));
|
|
7309
7849
|
|
|
7310
|
-
function upsertUsers(
|
|
7850
|
+
function upsertUsers(_x28) {
|
|
7311
7851
|
return _upsertUsers.apply(this, arguments);
|
|
7312
7852
|
}
|
|
7313
7853
|
|
|
@@ -7420,7 +7960,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7420
7960
|
}, _callee27, this, [[1, 11, 14, 17]]);
|
|
7421
7961
|
}));
|
|
7422
7962
|
|
|
7423
|
-
function partialUpdateUsers(
|
|
7963
|
+
function partialUpdateUsers(_x29) {
|
|
7424
7964
|
return _partialUpdateUsers.apply(this, arguments);
|
|
7425
7965
|
}
|
|
7426
7966
|
|
|
@@ -7448,7 +7988,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7448
7988
|
}, _callee28, this);
|
|
7449
7989
|
}));
|
|
7450
7990
|
|
|
7451
|
-
function deleteUser(
|
|
7991
|
+
function deleteUser(_x30, _x31) {
|
|
7452
7992
|
return _deleteUser.apply(this, arguments);
|
|
7453
7993
|
}
|
|
7454
7994
|
|
|
@@ -7476,7 +8016,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7476
8016
|
}, _callee29, this);
|
|
7477
8017
|
}));
|
|
7478
8018
|
|
|
7479
|
-
function reactivateUser(
|
|
8019
|
+
function reactivateUser(_x32, _x33) {
|
|
7480
8020
|
return _reactivateUser.apply(this, arguments);
|
|
7481
8021
|
}
|
|
7482
8022
|
|
|
@@ -7504,7 +8044,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7504
8044
|
}, _callee30, this);
|
|
7505
8045
|
}));
|
|
7506
8046
|
|
|
7507
|
-
function deactivateUser(
|
|
8047
|
+
function deactivateUser(_x34, _x35) {
|
|
7508
8048
|
return _deactivateUser.apply(this, arguments);
|
|
7509
8049
|
}
|
|
7510
8050
|
|
|
@@ -7532,7 +8072,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7532
8072
|
}, _callee31, this);
|
|
7533
8073
|
}));
|
|
7534
8074
|
|
|
7535
|
-
function exportUser(
|
|
8075
|
+
function exportUser(_x36, _x37) {
|
|
7536
8076
|
return _exportUser.apply(this, arguments);
|
|
7537
8077
|
}
|
|
7538
8078
|
|
|
@@ -7553,27 +8093,15 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7553
8093
|
while (1) {
|
|
7554
8094
|
switch (_context32.prev = _context32.next) {
|
|
7555
8095
|
case 0:
|
|
7556
|
-
|
|
7557
|
-
options.banned_by_id = options.user_id;
|
|
7558
|
-
delete options.user_id;
|
|
7559
|
-
console.warn("banUser: 'user_id' is deprecated, please consider switching to 'banned_by_id'");
|
|
7560
|
-
}
|
|
7561
|
-
|
|
7562
|
-
if ((options === null || options === void 0 ? void 0 : options.user) !== undefined) {
|
|
7563
|
-
options.banned_by = options.user;
|
|
7564
|
-
delete options.user;
|
|
7565
|
-
console.warn("banUser: 'user' is deprecated, please consider switching to 'banned_by'");
|
|
7566
|
-
}
|
|
7567
|
-
|
|
7568
|
-
_context32.next = 4;
|
|
8096
|
+
_context32.next = 2;
|
|
7569
8097
|
return this.post(this.baseURL + '/moderation/ban', _objectSpread({
|
|
7570
8098
|
target_user_id: targetUserID
|
|
7571
8099
|
}, options));
|
|
7572
8100
|
|
|
7573
|
-
case
|
|
8101
|
+
case 2:
|
|
7574
8102
|
return _context32.abrupt("return", _context32.sent);
|
|
7575
8103
|
|
|
7576
|
-
case
|
|
8104
|
+
case 3:
|
|
7577
8105
|
case "end":
|
|
7578
8106
|
return _context32.stop();
|
|
7579
8107
|
}
|
|
@@ -7581,7 +8109,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7581
8109
|
}, _callee32, this);
|
|
7582
8110
|
}));
|
|
7583
8111
|
|
|
7584
|
-
function banUser(
|
|
8112
|
+
function banUser(_x38, _x39) {
|
|
7585
8113
|
return _banUser.apply(this, arguments);
|
|
7586
8114
|
}
|
|
7587
8115
|
|
|
@@ -7618,7 +8146,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7618
8146
|
}, _callee33, this);
|
|
7619
8147
|
}));
|
|
7620
8148
|
|
|
7621
|
-
function unbanUser(
|
|
8149
|
+
function unbanUser(_x40, _x41) {
|
|
7622
8150
|
return _unbanUser.apply(this, arguments);
|
|
7623
8151
|
}
|
|
7624
8152
|
|
|
@@ -7655,7 +8183,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7655
8183
|
}, _callee34, this);
|
|
7656
8184
|
}));
|
|
7657
8185
|
|
|
7658
|
-
function shadowBan(
|
|
8186
|
+
function shadowBan(_x42, _x43) {
|
|
7659
8187
|
return _shadowBan.apply(this, arguments);
|
|
7660
8188
|
}
|
|
7661
8189
|
|
|
@@ -7692,7 +8220,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7692
8220
|
}, _callee35, this);
|
|
7693
8221
|
}));
|
|
7694
8222
|
|
|
7695
|
-
function removeShadowBan(
|
|
8223
|
+
function removeShadowBan(_x44, _x45) {
|
|
7696
8224
|
return _removeShadowBan.apply(this, arguments);
|
|
7697
8225
|
}
|
|
7698
8226
|
|
|
@@ -7735,7 +8263,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7735
8263
|
}, _callee36, this);
|
|
7736
8264
|
}));
|
|
7737
8265
|
|
|
7738
|
-
function muteUser(
|
|
8266
|
+
function muteUser(_x46, _x47) {
|
|
7739
8267
|
return _muteUser.apply(this, arguments);
|
|
7740
8268
|
}
|
|
7741
8269
|
|
|
@@ -7774,7 +8302,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7774
8302
|
}, _callee37, this);
|
|
7775
8303
|
}));
|
|
7776
8304
|
|
|
7777
|
-
function unmuteUser(
|
|
8305
|
+
function unmuteUser(_x48, _x49) {
|
|
7778
8306
|
return _unmuteUser.apply(this, arguments);
|
|
7779
8307
|
}
|
|
7780
8308
|
|
|
@@ -7833,7 +8361,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7833
8361
|
}, _callee38, this);
|
|
7834
8362
|
}));
|
|
7835
8363
|
|
|
7836
|
-
function flagMessage(
|
|
8364
|
+
function flagMessage(_x50) {
|
|
7837
8365
|
return _flagMessage.apply(this, arguments);
|
|
7838
8366
|
}
|
|
7839
8367
|
|
|
@@ -7873,7 +8401,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7873
8401
|
}, _callee39, this);
|
|
7874
8402
|
}));
|
|
7875
8403
|
|
|
7876
|
-
function flagUser(
|
|
8404
|
+
function flagUser(_x51) {
|
|
7877
8405
|
return _flagUser.apply(this, arguments);
|
|
7878
8406
|
}
|
|
7879
8407
|
|
|
@@ -7913,7 +8441,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7913
8441
|
}, _callee40, this);
|
|
7914
8442
|
}));
|
|
7915
8443
|
|
|
7916
|
-
function unflagMessage(
|
|
8444
|
+
function unflagMessage(_x52) {
|
|
7917
8445
|
return _unflagMessage.apply(this, arguments);
|
|
7918
8446
|
}
|
|
7919
8447
|
|
|
@@ -7953,7 +8481,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7953
8481
|
}, _callee41, this);
|
|
7954
8482
|
}));
|
|
7955
8483
|
|
|
7956
|
-
function unflagUser(
|
|
8484
|
+
function unflagUser(_x53) {
|
|
7957
8485
|
return _unflagUser.apply(this, arguments);
|
|
7958
8486
|
}
|
|
7959
8487
|
|
|
@@ -8092,7 +8620,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8092
8620
|
}, _callee43, this);
|
|
8093
8621
|
}));
|
|
8094
8622
|
|
|
8095
|
-
function translateMessage(
|
|
8623
|
+
function translateMessage(_x54, _x55) {
|
|
8096
8624
|
return _translateMessage.apply(this, arguments);
|
|
8097
8625
|
}
|
|
8098
8626
|
|
|
@@ -8208,7 +8736,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8208
8736
|
case 2:
|
|
8209
8737
|
clonedMessage = _extends__default['default']({}, message);
|
|
8210
8738
|
delete clonedMessage.id;
|
|
8211
|
-
reservedMessageFields = ['command', 'created_at', 'html', 'latest_reactions', 'own_reactions', 'reaction_counts', 'reply_count', 'type', 'updated_at', 'user', '__html'];
|
|
8739
|
+
reservedMessageFields = ['command', 'created_at', 'html', 'latest_reactions', 'own_reactions', 'quoted_message', 'reaction_counts', 'reply_count', 'type', 'updated_at', 'user', '__html'];
|
|
8212
8740
|
reservedMessageFields.forEach(function (item) {
|
|
8213
8741
|
if (clonedMessage[item] != null) {
|
|
8214
8742
|
delete clonedMessage[item];
|
|
@@ -8252,7 +8780,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8252
8780
|
}, _callee44, this);
|
|
8253
8781
|
}));
|
|
8254
8782
|
|
|
8255
|
-
function updateMessage(_x57, _x58
|
|
8783
|
+
function updateMessage(_x56, _x57, _x58) {
|
|
8256
8784
|
return _updateMessage.apply(this, arguments);
|
|
8257
8785
|
}
|
|
8258
8786
|
|
|
@@ -8313,7 +8841,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8313
8841
|
}, _callee45, this);
|
|
8314
8842
|
}));
|
|
8315
8843
|
|
|
8316
|
-
function partialUpdateMessage(_x60, _x61, _x62
|
|
8844
|
+
function partialUpdateMessage(_x59, _x60, _x61, _x62) {
|
|
8317
8845
|
return _partialUpdateMessage.apply(this, arguments);
|
|
8318
8846
|
}
|
|
8319
8847
|
|
|
@@ -8350,7 +8878,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8350
8878
|
}, _callee46, this);
|
|
8351
8879
|
}));
|
|
8352
8880
|
|
|
8353
|
-
function deleteMessage(
|
|
8881
|
+
function deleteMessage(_x63, _x64) {
|
|
8354
8882
|
return _deleteMessage.apply(this, arguments);
|
|
8355
8883
|
}
|
|
8356
8884
|
|
|
@@ -8378,7 +8906,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8378
8906
|
}, _callee47, this);
|
|
8379
8907
|
}));
|
|
8380
8908
|
|
|
8381
|
-
function getMessage(
|
|
8909
|
+
function getMessage(_x65) {
|
|
8382
8910
|
return _getMessage.apply(this, arguments);
|
|
8383
8911
|
}
|
|
8384
8912
|
|
|
@@ -8387,7 +8915,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8387
8915
|
}, {
|
|
8388
8916
|
key: "getUserAgent",
|
|
8389
8917
|
value: function getUserAgent() {
|
|
8390
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "
|
|
8918
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "5.0.1");
|
|
8391
8919
|
}
|
|
8392
8920
|
}, {
|
|
8393
8921
|
key: "setUserAgent",
|
|
@@ -8401,7 +8929,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8401
8929
|
}, {
|
|
8402
8930
|
key: "_enrichAxiosOptions",
|
|
8403
8931
|
value: function _enrichAxiosOptions() {
|
|
8404
|
-
var _options$headers
|
|
8932
|
+
var _options$headers;
|
|
8405
8933
|
|
|
8406
8934
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
8407
8935
|
params: {},
|
|
@@ -8411,21 +8939,23 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8411
8939
|
|
|
8412
8940
|
var token = this._getToken();
|
|
8413
8941
|
|
|
8942
|
+
var authorization = token ? {
|
|
8943
|
+
Authorization: token
|
|
8944
|
+
} : undefined;
|
|
8945
|
+
|
|
8414
8946
|
if (!((_options$headers = options.headers) !== null && _options$headers !== void 0 && _options$headers['x-client-request-id'])) {
|
|
8415
|
-
options.headers = {
|
|
8947
|
+
options.headers = _objectSpread(_objectSpread({}, options.headers), {}, {
|
|
8416
8948
|
'x-client-request-id': randomId()
|
|
8417
|
-
};
|
|
8949
|
+
});
|
|
8418
8950
|
}
|
|
8419
8951
|
|
|
8420
8952
|
return _objectSpread({
|
|
8421
|
-
params: _objectSpread(
|
|
8422
|
-
user_id: this.userID
|
|
8423
|
-
|
|
8424
|
-
api_key: this.key
|
|
8425
|
-
|
|
8426
|
-
}),
|
|
8427
|
-
headers: _objectSpread({
|
|
8428
|
-
Authorization: token,
|
|
8953
|
+
params: _objectSpread({
|
|
8954
|
+
user_id: this.userID,
|
|
8955
|
+
connection_id: this._getConnectionID(),
|
|
8956
|
+
api_key: this.key
|
|
8957
|
+
}, options.params),
|
|
8958
|
+
headers: _objectSpread(_objectSpread({}, authorization), {}, {
|
|
8429
8959
|
'stream-auth-type': this.getAuthType(),
|
|
8430
8960
|
'X-Stream-Client': this.getUserAgent()
|
|
8431
8961
|
}, options.headers)
|
|
@@ -8455,6 +8985,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8455
8985
|
}
|
|
8456
8986
|
}, 500);
|
|
8457
8987
|
}
|
|
8988
|
+
/**
|
|
8989
|
+
* encode ws url payload
|
|
8990
|
+
* @private
|
|
8991
|
+
* @returns json string
|
|
8992
|
+
*/
|
|
8993
|
+
|
|
8458
8994
|
}, {
|
|
8459
8995
|
key: "verifyWebhook",
|
|
8460
8996
|
value: function verifyWebhook(requestBody, xSignature) {
|
|
@@ -8595,7 +9131,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8595
9131
|
}, _callee48, this);
|
|
8596
9132
|
}));
|
|
8597
9133
|
|
|
8598
|
-
function sendUserCustomEvent(
|
|
9134
|
+
function sendUserCustomEvent(_x66, _x67) {
|
|
8599
9135
|
return _sendUserCustomEvent.apply(this, arguments);
|
|
8600
9136
|
}
|
|
8601
9137
|
|
|
@@ -8683,7 +9219,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8683
9219
|
}, _callee49, this);
|
|
8684
9220
|
}));
|
|
8685
9221
|
|
|
8686
|
-
function createSegment(
|
|
9222
|
+
function createSegment(_x68) {
|
|
8687
9223
|
return _createSegment.apply(this, arguments);
|
|
8688
9224
|
}
|
|
8689
9225
|
|
|
@@ -8723,7 +9259,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8723
9259
|
}, _callee50, this);
|
|
8724
9260
|
}));
|
|
8725
9261
|
|
|
8726
|
-
function getSegment(
|
|
9262
|
+
function getSegment(_x69) {
|
|
8727
9263
|
return _getSegment.apply(this, arguments);
|
|
8728
9264
|
}
|
|
8729
9265
|
|
|
@@ -8762,7 +9298,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8762
9298
|
}, _callee51, this);
|
|
8763
9299
|
}));
|
|
8764
9300
|
|
|
8765
|
-
function listSegments(
|
|
9301
|
+
function listSegments(_x70) {
|
|
8766
9302
|
return _listSegments.apply(this, arguments);
|
|
8767
9303
|
}
|
|
8768
9304
|
|
|
@@ -8805,7 +9341,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8805
9341
|
}, _callee52, this);
|
|
8806
9342
|
}));
|
|
8807
9343
|
|
|
8808
|
-
function updateSegment(
|
|
9344
|
+
function updateSegment(_x71, _x72) {
|
|
8809
9345
|
return _updateSegment.apply(this, arguments);
|
|
8810
9346
|
}
|
|
8811
9347
|
|
|
@@ -8837,7 +9373,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8837
9373
|
}, _callee53, this);
|
|
8838
9374
|
}));
|
|
8839
9375
|
|
|
8840
|
-
function deleteSegment(
|
|
9376
|
+
function deleteSegment(_x73) {
|
|
8841
9377
|
return _deleteSegment.apply(this, arguments);
|
|
8842
9378
|
}
|
|
8843
9379
|
|
|
@@ -8879,7 +9415,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8879
9415
|
}, _callee54, this);
|
|
8880
9416
|
}));
|
|
8881
9417
|
|
|
8882
|
-
function createCampaign(
|
|
9418
|
+
function createCampaign(_x74) {
|
|
8883
9419
|
return _createCampaign.apply(this, arguments);
|
|
8884
9420
|
}
|
|
8885
9421
|
|
|
@@ -8919,7 +9455,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8919
9455
|
}, _callee55, this);
|
|
8920
9456
|
}));
|
|
8921
9457
|
|
|
8922
|
-
function getCampaign(
|
|
9458
|
+
function getCampaign(_x75) {
|
|
8923
9459
|
return _getCampaign.apply(this, arguments);
|
|
8924
9460
|
}
|
|
8925
9461
|
|
|
@@ -8958,7 +9494,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8958
9494
|
}, _callee56, this);
|
|
8959
9495
|
}));
|
|
8960
9496
|
|
|
8961
|
-
function listCampaigns(
|
|
9497
|
+
function listCampaigns(_x76) {
|
|
8962
9498
|
return _listCampaigns.apply(this, arguments);
|
|
8963
9499
|
}
|
|
8964
9500
|
|
|
@@ -9001,7 +9537,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9001
9537
|
}, _callee57, this);
|
|
9002
9538
|
}));
|
|
9003
9539
|
|
|
9004
|
-
function updateCampaign(
|
|
9540
|
+
function updateCampaign(_x77, _x78) {
|
|
9005
9541
|
return _updateCampaign.apply(this, arguments);
|
|
9006
9542
|
}
|
|
9007
9543
|
|
|
@@ -9033,7 +9569,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9033
9569
|
}, _callee58, this);
|
|
9034
9570
|
}));
|
|
9035
9571
|
|
|
9036
|
-
function deleteCampaign(
|
|
9572
|
+
function deleteCampaign(_x79) {
|
|
9037
9573
|
return _deleteCampaign.apply(this, arguments);
|
|
9038
9574
|
}
|
|
9039
9575
|
|
|
@@ -9077,7 +9613,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9077
9613
|
}, _callee59, this);
|
|
9078
9614
|
}));
|
|
9079
9615
|
|
|
9080
|
-
function scheduleCampaign(
|
|
9616
|
+
function scheduleCampaign(_x80, _x81) {
|
|
9081
9617
|
return _scheduleCampaign.apply(this, arguments);
|
|
9082
9618
|
}
|
|
9083
9619
|
|
|
@@ -9117,7 +9653,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9117
9653
|
}, _callee60, this);
|
|
9118
9654
|
}));
|
|
9119
9655
|
|
|
9120
|
-
function stopCampaign(
|
|
9656
|
+
function stopCampaign(_x82) {
|
|
9121
9657
|
return _stopCampaign.apply(this, arguments);
|
|
9122
9658
|
}
|
|
9123
9659
|
|
|
@@ -9157,7 +9693,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9157
9693
|
}, _callee61, this);
|
|
9158
9694
|
}));
|
|
9159
9695
|
|
|
9160
|
-
function resumeCampaign(
|
|
9696
|
+
function resumeCampaign(_x83) {
|
|
9161
9697
|
return _resumeCampaign.apply(this, arguments);
|
|
9162
9698
|
}
|
|
9163
9699
|
|
|
@@ -9200,7 +9736,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9200
9736
|
}, _callee62, this);
|
|
9201
9737
|
}));
|
|
9202
9738
|
|
|
9203
|
-
function testCampaign(
|
|
9739
|
+
function testCampaign(_x84, _x85) {
|
|
9204
9740
|
return _testCampaign.apply(this, arguments);
|
|
9205
9741
|
}
|
|
9206
9742
|
|
|
@@ -9233,7 +9769,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9233
9769
|
}, _callee63, this);
|
|
9234
9770
|
}));
|
|
9235
9771
|
|
|
9236
|
-
function enrichURL(
|
|
9772
|
+
function enrichURL(_x86) {
|
|
9237
9773
|
return _enrichURL.apply(this, arguments);
|
|
9238
9774
|
}
|
|
9239
9775
|
|
|
@@ -9265,7 +9801,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9265
9801
|
}, _callee64, this);
|
|
9266
9802
|
}));
|
|
9267
9803
|
|
|
9268
|
-
function getTask(
|
|
9804
|
+
function getTask(_x87) {
|
|
9269
9805
|
return _getTask.apply(this, arguments);
|
|
9270
9806
|
}
|
|
9271
9807
|
|
|
@@ -9307,15 +9843,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9307
9843
|
}, _callee65, this);
|
|
9308
9844
|
}));
|
|
9309
9845
|
|
|
9310
|
-
function deleteChannels(
|
|
9846
|
+
function deleteChannels(_x88) {
|
|
9311
9847
|
return _deleteChannels.apply(this, arguments);
|
|
9312
9848
|
}
|
|
9313
9849
|
|
|
9314
9850
|
return deleteChannels;
|
|
9315
9851
|
}()
|
|
9316
|
-
}, {
|
|
9317
|
-
key: "deleteUsers",
|
|
9318
|
-
value:
|
|
9319
9852
|
/**
|
|
9320
9853
|
* deleteUsers - Batch Delete Users
|
|
9321
9854
|
*
|
|
@@ -9324,7 +9857,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9324
9857
|
*
|
|
9325
9858
|
* @return {APIResponse} A task ID
|
|
9326
9859
|
*/
|
|
9327
|
-
|
|
9860
|
+
|
|
9861
|
+
}, {
|
|
9862
|
+
key: "deleteUsers",
|
|
9863
|
+
value: function () {
|
|
9328
9864
|
var _deleteUsers = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee66(user_ids, options) {
|
|
9329
9865
|
return _regeneratorRuntime__default['default'].wrap(function _callee66$(_context66) {
|
|
9330
9866
|
while (1) {
|
|
@@ -9370,7 +9906,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9370
9906
|
}, _callee66, this);
|
|
9371
9907
|
}));
|
|
9372
9908
|
|
|
9373
|
-
function deleteUsers(
|
|
9909
|
+
function deleteUsers(_x89, _x90) {
|
|
9374
9910
|
return _deleteUsers.apply(this, arguments);
|
|
9375
9911
|
}
|
|
9376
9912
|
|
|
@@ -9502,4 +10038,5 @@ exports.encodeBase64 = encodeBase64;
|
|
|
9502
10038
|
exports.isOwnUser = isOwnUser;
|
|
9503
10039
|
exports.isValidEventType = isValidEventType;
|
|
9504
10040
|
exports.logChatPromiseExecution = logChatPromiseExecution;
|
|
10041
|
+
exports.postInsights = postInsights;
|
|
9505
10042
|
//# sourceMappingURL=index.js.map
|