stream-chat 4.4.3-dev.2 → 5.0.0
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 +1229 -720
- 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 +1229 -719
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +1229 -720
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1229 -719
- 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 +17 -10
- 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 +94 -88
- 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 +291 -712
- package/src/client_state.ts +2 -2
- package/src/connection.ts +146 -395
- package/src/connection_fallback.ts +205 -0
- package/src/errors.ts +58 -0
- package/src/insights.ts +38 -32
- package/src/permissions.ts +3 -24
- package/src/signing.ts +6 -17
- package/src/token_manager.ts +6 -18
- package/src/types.ts +268 -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, "
|
|
3621
|
-
|
|
3622
|
-
_defineProperty__default['default'](this, "insightMetrics", void 0);
|
|
3623
|
-
|
|
3624
|
-
_defineProperty__default['default'](this, "_buildUrl", function (reqID) {
|
|
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));
|
|
3721
|
+
_defineProperty__default['default'](this, "_buildUrl", function () {
|
|
3722
|
+
var qs = encodeURIComponent(_this.client._buildWSPayload(_this.requestID));
|
|
3634
3723
|
|
|
3635
|
-
var token = _this.tokenManager.getToken();
|
|
3724
|
+
var token = _this.client.tokenManager.getToken();
|
|
3636
3725
|
|
|
3637
|
-
return "".concat(_this.wsBaseURL, "/connect?json=").concat(qs, "&api_key=").concat(_this.
|
|
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,576 @@ 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 = 3;
|
|
5184
|
+
break;
|
|
5185
|
+
}
|
|
5186
|
+
|
|
5187
|
+
throw new Error('connecting already in progress');
|
|
5188
|
+
|
|
5189
|
+
case 3:
|
|
5190
|
+
if (!(_this.state === ConnectionState.Connected)) {
|
|
5191
|
+
_context3.next = 5;
|
|
5192
|
+
break;
|
|
5193
|
+
}
|
|
5194
|
+
|
|
5195
|
+
throw new Error('already connected and polling');
|
|
5196
|
+
|
|
5197
|
+
case 5:
|
|
5198
|
+
_this._setState(ConnectionState.Connecting);
|
|
5199
|
+
|
|
5200
|
+
_this.connectionID = undefined; // connect should be sent with empty connection_id so API creates one
|
|
5201
|
+
|
|
5202
|
+
_context3.prev = 7;
|
|
5203
|
+
_context3.next = 10;
|
|
5204
|
+
return _this._req({
|
|
5205
|
+
json: _this.client._buildWSPayload()
|
|
5206
|
+
}, {
|
|
5207
|
+
timeout: 8000
|
|
5208
|
+
}, // 8s
|
|
5209
|
+
reconnect);
|
|
5210
|
+
|
|
5211
|
+
case 10:
|
|
5212
|
+
_yield$_this$_req = _context3.sent;
|
|
5213
|
+
event = _yield$_this$_req.event;
|
|
5214
|
+
|
|
5215
|
+
_this._setState(ConnectionState.Connected);
|
|
5216
|
+
|
|
5217
|
+
_this.connectionID = event.connection_id;
|
|
5218
|
+
|
|
5219
|
+
_this._poll();
|
|
5220
|
+
|
|
5221
|
+
if (reconnect) {
|
|
5222
|
+
_this.client.recoverState();
|
|
5223
|
+
}
|
|
5224
|
+
|
|
5225
|
+
return _context3.abrupt("return", event);
|
|
4752
5226
|
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
break;
|
|
4757
|
-
}
|
|
5227
|
+
case 19:
|
|
5228
|
+
_context3.prev = 19;
|
|
5229
|
+
_context3.t0 = _context3["catch"](7);
|
|
4758
5230
|
|
|
4759
|
-
|
|
4760
|
-
return _this.tokenProvider();
|
|
5231
|
+
_this._setState(ConnectionState.Closed);
|
|
4761
5232
|
|
|
4762
|
-
|
|
4763
|
-
_this.token = _context2.sent;
|
|
4764
|
-
resolve(_this.token);
|
|
5233
|
+
throw _context3.t0;
|
|
4765
5234
|
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
}
|
|
5235
|
+
case 23:
|
|
5236
|
+
case "end":
|
|
5237
|
+
return _context3.stop();
|
|
4770
5238
|
}
|
|
4771
|
-
}
|
|
4772
|
-
})
|
|
5239
|
+
}
|
|
5240
|
+
}, _callee3, null, [[7, 19]]);
|
|
5241
|
+
})));
|
|
4773
5242
|
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
}());
|
|
4778
|
-
return _this.loadTokenPromise;
|
|
4779
|
-
});
|
|
5243
|
+
_defineProperty__default['default'](this, "isHealthy", function () {
|
|
5244
|
+
return _this.connectionID && _this.state === ConnectionState.Connected;
|
|
5245
|
+
});
|
|
4780
5246
|
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
return _this.token;
|
|
4784
|
-
}
|
|
5247
|
+
_defineProperty__default['default'](this, "disconnect", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4() {
|
|
5248
|
+
var _this$cancelToken3;
|
|
4785
5249
|
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
5250
|
+
var timeout,
|
|
5251
|
+
_args4 = arguments;
|
|
5252
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
5253
|
+
while (1) {
|
|
5254
|
+
switch (_context4.prev = _context4.next) {
|
|
5255
|
+
case 0:
|
|
5256
|
+
timeout = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : 2000;
|
|
5257
|
+
removeConnectionEventListeners(_this._onlineStatusChanged);
|
|
4789
5258
|
|
|
4790
|
-
|
|
4791
|
-
return JWTServerToken(_this.secret);
|
|
4792
|
-
}
|
|
5259
|
+
_this._setState(ConnectionState.Disconnected);
|
|
4793
5260
|
|
|
4794
|
-
|
|
4795
|
-
|
|
5261
|
+
(_this$cancelToken3 = _this.cancelToken) === null || _this$cancelToken3 === void 0 ? void 0 : _this$cancelToken3.cancel('disconnect() is called');
|
|
5262
|
+
_this.cancelToken = undefined;
|
|
5263
|
+
_context4.prev = 5;
|
|
5264
|
+
_context4.next = 8;
|
|
5265
|
+
return _this._req({
|
|
5266
|
+
close: true
|
|
5267
|
+
}, {
|
|
5268
|
+
timeout: timeout
|
|
5269
|
+
}, false);
|
|
4796
5270
|
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
});
|
|
5271
|
+
case 8:
|
|
5272
|
+
_this.connectionID = undefined;
|
|
4800
5273
|
|
|
4801
|
-
|
|
5274
|
+
_this._log("disconnect() - Closed connectionID");
|
|
4802
5275
|
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
}
|
|
5276
|
+
_context4.next = 15;
|
|
5277
|
+
break;
|
|
4806
5278
|
|
|
4807
|
-
|
|
5279
|
+
case 12:
|
|
5280
|
+
_context4.prev = 12;
|
|
5281
|
+
_context4.t0 = _context4["catch"](5);
|
|
4808
5282
|
|
|
4809
|
-
|
|
4810
|
-
|
|
5283
|
+
_this._log("disconnect() - Failed", {
|
|
5284
|
+
err: _context4.t0
|
|
5285
|
+
}, 'error');
|
|
5286
|
+
|
|
5287
|
+
case 15:
|
|
5288
|
+
case "end":
|
|
5289
|
+
return _context4.stop();
|
|
5290
|
+
}
|
|
5291
|
+
}
|
|
5292
|
+
}, _callee4, null, [[5, 12]]);
|
|
5293
|
+
})));
|
|
5294
|
+
|
|
5295
|
+
this.client = client;
|
|
5296
|
+
this.state = ConnectionState.Init;
|
|
5297
|
+
this.consecutiveFailures = 0;
|
|
5298
|
+
addConnectionEventListeners(this._onlineStatusChanged);
|
|
4811
5299
|
}
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
;
|
|
5300
|
+
|
|
5301
|
+
_createClass__default['default'](WSConnectionFallback, [{
|
|
5302
|
+
key: "_log",
|
|
5303
|
+
value: function _log(msg) {
|
|
5304
|
+
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5305
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
5306
|
+
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$1({
|
|
5307
|
+
tags: ['connection_fallback', 'connection']
|
|
5308
|
+
}, extra));
|
|
5309
|
+
}
|
|
5310
|
+
}, {
|
|
5311
|
+
key: "_setState",
|
|
5312
|
+
value: function _setState(state) {
|
|
5313
|
+
this._log("_setState() - ".concat(state)); // transition from connecting => connected
|
|
5314
|
+
|
|
5315
|
+
|
|
5316
|
+
if (this.state === ConnectionState.Connecting && state === ConnectionState.Connected) {
|
|
5317
|
+
//@ts-expect-error
|
|
5318
|
+
this.client.dispatchEvent({
|
|
5319
|
+
type: 'connection.changed',
|
|
5320
|
+
online: true
|
|
5321
|
+
});
|
|
5322
|
+
}
|
|
5323
|
+
|
|
5324
|
+
if (state === ConnectionState.Closed || state === ConnectionState.Disconnected) {
|
|
5325
|
+
//@ts-expect-error
|
|
5326
|
+
this.client.dispatchEvent({
|
|
5327
|
+
type: 'connection.changed',
|
|
5328
|
+
online: false
|
|
5329
|
+
});
|
|
5330
|
+
}
|
|
5331
|
+
|
|
5332
|
+
this.state = state;
|
|
5333
|
+
}
|
|
5334
|
+
/** @private */
|
|
5335
|
+
|
|
5336
|
+
}]);
|
|
5337
|
+
|
|
5338
|
+
return WSConnectionFallback;
|
|
5339
|
+
}();
|
|
4821
5340
|
|
|
4822
5341
|
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
5342
|
|
|
@@ -4857,10 +5376,6 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4857
5376
|
|
|
4858
5377
|
_defineProperty__default['default'](this, "configs", void 0);
|
|
4859
5378
|
|
|
4860
|
-
_defineProperty__default['default'](this, "connectionID", void 0);
|
|
4861
|
-
|
|
4862
|
-
_defineProperty__default['default'](this, "failures", void 0);
|
|
4863
|
-
|
|
4864
5379
|
_defineProperty__default['default'](this, "key", void 0);
|
|
4865
5380
|
|
|
4866
5381
|
_defineProperty__default['default'](this, "listeners", void 0);
|
|
@@ -4895,16 +5410,26 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4895
5410
|
|
|
4896
5411
|
_defineProperty__default['default'](this, "wsConnection", void 0);
|
|
4897
5412
|
|
|
5413
|
+
_defineProperty__default['default'](this, "wsFallback", void 0);
|
|
5414
|
+
|
|
4898
5415
|
_defineProperty__default['default'](this, "wsPromise", void 0);
|
|
4899
5416
|
|
|
4900
5417
|
_defineProperty__default['default'](this, "consecutiveFailures", void 0);
|
|
4901
5418
|
|
|
4902
5419
|
_defineProperty__default['default'](this, "insightMetrics", void 0);
|
|
4903
5420
|
|
|
4904
|
-
_defineProperty__default['default'](this, "
|
|
4905
|
-
|
|
5421
|
+
_defineProperty__default['default'](this, "defaultWSTimeoutWithFallback", void 0);
|
|
5422
|
+
|
|
5423
|
+
_defineProperty__default['default'](this, "defaultWSTimeout", void 0);
|
|
5424
|
+
|
|
5425
|
+
_defineProperty__default['default'](this, "_getConnectionID", function () {
|
|
5426
|
+
var _this$wsConnection, _this$wsFallback;
|
|
5427
|
+
|
|
5428
|
+
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);
|
|
5429
|
+
});
|
|
4906
5430
|
|
|
4907
|
-
|
|
5431
|
+
_defineProperty__default['default'](this, "_hasConnectionID", function () {
|
|
5432
|
+
return Boolean(_this._getConnectionID());
|
|
4908
5433
|
});
|
|
4909
5434
|
|
|
4910
5435
|
_defineProperty__default['default'](this, "connectUser", /*#__PURE__*/function () {
|
|
@@ -4990,36 +5515,55 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4990
5515
|
return _this.tokenManager.setTokenOrProvider(userTokenOrProvider, user);
|
|
4991
5516
|
});
|
|
4992
5517
|
|
|
4993
|
-
_defineProperty__default['default'](this, "closeConnection", function (
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
_this.cleaningIntervalRef = undefined;
|
|
4997
|
-
}
|
|
5518
|
+
_defineProperty__default['default'](this, "closeConnection", /*#__PURE__*/function () {
|
|
5519
|
+
var _ref2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2(timeout) {
|
|
5520
|
+
var _this$wsConnection2, _this$wsFallback2;
|
|
4998
5521
|
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5522
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
5523
|
+
while (1) {
|
|
5524
|
+
switch (_context2.prev = _context2.next) {
|
|
5525
|
+
case 0:
|
|
5526
|
+
if (_this.cleaningIntervalRef != null) {
|
|
5527
|
+
clearInterval(_this.cleaningIntervalRef);
|
|
5528
|
+
_this.cleaningIntervalRef = undefined;
|
|
5529
|
+
}
|
|
5002
5530
|
|
|
5003
|
-
|
|
5004
|
-
|
|
5531
|
+
_context2.next = 3;
|
|
5532
|
+
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
5533
|
|
|
5006
|
-
|
|
5007
|
-
|
|
5534
|
+
case 3:
|
|
5535
|
+
return _context2.abrupt("return", Promise.resolve());
|
|
5008
5536
|
|
|
5009
|
-
|
|
5537
|
+
case 4:
|
|
5538
|
+
case "end":
|
|
5539
|
+
return _context2.stop();
|
|
5540
|
+
}
|
|
5541
|
+
}
|
|
5542
|
+
}, _callee2);
|
|
5543
|
+
}));
|
|
5544
|
+
|
|
5545
|
+
return function (_x3) {
|
|
5546
|
+
return _ref2.apply(this, arguments);
|
|
5547
|
+
};
|
|
5548
|
+
}());
|
|
5549
|
+
|
|
5550
|
+
_defineProperty__default['default'](this, "openConnection", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
5551
|
+
var _this$wsConnection3, _this$wsFallback3;
|
|
5552
|
+
|
|
5553
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
5010
5554
|
while (1) {
|
|
5011
|
-
switch (
|
|
5555
|
+
switch (_context3.prev = _context3.next) {
|
|
5012
5556
|
case 0:
|
|
5013
5557
|
if (_this.userID) {
|
|
5014
|
-
|
|
5558
|
+
_context3.next = 2;
|
|
5015
5559
|
break;
|
|
5016
5560
|
}
|
|
5017
5561
|
|
|
5018
5562
|
throw Error('User is not set on client, use client.connectUser or client.connectAnonymousUser instead');
|
|
5019
5563
|
|
|
5020
5564
|
case 2:
|
|
5021
|
-
if (!((_this$
|
|
5022
|
-
|
|
5565
|
+
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())) {
|
|
5566
|
+
_context3.next = 5;
|
|
5023
5567
|
break;
|
|
5024
5568
|
}
|
|
5025
5569
|
|
|
@@ -5027,7 +5571,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5027
5571
|
tags: ['connection', 'client']
|
|
5028
5572
|
});
|
|
5029
5573
|
|
|
5030
|
-
return
|
|
5574
|
+
return _context3.abrupt("return", Promise.resolve());
|
|
5031
5575
|
|
|
5032
5576
|
case 5:
|
|
5033
5577
|
_this.clientID = "".concat(_this.userID, "--").concat(randomId());
|
|
@@ -5035,14 +5579,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5035
5579
|
|
|
5036
5580
|
_this._startCleaning();
|
|
5037
5581
|
|
|
5038
|
-
return
|
|
5582
|
+
return _context3.abrupt("return", _this.wsPromise);
|
|
5039
5583
|
|
|
5040
5584
|
case 9:
|
|
5041
5585
|
case "end":
|
|
5042
|
-
return
|
|
5586
|
+
return _context3.stop();
|
|
5043
5587
|
}
|
|
5044
5588
|
}
|
|
5045
|
-
},
|
|
5589
|
+
}, _callee3);
|
|
5046
5590
|
})));
|
|
5047
5591
|
|
|
5048
5592
|
_defineProperty__default['default'](this, "_setupConnection", this.openConnection);
|
|
@@ -5060,12 +5604,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5060
5604
|
});
|
|
5061
5605
|
|
|
5062
5606
|
_defineProperty__default['default'](this, "disconnectUser", /*#__PURE__*/function () {
|
|
5063
|
-
var
|
|
5607
|
+
var _ref4 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4(timeout) {
|
|
5064
5608
|
var closePromise, _i, _Object$values, _channel;
|
|
5065
5609
|
|
|
5066
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
5610
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
5067
5611
|
while (1) {
|
|
5068
|
-
switch (
|
|
5612
|
+
switch (_context4.prev = _context4.next) {
|
|
5069
5613
|
case 0:
|
|
5070
5614
|
_this.logger('info', 'client:disconnect() - Disconnecting the client', {
|
|
5071
5615
|
tags: ['connection', 'client']
|
|
@@ -5089,21 +5633,21 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5089
5633
|
|
|
5090
5634
|
_this.state = new ClientState(); // reset token manager
|
|
5091
5635
|
|
|
5092
|
-
_this.tokenManager.reset
|
|
5636
|
+
setTimeout(_this.tokenManager.reset); // delay reseting to use token for disconnect calls
|
|
5637
|
+
// close the WS connection
|
|
5093
5638
|
|
|
5094
|
-
|
|
5095
|
-
return _context3.abrupt("return", closePromise);
|
|
5639
|
+
return _context4.abrupt("return", closePromise);
|
|
5096
5640
|
|
|
5097
5641
|
case 11:
|
|
5098
5642
|
case "end":
|
|
5099
|
-
return
|
|
5643
|
+
return _context4.stop();
|
|
5100
5644
|
}
|
|
5101
5645
|
}
|
|
5102
|
-
},
|
|
5646
|
+
}, _callee4);
|
|
5103
5647
|
}));
|
|
5104
5648
|
|
|
5105
|
-
return function (
|
|
5106
|
-
return
|
|
5649
|
+
return function (_x4) {
|
|
5650
|
+
return _ref4.apply(this, arguments);
|
|
5107
5651
|
};
|
|
5108
5652
|
}());
|
|
5109
5653
|
|
|
@@ -5131,78 +5675,78 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5131
5675
|
_defineProperty__default['default'](this, "setAnonymousUser", this.connectAnonymousUser);
|
|
5132
5676
|
|
|
5133
5677
|
_defineProperty__default['default'](this, "doAxiosRequest", /*#__PURE__*/function () {
|
|
5134
|
-
var
|
|
5678
|
+
var _ref5 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(type, url, data) {
|
|
5135
5679
|
var options,
|
|
5136
5680
|
requestConfig,
|
|
5137
5681
|
response,
|
|
5138
5682
|
_requestConfig$header,
|
|
5139
|
-
|
|
5683
|
+
_args5 = arguments;
|
|
5140
5684
|
|
|
5141
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
5685
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
|
|
5142
5686
|
while (1) {
|
|
5143
|
-
switch (
|
|
5687
|
+
switch (_context5.prev = _context5.next) {
|
|
5144
5688
|
case 0:
|
|
5145
|
-
options =
|
|
5146
|
-
|
|
5689
|
+
options = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : {};
|
|
5690
|
+
_context5.next = 3;
|
|
5147
5691
|
return _this.tokenManager.tokenReady();
|
|
5148
5692
|
|
|
5149
5693
|
case 3:
|
|
5150
5694
|
requestConfig = _this._enrichAxiosOptions(options);
|
|
5151
|
-
|
|
5695
|
+
_context5.prev = 4;
|
|
5152
5696
|
|
|
5153
5697
|
_this._logApiRequest(type, url, data, requestConfig);
|
|
5154
5698
|
|
|
5155
|
-
|
|
5156
|
-
|
|
5699
|
+
_context5.t0 = type;
|
|
5700
|
+
_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
5701
|
break;
|
|
5158
5702
|
|
|
5159
5703
|
case 9:
|
|
5160
|
-
|
|
5704
|
+
_context5.next = 11;
|
|
5161
5705
|
return _this.axiosInstance.get(url, requestConfig);
|
|
5162
5706
|
|
|
5163
5707
|
case 11:
|
|
5164
|
-
response =
|
|
5165
|
-
return
|
|
5708
|
+
response = _context5.sent;
|
|
5709
|
+
return _context5.abrupt("break", 34);
|
|
5166
5710
|
|
|
5167
5711
|
case 13:
|
|
5168
|
-
|
|
5712
|
+
_context5.next = 15;
|
|
5169
5713
|
return _this.axiosInstance.delete(url, requestConfig);
|
|
5170
5714
|
|
|
5171
5715
|
case 15:
|
|
5172
|
-
response =
|
|
5173
|
-
return
|
|
5716
|
+
response = _context5.sent;
|
|
5717
|
+
return _context5.abrupt("break", 34);
|
|
5174
5718
|
|
|
5175
5719
|
case 17:
|
|
5176
|
-
|
|
5720
|
+
_context5.next = 19;
|
|
5177
5721
|
return _this.axiosInstance.post(url, data, requestConfig);
|
|
5178
5722
|
|
|
5179
5723
|
case 19:
|
|
5180
|
-
response =
|
|
5181
|
-
return
|
|
5724
|
+
response = _context5.sent;
|
|
5725
|
+
return _context5.abrupt("break", 34);
|
|
5182
5726
|
|
|
5183
5727
|
case 21:
|
|
5184
|
-
|
|
5728
|
+
_context5.next = 23;
|
|
5185
5729
|
return _this.axiosInstance.put(url, data, requestConfig);
|
|
5186
5730
|
|
|
5187
5731
|
case 23:
|
|
5188
|
-
response =
|
|
5189
|
-
return
|
|
5732
|
+
response = _context5.sent;
|
|
5733
|
+
return _context5.abrupt("break", 34);
|
|
5190
5734
|
|
|
5191
5735
|
case 25:
|
|
5192
|
-
|
|
5736
|
+
_context5.next = 27;
|
|
5193
5737
|
return _this.axiosInstance.patch(url, data, requestConfig);
|
|
5194
5738
|
|
|
5195
5739
|
case 27:
|
|
5196
|
-
response =
|
|
5197
|
-
return
|
|
5740
|
+
response = _context5.sent;
|
|
5741
|
+
return _context5.abrupt("break", 34);
|
|
5198
5742
|
|
|
5199
5743
|
case 29:
|
|
5200
|
-
|
|
5744
|
+
_context5.next = 31;
|
|
5201
5745
|
return _this.axiosInstance.options(url, requestConfig);
|
|
5202
5746
|
|
|
5203
5747
|
case 31:
|
|
5204
|
-
response =
|
|
5205
|
-
return
|
|
5748
|
+
response = _context5.sent;
|
|
5749
|
+
return _context5.abrupt("break", 34);
|
|
5206
5750
|
|
|
5207
5751
|
case 33:
|
|
5208
5752
|
throw new Error('Invalid request type');
|
|
@@ -5211,65 +5755,66 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5211
5755
|
_this._logApiResponse(type, url, response);
|
|
5212
5756
|
|
|
5213
5757
|
_this.consecutiveFailures = 0;
|
|
5214
|
-
return
|
|
5758
|
+
return _context5.abrupt("return", _this.handleResponse(response));
|
|
5215
5759
|
|
|
5216
5760
|
case 39:
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5761
|
+
_context5.prev = 39;
|
|
5762
|
+
_context5.t1 = _context5["catch"](4);
|
|
5763
|
+
_context5.t1.client_request_id = (_requestConfig$header = requestConfig.headers) === null || _requestConfig$header === void 0 ? void 0 : _requestConfig$header['x-client-request-id'];
|
|
5220
5764
|
|
|
5221
|
-
_this._logApiError(type, url,
|
|
5765
|
+
_this._logApiError(type, url, _context5.t1);
|
|
5222
5766
|
|
|
5223
5767
|
_this.consecutiveFailures += 1;
|
|
5224
5768
|
|
|
5225
|
-
if (!
|
|
5226
|
-
|
|
5769
|
+
if (!_context5.t1.response) {
|
|
5770
|
+
_context5.next = 56;
|
|
5227
5771
|
break;
|
|
5228
5772
|
}
|
|
5229
5773
|
|
|
5230
|
-
if (!(
|
|
5231
|
-
|
|
5774
|
+
if (!(_context5.t1.response.data.code === chatCodes.TOKEN_EXPIRED && !_this.tokenManager.isStatic())) {
|
|
5775
|
+
_context5.next = 53;
|
|
5232
5776
|
break;
|
|
5233
5777
|
}
|
|
5234
5778
|
|
|
5235
5779
|
if (!(_this.consecutiveFailures > 1)) {
|
|
5236
|
-
|
|
5780
|
+
_context5.next = 49;
|
|
5237
5781
|
break;
|
|
5238
5782
|
}
|
|
5239
5783
|
|
|
5240
|
-
|
|
5784
|
+
_context5.next = 49;
|
|
5241
5785
|
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5242
5786
|
|
|
5243
5787
|
case 49:
|
|
5244
5788
|
_this.tokenManager.loadToken();
|
|
5245
5789
|
|
|
5246
|
-
|
|
5790
|
+
_context5.next = 52;
|
|
5247
5791
|
return _this.doAxiosRequest(type, url, data, options);
|
|
5248
5792
|
|
|
5249
5793
|
case 52:
|
|
5250
|
-
return
|
|
5794
|
+
return _context5.abrupt("return", _context5.sent);
|
|
5251
5795
|
|
|
5252
5796
|
case 53:
|
|
5253
|
-
return
|
|
5797
|
+
return _context5.abrupt("return", _this.handleResponse(_context5.t1.response));
|
|
5254
5798
|
|
|
5255
5799
|
case 56:
|
|
5256
|
-
throw
|
|
5800
|
+
throw _context5.t1;
|
|
5257
5801
|
|
|
5258
5802
|
case 57:
|
|
5259
5803
|
case "end":
|
|
5260
|
-
return
|
|
5804
|
+
return _context5.stop();
|
|
5261
5805
|
}
|
|
5262
5806
|
}
|
|
5263
|
-
},
|
|
5807
|
+
}, _callee5, null, [[4, 39]]);
|
|
5264
5808
|
}));
|
|
5265
5809
|
|
|
5266
|
-
return function (
|
|
5267
|
-
return
|
|
5810
|
+
return function (_x5, _x6, _x7) {
|
|
5811
|
+
return _ref5.apply(this, arguments);
|
|
5268
5812
|
};
|
|
5269
5813
|
}());
|
|
5270
5814
|
|
|
5271
5815
|
_defineProperty__default['default'](this, "dispatchEvent", function (event) {
|
|
5272
|
-
// client event handlers
|
|
5816
|
+
if (!event.received_at) event.received_at = new Date(); // client event handlers
|
|
5817
|
+
|
|
5273
5818
|
var postListenerCallbacks = _this._handleClientEvent(event); // channel event handlers
|
|
5274
5819
|
|
|
5275
5820
|
|
|
@@ -5295,7 +5840,6 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5295
5840
|
// dispatch the event to the channel listeners
|
|
5296
5841
|
var jsonString = messageEvent.data;
|
|
5297
5842
|
var event = JSON.parse(jsonString);
|
|
5298
|
-
event.received_at = new Date();
|
|
5299
5843
|
|
|
5300
5844
|
_this.dispatchEvent(event);
|
|
5301
5845
|
});
|
|
@@ -5416,22 +5960,20 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5416
5960
|
}
|
|
5417
5961
|
});
|
|
5418
5962
|
|
|
5419
|
-
_defineProperty__default['default'](this, "recoverState", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
5420
|
-
var _this$wsConnection3;
|
|
5421
|
-
|
|
5963
|
+
_defineProperty__default['default'](this, "recoverState", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee6() {
|
|
5422
5964
|
var cids;
|
|
5423
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
5965
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee6$(_context6) {
|
|
5424
5966
|
while (1) {
|
|
5425
|
-
switch (
|
|
5967
|
+
switch (_context6.prev = _context6.next) {
|
|
5426
5968
|
case 0:
|
|
5427
|
-
_this.logger('info', "client:recoverState() - Start of recoverState with connectionID ".concat(
|
|
5969
|
+
_this.logger('info', "client:recoverState() - Start of recoverState with connectionID ".concat(_this._getConnectionID()), {
|
|
5428
5970
|
tags: ['connection']
|
|
5429
5971
|
});
|
|
5430
5972
|
|
|
5431
5973
|
cids = Object.keys(_this.activeChannels);
|
|
5432
5974
|
|
|
5433
5975
|
if (!(cids.length && _this.recoverStateOnReconnect)) {
|
|
5434
|
-
|
|
5976
|
+
_context6.next = 10;
|
|
5435
5977
|
break;
|
|
5436
5978
|
}
|
|
5437
5979
|
|
|
@@ -5439,7 +5981,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5439
5981
|
tags: ['connection', 'client']
|
|
5440
5982
|
});
|
|
5441
5983
|
|
|
5442
|
-
|
|
5984
|
+
_context6.next = 6;
|
|
5443
5985
|
return _this.queryChannels({
|
|
5444
5986
|
cid: {
|
|
5445
5987
|
$in: cids
|
|
@@ -5459,7 +6001,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5459
6001
|
type: 'connection.recovered'
|
|
5460
6002
|
});
|
|
5461
6003
|
|
|
5462
|
-
|
|
6004
|
+
_context6.next = 11;
|
|
5463
6005
|
break;
|
|
5464
6006
|
|
|
5465
6007
|
case 10:
|
|
@@ -5473,10 +6015,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5473
6015
|
|
|
5474
6016
|
case 13:
|
|
5475
6017
|
case "end":
|
|
5476
|
-
return
|
|
6018
|
+
return _context6.stop();
|
|
5477
6019
|
}
|
|
5478
6020
|
}
|
|
5479
|
-
},
|
|
6021
|
+
}, _callee6);
|
|
5480
6022
|
})));
|
|
5481
6023
|
|
|
5482
6024
|
_defineProperty__default['default'](this, "getChannelByMembers", function (channelType, custom) {
|
|
@@ -5556,66 +6098,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5556
6098
|
return !!_this.secret;
|
|
5557
6099
|
});
|
|
5558
6100
|
|
|
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
|
-
}());
|
|
6101
|
+
_defineProperty__default['default'](this, "_buildWSPayload", function (client_request_id) {
|
|
6102
|
+
return JSON.stringify({
|
|
6103
|
+
user_id: _this.userID,
|
|
6104
|
+
user_details: _this._user,
|
|
6105
|
+
device: _this.options.device,
|
|
6106
|
+
client_request_id: client_request_id
|
|
6107
|
+
});
|
|
6108
|
+
});
|
|
5619
6109
|
|
|
5620
6110
|
// set the key
|
|
5621
6111
|
this.key = _key;
|
|
@@ -5673,6 +6163,8 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5673
6163
|
this.tokenManager = new TokenManager(this.secret);
|
|
5674
6164
|
this.consecutiveFailures = 0;
|
|
5675
6165
|
this.insightMetrics = new InsightMetrics();
|
|
6166
|
+
this.defaultWSTimeoutWithFallback = 6000;
|
|
6167
|
+
this.defaultWSTimeout = 15000;
|
|
5676
6168
|
/**
|
|
5677
6169
|
* logger function should accept 3 parameters:
|
|
5678
6170
|
* @param logLevel string
|
|
@@ -5846,7 +6338,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5846
6338
|
}, _callee7, this);
|
|
5847
6339
|
}));
|
|
5848
6340
|
|
|
5849
|
-
function updateAppSettings(
|
|
6341
|
+
function updateAppSettings(_x8) {
|
|
5850
6342
|
return _updateAppSettings.apply(this, arguments);
|
|
5851
6343
|
}
|
|
5852
6344
|
|
|
@@ -5880,7 +6372,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5880
6372
|
}, _callee8, this);
|
|
5881
6373
|
}));
|
|
5882
6374
|
|
|
5883
|
-
function revokeTokens(
|
|
6375
|
+
function revokeTokens(_x9) {
|
|
5884
6376
|
return _revokeTokens.apply(this, arguments);
|
|
5885
6377
|
}
|
|
5886
6378
|
|
|
@@ -5912,7 +6404,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5912
6404
|
}, _callee9, this);
|
|
5913
6405
|
}));
|
|
5914
6406
|
|
|
5915
|
-
function revokeUserToken(
|
|
6407
|
+
function revokeUserToken(_x10, _x11) {
|
|
5916
6408
|
return _revokeUserToken.apply(this, arguments);
|
|
5917
6409
|
}
|
|
5918
6410
|
|
|
@@ -5971,7 +6463,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5971
6463
|
}, _callee10, this);
|
|
5972
6464
|
}));
|
|
5973
6465
|
|
|
5974
|
-
function revokeUsersToken(
|
|
6466
|
+
function revokeUsersToken(_x12, _x13) {
|
|
5975
6467
|
return _revokeUsersToken.apply(this, arguments);
|
|
5976
6468
|
}
|
|
5977
6469
|
|
|
@@ -6063,7 +6555,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6063
6555
|
}, _callee12, this);
|
|
6064
6556
|
}));
|
|
6065
6557
|
|
|
6066
|
-
function testPushSettings(
|
|
6558
|
+
function testPushSettings(_x14) {
|
|
6067
6559
|
return _testPushSettings.apply(this, arguments);
|
|
6068
6560
|
}
|
|
6069
6561
|
|
|
@@ -6172,7 +6664,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6172
6664
|
}, _callee14, this, [[1, 7]]);
|
|
6173
6665
|
}));
|
|
6174
6666
|
|
|
6175
|
-
function setGuestUser(
|
|
6667
|
+
function setGuestUser(_x15) {
|
|
6176
6668
|
return _setGuestUser.apply(this, arguments);
|
|
6177
6669
|
}
|
|
6178
6670
|
|
|
@@ -6483,72 +6975,84 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6483
6975
|
*/
|
|
6484
6976
|
function () {
|
|
6485
6977
|
var _connect = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee15() {
|
|
6486
|
-
var client;
|
|
6487
6978
|
return _regeneratorRuntime__default['default'].wrap(function _callee15$(_context15) {
|
|
6488
6979
|
while (1) {
|
|
6489
6980
|
switch (_context15.prev = _context15.next) {
|
|
6490
6981
|
case 0:
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
if (!(client.userID == null || this._user == null)) {
|
|
6495
|
-
_context15.next = 4;
|
|
6982
|
+
if (!(!this.userID || !this._user)) {
|
|
6983
|
+
_context15.next = 2;
|
|
6496
6984
|
break;
|
|
6497
6985
|
}
|
|
6498
6986
|
|
|
6499
6987
|
throw Error('Call connectUser or connectAnonymousUser before starting the connection');
|
|
6500
6988
|
|
|
6501
|
-
case
|
|
6502
|
-
if (
|
|
6503
|
-
_context15.next =
|
|
6989
|
+
case 2:
|
|
6990
|
+
if (this.wsBaseURL) {
|
|
6991
|
+
_context15.next = 4;
|
|
6504
6992
|
break;
|
|
6505
6993
|
}
|
|
6506
6994
|
|
|
6507
6995
|
throw Error('Websocket base url not set');
|
|
6508
6996
|
|
|
6509
|
-
case
|
|
6510
|
-
if (
|
|
6511
|
-
_context15.next =
|
|
6997
|
+
case 4:
|
|
6998
|
+
if (this.clientID) {
|
|
6999
|
+
_context15.next = 6;
|
|
6512
7000
|
break;
|
|
6513
7001
|
}
|
|
6514
7002
|
|
|
6515
7003
|
throw Error('clientID is not set');
|
|
6516
7004
|
|
|
6517
|
-
case
|
|
7005
|
+
case 6:
|
|
6518
7006
|
if (!this.wsConnection && (this.options.warmUp || this.options.enableInsights)) {
|
|
6519
|
-
this.
|
|
7007
|
+
this._sayHi();
|
|
6520
7008
|
} // The StableWSConnection handles all the reconnection logic.
|
|
6521
7009
|
|
|
6522
7010
|
|
|
6523
7011
|
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
|
|
7012
|
+
client: this
|
|
6539
7013
|
});
|
|
6540
|
-
_context15.
|
|
6541
|
-
|
|
7014
|
+
_context15.prev = 8;
|
|
7015
|
+
_context15.next = 11;
|
|
7016
|
+
return this.wsConnection.connect(this.options.enableWSFallback ? this.defaultWSTimeoutWithFallback : this.defaultWSTimeout);
|
|
6542
7017
|
|
|
6543
|
-
case
|
|
7018
|
+
case 11:
|
|
6544
7019
|
return _context15.abrupt("return", _context15.sent);
|
|
6545
7020
|
|
|
6546
|
-
case
|
|
7021
|
+
case 14:
|
|
7022
|
+
_context15.prev = 14;
|
|
7023
|
+
_context15.t0 = _context15["catch"](8);
|
|
7024
|
+
|
|
7025
|
+
if (!(this.options.enableWSFallback && isWSFailure(_context15.t0) && isOnline())) {
|
|
7026
|
+
_context15.next = 24;
|
|
7027
|
+
break;
|
|
7028
|
+
}
|
|
7029
|
+
|
|
7030
|
+
this.logger('info', 'client:connect() - WS failed, fallback to longpoll', {
|
|
7031
|
+
tags: ['connection', 'client']
|
|
7032
|
+
});
|
|
7033
|
+
|
|
7034
|
+
this.wsConnection._destroyCurrentWSConnection();
|
|
7035
|
+
|
|
7036
|
+
this.wsConnection.disconnect().then(); // close WS so no retry
|
|
7037
|
+
|
|
7038
|
+
this.wsFallback = new WSConnectionFallback({
|
|
7039
|
+
client: this
|
|
7040
|
+
});
|
|
7041
|
+
_context15.next = 23;
|
|
7042
|
+
return this.wsFallback.connect();
|
|
7043
|
+
|
|
7044
|
+
case 23:
|
|
7045
|
+
return _context15.abrupt("return", _context15.sent);
|
|
7046
|
+
|
|
7047
|
+
case 24:
|
|
7048
|
+
throw _context15.t0;
|
|
7049
|
+
|
|
7050
|
+
case 25:
|
|
6547
7051
|
case "end":
|
|
6548
7052
|
return _context15.stop();
|
|
6549
7053
|
}
|
|
6550
7054
|
}
|
|
6551
|
-
}, _callee15, this);
|
|
7055
|
+
}, _callee15, this, [[8, 14]]);
|
|
6552
7056
|
}));
|
|
6553
7057
|
|
|
6554
7058
|
function connect() {
|
|
@@ -6557,9 +7061,15 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6557
7061
|
|
|
6558
7062
|
return connect;
|
|
6559
7063
|
}()
|
|
7064
|
+
/**
|
|
7065
|
+
* Check the connectivity with server for warmup purpose.
|
|
7066
|
+
*
|
|
7067
|
+
* @private
|
|
7068
|
+
*/
|
|
7069
|
+
|
|
6560
7070
|
}, {
|
|
6561
|
-
key: "
|
|
6562
|
-
value: function
|
|
7071
|
+
key: "_sayHi",
|
|
7072
|
+
value: function _sayHi() {
|
|
6563
7073
|
var _this4 = this;
|
|
6564
7074
|
|
|
6565
7075
|
var client_request_id = randomId();
|
|
@@ -6568,12 +7078,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6568
7078
|
'x-client-request-id': client_request_id
|
|
6569
7079
|
}
|
|
6570
7080
|
};
|
|
6571
|
-
this.doAxiosRequest('get', this.baseURL + '/
|
|
6572
|
-
_this4.
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
7081
|
+
this.doAxiosRequest('get', this.baseURL + '/hi', null, opts).catch(function (e) {
|
|
7082
|
+
if (_this4.options.enableInsights) {
|
|
7083
|
+
postInsights('http_hi_failed', {
|
|
7084
|
+
api_key: _this4.key,
|
|
7085
|
+
err: e,
|
|
7086
|
+
client_request_id: client_request_id
|
|
7087
|
+
});
|
|
7088
|
+
}
|
|
6577
7089
|
});
|
|
6578
7090
|
}
|
|
6579
7091
|
/**
|
|
@@ -6636,7 +7148,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6636
7148
|
}, _callee16, this);
|
|
6637
7149
|
}));
|
|
6638
7150
|
|
|
6639
|
-
function queryUsers(
|
|
7151
|
+
function queryUsers(_x16) {
|
|
6640
7152
|
return _queryUsers.apply(this, arguments);
|
|
6641
7153
|
}
|
|
6642
7154
|
|
|
@@ -6855,7 +7367,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6855
7367
|
}, _callee19, this);
|
|
6856
7368
|
}));
|
|
6857
7369
|
|
|
6858
|
-
function queryChannels(
|
|
7370
|
+
function queryChannels(_x17) {
|
|
6859
7371
|
return _queryChannels.apply(this, arguments);
|
|
6860
7372
|
}
|
|
6861
7373
|
|
|
@@ -6941,7 +7453,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6941
7453
|
}, _callee20, this);
|
|
6942
7454
|
}));
|
|
6943
7455
|
|
|
6944
|
-
function search(
|
|
7456
|
+
function search(_x18, _x19) {
|
|
6945
7457
|
return _search.apply(this, arguments);
|
|
6946
7458
|
}
|
|
6947
7459
|
|
|
@@ -6959,7 +7471,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6959
7471
|
}, {
|
|
6960
7472
|
key: "setLocalDevice",
|
|
6961
7473
|
value: function setLocalDevice(device) {
|
|
6962
|
-
if (this.wsConnection) {
|
|
7474
|
+
if (this.wsConnection || this.wsFallback) {
|
|
6963
7475
|
throw new Error('you can only set device before opening a websocket connection');
|
|
6964
7476
|
}
|
|
6965
7477
|
|
|
@@ -7001,7 +7513,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7001
7513
|
}, _callee21, this);
|
|
7002
7514
|
}));
|
|
7003
7515
|
|
|
7004
|
-
function addDevice(_x21, _x22
|
|
7516
|
+
function addDevice(_x20, _x21, _x22) {
|
|
7005
7517
|
return _addDevice.apply(this, arguments);
|
|
7006
7518
|
}
|
|
7007
7519
|
|
|
@@ -7039,7 +7551,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7039
7551
|
}, _callee22, this);
|
|
7040
7552
|
}));
|
|
7041
7553
|
|
|
7042
|
-
function getDevices(
|
|
7554
|
+
function getDevices(_x23) {
|
|
7043
7555
|
return _getDevices.apply(this, arguments);
|
|
7044
7556
|
}
|
|
7045
7557
|
|
|
@@ -7079,7 +7591,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7079
7591
|
}, _callee23, this);
|
|
7080
7592
|
}));
|
|
7081
7593
|
|
|
7082
|
-
function removeDevice(
|
|
7594
|
+
function removeDevice(_x24, _x25) {
|
|
7083
7595
|
return _removeDevice.apply(this, arguments);
|
|
7084
7596
|
}
|
|
7085
7597
|
|
|
@@ -7120,7 +7632,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7120
7632
|
}, _callee24, this);
|
|
7121
7633
|
}));
|
|
7122
7634
|
|
|
7123
|
-
function getRateLimits(
|
|
7635
|
+
function getRateLimits(_x26) {
|
|
7124
7636
|
return _getRateLimits.apply(this, arguments);
|
|
7125
7637
|
}
|
|
7126
7638
|
|
|
@@ -7221,7 +7733,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7221
7733
|
}, _callee25, this);
|
|
7222
7734
|
}));
|
|
7223
7735
|
|
|
7224
|
-
function partialUpdateUser(
|
|
7736
|
+
function partialUpdateUser(_x27) {
|
|
7225
7737
|
return _partialUpdateUser.apply(this, arguments);
|
|
7226
7738
|
}
|
|
7227
7739
|
|
|
@@ -7307,7 +7819,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7307
7819
|
}, _callee26, this, [[2, 13, 16, 19]]);
|
|
7308
7820
|
}));
|
|
7309
7821
|
|
|
7310
|
-
function upsertUsers(
|
|
7822
|
+
function upsertUsers(_x28) {
|
|
7311
7823
|
return _upsertUsers.apply(this, arguments);
|
|
7312
7824
|
}
|
|
7313
7825
|
|
|
@@ -7420,7 +7932,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7420
7932
|
}, _callee27, this, [[1, 11, 14, 17]]);
|
|
7421
7933
|
}));
|
|
7422
7934
|
|
|
7423
|
-
function partialUpdateUsers(
|
|
7935
|
+
function partialUpdateUsers(_x29) {
|
|
7424
7936
|
return _partialUpdateUsers.apply(this, arguments);
|
|
7425
7937
|
}
|
|
7426
7938
|
|
|
@@ -7448,7 +7960,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7448
7960
|
}, _callee28, this);
|
|
7449
7961
|
}));
|
|
7450
7962
|
|
|
7451
|
-
function deleteUser(
|
|
7963
|
+
function deleteUser(_x30, _x31) {
|
|
7452
7964
|
return _deleteUser.apply(this, arguments);
|
|
7453
7965
|
}
|
|
7454
7966
|
|
|
@@ -7476,7 +7988,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7476
7988
|
}, _callee29, this);
|
|
7477
7989
|
}));
|
|
7478
7990
|
|
|
7479
|
-
function reactivateUser(
|
|
7991
|
+
function reactivateUser(_x32, _x33) {
|
|
7480
7992
|
return _reactivateUser.apply(this, arguments);
|
|
7481
7993
|
}
|
|
7482
7994
|
|
|
@@ -7504,7 +8016,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7504
8016
|
}, _callee30, this);
|
|
7505
8017
|
}));
|
|
7506
8018
|
|
|
7507
|
-
function deactivateUser(
|
|
8019
|
+
function deactivateUser(_x34, _x35) {
|
|
7508
8020
|
return _deactivateUser.apply(this, arguments);
|
|
7509
8021
|
}
|
|
7510
8022
|
|
|
@@ -7532,7 +8044,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7532
8044
|
}, _callee31, this);
|
|
7533
8045
|
}));
|
|
7534
8046
|
|
|
7535
|
-
function exportUser(
|
|
8047
|
+
function exportUser(_x36, _x37) {
|
|
7536
8048
|
return _exportUser.apply(this, arguments);
|
|
7537
8049
|
}
|
|
7538
8050
|
|
|
@@ -7553,27 +8065,15 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7553
8065
|
while (1) {
|
|
7554
8066
|
switch (_context32.prev = _context32.next) {
|
|
7555
8067
|
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;
|
|
8068
|
+
_context32.next = 2;
|
|
7569
8069
|
return this.post(this.baseURL + '/moderation/ban', _objectSpread({
|
|
7570
8070
|
target_user_id: targetUserID
|
|
7571
8071
|
}, options));
|
|
7572
8072
|
|
|
7573
|
-
case
|
|
8073
|
+
case 2:
|
|
7574
8074
|
return _context32.abrupt("return", _context32.sent);
|
|
7575
8075
|
|
|
7576
|
-
case
|
|
8076
|
+
case 3:
|
|
7577
8077
|
case "end":
|
|
7578
8078
|
return _context32.stop();
|
|
7579
8079
|
}
|
|
@@ -7581,7 +8081,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7581
8081
|
}, _callee32, this);
|
|
7582
8082
|
}));
|
|
7583
8083
|
|
|
7584
|
-
function banUser(
|
|
8084
|
+
function banUser(_x38, _x39) {
|
|
7585
8085
|
return _banUser.apply(this, arguments);
|
|
7586
8086
|
}
|
|
7587
8087
|
|
|
@@ -7618,7 +8118,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7618
8118
|
}, _callee33, this);
|
|
7619
8119
|
}));
|
|
7620
8120
|
|
|
7621
|
-
function unbanUser(
|
|
8121
|
+
function unbanUser(_x40, _x41) {
|
|
7622
8122
|
return _unbanUser.apply(this, arguments);
|
|
7623
8123
|
}
|
|
7624
8124
|
|
|
@@ -7655,7 +8155,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7655
8155
|
}, _callee34, this);
|
|
7656
8156
|
}));
|
|
7657
8157
|
|
|
7658
|
-
function shadowBan(
|
|
8158
|
+
function shadowBan(_x42, _x43) {
|
|
7659
8159
|
return _shadowBan.apply(this, arguments);
|
|
7660
8160
|
}
|
|
7661
8161
|
|
|
@@ -7692,7 +8192,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7692
8192
|
}, _callee35, this);
|
|
7693
8193
|
}));
|
|
7694
8194
|
|
|
7695
|
-
function removeShadowBan(
|
|
8195
|
+
function removeShadowBan(_x44, _x45) {
|
|
7696
8196
|
return _removeShadowBan.apply(this, arguments);
|
|
7697
8197
|
}
|
|
7698
8198
|
|
|
@@ -7735,7 +8235,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7735
8235
|
}, _callee36, this);
|
|
7736
8236
|
}));
|
|
7737
8237
|
|
|
7738
|
-
function muteUser(
|
|
8238
|
+
function muteUser(_x46, _x47) {
|
|
7739
8239
|
return _muteUser.apply(this, arguments);
|
|
7740
8240
|
}
|
|
7741
8241
|
|
|
@@ -7774,7 +8274,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7774
8274
|
}, _callee37, this);
|
|
7775
8275
|
}));
|
|
7776
8276
|
|
|
7777
|
-
function unmuteUser(
|
|
8277
|
+
function unmuteUser(_x48, _x49) {
|
|
7778
8278
|
return _unmuteUser.apply(this, arguments);
|
|
7779
8279
|
}
|
|
7780
8280
|
|
|
@@ -7833,7 +8333,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7833
8333
|
}, _callee38, this);
|
|
7834
8334
|
}));
|
|
7835
8335
|
|
|
7836
|
-
function flagMessage(
|
|
8336
|
+
function flagMessage(_x50) {
|
|
7837
8337
|
return _flagMessage.apply(this, arguments);
|
|
7838
8338
|
}
|
|
7839
8339
|
|
|
@@ -7873,7 +8373,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7873
8373
|
}, _callee39, this);
|
|
7874
8374
|
}));
|
|
7875
8375
|
|
|
7876
|
-
function flagUser(
|
|
8376
|
+
function flagUser(_x51) {
|
|
7877
8377
|
return _flagUser.apply(this, arguments);
|
|
7878
8378
|
}
|
|
7879
8379
|
|
|
@@ -7913,7 +8413,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7913
8413
|
}, _callee40, this);
|
|
7914
8414
|
}));
|
|
7915
8415
|
|
|
7916
|
-
function unflagMessage(
|
|
8416
|
+
function unflagMessage(_x52) {
|
|
7917
8417
|
return _unflagMessage.apply(this, arguments);
|
|
7918
8418
|
}
|
|
7919
8419
|
|
|
@@ -7953,7 +8453,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7953
8453
|
}, _callee41, this);
|
|
7954
8454
|
}));
|
|
7955
8455
|
|
|
7956
|
-
function unflagUser(
|
|
8456
|
+
function unflagUser(_x53) {
|
|
7957
8457
|
return _unflagUser.apply(this, arguments);
|
|
7958
8458
|
}
|
|
7959
8459
|
|
|
@@ -8092,7 +8592,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8092
8592
|
}, _callee43, this);
|
|
8093
8593
|
}));
|
|
8094
8594
|
|
|
8095
|
-
function translateMessage(
|
|
8595
|
+
function translateMessage(_x54, _x55) {
|
|
8096
8596
|
return _translateMessage.apply(this, arguments);
|
|
8097
8597
|
}
|
|
8098
8598
|
|
|
@@ -8208,7 +8708,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8208
8708
|
case 2:
|
|
8209
8709
|
clonedMessage = _extends__default['default']({}, message);
|
|
8210
8710
|
delete clonedMessage.id;
|
|
8211
|
-
reservedMessageFields = ['command', 'created_at', 'html', 'latest_reactions', 'own_reactions', 'reaction_counts', 'reply_count', 'type', 'updated_at', 'user', '__html'];
|
|
8711
|
+
reservedMessageFields = ['command', 'created_at', 'html', 'latest_reactions', 'own_reactions', 'quoted_message', 'reaction_counts', 'reply_count', 'type', 'updated_at', 'user', '__html'];
|
|
8212
8712
|
reservedMessageFields.forEach(function (item) {
|
|
8213
8713
|
if (clonedMessage[item] != null) {
|
|
8214
8714
|
delete clonedMessage[item];
|
|
@@ -8252,7 +8752,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8252
8752
|
}, _callee44, this);
|
|
8253
8753
|
}));
|
|
8254
8754
|
|
|
8255
|
-
function updateMessage(_x57, _x58
|
|
8755
|
+
function updateMessage(_x56, _x57, _x58) {
|
|
8256
8756
|
return _updateMessage.apply(this, arguments);
|
|
8257
8757
|
}
|
|
8258
8758
|
|
|
@@ -8313,7 +8813,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8313
8813
|
}, _callee45, this);
|
|
8314
8814
|
}));
|
|
8315
8815
|
|
|
8316
|
-
function partialUpdateMessage(_x60, _x61, _x62
|
|
8816
|
+
function partialUpdateMessage(_x59, _x60, _x61, _x62) {
|
|
8317
8817
|
return _partialUpdateMessage.apply(this, arguments);
|
|
8318
8818
|
}
|
|
8319
8819
|
|
|
@@ -8350,7 +8850,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8350
8850
|
}, _callee46, this);
|
|
8351
8851
|
}));
|
|
8352
8852
|
|
|
8353
|
-
function deleteMessage(
|
|
8853
|
+
function deleteMessage(_x63, _x64) {
|
|
8354
8854
|
return _deleteMessage.apply(this, arguments);
|
|
8355
8855
|
}
|
|
8356
8856
|
|
|
@@ -8378,7 +8878,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8378
8878
|
}, _callee47, this);
|
|
8379
8879
|
}));
|
|
8380
8880
|
|
|
8381
|
-
function getMessage(
|
|
8881
|
+
function getMessage(_x65) {
|
|
8382
8882
|
return _getMessage.apply(this, arguments);
|
|
8383
8883
|
}
|
|
8384
8884
|
|
|
@@ -8387,7 +8887,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8387
8887
|
}, {
|
|
8388
8888
|
key: "getUserAgent",
|
|
8389
8889
|
value: function getUserAgent() {
|
|
8390
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "
|
|
8890
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "5.0.0");
|
|
8391
8891
|
}
|
|
8392
8892
|
}, {
|
|
8393
8893
|
key: "setUserAgent",
|
|
@@ -8401,7 +8901,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8401
8901
|
}, {
|
|
8402
8902
|
key: "_enrichAxiosOptions",
|
|
8403
8903
|
value: function _enrichAxiosOptions() {
|
|
8404
|
-
var _options$headers
|
|
8904
|
+
var _options$headers;
|
|
8405
8905
|
|
|
8406
8906
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
8407
8907
|
params: {},
|
|
@@ -8411,10 +8911,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8411
8911
|
|
|
8412
8912
|
var token = this._getToken();
|
|
8413
8913
|
|
|
8914
|
+
var authorization = token ? {
|
|
8915
|
+
Authorization: token
|
|
8916
|
+
} : undefined;
|
|
8917
|
+
|
|
8414
8918
|
if (!((_options$headers = options.headers) !== null && _options$headers !== void 0 && _options$headers['x-client-request-id'])) {
|
|
8415
|
-
options.headers = {
|
|
8919
|
+
options.headers = _objectSpread(_objectSpread({}, options.headers), {}, {
|
|
8416
8920
|
'x-client-request-id': randomId()
|
|
8417
|
-
};
|
|
8921
|
+
});
|
|
8418
8922
|
}
|
|
8419
8923
|
|
|
8420
8924
|
return _objectSpread({
|
|
@@ -8422,10 +8926,9 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8422
8926
|
user_id: this.userID
|
|
8423
8927
|
}, options.params), {}, {
|
|
8424
8928
|
api_key: this.key,
|
|
8425
|
-
connection_id:
|
|
8929
|
+
connection_id: this._getConnectionID()
|
|
8426
8930
|
}),
|
|
8427
|
-
headers: _objectSpread({
|
|
8428
|
-
Authorization: token,
|
|
8931
|
+
headers: _objectSpread(_objectSpread({}, authorization), {}, {
|
|
8429
8932
|
'stream-auth-type': this.getAuthType(),
|
|
8430
8933
|
'X-Stream-Client': this.getUserAgent()
|
|
8431
8934
|
}, options.headers)
|
|
@@ -8455,6 +8958,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8455
8958
|
}
|
|
8456
8959
|
}, 500);
|
|
8457
8960
|
}
|
|
8961
|
+
/**
|
|
8962
|
+
* encode ws url payload
|
|
8963
|
+
* @private
|
|
8964
|
+
* @returns json string
|
|
8965
|
+
*/
|
|
8966
|
+
|
|
8458
8967
|
}, {
|
|
8459
8968
|
key: "verifyWebhook",
|
|
8460
8969
|
value: function verifyWebhook(requestBody, xSignature) {
|
|
@@ -8595,7 +9104,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8595
9104
|
}, _callee48, this);
|
|
8596
9105
|
}));
|
|
8597
9106
|
|
|
8598
|
-
function sendUserCustomEvent(
|
|
9107
|
+
function sendUserCustomEvent(_x66, _x67) {
|
|
8599
9108
|
return _sendUserCustomEvent.apply(this, arguments);
|
|
8600
9109
|
}
|
|
8601
9110
|
|
|
@@ -8683,7 +9192,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8683
9192
|
}, _callee49, this);
|
|
8684
9193
|
}));
|
|
8685
9194
|
|
|
8686
|
-
function createSegment(
|
|
9195
|
+
function createSegment(_x68) {
|
|
8687
9196
|
return _createSegment.apply(this, arguments);
|
|
8688
9197
|
}
|
|
8689
9198
|
|
|
@@ -8723,7 +9232,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8723
9232
|
}, _callee50, this);
|
|
8724
9233
|
}));
|
|
8725
9234
|
|
|
8726
|
-
function getSegment(
|
|
9235
|
+
function getSegment(_x69) {
|
|
8727
9236
|
return _getSegment.apply(this, arguments);
|
|
8728
9237
|
}
|
|
8729
9238
|
|
|
@@ -8762,7 +9271,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8762
9271
|
}, _callee51, this);
|
|
8763
9272
|
}));
|
|
8764
9273
|
|
|
8765
|
-
function listSegments(
|
|
9274
|
+
function listSegments(_x70) {
|
|
8766
9275
|
return _listSegments.apply(this, arguments);
|
|
8767
9276
|
}
|
|
8768
9277
|
|
|
@@ -8805,7 +9314,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8805
9314
|
}, _callee52, this);
|
|
8806
9315
|
}));
|
|
8807
9316
|
|
|
8808
|
-
function updateSegment(
|
|
9317
|
+
function updateSegment(_x71, _x72) {
|
|
8809
9318
|
return _updateSegment.apply(this, arguments);
|
|
8810
9319
|
}
|
|
8811
9320
|
|
|
@@ -8837,7 +9346,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8837
9346
|
}, _callee53, this);
|
|
8838
9347
|
}));
|
|
8839
9348
|
|
|
8840
|
-
function deleteSegment(
|
|
9349
|
+
function deleteSegment(_x73) {
|
|
8841
9350
|
return _deleteSegment.apply(this, arguments);
|
|
8842
9351
|
}
|
|
8843
9352
|
|
|
@@ -8879,7 +9388,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8879
9388
|
}, _callee54, this);
|
|
8880
9389
|
}));
|
|
8881
9390
|
|
|
8882
|
-
function createCampaign(
|
|
9391
|
+
function createCampaign(_x74) {
|
|
8883
9392
|
return _createCampaign.apply(this, arguments);
|
|
8884
9393
|
}
|
|
8885
9394
|
|
|
@@ -8919,7 +9428,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8919
9428
|
}, _callee55, this);
|
|
8920
9429
|
}));
|
|
8921
9430
|
|
|
8922
|
-
function getCampaign(
|
|
9431
|
+
function getCampaign(_x75) {
|
|
8923
9432
|
return _getCampaign.apply(this, arguments);
|
|
8924
9433
|
}
|
|
8925
9434
|
|
|
@@ -8958,7 +9467,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8958
9467
|
}, _callee56, this);
|
|
8959
9468
|
}));
|
|
8960
9469
|
|
|
8961
|
-
function listCampaigns(
|
|
9470
|
+
function listCampaigns(_x76) {
|
|
8962
9471
|
return _listCampaigns.apply(this, arguments);
|
|
8963
9472
|
}
|
|
8964
9473
|
|
|
@@ -9001,7 +9510,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9001
9510
|
}, _callee57, this);
|
|
9002
9511
|
}));
|
|
9003
9512
|
|
|
9004
|
-
function updateCampaign(
|
|
9513
|
+
function updateCampaign(_x77, _x78) {
|
|
9005
9514
|
return _updateCampaign.apply(this, arguments);
|
|
9006
9515
|
}
|
|
9007
9516
|
|
|
@@ -9033,7 +9542,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9033
9542
|
}, _callee58, this);
|
|
9034
9543
|
}));
|
|
9035
9544
|
|
|
9036
|
-
function deleteCampaign(
|
|
9545
|
+
function deleteCampaign(_x79) {
|
|
9037
9546
|
return _deleteCampaign.apply(this, arguments);
|
|
9038
9547
|
}
|
|
9039
9548
|
|
|
@@ -9077,7 +9586,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9077
9586
|
}, _callee59, this);
|
|
9078
9587
|
}));
|
|
9079
9588
|
|
|
9080
|
-
function scheduleCampaign(
|
|
9589
|
+
function scheduleCampaign(_x80, _x81) {
|
|
9081
9590
|
return _scheduleCampaign.apply(this, arguments);
|
|
9082
9591
|
}
|
|
9083
9592
|
|
|
@@ -9117,7 +9626,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9117
9626
|
}, _callee60, this);
|
|
9118
9627
|
}));
|
|
9119
9628
|
|
|
9120
|
-
function stopCampaign(
|
|
9629
|
+
function stopCampaign(_x82) {
|
|
9121
9630
|
return _stopCampaign.apply(this, arguments);
|
|
9122
9631
|
}
|
|
9123
9632
|
|
|
@@ -9157,7 +9666,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9157
9666
|
}, _callee61, this);
|
|
9158
9667
|
}));
|
|
9159
9668
|
|
|
9160
|
-
function resumeCampaign(
|
|
9669
|
+
function resumeCampaign(_x83) {
|
|
9161
9670
|
return _resumeCampaign.apply(this, arguments);
|
|
9162
9671
|
}
|
|
9163
9672
|
|
|
@@ -9200,7 +9709,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9200
9709
|
}, _callee62, this);
|
|
9201
9710
|
}));
|
|
9202
9711
|
|
|
9203
|
-
function testCampaign(
|
|
9712
|
+
function testCampaign(_x84, _x85) {
|
|
9204
9713
|
return _testCampaign.apply(this, arguments);
|
|
9205
9714
|
}
|
|
9206
9715
|
|
|
@@ -9233,7 +9742,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9233
9742
|
}, _callee63, this);
|
|
9234
9743
|
}));
|
|
9235
9744
|
|
|
9236
|
-
function enrichURL(
|
|
9745
|
+
function enrichURL(_x86) {
|
|
9237
9746
|
return _enrichURL.apply(this, arguments);
|
|
9238
9747
|
}
|
|
9239
9748
|
|
|
@@ -9265,7 +9774,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9265
9774
|
}, _callee64, this);
|
|
9266
9775
|
}));
|
|
9267
9776
|
|
|
9268
|
-
function getTask(
|
|
9777
|
+
function getTask(_x87) {
|
|
9269
9778
|
return _getTask.apply(this, arguments);
|
|
9270
9779
|
}
|
|
9271
9780
|
|
|
@@ -9307,15 +9816,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9307
9816
|
}, _callee65, this);
|
|
9308
9817
|
}));
|
|
9309
9818
|
|
|
9310
|
-
function deleteChannels(
|
|
9819
|
+
function deleteChannels(_x88) {
|
|
9311
9820
|
return _deleteChannels.apply(this, arguments);
|
|
9312
9821
|
}
|
|
9313
9822
|
|
|
9314
9823
|
return deleteChannels;
|
|
9315
9824
|
}()
|
|
9316
|
-
}, {
|
|
9317
|
-
key: "deleteUsers",
|
|
9318
|
-
value:
|
|
9319
9825
|
/**
|
|
9320
9826
|
* deleteUsers - Batch Delete Users
|
|
9321
9827
|
*
|
|
@@ -9324,7 +9830,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9324
9830
|
*
|
|
9325
9831
|
* @return {APIResponse} A task ID
|
|
9326
9832
|
*/
|
|
9327
|
-
|
|
9833
|
+
|
|
9834
|
+
}, {
|
|
9835
|
+
key: "deleteUsers",
|
|
9836
|
+
value: function () {
|
|
9328
9837
|
var _deleteUsers = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee66(user_ids, options) {
|
|
9329
9838
|
return _regeneratorRuntime__default['default'].wrap(function _callee66$(_context66) {
|
|
9330
9839
|
while (1) {
|
|
@@ -9370,7 +9879,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9370
9879
|
}, _callee66, this);
|
|
9371
9880
|
}));
|
|
9372
9881
|
|
|
9373
|
-
function deleteUsers(
|
|
9882
|
+
function deleteUsers(_x89, _x90) {
|
|
9374
9883
|
return _deleteUsers.apply(this, arguments);
|
|
9375
9884
|
}
|
|
9376
9885
|
|
|
@@ -9502,4 +10011,5 @@ exports.encodeBase64 = encodeBase64;
|
|
|
9502
10011
|
exports.isOwnUser = isOwnUser;
|
|
9503
10012
|
exports.isValidEventType = isValidEventType;
|
|
9504
10013
|
exports.logChatPromiseExecution = logChatPromiseExecution;
|
|
10014
|
+
exports.postInsights = postInsights;
|
|
9505
10015
|
//# sourceMappingURL=index.js.map
|