stream-chat 4.4.3-dev.1 → 4.5.0-beta.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 +1239 -716
- 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 +1239 -715
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +1239 -716
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1239 -715
- 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 -49
- 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 +42 -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 +95 -80
- 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 +307 -708
- 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 +270 -504
- package/src/utils.ts +49 -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,45 @@ 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
|
|
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
|
+
if (!nav) return true;
|
|
981
|
+
return nav.onLine;
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* listenForConnectionChanges - Adds an event listener fired on browser going online or offline
|
|
985
|
+
*/
|
|
986
|
+
|
|
987
|
+
function addConnectionEventListeners(cb) {
|
|
988
|
+
if (typeof window !== 'undefined' && window.addEventListener) {
|
|
989
|
+
window.addEventListener('offline', cb);
|
|
990
|
+
window.addEventListener('online', cb);
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
function removeConnectionEventListeners(cb) {
|
|
994
|
+
if (typeof window !== 'undefined' && window.removeEventListener) {
|
|
995
|
+
window.removeEventListener('offline', cb);
|
|
996
|
+
window.removeEventListener('online', cb);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
966
999
|
|
|
967
1000
|
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
1001
|
|
|
@@ -970,9 +1003,9 @@ function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o
|
|
|
970
1003
|
|
|
971
1004
|
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
1005
|
|
|
973
|
-
function ownKeys$
|
|
1006
|
+
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
1007
|
|
|
975
|
-
function _objectSpread$
|
|
1008
|
+
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
1009
|
|
|
977
1010
|
/**
|
|
978
1011
|
* Channel - The Channel class manages it's own state.
|
|
@@ -1092,7 +1125,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1092
1125
|
|
|
1093
1126
|
this.data = data; // this._data is used for the requests...
|
|
1094
1127
|
|
|
1095
|
-
this._data = _objectSpread$
|
|
1128
|
+
this._data = _objectSpread$5({}, data);
|
|
1096
1129
|
this.cid = "".concat(type, ":").concat(id);
|
|
1097
1130
|
this.listeners = {}; // perhaps the state variable should be private
|
|
1098
1131
|
|
|
@@ -1150,7 +1183,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1150
1183
|
switch (_context2.prev = _context2.next) {
|
|
1151
1184
|
case 0:
|
|
1152
1185
|
_context2.next = 2;
|
|
1153
|
-
return this.getClient().post(this._channelURL() + '/message', _objectSpread$
|
|
1186
|
+
return this.getClient().post(this._channelURL() + '/message', _objectSpread$5({
|
|
1154
1187
|
message: message
|
|
1155
1188
|
}, options));
|
|
1156
1189
|
|
|
@@ -1269,7 +1302,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1269
1302
|
|
|
1270
1303
|
case 3:
|
|
1271
1304
|
// Return a list of channels
|
|
1272
|
-
payload = _objectSpread$
|
|
1305
|
+
payload = _objectSpread$5(_objectSpread$5({
|
|
1273
1306
|
filter_conditions: {
|
|
1274
1307
|
cid: this.cid
|
|
1275
1308
|
}
|
|
@@ -1366,7 +1399,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1366
1399
|
|
|
1367
1400
|
_context5.next = 6;
|
|
1368
1401
|
return this.getClient().get(this.getClient().baseURL + '/members', {
|
|
1369
|
-
payload: _objectSpread$
|
|
1402
|
+
payload: _objectSpread$5({
|
|
1370
1403
|
type: type,
|
|
1371
1404
|
id: id,
|
|
1372
1405
|
members: members,
|
|
@@ -1427,7 +1460,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1427
1460
|
|
|
1428
1461
|
case 4:
|
|
1429
1462
|
_context6.next = 6;
|
|
1430
|
-
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(messageID, "/reaction"), _objectSpread$
|
|
1463
|
+
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(messageID, "/reaction"), _objectSpread$5({
|
|
1431
1464
|
reaction: reaction
|
|
1432
1465
|
}, options));
|
|
1433
1466
|
|
|
@@ -1482,7 +1515,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1482
1515
|
*
|
|
1483
1516
|
* @param {ChannelData<ChannelType>} channelData The object to update the custom properties of this channel with
|
|
1484
1517
|
* @param {Message<AttachmentType, MessageType, UserType>} [updateMessage] Optional message object for channel members notification
|
|
1485
|
-
* @param {
|
|
1518
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1486
1519
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1487
1520
|
*/
|
|
1488
1521
|
|
|
@@ -1508,7 +1541,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1508
1541
|
delete channelData[key];
|
|
1509
1542
|
});
|
|
1510
1543
|
_context7.next = 7;
|
|
1511
|
-
return this._update(_objectSpread$
|
|
1544
|
+
return this._update(_objectSpread$5({
|
|
1512
1545
|
message: updateMessage,
|
|
1513
1546
|
data: channelData
|
|
1514
1547
|
}, options));
|
|
@@ -1681,25 +1714,28 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1681
1714
|
}()
|
|
1682
1715
|
/**
|
|
1683
1716
|
* truncate - Removes all messages from the channel
|
|
1684
|
-
*
|
|
1685
|
-
* @return {Promise<TruncateChannelAPIResponse<ChannelType, CommandType, UserType>>} The server response
|
|
1717
|
+
* @param {TruncateOptions<AttachmentType, MessageType, UserType>} [options] Defines truncation options
|
|
1718
|
+
* @return {Promise<TruncateChannelAPIResponse<ChannelType, CommandType, UserType, MessageType, ReactionType>>} The server response
|
|
1686
1719
|
*/
|
|
1687
1720
|
|
|
1688
1721
|
}, {
|
|
1689
1722
|
key: "truncate",
|
|
1690
1723
|
value: function () {
|
|
1691
1724
|
var _truncate = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee12() {
|
|
1725
|
+
var options,
|
|
1726
|
+
_args12 = arguments;
|
|
1692
1727
|
return _regeneratorRuntime__default['default'].wrap(function _callee12$(_context12) {
|
|
1693
1728
|
while (1) {
|
|
1694
1729
|
switch (_context12.prev = _context12.next) {
|
|
1695
1730
|
case 0:
|
|
1696
|
-
|
|
1697
|
-
|
|
1731
|
+
options = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
|
|
1732
|
+
_context12.next = 3;
|
|
1733
|
+
return this.getClient().post(this._channelURL() + '/truncate', options);
|
|
1698
1734
|
|
|
1699
|
-
case
|
|
1735
|
+
case 3:
|
|
1700
1736
|
return _context12.abrupt("return", _context12.sent);
|
|
1701
1737
|
|
|
1702
|
-
case
|
|
1738
|
+
case 4:
|
|
1703
1739
|
case "end":
|
|
1704
1740
|
return _context12.stop();
|
|
1705
1741
|
}
|
|
@@ -1733,7 +1769,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1733
1769
|
case 0:
|
|
1734
1770
|
options = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
|
|
1735
1771
|
_context13.next = 3;
|
|
1736
|
-
return this._update(_objectSpread$
|
|
1772
|
+
return this._update(_objectSpread$5({
|
|
1737
1773
|
accept_invite: true
|
|
1738
1774
|
}, options));
|
|
1739
1775
|
|
|
@@ -1774,7 +1810,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1774
1810
|
case 0:
|
|
1775
1811
|
options = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
|
|
1776
1812
|
_context14.next = 3;
|
|
1777
|
-
return this._update(_objectSpread$
|
|
1813
|
+
return this._update(_objectSpread$5({
|
|
1778
1814
|
reject_invite: true
|
|
1779
1815
|
}, options));
|
|
1780
1816
|
|
|
@@ -1800,6 +1836,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1800
1836
|
*
|
|
1801
1837
|
* @param {{user_id: string, channel_role?: Role}[]} members An array of members to add to the channel
|
|
1802
1838
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1839
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1803
1840
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1804
1841
|
*/
|
|
1805
1842
|
|
|
@@ -1807,20 +1844,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1807
1844
|
key: "addMembers",
|
|
1808
1845
|
value: function () {
|
|
1809
1846
|
var _addMembers = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee15(members, message) {
|
|
1847
|
+
var options,
|
|
1848
|
+
_args15 = arguments;
|
|
1810
1849
|
return _regeneratorRuntime__default['default'].wrap(function _callee15$(_context15) {
|
|
1811
1850
|
while (1) {
|
|
1812
1851
|
switch (_context15.prev = _context15.next) {
|
|
1813
1852
|
case 0:
|
|
1814
|
-
|
|
1815
|
-
|
|
1853
|
+
options = _args15.length > 2 && _args15[2] !== undefined ? _args15[2] : {};
|
|
1854
|
+
_context15.next = 3;
|
|
1855
|
+
return this._update(_objectSpread$5({
|
|
1816
1856
|
add_members: members,
|
|
1817
1857
|
message: message
|
|
1818
|
-
});
|
|
1858
|
+
}, options));
|
|
1819
1859
|
|
|
1820
|
-
case
|
|
1860
|
+
case 3:
|
|
1821
1861
|
return _context15.abrupt("return", _context15.sent);
|
|
1822
1862
|
|
|
1823
|
-
case
|
|
1863
|
+
case 4:
|
|
1824
1864
|
case "end":
|
|
1825
1865
|
return _context15.stop();
|
|
1826
1866
|
}
|
|
@@ -1839,6 +1879,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1839
1879
|
*
|
|
1840
1880
|
* @param {string[]} members An array of member identifiers
|
|
1841
1881
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1882
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1842
1883
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1843
1884
|
*/
|
|
1844
1885
|
|
|
@@ -1846,20 +1887,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1846
1887
|
key: "addModerators",
|
|
1847
1888
|
value: function () {
|
|
1848
1889
|
var _addModerators = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee16(members, message) {
|
|
1890
|
+
var options,
|
|
1891
|
+
_args16 = arguments;
|
|
1849
1892
|
return _regeneratorRuntime__default['default'].wrap(function _callee16$(_context16) {
|
|
1850
1893
|
while (1) {
|
|
1851
1894
|
switch (_context16.prev = _context16.next) {
|
|
1852
1895
|
case 0:
|
|
1853
|
-
|
|
1854
|
-
|
|
1896
|
+
options = _args16.length > 2 && _args16[2] !== undefined ? _args16[2] : {};
|
|
1897
|
+
_context16.next = 3;
|
|
1898
|
+
return this._update(_objectSpread$5({
|
|
1855
1899
|
add_moderators: members,
|
|
1856
1900
|
message: message
|
|
1857
|
-
});
|
|
1901
|
+
}, options));
|
|
1858
1902
|
|
|
1859
|
-
case
|
|
1903
|
+
case 3:
|
|
1860
1904
|
return _context16.abrupt("return", _context16.sent);
|
|
1861
1905
|
|
|
1862
|
-
case
|
|
1906
|
+
case 4:
|
|
1863
1907
|
case "end":
|
|
1864
1908
|
return _context16.stop();
|
|
1865
1909
|
}
|
|
@@ -1878,6 +1922,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1878
1922
|
*
|
|
1879
1923
|
* @param {{channel_role: Role, user_id: string}[]} roles List of role assignments
|
|
1880
1924
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1925
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1881
1926
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1882
1927
|
*/
|
|
1883
1928
|
|
|
@@ -1885,20 +1930,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1885
1930
|
key: "assignRoles",
|
|
1886
1931
|
value: function () {
|
|
1887
1932
|
var _assignRoles = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee17(roles, message) {
|
|
1933
|
+
var options,
|
|
1934
|
+
_args17 = arguments;
|
|
1888
1935
|
return _regeneratorRuntime__default['default'].wrap(function _callee17$(_context17) {
|
|
1889
1936
|
while (1) {
|
|
1890
1937
|
switch (_context17.prev = _context17.next) {
|
|
1891
1938
|
case 0:
|
|
1892
|
-
|
|
1893
|
-
|
|
1939
|
+
options = _args17.length > 2 && _args17[2] !== undefined ? _args17[2] : {};
|
|
1940
|
+
_context17.next = 3;
|
|
1941
|
+
return this._update(_objectSpread$5({
|
|
1894
1942
|
assign_roles: roles,
|
|
1895
1943
|
message: message
|
|
1896
|
-
});
|
|
1944
|
+
}, options));
|
|
1897
1945
|
|
|
1898
|
-
case
|
|
1946
|
+
case 3:
|
|
1899
1947
|
return _context17.abrupt("return", _context17.sent);
|
|
1900
1948
|
|
|
1901
|
-
case
|
|
1949
|
+
case 4:
|
|
1902
1950
|
case "end":
|
|
1903
1951
|
return _context17.stop();
|
|
1904
1952
|
}
|
|
@@ -1917,6 +1965,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1917
1965
|
*
|
|
1918
1966
|
* @param {{user_id: string, channel_role?: Role}[]} members An array of members to invite to the channel
|
|
1919
1967
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1968
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1920
1969
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1921
1970
|
*/
|
|
1922
1971
|
|
|
@@ -1924,20 +1973,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1924
1973
|
key: "inviteMembers",
|
|
1925
1974
|
value: function () {
|
|
1926
1975
|
var _inviteMembers = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee18(members, message) {
|
|
1976
|
+
var options,
|
|
1977
|
+
_args18 = arguments;
|
|
1927
1978
|
return _regeneratorRuntime__default['default'].wrap(function _callee18$(_context18) {
|
|
1928
1979
|
while (1) {
|
|
1929
1980
|
switch (_context18.prev = _context18.next) {
|
|
1930
1981
|
case 0:
|
|
1931
|
-
|
|
1932
|
-
|
|
1982
|
+
options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
|
|
1983
|
+
_context18.next = 3;
|
|
1984
|
+
return this._update(_objectSpread$5({
|
|
1933
1985
|
invites: members,
|
|
1934
1986
|
message: message
|
|
1935
|
-
});
|
|
1987
|
+
}, options));
|
|
1936
1988
|
|
|
1937
|
-
case
|
|
1989
|
+
case 3:
|
|
1938
1990
|
return _context18.abrupt("return", _context18.sent);
|
|
1939
1991
|
|
|
1940
|
-
case
|
|
1992
|
+
case 4:
|
|
1941
1993
|
case "end":
|
|
1942
1994
|
return _context18.stop();
|
|
1943
1995
|
}
|
|
@@ -1956,6 +2008,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1956
2008
|
*
|
|
1957
2009
|
* @param {string[]} members An array of member identifiers
|
|
1958
2010
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
2011
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1959
2012
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1960
2013
|
*/
|
|
1961
2014
|
|
|
@@ -1963,20 +2016,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1963
2016
|
key: "removeMembers",
|
|
1964
2017
|
value: function () {
|
|
1965
2018
|
var _removeMembers = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee19(members, message) {
|
|
2019
|
+
var options,
|
|
2020
|
+
_args19 = arguments;
|
|
1966
2021
|
return _regeneratorRuntime__default['default'].wrap(function _callee19$(_context19) {
|
|
1967
2022
|
while (1) {
|
|
1968
2023
|
switch (_context19.prev = _context19.next) {
|
|
1969
2024
|
case 0:
|
|
1970
|
-
|
|
1971
|
-
|
|
2025
|
+
options = _args19.length > 2 && _args19[2] !== undefined ? _args19[2] : {};
|
|
2026
|
+
_context19.next = 3;
|
|
2027
|
+
return this._update(_objectSpread$5({
|
|
1972
2028
|
remove_members: members,
|
|
1973
2029
|
message: message
|
|
1974
|
-
});
|
|
2030
|
+
}, options));
|
|
1975
2031
|
|
|
1976
|
-
case
|
|
2032
|
+
case 3:
|
|
1977
2033
|
return _context19.abrupt("return", _context19.sent);
|
|
1978
2034
|
|
|
1979
|
-
case
|
|
2035
|
+
case 4:
|
|
1980
2036
|
case "end":
|
|
1981
2037
|
return _context19.stop();
|
|
1982
2038
|
}
|
|
@@ -1995,6 +2051,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1995
2051
|
*
|
|
1996
2052
|
* @param {string[]} members An array of member identifiers
|
|
1997
2053
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
2054
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1998
2055
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1999
2056
|
*/
|
|
2000
2057
|
|
|
@@ -2002,20 +2059,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2002
2059
|
key: "demoteModerators",
|
|
2003
2060
|
value: function () {
|
|
2004
2061
|
var _demoteModerators = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee20(members, message) {
|
|
2062
|
+
var options,
|
|
2063
|
+
_args20 = arguments;
|
|
2005
2064
|
return _regeneratorRuntime__default['default'].wrap(function _callee20$(_context20) {
|
|
2006
2065
|
while (1) {
|
|
2007
2066
|
switch (_context20.prev = _context20.next) {
|
|
2008
2067
|
case 0:
|
|
2009
|
-
|
|
2010
|
-
|
|
2068
|
+
options = _args20.length > 2 && _args20[2] !== undefined ? _args20[2] : {};
|
|
2069
|
+
_context20.next = 3;
|
|
2070
|
+
return this._update(_objectSpread$5({
|
|
2011
2071
|
demote_moderators: members,
|
|
2012
2072
|
message: message
|
|
2013
|
-
});
|
|
2073
|
+
}, options));
|
|
2014
2074
|
|
|
2015
|
-
case
|
|
2075
|
+
case 3:
|
|
2016
2076
|
return _context20.abrupt("return", _context20.sent);
|
|
2017
2077
|
|
|
2018
|
-
case
|
|
2078
|
+
case 4:
|
|
2019
2079
|
case "end":
|
|
2020
2080
|
return _context20.stop();
|
|
2021
2081
|
}
|
|
@@ -2092,7 +2152,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2092
2152
|
case 0:
|
|
2093
2153
|
opts = _args22.length > 0 && _args22[0] !== undefined ? _args22[0] : {};
|
|
2094
2154
|
_context22.next = 3;
|
|
2095
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$
|
|
2155
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$5({
|
|
2096
2156
|
channel_cid: this.cid
|
|
2097
2157
|
}, opts));
|
|
2098
2158
|
|
|
@@ -2134,7 +2194,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2134
2194
|
case 0:
|
|
2135
2195
|
opts = _args23.length > 0 && _args23[0] !== undefined ? _args23[0] : {};
|
|
2136
2196
|
_context23.next = 3;
|
|
2137
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$
|
|
2197
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$5({
|
|
2138
2198
|
channel_cid: this.cid
|
|
2139
2199
|
}, opts));
|
|
2140
2200
|
|
|
@@ -2343,7 +2403,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2343
2403
|
|
|
2344
2404
|
case 4:
|
|
2345
2405
|
_context26.next = 6;
|
|
2346
|
-
return this.getClient().post(this._channelURL() + '/read', _objectSpread$
|
|
2406
|
+
return this.getClient().post(this._channelURL() + '/read', _objectSpread$5({}, data));
|
|
2347
2407
|
|
|
2348
2408
|
case 6:
|
|
2349
2409
|
return _context26.abrupt("return", _context26.sent);
|
|
@@ -2411,7 +2471,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2411
2471
|
defaultOptions.watch = false;
|
|
2412
2472
|
}
|
|
2413
2473
|
|
|
2414
|
-
combined = _objectSpread$
|
|
2474
|
+
combined = _objectSpread$5(_objectSpread$5({}, defaultOptions), options);
|
|
2415
2475
|
_context27.next = 7;
|
|
2416
2476
|
return this.query(combined);
|
|
2417
2477
|
|
|
@@ -2502,7 +2562,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2502
2562
|
switch (_context29.prev = _context29.next) {
|
|
2503
2563
|
case 0:
|
|
2504
2564
|
_context29.next = 2;
|
|
2505
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(parent_id, "/replies"), _objectSpread$
|
|
2565
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(parent_id, "/replies"), _objectSpread$5({}, options));
|
|
2506
2566
|
|
|
2507
2567
|
case 2:
|
|
2508
2568
|
data = _context29.sent;
|
|
@@ -2540,7 +2600,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2540
2600
|
}, {
|
|
2541
2601
|
key: "getReactions",
|
|
2542
2602
|
value: function getReactions(message_id, options) {
|
|
2543
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(message_id, "/reactions"), _objectSpread$
|
|
2603
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(message_id, "/reactions"), _objectSpread$5({}, options));
|
|
2544
2604
|
}
|
|
2545
2605
|
/**
|
|
2546
2606
|
* getMessagesById - Retrieves a list of messages by ID
|
|
@@ -2672,7 +2732,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2672
2732
|
}
|
|
2673
2733
|
|
|
2674
2734
|
_context30.next = 6;
|
|
2675
|
-
return this.getClient().post(queryURL + '/query', _objectSpread$
|
|
2735
|
+
return this.getClient().post(queryURL + '/query', _objectSpread$5({
|
|
2676
2736
|
data: this._data,
|
|
2677
2737
|
state: true
|
|
2678
2738
|
}, options));
|
|
@@ -2743,7 +2803,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2743
2803
|
this._checkInitialized();
|
|
2744
2804
|
|
|
2745
2805
|
_context31.next = 3;
|
|
2746
|
-
return this.getClient().banUser(targetUserID, _objectSpread$
|
|
2806
|
+
return this.getClient().banUser(targetUserID, _objectSpread$5(_objectSpread$5({}, options), {}, {
|
|
2747
2807
|
type: this.type,
|
|
2748
2808
|
id: this.id
|
|
2749
2809
|
}));
|
|
@@ -2915,7 +2975,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2915
2975
|
this._checkInitialized();
|
|
2916
2976
|
|
|
2917
2977
|
_context35.next = 3;
|
|
2918
|
-
return this.getClient().shadowBan(targetUserID, _objectSpread$
|
|
2978
|
+
return this.getClient().shadowBan(targetUserID, _objectSpread$5(_objectSpread$5({}, options), {}, {
|
|
2919
2979
|
type: this.type,
|
|
2920
2980
|
id: this.id
|
|
2921
2981
|
}));
|
|
@@ -3328,7 +3388,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3328
3388
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
3329
3389
|
var read = _step3.value;
|
|
3330
3390
|
|
|
3331
|
-
var parsedRead = _objectSpread$
|
|
3391
|
+
var parsedRead = _objectSpread$5(_objectSpread$5({}, read), {}, {
|
|
3332
3392
|
last_read: new Date(read.last_read)
|
|
3333
3393
|
});
|
|
3334
3394
|
|
|
@@ -3455,9 +3515,9 @@ var ClientState = /*#__PURE__*/function () {
|
|
|
3455
3515
|
return ClientState;
|
|
3456
3516
|
}();
|
|
3457
3517
|
|
|
3458
|
-
function ownKeys$
|
|
3518
|
+
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
3519
|
|
|
3460
|
-
function _objectSpread$
|
|
3520
|
+
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
3521
|
var InsightMetrics = function InsightMetrics() {
|
|
3462
3522
|
_classCallCheck__default['default'](this, InsightMetrics);
|
|
3463
3523
|
|
|
@@ -3474,32 +3534,94 @@ var InsightMetrics = function InsightMetrics() {
|
|
|
3474
3534
|
this.wsConsecutiveFailures = 0;
|
|
3475
3535
|
this.instanceClientId = randomId();
|
|
3476
3536
|
};
|
|
3537
|
+
/**
|
|
3538
|
+
* postInsights is not supposed to be used by end users directly within chat application, and thus is kept isolated
|
|
3539
|
+
* from all the client/connection code/logic.
|
|
3540
|
+
*
|
|
3541
|
+
* @param insightType
|
|
3542
|
+
* @param insights
|
|
3543
|
+
*/
|
|
3544
|
+
|
|
3545
|
+
var postInsights = /*#__PURE__*/function () {
|
|
3546
|
+
var _ref = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(insightType, insights) {
|
|
3547
|
+
var maxAttempts, i;
|
|
3548
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
3549
|
+
while (1) {
|
|
3550
|
+
switch (_context.prev = _context.next) {
|
|
3551
|
+
case 0:
|
|
3552
|
+
maxAttempts = 3;
|
|
3553
|
+
i = 0;
|
|
3554
|
+
|
|
3555
|
+
case 2:
|
|
3556
|
+
if (!(i < maxAttempts)) {
|
|
3557
|
+
_context.next = 17;
|
|
3558
|
+
break;
|
|
3559
|
+
}
|
|
3560
|
+
|
|
3561
|
+
_context.prev = 3;
|
|
3562
|
+
_context.next = 6;
|
|
3563
|
+
return axios__default['default'].post("https://chat-insights.getstream.io/insights/".concat(insightType), insights);
|
|
3564
|
+
|
|
3565
|
+
case 6:
|
|
3566
|
+
_context.next = 13;
|
|
3567
|
+
break;
|
|
3568
|
+
|
|
3569
|
+
case 8:
|
|
3570
|
+
_context.prev = 8;
|
|
3571
|
+
_context.t0 = _context["catch"](3);
|
|
3572
|
+
_context.next = 12;
|
|
3573
|
+
return sleep((i + 1) * 3000);
|
|
3574
|
+
|
|
3575
|
+
case 12:
|
|
3576
|
+
return _context.abrupt("continue", 14);
|
|
3577
|
+
|
|
3578
|
+
case 13:
|
|
3579
|
+
return _context.abrupt("break", 17);
|
|
3580
|
+
|
|
3581
|
+
case 14:
|
|
3582
|
+
i++;
|
|
3583
|
+
_context.next = 2;
|
|
3584
|
+
break;
|
|
3585
|
+
|
|
3586
|
+
case 17:
|
|
3587
|
+
case "end":
|
|
3588
|
+
return _context.stop();
|
|
3589
|
+
}
|
|
3590
|
+
}
|
|
3591
|
+
}, _callee, null, [[3, 8]]);
|
|
3592
|
+
}));
|
|
3593
|
+
|
|
3594
|
+
return function postInsights(_x, _x2) {
|
|
3595
|
+
return _ref.apply(this, arguments);
|
|
3596
|
+
};
|
|
3597
|
+
}();
|
|
3477
3598
|
function buildWsFatalInsight(connection, event) {
|
|
3478
|
-
return _objectSpread$
|
|
3599
|
+
return _objectSpread$4(_objectSpread$4({}, event), buildWsBaseInsight(connection));
|
|
3479
3600
|
}
|
|
3480
3601
|
|
|
3481
3602
|
function buildWsBaseInsight(connection) {
|
|
3482
3603
|
var _connection$ws, _navigator, _navigator2;
|
|
3483
3604
|
|
|
3605
|
+
var client = connection.client;
|
|
3484
3606
|
return {
|
|
3485
3607
|
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:
|
|
3608
|
+
url: connection._buildUrl(),
|
|
3609
|
+
api_key: client.key,
|
|
3610
|
+
start_ts: client.insightMetrics.connectionStartTimestamp,
|
|
3489
3611
|
end_ts: new Date().getTime(),
|
|
3490
|
-
auth_type:
|
|
3491
|
-
token:
|
|
3492
|
-
user_id:
|
|
3493
|
-
user_details:
|
|
3494
|
-
device:
|
|
3612
|
+
auth_type: client.getAuthType(),
|
|
3613
|
+
token: client.tokenManager.token,
|
|
3614
|
+
user_id: client.userID,
|
|
3615
|
+
user_details: client._user,
|
|
3616
|
+
device: client.options.device,
|
|
3495
3617
|
client_id: connection.connectionID,
|
|
3496
3618
|
ws_details: connection.ws,
|
|
3497
|
-
ws_consecutive_failures:
|
|
3498
|
-
ws_total_failures:
|
|
3619
|
+
ws_consecutive_failures: client.insightMetrics.wsConsecutiveFailures,
|
|
3620
|
+
ws_total_failures: client.insightMetrics.wsTotalFailures,
|
|
3499
3621
|
request_id: connection.requestID,
|
|
3500
3622
|
online: typeof navigator !== 'undefined' ? (_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.onLine : null,
|
|
3501
3623
|
user_agent: typeof navigator !== 'undefined' ? (_navigator2 = navigator) === null || _navigator2 === void 0 ? void 0 : _navigator2.userAgent : null,
|
|
3502
|
-
instance_client_id:
|
|
3624
|
+
instance_client_id: client.insightMetrics.instanceClientId
|
|
3503
3625
|
};
|
|
3504
3626
|
}
|
|
3505
3627
|
|
|
@@ -3507,6 +3629,10 @@ function buildWsSuccessAfterFailureInsight(connection) {
|
|
|
3507
3629
|
return buildWsBaseInsight(connection);
|
|
3508
3630
|
}
|
|
3509
3631
|
|
|
3632
|
+
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; }
|
|
3633
|
+
|
|
3634
|
+
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; }
|
|
3635
|
+
|
|
3510
3636
|
// Type guards to check WebSocket error type
|
|
3511
3637
|
var isCloseEvent = function isCloseEvent(res) {
|
|
3512
3638
|
return res.code !== undefined;
|
|
@@ -3515,7 +3641,6 @@ var isCloseEvent = function isCloseEvent(res) {
|
|
|
3515
3641
|
var isErrorEvent = function isErrorEvent(res) {
|
|
3516
3642
|
return res.error !== undefined;
|
|
3517
3643
|
};
|
|
3518
|
-
|
|
3519
3644
|
/**
|
|
3520
3645
|
* StableWSConnection - A WS connection that reconnects upon failure.
|
|
3521
3646
|
* - the browser will sometimes report that you're online or offline
|
|
@@ -3533,53 +3658,19 @@ var isErrorEvent = function isErrorEvent(res) {
|
|
|
3533
3658
|
* - state can be recovered by querying the channel again
|
|
3534
3659
|
* - if the servers fails to publish a message to the client, the WS connection is destroyed
|
|
3535
3660
|
*/
|
|
3661
|
+
|
|
3662
|
+
|
|
3536
3663
|
var StableWSConnection = /*#__PURE__*/function () {
|
|
3664
|
+
// global from constructor
|
|
3665
|
+
// local vars
|
|
3537
3666
|
function StableWSConnection(_ref) {
|
|
3538
3667
|
var _this = this;
|
|
3539
3668
|
|
|
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;
|
|
3669
|
+
var client = _ref.client;
|
|
3555
3670
|
|
|
3556
3671
|
_classCallCheck__default['default'](this, StableWSConnection);
|
|
3557
3672
|
|
|
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);
|
|
3673
|
+
_defineProperty__default['default'](this, "client", void 0);
|
|
3583
3674
|
|
|
3584
3675
|
_defineProperty__default['default'](this, "connectionID", void 0);
|
|
3585
3676
|
|
|
@@ -3593,6 +3684,8 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3593
3684
|
|
|
3594
3685
|
_defineProperty__default['default'](this, "isConnecting", void 0);
|
|
3595
3686
|
|
|
3687
|
+
_defineProperty__default['default'](this, "isDisconnected", void 0);
|
|
3688
|
+
|
|
3596
3689
|
_defineProperty__default['default'](this, "isHealthy", void 0);
|
|
3597
3690
|
|
|
3598
3691
|
_defineProperty__default['default'](this, "isResolved", void 0);
|
|
@@ -3607,8 +3700,6 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3607
3700
|
|
|
3608
3701
|
_defineProperty__default['default'](this, "requestID", void 0);
|
|
3609
3702
|
|
|
3610
|
-
_defineProperty__default['default'](this, "connectionStartTimestamp", void 0);
|
|
3611
|
-
|
|
3612
3703
|
_defineProperty__default['default'](this, "resolvePromise", void 0);
|
|
3613
3704
|
|
|
3614
3705
|
_defineProperty__default['default'](this, "totalFailures", void 0);
|
|
@@ -3617,32 +3708,18 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3617
3708
|
|
|
3618
3709
|
_defineProperty__default['default'](this, "wsID", void 0);
|
|
3619
3710
|
|
|
3620
|
-
_defineProperty__default['default'](this, "
|
|
3621
|
-
|
|
3622
|
-
_defineProperty__default['default'](this, "insightMetrics", void 0);
|
|
3711
|
+
_defineProperty__default['default'](this, "_buildUrl", function () {
|
|
3712
|
+
var qs = encodeURIComponent(_this.client._buildWSPayload(_this.requestID));
|
|
3623
3713
|
|
|
3624
|
-
|
|
3625
|
-
var params = {
|
|
3626
|
-
user_id: _this.user.id,
|
|
3627
|
-
user_details: _this.user,
|
|
3628
|
-
user_token: _this.tokenManager.getToken(),
|
|
3629
|
-
server_determines_connection_id: true,
|
|
3630
|
-
device: _this.device,
|
|
3631
|
-
request_id: reqID
|
|
3632
|
-
};
|
|
3633
|
-
var qs = encodeURIComponent(JSON.stringify(params));
|
|
3714
|
+
var token = _this.client.tokenManager.getToken();
|
|
3634
3715
|
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
return "".concat(_this.wsBaseURL, "/connect?json=").concat(qs, "&api_key=").concat(_this.apiKey, "&authorization=").concat(token, "&stream-auth-type=").concat(_this.authType, "&X-Stream-Client=").concat(_this.userAgent);
|
|
3716
|
+
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
3717
|
});
|
|
3639
3718
|
|
|
3640
3719
|
_defineProperty__default['default'](this, "onlineStatusChanged", function (event) {
|
|
3641
3720
|
if (event.type === 'offline') {
|
|
3642
3721
|
// mark the connection as down
|
|
3643
|
-
_this.
|
|
3644
|
-
tags: ['connection']
|
|
3645
|
-
});
|
|
3722
|
+
_this._log('onlineStatusChanged() - Status changing to offline');
|
|
3646
3723
|
|
|
3647
3724
|
_this._setHealth(false);
|
|
3648
3725
|
} else if (event.type === 'online') {
|
|
@@ -3650,9 +3727,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3650
3727
|
// We check this.isHealthy, not sure if it's always
|
|
3651
3728
|
// smart to create a new WS connection if the old one is still up and running.
|
|
3652
3729
|
// it's possible we didn't miss any messages, so this process is just expensive and not needed.
|
|
3653
|
-
_this.
|
|
3654
|
-
tags: ['connection']
|
|
3655
|
-
});
|
|
3730
|
+
_this._log("onlineStatusChanged() - Status changing to online. isHealthy: ".concat(_this.isHealthy));
|
|
3656
3731
|
|
|
3657
3732
|
if (!_this.isHealthy) {
|
|
3658
3733
|
_this._reconnect({
|
|
@@ -3665,8 +3740,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3665
3740
|
_defineProperty__default['default'](this, "onopen", function (wsID) {
|
|
3666
3741
|
if (_this.wsID !== wsID) return;
|
|
3667
3742
|
|
|
3668
|
-
_this.
|
|
3669
|
-
tags: ['connection'],
|
|
3743
|
+
_this._log('onopen() - onopen callback', {
|
|
3670
3744
|
wsID: wsID
|
|
3671
3745
|
});
|
|
3672
3746
|
});
|
|
@@ -3678,27 +3752,26 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3678
3752
|
// after that a ws.onclose..
|
|
3679
3753
|
|
|
3680
3754
|
if (!_this.isResolved && data) {
|
|
3755
|
+
var _this$resolvePromise;
|
|
3756
|
+
|
|
3681
3757
|
_this.isResolved = true;
|
|
3682
3758
|
|
|
3683
|
-
if (data.error
|
|
3759
|
+
if (data.error) {
|
|
3684
3760
|
var _this$rejectPromise;
|
|
3685
3761
|
|
|
3686
3762
|
(_this$rejectPromise = _this.rejectPromise) === null || _this$rejectPromise === void 0 ? void 0 : _this$rejectPromise.call(_this, _this._errorFromWSEvent(data, false));
|
|
3687
3763
|
return;
|
|
3688
|
-
}
|
|
3689
|
-
var _this$resolvePromise;
|
|
3764
|
+
}
|
|
3690
3765
|
|
|
3691
|
-
|
|
3766
|
+
(_this$resolvePromise = _this.resolvePromise) === null || _this$resolvePromise === void 0 ? void 0 : _this$resolvePromise.call(_this, data);
|
|
3692
3767
|
|
|
3693
|
-
|
|
3694
|
-
}
|
|
3768
|
+
_this._setHealth(true);
|
|
3695
3769
|
} // trigger the event..
|
|
3696
3770
|
|
|
3697
3771
|
|
|
3698
3772
|
_this.lastEvent = new Date();
|
|
3699
3773
|
|
|
3700
|
-
_this.
|
|
3701
|
-
tags: ['connection'],
|
|
3774
|
+
_this._log('onmessage() - onmessage callback', {
|
|
3702
3775
|
event: event,
|
|
3703
3776
|
wsID: wsID
|
|
3704
3777
|
});
|
|
@@ -3707,7 +3780,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3707
3780
|
_this.scheduleNextPing();
|
|
3708
3781
|
}
|
|
3709
3782
|
|
|
3710
|
-
_this.
|
|
3783
|
+
_this.client.handleEvent(event);
|
|
3711
3784
|
|
|
3712
3785
|
_this.scheduleConnectionCheck();
|
|
3713
3786
|
});
|
|
@@ -3715,8 +3788,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3715
3788
|
_defineProperty__default['default'](this, "onclose", function (wsID, event) {
|
|
3716
3789
|
if (_this.wsID !== wsID) return;
|
|
3717
3790
|
|
|
3718
|
-
_this.
|
|
3719
|
-
tags: ['connection'],
|
|
3791
|
+
_this._log('onclose() - onclose callback - ' + event.code, {
|
|
3720
3792
|
event: event,
|
|
3721
3793
|
wsID: wsID
|
|
3722
3794
|
});
|
|
@@ -3733,8 +3805,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3733
3805
|
error.target = event.target;
|
|
3734
3806
|
(_this$rejectPromise2 = _this.rejectPromise) === null || _this$rejectPromise2 === void 0 ? void 0 : _this$rejectPromise2.call(_this, error);
|
|
3735
3807
|
|
|
3736
|
-
_this.
|
|
3737
|
-
tags: ['connection'],
|
|
3808
|
+
_this._log("onclose() - WS connection reject with error ".concat(event.reason), {
|
|
3738
3809
|
event: event
|
|
3739
3810
|
});
|
|
3740
3811
|
} else {
|
|
@@ -3748,8 +3819,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3748
3819
|
_this.isConnecting = false;
|
|
3749
3820
|
(_this$rejectPromise3 = _this.rejectPromise) === null || _this$rejectPromise3 === void 0 ? void 0 : _this$rejectPromise3.call(_this, _this._errorFromWSEvent(event));
|
|
3750
3821
|
|
|
3751
|
-
_this.
|
|
3752
|
-
tags: ['connection'],
|
|
3822
|
+
_this._log("onclose() - WS connection closed. Calling reconnect ...", {
|
|
3753
3823
|
event: event
|
|
3754
3824
|
}); // reconnect if its an abnormal failure
|
|
3755
3825
|
|
|
@@ -3770,8 +3840,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3770
3840
|
_this.isConnecting = false;
|
|
3771
3841
|
(_this$rejectPromise4 = _this.rejectPromise) === null || _this$rejectPromise4 === void 0 ? void 0 : _this$rejectPromise4.call(_this, _this._errorFromWSEvent(event));
|
|
3772
3842
|
|
|
3773
|
-
_this.
|
|
3774
|
-
tags: ['connection'],
|
|
3843
|
+
_this._log("onerror() - WS connection resulted into error", {
|
|
3775
3844
|
event: event
|
|
3776
3845
|
});
|
|
3777
3846
|
|
|
@@ -3779,28 +3848,28 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3779
3848
|
});
|
|
3780
3849
|
|
|
3781
3850
|
_defineProperty__default['default'](this, "_setHealth", function (healthy) {
|
|
3782
|
-
if (healthy
|
|
3783
|
-
|
|
3784
|
-
_this.isHealthy = true;
|
|
3851
|
+
if (healthy === _this.isHealthy) return;
|
|
3852
|
+
_this.isHealthy = healthy;
|
|
3785
3853
|
|
|
3786
|
-
|
|
3854
|
+
if (_this.isHealthy) {
|
|
3855
|
+
//@ts-expect-error
|
|
3856
|
+
_this.client.dispatchEvent({
|
|
3787
3857
|
type: 'connection.changed',
|
|
3788
|
-
online:
|
|
3858
|
+
online: _this.isHealthy
|
|
3789
3859
|
});
|
|
3790
|
-
}
|
|
3791
3860
|
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
}
|
|
3803
|
-
}
|
|
3861
|
+
return;
|
|
3862
|
+
} // we're offline, wait few seconds and fire and event if still offline
|
|
3863
|
+
|
|
3864
|
+
|
|
3865
|
+
setTimeout(function () {
|
|
3866
|
+
if (_this.isHealthy) return; //@ts-expect-error
|
|
3867
|
+
|
|
3868
|
+
_this.client.dispatchEvent({
|
|
3869
|
+
type: 'connection.changed',
|
|
3870
|
+
online: _this.isHealthy
|
|
3871
|
+
});
|
|
3872
|
+
}, 5000);
|
|
3804
3873
|
});
|
|
3805
3874
|
|
|
3806
3875
|
_defineProperty__default['default'](this, "_errorFromWSEvent", function (event) {
|
|
@@ -3822,10 +3891,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3822
3891
|
} // Keeping this `warn` level log, to avoid cluttering of error logs from ws failures.
|
|
3823
3892
|
|
|
3824
3893
|
|
|
3825
|
-
_this.
|
|
3826
|
-
tags: ['connection'],
|
|
3894
|
+
_this._log("_errorFromWSEvent() - WS failed with code ".concat(code), {
|
|
3827
3895
|
event: event
|
|
3828
|
-
});
|
|
3896
|
+
}, 'warn');
|
|
3829
3897
|
|
|
3830
3898
|
var error = new Error("WS failed with code ".concat(code, " and reason - ").concat(message));
|
|
3831
3899
|
error.code = code;
|
|
@@ -3839,50 +3907,13 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3839
3907
|
return error;
|
|
3840
3908
|
});
|
|
3841
3909
|
|
|
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
3910
|
_defineProperty__default['default'](this, "_setupConnectionPromise", function () {
|
|
3865
|
-
var that = _this;
|
|
3866
3911
|
_this.isResolved = false;
|
|
3867
3912
|
/** a promise that is resolved once ws.open is called */
|
|
3868
3913
|
|
|
3869
3914
|
_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;
|
|
3915
|
+
_this.resolvePromise = resolve;
|
|
3916
|
+
_this.rejectPromise = reject;
|
|
3886
3917
|
});
|
|
3887
3918
|
});
|
|
3888
3919
|
|
|
@@ -3896,7 +3927,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3896
3927
|
// send the healthcheck.., server replies with a health check event
|
|
3897
3928
|
var data = [{
|
|
3898
3929
|
type: 'health.check',
|
|
3899
|
-
client_id: _this.clientID
|
|
3930
|
+
client_id: _this.client.clientID
|
|
3900
3931
|
}]; // try to send on the connection
|
|
3901
3932
|
|
|
3902
3933
|
try {
|
|
@@ -3917,9 +3948,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3917
3948
|
var now = new Date();
|
|
3918
3949
|
|
|
3919
3950
|
if (_this.lastEvent && now.getTime() - _this.lastEvent.getTime() > _this.connectionCheckTimeout) {
|
|
3920
|
-
_this.
|
|
3921
|
-
tags: ['connection']
|
|
3922
|
-
});
|
|
3951
|
+
_this._log('scheduleConnectionCheck - going to reconnect');
|
|
3923
3952
|
|
|
3924
3953
|
_this._setHealth(false);
|
|
3925
3954
|
|
|
@@ -3928,15 +3957,8 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3928
3957
|
}, _this.connectionCheckTimeout);
|
|
3929
3958
|
});
|
|
3930
3959
|
|
|
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;
|
|
3960
|
+
/** StreamChat client */
|
|
3961
|
+
this.client = client;
|
|
3940
3962
|
/** consecutive failures influence the duration of the timeout */
|
|
3941
3963
|
|
|
3942
3964
|
this.consecutiveFailures = 0;
|
|
@@ -3946,18 +3968,15 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3946
3968
|
/** We only make 1 attempt to reconnect at the same time.. */
|
|
3947
3969
|
|
|
3948
3970
|
this.isConnecting = false;
|
|
3971
|
+
/** To avoid reconnect if client is disconnected */
|
|
3972
|
+
|
|
3973
|
+
this.isDisconnected = false;
|
|
3949
3974
|
/** Boolean that indicates if the connection promise is resolved */
|
|
3950
3975
|
|
|
3951
3976
|
this.isResolved = false;
|
|
3952
3977
|
/** Boolean that indicates if we have a working connection to the server */
|
|
3953
3978
|
|
|
3954
3979
|
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
3980
|
/** Incremented when a new WS connection is made */
|
|
3962
3981
|
|
|
3963
3982
|
this.wsID = 1;
|
|
@@ -3968,74 +3987,82 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3968
3987
|
|
|
3969
3988
|
this.pingInterval = 25 * 1000;
|
|
3970
3989
|
this.connectionCheckTimeout = this.pingInterval + 10 * 1000;
|
|
3971
|
-
|
|
3972
|
-
this._listenForConnectionChanges();
|
|
3973
|
-
|
|
3974
|
-
this.postInsights = postInsights;
|
|
3975
|
-
this.insightMetrics = insightMetrics;
|
|
3990
|
+
addConnectionEventListeners(this.onlineStatusChanged);
|
|
3976
3991
|
}
|
|
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
3992
|
|
|
3984
3993
|
_createClass__default['default'](StableWSConnection, [{
|
|
3994
|
+
key: "_log",
|
|
3995
|
+
value: function _log(msg) {
|
|
3996
|
+
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
3997
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
3998
|
+
this.client.logger(level, 'connection:' + msg, _objectSpread$3({
|
|
3999
|
+
tags: ['connection']
|
|
4000
|
+
}, extra));
|
|
4001
|
+
}
|
|
4002
|
+
/**
|
|
4003
|
+
* connect - Connect to the WS URL
|
|
4004
|
+
* the default 15s timeout allows between 2~3 tries
|
|
4005
|
+
* @return {ConnectAPIResponse<ChannelType, CommandType, UserType>} Promise that completes once the first health check message is received
|
|
4006
|
+
*/
|
|
4007
|
+
|
|
4008
|
+
}, {
|
|
3985
4009
|
key: "connect",
|
|
3986
4010
|
value: function () {
|
|
3987
4011
|
var _connect2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
|
3988
|
-
var
|
|
4012
|
+
var timeout,
|
|
4013
|
+
healthCheck,
|
|
4014
|
+
_args = arguments;
|
|
3989
4015
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
3990
4016
|
while (1) {
|
|
3991
4017
|
switch (_context.prev = _context.next) {
|
|
3992
4018
|
case 0:
|
|
4019
|
+
timeout = _args.length > 0 && _args[0] !== undefined ? _args[0] : 15000;
|
|
4020
|
+
|
|
3993
4021
|
if (!this.isConnecting) {
|
|
3994
|
-
_context.next =
|
|
4022
|
+
_context.next = 3;
|
|
3995
4023
|
break;
|
|
3996
4024
|
}
|
|
3997
4025
|
|
|
3998
4026
|
throw Error("You've called connect twice, can only attempt 1 connection at the time");
|
|
3999
4027
|
|
|
4000
|
-
case
|
|
4001
|
-
|
|
4002
|
-
_context.
|
|
4028
|
+
case 3:
|
|
4029
|
+
this.isDisconnected = false;
|
|
4030
|
+
_context.prev = 4;
|
|
4031
|
+
_context.next = 7;
|
|
4003
4032
|
return this._connect();
|
|
4004
4033
|
|
|
4005
|
-
case
|
|
4034
|
+
case 7:
|
|
4006
4035
|
healthCheck = _context.sent;
|
|
4007
4036
|
this.consecutiveFailures = 0;
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
_context.next =
|
|
4037
|
+
|
|
4038
|
+
this._log("connect() - Established ws connection with healthcheck: ".concat(healthCheck));
|
|
4039
|
+
|
|
4040
|
+
_context.next = 23;
|
|
4012
4041
|
break;
|
|
4013
4042
|
|
|
4014
|
-
case
|
|
4015
|
-
_context.prev =
|
|
4016
|
-
_context.t0 = _context["catch"](
|
|
4043
|
+
case 12:
|
|
4044
|
+
_context.prev = 12;
|
|
4045
|
+
_context.t0 = _context["catch"](4);
|
|
4017
4046
|
this.isHealthy = false;
|
|
4018
4047
|
this.consecutiveFailures += 1;
|
|
4019
4048
|
|
|
4020
|
-
if (!(_context.t0.code === chatCodes.TOKEN_EXPIRED && !this.tokenManager.isStatic())) {
|
|
4021
|
-
_context.next =
|
|
4049
|
+
if (!(_context.t0.code === chatCodes.TOKEN_EXPIRED && !this.client.tokenManager.isStatic())) {
|
|
4050
|
+
_context.next = 21;
|
|
4022
4051
|
break;
|
|
4023
4052
|
}
|
|
4024
4053
|
|
|
4025
|
-
this.
|
|
4026
|
-
tags: ['connection']
|
|
4027
|
-
});
|
|
4054
|
+
this._log('connect() - WS failure due to expired token, so going to try to reload token and reconnect');
|
|
4028
4055
|
|
|
4029
4056
|
this._reconnect({
|
|
4030
4057
|
refreshToken: true
|
|
4031
4058
|
});
|
|
4032
4059
|
|
|
4033
|
-
_context.next =
|
|
4060
|
+
_context.next = 23;
|
|
4034
4061
|
break;
|
|
4035
4062
|
|
|
4036
|
-
case
|
|
4063
|
+
case 21:
|
|
4037
4064
|
if (_context.t0.isWSFailure) {
|
|
4038
|
-
_context.next =
|
|
4065
|
+
_context.next = 23;
|
|
4039
4066
|
break;
|
|
4040
4067
|
}
|
|
4041
4068
|
|
|
@@ -4046,19 +4073,19 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4046
4073
|
isWSFailure: _context.t0.isWSFailure
|
|
4047
4074
|
}));
|
|
4048
4075
|
|
|
4049
|
-
case 21:
|
|
4050
|
-
_context.next = 23;
|
|
4051
|
-
return this._waitForHealthy();
|
|
4052
|
-
|
|
4053
4076
|
case 23:
|
|
4077
|
+
_context.next = 25;
|
|
4078
|
+
return this._waitForHealthy(timeout);
|
|
4079
|
+
|
|
4080
|
+
case 25:
|
|
4054
4081
|
return _context.abrupt("return", _context.sent);
|
|
4055
4082
|
|
|
4056
|
-
case
|
|
4083
|
+
case 26:
|
|
4057
4084
|
case "end":
|
|
4058
4085
|
return _context.stop();
|
|
4059
4086
|
}
|
|
4060
4087
|
}
|
|
4061
|
-
}, _callee, this, [[
|
|
4088
|
+
}, _callee, this, [[4, 12]]);
|
|
4062
4089
|
}));
|
|
4063
4090
|
|
|
4064
4091
|
function connect() {
|
|
@@ -4149,6 +4176,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4149
4176
|
return sleep(timeout);
|
|
4150
4177
|
|
|
4151
4178
|
case 2:
|
|
4179
|
+
_this2.isConnecting = false;
|
|
4152
4180
|
throw new Error(JSON.stringify({
|
|
4153
4181
|
code: '',
|
|
4154
4182
|
StatusCode: '',
|
|
@@ -4156,7 +4184,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4156
4184
|
isWSFailure: true
|
|
4157
4185
|
}));
|
|
4158
4186
|
|
|
4159
|
-
case
|
|
4187
|
+
case 4:
|
|
4160
4188
|
case "end":
|
|
4161
4189
|
return _context3.stop();
|
|
4162
4190
|
}
|
|
@@ -4180,7 +4208,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4180
4208
|
}()
|
|
4181
4209
|
/**
|
|
4182
4210
|
* Builds and returns the url for websocket.
|
|
4183
|
-
* @
|
|
4211
|
+
* @private
|
|
4184
4212
|
* @returns url string
|
|
4185
4213
|
*/
|
|
4186
4214
|
|
|
@@ -4194,10 +4222,11 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4194
4222
|
function disconnect(timeout) {
|
|
4195
4223
|
var _this3 = this;
|
|
4196
4224
|
|
|
4197
|
-
this.
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
this.
|
|
4225
|
+
this._log("disconnect() - Closing the websocket connection for wsID ".concat(this.wsID));
|
|
4226
|
+
|
|
4227
|
+
this.wsID += 1;
|
|
4228
|
+
this.isConnecting = false;
|
|
4229
|
+
this.isDisconnected = true; // start by removing all the listeners
|
|
4201
4230
|
|
|
4202
4231
|
if (this.healthCheckTimeoutRef) {
|
|
4203
4232
|
clearInterval(this.healthCheckTimeoutRef);
|
|
@@ -4207,8 +4236,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4207
4236
|
clearInterval(this.connectionCheckTimeoutRef);
|
|
4208
4237
|
}
|
|
4209
4238
|
|
|
4210
|
-
this.
|
|
4211
|
-
|
|
4239
|
+
removeConnectionEventListeners(this.onlineStatusChanged);
|
|
4212
4240
|
this.isHealthy = false; // remove ws handlers...
|
|
4213
4241
|
|
|
4214
4242
|
if (this.ws && this.ws.removeAllListeners) {
|
|
@@ -4224,8 +4252,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4224
4252
|
if (ws && ws.close && ws.readyState === ws.OPEN) {
|
|
4225
4253
|
isClosedPromise = new Promise(function (resolve) {
|
|
4226
4254
|
var onclose = function onclose(event) {
|
|
4227
|
-
_this3.
|
|
4228
|
-
tags: ['connection'],
|
|
4255
|
+
_this3._log("disconnect() - resolving isClosedPromise ".concat(event ? 'with' : 'without', " close frame"), {
|
|
4229
4256
|
event: event
|
|
4230
4257
|
});
|
|
4231
4258
|
|
|
@@ -4237,14 +4264,13 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4237
4264
|
|
|
4238
4265
|
setTimeout(onclose, timeout != null ? timeout : 1000);
|
|
4239
4266
|
});
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4267
|
+
|
|
4268
|
+
this._log("disconnect() - Manually closed connection by calling client.disconnect()");
|
|
4269
|
+
|
|
4243
4270
|
ws.close(chatCodes.WS_CLOSED_SUCCESS, 'Manually closed connection by calling client.disconnect()');
|
|
4244
4271
|
} else {
|
|
4245
|
-
this.
|
|
4246
|
-
|
|
4247
|
-
});
|
|
4272
|
+
this._log("disconnect() - ws connection doesn't exist or it is already closed.");
|
|
4273
|
+
|
|
4248
4274
|
isClosedPromise = Promise.resolve();
|
|
4249
4275
|
}
|
|
4250
4276
|
|
|
@@ -4261,13 +4287,12 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4261
4287
|
key: "_connect",
|
|
4262
4288
|
value: function () {
|
|
4263
4289
|
var _connect3 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5() {
|
|
4264
|
-
var wsURL, response,
|
|
4265
|
-
|
|
4290
|
+
var wsURL, response, insights;
|
|
4266
4291
|
return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
|
|
4267
4292
|
while (1) {
|
|
4268
4293
|
switch (_context5.prev = _context5.next) {
|
|
4269
4294
|
case 0:
|
|
4270
|
-
if (!this.isConnecting) {
|
|
4295
|
+
if (!(this.isConnecting || this.isDisconnected)) {
|
|
4271
4296
|
_context5.next = 2;
|
|
4272
4297
|
break;
|
|
4273
4298
|
}
|
|
@@ -4278,15 +4303,15 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4278
4303
|
// simply ignore _connect if it's currently trying to connect
|
|
4279
4304
|
this.isConnecting = true;
|
|
4280
4305
|
this.requestID = randomId();
|
|
4281
|
-
this.insightMetrics.connectionStartTimestamp = new Date().getTime();
|
|
4306
|
+
this.client.insightMetrics.connectionStartTimestamp = new Date().getTime();
|
|
4282
4307
|
_context5.prev = 5;
|
|
4283
4308
|
_context5.next = 8;
|
|
4284
|
-
return this.tokenManager.tokenReady();
|
|
4309
|
+
return this.client.tokenManager.tokenReady();
|
|
4285
4310
|
|
|
4286
4311
|
case 8:
|
|
4287
4312
|
this._setupConnectionPromise();
|
|
4288
4313
|
|
|
4289
|
-
wsURL = this._buildUrl(
|
|
4314
|
+
wsURL = this._buildUrl();
|
|
4290
4315
|
this.ws = new WebSocket__default['default'](wsURL);
|
|
4291
4316
|
this.ws.onopen = this.onopen.bind(this, this.wsID);
|
|
4292
4317
|
this.ws.onclose = this.onclose.bind(this, this.wsID);
|
|
@@ -4306,9 +4331,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4306
4331
|
|
|
4307
4332
|
this.connectionID = response.connection_id;
|
|
4308
4333
|
|
|
4309
|
-
if (this.insightMetrics.wsConsecutiveFailures > 0 && this.
|
|
4310
|
-
|
|
4311
|
-
this.insightMetrics.wsConsecutiveFailures = 0;
|
|
4334
|
+
if (this.client.insightMetrics.wsConsecutiveFailures > 0 && this.client.options.enableInsights) {
|
|
4335
|
+
postInsights('ws_success_after_failure', buildWsSuccessAfterFailureInsight(this));
|
|
4336
|
+
this.client.insightMetrics.wsConsecutiveFailures = 0;
|
|
4312
4337
|
}
|
|
4313
4338
|
|
|
4314
4339
|
return _context5.abrupt("return", response);
|
|
@@ -4322,12 +4347,11 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4322
4347
|
_context5.t0 = _context5["catch"](5);
|
|
4323
4348
|
this.isConnecting = false;
|
|
4324
4349
|
|
|
4325
|
-
if (this.
|
|
4326
|
-
this.insightMetrics.wsConsecutiveFailures++;
|
|
4327
|
-
this.insightMetrics.wsTotalFailures++;
|
|
4328
|
-
|
|
4350
|
+
if (this.client.options.enableInsights) {
|
|
4351
|
+
this.client.insightMetrics.wsConsecutiveFailures++;
|
|
4352
|
+
this.client.insightMetrics.wsTotalFailures++;
|
|
4329
4353
|
insights = buildWsFatalInsight(this, convertErrorToJson(_context5.t0));
|
|
4330
|
-
|
|
4354
|
+
postInsights === null || postInsights === void 0 ? void 0 : postInsights('ws_fatal', insights);
|
|
4331
4355
|
}
|
|
4332
4356
|
|
|
4333
4357
|
throw _context5.t0;
|
|
@@ -4361,26 +4385,23 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4361
4385
|
var _reconnect2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee6() {
|
|
4362
4386
|
var options,
|
|
4363
4387
|
interval,
|
|
4364
|
-
_open,
|
|
4365
4388
|
_args6 = arguments;
|
|
4366
|
-
|
|
4367
4389
|
return _regeneratorRuntime__default['default'].wrap(function _callee6$(_context6) {
|
|
4368
4390
|
while (1) {
|
|
4369
4391
|
switch (_context6.prev = _context6.next) {
|
|
4370
4392
|
case 0:
|
|
4371
4393
|
options = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4394
|
+
|
|
4395
|
+
this._log('_reconnect() - Initiating the reconnect'); // only allow 1 connection at the time
|
|
4396
|
+
|
|
4375
4397
|
|
|
4376
4398
|
if (!(this.isConnecting || this.isHealthy)) {
|
|
4377
4399
|
_context6.next = 5;
|
|
4378
4400
|
break;
|
|
4379
4401
|
}
|
|
4380
4402
|
|
|
4381
|
-
this.
|
|
4382
|
-
|
|
4383
|
-
});
|
|
4403
|
+
this._log('_reconnect() - Abort (1) since already connecting or healthy');
|
|
4404
|
+
|
|
4384
4405
|
return _context6.abrupt("return");
|
|
4385
4406
|
|
|
4386
4407
|
case 5:
|
|
@@ -4402,95 +4423,86 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4402
4423
|
break;
|
|
4403
4424
|
}
|
|
4404
4425
|
|
|
4405
|
-
this.
|
|
4406
|
-
|
|
4407
|
-
});
|
|
4426
|
+
this._log('_reconnect() - Abort (2) since already connecting or healthy');
|
|
4427
|
+
|
|
4408
4428
|
return _context6.abrupt("return");
|
|
4409
4429
|
|
|
4410
4430
|
case 12:
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
}
|
|
4431
|
+
if (!this.isDisconnected) {
|
|
4432
|
+
_context6.next = 15;
|
|
4433
|
+
break;
|
|
4434
|
+
}
|
|
4435
|
+
|
|
4436
|
+
this._log('_reconnect() - Abort (3) since disconnect() is called');
|
|
4437
|
+
|
|
4438
|
+
return _context6.abrupt("return");
|
|
4439
|
+
|
|
4440
|
+
case 15:
|
|
4441
|
+
this._log('_reconnect() - Destroying current WS connection'); // cleanup the old connection
|
|
4442
|
+
|
|
4415
4443
|
|
|
4416
4444
|
this._destroyCurrentWSConnection();
|
|
4417
4445
|
|
|
4418
4446
|
if (!options.refreshToken) {
|
|
4419
|
-
_context6.next =
|
|
4447
|
+
_context6.next = 20;
|
|
4420
4448
|
break;
|
|
4421
4449
|
}
|
|
4422
4450
|
|
|
4423
|
-
_context6.next = 17;
|
|
4424
|
-
return this.tokenManager.loadToken();
|
|
4425
|
-
|
|
4426
|
-
case 17:
|
|
4427
|
-
_context6.prev = 17;
|
|
4428
4451
|
_context6.next = 20;
|
|
4429
|
-
return this.
|
|
4452
|
+
return this.client.tokenManager.loadToken();
|
|
4430
4453
|
|
|
4431
4454
|
case 20:
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
_context6.next = 26;
|
|
4436
|
-
break;
|
|
4437
|
-
}
|
|
4455
|
+
_context6.prev = 20;
|
|
4456
|
+
_context6.next = 23;
|
|
4457
|
+
return this._connect();
|
|
4438
4458
|
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
});
|
|
4442
|
-
_context6.next = 25;
|
|
4443
|
-
return this.recoverCallback(_open);
|
|
4459
|
+
case 23:
|
|
4460
|
+
this._log('_reconnect() - Waiting for recoverCallBack');
|
|
4444
4461
|
|
|
4445
|
-
|
|
4446
|
-
this.
|
|
4447
|
-
tags: ['connection']
|
|
4448
|
-
});
|
|
4462
|
+
_context6.next = 26;
|
|
4463
|
+
return this.client.recoverState();
|
|
4449
4464
|
|
|
4450
4465
|
case 26:
|
|
4466
|
+
this._log('_reconnect() - Finished recoverCallBack');
|
|
4467
|
+
|
|
4451
4468
|
this.consecutiveFailures = 0;
|
|
4452
|
-
_context6.next =
|
|
4469
|
+
_context6.next = 38;
|
|
4453
4470
|
break;
|
|
4454
4471
|
|
|
4455
|
-
case
|
|
4456
|
-
_context6.prev =
|
|
4457
|
-
_context6.t0 = _context6["catch"](
|
|
4472
|
+
case 30:
|
|
4473
|
+
_context6.prev = 30;
|
|
4474
|
+
_context6.t0 = _context6["catch"](20);
|
|
4458
4475
|
this.isHealthy = false;
|
|
4459
4476
|
this.consecutiveFailures += 1;
|
|
4460
4477
|
|
|
4461
|
-
if (!(_context6.t0.code === chatCodes.TOKEN_EXPIRED && !this.tokenManager.isStatic())) {
|
|
4462
|
-
_context6.next =
|
|
4478
|
+
if (!(_context6.t0.code === chatCodes.TOKEN_EXPIRED && !this.client.tokenManager.isStatic())) {
|
|
4479
|
+
_context6.next = 37;
|
|
4463
4480
|
break;
|
|
4464
4481
|
}
|
|
4465
4482
|
|
|
4466
|
-
this.
|
|
4467
|
-
|
|
4468
|
-
});
|
|
4483
|
+
this._log('_reconnect() - WS failure due to expired token, so going to try to reload token and reconnect');
|
|
4484
|
+
|
|
4469
4485
|
return _context6.abrupt("return", this._reconnect({
|
|
4470
4486
|
refreshToken: true
|
|
4471
4487
|
}));
|
|
4472
4488
|
|
|
4473
|
-
case
|
|
4489
|
+
case 37:
|
|
4474
4490
|
// reconnect on WS failures, don't reconnect if there is a code bug
|
|
4475
4491
|
if (_context6.t0.isWSFailure) {
|
|
4476
|
-
this.
|
|
4477
|
-
tags: ['connection']
|
|
4478
|
-
});
|
|
4492
|
+
this._log('_reconnect() - WS failure, so going to try to reconnect');
|
|
4479
4493
|
|
|
4480
4494
|
this._reconnect();
|
|
4481
4495
|
}
|
|
4482
4496
|
|
|
4483
|
-
case 37:
|
|
4484
|
-
this.logger('info', 'connection:_reconnect() - == END ==', {
|
|
4485
|
-
tags: ['connection']
|
|
4486
|
-
});
|
|
4487
|
-
|
|
4488
4497
|
case 38:
|
|
4498
|
+
this._log('_reconnect() - == END ==');
|
|
4499
|
+
|
|
4500
|
+
case 39:
|
|
4489
4501
|
case "end":
|
|
4490
4502
|
return _context6.stop();
|
|
4491
4503
|
}
|
|
4492
4504
|
}
|
|
4493
|
-
}, _callee6, this, [[
|
|
4505
|
+
}, _callee6, this, [[20, 30]]);
|
|
4494
4506
|
}));
|
|
4495
4507
|
|
|
4496
4508
|
function _reconnect() {
|
|
@@ -4519,13 +4531,10 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4519
4531
|
this.wsID += 1;
|
|
4520
4532
|
|
|
4521
4533
|
try {
|
|
4522
|
-
|
|
4523
|
-
this.ws.removeAllListeners();
|
|
4524
|
-
}
|
|
4534
|
+
var _this$ws2, _this$ws3;
|
|
4525
4535
|
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
}
|
|
4536
|
+
this === null || this === void 0 ? void 0 : (_this$ws2 = this.ws) === null || _this$ws2 === void 0 ? void 0 : _this$ws2.removeAllListeners();
|
|
4537
|
+
this === null || this === void 0 ? void 0 : (_this$ws3 = this.ws) === null || _this$ws3 === void 0 ? void 0 : _this$ws3.close();
|
|
4529
4538
|
} catch (e) {// we don't care
|
|
4530
4539
|
}
|
|
4531
4540
|
}
|
|
@@ -4538,9 +4547,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4538
4547
|
return StableWSConnection;
|
|
4539
4548
|
}();
|
|
4540
4549
|
|
|
4541
|
-
function ownKeys$
|
|
4550
|
+
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
4551
|
|
|
4543
|
-
function _objectSpread$
|
|
4552
|
+
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
4553
|
|
|
4545
4554
|
/**
|
|
4546
4555
|
* Creates the JWT token that can be used for a UserSession
|
|
@@ -4549,7 +4558,7 @@ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) {
|
|
|
4549
4558
|
* @private
|
|
4550
4559
|
* @param {Secret} apiSecret - API Secret key
|
|
4551
4560
|
* @param {string} userId - The user_id key in the JWT payload
|
|
4552
|
-
* @param {
|
|
4561
|
+
* @param {UR} [extraData] - Extra that should be part of the JWT token
|
|
4553
4562
|
* @param {SignOptions} [jwtOptions] - Options that can be past to jwt.sign
|
|
4554
4563
|
* @return {string} JWT Token
|
|
4555
4564
|
*/
|
|
@@ -4561,7 +4570,7 @@ function JWTUserToken(apiSecret, userId) {
|
|
|
4561
4570
|
throw new TypeError('userId should be a string');
|
|
4562
4571
|
}
|
|
4563
4572
|
|
|
4564
|
-
var payload = _objectSpread$
|
|
4573
|
+
var payload = _objectSpread$2({
|
|
4565
4574
|
user_id: userId
|
|
4566
4575
|
}, extraData); // make sure we return a clear error when jwt is shimmed (ie. browser build)
|
|
4567
4576
|
|
|
@@ -4748,76 +4757,576 @@ function TokenManager(secret) {
|
|
|
4748
4757
|
break;
|
|
4749
4758
|
}
|
|
4750
4759
|
|
|
4751
|
-
return _context2.abrupt("return", resolve(_this.token));
|
|
4760
|
+
return _context2.abrupt("return", resolve(_this.token));
|
|
4761
|
+
|
|
4762
|
+
case 2:
|
|
4763
|
+
if (!(_this.tokenProvider && typeof _this.tokenProvider !== 'string')) {
|
|
4764
|
+
_context2.next = 7;
|
|
4765
|
+
break;
|
|
4766
|
+
}
|
|
4767
|
+
|
|
4768
|
+
_context2.next = 5;
|
|
4769
|
+
return _this.tokenProvider();
|
|
4770
|
+
|
|
4771
|
+
case 5:
|
|
4772
|
+
_this.token = _context2.sent;
|
|
4773
|
+
resolve(_this.token);
|
|
4774
|
+
|
|
4775
|
+
case 7:
|
|
4776
|
+
case "end":
|
|
4777
|
+
return _context2.stop();
|
|
4778
|
+
}
|
|
4779
|
+
}
|
|
4780
|
+
}, _callee2);
|
|
4781
|
+
}));
|
|
4782
|
+
|
|
4783
|
+
return function (_x3) {
|
|
4784
|
+
return _ref2.apply(this, arguments);
|
|
4785
|
+
};
|
|
4786
|
+
}());
|
|
4787
|
+
return _this.loadTokenPromise;
|
|
4788
|
+
});
|
|
4789
|
+
|
|
4790
|
+
_defineProperty__default['default'](this, "getToken", function () {
|
|
4791
|
+
if (_this.token) {
|
|
4792
|
+
return _this.token;
|
|
4793
|
+
}
|
|
4794
|
+
|
|
4795
|
+
if (_this.user && _this.user.anon && !_this.token) {
|
|
4796
|
+
return _this.token;
|
|
4797
|
+
}
|
|
4798
|
+
|
|
4799
|
+
if (_this.secret) {
|
|
4800
|
+
return JWTServerToken(_this.secret);
|
|
4801
|
+
}
|
|
4802
|
+
|
|
4803
|
+
throw new Error("Both secret and user tokens are not set. Either client.connectUser wasn't called or client.disconnect was called");
|
|
4804
|
+
});
|
|
4805
|
+
|
|
4806
|
+
_defineProperty__default['default'](this, "isStatic", function () {
|
|
4807
|
+
return _this.type === 'static';
|
|
4808
|
+
});
|
|
4809
|
+
|
|
4810
|
+
this.loadTokenPromise = null;
|
|
4811
|
+
|
|
4812
|
+
if (secret) {
|
|
4813
|
+
this.secret = secret;
|
|
4814
|
+
}
|
|
4815
|
+
|
|
4816
|
+
this.type = 'static';
|
|
4817
|
+
|
|
4818
|
+
if (this.secret) {
|
|
4819
|
+
this.token = JWTServerToken(this.secret);
|
|
4820
|
+
}
|
|
4821
|
+
}
|
|
4822
|
+
/**
|
|
4823
|
+
* Set the static string token or token provider.
|
|
4824
|
+
* Token provider should return a token string or a promise which resolves to string token.
|
|
4825
|
+
*
|
|
4826
|
+
* @param {TokenOrProvider} tokenOrProvider
|
|
4827
|
+
* @param {UserResponse<UserType>} user
|
|
4828
|
+
*/
|
|
4829
|
+
;
|
|
4830
|
+
|
|
4831
|
+
var APIErrorCodes = {
|
|
4832
|
+
'-1': {
|
|
4833
|
+
name: 'InternalSystemError',
|
|
4834
|
+
retryable: true
|
|
4835
|
+
},
|
|
4836
|
+
'2': {
|
|
4837
|
+
name: 'AccessKeyError',
|
|
4838
|
+
retryable: false
|
|
4839
|
+
},
|
|
4840
|
+
'3': {
|
|
4841
|
+
name: 'AuthenticationFailedError',
|
|
4842
|
+
retryable: true
|
|
4843
|
+
},
|
|
4844
|
+
'4': {
|
|
4845
|
+
name: 'InputError',
|
|
4846
|
+
retryable: false
|
|
4847
|
+
},
|
|
4848
|
+
'6': {
|
|
4849
|
+
name: 'DuplicateUsernameError',
|
|
4850
|
+
retryable: false
|
|
4851
|
+
},
|
|
4852
|
+
'9': {
|
|
4853
|
+
name: 'RateLimitError',
|
|
4854
|
+
retryable: true
|
|
4855
|
+
},
|
|
4856
|
+
'16': {
|
|
4857
|
+
name: 'DoesNotExistError',
|
|
4858
|
+
retryable: false
|
|
4859
|
+
},
|
|
4860
|
+
'17': {
|
|
4861
|
+
name: 'NotAllowedError',
|
|
4862
|
+
retryable: false
|
|
4863
|
+
},
|
|
4864
|
+
'18': {
|
|
4865
|
+
name: 'EventNotSupportedError',
|
|
4866
|
+
retryable: false
|
|
4867
|
+
},
|
|
4868
|
+
'19': {
|
|
4869
|
+
name: 'ChannelFeatureNotSupportedError',
|
|
4870
|
+
retryable: false
|
|
4871
|
+
},
|
|
4872
|
+
'20': {
|
|
4873
|
+
name: 'MessageTooLongError',
|
|
4874
|
+
retryable: false
|
|
4875
|
+
},
|
|
4876
|
+
'21': {
|
|
4877
|
+
name: 'MultipleNestingLevelError',
|
|
4878
|
+
retryable: false
|
|
4879
|
+
},
|
|
4880
|
+
'22': {
|
|
4881
|
+
name: 'PayloadTooBigError',
|
|
4882
|
+
retryable: false
|
|
4883
|
+
},
|
|
4884
|
+
'23': {
|
|
4885
|
+
name: 'RequestTimeoutError',
|
|
4886
|
+
retryable: true
|
|
4887
|
+
},
|
|
4888
|
+
'24': {
|
|
4889
|
+
name: 'MaxHeaderSizeExceededError',
|
|
4890
|
+
retryable: false
|
|
4891
|
+
},
|
|
4892
|
+
'40': {
|
|
4893
|
+
name: 'AuthErrorTokenExpired',
|
|
4894
|
+
retryable: false
|
|
4895
|
+
},
|
|
4896
|
+
'41': {
|
|
4897
|
+
name: 'AuthErrorTokenNotValidYet',
|
|
4898
|
+
retryable: false
|
|
4899
|
+
},
|
|
4900
|
+
'42': {
|
|
4901
|
+
name: 'AuthErrorTokenUsedBeforeIssuedAt',
|
|
4902
|
+
retryable: false
|
|
4903
|
+
},
|
|
4904
|
+
'43': {
|
|
4905
|
+
name: 'AuthErrorTokenSignatureInvalid',
|
|
4906
|
+
retryable: false
|
|
4907
|
+
},
|
|
4908
|
+
'44': {
|
|
4909
|
+
name: 'CustomCommandEndpointMissingError',
|
|
4910
|
+
retryable: false
|
|
4911
|
+
},
|
|
4912
|
+
'45': {
|
|
4913
|
+
name: 'CustomCommandEndpointCallError',
|
|
4914
|
+
retryable: true
|
|
4915
|
+
},
|
|
4916
|
+
'46': {
|
|
4917
|
+
name: 'ConnectionIDNotFoundError',
|
|
4918
|
+
retryable: false
|
|
4919
|
+
},
|
|
4920
|
+
'60': {
|
|
4921
|
+
name: 'CoolDownError',
|
|
4922
|
+
retryable: true
|
|
4923
|
+
},
|
|
4924
|
+
'69': {
|
|
4925
|
+
name: 'ErrWrongRegion',
|
|
4926
|
+
retryable: false
|
|
4927
|
+
},
|
|
4928
|
+
'70': {
|
|
4929
|
+
name: 'ErrQueryChannelPermissions',
|
|
4930
|
+
retryable: false
|
|
4931
|
+
},
|
|
4932
|
+
'71': {
|
|
4933
|
+
name: 'ErrTooManyConnections',
|
|
4934
|
+
retryable: true
|
|
4935
|
+
},
|
|
4936
|
+
'99': {
|
|
4937
|
+
name: 'AppSuspendedError',
|
|
4938
|
+
retryable: false
|
|
4939
|
+
}
|
|
4940
|
+
};
|
|
4941
|
+
function isAPIError(error) {
|
|
4942
|
+
return error.code !== undefined;
|
|
4943
|
+
}
|
|
4944
|
+
function isErrorRetryable(error) {
|
|
4945
|
+
if (!error.code) return false;
|
|
4946
|
+
var err = APIErrorCodes["".concat(error.code)];
|
|
4947
|
+
if (!err) return false;
|
|
4948
|
+
return err.retryable;
|
|
4949
|
+
}
|
|
4950
|
+
function isConnectionIDError(error) {
|
|
4951
|
+
return error.code === 46; // ConnectionIDNotFoundError
|
|
4952
|
+
}
|
|
4953
|
+
function isWSFailure(err) {
|
|
4954
|
+
if (typeof err.isWSFailure === 'boolean') {
|
|
4955
|
+
return err.isWSFailure;
|
|
4956
|
+
}
|
|
4957
|
+
|
|
4958
|
+
try {
|
|
4959
|
+
return JSON.parse(err.message).isWSFailure;
|
|
4960
|
+
} catch (_) {
|
|
4961
|
+
return false;
|
|
4962
|
+
}
|
|
4963
|
+
}
|
|
4964
|
+
|
|
4965
|
+
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; }
|
|
4966
|
+
|
|
4967
|
+
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; }
|
|
4968
|
+
var ConnectionState;
|
|
4969
|
+
|
|
4970
|
+
(function (ConnectionState) {
|
|
4971
|
+
ConnectionState["Closed"] = "CLOSED";
|
|
4972
|
+
ConnectionState["Connected"] = "CONNECTED";
|
|
4973
|
+
ConnectionState["Connecting"] = "CONNECTING";
|
|
4974
|
+
ConnectionState["Disconnected"] = "DISCONNECTED";
|
|
4975
|
+
ConnectionState["Init"] = "INIT";
|
|
4976
|
+
})(ConnectionState || (ConnectionState = {}));
|
|
4977
|
+
|
|
4978
|
+
var WSConnectionFallback = /*#__PURE__*/function () {
|
|
4979
|
+
function WSConnectionFallback(_ref) {
|
|
4980
|
+
var _this = this;
|
|
4981
|
+
|
|
4982
|
+
var client = _ref.client;
|
|
4983
|
+
|
|
4984
|
+
_classCallCheck__default['default'](this, WSConnectionFallback);
|
|
4985
|
+
|
|
4986
|
+
_defineProperty__default['default'](this, "client", void 0);
|
|
4987
|
+
|
|
4988
|
+
_defineProperty__default['default'](this, "state", void 0);
|
|
4989
|
+
|
|
4990
|
+
_defineProperty__default['default'](this, "consecutiveFailures", void 0);
|
|
4991
|
+
|
|
4992
|
+
_defineProperty__default['default'](this, "connectionID", void 0);
|
|
4993
|
+
|
|
4994
|
+
_defineProperty__default['default'](this, "cancelToken", void 0);
|
|
4995
|
+
|
|
4996
|
+
_defineProperty__default['default'](this, "_onlineStatusChanged", function (event) {
|
|
4997
|
+
_this._log("_onlineStatusChanged() - ".concat(event.type));
|
|
4998
|
+
|
|
4999
|
+
if (event.type === 'offline') {
|
|
5000
|
+
var _this$cancelToken;
|
|
5001
|
+
|
|
5002
|
+
_this._setState(ConnectionState.Closed);
|
|
5003
|
+
|
|
5004
|
+
(_this$cancelToken = _this.cancelToken) === null || _this$cancelToken === void 0 ? void 0 : _this$cancelToken.cancel('disconnect() is called');
|
|
5005
|
+
_this.cancelToken = undefined;
|
|
5006
|
+
return;
|
|
5007
|
+
}
|
|
5008
|
+
|
|
5009
|
+
if (event.type === 'online' && _this.state === ConnectionState.Closed) {
|
|
5010
|
+
_this.connect(true);
|
|
5011
|
+
}
|
|
5012
|
+
});
|
|
5013
|
+
|
|
5014
|
+
_defineProperty__default['default'](this, "_req", /*#__PURE__*/function () {
|
|
5015
|
+
var _ref2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(params, config, retry) {
|
|
5016
|
+
var _this$cancelToken2, res;
|
|
5017
|
+
|
|
5018
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
5019
|
+
while (1) {
|
|
5020
|
+
switch (_context.prev = _context.next) {
|
|
5021
|
+
case 0:
|
|
5022
|
+
if (!_this.cancelToken && !params.close) {
|
|
5023
|
+
_this.cancelToken = axios__default['default'].CancelToken.source();
|
|
5024
|
+
}
|
|
5025
|
+
|
|
5026
|
+
_context.prev = 1;
|
|
5027
|
+
_context.next = 4;
|
|
5028
|
+
return _this.client.doAxiosRequest('get', _this.client.baseURL.replace(':3030', ':8900') + '/longpoll', // replace port if present for testing with local API
|
|
5029
|
+
undefined, {
|
|
5030
|
+
config: _objectSpread$1(_objectSpread$1({}, config), {}, {
|
|
5031
|
+
cancelToken: (_this$cancelToken2 = _this.cancelToken) === null || _this$cancelToken2 === void 0 ? void 0 : _this$cancelToken2.token
|
|
5032
|
+
}),
|
|
5033
|
+
params: params
|
|
5034
|
+
});
|
|
5035
|
+
|
|
5036
|
+
case 4:
|
|
5037
|
+
res = _context.sent;
|
|
5038
|
+
_this.consecutiveFailures = 0; // always reset in case of no error
|
|
5039
|
+
|
|
5040
|
+
return _context.abrupt("return", res);
|
|
5041
|
+
|
|
5042
|
+
case 9:
|
|
5043
|
+
_context.prev = 9;
|
|
5044
|
+
_context.t0 = _context["catch"](1);
|
|
5045
|
+
_this.consecutiveFailures += 1;
|
|
5046
|
+
|
|
5047
|
+
if (!(retry && isErrorRetryable(_context.t0))) {
|
|
5048
|
+
_context.next = 17;
|
|
5049
|
+
break;
|
|
5050
|
+
}
|
|
5051
|
+
|
|
5052
|
+
_this._log("_req() - Retryable error, retrying request");
|
|
5053
|
+
|
|
5054
|
+
_context.next = 16;
|
|
5055
|
+
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5056
|
+
|
|
5057
|
+
case 16:
|
|
5058
|
+
return _context.abrupt("return", _this._req(params, config, retry));
|
|
5059
|
+
|
|
5060
|
+
case 17:
|
|
5061
|
+
throw _context.t0;
|
|
5062
|
+
|
|
5063
|
+
case 18:
|
|
5064
|
+
case "end":
|
|
5065
|
+
return _context.stop();
|
|
5066
|
+
}
|
|
5067
|
+
}
|
|
5068
|
+
}, _callee, null, [[1, 9]]);
|
|
5069
|
+
}));
|
|
5070
|
+
|
|
5071
|
+
return function (_x, _x2, _x3) {
|
|
5072
|
+
return _ref2.apply(this, arguments);
|
|
5073
|
+
};
|
|
5074
|
+
}());
|
|
5075
|
+
|
|
5076
|
+
_defineProperty__default['default'](this, "_poll", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
|
|
5077
|
+
var _data$events, data, i;
|
|
5078
|
+
|
|
5079
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
5080
|
+
while (1) {
|
|
5081
|
+
switch (_context2.prev = _context2.next) {
|
|
5082
|
+
case 0:
|
|
5083
|
+
if (!(_this.state === ConnectionState.Connected)) {
|
|
5084
|
+
_context2.next = 25;
|
|
5085
|
+
break;
|
|
5086
|
+
}
|
|
5087
|
+
|
|
5088
|
+
_context2.prev = 1;
|
|
5089
|
+
_context2.next = 4;
|
|
5090
|
+
return _this._req({}, {
|
|
5091
|
+
timeout: 30000
|
|
5092
|
+
}, true);
|
|
5093
|
+
|
|
5094
|
+
case 4:
|
|
5095
|
+
data = _context2.sent;
|
|
5096
|
+
|
|
5097
|
+
// 30s => API responds in 20s if there is no event
|
|
5098
|
+
if ((_data$events = data.events) !== null && _data$events !== void 0 && _data$events.length) {
|
|
5099
|
+
for (i = 0; i < data.events.length; i++) {
|
|
5100
|
+
_this.client.dispatchEvent(data.events[i]);
|
|
5101
|
+
}
|
|
5102
|
+
}
|
|
5103
|
+
|
|
5104
|
+
_context2.next = 23;
|
|
5105
|
+
break;
|
|
5106
|
+
|
|
5107
|
+
case 8:
|
|
5108
|
+
_context2.prev = 8;
|
|
5109
|
+
_context2.t0 = _context2["catch"](1);
|
|
5110
|
+
|
|
5111
|
+
if (!axios__default['default'].isCancel(_context2.t0)) {
|
|
5112
|
+
_context2.next = 13;
|
|
5113
|
+
break;
|
|
5114
|
+
}
|
|
5115
|
+
|
|
5116
|
+
_this._log("_poll() - axios canceled request");
|
|
5117
|
+
|
|
5118
|
+
return _context2.abrupt("return");
|
|
5119
|
+
|
|
5120
|
+
case 13:
|
|
5121
|
+
if (!isConnectionIDError(_context2.t0)) {
|
|
5122
|
+
_context2.next = 18;
|
|
5123
|
+
break;
|
|
5124
|
+
}
|
|
5125
|
+
|
|
5126
|
+
_this._log("_poll() - ConnectionID error, connecting without ID...");
|
|
5127
|
+
|
|
5128
|
+
_this._setState(ConnectionState.Disconnected);
|
|
5129
|
+
|
|
5130
|
+
_this.connect(true);
|
|
5131
|
+
|
|
5132
|
+
return _context2.abrupt("return");
|
|
5133
|
+
|
|
5134
|
+
case 18:
|
|
5135
|
+
if (!(isAPIError(_context2.t0) && !isErrorRetryable(_context2.t0))) {
|
|
5136
|
+
_context2.next = 21;
|
|
5137
|
+
break;
|
|
5138
|
+
}
|
|
5139
|
+
|
|
5140
|
+
_this._setState(ConnectionState.Closed);
|
|
5141
|
+
|
|
5142
|
+
return _context2.abrupt("return");
|
|
5143
|
+
|
|
5144
|
+
case 21:
|
|
5145
|
+
_context2.next = 23;
|
|
5146
|
+
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5147
|
+
|
|
5148
|
+
case 23:
|
|
5149
|
+
_context2.next = 0;
|
|
5150
|
+
break;
|
|
5151
|
+
|
|
5152
|
+
case 25:
|
|
5153
|
+
case "end":
|
|
5154
|
+
return _context2.stop();
|
|
5155
|
+
}
|
|
5156
|
+
}
|
|
5157
|
+
}, _callee2, null, [[1, 8]]);
|
|
5158
|
+
})));
|
|
5159
|
+
|
|
5160
|
+
_defineProperty__default['default'](this, "connect", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
5161
|
+
var reconnect,
|
|
5162
|
+
_yield$_this$_req,
|
|
5163
|
+
event,
|
|
5164
|
+
_args3 = arguments;
|
|
5165
|
+
|
|
5166
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
5167
|
+
while (1) {
|
|
5168
|
+
switch (_context3.prev = _context3.next) {
|
|
5169
|
+
case 0:
|
|
5170
|
+
reconnect = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : false;
|
|
5171
|
+
|
|
5172
|
+
if (!(_this.state === ConnectionState.Connecting)) {
|
|
5173
|
+
_context3.next = 3;
|
|
5174
|
+
break;
|
|
5175
|
+
}
|
|
5176
|
+
|
|
5177
|
+
throw new Error('connecting already in progress');
|
|
5178
|
+
|
|
5179
|
+
case 3:
|
|
5180
|
+
if (!(_this.state === ConnectionState.Connected)) {
|
|
5181
|
+
_context3.next = 5;
|
|
5182
|
+
break;
|
|
5183
|
+
}
|
|
5184
|
+
|
|
5185
|
+
throw new Error('already connected and polling');
|
|
5186
|
+
|
|
5187
|
+
case 5:
|
|
5188
|
+
_this._setState(ConnectionState.Connecting);
|
|
5189
|
+
|
|
5190
|
+
_this.connectionID = undefined; // connect should be sent with empty connection_id so API creates one
|
|
5191
|
+
|
|
5192
|
+
_context3.prev = 7;
|
|
5193
|
+
_context3.next = 10;
|
|
5194
|
+
return _this._req({
|
|
5195
|
+
json: _this.client._buildWSPayload()
|
|
5196
|
+
}, {
|
|
5197
|
+
timeout: 8000
|
|
5198
|
+
}, // 8s
|
|
5199
|
+
reconnect);
|
|
5200
|
+
|
|
5201
|
+
case 10:
|
|
5202
|
+
_yield$_this$_req = _context3.sent;
|
|
5203
|
+
event = _yield$_this$_req.event;
|
|
5204
|
+
|
|
5205
|
+
_this._setState(ConnectionState.Connected);
|
|
5206
|
+
|
|
5207
|
+
_this.connectionID = event.connection_id;
|
|
5208
|
+
|
|
5209
|
+
_this._poll();
|
|
5210
|
+
|
|
5211
|
+
if (reconnect) {
|
|
5212
|
+
_this.client.recoverState();
|
|
5213
|
+
}
|
|
5214
|
+
|
|
5215
|
+
return _context3.abrupt("return", event);
|
|
5216
|
+
|
|
5217
|
+
case 19:
|
|
5218
|
+
_context3.prev = 19;
|
|
5219
|
+
_context3.t0 = _context3["catch"](7);
|
|
5220
|
+
|
|
5221
|
+
_this._setState(ConnectionState.Closed);
|
|
5222
|
+
|
|
5223
|
+
throw _context3.t0;
|
|
5224
|
+
|
|
5225
|
+
case 23:
|
|
5226
|
+
case "end":
|
|
5227
|
+
return _context3.stop();
|
|
5228
|
+
}
|
|
5229
|
+
}
|
|
5230
|
+
}, _callee3, null, [[7, 19]]);
|
|
5231
|
+
})));
|
|
5232
|
+
|
|
5233
|
+
_defineProperty__default['default'](this, "isHealthy", function () {
|
|
5234
|
+
return _this.connectionID && _this.state === ConnectionState.Connected;
|
|
5235
|
+
});
|
|
4752
5236
|
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
_context2.next = 7;
|
|
4756
|
-
break;
|
|
4757
|
-
}
|
|
5237
|
+
_defineProperty__default['default'](this, "disconnect", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4() {
|
|
5238
|
+
var _this$cancelToken3;
|
|
4758
5239
|
|
|
4759
|
-
|
|
4760
|
-
|
|
5240
|
+
var timeout,
|
|
5241
|
+
_args4 = arguments;
|
|
5242
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
5243
|
+
while (1) {
|
|
5244
|
+
switch (_context4.prev = _context4.next) {
|
|
5245
|
+
case 0:
|
|
5246
|
+
timeout = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : 2000;
|
|
5247
|
+
removeConnectionEventListeners(_this._onlineStatusChanged);
|
|
4761
5248
|
|
|
4762
|
-
|
|
4763
|
-
_this.token = _context2.sent;
|
|
4764
|
-
resolve(_this.token);
|
|
5249
|
+
_this._setState(ConnectionState.Disconnected);
|
|
4765
5250
|
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
5251
|
+
(_this$cancelToken3 = _this.cancelToken) === null || _this$cancelToken3 === void 0 ? void 0 : _this$cancelToken3.cancel('disconnect() is called');
|
|
5252
|
+
_this.cancelToken = undefined;
|
|
5253
|
+
_context4.prev = 5;
|
|
5254
|
+
_context4.next = 8;
|
|
5255
|
+
return _this._req({
|
|
5256
|
+
close: true
|
|
5257
|
+
}, {
|
|
5258
|
+
timeout: timeout
|
|
5259
|
+
}, false);
|
|
4773
5260
|
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
};
|
|
4777
|
-
}());
|
|
4778
|
-
return _this.loadTokenPromise;
|
|
4779
|
-
});
|
|
5261
|
+
case 8:
|
|
5262
|
+
_this.connectionID = undefined;
|
|
4780
5263
|
|
|
4781
|
-
|
|
4782
|
-
if (_this.token) {
|
|
4783
|
-
return _this.token;
|
|
4784
|
-
}
|
|
5264
|
+
_this._log("disconnect() - Closed connectionID");
|
|
4785
5265
|
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
}
|
|
5266
|
+
_context4.next = 15;
|
|
5267
|
+
break;
|
|
4789
5268
|
|
|
4790
|
-
|
|
4791
|
-
|
|
5269
|
+
case 12:
|
|
5270
|
+
_context4.prev = 12;
|
|
5271
|
+
_context4.t0 = _context4["catch"](5);
|
|
5272
|
+
|
|
5273
|
+
_this._log("disconnect() - Failed", {
|
|
5274
|
+
err: _context4.t0
|
|
5275
|
+
});
|
|
5276
|
+
|
|
5277
|
+
case 15:
|
|
5278
|
+
case "end":
|
|
5279
|
+
return _context4.stop();
|
|
5280
|
+
}
|
|
5281
|
+
}
|
|
5282
|
+
}, _callee4, null, [[5, 12]]);
|
|
5283
|
+
})));
|
|
5284
|
+
|
|
5285
|
+
this.client = client;
|
|
5286
|
+
this.state = ConnectionState.Init;
|
|
5287
|
+
this.consecutiveFailures = 0;
|
|
5288
|
+
addConnectionEventListeners(this._onlineStatusChanged);
|
|
5289
|
+
}
|
|
5290
|
+
|
|
5291
|
+
_createClass__default['default'](WSConnectionFallback, [{
|
|
5292
|
+
key: "_log",
|
|
5293
|
+
value: function _log(msg) {
|
|
5294
|
+
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5295
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
5296
|
+
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$1({
|
|
5297
|
+
tags: ['connection_fallback', 'connection']
|
|
5298
|
+
}, extra));
|
|
4792
5299
|
}
|
|
5300
|
+
}, {
|
|
5301
|
+
key: "_setState",
|
|
5302
|
+
value: function _setState(state) {
|
|
5303
|
+
this._log("_setState() - ".concat(state)); // transition from connecting => connected
|
|
4793
5304
|
|
|
4794
|
-
throw new Error("Both secret and user tokens are not set. Either client.connectUser wasn't called or client.disconnect was called");
|
|
4795
|
-
});
|
|
4796
5305
|
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
5306
|
+
if (this.state === ConnectionState.Connecting && state === ConnectionState.Connected) {
|
|
5307
|
+
//@ts-expect-error
|
|
5308
|
+
this.client.dispatchEvent({
|
|
5309
|
+
type: 'connection.changed',
|
|
5310
|
+
online: true
|
|
5311
|
+
});
|
|
5312
|
+
}
|
|
4800
5313
|
|
|
4801
|
-
|
|
5314
|
+
if (state === ConnectionState.Closed || state === ConnectionState.Disconnected) {
|
|
5315
|
+
//@ts-expect-error
|
|
5316
|
+
this.client.dispatchEvent({
|
|
5317
|
+
type: 'connection.changed',
|
|
5318
|
+
online: false
|
|
5319
|
+
});
|
|
5320
|
+
}
|
|
4802
5321
|
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
5322
|
+
this.state = state;
|
|
5323
|
+
}
|
|
5324
|
+
/** @private */
|
|
4806
5325
|
|
|
4807
|
-
|
|
5326
|
+
}]);
|
|
4808
5327
|
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
}
|
|
4812
|
-
}
|
|
4813
|
-
/**
|
|
4814
|
-
* Set the static string token or token provider.
|
|
4815
|
-
* Token provider should return a token string or a promise which resolves to string token.
|
|
4816
|
-
*
|
|
4817
|
-
* @param {TokenOrProvider} tokenOrProvider
|
|
4818
|
-
* @param {UserResponse<UserType>} user
|
|
4819
|
-
*/
|
|
4820
|
-
;
|
|
5328
|
+
return WSConnectionFallback;
|
|
5329
|
+
}();
|
|
4821
5330
|
|
|
4822
5331
|
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
5332
|
|
|
@@ -4857,10 +5366,6 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4857
5366
|
|
|
4858
5367
|
_defineProperty__default['default'](this, "configs", void 0);
|
|
4859
5368
|
|
|
4860
|
-
_defineProperty__default['default'](this, "connectionID", void 0);
|
|
4861
|
-
|
|
4862
|
-
_defineProperty__default['default'](this, "failures", void 0);
|
|
4863
|
-
|
|
4864
5369
|
_defineProperty__default['default'](this, "key", void 0);
|
|
4865
5370
|
|
|
4866
5371
|
_defineProperty__default['default'](this, "listeners", void 0);
|
|
@@ -4895,16 +5400,26 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4895
5400
|
|
|
4896
5401
|
_defineProperty__default['default'](this, "wsConnection", void 0);
|
|
4897
5402
|
|
|
5403
|
+
_defineProperty__default['default'](this, "wsFallback", void 0);
|
|
5404
|
+
|
|
4898
5405
|
_defineProperty__default['default'](this, "wsPromise", void 0);
|
|
4899
5406
|
|
|
4900
5407
|
_defineProperty__default['default'](this, "consecutiveFailures", void 0);
|
|
4901
5408
|
|
|
4902
5409
|
_defineProperty__default['default'](this, "insightMetrics", void 0);
|
|
4903
5410
|
|
|
4904
|
-
_defineProperty__default['default'](this, "
|
|
4905
|
-
|
|
5411
|
+
_defineProperty__default['default'](this, "defaultWSTimeoutWithFallback", void 0);
|
|
5412
|
+
|
|
5413
|
+
_defineProperty__default['default'](this, "defaultWSTimeout", void 0);
|
|
5414
|
+
|
|
5415
|
+
_defineProperty__default['default'](this, "_getConnectionID", function () {
|
|
5416
|
+
var _this$wsConnection, _this$wsFallback;
|
|
4906
5417
|
|
|
4907
|
-
return
|
|
5418
|
+
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);
|
|
5419
|
+
});
|
|
5420
|
+
|
|
5421
|
+
_defineProperty__default['default'](this, "_hasConnectionID", function () {
|
|
5422
|
+
return Boolean(_this._getConnectionID());
|
|
4908
5423
|
});
|
|
4909
5424
|
|
|
4910
5425
|
_defineProperty__default['default'](this, "connectUser", /*#__PURE__*/function () {
|
|
@@ -4990,36 +5505,55 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4990
5505
|
return _this.tokenManager.setTokenOrProvider(userTokenOrProvider, user);
|
|
4991
5506
|
});
|
|
4992
5507
|
|
|
4993
|
-
_defineProperty__default['default'](this, "closeConnection", function (
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
_this.cleaningIntervalRef = undefined;
|
|
4997
|
-
}
|
|
5508
|
+
_defineProperty__default['default'](this, "closeConnection", /*#__PURE__*/function () {
|
|
5509
|
+
var _ref2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2(timeout) {
|
|
5510
|
+
var _this$wsConnection2, _this$wsFallback2;
|
|
4998
5511
|
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5512
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
5513
|
+
while (1) {
|
|
5514
|
+
switch (_context2.prev = _context2.next) {
|
|
5515
|
+
case 0:
|
|
5516
|
+
if (_this.cleaningIntervalRef != null) {
|
|
5517
|
+
clearInterval(_this.cleaningIntervalRef);
|
|
5518
|
+
_this.cleaningIntervalRef = undefined;
|
|
5519
|
+
}
|
|
5002
5520
|
|
|
5003
|
-
|
|
5004
|
-
|
|
5521
|
+
_context2.next = 3;
|
|
5522
|
+
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
5523
|
|
|
5006
|
-
|
|
5007
|
-
|
|
5524
|
+
case 3:
|
|
5525
|
+
return _context2.abrupt("return", Promise.resolve());
|
|
5008
5526
|
|
|
5009
|
-
|
|
5527
|
+
case 4:
|
|
5528
|
+
case "end":
|
|
5529
|
+
return _context2.stop();
|
|
5530
|
+
}
|
|
5531
|
+
}
|
|
5532
|
+
}, _callee2);
|
|
5533
|
+
}));
|
|
5534
|
+
|
|
5535
|
+
return function (_x3) {
|
|
5536
|
+
return _ref2.apply(this, arguments);
|
|
5537
|
+
};
|
|
5538
|
+
}());
|
|
5539
|
+
|
|
5540
|
+
_defineProperty__default['default'](this, "openConnection", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
5541
|
+
var _this$wsConnection3, _this$wsFallback3;
|
|
5542
|
+
|
|
5543
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
5010
5544
|
while (1) {
|
|
5011
|
-
switch (
|
|
5545
|
+
switch (_context3.prev = _context3.next) {
|
|
5012
5546
|
case 0:
|
|
5013
5547
|
if (_this.userID) {
|
|
5014
|
-
|
|
5548
|
+
_context3.next = 2;
|
|
5015
5549
|
break;
|
|
5016
5550
|
}
|
|
5017
5551
|
|
|
5018
5552
|
throw Error('User is not set on client, use client.connectUser or client.connectAnonymousUser instead');
|
|
5019
5553
|
|
|
5020
5554
|
case 2:
|
|
5021
|
-
if (!((_this$
|
|
5022
|
-
|
|
5555
|
+
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())) {
|
|
5556
|
+
_context3.next = 5;
|
|
5023
5557
|
break;
|
|
5024
5558
|
}
|
|
5025
5559
|
|
|
@@ -5027,7 +5561,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5027
5561
|
tags: ['connection', 'client']
|
|
5028
5562
|
});
|
|
5029
5563
|
|
|
5030
|
-
return
|
|
5564
|
+
return _context3.abrupt("return", Promise.resolve());
|
|
5031
5565
|
|
|
5032
5566
|
case 5:
|
|
5033
5567
|
_this.clientID = "".concat(_this.userID, "--").concat(randomId());
|
|
@@ -5035,14 +5569,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5035
5569
|
|
|
5036
5570
|
_this._startCleaning();
|
|
5037
5571
|
|
|
5038
|
-
return
|
|
5572
|
+
return _context3.abrupt("return", _this.wsPromise);
|
|
5039
5573
|
|
|
5040
5574
|
case 9:
|
|
5041
5575
|
case "end":
|
|
5042
|
-
return
|
|
5576
|
+
return _context3.stop();
|
|
5043
5577
|
}
|
|
5044
5578
|
}
|
|
5045
|
-
},
|
|
5579
|
+
}, _callee3);
|
|
5046
5580
|
})));
|
|
5047
5581
|
|
|
5048
5582
|
_defineProperty__default['default'](this, "_setupConnection", this.openConnection);
|
|
@@ -5060,12 +5594,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5060
5594
|
});
|
|
5061
5595
|
|
|
5062
5596
|
_defineProperty__default['default'](this, "disconnectUser", /*#__PURE__*/function () {
|
|
5063
|
-
var
|
|
5597
|
+
var _ref4 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4(timeout) {
|
|
5064
5598
|
var closePromise, _i, _Object$values, _channel;
|
|
5065
5599
|
|
|
5066
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
5600
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
5067
5601
|
while (1) {
|
|
5068
|
-
switch (
|
|
5602
|
+
switch (_context4.prev = _context4.next) {
|
|
5069
5603
|
case 0:
|
|
5070
5604
|
_this.logger('info', 'client:disconnect() - Disconnecting the client', {
|
|
5071
5605
|
tags: ['connection', 'client']
|
|
@@ -5089,21 +5623,21 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5089
5623
|
|
|
5090
5624
|
_this.state = new ClientState(); // reset token manager
|
|
5091
5625
|
|
|
5092
|
-
_this.tokenManager.reset
|
|
5093
|
-
|
|
5626
|
+
setTimeout(_this.tokenManager.reset); // delay reseting to use token for disconnect calls
|
|
5627
|
+
// close the WS connection
|
|
5094
5628
|
|
|
5095
|
-
return
|
|
5629
|
+
return _context4.abrupt("return", closePromise);
|
|
5096
5630
|
|
|
5097
5631
|
case 11:
|
|
5098
5632
|
case "end":
|
|
5099
|
-
return
|
|
5633
|
+
return _context4.stop();
|
|
5100
5634
|
}
|
|
5101
5635
|
}
|
|
5102
|
-
},
|
|
5636
|
+
}, _callee4);
|
|
5103
5637
|
}));
|
|
5104
5638
|
|
|
5105
|
-
return function (
|
|
5106
|
-
return
|
|
5639
|
+
return function (_x4) {
|
|
5640
|
+
return _ref4.apply(this, arguments);
|
|
5107
5641
|
};
|
|
5108
5642
|
}());
|
|
5109
5643
|
|
|
@@ -5131,76 +5665,78 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5131
5665
|
_defineProperty__default['default'](this, "setAnonymousUser", this.connectAnonymousUser);
|
|
5132
5666
|
|
|
5133
5667
|
_defineProperty__default['default'](this, "doAxiosRequest", /*#__PURE__*/function () {
|
|
5134
|
-
var
|
|
5668
|
+
var _ref5 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(type, url, data) {
|
|
5135
5669
|
var options,
|
|
5136
5670
|
requestConfig,
|
|
5137
5671
|
response,
|
|
5138
|
-
|
|
5139
|
-
|
|
5672
|
+
_requestConfig$header,
|
|
5673
|
+
_args5 = arguments;
|
|
5674
|
+
|
|
5675
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
|
|
5140
5676
|
while (1) {
|
|
5141
|
-
switch (
|
|
5677
|
+
switch (_context5.prev = _context5.next) {
|
|
5142
5678
|
case 0:
|
|
5143
|
-
options =
|
|
5144
|
-
|
|
5679
|
+
options = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : {};
|
|
5680
|
+
_context5.next = 3;
|
|
5145
5681
|
return _this.tokenManager.tokenReady();
|
|
5146
5682
|
|
|
5147
5683
|
case 3:
|
|
5148
5684
|
requestConfig = _this._enrichAxiosOptions(options);
|
|
5149
|
-
|
|
5685
|
+
_context5.prev = 4;
|
|
5150
5686
|
|
|
5151
5687
|
_this._logApiRequest(type, url, data, requestConfig);
|
|
5152
5688
|
|
|
5153
|
-
|
|
5154
|
-
|
|
5689
|
+
_context5.t0 = type;
|
|
5690
|
+
_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;
|
|
5155
5691
|
break;
|
|
5156
5692
|
|
|
5157
5693
|
case 9:
|
|
5158
|
-
|
|
5694
|
+
_context5.next = 11;
|
|
5159
5695
|
return _this.axiosInstance.get(url, requestConfig);
|
|
5160
5696
|
|
|
5161
5697
|
case 11:
|
|
5162
|
-
response =
|
|
5163
|
-
return
|
|
5698
|
+
response = _context5.sent;
|
|
5699
|
+
return _context5.abrupt("break", 34);
|
|
5164
5700
|
|
|
5165
5701
|
case 13:
|
|
5166
|
-
|
|
5702
|
+
_context5.next = 15;
|
|
5167
5703
|
return _this.axiosInstance.delete(url, requestConfig);
|
|
5168
5704
|
|
|
5169
5705
|
case 15:
|
|
5170
|
-
response =
|
|
5171
|
-
return
|
|
5706
|
+
response = _context5.sent;
|
|
5707
|
+
return _context5.abrupt("break", 34);
|
|
5172
5708
|
|
|
5173
5709
|
case 17:
|
|
5174
|
-
|
|
5710
|
+
_context5.next = 19;
|
|
5175
5711
|
return _this.axiosInstance.post(url, data, requestConfig);
|
|
5176
5712
|
|
|
5177
5713
|
case 19:
|
|
5178
|
-
response =
|
|
5179
|
-
return
|
|
5714
|
+
response = _context5.sent;
|
|
5715
|
+
return _context5.abrupt("break", 34);
|
|
5180
5716
|
|
|
5181
5717
|
case 21:
|
|
5182
|
-
|
|
5718
|
+
_context5.next = 23;
|
|
5183
5719
|
return _this.axiosInstance.put(url, data, requestConfig);
|
|
5184
5720
|
|
|
5185
5721
|
case 23:
|
|
5186
|
-
response =
|
|
5187
|
-
return
|
|
5722
|
+
response = _context5.sent;
|
|
5723
|
+
return _context5.abrupt("break", 34);
|
|
5188
5724
|
|
|
5189
5725
|
case 25:
|
|
5190
|
-
|
|
5726
|
+
_context5.next = 27;
|
|
5191
5727
|
return _this.axiosInstance.patch(url, data, requestConfig);
|
|
5192
5728
|
|
|
5193
5729
|
case 27:
|
|
5194
|
-
response =
|
|
5195
|
-
return
|
|
5730
|
+
response = _context5.sent;
|
|
5731
|
+
return _context5.abrupt("break", 34);
|
|
5196
5732
|
|
|
5197
5733
|
case 29:
|
|
5198
|
-
|
|
5734
|
+
_context5.next = 31;
|
|
5199
5735
|
return _this.axiosInstance.options(url, requestConfig);
|
|
5200
5736
|
|
|
5201
5737
|
case 31:
|
|
5202
|
-
response =
|
|
5203
|
-
return
|
|
5738
|
+
response = _context5.sent;
|
|
5739
|
+
return _context5.abrupt("break", 34);
|
|
5204
5740
|
|
|
5205
5741
|
case 33:
|
|
5206
5742
|
throw new Error('Invalid request type');
|
|
@@ -5209,64 +5745,66 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5209
5745
|
_this._logApiResponse(type, url, response);
|
|
5210
5746
|
|
|
5211
5747
|
_this.consecutiveFailures = 0;
|
|
5212
|
-
return
|
|
5748
|
+
return _context5.abrupt("return", _this.handleResponse(response));
|
|
5213
5749
|
|
|
5214
5750
|
case 39:
|
|
5215
|
-
|
|
5216
|
-
|
|
5751
|
+
_context5.prev = 39;
|
|
5752
|
+
_context5.t1 = _context5["catch"](4);
|
|
5753
|
+
_context5.t1.client_request_id = (_requestConfig$header = requestConfig.headers) === null || _requestConfig$header === void 0 ? void 0 : _requestConfig$header['x-client-request-id'];
|
|
5217
5754
|
|
|
5218
|
-
_this._logApiError(type, url,
|
|
5755
|
+
_this._logApiError(type, url, _context5.t1);
|
|
5219
5756
|
|
|
5220
5757
|
_this.consecutiveFailures += 1;
|
|
5221
5758
|
|
|
5222
|
-
if (!
|
|
5223
|
-
|
|
5759
|
+
if (!_context5.t1.response) {
|
|
5760
|
+
_context5.next = 56;
|
|
5224
5761
|
break;
|
|
5225
5762
|
}
|
|
5226
5763
|
|
|
5227
|
-
if (!(
|
|
5228
|
-
|
|
5764
|
+
if (!(_context5.t1.response.data.code === chatCodes.TOKEN_EXPIRED && !_this.tokenManager.isStatic())) {
|
|
5765
|
+
_context5.next = 53;
|
|
5229
5766
|
break;
|
|
5230
5767
|
}
|
|
5231
5768
|
|
|
5232
5769
|
if (!(_this.consecutiveFailures > 1)) {
|
|
5233
|
-
|
|
5770
|
+
_context5.next = 49;
|
|
5234
5771
|
break;
|
|
5235
5772
|
}
|
|
5236
5773
|
|
|
5237
|
-
|
|
5774
|
+
_context5.next = 49;
|
|
5238
5775
|
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5239
5776
|
|
|
5240
|
-
case
|
|
5777
|
+
case 49:
|
|
5241
5778
|
_this.tokenManager.loadToken();
|
|
5242
5779
|
|
|
5243
|
-
|
|
5780
|
+
_context5.next = 52;
|
|
5244
5781
|
return _this.doAxiosRequest(type, url, data, options);
|
|
5245
5782
|
|
|
5246
|
-
case 51:
|
|
5247
|
-
return _context4.abrupt("return", _context4.sent);
|
|
5248
|
-
|
|
5249
5783
|
case 52:
|
|
5250
|
-
return
|
|
5784
|
+
return _context5.abrupt("return", _context5.sent);
|
|
5251
5785
|
|
|
5252
|
-
case
|
|
5253
|
-
|
|
5786
|
+
case 53:
|
|
5787
|
+
return _context5.abrupt("return", _this.handleResponse(_context5.t1.response));
|
|
5254
5788
|
|
|
5255
5789
|
case 56:
|
|
5790
|
+
throw _context5.t1;
|
|
5791
|
+
|
|
5792
|
+
case 57:
|
|
5256
5793
|
case "end":
|
|
5257
|
-
return
|
|
5794
|
+
return _context5.stop();
|
|
5258
5795
|
}
|
|
5259
5796
|
}
|
|
5260
|
-
},
|
|
5797
|
+
}, _callee5, null, [[4, 39]]);
|
|
5261
5798
|
}));
|
|
5262
5799
|
|
|
5263
|
-
return function (
|
|
5264
|
-
return
|
|
5800
|
+
return function (_x5, _x6, _x7) {
|
|
5801
|
+
return _ref5.apply(this, arguments);
|
|
5265
5802
|
};
|
|
5266
5803
|
}());
|
|
5267
5804
|
|
|
5268
5805
|
_defineProperty__default['default'](this, "dispatchEvent", function (event) {
|
|
5269
|
-
// client event handlers
|
|
5806
|
+
if (!event.received_at) event.received_at = new Date(); // client event handlers
|
|
5807
|
+
|
|
5270
5808
|
var postListenerCallbacks = _this._handleClientEvent(event); // channel event handlers
|
|
5271
5809
|
|
|
5272
5810
|
|
|
@@ -5292,7 +5830,6 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5292
5830
|
// dispatch the event to the channel listeners
|
|
5293
5831
|
var jsonString = messageEvent.data;
|
|
5294
5832
|
var event = JSON.parse(jsonString);
|
|
5295
|
-
event.received_at = new Date();
|
|
5296
5833
|
|
|
5297
5834
|
_this.dispatchEvent(event);
|
|
5298
5835
|
});
|
|
@@ -5413,22 +5950,20 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5413
5950
|
}
|
|
5414
5951
|
});
|
|
5415
5952
|
|
|
5416
|
-
_defineProperty__default['default'](this, "recoverState", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
5417
|
-
var _this$wsConnection3;
|
|
5418
|
-
|
|
5953
|
+
_defineProperty__default['default'](this, "recoverState", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee6() {
|
|
5419
5954
|
var cids;
|
|
5420
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
5955
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee6$(_context6) {
|
|
5421
5956
|
while (1) {
|
|
5422
|
-
switch (
|
|
5957
|
+
switch (_context6.prev = _context6.next) {
|
|
5423
5958
|
case 0:
|
|
5424
|
-
_this.logger('info', "client:recoverState() - Start of recoverState with connectionID ".concat(
|
|
5959
|
+
_this.logger('info', "client:recoverState() - Start of recoverState with connectionID ".concat(_this._getConnectionID()), {
|
|
5425
5960
|
tags: ['connection']
|
|
5426
5961
|
});
|
|
5427
5962
|
|
|
5428
5963
|
cids = Object.keys(_this.activeChannels);
|
|
5429
5964
|
|
|
5430
5965
|
if (!(cids.length && _this.recoverStateOnReconnect)) {
|
|
5431
|
-
|
|
5966
|
+
_context6.next = 10;
|
|
5432
5967
|
break;
|
|
5433
5968
|
}
|
|
5434
5969
|
|
|
@@ -5436,7 +5971,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5436
5971
|
tags: ['connection', 'client']
|
|
5437
5972
|
});
|
|
5438
5973
|
|
|
5439
|
-
|
|
5974
|
+
_context6.next = 6;
|
|
5440
5975
|
return _this.queryChannels({
|
|
5441
5976
|
cid: {
|
|
5442
5977
|
$in: cids
|
|
@@ -5456,7 +5991,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5456
5991
|
type: 'connection.recovered'
|
|
5457
5992
|
});
|
|
5458
5993
|
|
|
5459
|
-
|
|
5994
|
+
_context6.next = 11;
|
|
5460
5995
|
break;
|
|
5461
5996
|
|
|
5462
5997
|
case 10:
|
|
@@ -5470,10 +6005,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5470
6005
|
|
|
5471
6006
|
case 13:
|
|
5472
6007
|
case "end":
|
|
5473
|
-
return
|
|
6008
|
+
return _context6.stop();
|
|
5474
6009
|
}
|
|
5475
6010
|
}
|
|
5476
|
-
},
|
|
6011
|
+
}, _callee6);
|
|
5477
6012
|
})));
|
|
5478
6013
|
|
|
5479
6014
|
_defineProperty__default['default'](this, "getChannelByMembers", function (channelType, custom) {
|
|
@@ -5553,66 +6088,16 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5553
6088
|
return !!_this.secret;
|
|
5554
6089
|
});
|
|
5555
6090
|
|
|
5556
|
-
_defineProperty__default['default'](this, "
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
case 2:
|
|
5567
|
-
if (!(i < maxAttempts)) {
|
|
5568
|
-
_context6.next = 18;
|
|
5569
|
-
break;
|
|
5570
|
-
}
|
|
5571
|
-
|
|
5572
|
-
_context6.prev = 3;
|
|
5573
|
-
_context6.next = 6;
|
|
5574
|
-
return _this.axiosInstance.post("https://chat-insights.getstream.io/insights/".concat(insightType), insights);
|
|
5575
|
-
|
|
5576
|
-
case 6:
|
|
5577
|
-
_context6.next = 14;
|
|
5578
|
-
break;
|
|
5579
|
-
|
|
5580
|
-
case 8:
|
|
5581
|
-
_context6.prev = 8;
|
|
5582
|
-
_context6.t0 = _context6["catch"](3);
|
|
5583
|
-
|
|
5584
|
-
_this.logger('warn', "failed to send insights event ".concat(insightType), {
|
|
5585
|
-
tags: ['insights', 'connection'],
|
|
5586
|
-
error: _context6.t0,
|
|
5587
|
-
insights: insights
|
|
5588
|
-
});
|
|
5589
|
-
|
|
5590
|
-
_context6.next = 13;
|
|
5591
|
-
return sleep((i + 1) * 3000);
|
|
5592
|
-
|
|
5593
|
-
case 13:
|
|
5594
|
-
return _context6.abrupt("continue", 15);
|
|
5595
|
-
|
|
5596
|
-
case 14:
|
|
5597
|
-
return _context6.abrupt("break", 18);
|
|
5598
|
-
|
|
5599
|
-
case 15:
|
|
5600
|
-
i++;
|
|
5601
|
-
_context6.next = 2;
|
|
5602
|
-
break;
|
|
5603
|
-
|
|
5604
|
-
case 18:
|
|
5605
|
-
case "end":
|
|
5606
|
-
return _context6.stop();
|
|
5607
|
-
}
|
|
5608
|
-
}
|
|
5609
|
-
}, _callee6, null, [[3, 8]]);
|
|
5610
|
-
}));
|
|
5611
|
-
|
|
5612
|
-
return function (_x7, _x8) {
|
|
5613
|
-
return _ref6.apply(this, arguments);
|
|
5614
|
-
};
|
|
5615
|
-
}());
|
|
6091
|
+
_defineProperty__default['default'](this, "_buildWSPayload", function (client_request_id) {
|
|
6092
|
+
return JSON.stringify({
|
|
6093
|
+
user_id: _this.userID,
|
|
6094
|
+
user_details: _this._user,
|
|
6095
|
+
user_token: _this.tokenManager.getToken(),
|
|
6096
|
+
server_determines_connection_id: true,
|
|
6097
|
+
device: _this.options.device,
|
|
6098
|
+
client_request_id: client_request_id
|
|
6099
|
+
});
|
|
6100
|
+
});
|
|
5616
6101
|
|
|
5617
6102
|
// set the key
|
|
5618
6103
|
this.key = _key;
|
|
@@ -5646,7 +6131,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5646
6131
|
}
|
|
5647
6132
|
|
|
5648
6133
|
this.axiosInstance = axios__default['default'].create(this.options);
|
|
5649
|
-
this.setBaseURL(this.options.baseURL || 'https://chat
|
|
6134
|
+
this.setBaseURL(this.options.baseURL || 'https://chat.stream-io-api.com');
|
|
5650
6135
|
|
|
5651
6136
|
if (typeof process !== 'undefined' && process.env.STREAM_LOCAL_TEST_RUN) {
|
|
5652
6137
|
this.setBaseURL('http://localhost:3030');
|
|
@@ -5670,6 +6155,8 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5670
6155
|
this.tokenManager = new TokenManager(this.secret);
|
|
5671
6156
|
this.consecutiveFailures = 0;
|
|
5672
6157
|
this.insightMetrics = new InsightMetrics();
|
|
6158
|
+
this.defaultWSTimeoutWithFallback = 6000;
|
|
6159
|
+
this.defaultWSTimeout = 15000;
|
|
5673
6160
|
/**
|
|
5674
6161
|
* logger function should accept 3 parameters:
|
|
5675
6162
|
* @param logLevel string
|
|
@@ -5843,7 +6330,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5843
6330
|
}, _callee7, this);
|
|
5844
6331
|
}));
|
|
5845
6332
|
|
|
5846
|
-
function updateAppSettings(
|
|
6333
|
+
function updateAppSettings(_x8) {
|
|
5847
6334
|
return _updateAppSettings.apply(this, arguments);
|
|
5848
6335
|
}
|
|
5849
6336
|
|
|
@@ -5877,7 +6364,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5877
6364
|
}, _callee8, this);
|
|
5878
6365
|
}));
|
|
5879
6366
|
|
|
5880
|
-
function revokeTokens(
|
|
6367
|
+
function revokeTokens(_x9) {
|
|
5881
6368
|
return _revokeTokens.apply(this, arguments);
|
|
5882
6369
|
}
|
|
5883
6370
|
|
|
@@ -5909,7 +6396,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5909
6396
|
}, _callee9, this);
|
|
5910
6397
|
}));
|
|
5911
6398
|
|
|
5912
|
-
function revokeUserToken(
|
|
6399
|
+
function revokeUserToken(_x10, _x11) {
|
|
5913
6400
|
return _revokeUserToken.apply(this, arguments);
|
|
5914
6401
|
}
|
|
5915
6402
|
|
|
@@ -5968,7 +6455,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5968
6455
|
}, _callee10, this);
|
|
5969
6456
|
}));
|
|
5970
6457
|
|
|
5971
|
-
function revokeUsersToken(
|
|
6458
|
+
function revokeUsersToken(_x12, _x13) {
|
|
5972
6459
|
return _revokeUsersToken.apply(this, arguments);
|
|
5973
6460
|
}
|
|
5974
6461
|
|
|
@@ -6060,7 +6547,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6060
6547
|
}, _callee12, this);
|
|
6061
6548
|
}));
|
|
6062
6549
|
|
|
6063
|
-
function testPushSettings(
|
|
6550
|
+
function testPushSettings(_x14) {
|
|
6064
6551
|
return _testPushSettings.apply(this, arguments);
|
|
6065
6552
|
}
|
|
6066
6553
|
|
|
@@ -6169,7 +6656,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6169
6656
|
}, _callee14, this, [[1, 7]]);
|
|
6170
6657
|
}));
|
|
6171
6658
|
|
|
6172
|
-
function setGuestUser(
|
|
6659
|
+
function setGuestUser(_x15) {
|
|
6173
6660
|
return _setGuestUser.apply(this, arguments);
|
|
6174
6661
|
}
|
|
6175
6662
|
|
|
@@ -6480,90 +6967,84 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6480
6967
|
*/
|
|
6481
6968
|
function () {
|
|
6482
6969
|
var _connect = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee15() {
|
|
6483
|
-
var client, warmUpPromise, handshake;
|
|
6484
6970
|
return _regeneratorRuntime__default['default'].wrap(function _callee15$(_context15) {
|
|
6485
6971
|
while (1) {
|
|
6486
6972
|
switch (_context15.prev = _context15.next) {
|
|
6487
6973
|
case 0:
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
if (!(client.userID == null || this._user == null)) {
|
|
6492
|
-
_context15.next = 4;
|
|
6974
|
+
if (!(!this.userID || !this._user)) {
|
|
6975
|
+
_context15.next = 2;
|
|
6493
6976
|
break;
|
|
6494
6977
|
}
|
|
6495
6978
|
|
|
6496
6979
|
throw Error('Call connectUser or connectAnonymousUser before starting the connection');
|
|
6497
6980
|
|
|
6498
|
-
case
|
|
6499
|
-
if (
|
|
6500
|
-
_context15.next =
|
|
6981
|
+
case 2:
|
|
6982
|
+
if (this.wsBaseURL) {
|
|
6983
|
+
_context15.next = 4;
|
|
6501
6984
|
break;
|
|
6502
6985
|
}
|
|
6503
6986
|
|
|
6504
6987
|
throw Error('Websocket base url not set');
|
|
6505
6988
|
|
|
6506
|
-
case
|
|
6507
|
-
if (
|
|
6508
|
-
_context15.next =
|
|
6989
|
+
case 4:
|
|
6990
|
+
if (this.clientID) {
|
|
6991
|
+
_context15.next = 6;
|
|
6509
6992
|
break;
|
|
6510
6993
|
}
|
|
6511
6994
|
|
|
6512
6995
|
throw Error('clientID is not set');
|
|
6513
6996
|
|
|
6514
|
-
case
|
|
6515
|
-
|
|
6997
|
+
case 6:
|
|
6998
|
+
if (!this.wsConnection && (this.options.warmUp || this.options.enableInsights)) {
|
|
6999
|
+
this._sayHi();
|
|
7000
|
+
} // The StableWSConnection handles all the reconnection logic.
|
|
7001
|
+
|
|
7002
|
+
|
|
6516
7003
|
this.wsConnection = new StableWSConnection({
|
|
6517
|
-
|
|
6518
|
-
clientID: client.clientID,
|
|
6519
|
-
userID: client.userID,
|
|
6520
|
-
tokenManager: client.tokenManager,
|
|
6521
|
-
user: this._user,
|
|
6522
|
-
authType: this.getAuthType(),
|
|
6523
|
-
userAgent: this.getUserAgent(),
|
|
6524
|
-
apiKey: this.key,
|
|
6525
|
-
recoverCallback: this.recoverState,
|
|
6526
|
-
messageCallback: this.handleEvent,
|
|
6527
|
-
eventCallback: this.dispatchEvent,
|
|
6528
|
-
logger: this.logger,
|
|
6529
|
-
device: this.options.device,
|
|
6530
|
-
postInsights: this.options.enableInsights ? this.postInsights : undefined,
|
|
6531
|
-
insightMetrics: this.insightMetrics
|
|
7004
|
+
client: this
|
|
6532
7005
|
});
|
|
7006
|
+
_context15.prev = 8;
|
|
7007
|
+
_context15.next = 11;
|
|
7008
|
+
return this.wsConnection.connect(this.options.enableWSFallback ? this.defaultWSTimeoutWithFallback : this.defaultWSTimeout);
|
|
6533
7009
|
|
|
6534
|
-
|
|
6535
|
-
|
|
7010
|
+
case 11:
|
|
7011
|
+
return _context15.abrupt("return", _context15.sent);
|
|
7012
|
+
|
|
7013
|
+
case 14:
|
|
7014
|
+
_context15.prev = 14;
|
|
7015
|
+
_context15.t0 = _context15["catch"](8);
|
|
7016
|
+
|
|
7017
|
+
if (!(this.options.enableWSFallback && isWSFailure(_context15.t0) && isOnline())) {
|
|
7018
|
+
_context15.next = 24;
|
|
7019
|
+
break;
|
|
6536
7020
|
}
|
|
6537
7021
|
|
|
6538
|
-
|
|
6539
|
-
|
|
7022
|
+
this.logger('info', 'client:connect() - WS failed, fallback to longpoll', {
|
|
7023
|
+
tags: ['connection', 'client']
|
|
7024
|
+
});
|
|
6540
7025
|
|
|
6541
|
-
|
|
6542
|
-
handshake = _context15.sent;
|
|
6543
|
-
_context15.prev = 13;
|
|
6544
|
-
_context15.next = 16;
|
|
6545
|
-
return warmUpPromise;
|
|
7026
|
+
this.wsConnection._destroyCurrentWSConnection();
|
|
6546
7027
|
|
|
6547
|
-
|
|
6548
|
-
_context15.next = 21;
|
|
6549
|
-
break;
|
|
7028
|
+
this.wsConnection.disconnect().then(); // close WS so no retry
|
|
6550
7029
|
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
_context15.t0 = _context15["catch"](13);
|
|
6554
|
-
this.logger('error', 'Warmup request failed', {
|
|
6555
|
-
error: _context15.t0
|
|
7030
|
+
this.wsFallback = new WSConnectionFallback({
|
|
7031
|
+
client: this
|
|
6556
7032
|
});
|
|
7033
|
+
_context15.next = 23;
|
|
7034
|
+
return this.wsFallback.connect();
|
|
6557
7035
|
|
|
6558
|
-
case
|
|
6559
|
-
return _context15.abrupt("return",
|
|
7036
|
+
case 23:
|
|
7037
|
+
return _context15.abrupt("return", _context15.sent);
|
|
6560
7038
|
|
|
6561
|
-
case
|
|
7039
|
+
case 24:
|
|
7040
|
+
throw _context15.t0;
|
|
7041
|
+
|
|
7042
|
+
case 25:
|
|
6562
7043
|
case "end":
|
|
6563
7044
|
return _context15.stop();
|
|
6564
7045
|
}
|
|
6565
7046
|
}
|
|
6566
|
-
}, _callee15, this, [[
|
|
7047
|
+
}, _callee15, this, [[8, 14]]);
|
|
6567
7048
|
}));
|
|
6568
7049
|
|
|
6569
7050
|
function connect() {
|
|
@@ -6572,6 +7053,33 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6572
7053
|
|
|
6573
7054
|
return connect;
|
|
6574
7055
|
}()
|
|
7056
|
+
/**
|
|
7057
|
+
* Check the connectivity with server for warmup purpose.
|
|
7058
|
+
*
|
|
7059
|
+
* @private
|
|
7060
|
+
*/
|
|
7061
|
+
|
|
7062
|
+
}, {
|
|
7063
|
+
key: "_sayHi",
|
|
7064
|
+
value: function _sayHi() {
|
|
7065
|
+
var _this4 = this;
|
|
7066
|
+
|
|
7067
|
+
var client_request_id = randomId();
|
|
7068
|
+
var opts = {
|
|
7069
|
+
headers: {
|
|
7070
|
+
'x-client-request-id': client_request_id
|
|
7071
|
+
}
|
|
7072
|
+
};
|
|
7073
|
+
this.doAxiosRequest('get', this.baseURL + '/hi', null, opts).catch(function (e) {
|
|
7074
|
+
if (_this4.options.enableInsights) {
|
|
7075
|
+
postInsights('http_hi_failed', {
|
|
7076
|
+
api_key: _this4.key,
|
|
7077
|
+
err: e,
|
|
7078
|
+
client_request_id: client_request_id
|
|
7079
|
+
});
|
|
7080
|
+
}
|
|
7081
|
+
});
|
|
7082
|
+
}
|
|
6575
7083
|
/**
|
|
6576
7084
|
* queryUsers - Query users and watch user presence
|
|
6577
7085
|
*
|
|
@@ -6632,7 +7140,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6632
7140
|
}, _callee16, this);
|
|
6633
7141
|
}));
|
|
6634
7142
|
|
|
6635
|
-
function queryUsers(
|
|
7143
|
+
function queryUsers(_x16) {
|
|
6636
7144
|
return _queryUsers.apply(this, arguments);
|
|
6637
7145
|
}
|
|
6638
7146
|
|
|
@@ -6851,7 +7359,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6851
7359
|
}, _callee19, this);
|
|
6852
7360
|
}));
|
|
6853
7361
|
|
|
6854
|
-
function queryChannels(
|
|
7362
|
+
function queryChannels(_x17) {
|
|
6855
7363
|
return _queryChannels.apply(this, arguments);
|
|
6856
7364
|
}
|
|
6857
7365
|
|
|
@@ -6937,7 +7445,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6937
7445
|
}, _callee20, this);
|
|
6938
7446
|
}));
|
|
6939
7447
|
|
|
6940
|
-
function search(
|
|
7448
|
+
function search(_x18, _x19) {
|
|
6941
7449
|
return _search.apply(this, arguments);
|
|
6942
7450
|
}
|
|
6943
7451
|
|
|
@@ -6955,7 +7463,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6955
7463
|
}, {
|
|
6956
7464
|
key: "setLocalDevice",
|
|
6957
7465
|
value: function setLocalDevice(device) {
|
|
6958
|
-
if (this.wsConnection) {
|
|
7466
|
+
if (this.wsConnection || this.wsFallback) {
|
|
6959
7467
|
throw new Error('you can only set device before opening a websocket connection');
|
|
6960
7468
|
}
|
|
6961
7469
|
|
|
@@ -6997,7 +7505,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6997
7505
|
}, _callee21, this);
|
|
6998
7506
|
}));
|
|
6999
7507
|
|
|
7000
|
-
function addDevice(_x21, _x22
|
|
7508
|
+
function addDevice(_x20, _x21, _x22) {
|
|
7001
7509
|
return _addDevice.apply(this, arguments);
|
|
7002
7510
|
}
|
|
7003
7511
|
|
|
@@ -7035,7 +7543,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7035
7543
|
}, _callee22, this);
|
|
7036
7544
|
}));
|
|
7037
7545
|
|
|
7038
|
-
function getDevices(
|
|
7546
|
+
function getDevices(_x23) {
|
|
7039
7547
|
return _getDevices.apply(this, arguments);
|
|
7040
7548
|
}
|
|
7041
7549
|
|
|
@@ -7075,7 +7583,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7075
7583
|
}, _callee23, this);
|
|
7076
7584
|
}));
|
|
7077
7585
|
|
|
7078
|
-
function removeDevice(
|
|
7586
|
+
function removeDevice(_x24, _x25) {
|
|
7079
7587
|
return _removeDevice.apply(this, arguments);
|
|
7080
7588
|
}
|
|
7081
7589
|
|
|
@@ -7116,7 +7624,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7116
7624
|
}, _callee24, this);
|
|
7117
7625
|
}));
|
|
7118
7626
|
|
|
7119
|
-
function getRateLimits(
|
|
7627
|
+
function getRateLimits(_x26) {
|
|
7120
7628
|
return _getRateLimits.apply(this, arguments);
|
|
7121
7629
|
}
|
|
7122
7630
|
|
|
@@ -7217,7 +7725,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7217
7725
|
}, _callee25, this);
|
|
7218
7726
|
}));
|
|
7219
7727
|
|
|
7220
|
-
function partialUpdateUser(
|
|
7728
|
+
function partialUpdateUser(_x27) {
|
|
7221
7729
|
return _partialUpdateUser.apply(this, arguments);
|
|
7222
7730
|
}
|
|
7223
7731
|
|
|
@@ -7303,7 +7811,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7303
7811
|
}, _callee26, this, [[2, 13, 16, 19]]);
|
|
7304
7812
|
}));
|
|
7305
7813
|
|
|
7306
|
-
function upsertUsers(
|
|
7814
|
+
function upsertUsers(_x28) {
|
|
7307
7815
|
return _upsertUsers.apply(this, arguments);
|
|
7308
7816
|
}
|
|
7309
7817
|
|
|
@@ -7416,7 +7924,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7416
7924
|
}, _callee27, this, [[1, 11, 14, 17]]);
|
|
7417
7925
|
}));
|
|
7418
7926
|
|
|
7419
|
-
function partialUpdateUsers(
|
|
7927
|
+
function partialUpdateUsers(_x29) {
|
|
7420
7928
|
return _partialUpdateUsers.apply(this, arguments);
|
|
7421
7929
|
}
|
|
7422
7930
|
|
|
@@ -7444,7 +7952,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7444
7952
|
}, _callee28, this);
|
|
7445
7953
|
}));
|
|
7446
7954
|
|
|
7447
|
-
function deleteUser(
|
|
7955
|
+
function deleteUser(_x30, _x31) {
|
|
7448
7956
|
return _deleteUser.apply(this, arguments);
|
|
7449
7957
|
}
|
|
7450
7958
|
|
|
@@ -7472,7 +7980,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7472
7980
|
}, _callee29, this);
|
|
7473
7981
|
}));
|
|
7474
7982
|
|
|
7475
|
-
function reactivateUser(
|
|
7983
|
+
function reactivateUser(_x32, _x33) {
|
|
7476
7984
|
return _reactivateUser.apply(this, arguments);
|
|
7477
7985
|
}
|
|
7478
7986
|
|
|
@@ -7500,7 +8008,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7500
8008
|
}, _callee30, this);
|
|
7501
8009
|
}));
|
|
7502
8010
|
|
|
7503
|
-
function deactivateUser(
|
|
8011
|
+
function deactivateUser(_x34, _x35) {
|
|
7504
8012
|
return _deactivateUser.apply(this, arguments);
|
|
7505
8013
|
}
|
|
7506
8014
|
|
|
@@ -7528,7 +8036,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7528
8036
|
}, _callee31, this);
|
|
7529
8037
|
}));
|
|
7530
8038
|
|
|
7531
|
-
function exportUser(
|
|
8039
|
+
function exportUser(_x36, _x37) {
|
|
7532
8040
|
return _exportUser.apply(this, arguments);
|
|
7533
8041
|
}
|
|
7534
8042
|
|
|
@@ -7577,7 +8085,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7577
8085
|
}, _callee32, this);
|
|
7578
8086
|
}));
|
|
7579
8087
|
|
|
7580
|
-
function banUser(
|
|
8088
|
+
function banUser(_x38, _x39) {
|
|
7581
8089
|
return _banUser.apply(this, arguments);
|
|
7582
8090
|
}
|
|
7583
8091
|
|
|
@@ -7614,7 +8122,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7614
8122
|
}, _callee33, this);
|
|
7615
8123
|
}));
|
|
7616
8124
|
|
|
7617
|
-
function unbanUser(
|
|
8125
|
+
function unbanUser(_x40, _x41) {
|
|
7618
8126
|
return _unbanUser.apply(this, arguments);
|
|
7619
8127
|
}
|
|
7620
8128
|
|
|
@@ -7651,7 +8159,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7651
8159
|
}, _callee34, this);
|
|
7652
8160
|
}));
|
|
7653
8161
|
|
|
7654
|
-
function shadowBan(
|
|
8162
|
+
function shadowBan(_x42, _x43) {
|
|
7655
8163
|
return _shadowBan.apply(this, arguments);
|
|
7656
8164
|
}
|
|
7657
8165
|
|
|
@@ -7688,7 +8196,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7688
8196
|
}, _callee35, this);
|
|
7689
8197
|
}));
|
|
7690
8198
|
|
|
7691
|
-
function removeShadowBan(
|
|
8199
|
+
function removeShadowBan(_x44, _x45) {
|
|
7692
8200
|
return _removeShadowBan.apply(this, arguments);
|
|
7693
8201
|
}
|
|
7694
8202
|
|
|
@@ -7731,7 +8239,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7731
8239
|
}, _callee36, this);
|
|
7732
8240
|
}));
|
|
7733
8241
|
|
|
7734
|
-
function muteUser(
|
|
8242
|
+
function muteUser(_x46, _x47) {
|
|
7735
8243
|
return _muteUser.apply(this, arguments);
|
|
7736
8244
|
}
|
|
7737
8245
|
|
|
@@ -7770,7 +8278,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7770
8278
|
}, _callee37, this);
|
|
7771
8279
|
}));
|
|
7772
8280
|
|
|
7773
|
-
function unmuteUser(
|
|
8281
|
+
function unmuteUser(_x48, _x49) {
|
|
7774
8282
|
return _unmuteUser.apply(this, arguments);
|
|
7775
8283
|
}
|
|
7776
8284
|
|
|
@@ -7829,7 +8337,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7829
8337
|
}, _callee38, this);
|
|
7830
8338
|
}));
|
|
7831
8339
|
|
|
7832
|
-
function flagMessage(
|
|
8340
|
+
function flagMessage(_x50) {
|
|
7833
8341
|
return _flagMessage.apply(this, arguments);
|
|
7834
8342
|
}
|
|
7835
8343
|
|
|
@@ -7869,7 +8377,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7869
8377
|
}, _callee39, this);
|
|
7870
8378
|
}));
|
|
7871
8379
|
|
|
7872
|
-
function flagUser(
|
|
8380
|
+
function flagUser(_x51) {
|
|
7873
8381
|
return _flagUser.apply(this, arguments);
|
|
7874
8382
|
}
|
|
7875
8383
|
|
|
@@ -7909,7 +8417,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7909
8417
|
}, _callee40, this);
|
|
7910
8418
|
}));
|
|
7911
8419
|
|
|
7912
|
-
function unflagMessage(
|
|
8420
|
+
function unflagMessage(_x52) {
|
|
7913
8421
|
return _unflagMessage.apply(this, arguments);
|
|
7914
8422
|
}
|
|
7915
8423
|
|
|
@@ -7949,7 +8457,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7949
8457
|
}, _callee41, this);
|
|
7950
8458
|
}));
|
|
7951
8459
|
|
|
7952
|
-
function unflagUser(
|
|
8460
|
+
function unflagUser(_x53) {
|
|
7953
8461
|
return _unflagUser.apply(this, arguments);
|
|
7954
8462
|
}
|
|
7955
8463
|
|
|
@@ -8088,7 +8596,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8088
8596
|
}, _callee43, this);
|
|
8089
8597
|
}));
|
|
8090
8598
|
|
|
8091
|
-
function translateMessage(
|
|
8599
|
+
function translateMessage(_x54, _x55) {
|
|
8092
8600
|
return _translateMessage.apply(this, arguments);
|
|
8093
8601
|
}
|
|
8094
8602
|
|
|
@@ -8204,7 +8712,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8204
8712
|
case 2:
|
|
8205
8713
|
clonedMessage = _extends__default['default']({}, message);
|
|
8206
8714
|
delete clonedMessage.id;
|
|
8207
|
-
reservedMessageFields = ['command', 'created_at', 'html', 'latest_reactions', 'own_reactions', 'reaction_counts', 'reply_count', 'type', 'updated_at', 'user', '__html'];
|
|
8715
|
+
reservedMessageFields = ['command', 'created_at', 'html', 'latest_reactions', 'own_reactions', 'quoted_message', 'reaction_counts', 'reply_count', 'type', 'updated_at', 'user', '__html'];
|
|
8208
8716
|
reservedMessageFields.forEach(function (item) {
|
|
8209
8717
|
if (clonedMessage[item] != null) {
|
|
8210
8718
|
delete clonedMessage[item];
|
|
@@ -8248,7 +8756,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8248
8756
|
}, _callee44, this);
|
|
8249
8757
|
}));
|
|
8250
8758
|
|
|
8251
|
-
function updateMessage(_x57, _x58
|
|
8759
|
+
function updateMessage(_x56, _x57, _x58) {
|
|
8252
8760
|
return _updateMessage.apply(this, arguments);
|
|
8253
8761
|
}
|
|
8254
8762
|
|
|
@@ -8309,7 +8817,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8309
8817
|
}, _callee45, this);
|
|
8310
8818
|
}));
|
|
8311
8819
|
|
|
8312
|
-
function partialUpdateMessage(_x60, _x61, _x62
|
|
8820
|
+
function partialUpdateMessage(_x59, _x60, _x61, _x62) {
|
|
8313
8821
|
return _partialUpdateMessage.apply(this, arguments);
|
|
8314
8822
|
}
|
|
8315
8823
|
|
|
@@ -8346,7 +8854,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8346
8854
|
}, _callee46, this);
|
|
8347
8855
|
}));
|
|
8348
8856
|
|
|
8349
|
-
function deleteMessage(
|
|
8857
|
+
function deleteMessage(_x63, _x64) {
|
|
8350
8858
|
return _deleteMessage.apply(this, arguments);
|
|
8351
8859
|
}
|
|
8352
8860
|
|
|
@@ -8374,7 +8882,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8374
8882
|
}, _callee47, this);
|
|
8375
8883
|
}));
|
|
8376
8884
|
|
|
8377
|
-
function getMessage(
|
|
8885
|
+
function getMessage(_x65) {
|
|
8378
8886
|
return _getMessage.apply(this, arguments);
|
|
8379
8887
|
}
|
|
8380
8888
|
|
|
@@ -8383,7 +8891,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8383
8891
|
}, {
|
|
8384
8892
|
key: "getUserAgent",
|
|
8385
8893
|
value: function getUserAgent() {
|
|
8386
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "4.
|
|
8894
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "4.5.0-beta.0");
|
|
8387
8895
|
}
|
|
8388
8896
|
}, {
|
|
8389
8897
|
key: "setUserAgent",
|
|
@@ -8397,7 +8905,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8397
8905
|
}, {
|
|
8398
8906
|
key: "_enrichAxiosOptions",
|
|
8399
8907
|
value: function _enrichAxiosOptions() {
|
|
8400
|
-
var
|
|
8908
|
+
var _options$headers;
|
|
8401
8909
|
|
|
8402
8910
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
8403
8911
|
params: {},
|
|
@@ -8407,15 +8915,24 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8407
8915
|
|
|
8408
8916
|
var token = this._getToken();
|
|
8409
8917
|
|
|
8918
|
+
var authorization = token ? {
|
|
8919
|
+
Authorization: token
|
|
8920
|
+
} : undefined;
|
|
8921
|
+
|
|
8922
|
+
if (!((_options$headers = options.headers) !== null && _options$headers !== void 0 && _options$headers['x-client-request-id'])) {
|
|
8923
|
+
options.headers = _objectSpread(_objectSpread({}, options.headers), {}, {
|
|
8924
|
+
'x-client-request-id': randomId()
|
|
8925
|
+
});
|
|
8926
|
+
}
|
|
8927
|
+
|
|
8410
8928
|
return _objectSpread({
|
|
8411
8929
|
params: _objectSpread(_objectSpread({
|
|
8412
8930
|
user_id: this.userID
|
|
8413
8931
|
}, options.params), {}, {
|
|
8414
8932
|
api_key: this.key,
|
|
8415
|
-
connection_id:
|
|
8933
|
+
connection_id: this._getConnectionID()
|
|
8416
8934
|
}),
|
|
8417
|
-
headers: _objectSpread({
|
|
8418
|
-
Authorization: token,
|
|
8935
|
+
headers: _objectSpread(_objectSpread({}, authorization), {}, {
|
|
8419
8936
|
'stream-auth-type': this.getAuthType(),
|
|
8420
8937
|
'X-Stream-Client': this.getUserAgent()
|
|
8421
8938
|
}, options.headers)
|
|
@@ -8445,6 +8962,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8445
8962
|
}
|
|
8446
8963
|
}, 500);
|
|
8447
8964
|
}
|
|
8965
|
+
/**
|
|
8966
|
+
* encode ws url payload
|
|
8967
|
+
* @private
|
|
8968
|
+
* @returns json string
|
|
8969
|
+
*/
|
|
8970
|
+
|
|
8448
8971
|
}, {
|
|
8449
8972
|
key: "verifyWebhook",
|
|
8450
8973
|
value: function verifyWebhook(requestBody, xSignature) {
|
|
@@ -8585,7 +9108,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8585
9108
|
}, _callee48, this);
|
|
8586
9109
|
}));
|
|
8587
9110
|
|
|
8588
|
-
function sendUserCustomEvent(
|
|
9111
|
+
function sendUserCustomEvent(_x66, _x67) {
|
|
8589
9112
|
return _sendUserCustomEvent.apply(this, arguments);
|
|
8590
9113
|
}
|
|
8591
9114
|
|
|
@@ -8673,7 +9196,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8673
9196
|
}, _callee49, this);
|
|
8674
9197
|
}));
|
|
8675
9198
|
|
|
8676
|
-
function createSegment(
|
|
9199
|
+
function createSegment(_x68) {
|
|
8677
9200
|
return _createSegment.apply(this, arguments);
|
|
8678
9201
|
}
|
|
8679
9202
|
|
|
@@ -8713,7 +9236,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8713
9236
|
}, _callee50, this);
|
|
8714
9237
|
}));
|
|
8715
9238
|
|
|
8716
|
-
function getSegment(
|
|
9239
|
+
function getSegment(_x69) {
|
|
8717
9240
|
return _getSegment.apply(this, arguments);
|
|
8718
9241
|
}
|
|
8719
9242
|
|
|
@@ -8752,7 +9275,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8752
9275
|
}, _callee51, this);
|
|
8753
9276
|
}));
|
|
8754
9277
|
|
|
8755
|
-
function listSegments(
|
|
9278
|
+
function listSegments(_x70) {
|
|
8756
9279
|
return _listSegments.apply(this, arguments);
|
|
8757
9280
|
}
|
|
8758
9281
|
|
|
@@ -8795,7 +9318,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8795
9318
|
}, _callee52, this);
|
|
8796
9319
|
}));
|
|
8797
9320
|
|
|
8798
|
-
function updateSegment(
|
|
9321
|
+
function updateSegment(_x71, _x72) {
|
|
8799
9322
|
return _updateSegment.apply(this, arguments);
|
|
8800
9323
|
}
|
|
8801
9324
|
|
|
@@ -8827,7 +9350,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8827
9350
|
}, _callee53, this);
|
|
8828
9351
|
}));
|
|
8829
9352
|
|
|
8830
|
-
function deleteSegment(
|
|
9353
|
+
function deleteSegment(_x73) {
|
|
8831
9354
|
return _deleteSegment.apply(this, arguments);
|
|
8832
9355
|
}
|
|
8833
9356
|
|
|
@@ -8869,7 +9392,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8869
9392
|
}, _callee54, this);
|
|
8870
9393
|
}));
|
|
8871
9394
|
|
|
8872
|
-
function createCampaign(
|
|
9395
|
+
function createCampaign(_x74) {
|
|
8873
9396
|
return _createCampaign.apply(this, arguments);
|
|
8874
9397
|
}
|
|
8875
9398
|
|
|
@@ -8909,7 +9432,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8909
9432
|
}, _callee55, this);
|
|
8910
9433
|
}));
|
|
8911
9434
|
|
|
8912
|
-
function getCampaign(
|
|
9435
|
+
function getCampaign(_x75) {
|
|
8913
9436
|
return _getCampaign.apply(this, arguments);
|
|
8914
9437
|
}
|
|
8915
9438
|
|
|
@@ -8948,7 +9471,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8948
9471
|
}, _callee56, this);
|
|
8949
9472
|
}));
|
|
8950
9473
|
|
|
8951
|
-
function listCampaigns(
|
|
9474
|
+
function listCampaigns(_x76) {
|
|
8952
9475
|
return _listCampaigns.apply(this, arguments);
|
|
8953
9476
|
}
|
|
8954
9477
|
|
|
@@ -8991,7 +9514,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8991
9514
|
}, _callee57, this);
|
|
8992
9515
|
}));
|
|
8993
9516
|
|
|
8994
|
-
function updateCampaign(
|
|
9517
|
+
function updateCampaign(_x77, _x78) {
|
|
8995
9518
|
return _updateCampaign.apply(this, arguments);
|
|
8996
9519
|
}
|
|
8997
9520
|
|
|
@@ -9023,7 +9546,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9023
9546
|
}, _callee58, this);
|
|
9024
9547
|
}));
|
|
9025
9548
|
|
|
9026
|
-
function deleteCampaign(
|
|
9549
|
+
function deleteCampaign(_x79) {
|
|
9027
9550
|
return _deleteCampaign.apply(this, arguments);
|
|
9028
9551
|
}
|
|
9029
9552
|
|
|
@@ -9067,7 +9590,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9067
9590
|
}, _callee59, this);
|
|
9068
9591
|
}));
|
|
9069
9592
|
|
|
9070
|
-
function scheduleCampaign(
|
|
9593
|
+
function scheduleCampaign(_x80, _x81) {
|
|
9071
9594
|
return _scheduleCampaign.apply(this, arguments);
|
|
9072
9595
|
}
|
|
9073
9596
|
|
|
@@ -9107,7 +9630,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9107
9630
|
}, _callee60, this);
|
|
9108
9631
|
}));
|
|
9109
9632
|
|
|
9110
|
-
function stopCampaign(
|
|
9633
|
+
function stopCampaign(_x82) {
|
|
9111
9634
|
return _stopCampaign.apply(this, arguments);
|
|
9112
9635
|
}
|
|
9113
9636
|
|
|
@@ -9147,7 +9670,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9147
9670
|
}, _callee61, this);
|
|
9148
9671
|
}));
|
|
9149
9672
|
|
|
9150
|
-
function resumeCampaign(
|
|
9673
|
+
function resumeCampaign(_x83) {
|
|
9151
9674
|
return _resumeCampaign.apply(this, arguments);
|
|
9152
9675
|
}
|
|
9153
9676
|
|
|
@@ -9190,7 +9713,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9190
9713
|
}, _callee62, this);
|
|
9191
9714
|
}));
|
|
9192
9715
|
|
|
9193
|
-
function testCampaign(
|
|
9716
|
+
function testCampaign(_x84, _x85) {
|
|
9194
9717
|
return _testCampaign.apply(this, arguments);
|
|
9195
9718
|
}
|
|
9196
9719
|
|
|
@@ -9223,7 +9746,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9223
9746
|
}, _callee63, this);
|
|
9224
9747
|
}));
|
|
9225
9748
|
|
|
9226
|
-
function enrichURL(
|
|
9749
|
+
function enrichURL(_x86) {
|
|
9227
9750
|
return _enrichURL.apply(this, arguments);
|
|
9228
9751
|
}
|
|
9229
9752
|
|
|
@@ -9255,7 +9778,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9255
9778
|
}, _callee64, this);
|
|
9256
9779
|
}));
|
|
9257
9780
|
|
|
9258
|
-
function getTask(
|
|
9781
|
+
function getTask(_x87) {
|
|
9259
9782
|
return _getTask.apply(this, arguments);
|
|
9260
9783
|
}
|
|
9261
9784
|
|
|
@@ -9297,15 +9820,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9297
9820
|
}, _callee65, this);
|
|
9298
9821
|
}));
|
|
9299
9822
|
|
|
9300
|
-
function deleteChannels(
|
|
9823
|
+
function deleteChannels(_x88) {
|
|
9301
9824
|
return _deleteChannels.apply(this, arguments);
|
|
9302
9825
|
}
|
|
9303
9826
|
|
|
9304
9827
|
return deleteChannels;
|
|
9305
9828
|
}()
|
|
9306
|
-
}, {
|
|
9307
|
-
key: "deleteUsers",
|
|
9308
|
-
value:
|
|
9309
9829
|
/**
|
|
9310
9830
|
* deleteUsers - Batch Delete Users
|
|
9311
9831
|
*
|
|
@@ -9314,7 +9834,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9314
9834
|
*
|
|
9315
9835
|
* @return {APIResponse} A task ID
|
|
9316
9836
|
*/
|
|
9317
|
-
|
|
9837
|
+
|
|
9838
|
+
}, {
|
|
9839
|
+
key: "deleteUsers",
|
|
9840
|
+
value: function () {
|
|
9318
9841
|
var _deleteUsers = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee66(user_ids, options) {
|
|
9319
9842
|
return _regeneratorRuntime__default['default'].wrap(function _callee66$(_context66) {
|
|
9320
9843
|
while (1) {
|
|
@@ -9360,7 +9883,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9360
9883
|
}, _callee66, this);
|
|
9361
9884
|
}));
|
|
9362
9885
|
|
|
9363
|
-
function deleteUsers(
|
|
9886
|
+
function deleteUsers(_x89, _x90) {
|
|
9364
9887
|
return _deleteUsers.apply(this, arguments);
|
|
9365
9888
|
}
|
|
9366
9889
|
|
|
@@ -9492,4 +10015,5 @@ exports.encodeBase64 = encodeBase64;
|
|
|
9492
10015
|
exports.isOwnUser = isOwnUser;
|
|
9493
10016
|
exports.isValidEventType = isValidEventType;
|
|
9494
10017
|
exports.logChatPromiseExecution = logChatPromiseExecution;
|
|
10018
|
+
exports.postInsights = postInsights;
|
|
9495
10019
|
//# sourceMappingURL=index.js.map
|