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/browser.js
CHANGED
|
@@ -108,9 +108,9 @@ var decodeBase64 = function decodeBase64(s) {
|
|
|
108
108
|
|
|
109
109
|
var https = null;
|
|
110
110
|
|
|
111
|
-
function ownKeys$
|
|
111
|
+
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; }
|
|
112
112
|
|
|
113
|
-
function _objectSpread$
|
|
113
|
+
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; }
|
|
114
114
|
|
|
115
115
|
/**
|
|
116
116
|
* ChannelState - A container class for the channel state.
|
|
@@ -178,7 +178,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
178
178
|
var m = messages[i];
|
|
179
179
|
|
|
180
180
|
if (((_m$user = m.user) === null || _m$user === void 0 ? void 0 : _m$user.id) === user.id) {
|
|
181
|
-
messages[i] = _objectSpread$
|
|
181
|
+
messages[i] = _objectSpread$7(_objectSpread$7({}, m), {}, {
|
|
182
182
|
user: user
|
|
183
183
|
});
|
|
184
184
|
}
|
|
@@ -231,7 +231,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
231
231
|
user: m.user
|
|
232
232
|
};
|
|
233
233
|
} else {
|
|
234
|
-
messages[i] = _objectSpread$
|
|
234
|
+
messages[i] = _objectSpread$7(_objectSpread$7({}, m), {}, {
|
|
235
235
|
type: 'deleted',
|
|
236
236
|
deleted_at: user.deleted_at
|
|
237
237
|
});
|
|
@@ -299,7 +299,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
299
299
|
}, {
|
|
300
300
|
key: "formatMessage",
|
|
301
301
|
value: function formatMessage(message) {
|
|
302
|
-
return _objectSpread$
|
|
302
|
+
return _objectSpread$7(_objectSpread$7({}, message), {}, {
|
|
303
303
|
/**
|
|
304
304
|
* @deprecated please use `html`
|
|
305
305
|
*/
|
|
@@ -489,7 +489,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
489
489
|
var parseMessage = function parseMessage(m) {
|
|
490
490
|
var _m$pinned_at, _m$updated_at;
|
|
491
491
|
|
|
492
|
-
return _objectSpread$
|
|
492
|
+
return _objectSpread$7(_objectSpread$7({}, m), {}, {
|
|
493
493
|
created_at: m.created_at.toString(),
|
|
494
494
|
pinned_at: (_m$pinned_at = m.pinned_at) === null || _m$pinned_at === void 0 ? void 0 : _m$pinned_at.toString(),
|
|
495
495
|
updated_at: (_m$updated_at = m.updated_at) === null || _m$updated_at === void 0 ? void 0 : _m$updated_at.toString()
|
|
@@ -499,8 +499,8 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
499
499
|
var updatedMessages = this.messages.filter(function (msg) {
|
|
500
500
|
return msg.quoted_message_id === message.id;
|
|
501
501
|
}).map(parseMessage).map(function (msg) {
|
|
502
|
-
return _objectSpread$
|
|
503
|
-
quoted_message: _objectSpread$
|
|
502
|
+
return _objectSpread$7(_objectSpread$7({}, msg), {}, {
|
|
503
|
+
quoted_message: _objectSpread$7(_objectSpread$7({}, message), {}, {
|
|
504
504
|
attachments: []
|
|
505
505
|
})
|
|
506
506
|
});
|
|
@@ -720,9 +720,9 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
720
720
|
return ChannelState;
|
|
721
721
|
}();
|
|
722
722
|
|
|
723
|
-
function ownKeys$
|
|
723
|
+
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; }
|
|
724
724
|
|
|
725
|
-
function _objectSpread$
|
|
725
|
+
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; }
|
|
726
726
|
|
|
727
727
|
var EVENT_MAP = {
|
|
728
728
|
'channel.created': true,
|
|
@@ -769,7 +769,7 @@ var EVENT_MAP = {
|
|
|
769
769
|
'connection.recovered': true
|
|
770
770
|
};
|
|
771
771
|
|
|
772
|
-
var IS_VALID_EVENT_MAP_TYPE = _objectSpread$
|
|
772
|
+
var IS_VALID_EVENT_MAP_TYPE = _objectSpread$6(_objectSpread$6({}, EVENT_MAP), {}, {
|
|
773
773
|
all: true
|
|
774
774
|
});
|
|
775
775
|
|
|
@@ -777,7 +777,7 @@ var isValidEventType = function isValidEventType(eventType) {
|
|
|
777
777
|
return IS_VALID_EVENT_MAP_TYPE[eventType] || false;
|
|
778
778
|
};
|
|
779
779
|
|
|
780
|
-
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) {
|
|
780
|
+
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; } } }; }
|
|
781
781
|
|
|
782
782
|
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); }
|
|
783
783
|
|
|
@@ -953,12 +953,45 @@ function getRandomBytes(length) {
|
|
|
953
953
|
function convertErrorToJson(err) {
|
|
954
954
|
var jsonObj = {};
|
|
955
955
|
if (!err) return jsonObj;
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
956
|
+
|
|
957
|
+
try {
|
|
958
|
+
Object.getOwnPropertyNames(err).forEach(function (key) {
|
|
959
|
+
jsonObj[key] = Object.getOwnPropertyDescriptor(err, key);
|
|
960
|
+
});
|
|
961
|
+
} catch (_) {
|
|
962
|
+
return {
|
|
963
|
+
error: 'failed to serialize the error'
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
|
|
960
967
|
return jsonObj;
|
|
961
968
|
}
|
|
969
|
+
/**
|
|
970
|
+
* isOnline safely return the navigator.online value
|
|
971
|
+
* if navigator is not in global object, it always return true
|
|
972
|
+
*/
|
|
973
|
+
|
|
974
|
+
function isOnline() {
|
|
975
|
+
var nav = typeof navigator !== 'undefined' ? navigator : typeof window !== 'undefined' && window.navigator ? window.navigator : undefined;
|
|
976
|
+
if (!nav) return true;
|
|
977
|
+
return nav.onLine;
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* listenForConnectionChanges - Adds an event listener fired on browser going online or offline
|
|
981
|
+
*/
|
|
982
|
+
|
|
983
|
+
function addConnectionEventListeners(cb) {
|
|
984
|
+
if (typeof window !== 'undefined' && window.addEventListener) {
|
|
985
|
+
window.addEventListener('offline', cb);
|
|
986
|
+
window.addEventListener('online', cb);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
function removeConnectionEventListeners(cb) {
|
|
990
|
+
if (typeof window !== 'undefined' && window.removeEventListener) {
|
|
991
|
+
window.removeEventListener('offline', cb);
|
|
992
|
+
window.removeEventListener('online', cb);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
962
995
|
|
|
963
996
|
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; } } }; }
|
|
964
997
|
|
|
@@ -966,9 +999,9 @@ function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o
|
|
|
966
999
|
|
|
967
1000
|
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; }
|
|
968
1001
|
|
|
969
|
-
function ownKeys$
|
|
1002
|
+
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; }
|
|
970
1003
|
|
|
971
|
-
function _objectSpread$
|
|
1004
|
+
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; }
|
|
972
1005
|
|
|
973
1006
|
/**
|
|
974
1007
|
* Channel - The Channel class manages it's own state.
|
|
@@ -1088,7 +1121,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1088
1121
|
|
|
1089
1122
|
this.data = data; // this._data is used for the requests...
|
|
1090
1123
|
|
|
1091
|
-
this._data = _objectSpread$
|
|
1124
|
+
this._data = _objectSpread$5({}, data);
|
|
1092
1125
|
this.cid = "".concat(type, ":").concat(id);
|
|
1093
1126
|
this.listeners = {}; // perhaps the state variable should be private
|
|
1094
1127
|
|
|
@@ -1146,7 +1179,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1146
1179
|
switch (_context2.prev = _context2.next) {
|
|
1147
1180
|
case 0:
|
|
1148
1181
|
_context2.next = 2;
|
|
1149
|
-
return this.getClient().post(this._channelURL() + '/message', _objectSpread$
|
|
1182
|
+
return this.getClient().post(this._channelURL() + '/message', _objectSpread$5({
|
|
1150
1183
|
message: message
|
|
1151
1184
|
}, options));
|
|
1152
1185
|
|
|
@@ -1265,7 +1298,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1265
1298
|
|
|
1266
1299
|
case 3:
|
|
1267
1300
|
// Return a list of channels
|
|
1268
|
-
payload = _objectSpread$
|
|
1301
|
+
payload = _objectSpread$5(_objectSpread$5({
|
|
1269
1302
|
filter_conditions: {
|
|
1270
1303
|
cid: this.cid
|
|
1271
1304
|
}
|
|
@@ -1362,7 +1395,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1362
1395
|
|
|
1363
1396
|
_context5.next = 6;
|
|
1364
1397
|
return this.getClient().get(this.getClient().baseURL + '/members', {
|
|
1365
|
-
payload: _objectSpread$
|
|
1398
|
+
payload: _objectSpread$5({
|
|
1366
1399
|
type: type,
|
|
1367
1400
|
id: id,
|
|
1368
1401
|
members: members,
|
|
@@ -1423,7 +1456,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1423
1456
|
|
|
1424
1457
|
case 4:
|
|
1425
1458
|
_context6.next = 6;
|
|
1426
|
-
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(messageID, "/reaction"), _objectSpread$
|
|
1459
|
+
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(messageID, "/reaction"), _objectSpread$5({
|
|
1427
1460
|
reaction: reaction
|
|
1428
1461
|
}, options));
|
|
1429
1462
|
|
|
@@ -1478,7 +1511,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1478
1511
|
*
|
|
1479
1512
|
* @param {ChannelData<ChannelType>} channelData The object to update the custom properties of this channel with
|
|
1480
1513
|
* @param {Message<AttachmentType, MessageType, UserType>} [updateMessage] Optional message object for channel members notification
|
|
1481
|
-
* @param {
|
|
1514
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1482
1515
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1483
1516
|
*/
|
|
1484
1517
|
|
|
@@ -1504,7 +1537,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1504
1537
|
delete channelData[key];
|
|
1505
1538
|
});
|
|
1506
1539
|
_context7.next = 7;
|
|
1507
|
-
return this._update(_objectSpread$
|
|
1540
|
+
return this._update(_objectSpread$5({
|
|
1508
1541
|
message: updateMessage,
|
|
1509
1542
|
data: channelData
|
|
1510
1543
|
}, options));
|
|
@@ -1677,25 +1710,28 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1677
1710
|
}()
|
|
1678
1711
|
/**
|
|
1679
1712
|
* truncate - Removes all messages from the channel
|
|
1680
|
-
*
|
|
1681
|
-
* @return {Promise<TruncateChannelAPIResponse<ChannelType, CommandType, UserType>>} The server response
|
|
1713
|
+
* @param {TruncateOptions<AttachmentType, MessageType, UserType>} [options] Defines truncation options
|
|
1714
|
+
* @return {Promise<TruncateChannelAPIResponse<ChannelType, CommandType, UserType, MessageType, ReactionType>>} The server response
|
|
1682
1715
|
*/
|
|
1683
1716
|
|
|
1684
1717
|
}, {
|
|
1685
1718
|
key: "truncate",
|
|
1686
1719
|
value: function () {
|
|
1687
1720
|
var _truncate = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee12() {
|
|
1721
|
+
var options,
|
|
1722
|
+
_args12 = arguments;
|
|
1688
1723
|
return _regeneratorRuntime__default['default'].wrap(function _callee12$(_context12) {
|
|
1689
1724
|
while (1) {
|
|
1690
1725
|
switch (_context12.prev = _context12.next) {
|
|
1691
1726
|
case 0:
|
|
1692
|
-
|
|
1693
|
-
|
|
1727
|
+
options = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
|
|
1728
|
+
_context12.next = 3;
|
|
1729
|
+
return this.getClient().post(this._channelURL() + '/truncate', options);
|
|
1694
1730
|
|
|
1695
|
-
case
|
|
1731
|
+
case 3:
|
|
1696
1732
|
return _context12.abrupt("return", _context12.sent);
|
|
1697
1733
|
|
|
1698
|
-
case
|
|
1734
|
+
case 4:
|
|
1699
1735
|
case "end":
|
|
1700
1736
|
return _context12.stop();
|
|
1701
1737
|
}
|
|
@@ -1729,7 +1765,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1729
1765
|
case 0:
|
|
1730
1766
|
options = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
|
|
1731
1767
|
_context13.next = 3;
|
|
1732
|
-
return this._update(_objectSpread$
|
|
1768
|
+
return this._update(_objectSpread$5({
|
|
1733
1769
|
accept_invite: true
|
|
1734
1770
|
}, options));
|
|
1735
1771
|
|
|
@@ -1770,7 +1806,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1770
1806
|
case 0:
|
|
1771
1807
|
options = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
|
|
1772
1808
|
_context14.next = 3;
|
|
1773
|
-
return this._update(_objectSpread$
|
|
1809
|
+
return this._update(_objectSpread$5({
|
|
1774
1810
|
reject_invite: true
|
|
1775
1811
|
}, options));
|
|
1776
1812
|
|
|
@@ -1796,6 +1832,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1796
1832
|
*
|
|
1797
1833
|
* @param {{user_id: string, channel_role?: Role}[]} members An array of members to add to the channel
|
|
1798
1834
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1835
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1799
1836
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1800
1837
|
*/
|
|
1801
1838
|
|
|
@@ -1803,20 +1840,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1803
1840
|
key: "addMembers",
|
|
1804
1841
|
value: function () {
|
|
1805
1842
|
var _addMembers = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee15(members, message) {
|
|
1843
|
+
var options,
|
|
1844
|
+
_args15 = arguments;
|
|
1806
1845
|
return _regeneratorRuntime__default['default'].wrap(function _callee15$(_context15) {
|
|
1807
1846
|
while (1) {
|
|
1808
1847
|
switch (_context15.prev = _context15.next) {
|
|
1809
1848
|
case 0:
|
|
1810
|
-
|
|
1811
|
-
|
|
1849
|
+
options = _args15.length > 2 && _args15[2] !== undefined ? _args15[2] : {};
|
|
1850
|
+
_context15.next = 3;
|
|
1851
|
+
return this._update(_objectSpread$5({
|
|
1812
1852
|
add_members: members,
|
|
1813
1853
|
message: message
|
|
1814
|
-
});
|
|
1854
|
+
}, options));
|
|
1815
1855
|
|
|
1816
|
-
case
|
|
1856
|
+
case 3:
|
|
1817
1857
|
return _context15.abrupt("return", _context15.sent);
|
|
1818
1858
|
|
|
1819
|
-
case
|
|
1859
|
+
case 4:
|
|
1820
1860
|
case "end":
|
|
1821
1861
|
return _context15.stop();
|
|
1822
1862
|
}
|
|
@@ -1835,6 +1875,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1835
1875
|
*
|
|
1836
1876
|
* @param {string[]} members An array of member identifiers
|
|
1837
1877
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1878
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1838
1879
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1839
1880
|
*/
|
|
1840
1881
|
|
|
@@ -1842,20 +1883,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1842
1883
|
key: "addModerators",
|
|
1843
1884
|
value: function () {
|
|
1844
1885
|
var _addModerators = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee16(members, message) {
|
|
1886
|
+
var options,
|
|
1887
|
+
_args16 = arguments;
|
|
1845
1888
|
return _regeneratorRuntime__default['default'].wrap(function _callee16$(_context16) {
|
|
1846
1889
|
while (1) {
|
|
1847
1890
|
switch (_context16.prev = _context16.next) {
|
|
1848
1891
|
case 0:
|
|
1849
|
-
|
|
1850
|
-
|
|
1892
|
+
options = _args16.length > 2 && _args16[2] !== undefined ? _args16[2] : {};
|
|
1893
|
+
_context16.next = 3;
|
|
1894
|
+
return this._update(_objectSpread$5({
|
|
1851
1895
|
add_moderators: members,
|
|
1852
1896
|
message: message
|
|
1853
|
-
});
|
|
1897
|
+
}, options));
|
|
1854
1898
|
|
|
1855
|
-
case
|
|
1899
|
+
case 3:
|
|
1856
1900
|
return _context16.abrupt("return", _context16.sent);
|
|
1857
1901
|
|
|
1858
|
-
case
|
|
1902
|
+
case 4:
|
|
1859
1903
|
case "end":
|
|
1860
1904
|
return _context16.stop();
|
|
1861
1905
|
}
|
|
@@ -1874,6 +1918,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1874
1918
|
*
|
|
1875
1919
|
* @param {{channel_role: Role, user_id: string}[]} roles List of role assignments
|
|
1876
1920
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1921
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1877
1922
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1878
1923
|
*/
|
|
1879
1924
|
|
|
@@ -1881,20 +1926,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1881
1926
|
key: "assignRoles",
|
|
1882
1927
|
value: function () {
|
|
1883
1928
|
var _assignRoles = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee17(roles, message) {
|
|
1929
|
+
var options,
|
|
1930
|
+
_args17 = arguments;
|
|
1884
1931
|
return _regeneratorRuntime__default['default'].wrap(function _callee17$(_context17) {
|
|
1885
1932
|
while (1) {
|
|
1886
1933
|
switch (_context17.prev = _context17.next) {
|
|
1887
1934
|
case 0:
|
|
1888
|
-
|
|
1889
|
-
|
|
1935
|
+
options = _args17.length > 2 && _args17[2] !== undefined ? _args17[2] : {};
|
|
1936
|
+
_context17.next = 3;
|
|
1937
|
+
return this._update(_objectSpread$5({
|
|
1890
1938
|
assign_roles: roles,
|
|
1891
1939
|
message: message
|
|
1892
|
-
});
|
|
1940
|
+
}, options));
|
|
1893
1941
|
|
|
1894
|
-
case
|
|
1942
|
+
case 3:
|
|
1895
1943
|
return _context17.abrupt("return", _context17.sent);
|
|
1896
1944
|
|
|
1897
|
-
case
|
|
1945
|
+
case 4:
|
|
1898
1946
|
case "end":
|
|
1899
1947
|
return _context17.stop();
|
|
1900
1948
|
}
|
|
@@ -1913,6 +1961,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1913
1961
|
*
|
|
1914
1962
|
* @param {{user_id: string, channel_role?: Role}[]} members An array of members to invite to the channel
|
|
1915
1963
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1964
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1916
1965
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1917
1966
|
*/
|
|
1918
1967
|
|
|
@@ -1920,20 +1969,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1920
1969
|
key: "inviteMembers",
|
|
1921
1970
|
value: function () {
|
|
1922
1971
|
var _inviteMembers = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee18(members, message) {
|
|
1972
|
+
var options,
|
|
1973
|
+
_args18 = arguments;
|
|
1923
1974
|
return _regeneratorRuntime__default['default'].wrap(function _callee18$(_context18) {
|
|
1924
1975
|
while (1) {
|
|
1925
1976
|
switch (_context18.prev = _context18.next) {
|
|
1926
1977
|
case 0:
|
|
1927
|
-
|
|
1928
|
-
|
|
1978
|
+
options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
|
|
1979
|
+
_context18.next = 3;
|
|
1980
|
+
return this._update(_objectSpread$5({
|
|
1929
1981
|
invites: members,
|
|
1930
1982
|
message: message
|
|
1931
|
-
});
|
|
1983
|
+
}, options));
|
|
1932
1984
|
|
|
1933
|
-
case
|
|
1985
|
+
case 3:
|
|
1934
1986
|
return _context18.abrupt("return", _context18.sent);
|
|
1935
1987
|
|
|
1936
|
-
case
|
|
1988
|
+
case 4:
|
|
1937
1989
|
case "end":
|
|
1938
1990
|
return _context18.stop();
|
|
1939
1991
|
}
|
|
@@ -1952,6 +2004,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1952
2004
|
*
|
|
1953
2005
|
* @param {string[]} members An array of member identifiers
|
|
1954
2006
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
2007
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1955
2008
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1956
2009
|
*/
|
|
1957
2010
|
|
|
@@ -1959,20 +2012,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1959
2012
|
key: "removeMembers",
|
|
1960
2013
|
value: function () {
|
|
1961
2014
|
var _removeMembers = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee19(members, message) {
|
|
2015
|
+
var options,
|
|
2016
|
+
_args19 = arguments;
|
|
1962
2017
|
return _regeneratorRuntime__default['default'].wrap(function _callee19$(_context19) {
|
|
1963
2018
|
while (1) {
|
|
1964
2019
|
switch (_context19.prev = _context19.next) {
|
|
1965
2020
|
case 0:
|
|
1966
|
-
|
|
1967
|
-
|
|
2021
|
+
options = _args19.length > 2 && _args19[2] !== undefined ? _args19[2] : {};
|
|
2022
|
+
_context19.next = 3;
|
|
2023
|
+
return this._update(_objectSpread$5({
|
|
1968
2024
|
remove_members: members,
|
|
1969
2025
|
message: message
|
|
1970
|
-
});
|
|
2026
|
+
}, options));
|
|
1971
2027
|
|
|
1972
|
-
case
|
|
2028
|
+
case 3:
|
|
1973
2029
|
return _context19.abrupt("return", _context19.sent);
|
|
1974
2030
|
|
|
1975
|
-
case
|
|
2031
|
+
case 4:
|
|
1976
2032
|
case "end":
|
|
1977
2033
|
return _context19.stop();
|
|
1978
2034
|
}
|
|
@@ -1991,6 +2047,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1991
2047
|
*
|
|
1992
2048
|
* @param {string[]} members An array of member identifiers
|
|
1993
2049
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
2050
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1994
2051
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1995
2052
|
*/
|
|
1996
2053
|
|
|
@@ -1998,20 +2055,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1998
2055
|
key: "demoteModerators",
|
|
1999
2056
|
value: function () {
|
|
2000
2057
|
var _demoteModerators = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee20(members, message) {
|
|
2058
|
+
var options,
|
|
2059
|
+
_args20 = arguments;
|
|
2001
2060
|
return _regeneratorRuntime__default['default'].wrap(function _callee20$(_context20) {
|
|
2002
2061
|
while (1) {
|
|
2003
2062
|
switch (_context20.prev = _context20.next) {
|
|
2004
2063
|
case 0:
|
|
2005
|
-
|
|
2006
|
-
|
|
2064
|
+
options = _args20.length > 2 && _args20[2] !== undefined ? _args20[2] : {};
|
|
2065
|
+
_context20.next = 3;
|
|
2066
|
+
return this._update(_objectSpread$5({
|
|
2007
2067
|
demote_moderators: members,
|
|
2008
2068
|
message: message
|
|
2009
|
-
});
|
|
2069
|
+
}, options));
|
|
2010
2070
|
|
|
2011
|
-
case
|
|
2071
|
+
case 3:
|
|
2012
2072
|
return _context20.abrupt("return", _context20.sent);
|
|
2013
2073
|
|
|
2014
|
-
case
|
|
2074
|
+
case 4:
|
|
2015
2075
|
case "end":
|
|
2016
2076
|
return _context20.stop();
|
|
2017
2077
|
}
|
|
@@ -2088,7 +2148,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2088
2148
|
case 0:
|
|
2089
2149
|
opts = _args22.length > 0 && _args22[0] !== undefined ? _args22[0] : {};
|
|
2090
2150
|
_context22.next = 3;
|
|
2091
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$
|
|
2151
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$5({
|
|
2092
2152
|
channel_cid: this.cid
|
|
2093
2153
|
}, opts));
|
|
2094
2154
|
|
|
@@ -2130,7 +2190,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2130
2190
|
case 0:
|
|
2131
2191
|
opts = _args23.length > 0 && _args23[0] !== undefined ? _args23[0] : {};
|
|
2132
2192
|
_context23.next = 3;
|
|
2133
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$
|
|
2193
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$5({
|
|
2134
2194
|
channel_cid: this.cid
|
|
2135
2195
|
}, opts));
|
|
2136
2196
|
|
|
@@ -2339,7 +2399,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2339
2399
|
|
|
2340
2400
|
case 4:
|
|
2341
2401
|
_context26.next = 6;
|
|
2342
|
-
return this.getClient().post(this._channelURL() + '/read', _objectSpread$
|
|
2402
|
+
return this.getClient().post(this._channelURL() + '/read', _objectSpread$5({}, data));
|
|
2343
2403
|
|
|
2344
2404
|
case 6:
|
|
2345
2405
|
return _context26.abrupt("return", _context26.sent);
|
|
@@ -2407,7 +2467,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2407
2467
|
defaultOptions.watch = false;
|
|
2408
2468
|
}
|
|
2409
2469
|
|
|
2410
|
-
combined = _objectSpread$
|
|
2470
|
+
combined = _objectSpread$5(_objectSpread$5({}, defaultOptions), options);
|
|
2411
2471
|
_context27.next = 7;
|
|
2412
2472
|
return this.query(combined);
|
|
2413
2473
|
|
|
@@ -2498,7 +2558,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2498
2558
|
switch (_context29.prev = _context29.next) {
|
|
2499
2559
|
case 0:
|
|
2500
2560
|
_context29.next = 2;
|
|
2501
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(parent_id, "/replies"), _objectSpread$
|
|
2561
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(parent_id, "/replies"), _objectSpread$5({}, options));
|
|
2502
2562
|
|
|
2503
2563
|
case 2:
|
|
2504
2564
|
data = _context29.sent;
|
|
@@ -2536,7 +2596,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2536
2596
|
}, {
|
|
2537
2597
|
key: "getReactions",
|
|
2538
2598
|
value: function getReactions(message_id, options) {
|
|
2539
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(message_id, "/reactions"), _objectSpread$
|
|
2599
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(message_id, "/reactions"), _objectSpread$5({}, options));
|
|
2540
2600
|
}
|
|
2541
2601
|
/**
|
|
2542
2602
|
* getMessagesById - Retrieves a list of messages by ID
|
|
@@ -2668,7 +2728,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2668
2728
|
}
|
|
2669
2729
|
|
|
2670
2730
|
_context30.next = 6;
|
|
2671
|
-
return this.getClient().post(queryURL + '/query', _objectSpread$
|
|
2731
|
+
return this.getClient().post(queryURL + '/query', _objectSpread$5({
|
|
2672
2732
|
data: this._data,
|
|
2673
2733
|
state: true
|
|
2674
2734
|
}, options));
|
|
@@ -2739,7 +2799,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2739
2799
|
this._checkInitialized();
|
|
2740
2800
|
|
|
2741
2801
|
_context31.next = 3;
|
|
2742
|
-
return this.getClient().banUser(targetUserID, _objectSpread$
|
|
2802
|
+
return this.getClient().banUser(targetUserID, _objectSpread$5(_objectSpread$5({}, options), {}, {
|
|
2743
2803
|
type: this.type,
|
|
2744
2804
|
id: this.id
|
|
2745
2805
|
}));
|
|
@@ -2911,7 +2971,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2911
2971
|
this._checkInitialized();
|
|
2912
2972
|
|
|
2913
2973
|
_context35.next = 3;
|
|
2914
|
-
return this.getClient().shadowBan(targetUserID, _objectSpread$
|
|
2974
|
+
return this.getClient().shadowBan(targetUserID, _objectSpread$5(_objectSpread$5({}, options), {}, {
|
|
2915
2975
|
type: this.type,
|
|
2916
2976
|
id: this.id
|
|
2917
2977
|
}));
|
|
@@ -3324,7 +3384,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3324
3384
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
3325
3385
|
var read = _step3.value;
|
|
3326
3386
|
|
|
3327
|
-
var parsedRead = _objectSpread$
|
|
3387
|
+
var parsedRead = _objectSpread$5(_objectSpread$5({}, read), {}, {
|
|
3328
3388
|
last_read: new Date(read.last_read)
|
|
3329
3389
|
});
|
|
3330
3390
|
|
|
@@ -3451,9 +3511,9 @@ var ClientState = /*#__PURE__*/function () {
|
|
|
3451
3511
|
return ClientState;
|
|
3452
3512
|
}();
|
|
3453
3513
|
|
|
3454
|
-
function ownKeys$
|
|
3514
|
+
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; }
|
|
3455
3515
|
|
|
3456
|
-
function _objectSpread$
|
|
3516
|
+
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; }
|
|
3457
3517
|
var InsightMetrics = function InsightMetrics() {
|
|
3458
3518
|
_classCallCheck__default['default'](this, InsightMetrics);
|
|
3459
3519
|
|
|
@@ -3470,32 +3530,94 @@ var InsightMetrics = function InsightMetrics() {
|
|
|
3470
3530
|
this.wsConsecutiveFailures = 0;
|
|
3471
3531
|
this.instanceClientId = randomId();
|
|
3472
3532
|
};
|
|
3533
|
+
/**
|
|
3534
|
+
* postInsights is not supposed to be used by end users directly within chat application, and thus is kept isolated
|
|
3535
|
+
* from all the client/connection code/logic.
|
|
3536
|
+
*
|
|
3537
|
+
* @param insightType
|
|
3538
|
+
* @param insights
|
|
3539
|
+
*/
|
|
3540
|
+
|
|
3541
|
+
var postInsights = /*#__PURE__*/function () {
|
|
3542
|
+
var _ref = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(insightType, insights) {
|
|
3543
|
+
var maxAttempts, i;
|
|
3544
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
3545
|
+
while (1) {
|
|
3546
|
+
switch (_context.prev = _context.next) {
|
|
3547
|
+
case 0:
|
|
3548
|
+
maxAttempts = 3;
|
|
3549
|
+
i = 0;
|
|
3550
|
+
|
|
3551
|
+
case 2:
|
|
3552
|
+
if (!(i < maxAttempts)) {
|
|
3553
|
+
_context.next = 17;
|
|
3554
|
+
break;
|
|
3555
|
+
}
|
|
3556
|
+
|
|
3557
|
+
_context.prev = 3;
|
|
3558
|
+
_context.next = 6;
|
|
3559
|
+
return axios__default['default'].post("https://chat-insights.getstream.io/insights/".concat(insightType), insights);
|
|
3560
|
+
|
|
3561
|
+
case 6:
|
|
3562
|
+
_context.next = 13;
|
|
3563
|
+
break;
|
|
3564
|
+
|
|
3565
|
+
case 8:
|
|
3566
|
+
_context.prev = 8;
|
|
3567
|
+
_context.t0 = _context["catch"](3);
|
|
3568
|
+
_context.next = 12;
|
|
3569
|
+
return sleep((i + 1) * 3000);
|
|
3570
|
+
|
|
3571
|
+
case 12:
|
|
3572
|
+
return _context.abrupt("continue", 14);
|
|
3573
|
+
|
|
3574
|
+
case 13:
|
|
3575
|
+
return _context.abrupt("break", 17);
|
|
3576
|
+
|
|
3577
|
+
case 14:
|
|
3578
|
+
i++;
|
|
3579
|
+
_context.next = 2;
|
|
3580
|
+
break;
|
|
3581
|
+
|
|
3582
|
+
case 17:
|
|
3583
|
+
case "end":
|
|
3584
|
+
return _context.stop();
|
|
3585
|
+
}
|
|
3586
|
+
}
|
|
3587
|
+
}, _callee, null, [[3, 8]]);
|
|
3588
|
+
}));
|
|
3589
|
+
|
|
3590
|
+
return function postInsights(_x, _x2) {
|
|
3591
|
+
return _ref.apply(this, arguments);
|
|
3592
|
+
};
|
|
3593
|
+
}();
|
|
3473
3594
|
function buildWsFatalInsight(connection, event) {
|
|
3474
|
-
return _objectSpread$
|
|
3595
|
+
return _objectSpread$4(_objectSpread$4({}, event), buildWsBaseInsight(connection));
|
|
3475
3596
|
}
|
|
3476
3597
|
|
|
3477
3598
|
function buildWsBaseInsight(connection) {
|
|
3478
3599
|
var _connection$ws, _navigator, _navigator2;
|
|
3479
3600
|
|
|
3601
|
+
var client = connection.client;
|
|
3480
3602
|
return {
|
|
3481
3603
|
ready_state: (_connection$ws = connection.ws) === null || _connection$ws === void 0 ? void 0 : _connection$ws.readyState,
|
|
3482
|
-
url: connection._buildUrl(
|
|
3483
|
-
api_key:
|
|
3484
|
-
start_ts:
|
|
3604
|
+
url: connection._buildUrl(),
|
|
3605
|
+
api_key: client.key,
|
|
3606
|
+
start_ts: client.insightMetrics.connectionStartTimestamp,
|
|
3485
3607
|
end_ts: new Date().getTime(),
|
|
3486
|
-
auth_type:
|
|
3487
|
-
token:
|
|
3488
|
-
user_id:
|
|
3489
|
-
user_details:
|
|
3490
|
-
device:
|
|
3608
|
+
auth_type: client.getAuthType(),
|
|
3609
|
+
token: client.tokenManager.token,
|
|
3610
|
+
user_id: client.userID,
|
|
3611
|
+
user_details: client._user,
|
|
3612
|
+
device: client.options.device,
|
|
3491
3613
|
client_id: connection.connectionID,
|
|
3492
3614
|
ws_details: connection.ws,
|
|
3493
|
-
ws_consecutive_failures:
|
|
3494
|
-
ws_total_failures:
|
|
3615
|
+
ws_consecutive_failures: client.insightMetrics.wsConsecutiveFailures,
|
|
3616
|
+
ws_total_failures: client.insightMetrics.wsTotalFailures,
|
|
3495
3617
|
request_id: connection.requestID,
|
|
3496
3618
|
online: typeof navigator !== 'undefined' ? (_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.onLine : null,
|
|
3497
3619
|
user_agent: typeof navigator !== 'undefined' ? (_navigator2 = navigator) === null || _navigator2 === void 0 ? void 0 : _navigator2.userAgent : null,
|
|
3498
|
-
instance_client_id:
|
|
3620
|
+
instance_client_id: client.insightMetrics.instanceClientId
|
|
3499
3621
|
};
|
|
3500
3622
|
}
|
|
3501
3623
|
|
|
@@ -3503,6 +3625,10 @@ function buildWsSuccessAfterFailureInsight(connection) {
|
|
|
3503
3625
|
return buildWsBaseInsight(connection);
|
|
3504
3626
|
}
|
|
3505
3627
|
|
|
3628
|
+
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; }
|
|
3629
|
+
|
|
3630
|
+
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; }
|
|
3631
|
+
|
|
3506
3632
|
// Type guards to check WebSocket error type
|
|
3507
3633
|
var isCloseEvent = function isCloseEvent(res) {
|
|
3508
3634
|
return res.code !== undefined;
|
|
@@ -3511,7 +3637,6 @@ var isCloseEvent = function isCloseEvent(res) {
|
|
|
3511
3637
|
var isErrorEvent = function isErrorEvent(res) {
|
|
3512
3638
|
return res.error !== undefined;
|
|
3513
3639
|
};
|
|
3514
|
-
|
|
3515
3640
|
/**
|
|
3516
3641
|
* StableWSConnection - A WS connection that reconnects upon failure.
|
|
3517
3642
|
* - the browser will sometimes report that you're online or offline
|
|
@@ -3529,53 +3654,19 @@ var isErrorEvent = function isErrorEvent(res) {
|
|
|
3529
3654
|
* - state can be recovered by querying the channel again
|
|
3530
3655
|
* - if the servers fails to publish a message to the client, the WS connection is destroyed
|
|
3531
3656
|
*/
|
|
3657
|
+
|
|
3658
|
+
|
|
3532
3659
|
var StableWSConnection = /*#__PURE__*/function () {
|
|
3660
|
+
// global from constructor
|
|
3661
|
+
// local vars
|
|
3533
3662
|
function StableWSConnection(_ref) {
|
|
3534
3663
|
var _this = this;
|
|
3535
3664
|
|
|
3536
|
-
var
|
|
3537
|
-
authType = _ref.authType,
|
|
3538
|
-
clientID = _ref.clientID,
|
|
3539
|
-
eventCallback = _ref.eventCallback,
|
|
3540
|
-
logger = _ref.logger,
|
|
3541
|
-
messageCallback = _ref.messageCallback,
|
|
3542
|
-
recoverCallback = _ref.recoverCallback,
|
|
3543
|
-
tokenManager = _ref.tokenManager,
|
|
3544
|
-
user = _ref.user,
|
|
3545
|
-
userAgent = _ref.userAgent,
|
|
3546
|
-
userID = _ref.userID,
|
|
3547
|
-
wsBaseURL = _ref.wsBaseURL,
|
|
3548
|
-
device = _ref.device,
|
|
3549
|
-
postInsights = _ref.postInsights,
|
|
3550
|
-
insightMetrics = _ref.insightMetrics;
|
|
3665
|
+
var client = _ref.client;
|
|
3551
3666
|
|
|
3552
3667
|
_classCallCheck__default['default'](this, StableWSConnection);
|
|
3553
3668
|
|
|
3554
|
-
_defineProperty__default['default'](this, "
|
|
3555
|
-
|
|
3556
|
-
_defineProperty__default['default'](this, "authType", void 0);
|
|
3557
|
-
|
|
3558
|
-
_defineProperty__default['default'](this, "clientID", void 0);
|
|
3559
|
-
|
|
3560
|
-
_defineProperty__default['default'](this, "eventCallback", void 0);
|
|
3561
|
-
|
|
3562
|
-
_defineProperty__default['default'](this, "logger", void 0);
|
|
3563
|
-
|
|
3564
|
-
_defineProperty__default['default'](this, "messageCallback", void 0);
|
|
3565
|
-
|
|
3566
|
-
_defineProperty__default['default'](this, "recoverCallback", void 0);
|
|
3567
|
-
|
|
3568
|
-
_defineProperty__default['default'](this, "tokenManager", void 0);
|
|
3569
|
-
|
|
3570
|
-
_defineProperty__default['default'](this, "user", void 0);
|
|
3571
|
-
|
|
3572
|
-
_defineProperty__default['default'](this, "userAgent", void 0);
|
|
3573
|
-
|
|
3574
|
-
_defineProperty__default['default'](this, "userID", void 0);
|
|
3575
|
-
|
|
3576
|
-
_defineProperty__default['default'](this, "wsBaseURL", void 0);
|
|
3577
|
-
|
|
3578
|
-
_defineProperty__default['default'](this, "device", void 0);
|
|
3669
|
+
_defineProperty__default['default'](this, "client", void 0);
|
|
3579
3670
|
|
|
3580
3671
|
_defineProperty__default['default'](this, "connectionID", void 0);
|
|
3581
3672
|
|
|
@@ -3589,6 +3680,8 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3589
3680
|
|
|
3590
3681
|
_defineProperty__default['default'](this, "isConnecting", void 0);
|
|
3591
3682
|
|
|
3683
|
+
_defineProperty__default['default'](this, "isDisconnected", void 0);
|
|
3684
|
+
|
|
3592
3685
|
_defineProperty__default['default'](this, "isHealthy", void 0);
|
|
3593
3686
|
|
|
3594
3687
|
_defineProperty__default['default'](this, "isResolved", void 0);
|
|
@@ -3603,8 +3696,6 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3603
3696
|
|
|
3604
3697
|
_defineProperty__default['default'](this, "requestID", void 0);
|
|
3605
3698
|
|
|
3606
|
-
_defineProperty__default['default'](this, "connectionStartTimestamp", void 0);
|
|
3607
|
-
|
|
3608
3699
|
_defineProperty__default['default'](this, "resolvePromise", void 0);
|
|
3609
3700
|
|
|
3610
3701
|
_defineProperty__default['default'](this, "totalFailures", void 0);
|
|
@@ -3613,32 +3704,18 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3613
3704
|
|
|
3614
3705
|
_defineProperty__default['default'](this, "wsID", void 0);
|
|
3615
3706
|
|
|
3616
|
-
_defineProperty__default['default'](this, "
|
|
3617
|
-
|
|
3618
|
-
_defineProperty__default['default'](this, "insightMetrics", void 0);
|
|
3707
|
+
_defineProperty__default['default'](this, "_buildUrl", function () {
|
|
3708
|
+
var qs = encodeURIComponent(_this.client._buildWSPayload(_this.requestID));
|
|
3619
3709
|
|
|
3620
|
-
|
|
3621
|
-
var params = {
|
|
3622
|
-
user_id: _this.user.id,
|
|
3623
|
-
user_details: _this.user,
|
|
3624
|
-
user_token: _this.tokenManager.getToken(),
|
|
3625
|
-
server_determines_connection_id: true,
|
|
3626
|
-
device: _this.device,
|
|
3627
|
-
request_id: reqID
|
|
3628
|
-
};
|
|
3629
|
-
var qs = encodeURIComponent(JSON.stringify(params));
|
|
3710
|
+
var token = _this.client.tokenManager.getToken();
|
|
3630
3711
|
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
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);
|
|
3712
|
+
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());
|
|
3634
3713
|
});
|
|
3635
3714
|
|
|
3636
3715
|
_defineProperty__default['default'](this, "onlineStatusChanged", function (event) {
|
|
3637
3716
|
if (event.type === 'offline') {
|
|
3638
3717
|
// mark the connection as down
|
|
3639
|
-
_this.
|
|
3640
|
-
tags: ['connection']
|
|
3641
|
-
});
|
|
3718
|
+
_this._log('onlineStatusChanged() - Status changing to offline');
|
|
3642
3719
|
|
|
3643
3720
|
_this._setHealth(false);
|
|
3644
3721
|
} else if (event.type === 'online') {
|
|
@@ -3646,9 +3723,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3646
3723
|
// We check this.isHealthy, not sure if it's always
|
|
3647
3724
|
// smart to create a new WS connection if the old one is still up and running.
|
|
3648
3725
|
// it's possible we didn't miss any messages, so this process is just expensive and not needed.
|
|
3649
|
-
_this.
|
|
3650
|
-
tags: ['connection']
|
|
3651
|
-
});
|
|
3726
|
+
_this._log("onlineStatusChanged() - Status changing to online. isHealthy: ".concat(_this.isHealthy));
|
|
3652
3727
|
|
|
3653
3728
|
if (!_this.isHealthy) {
|
|
3654
3729
|
_this._reconnect({
|
|
@@ -3661,8 +3736,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3661
3736
|
_defineProperty__default['default'](this, "onopen", function (wsID) {
|
|
3662
3737
|
if (_this.wsID !== wsID) return;
|
|
3663
3738
|
|
|
3664
|
-
_this.
|
|
3665
|
-
tags: ['connection'],
|
|
3739
|
+
_this._log('onopen() - onopen callback', {
|
|
3666
3740
|
wsID: wsID
|
|
3667
3741
|
});
|
|
3668
3742
|
});
|
|
@@ -3674,27 +3748,26 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3674
3748
|
// after that a ws.onclose..
|
|
3675
3749
|
|
|
3676
3750
|
if (!_this.isResolved && data) {
|
|
3751
|
+
var _this$resolvePromise;
|
|
3752
|
+
|
|
3677
3753
|
_this.isResolved = true;
|
|
3678
3754
|
|
|
3679
|
-
if (data.error
|
|
3755
|
+
if (data.error) {
|
|
3680
3756
|
var _this$rejectPromise;
|
|
3681
3757
|
|
|
3682
3758
|
(_this$rejectPromise = _this.rejectPromise) === null || _this$rejectPromise === void 0 ? void 0 : _this$rejectPromise.call(_this, _this._errorFromWSEvent(data, false));
|
|
3683
3759
|
return;
|
|
3684
|
-
}
|
|
3685
|
-
var _this$resolvePromise;
|
|
3760
|
+
}
|
|
3686
3761
|
|
|
3687
|
-
|
|
3762
|
+
(_this$resolvePromise = _this.resolvePromise) === null || _this$resolvePromise === void 0 ? void 0 : _this$resolvePromise.call(_this, data);
|
|
3688
3763
|
|
|
3689
|
-
|
|
3690
|
-
}
|
|
3764
|
+
_this._setHealth(true);
|
|
3691
3765
|
} // trigger the event..
|
|
3692
3766
|
|
|
3693
3767
|
|
|
3694
3768
|
_this.lastEvent = new Date();
|
|
3695
3769
|
|
|
3696
|
-
_this.
|
|
3697
|
-
tags: ['connection'],
|
|
3770
|
+
_this._log('onmessage() - onmessage callback', {
|
|
3698
3771
|
event: event,
|
|
3699
3772
|
wsID: wsID
|
|
3700
3773
|
});
|
|
@@ -3703,7 +3776,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3703
3776
|
_this.scheduleNextPing();
|
|
3704
3777
|
}
|
|
3705
3778
|
|
|
3706
|
-
_this.
|
|
3779
|
+
_this.client.handleEvent(event);
|
|
3707
3780
|
|
|
3708
3781
|
_this.scheduleConnectionCheck();
|
|
3709
3782
|
});
|
|
@@ -3711,8 +3784,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3711
3784
|
_defineProperty__default['default'](this, "onclose", function (wsID, event) {
|
|
3712
3785
|
if (_this.wsID !== wsID) return;
|
|
3713
3786
|
|
|
3714
|
-
_this.
|
|
3715
|
-
tags: ['connection'],
|
|
3787
|
+
_this._log('onclose() - onclose callback - ' + event.code, {
|
|
3716
3788
|
event: event,
|
|
3717
3789
|
wsID: wsID
|
|
3718
3790
|
});
|
|
@@ -3729,8 +3801,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3729
3801
|
error.target = event.target;
|
|
3730
3802
|
(_this$rejectPromise2 = _this.rejectPromise) === null || _this$rejectPromise2 === void 0 ? void 0 : _this$rejectPromise2.call(_this, error);
|
|
3731
3803
|
|
|
3732
|
-
_this.
|
|
3733
|
-
tags: ['connection'],
|
|
3804
|
+
_this._log("onclose() - WS connection reject with error ".concat(event.reason), {
|
|
3734
3805
|
event: event
|
|
3735
3806
|
});
|
|
3736
3807
|
} else {
|
|
@@ -3744,8 +3815,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3744
3815
|
_this.isConnecting = false;
|
|
3745
3816
|
(_this$rejectPromise3 = _this.rejectPromise) === null || _this$rejectPromise3 === void 0 ? void 0 : _this$rejectPromise3.call(_this, _this._errorFromWSEvent(event));
|
|
3746
3817
|
|
|
3747
|
-
_this.
|
|
3748
|
-
tags: ['connection'],
|
|
3818
|
+
_this._log("onclose() - WS connection closed. Calling reconnect ...", {
|
|
3749
3819
|
event: event
|
|
3750
3820
|
}); // reconnect if its an abnormal failure
|
|
3751
3821
|
|
|
@@ -3766,8 +3836,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3766
3836
|
_this.isConnecting = false;
|
|
3767
3837
|
(_this$rejectPromise4 = _this.rejectPromise) === null || _this$rejectPromise4 === void 0 ? void 0 : _this$rejectPromise4.call(_this, _this._errorFromWSEvent(event));
|
|
3768
3838
|
|
|
3769
|
-
_this.
|
|
3770
|
-
tags: ['connection'],
|
|
3839
|
+
_this._log("onerror() - WS connection resulted into error", {
|
|
3771
3840
|
event: event
|
|
3772
3841
|
});
|
|
3773
3842
|
|
|
@@ -3775,28 +3844,28 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3775
3844
|
});
|
|
3776
3845
|
|
|
3777
3846
|
_defineProperty__default['default'](this, "_setHealth", function (healthy) {
|
|
3778
|
-
if (healthy
|
|
3779
|
-
|
|
3780
|
-
_this.isHealthy = true;
|
|
3847
|
+
if (healthy === _this.isHealthy) return;
|
|
3848
|
+
_this.isHealthy = healthy;
|
|
3781
3849
|
|
|
3782
|
-
|
|
3850
|
+
if (_this.isHealthy) {
|
|
3851
|
+
//@ts-expect-error
|
|
3852
|
+
_this.client.dispatchEvent({
|
|
3783
3853
|
type: 'connection.changed',
|
|
3784
|
-
online:
|
|
3854
|
+
online: _this.isHealthy
|
|
3785
3855
|
});
|
|
3786
|
-
}
|
|
3787
3856
|
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
}
|
|
3799
|
-
}
|
|
3857
|
+
return;
|
|
3858
|
+
} // we're offline, wait few seconds and fire and event if still offline
|
|
3859
|
+
|
|
3860
|
+
|
|
3861
|
+
setTimeout(function () {
|
|
3862
|
+
if (_this.isHealthy) return; //@ts-expect-error
|
|
3863
|
+
|
|
3864
|
+
_this.client.dispatchEvent({
|
|
3865
|
+
type: 'connection.changed',
|
|
3866
|
+
online: _this.isHealthy
|
|
3867
|
+
});
|
|
3868
|
+
}, 5000);
|
|
3800
3869
|
});
|
|
3801
3870
|
|
|
3802
3871
|
_defineProperty__default['default'](this, "_errorFromWSEvent", function (event) {
|
|
@@ -3818,10 +3887,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3818
3887
|
} // Keeping this `warn` level log, to avoid cluttering of error logs from ws failures.
|
|
3819
3888
|
|
|
3820
3889
|
|
|
3821
|
-
_this.
|
|
3822
|
-
tags: ['connection'],
|
|
3890
|
+
_this._log("_errorFromWSEvent() - WS failed with code ".concat(code), {
|
|
3823
3891
|
event: event
|
|
3824
|
-
});
|
|
3892
|
+
}, 'warn');
|
|
3825
3893
|
|
|
3826
3894
|
var error = new Error("WS failed with code ".concat(code, " and reason - ").concat(message));
|
|
3827
3895
|
error.code = code;
|
|
@@ -3835,50 +3903,13 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3835
3903
|
return error;
|
|
3836
3904
|
});
|
|
3837
3905
|
|
|
3838
|
-
_defineProperty__default['default'](this, "_listenForConnectionChanges", function () {
|
|
3839
|
-
var _window;
|
|
3840
|
-
|
|
3841
|
-
// (typeof window !== 'undefined') check is for environments where window is not defined, such as nextjs environment,
|
|
3842
|
-
// and thus (window === undefined) will result in ReferenceError.
|
|
3843
|
-
if (typeof window !== 'undefined' && (_window = window) !== null && _window !== void 0 && _window.addEventListener) {
|
|
3844
|
-
window.addEventListener('offline', _this.onlineStatusChanged);
|
|
3845
|
-
window.addEventListener('online', _this.onlineStatusChanged);
|
|
3846
|
-
}
|
|
3847
|
-
});
|
|
3848
|
-
|
|
3849
|
-
_defineProperty__default['default'](this, "_removeConnectionListeners", function () {
|
|
3850
|
-
var _window2;
|
|
3851
|
-
|
|
3852
|
-
// (typeof window !== 'undefined') check is for environments where window is not defined, such as nextjs environment,
|
|
3853
|
-
// and thus (window === undefined) will result in ReferenceError.
|
|
3854
|
-
if (typeof window !== 'undefined' && (_window2 = window) !== null && _window2 !== void 0 && _window2.removeEventListener) {
|
|
3855
|
-
window.removeEventListener('offline', _this.onlineStatusChanged);
|
|
3856
|
-
window.removeEventListener('online', _this.onlineStatusChanged);
|
|
3857
|
-
}
|
|
3858
|
-
});
|
|
3859
|
-
|
|
3860
3906
|
_defineProperty__default['default'](this, "_setupConnectionPromise", function () {
|
|
3861
|
-
var that = _this;
|
|
3862
3907
|
_this.isResolved = false;
|
|
3863
3908
|
/** a promise that is resolved once ws.open is called */
|
|
3864
3909
|
|
|
3865
3910
|
_this.connectionOpen = new Promise(function (resolve, reject) {
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
}).then(function (e) {
|
|
3869
|
-
if (e.data && typeof e.data === 'string') {
|
|
3870
|
-
var data = JSON.parse(e.data);
|
|
3871
|
-
|
|
3872
|
-
if (data && data.error != null) {
|
|
3873
|
-
throw new Error(JSON.stringify(data.error));
|
|
3874
|
-
}
|
|
3875
|
-
|
|
3876
|
-
return data;
|
|
3877
|
-
} else {
|
|
3878
|
-
return undefined;
|
|
3879
|
-
}
|
|
3880
|
-
}, function (error) {
|
|
3881
|
-
throw error;
|
|
3911
|
+
_this.resolvePromise = resolve;
|
|
3912
|
+
_this.rejectPromise = reject;
|
|
3882
3913
|
});
|
|
3883
3914
|
});
|
|
3884
3915
|
|
|
@@ -3892,7 +3923,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3892
3923
|
// send the healthcheck.., server replies with a health check event
|
|
3893
3924
|
var data = [{
|
|
3894
3925
|
type: 'health.check',
|
|
3895
|
-
client_id: _this.clientID
|
|
3926
|
+
client_id: _this.client.clientID
|
|
3896
3927
|
}]; // try to send on the connection
|
|
3897
3928
|
|
|
3898
3929
|
try {
|
|
@@ -3913,9 +3944,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3913
3944
|
var now = new Date();
|
|
3914
3945
|
|
|
3915
3946
|
if (_this.lastEvent && now.getTime() - _this.lastEvent.getTime() > _this.connectionCheckTimeout) {
|
|
3916
|
-
_this.
|
|
3917
|
-
tags: ['connection']
|
|
3918
|
-
});
|
|
3947
|
+
_this._log('scheduleConnectionCheck - going to reconnect');
|
|
3919
3948
|
|
|
3920
3949
|
_this._setHealth(false);
|
|
3921
3950
|
|
|
@@ -3924,15 +3953,8 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3924
3953
|
}, _this.connectionCheckTimeout);
|
|
3925
3954
|
});
|
|
3926
3955
|
|
|
3927
|
-
|
|
3928
|
-
this.
|
|
3929
|
-
this.userID = userID;
|
|
3930
|
-
this.user = user;
|
|
3931
|
-
this.authType = authType;
|
|
3932
|
-
this.userAgent = userAgent;
|
|
3933
|
-
this.apiKey = apiKey;
|
|
3934
|
-
this.tokenManager = tokenManager;
|
|
3935
|
-
this.device = device;
|
|
3956
|
+
/** StreamChat client */
|
|
3957
|
+
this.client = client;
|
|
3936
3958
|
/** consecutive failures influence the duration of the timeout */
|
|
3937
3959
|
|
|
3938
3960
|
this.consecutiveFailures = 0;
|
|
@@ -3942,18 +3964,15 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3942
3964
|
/** We only make 1 attempt to reconnect at the same time.. */
|
|
3943
3965
|
|
|
3944
3966
|
this.isConnecting = false;
|
|
3967
|
+
/** To avoid reconnect if client is disconnected */
|
|
3968
|
+
|
|
3969
|
+
this.isDisconnected = false;
|
|
3945
3970
|
/** Boolean that indicates if the connection promise is resolved */
|
|
3946
3971
|
|
|
3947
3972
|
this.isResolved = false;
|
|
3948
3973
|
/** Boolean that indicates if we have a working connection to the server */
|
|
3949
3974
|
|
|
3950
3975
|
this.isHealthy = false;
|
|
3951
|
-
/** Callback when the connection fails and recovers */
|
|
3952
|
-
|
|
3953
|
-
this.recoverCallback = recoverCallback;
|
|
3954
|
-
this.messageCallback = messageCallback;
|
|
3955
|
-
this.eventCallback = eventCallback;
|
|
3956
|
-
this.logger = logger;
|
|
3957
3976
|
/** Incremented when a new WS connection is made */
|
|
3958
3977
|
|
|
3959
3978
|
this.wsID = 1;
|
|
@@ -3964,74 +3983,82 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3964
3983
|
|
|
3965
3984
|
this.pingInterval = 25 * 1000;
|
|
3966
3985
|
this.connectionCheckTimeout = this.pingInterval + 10 * 1000;
|
|
3967
|
-
|
|
3968
|
-
this._listenForConnectionChanges();
|
|
3969
|
-
|
|
3970
|
-
this.postInsights = postInsights;
|
|
3971
|
-
this.insightMetrics = insightMetrics;
|
|
3986
|
+
addConnectionEventListeners(this.onlineStatusChanged);
|
|
3972
3987
|
}
|
|
3973
|
-
/**
|
|
3974
|
-
* connect - Connect to the WS URL
|
|
3975
|
-
*
|
|
3976
|
-
* @return {ConnectAPIResponse<ChannelType, CommandType, UserType>} Promise that completes once the first health check message is received
|
|
3977
|
-
*/
|
|
3978
|
-
|
|
3979
3988
|
|
|
3980
3989
|
_createClass__default['default'](StableWSConnection, [{
|
|
3990
|
+
key: "_log",
|
|
3991
|
+
value: function _log(msg) {
|
|
3992
|
+
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
3993
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
3994
|
+
this.client.logger(level, 'connection:' + msg, _objectSpread$3({
|
|
3995
|
+
tags: ['connection']
|
|
3996
|
+
}, extra));
|
|
3997
|
+
}
|
|
3998
|
+
/**
|
|
3999
|
+
* connect - Connect to the WS URL
|
|
4000
|
+
* the default 15s timeout allows between 2~3 tries
|
|
4001
|
+
* @return {ConnectAPIResponse<ChannelType, CommandType, UserType>} Promise that completes once the first health check message is received
|
|
4002
|
+
*/
|
|
4003
|
+
|
|
4004
|
+
}, {
|
|
3981
4005
|
key: "connect",
|
|
3982
4006
|
value: function () {
|
|
3983
4007
|
var _connect2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
|
3984
|
-
var
|
|
4008
|
+
var timeout,
|
|
4009
|
+
healthCheck,
|
|
4010
|
+
_args = arguments;
|
|
3985
4011
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
3986
4012
|
while (1) {
|
|
3987
4013
|
switch (_context.prev = _context.next) {
|
|
3988
4014
|
case 0:
|
|
4015
|
+
timeout = _args.length > 0 && _args[0] !== undefined ? _args[0] : 15000;
|
|
4016
|
+
|
|
3989
4017
|
if (!this.isConnecting) {
|
|
3990
|
-
_context.next =
|
|
4018
|
+
_context.next = 3;
|
|
3991
4019
|
break;
|
|
3992
4020
|
}
|
|
3993
4021
|
|
|
3994
4022
|
throw Error("You've called connect twice, can only attempt 1 connection at the time");
|
|
3995
4023
|
|
|
3996
|
-
case
|
|
3997
|
-
|
|
3998
|
-
_context.
|
|
4024
|
+
case 3:
|
|
4025
|
+
this.isDisconnected = false;
|
|
4026
|
+
_context.prev = 4;
|
|
4027
|
+
_context.next = 7;
|
|
3999
4028
|
return this._connect();
|
|
4000
4029
|
|
|
4001
|
-
case
|
|
4030
|
+
case 7:
|
|
4002
4031
|
healthCheck = _context.sent;
|
|
4003
4032
|
this.consecutiveFailures = 0;
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
_context.next =
|
|
4033
|
+
|
|
4034
|
+
this._log("connect() - Established ws connection with healthcheck: ".concat(healthCheck));
|
|
4035
|
+
|
|
4036
|
+
_context.next = 23;
|
|
4008
4037
|
break;
|
|
4009
4038
|
|
|
4010
|
-
case
|
|
4011
|
-
_context.prev =
|
|
4012
|
-
_context.t0 = _context["catch"](
|
|
4039
|
+
case 12:
|
|
4040
|
+
_context.prev = 12;
|
|
4041
|
+
_context.t0 = _context["catch"](4);
|
|
4013
4042
|
this.isHealthy = false;
|
|
4014
4043
|
this.consecutiveFailures += 1;
|
|
4015
4044
|
|
|
4016
|
-
if (!(_context.t0.code === chatCodes.TOKEN_EXPIRED && !this.tokenManager.isStatic())) {
|
|
4017
|
-
_context.next =
|
|
4045
|
+
if (!(_context.t0.code === chatCodes.TOKEN_EXPIRED && !this.client.tokenManager.isStatic())) {
|
|
4046
|
+
_context.next = 21;
|
|
4018
4047
|
break;
|
|
4019
4048
|
}
|
|
4020
4049
|
|
|
4021
|
-
this.
|
|
4022
|
-
tags: ['connection']
|
|
4023
|
-
});
|
|
4050
|
+
this._log('connect() - WS failure due to expired token, so going to try to reload token and reconnect');
|
|
4024
4051
|
|
|
4025
4052
|
this._reconnect({
|
|
4026
4053
|
refreshToken: true
|
|
4027
4054
|
});
|
|
4028
4055
|
|
|
4029
|
-
_context.next =
|
|
4056
|
+
_context.next = 23;
|
|
4030
4057
|
break;
|
|
4031
4058
|
|
|
4032
|
-
case
|
|
4059
|
+
case 21:
|
|
4033
4060
|
if (_context.t0.isWSFailure) {
|
|
4034
|
-
_context.next =
|
|
4061
|
+
_context.next = 23;
|
|
4035
4062
|
break;
|
|
4036
4063
|
}
|
|
4037
4064
|
|
|
@@ -4042,19 +4069,19 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4042
4069
|
isWSFailure: _context.t0.isWSFailure
|
|
4043
4070
|
}));
|
|
4044
4071
|
|
|
4045
|
-
case 21:
|
|
4046
|
-
_context.next = 23;
|
|
4047
|
-
return this._waitForHealthy();
|
|
4048
|
-
|
|
4049
4072
|
case 23:
|
|
4073
|
+
_context.next = 25;
|
|
4074
|
+
return this._waitForHealthy(timeout);
|
|
4075
|
+
|
|
4076
|
+
case 25:
|
|
4050
4077
|
return _context.abrupt("return", _context.sent);
|
|
4051
4078
|
|
|
4052
|
-
case
|
|
4079
|
+
case 26:
|
|
4053
4080
|
case "end":
|
|
4054
4081
|
return _context.stop();
|
|
4055
4082
|
}
|
|
4056
4083
|
}
|
|
4057
|
-
}, _callee, this, [[
|
|
4084
|
+
}, _callee, this, [[4, 12]]);
|
|
4058
4085
|
}));
|
|
4059
4086
|
|
|
4060
4087
|
function connect() {
|
|
@@ -4145,6 +4172,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4145
4172
|
return sleep(timeout);
|
|
4146
4173
|
|
|
4147
4174
|
case 2:
|
|
4175
|
+
_this2.isConnecting = false;
|
|
4148
4176
|
throw new Error(JSON.stringify({
|
|
4149
4177
|
code: '',
|
|
4150
4178
|
StatusCode: '',
|
|
@@ -4152,7 +4180,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4152
4180
|
isWSFailure: true
|
|
4153
4181
|
}));
|
|
4154
4182
|
|
|
4155
|
-
case
|
|
4183
|
+
case 4:
|
|
4156
4184
|
case "end":
|
|
4157
4185
|
return _context3.stop();
|
|
4158
4186
|
}
|
|
@@ -4176,7 +4204,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4176
4204
|
}()
|
|
4177
4205
|
/**
|
|
4178
4206
|
* Builds and returns the url for websocket.
|
|
4179
|
-
* @
|
|
4207
|
+
* @private
|
|
4180
4208
|
* @returns url string
|
|
4181
4209
|
*/
|
|
4182
4210
|
|
|
@@ -4190,10 +4218,11 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4190
4218
|
function disconnect(timeout) {
|
|
4191
4219
|
var _this3 = this;
|
|
4192
4220
|
|
|
4193
|
-
this.
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
this.
|
|
4221
|
+
this._log("disconnect() - Closing the websocket connection for wsID ".concat(this.wsID));
|
|
4222
|
+
|
|
4223
|
+
this.wsID += 1;
|
|
4224
|
+
this.isConnecting = false;
|
|
4225
|
+
this.isDisconnected = true; // start by removing all the listeners
|
|
4197
4226
|
|
|
4198
4227
|
if (this.healthCheckTimeoutRef) {
|
|
4199
4228
|
clearInterval(this.healthCheckTimeoutRef);
|
|
@@ -4203,8 +4232,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4203
4232
|
clearInterval(this.connectionCheckTimeoutRef);
|
|
4204
4233
|
}
|
|
4205
4234
|
|
|
4206
|
-
this.
|
|
4207
|
-
|
|
4235
|
+
removeConnectionEventListeners(this.onlineStatusChanged);
|
|
4208
4236
|
this.isHealthy = false; // remove ws handlers...
|
|
4209
4237
|
|
|
4210
4238
|
if (this.ws && this.ws.removeAllListeners) {
|
|
@@ -4220,8 +4248,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4220
4248
|
if (ws && ws.close && ws.readyState === ws.OPEN) {
|
|
4221
4249
|
isClosedPromise = new Promise(function (resolve) {
|
|
4222
4250
|
var onclose = function onclose(event) {
|
|
4223
|
-
_this3.
|
|
4224
|
-
tags: ['connection'],
|
|
4251
|
+
_this3._log("disconnect() - resolving isClosedPromise ".concat(event ? 'with' : 'without', " close frame"), {
|
|
4225
4252
|
event: event
|
|
4226
4253
|
});
|
|
4227
4254
|
|
|
@@ -4233,14 +4260,13 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4233
4260
|
|
|
4234
4261
|
setTimeout(onclose, timeout != null ? timeout : 1000);
|
|
4235
4262
|
});
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4263
|
+
|
|
4264
|
+
this._log("disconnect() - Manually closed connection by calling client.disconnect()");
|
|
4265
|
+
|
|
4239
4266
|
ws.close(chatCodes.WS_CLOSED_SUCCESS, 'Manually closed connection by calling client.disconnect()');
|
|
4240
4267
|
} else {
|
|
4241
|
-
this.
|
|
4242
|
-
|
|
4243
|
-
});
|
|
4268
|
+
this._log("disconnect() - ws connection doesn't exist or it is already closed.");
|
|
4269
|
+
|
|
4244
4270
|
isClosedPromise = Promise.resolve();
|
|
4245
4271
|
}
|
|
4246
4272
|
|
|
@@ -4257,13 +4283,12 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4257
4283
|
key: "_connect",
|
|
4258
4284
|
value: function () {
|
|
4259
4285
|
var _connect3 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5() {
|
|
4260
|
-
var wsURL, response,
|
|
4261
|
-
|
|
4286
|
+
var wsURL, response, insights;
|
|
4262
4287
|
return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
|
|
4263
4288
|
while (1) {
|
|
4264
4289
|
switch (_context5.prev = _context5.next) {
|
|
4265
4290
|
case 0:
|
|
4266
|
-
if (!this.isConnecting) {
|
|
4291
|
+
if (!(this.isConnecting || this.isDisconnected)) {
|
|
4267
4292
|
_context5.next = 2;
|
|
4268
4293
|
break;
|
|
4269
4294
|
}
|
|
@@ -4274,15 +4299,15 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4274
4299
|
// simply ignore _connect if it's currently trying to connect
|
|
4275
4300
|
this.isConnecting = true;
|
|
4276
4301
|
this.requestID = randomId();
|
|
4277
|
-
this.insightMetrics.connectionStartTimestamp = new Date().getTime();
|
|
4302
|
+
this.client.insightMetrics.connectionStartTimestamp = new Date().getTime();
|
|
4278
4303
|
_context5.prev = 5;
|
|
4279
4304
|
_context5.next = 8;
|
|
4280
|
-
return this.tokenManager.tokenReady();
|
|
4305
|
+
return this.client.tokenManager.tokenReady();
|
|
4281
4306
|
|
|
4282
4307
|
case 8:
|
|
4283
4308
|
this._setupConnectionPromise();
|
|
4284
4309
|
|
|
4285
|
-
wsURL = this._buildUrl(
|
|
4310
|
+
wsURL = this._buildUrl();
|
|
4286
4311
|
this.ws = new WebSocket__default['default'](wsURL);
|
|
4287
4312
|
this.ws.onopen = this.onopen.bind(this, this.wsID);
|
|
4288
4313
|
this.ws.onclose = this.onclose.bind(this, this.wsID);
|
|
@@ -4302,9 +4327,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4302
4327
|
|
|
4303
4328
|
this.connectionID = response.connection_id;
|
|
4304
4329
|
|
|
4305
|
-
if (this.insightMetrics.wsConsecutiveFailures > 0 && this.
|
|
4306
|
-
|
|
4307
|
-
this.insightMetrics.wsConsecutiveFailures = 0;
|
|
4330
|
+
if (this.client.insightMetrics.wsConsecutiveFailures > 0 && this.client.options.enableInsights) {
|
|
4331
|
+
postInsights('ws_success_after_failure', buildWsSuccessAfterFailureInsight(this));
|
|
4332
|
+
this.client.insightMetrics.wsConsecutiveFailures = 0;
|
|
4308
4333
|
}
|
|
4309
4334
|
|
|
4310
4335
|
return _context5.abrupt("return", response);
|
|
@@ -4318,12 +4343,11 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4318
4343
|
_context5.t0 = _context5["catch"](5);
|
|
4319
4344
|
this.isConnecting = false;
|
|
4320
4345
|
|
|
4321
|
-
if (this.
|
|
4322
|
-
this.insightMetrics.wsConsecutiveFailures++;
|
|
4323
|
-
this.insightMetrics.wsTotalFailures++;
|
|
4324
|
-
|
|
4346
|
+
if (this.client.options.enableInsights) {
|
|
4347
|
+
this.client.insightMetrics.wsConsecutiveFailures++;
|
|
4348
|
+
this.client.insightMetrics.wsTotalFailures++;
|
|
4325
4349
|
insights = buildWsFatalInsight(this, convertErrorToJson(_context5.t0));
|
|
4326
|
-
|
|
4350
|
+
postInsights === null || postInsights === void 0 ? void 0 : postInsights('ws_fatal', insights);
|
|
4327
4351
|
}
|
|
4328
4352
|
|
|
4329
4353
|
throw _context5.t0;
|
|
@@ -4357,26 +4381,23 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4357
4381
|
var _reconnect2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee6() {
|
|
4358
4382
|
var options,
|
|
4359
4383
|
interval,
|
|
4360
|
-
_open,
|
|
4361
4384
|
_args6 = arguments;
|
|
4362
|
-
|
|
4363
4385
|
return _regeneratorRuntime__default['default'].wrap(function _callee6$(_context6) {
|
|
4364
4386
|
while (1) {
|
|
4365
4387
|
switch (_context6.prev = _context6.next) {
|
|
4366
4388
|
case 0:
|
|
4367
4389
|
options = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4390
|
+
|
|
4391
|
+
this._log('_reconnect() - Initiating the reconnect'); // only allow 1 connection at the time
|
|
4392
|
+
|
|
4371
4393
|
|
|
4372
4394
|
if (!(this.isConnecting || this.isHealthy)) {
|
|
4373
4395
|
_context6.next = 5;
|
|
4374
4396
|
break;
|
|
4375
4397
|
}
|
|
4376
4398
|
|
|
4377
|
-
this.
|
|
4378
|
-
|
|
4379
|
-
});
|
|
4399
|
+
this._log('_reconnect() - Abort (1) since already connecting or healthy');
|
|
4400
|
+
|
|
4380
4401
|
return _context6.abrupt("return");
|
|
4381
4402
|
|
|
4382
4403
|
case 5:
|
|
@@ -4398,95 +4419,86 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4398
4419
|
break;
|
|
4399
4420
|
}
|
|
4400
4421
|
|
|
4401
|
-
this.
|
|
4402
|
-
|
|
4403
|
-
});
|
|
4422
|
+
this._log('_reconnect() - Abort (2) since already connecting or healthy');
|
|
4423
|
+
|
|
4404
4424
|
return _context6.abrupt("return");
|
|
4405
4425
|
|
|
4406
4426
|
case 12:
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
}
|
|
4427
|
+
if (!this.isDisconnected) {
|
|
4428
|
+
_context6.next = 15;
|
|
4429
|
+
break;
|
|
4430
|
+
}
|
|
4431
|
+
|
|
4432
|
+
this._log('_reconnect() - Abort (3) since disconnect() is called');
|
|
4433
|
+
|
|
4434
|
+
return _context6.abrupt("return");
|
|
4435
|
+
|
|
4436
|
+
case 15:
|
|
4437
|
+
this._log('_reconnect() - Destroying current WS connection'); // cleanup the old connection
|
|
4438
|
+
|
|
4411
4439
|
|
|
4412
4440
|
this._destroyCurrentWSConnection();
|
|
4413
4441
|
|
|
4414
4442
|
if (!options.refreshToken) {
|
|
4415
|
-
_context6.next =
|
|
4443
|
+
_context6.next = 20;
|
|
4416
4444
|
break;
|
|
4417
4445
|
}
|
|
4418
4446
|
|
|
4419
|
-
_context6.next = 17;
|
|
4420
|
-
return this.tokenManager.loadToken();
|
|
4421
|
-
|
|
4422
|
-
case 17:
|
|
4423
|
-
_context6.prev = 17;
|
|
4424
4447
|
_context6.next = 20;
|
|
4425
|
-
return this.
|
|
4448
|
+
return this.client.tokenManager.loadToken();
|
|
4426
4449
|
|
|
4427
4450
|
case 20:
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
_context6.next = 26;
|
|
4432
|
-
break;
|
|
4433
|
-
}
|
|
4451
|
+
_context6.prev = 20;
|
|
4452
|
+
_context6.next = 23;
|
|
4453
|
+
return this._connect();
|
|
4434
4454
|
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
});
|
|
4438
|
-
_context6.next = 25;
|
|
4439
|
-
return this.recoverCallback(_open);
|
|
4455
|
+
case 23:
|
|
4456
|
+
this._log('_reconnect() - Waiting for recoverCallBack');
|
|
4440
4457
|
|
|
4441
|
-
|
|
4442
|
-
this.
|
|
4443
|
-
tags: ['connection']
|
|
4444
|
-
});
|
|
4458
|
+
_context6.next = 26;
|
|
4459
|
+
return this.client.recoverState();
|
|
4445
4460
|
|
|
4446
4461
|
case 26:
|
|
4462
|
+
this._log('_reconnect() - Finished recoverCallBack');
|
|
4463
|
+
|
|
4447
4464
|
this.consecutiveFailures = 0;
|
|
4448
|
-
_context6.next =
|
|
4465
|
+
_context6.next = 38;
|
|
4449
4466
|
break;
|
|
4450
4467
|
|
|
4451
|
-
case
|
|
4452
|
-
_context6.prev =
|
|
4453
|
-
_context6.t0 = _context6["catch"](
|
|
4468
|
+
case 30:
|
|
4469
|
+
_context6.prev = 30;
|
|
4470
|
+
_context6.t0 = _context6["catch"](20);
|
|
4454
4471
|
this.isHealthy = false;
|
|
4455
4472
|
this.consecutiveFailures += 1;
|
|
4456
4473
|
|
|
4457
|
-
if (!(_context6.t0.code === chatCodes.TOKEN_EXPIRED && !this.tokenManager.isStatic())) {
|
|
4458
|
-
_context6.next =
|
|
4474
|
+
if (!(_context6.t0.code === chatCodes.TOKEN_EXPIRED && !this.client.tokenManager.isStatic())) {
|
|
4475
|
+
_context6.next = 37;
|
|
4459
4476
|
break;
|
|
4460
4477
|
}
|
|
4461
4478
|
|
|
4462
|
-
this.
|
|
4463
|
-
|
|
4464
|
-
});
|
|
4479
|
+
this._log('_reconnect() - WS failure due to expired token, so going to try to reload token and reconnect');
|
|
4480
|
+
|
|
4465
4481
|
return _context6.abrupt("return", this._reconnect({
|
|
4466
4482
|
refreshToken: true
|
|
4467
4483
|
}));
|
|
4468
4484
|
|
|
4469
|
-
case
|
|
4485
|
+
case 37:
|
|
4470
4486
|
// reconnect on WS failures, don't reconnect if there is a code bug
|
|
4471
4487
|
if (_context6.t0.isWSFailure) {
|
|
4472
|
-
this.
|
|
4473
|
-
tags: ['connection']
|
|
4474
|
-
});
|
|
4488
|
+
this._log('_reconnect() - WS failure, so going to try to reconnect');
|
|
4475
4489
|
|
|
4476
4490
|
this._reconnect();
|
|
4477
4491
|
}
|
|
4478
4492
|
|
|
4479
|
-
case 37:
|
|
4480
|
-
this.logger('info', 'connection:_reconnect() - == END ==', {
|
|
4481
|
-
tags: ['connection']
|
|
4482
|
-
});
|
|
4483
|
-
|
|
4484
4493
|
case 38:
|
|
4494
|
+
this._log('_reconnect() - == END ==');
|
|
4495
|
+
|
|
4496
|
+
case 39:
|
|
4485
4497
|
case "end":
|
|
4486
4498
|
return _context6.stop();
|
|
4487
4499
|
}
|
|
4488
4500
|
}
|
|
4489
|
-
}, _callee6, this, [[
|
|
4501
|
+
}, _callee6, this, [[20, 30]]);
|
|
4490
4502
|
}));
|
|
4491
4503
|
|
|
4492
4504
|
function _reconnect() {
|
|
@@ -4515,13 +4527,10 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4515
4527
|
this.wsID += 1;
|
|
4516
4528
|
|
|
4517
4529
|
try {
|
|
4518
|
-
|
|
4519
|
-
this.ws.removeAllListeners();
|
|
4520
|
-
}
|
|
4530
|
+
var _this$ws2, _this$ws3;
|
|
4521
4531
|
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
}
|
|
4532
|
+
this === null || this === void 0 ? void 0 : (_this$ws2 = this.ws) === null || _this$ws2 === void 0 ? void 0 : _this$ws2.removeAllListeners();
|
|
4533
|
+
this === null || this === void 0 ? void 0 : (_this$ws3 = this.ws) === null || _this$ws3 === void 0 ? void 0 : _this$ws3.close();
|
|
4525
4534
|
} catch (e) {// we don't care
|
|
4526
4535
|
}
|
|
4527
4536
|
}
|
|
@@ -4538,9 +4547,9 @@ var jwt = null;
|
|
|
4538
4547
|
|
|
4539
4548
|
var crypto$1 = null;
|
|
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
|
|
|
@@ -4742,76 +4751,576 @@ function TokenManager(secret) {
|
|
|
4742
4751
|
break;
|
|
4743
4752
|
}
|
|
4744
4753
|
|
|
4745
|
-
return _context2.abrupt("return", resolve(_this.token));
|
|
4754
|
+
return _context2.abrupt("return", resolve(_this.token));
|
|
4755
|
+
|
|
4756
|
+
case 2:
|
|
4757
|
+
if (!(_this.tokenProvider && typeof _this.tokenProvider !== 'string')) {
|
|
4758
|
+
_context2.next = 7;
|
|
4759
|
+
break;
|
|
4760
|
+
}
|
|
4761
|
+
|
|
4762
|
+
_context2.next = 5;
|
|
4763
|
+
return _this.tokenProvider();
|
|
4764
|
+
|
|
4765
|
+
case 5:
|
|
4766
|
+
_this.token = _context2.sent;
|
|
4767
|
+
resolve(_this.token);
|
|
4768
|
+
|
|
4769
|
+
case 7:
|
|
4770
|
+
case "end":
|
|
4771
|
+
return _context2.stop();
|
|
4772
|
+
}
|
|
4773
|
+
}
|
|
4774
|
+
}, _callee2);
|
|
4775
|
+
}));
|
|
4776
|
+
|
|
4777
|
+
return function (_x3) {
|
|
4778
|
+
return _ref2.apply(this, arguments);
|
|
4779
|
+
};
|
|
4780
|
+
}());
|
|
4781
|
+
return _this.loadTokenPromise;
|
|
4782
|
+
});
|
|
4783
|
+
|
|
4784
|
+
_defineProperty__default['default'](this, "getToken", function () {
|
|
4785
|
+
if (_this.token) {
|
|
4786
|
+
return _this.token;
|
|
4787
|
+
}
|
|
4788
|
+
|
|
4789
|
+
if (_this.user && _this.user.anon && !_this.token) {
|
|
4790
|
+
return _this.token;
|
|
4791
|
+
}
|
|
4792
|
+
|
|
4793
|
+
if (_this.secret) {
|
|
4794
|
+
return JWTServerToken(_this.secret);
|
|
4795
|
+
}
|
|
4796
|
+
|
|
4797
|
+
throw new Error("Both secret and user tokens are not set. Either client.connectUser wasn't called or client.disconnect was called");
|
|
4798
|
+
});
|
|
4799
|
+
|
|
4800
|
+
_defineProperty__default['default'](this, "isStatic", function () {
|
|
4801
|
+
return _this.type === 'static';
|
|
4802
|
+
});
|
|
4803
|
+
|
|
4804
|
+
this.loadTokenPromise = null;
|
|
4805
|
+
|
|
4806
|
+
if (secret) {
|
|
4807
|
+
this.secret = secret;
|
|
4808
|
+
}
|
|
4809
|
+
|
|
4810
|
+
this.type = 'static';
|
|
4811
|
+
|
|
4812
|
+
if (this.secret) {
|
|
4813
|
+
this.token = JWTServerToken(this.secret);
|
|
4814
|
+
}
|
|
4815
|
+
}
|
|
4816
|
+
/**
|
|
4817
|
+
* Set the static string token or token provider.
|
|
4818
|
+
* Token provider should return a token string or a promise which resolves to string token.
|
|
4819
|
+
*
|
|
4820
|
+
* @param {TokenOrProvider} tokenOrProvider
|
|
4821
|
+
* @param {UserResponse<UserType>} user
|
|
4822
|
+
*/
|
|
4823
|
+
;
|
|
4824
|
+
|
|
4825
|
+
var APIErrorCodes = {
|
|
4826
|
+
'-1': {
|
|
4827
|
+
name: 'InternalSystemError',
|
|
4828
|
+
retryable: true
|
|
4829
|
+
},
|
|
4830
|
+
'2': {
|
|
4831
|
+
name: 'AccessKeyError',
|
|
4832
|
+
retryable: false
|
|
4833
|
+
},
|
|
4834
|
+
'3': {
|
|
4835
|
+
name: 'AuthenticationFailedError',
|
|
4836
|
+
retryable: true
|
|
4837
|
+
},
|
|
4838
|
+
'4': {
|
|
4839
|
+
name: 'InputError',
|
|
4840
|
+
retryable: false
|
|
4841
|
+
},
|
|
4842
|
+
'6': {
|
|
4843
|
+
name: 'DuplicateUsernameError',
|
|
4844
|
+
retryable: false
|
|
4845
|
+
},
|
|
4846
|
+
'9': {
|
|
4847
|
+
name: 'RateLimitError',
|
|
4848
|
+
retryable: true
|
|
4849
|
+
},
|
|
4850
|
+
'16': {
|
|
4851
|
+
name: 'DoesNotExistError',
|
|
4852
|
+
retryable: false
|
|
4853
|
+
},
|
|
4854
|
+
'17': {
|
|
4855
|
+
name: 'NotAllowedError',
|
|
4856
|
+
retryable: false
|
|
4857
|
+
},
|
|
4858
|
+
'18': {
|
|
4859
|
+
name: 'EventNotSupportedError',
|
|
4860
|
+
retryable: false
|
|
4861
|
+
},
|
|
4862
|
+
'19': {
|
|
4863
|
+
name: 'ChannelFeatureNotSupportedError',
|
|
4864
|
+
retryable: false
|
|
4865
|
+
},
|
|
4866
|
+
'20': {
|
|
4867
|
+
name: 'MessageTooLongError',
|
|
4868
|
+
retryable: false
|
|
4869
|
+
},
|
|
4870
|
+
'21': {
|
|
4871
|
+
name: 'MultipleNestingLevelError',
|
|
4872
|
+
retryable: false
|
|
4873
|
+
},
|
|
4874
|
+
'22': {
|
|
4875
|
+
name: 'PayloadTooBigError',
|
|
4876
|
+
retryable: false
|
|
4877
|
+
},
|
|
4878
|
+
'23': {
|
|
4879
|
+
name: 'RequestTimeoutError',
|
|
4880
|
+
retryable: true
|
|
4881
|
+
},
|
|
4882
|
+
'24': {
|
|
4883
|
+
name: 'MaxHeaderSizeExceededError',
|
|
4884
|
+
retryable: false
|
|
4885
|
+
},
|
|
4886
|
+
'40': {
|
|
4887
|
+
name: 'AuthErrorTokenExpired',
|
|
4888
|
+
retryable: false
|
|
4889
|
+
},
|
|
4890
|
+
'41': {
|
|
4891
|
+
name: 'AuthErrorTokenNotValidYet',
|
|
4892
|
+
retryable: false
|
|
4893
|
+
},
|
|
4894
|
+
'42': {
|
|
4895
|
+
name: 'AuthErrorTokenUsedBeforeIssuedAt',
|
|
4896
|
+
retryable: false
|
|
4897
|
+
},
|
|
4898
|
+
'43': {
|
|
4899
|
+
name: 'AuthErrorTokenSignatureInvalid',
|
|
4900
|
+
retryable: false
|
|
4901
|
+
},
|
|
4902
|
+
'44': {
|
|
4903
|
+
name: 'CustomCommandEndpointMissingError',
|
|
4904
|
+
retryable: false
|
|
4905
|
+
},
|
|
4906
|
+
'45': {
|
|
4907
|
+
name: 'CustomCommandEndpointCallError',
|
|
4908
|
+
retryable: true
|
|
4909
|
+
},
|
|
4910
|
+
'46': {
|
|
4911
|
+
name: 'ConnectionIDNotFoundError',
|
|
4912
|
+
retryable: false
|
|
4913
|
+
},
|
|
4914
|
+
'60': {
|
|
4915
|
+
name: 'CoolDownError',
|
|
4916
|
+
retryable: true
|
|
4917
|
+
},
|
|
4918
|
+
'69': {
|
|
4919
|
+
name: 'ErrWrongRegion',
|
|
4920
|
+
retryable: false
|
|
4921
|
+
},
|
|
4922
|
+
'70': {
|
|
4923
|
+
name: 'ErrQueryChannelPermissions',
|
|
4924
|
+
retryable: false
|
|
4925
|
+
},
|
|
4926
|
+
'71': {
|
|
4927
|
+
name: 'ErrTooManyConnections',
|
|
4928
|
+
retryable: true
|
|
4929
|
+
},
|
|
4930
|
+
'99': {
|
|
4931
|
+
name: 'AppSuspendedError',
|
|
4932
|
+
retryable: false
|
|
4933
|
+
}
|
|
4934
|
+
};
|
|
4935
|
+
function isAPIError(error) {
|
|
4936
|
+
return error.code !== undefined;
|
|
4937
|
+
}
|
|
4938
|
+
function isErrorRetryable(error) {
|
|
4939
|
+
if (!error.code) return false;
|
|
4940
|
+
var err = APIErrorCodes["".concat(error.code)];
|
|
4941
|
+
if (!err) return false;
|
|
4942
|
+
return err.retryable;
|
|
4943
|
+
}
|
|
4944
|
+
function isConnectionIDError(error) {
|
|
4945
|
+
return error.code === 46; // ConnectionIDNotFoundError
|
|
4946
|
+
}
|
|
4947
|
+
function isWSFailure(err) {
|
|
4948
|
+
if (typeof err.isWSFailure === 'boolean') {
|
|
4949
|
+
return err.isWSFailure;
|
|
4950
|
+
}
|
|
4951
|
+
|
|
4952
|
+
try {
|
|
4953
|
+
return JSON.parse(err.message).isWSFailure;
|
|
4954
|
+
} catch (_) {
|
|
4955
|
+
return false;
|
|
4956
|
+
}
|
|
4957
|
+
}
|
|
4958
|
+
|
|
4959
|
+
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; }
|
|
4960
|
+
|
|
4961
|
+
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; }
|
|
4962
|
+
var ConnectionState;
|
|
4963
|
+
|
|
4964
|
+
(function (ConnectionState) {
|
|
4965
|
+
ConnectionState["Closed"] = "CLOSED";
|
|
4966
|
+
ConnectionState["Connected"] = "CONNECTED";
|
|
4967
|
+
ConnectionState["Connecting"] = "CONNECTING";
|
|
4968
|
+
ConnectionState["Disconnected"] = "DISCONNECTED";
|
|
4969
|
+
ConnectionState["Init"] = "INIT";
|
|
4970
|
+
})(ConnectionState || (ConnectionState = {}));
|
|
4971
|
+
|
|
4972
|
+
var WSConnectionFallback = /*#__PURE__*/function () {
|
|
4973
|
+
function WSConnectionFallback(_ref) {
|
|
4974
|
+
var _this = this;
|
|
4975
|
+
|
|
4976
|
+
var client = _ref.client;
|
|
4977
|
+
|
|
4978
|
+
_classCallCheck__default['default'](this, WSConnectionFallback);
|
|
4979
|
+
|
|
4980
|
+
_defineProperty__default['default'](this, "client", void 0);
|
|
4981
|
+
|
|
4982
|
+
_defineProperty__default['default'](this, "state", void 0);
|
|
4983
|
+
|
|
4984
|
+
_defineProperty__default['default'](this, "consecutiveFailures", void 0);
|
|
4985
|
+
|
|
4986
|
+
_defineProperty__default['default'](this, "connectionID", void 0);
|
|
4987
|
+
|
|
4988
|
+
_defineProperty__default['default'](this, "cancelToken", void 0);
|
|
4989
|
+
|
|
4990
|
+
_defineProperty__default['default'](this, "_onlineStatusChanged", function (event) {
|
|
4991
|
+
_this._log("_onlineStatusChanged() - ".concat(event.type));
|
|
4992
|
+
|
|
4993
|
+
if (event.type === 'offline') {
|
|
4994
|
+
var _this$cancelToken;
|
|
4995
|
+
|
|
4996
|
+
_this._setState(ConnectionState.Closed);
|
|
4997
|
+
|
|
4998
|
+
(_this$cancelToken = _this.cancelToken) === null || _this$cancelToken === void 0 ? void 0 : _this$cancelToken.cancel('disconnect() is called');
|
|
4999
|
+
_this.cancelToken = undefined;
|
|
5000
|
+
return;
|
|
5001
|
+
}
|
|
5002
|
+
|
|
5003
|
+
if (event.type === 'online' && _this.state === ConnectionState.Closed) {
|
|
5004
|
+
_this.connect(true);
|
|
5005
|
+
}
|
|
5006
|
+
});
|
|
5007
|
+
|
|
5008
|
+
_defineProperty__default['default'](this, "_req", /*#__PURE__*/function () {
|
|
5009
|
+
var _ref2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(params, config, retry) {
|
|
5010
|
+
var _this$cancelToken2, res;
|
|
5011
|
+
|
|
5012
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
5013
|
+
while (1) {
|
|
5014
|
+
switch (_context.prev = _context.next) {
|
|
5015
|
+
case 0:
|
|
5016
|
+
if (!_this.cancelToken && !params.close) {
|
|
5017
|
+
_this.cancelToken = axios__default['default'].CancelToken.source();
|
|
5018
|
+
}
|
|
5019
|
+
|
|
5020
|
+
_context.prev = 1;
|
|
5021
|
+
_context.next = 4;
|
|
5022
|
+
return _this.client.doAxiosRequest('get', _this.client.baseURL.replace(':3030', ':8900') + '/longpoll', // replace port if present for testing with local API
|
|
5023
|
+
undefined, {
|
|
5024
|
+
config: _objectSpread$1(_objectSpread$1({}, config), {}, {
|
|
5025
|
+
cancelToken: (_this$cancelToken2 = _this.cancelToken) === null || _this$cancelToken2 === void 0 ? void 0 : _this$cancelToken2.token
|
|
5026
|
+
}),
|
|
5027
|
+
params: params
|
|
5028
|
+
});
|
|
5029
|
+
|
|
5030
|
+
case 4:
|
|
5031
|
+
res = _context.sent;
|
|
5032
|
+
_this.consecutiveFailures = 0; // always reset in case of no error
|
|
5033
|
+
|
|
5034
|
+
return _context.abrupt("return", res);
|
|
5035
|
+
|
|
5036
|
+
case 9:
|
|
5037
|
+
_context.prev = 9;
|
|
5038
|
+
_context.t0 = _context["catch"](1);
|
|
5039
|
+
_this.consecutiveFailures += 1;
|
|
5040
|
+
|
|
5041
|
+
if (!(retry && isErrorRetryable(_context.t0))) {
|
|
5042
|
+
_context.next = 17;
|
|
5043
|
+
break;
|
|
5044
|
+
}
|
|
5045
|
+
|
|
5046
|
+
_this._log("_req() - Retryable error, retrying request");
|
|
5047
|
+
|
|
5048
|
+
_context.next = 16;
|
|
5049
|
+
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5050
|
+
|
|
5051
|
+
case 16:
|
|
5052
|
+
return _context.abrupt("return", _this._req(params, config, retry));
|
|
5053
|
+
|
|
5054
|
+
case 17:
|
|
5055
|
+
throw _context.t0;
|
|
5056
|
+
|
|
5057
|
+
case 18:
|
|
5058
|
+
case "end":
|
|
5059
|
+
return _context.stop();
|
|
5060
|
+
}
|
|
5061
|
+
}
|
|
5062
|
+
}, _callee, null, [[1, 9]]);
|
|
5063
|
+
}));
|
|
5064
|
+
|
|
5065
|
+
return function (_x, _x2, _x3) {
|
|
5066
|
+
return _ref2.apply(this, arguments);
|
|
5067
|
+
};
|
|
5068
|
+
}());
|
|
5069
|
+
|
|
5070
|
+
_defineProperty__default['default'](this, "_poll", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
|
|
5071
|
+
var _data$events, data, i;
|
|
5072
|
+
|
|
5073
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
5074
|
+
while (1) {
|
|
5075
|
+
switch (_context2.prev = _context2.next) {
|
|
5076
|
+
case 0:
|
|
5077
|
+
if (!(_this.state === ConnectionState.Connected)) {
|
|
5078
|
+
_context2.next = 25;
|
|
5079
|
+
break;
|
|
5080
|
+
}
|
|
5081
|
+
|
|
5082
|
+
_context2.prev = 1;
|
|
5083
|
+
_context2.next = 4;
|
|
5084
|
+
return _this._req({}, {
|
|
5085
|
+
timeout: 30000
|
|
5086
|
+
}, true);
|
|
5087
|
+
|
|
5088
|
+
case 4:
|
|
5089
|
+
data = _context2.sent;
|
|
5090
|
+
|
|
5091
|
+
// 30s => API responds in 20s if there is no event
|
|
5092
|
+
if ((_data$events = data.events) !== null && _data$events !== void 0 && _data$events.length) {
|
|
5093
|
+
for (i = 0; i < data.events.length; i++) {
|
|
5094
|
+
_this.client.dispatchEvent(data.events[i]);
|
|
5095
|
+
}
|
|
5096
|
+
}
|
|
5097
|
+
|
|
5098
|
+
_context2.next = 23;
|
|
5099
|
+
break;
|
|
5100
|
+
|
|
5101
|
+
case 8:
|
|
5102
|
+
_context2.prev = 8;
|
|
5103
|
+
_context2.t0 = _context2["catch"](1);
|
|
5104
|
+
|
|
5105
|
+
if (!axios__default['default'].isCancel(_context2.t0)) {
|
|
5106
|
+
_context2.next = 13;
|
|
5107
|
+
break;
|
|
5108
|
+
}
|
|
5109
|
+
|
|
5110
|
+
_this._log("_poll() - axios canceled request");
|
|
5111
|
+
|
|
5112
|
+
return _context2.abrupt("return");
|
|
5113
|
+
|
|
5114
|
+
case 13:
|
|
5115
|
+
if (!isConnectionIDError(_context2.t0)) {
|
|
5116
|
+
_context2.next = 18;
|
|
5117
|
+
break;
|
|
5118
|
+
}
|
|
5119
|
+
|
|
5120
|
+
_this._log("_poll() - ConnectionID error, connecting without ID...");
|
|
5121
|
+
|
|
5122
|
+
_this._setState(ConnectionState.Disconnected);
|
|
5123
|
+
|
|
5124
|
+
_this.connect(true);
|
|
5125
|
+
|
|
5126
|
+
return _context2.abrupt("return");
|
|
5127
|
+
|
|
5128
|
+
case 18:
|
|
5129
|
+
if (!(isAPIError(_context2.t0) && !isErrorRetryable(_context2.t0))) {
|
|
5130
|
+
_context2.next = 21;
|
|
5131
|
+
break;
|
|
5132
|
+
}
|
|
5133
|
+
|
|
5134
|
+
_this._setState(ConnectionState.Closed);
|
|
5135
|
+
|
|
5136
|
+
return _context2.abrupt("return");
|
|
5137
|
+
|
|
5138
|
+
case 21:
|
|
5139
|
+
_context2.next = 23;
|
|
5140
|
+
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5141
|
+
|
|
5142
|
+
case 23:
|
|
5143
|
+
_context2.next = 0;
|
|
5144
|
+
break;
|
|
5145
|
+
|
|
5146
|
+
case 25:
|
|
5147
|
+
case "end":
|
|
5148
|
+
return _context2.stop();
|
|
5149
|
+
}
|
|
5150
|
+
}
|
|
5151
|
+
}, _callee2, null, [[1, 8]]);
|
|
5152
|
+
})));
|
|
5153
|
+
|
|
5154
|
+
_defineProperty__default['default'](this, "connect", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
5155
|
+
var reconnect,
|
|
5156
|
+
_yield$_this$_req,
|
|
5157
|
+
event,
|
|
5158
|
+
_args3 = arguments;
|
|
5159
|
+
|
|
5160
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
5161
|
+
while (1) {
|
|
5162
|
+
switch (_context3.prev = _context3.next) {
|
|
5163
|
+
case 0:
|
|
5164
|
+
reconnect = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : false;
|
|
5165
|
+
|
|
5166
|
+
if (!(_this.state === ConnectionState.Connecting)) {
|
|
5167
|
+
_context3.next = 3;
|
|
5168
|
+
break;
|
|
5169
|
+
}
|
|
5170
|
+
|
|
5171
|
+
throw new Error('connecting already in progress');
|
|
5172
|
+
|
|
5173
|
+
case 3:
|
|
5174
|
+
if (!(_this.state === ConnectionState.Connected)) {
|
|
5175
|
+
_context3.next = 5;
|
|
5176
|
+
break;
|
|
5177
|
+
}
|
|
5178
|
+
|
|
5179
|
+
throw new Error('already connected and polling');
|
|
5180
|
+
|
|
5181
|
+
case 5:
|
|
5182
|
+
_this._setState(ConnectionState.Connecting);
|
|
5183
|
+
|
|
5184
|
+
_this.connectionID = undefined; // connect should be sent with empty connection_id so API creates one
|
|
5185
|
+
|
|
5186
|
+
_context3.prev = 7;
|
|
5187
|
+
_context3.next = 10;
|
|
5188
|
+
return _this._req({
|
|
5189
|
+
json: _this.client._buildWSPayload()
|
|
5190
|
+
}, {
|
|
5191
|
+
timeout: 8000
|
|
5192
|
+
}, // 8s
|
|
5193
|
+
reconnect);
|
|
5194
|
+
|
|
5195
|
+
case 10:
|
|
5196
|
+
_yield$_this$_req = _context3.sent;
|
|
5197
|
+
event = _yield$_this$_req.event;
|
|
5198
|
+
|
|
5199
|
+
_this._setState(ConnectionState.Connected);
|
|
5200
|
+
|
|
5201
|
+
_this.connectionID = event.connection_id;
|
|
5202
|
+
|
|
5203
|
+
_this._poll();
|
|
5204
|
+
|
|
5205
|
+
if (reconnect) {
|
|
5206
|
+
_this.client.recoverState();
|
|
5207
|
+
}
|
|
5208
|
+
|
|
5209
|
+
return _context3.abrupt("return", event);
|
|
5210
|
+
|
|
5211
|
+
case 19:
|
|
5212
|
+
_context3.prev = 19;
|
|
5213
|
+
_context3.t0 = _context3["catch"](7);
|
|
5214
|
+
|
|
5215
|
+
_this._setState(ConnectionState.Closed);
|
|
5216
|
+
|
|
5217
|
+
throw _context3.t0;
|
|
5218
|
+
|
|
5219
|
+
case 23:
|
|
5220
|
+
case "end":
|
|
5221
|
+
return _context3.stop();
|
|
5222
|
+
}
|
|
5223
|
+
}
|
|
5224
|
+
}, _callee3, null, [[7, 19]]);
|
|
5225
|
+
})));
|
|
5226
|
+
|
|
5227
|
+
_defineProperty__default['default'](this, "isHealthy", function () {
|
|
5228
|
+
return _this.connectionID && _this.state === ConnectionState.Connected;
|
|
5229
|
+
});
|
|
4746
5230
|
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
_context2.next = 7;
|
|
4750
|
-
break;
|
|
4751
|
-
}
|
|
5231
|
+
_defineProperty__default['default'](this, "disconnect", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4() {
|
|
5232
|
+
var _this$cancelToken3;
|
|
4752
5233
|
|
|
4753
|
-
|
|
4754
|
-
|
|
5234
|
+
var timeout,
|
|
5235
|
+
_args4 = arguments;
|
|
5236
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
5237
|
+
while (1) {
|
|
5238
|
+
switch (_context4.prev = _context4.next) {
|
|
5239
|
+
case 0:
|
|
5240
|
+
timeout = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : 2000;
|
|
5241
|
+
removeConnectionEventListeners(_this._onlineStatusChanged);
|
|
4755
5242
|
|
|
4756
|
-
|
|
4757
|
-
_this.token = _context2.sent;
|
|
4758
|
-
resolve(_this.token);
|
|
5243
|
+
_this._setState(ConnectionState.Disconnected);
|
|
4759
5244
|
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
5245
|
+
(_this$cancelToken3 = _this.cancelToken) === null || _this$cancelToken3 === void 0 ? void 0 : _this$cancelToken3.cancel('disconnect() is called');
|
|
5246
|
+
_this.cancelToken = undefined;
|
|
5247
|
+
_context4.prev = 5;
|
|
5248
|
+
_context4.next = 8;
|
|
5249
|
+
return _this._req({
|
|
5250
|
+
close: true
|
|
5251
|
+
}, {
|
|
5252
|
+
timeout: timeout
|
|
5253
|
+
}, false);
|
|
4767
5254
|
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
};
|
|
4771
|
-
}());
|
|
4772
|
-
return _this.loadTokenPromise;
|
|
4773
|
-
});
|
|
5255
|
+
case 8:
|
|
5256
|
+
_this.connectionID = undefined;
|
|
4774
5257
|
|
|
4775
|
-
|
|
4776
|
-
if (_this.token) {
|
|
4777
|
-
return _this.token;
|
|
4778
|
-
}
|
|
5258
|
+
_this._log("disconnect() - Closed connectionID");
|
|
4779
5259
|
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
}
|
|
5260
|
+
_context4.next = 15;
|
|
5261
|
+
break;
|
|
4783
5262
|
|
|
4784
|
-
|
|
4785
|
-
|
|
5263
|
+
case 12:
|
|
5264
|
+
_context4.prev = 12;
|
|
5265
|
+
_context4.t0 = _context4["catch"](5);
|
|
5266
|
+
|
|
5267
|
+
_this._log("disconnect() - Failed", {
|
|
5268
|
+
err: _context4.t0
|
|
5269
|
+
});
|
|
5270
|
+
|
|
5271
|
+
case 15:
|
|
5272
|
+
case "end":
|
|
5273
|
+
return _context4.stop();
|
|
5274
|
+
}
|
|
5275
|
+
}
|
|
5276
|
+
}, _callee4, null, [[5, 12]]);
|
|
5277
|
+
})));
|
|
5278
|
+
|
|
5279
|
+
this.client = client;
|
|
5280
|
+
this.state = ConnectionState.Init;
|
|
5281
|
+
this.consecutiveFailures = 0;
|
|
5282
|
+
addConnectionEventListeners(this._onlineStatusChanged);
|
|
5283
|
+
}
|
|
5284
|
+
|
|
5285
|
+
_createClass__default['default'](WSConnectionFallback, [{
|
|
5286
|
+
key: "_log",
|
|
5287
|
+
value: function _log(msg) {
|
|
5288
|
+
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5289
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
5290
|
+
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$1({
|
|
5291
|
+
tags: ['connection_fallback', 'connection']
|
|
5292
|
+
}, extra));
|
|
4786
5293
|
}
|
|
5294
|
+
}, {
|
|
5295
|
+
key: "_setState",
|
|
5296
|
+
value: function _setState(state) {
|
|
5297
|
+
this._log("_setState() - ".concat(state)); // transition from connecting => connected
|
|
4787
5298
|
|
|
4788
|
-
throw new Error("Both secret and user tokens are not set. Either client.connectUser wasn't called or client.disconnect was called");
|
|
4789
|
-
});
|
|
4790
5299
|
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
5300
|
+
if (this.state === ConnectionState.Connecting && state === ConnectionState.Connected) {
|
|
5301
|
+
//@ts-expect-error
|
|
5302
|
+
this.client.dispatchEvent({
|
|
5303
|
+
type: 'connection.changed',
|
|
5304
|
+
online: true
|
|
5305
|
+
});
|
|
5306
|
+
}
|
|
4794
5307
|
|
|
4795
|
-
|
|
5308
|
+
if (state === ConnectionState.Closed || state === ConnectionState.Disconnected) {
|
|
5309
|
+
//@ts-expect-error
|
|
5310
|
+
this.client.dispatchEvent({
|
|
5311
|
+
type: 'connection.changed',
|
|
5312
|
+
online: false
|
|
5313
|
+
});
|
|
5314
|
+
}
|
|
4796
5315
|
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
5316
|
+
this.state = state;
|
|
5317
|
+
}
|
|
5318
|
+
/** @private */
|
|
4800
5319
|
|
|
4801
|
-
|
|
5320
|
+
}]);
|
|
4802
5321
|
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
}
|
|
4806
|
-
}
|
|
4807
|
-
/**
|
|
4808
|
-
* Set the static string token or token provider.
|
|
4809
|
-
* Token provider should return a token string or a promise which resolves to string token.
|
|
4810
|
-
*
|
|
4811
|
-
* @param {TokenOrProvider} tokenOrProvider
|
|
4812
|
-
* @param {UserResponse<UserType>} user
|
|
4813
|
-
*/
|
|
4814
|
-
;
|
|
5322
|
+
return WSConnectionFallback;
|
|
5323
|
+
}();
|
|
4815
5324
|
|
|
4816
5325
|
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; } } }; }
|
|
4817
5326
|
|
|
@@ -4851,10 +5360,6 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4851
5360
|
|
|
4852
5361
|
_defineProperty__default['default'](this, "configs", void 0);
|
|
4853
5362
|
|
|
4854
|
-
_defineProperty__default['default'](this, "connectionID", void 0);
|
|
4855
|
-
|
|
4856
|
-
_defineProperty__default['default'](this, "failures", void 0);
|
|
4857
|
-
|
|
4858
5363
|
_defineProperty__default['default'](this, "key", void 0);
|
|
4859
5364
|
|
|
4860
5365
|
_defineProperty__default['default'](this, "listeners", void 0);
|
|
@@ -4889,16 +5394,26 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4889
5394
|
|
|
4890
5395
|
_defineProperty__default['default'](this, "wsConnection", void 0);
|
|
4891
5396
|
|
|
5397
|
+
_defineProperty__default['default'](this, "wsFallback", void 0);
|
|
5398
|
+
|
|
4892
5399
|
_defineProperty__default['default'](this, "wsPromise", void 0);
|
|
4893
5400
|
|
|
4894
5401
|
_defineProperty__default['default'](this, "consecutiveFailures", void 0);
|
|
4895
5402
|
|
|
4896
5403
|
_defineProperty__default['default'](this, "insightMetrics", void 0);
|
|
4897
5404
|
|
|
4898
|
-
_defineProperty__default['default'](this, "
|
|
4899
|
-
|
|
5405
|
+
_defineProperty__default['default'](this, "defaultWSTimeoutWithFallback", void 0);
|
|
5406
|
+
|
|
5407
|
+
_defineProperty__default['default'](this, "defaultWSTimeout", void 0);
|
|
5408
|
+
|
|
5409
|
+
_defineProperty__default['default'](this, "_getConnectionID", function () {
|
|
5410
|
+
var _this$wsConnection, _this$wsFallback;
|
|
4900
5411
|
|
|
4901
|
-
return
|
|
5412
|
+
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);
|
|
5413
|
+
});
|
|
5414
|
+
|
|
5415
|
+
_defineProperty__default['default'](this, "_hasConnectionID", function () {
|
|
5416
|
+
return Boolean(_this._getConnectionID());
|
|
4902
5417
|
});
|
|
4903
5418
|
|
|
4904
5419
|
_defineProperty__default['default'](this, "connectUser", /*#__PURE__*/function () {
|
|
@@ -4984,36 +5499,55 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4984
5499
|
return _this.tokenManager.setTokenOrProvider(userTokenOrProvider, user);
|
|
4985
5500
|
});
|
|
4986
5501
|
|
|
4987
|
-
_defineProperty__default['default'](this, "closeConnection", function (
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
_this.cleaningIntervalRef = undefined;
|
|
4991
|
-
}
|
|
5502
|
+
_defineProperty__default['default'](this, "closeConnection", /*#__PURE__*/function () {
|
|
5503
|
+
var _ref2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2(timeout) {
|
|
5504
|
+
var _this$wsConnection2, _this$wsFallback2;
|
|
4992
5505
|
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
5506
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
5507
|
+
while (1) {
|
|
5508
|
+
switch (_context2.prev = _context2.next) {
|
|
5509
|
+
case 0:
|
|
5510
|
+
if (_this.cleaningIntervalRef != null) {
|
|
5511
|
+
clearInterval(_this.cleaningIntervalRef);
|
|
5512
|
+
_this.cleaningIntervalRef = undefined;
|
|
5513
|
+
}
|
|
4996
5514
|
|
|
4997
|
-
|
|
4998
|
-
|
|
5515
|
+
_context2.next = 3;
|
|
5516
|
+
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)]);
|
|
4999
5517
|
|
|
5000
|
-
|
|
5001
|
-
|
|
5518
|
+
case 3:
|
|
5519
|
+
return _context2.abrupt("return", Promise.resolve());
|
|
5002
5520
|
|
|
5003
|
-
|
|
5521
|
+
case 4:
|
|
5522
|
+
case "end":
|
|
5523
|
+
return _context2.stop();
|
|
5524
|
+
}
|
|
5525
|
+
}
|
|
5526
|
+
}, _callee2);
|
|
5527
|
+
}));
|
|
5528
|
+
|
|
5529
|
+
return function (_x3) {
|
|
5530
|
+
return _ref2.apply(this, arguments);
|
|
5531
|
+
};
|
|
5532
|
+
}());
|
|
5533
|
+
|
|
5534
|
+
_defineProperty__default['default'](this, "openConnection", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
5535
|
+
var _this$wsConnection3, _this$wsFallback3;
|
|
5536
|
+
|
|
5537
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
5004
5538
|
while (1) {
|
|
5005
|
-
switch (
|
|
5539
|
+
switch (_context3.prev = _context3.next) {
|
|
5006
5540
|
case 0:
|
|
5007
5541
|
if (_this.userID) {
|
|
5008
|
-
|
|
5542
|
+
_context3.next = 2;
|
|
5009
5543
|
break;
|
|
5010
5544
|
}
|
|
5011
5545
|
|
|
5012
5546
|
throw Error('User is not set on client, use client.connectUser or client.connectAnonymousUser instead');
|
|
5013
5547
|
|
|
5014
5548
|
case 2:
|
|
5015
|
-
if (!((_this$
|
|
5016
|
-
|
|
5549
|
+
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())) {
|
|
5550
|
+
_context3.next = 5;
|
|
5017
5551
|
break;
|
|
5018
5552
|
}
|
|
5019
5553
|
|
|
@@ -5021,7 +5555,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5021
5555
|
tags: ['connection', 'client']
|
|
5022
5556
|
});
|
|
5023
5557
|
|
|
5024
|
-
return
|
|
5558
|
+
return _context3.abrupt("return", Promise.resolve());
|
|
5025
5559
|
|
|
5026
5560
|
case 5:
|
|
5027
5561
|
_this.clientID = "".concat(_this.userID, "--").concat(randomId());
|
|
@@ -5029,14 +5563,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5029
5563
|
|
|
5030
5564
|
_this._startCleaning();
|
|
5031
5565
|
|
|
5032
|
-
return
|
|
5566
|
+
return _context3.abrupt("return", _this.wsPromise);
|
|
5033
5567
|
|
|
5034
5568
|
case 9:
|
|
5035
5569
|
case "end":
|
|
5036
|
-
return
|
|
5570
|
+
return _context3.stop();
|
|
5037
5571
|
}
|
|
5038
5572
|
}
|
|
5039
|
-
},
|
|
5573
|
+
}, _callee3);
|
|
5040
5574
|
})));
|
|
5041
5575
|
|
|
5042
5576
|
_defineProperty__default['default'](this, "_setupConnection", this.openConnection);
|
|
@@ -5054,12 +5588,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5054
5588
|
});
|
|
5055
5589
|
|
|
5056
5590
|
_defineProperty__default['default'](this, "disconnectUser", /*#__PURE__*/function () {
|
|
5057
|
-
var
|
|
5591
|
+
var _ref4 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4(timeout) {
|
|
5058
5592
|
var closePromise, _i, _Object$values, _channel;
|
|
5059
5593
|
|
|
5060
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
5594
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
5061
5595
|
while (1) {
|
|
5062
|
-
switch (
|
|
5596
|
+
switch (_context4.prev = _context4.next) {
|
|
5063
5597
|
case 0:
|
|
5064
5598
|
_this.logger('info', 'client:disconnect() - Disconnecting the client', {
|
|
5065
5599
|
tags: ['connection', 'client']
|
|
@@ -5083,21 +5617,21 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5083
5617
|
|
|
5084
5618
|
_this.state = new ClientState(); // reset token manager
|
|
5085
5619
|
|
|
5086
|
-
_this.tokenManager.reset
|
|
5087
|
-
|
|
5620
|
+
setTimeout(_this.tokenManager.reset); // delay reseting to use token for disconnect calls
|
|
5621
|
+
// close the WS connection
|
|
5088
5622
|
|
|
5089
|
-
return
|
|
5623
|
+
return _context4.abrupt("return", closePromise);
|
|
5090
5624
|
|
|
5091
5625
|
case 11:
|
|
5092
5626
|
case "end":
|
|
5093
|
-
return
|
|
5627
|
+
return _context4.stop();
|
|
5094
5628
|
}
|
|
5095
5629
|
}
|
|
5096
|
-
},
|
|
5630
|
+
}, _callee4);
|
|
5097
5631
|
}));
|
|
5098
5632
|
|
|
5099
|
-
return function (
|
|
5100
|
-
return
|
|
5633
|
+
return function (_x4) {
|
|
5634
|
+
return _ref4.apply(this, arguments);
|
|
5101
5635
|
};
|
|
5102
5636
|
}());
|
|
5103
5637
|
|
|
@@ -5125,76 +5659,78 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5125
5659
|
_defineProperty__default['default'](this, "setAnonymousUser", this.connectAnonymousUser);
|
|
5126
5660
|
|
|
5127
5661
|
_defineProperty__default['default'](this, "doAxiosRequest", /*#__PURE__*/function () {
|
|
5128
|
-
var
|
|
5662
|
+
var _ref5 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(type, url, data) {
|
|
5129
5663
|
var options,
|
|
5130
5664
|
requestConfig,
|
|
5131
5665
|
response,
|
|
5132
|
-
|
|
5133
|
-
|
|
5666
|
+
_requestConfig$header,
|
|
5667
|
+
_args5 = arguments;
|
|
5668
|
+
|
|
5669
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
|
|
5134
5670
|
while (1) {
|
|
5135
|
-
switch (
|
|
5671
|
+
switch (_context5.prev = _context5.next) {
|
|
5136
5672
|
case 0:
|
|
5137
|
-
options =
|
|
5138
|
-
|
|
5673
|
+
options = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : {};
|
|
5674
|
+
_context5.next = 3;
|
|
5139
5675
|
return _this.tokenManager.tokenReady();
|
|
5140
5676
|
|
|
5141
5677
|
case 3:
|
|
5142
5678
|
requestConfig = _this._enrichAxiosOptions(options);
|
|
5143
|
-
|
|
5679
|
+
_context5.prev = 4;
|
|
5144
5680
|
|
|
5145
5681
|
_this._logApiRequest(type, url, data, requestConfig);
|
|
5146
5682
|
|
|
5147
|
-
|
|
5148
|
-
|
|
5683
|
+
_context5.t0 = type;
|
|
5684
|
+
_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;
|
|
5149
5685
|
break;
|
|
5150
5686
|
|
|
5151
5687
|
case 9:
|
|
5152
|
-
|
|
5688
|
+
_context5.next = 11;
|
|
5153
5689
|
return _this.axiosInstance.get(url, requestConfig);
|
|
5154
5690
|
|
|
5155
5691
|
case 11:
|
|
5156
|
-
response =
|
|
5157
|
-
return
|
|
5692
|
+
response = _context5.sent;
|
|
5693
|
+
return _context5.abrupt("break", 34);
|
|
5158
5694
|
|
|
5159
5695
|
case 13:
|
|
5160
|
-
|
|
5696
|
+
_context5.next = 15;
|
|
5161
5697
|
return _this.axiosInstance.delete(url, requestConfig);
|
|
5162
5698
|
|
|
5163
5699
|
case 15:
|
|
5164
|
-
response =
|
|
5165
|
-
return
|
|
5700
|
+
response = _context5.sent;
|
|
5701
|
+
return _context5.abrupt("break", 34);
|
|
5166
5702
|
|
|
5167
5703
|
case 17:
|
|
5168
|
-
|
|
5704
|
+
_context5.next = 19;
|
|
5169
5705
|
return _this.axiosInstance.post(url, data, requestConfig);
|
|
5170
5706
|
|
|
5171
5707
|
case 19:
|
|
5172
|
-
response =
|
|
5173
|
-
return
|
|
5708
|
+
response = _context5.sent;
|
|
5709
|
+
return _context5.abrupt("break", 34);
|
|
5174
5710
|
|
|
5175
5711
|
case 21:
|
|
5176
|
-
|
|
5712
|
+
_context5.next = 23;
|
|
5177
5713
|
return _this.axiosInstance.put(url, data, requestConfig);
|
|
5178
5714
|
|
|
5179
5715
|
case 23:
|
|
5180
|
-
response =
|
|
5181
|
-
return
|
|
5716
|
+
response = _context5.sent;
|
|
5717
|
+
return _context5.abrupt("break", 34);
|
|
5182
5718
|
|
|
5183
5719
|
case 25:
|
|
5184
|
-
|
|
5720
|
+
_context5.next = 27;
|
|
5185
5721
|
return _this.axiosInstance.patch(url, data, requestConfig);
|
|
5186
5722
|
|
|
5187
5723
|
case 27:
|
|
5188
|
-
response =
|
|
5189
|
-
return
|
|
5724
|
+
response = _context5.sent;
|
|
5725
|
+
return _context5.abrupt("break", 34);
|
|
5190
5726
|
|
|
5191
5727
|
case 29:
|
|
5192
|
-
|
|
5728
|
+
_context5.next = 31;
|
|
5193
5729
|
return _this.axiosInstance.options(url, requestConfig);
|
|
5194
5730
|
|
|
5195
5731
|
case 31:
|
|
5196
|
-
response =
|
|
5197
|
-
return
|
|
5732
|
+
response = _context5.sent;
|
|
5733
|
+
return _context5.abrupt("break", 34);
|
|
5198
5734
|
|
|
5199
5735
|
case 33:
|
|
5200
5736
|
throw new Error('Invalid request type');
|
|
@@ -5203,64 +5739,66 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5203
5739
|
_this._logApiResponse(type, url, response);
|
|
5204
5740
|
|
|
5205
5741
|
_this.consecutiveFailures = 0;
|
|
5206
|
-
return
|
|
5742
|
+
return _context5.abrupt("return", _this.handleResponse(response));
|
|
5207
5743
|
|
|
5208
5744
|
case 39:
|
|
5209
|
-
|
|
5210
|
-
|
|
5745
|
+
_context5.prev = 39;
|
|
5746
|
+
_context5.t1 = _context5["catch"](4);
|
|
5747
|
+
_context5.t1.client_request_id = (_requestConfig$header = requestConfig.headers) === null || _requestConfig$header === void 0 ? void 0 : _requestConfig$header['x-client-request-id'];
|
|
5211
5748
|
|
|
5212
|
-
_this._logApiError(type, url,
|
|
5749
|
+
_this._logApiError(type, url, _context5.t1);
|
|
5213
5750
|
|
|
5214
5751
|
_this.consecutiveFailures += 1;
|
|
5215
5752
|
|
|
5216
|
-
if (!
|
|
5217
|
-
|
|
5753
|
+
if (!_context5.t1.response) {
|
|
5754
|
+
_context5.next = 56;
|
|
5218
5755
|
break;
|
|
5219
5756
|
}
|
|
5220
5757
|
|
|
5221
|
-
if (!(
|
|
5222
|
-
|
|
5758
|
+
if (!(_context5.t1.response.data.code === chatCodes.TOKEN_EXPIRED && !_this.tokenManager.isStatic())) {
|
|
5759
|
+
_context5.next = 53;
|
|
5223
5760
|
break;
|
|
5224
5761
|
}
|
|
5225
5762
|
|
|
5226
5763
|
if (!(_this.consecutiveFailures > 1)) {
|
|
5227
|
-
|
|
5764
|
+
_context5.next = 49;
|
|
5228
5765
|
break;
|
|
5229
5766
|
}
|
|
5230
5767
|
|
|
5231
|
-
|
|
5768
|
+
_context5.next = 49;
|
|
5232
5769
|
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5233
5770
|
|
|
5234
|
-
case
|
|
5771
|
+
case 49:
|
|
5235
5772
|
_this.tokenManager.loadToken();
|
|
5236
5773
|
|
|
5237
|
-
|
|
5774
|
+
_context5.next = 52;
|
|
5238
5775
|
return _this.doAxiosRequest(type, url, data, options);
|
|
5239
5776
|
|
|
5240
|
-
case 51:
|
|
5241
|
-
return _context4.abrupt("return", _context4.sent);
|
|
5242
|
-
|
|
5243
5777
|
case 52:
|
|
5244
|
-
return
|
|
5778
|
+
return _context5.abrupt("return", _context5.sent);
|
|
5245
5779
|
|
|
5246
|
-
case
|
|
5247
|
-
|
|
5780
|
+
case 53:
|
|
5781
|
+
return _context5.abrupt("return", _this.handleResponse(_context5.t1.response));
|
|
5248
5782
|
|
|
5249
5783
|
case 56:
|
|
5784
|
+
throw _context5.t1;
|
|
5785
|
+
|
|
5786
|
+
case 57:
|
|
5250
5787
|
case "end":
|
|
5251
|
-
return
|
|
5788
|
+
return _context5.stop();
|
|
5252
5789
|
}
|
|
5253
5790
|
}
|
|
5254
|
-
},
|
|
5791
|
+
}, _callee5, null, [[4, 39]]);
|
|
5255
5792
|
}));
|
|
5256
5793
|
|
|
5257
|
-
return function (
|
|
5258
|
-
return
|
|
5794
|
+
return function (_x5, _x6, _x7) {
|
|
5795
|
+
return _ref5.apply(this, arguments);
|
|
5259
5796
|
};
|
|
5260
5797
|
}());
|
|
5261
5798
|
|
|
5262
5799
|
_defineProperty__default['default'](this, "dispatchEvent", function (event) {
|
|
5263
|
-
// client event handlers
|
|
5800
|
+
if (!event.received_at) event.received_at = new Date(); // client event handlers
|
|
5801
|
+
|
|
5264
5802
|
var postListenerCallbacks = _this._handleClientEvent(event); // channel event handlers
|
|
5265
5803
|
|
|
5266
5804
|
|
|
@@ -5286,7 +5824,6 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5286
5824
|
// dispatch the event to the channel listeners
|
|
5287
5825
|
var jsonString = messageEvent.data;
|
|
5288
5826
|
var event = JSON.parse(jsonString);
|
|
5289
|
-
event.received_at = new Date();
|
|
5290
5827
|
|
|
5291
5828
|
_this.dispatchEvent(event);
|
|
5292
5829
|
});
|
|
@@ -5407,22 +5944,20 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5407
5944
|
}
|
|
5408
5945
|
});
|
|
5409
5946
|
|
|
5410
|
-
_defineProperty__default['default'](this, "recoverState", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
5411
|
-
var _this$wsConnection3;
|
|
5412
|
-
|
|
5947
|
+
_defineProperty__default['default'](this, "recoverState", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee6() {
|
|
5413
5948
|
var cids;
|
|
5414
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
5949
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee6$(_context6) {
|
|
5415
5950
|
while (1) {
|
|
5416
|
-
switch (
|
|
5951
|
+
switch (_context6.prev = _context6.next) {
|
|
5417
5952
|
case 0:
|
|
5418
|
-
_this.logger('info', "client:recoverState() - Start of recoverState with connectionID ".concat(
|
|
5953
|
+
_this.logger('info', "client:recoverState() - Start of recoverState with connectionID ".concat(_this._getConnectionID()), {
|
|
5419
5954
|
tags: ['connection']
|
|
5420
5955
|
});
|
|
5421
5956
|
|
|
5422
5957
|
cids = Object.keys(_this.activeChannels);
|
|
5423
5958
|
|
|
5424
5959
|
if (!(cids.length && _this.recoverStateOnReconnect)) {
|
|
5425
|
-
|
|
5960
|
+
_context6.next = 10;
|
|
5426
5961
|
break;
|
|
5427
5962
|
}
|
|
5428
5963
|
|
|
@@ -5430,7 +5965,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5430
5965
|
tags: ['connection', 'client']
|
|
5431
5966
|
});
|
|
5432
5967
|
|
|
5433
|
-
|
|
5968
|
+
_context6.next = 6;
|
|
5434
5969
|
return _this.queryChannels({
|
|
5435
5970
|
cid: {
|
|
5436
5971
|
$in: cids
|
|
@@ -5450,7 +5985,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5450
5985
|
type: 'connection.recovered'
|
|
5451
5986
|
});
|
|
5452
5987
|
|
|
5453
|
-
|
|
5988
|
+
_context6.next = 11;
|
|
5454
5989
|
break;
|
|
5455
5990
|
|
|
5456
5991
|
case 10:
|
|
@@ -5464,10 +5999,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5464
5999
|
|
|
5465
6000
|
case 13:
|
|
5466
6001
|
case "end":
|
|
5467
|
-
return
|
|
6002
|
+
return _context6.stop();
|
|
5468
6003
|
}
|
|
5469
6004
|
}
|
|
5470
|
-
},
|
|
6005
|
+
}, _callee6);
|
|
5471
6006
|
})));
|
|
5472
6007
|
|
|
5473
6008
|
_defineProperty__default['default'](this, "getChannelByMembers", function (channelType, custom) {
|
|
@@ -5547,66 +6082,16 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5547
6082
|
return !!_this.secret;
|
|
5548
6083
|
});
|
|
5549
6084
|
|
|
5550
|
-
_defineProperty__default['default'](this, "
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
case 2:
|
|
5561
|
-
if (!(i < maxAttempts)) {
|
|
5562
|
-
_context6.next = 18;
|
|
5563
|
-
break;
|
|
5564
|
-
}
|
|
5565
|
-
|
|
5566
|
-
_context6.prev = 3;
|
|
5567
|
-
_context6.next = 6;
|
|
5568
|
-
return _this.axiosInstance.post("https://chat-insights.getstream.io/insights/".concat(insightType), insights);
|
|
5569
|
-
|
|
5570
|
-
case 6:
|
|
5571
|
-
_context6.next = 14;
|
|
5572
|
-
break;
|
|
5573
|
-
|
|
5574
|
-
case 8:
|
|
5575
|
-
_context6.prev = 8;
|
|
5576
|
-
_context6.t0 = _context6["catch"](3);
|
|
5577
|
-
|
|
5578
|
-
_this.logger('warn', "failed to send insights event ".concat(insightType), {
|
|
5579
|
-
tags: ['insights', 'connection'],
|
|
5580
|
-
error: _context6.t0,
|
|
5581
|
-
insights: insights
|
|
5582
|
-
});
|
|
5583
|
-
|
|
5584
|
-
_context6.next = 13;
|
|
5585
|
-
return sleep((i + 1) * 3000);
|
|
5586
|
-
|
|
5587
|
-
case 13:
|
|
5588
|
-
return _context6.abrupt("continue", 15);
|
|
5589
|
-
|
|
5590
|
-
case 14:
|
|
5591
|
-
return _context6.abrupt("break", 18);
|
|
5592
|
-
|
|
5593
|
-
case 15:
|
|
5594
|
-
i++;
|
|
5595
|
-
_context6.next = 2;
|
|
5596
|
-
break;
|
|
5597
|
-
|
|
5598
|
-
case 18:
|
|
5599
|
-
case "end":
|
|
5600
|
-
return _context6.stop();
|
|
5601
|
-
}
|
|
5602
|
-
}
|
|
5603
|
-
}, _callee6, null, [[3, 8]]);
|
|
5604
|
-
}));
|
|
5605
|
-
|
|
5606
|
-
return function (_x7, _x8) {
|
|
5607
|
-
return _ref6.apply(this, arguments);
|
|
5608
|
-
};
|
|
5609
|
-
}());
|
|
6085
|
+
_defineProperty__default['default'](this, "_buildWSPayload", function (client_request_id) {
|
|
6086
|
+
return JSON.stringify({
|
|
6087
|
+
user_id: _this.userID,
|
|
6088
|
+
user_details: _this._user,
|
|
6089
|
+
user_token: _this.tokenManager.getToken(),
|
|
6090
|
+
server_determines_connection_id: true,
|
|
6091
|
+
device: _this.options.device,
|
|
6092
|
+
client_request_id: client_request_id
|
|
6093
|
+
});
|
|
6094
|
+
});
|
|
5610
6095
|
|
|
5611
6096
|
// set the key
|
|
5612
6097
|
this.key = _key;
|
|
@@ -5640,7 +6125,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5640
6125
|
}
|
|
5641
6126
|
|
|
5642
6127
|
this.axiosInstance = axios__default['default'].create(this.options);
|
|
5643
|
-
this.setBaseURL(this.options.baseURL || 'https://chat
|
|
6128
|
+
this.setBaseURL(this.options.baseURL || 'https://chat.stream-io-api.com');
|
|
5644
6129
|
|
|
5645
6130
|
if (typeof process !== 'undefined' && process.env.STREAM_LOCAL_TEST_RUN) {
|
|
5646
6131
|
this.setBaseURL('http://localhost:3030');
|
|
@@ -5664,6 +6149,8 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5664
6149
|
this.tokenManager = new TokenManager(this.secret);
|
|
5665
6150
|
this.consecutiveFailures = 0;
|
|
5666
6151
|
this.insightMetrics = new InsightMetrics();
|
|
6152
|
+
this.defaultWSTimeoutWithFallback = 6000;
|
|
6153
|
+
this.defaultWSTimeout = 15000;
|
|
5667
6154
|
/**
|
|
5668
6155
|
* logger function should accept 3 parameters:
|
|
5669
6156
|
* @param logLevel string
|
|
@@ -5837,7 +6324,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5837
6324
|
}, _callee7, this);
|
|
5838
6325
|
}));
|
|
5839
6326
|
|
|
5840
|
-
function updateAppSettings(
|
|
6327
|
+
function updateAppSettings(_x8) {
|
|
5841
6328
|
return _updateAppSettings.apply(this, arguments);
|
|
5842
6329
|
}
|
|
5843
6330
|
|
|
@@ -5871,7 +6358,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5871
6358
|
}, _callee8, this);
|
|
5872
6359
|
}));
|
|
5873
6360
|
|
|
5874
|
-
function revokeTokens(
|
|
6361
|
+
function revokeTokens(_x9) {
|
|
5875
6362
|
return _revokeTokens.apply(this, arguments);
|
|
5876
6363
|
}
|
|
5877
6364
|
|
|
@@ -5903,7 +6390,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5903
6390
|
}, _callee9, this);
|
|
5904
6391
|
}));
|
|
5905
6392
|
|
|
5906
|
-
function revokeUserToken(
|
|
6393
|
+
function revokeUserToken(_x10, _x11) {
|
|
5907
6394
|
return _revokeUserToken.apply(this, arguments);
|
|
5908
6395
|
}
|
|
5909
6396
|
|
|
@@ -5962,7 +6449,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5962
6449
|
}, _callee10, this);
|
|
5963
6450
|
}));
|
|
5964
6451
|
|
|
5965
|
-
function revokeUsersToken(
|
|
6452
|
+
function revokeUsersToken(_x12, _x13) {
|
|
5966
6453
|
return _revokeUsersToken.apply(this, arguments);
|
|
5967
6454
|
}
|
|
5968
6455
|
|
|
@@ -6054,7 +6541,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6054
6541
|
}, _callee12, this);
|
|
6055
6542
|
}));
|
|
6056
6543
|
|
|
6057
|
-
function testPushSettings(
|
|
6544
|
+
function testPushSettings(_x14) {
|
|
6058
6545
|
return _testPushSettings.apply(this, arguments);
|
|
6059
6546
|
}
|
|
6060
6547
|
|
|
@@ -6163,7 +6650,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6163
6650
|
}, _callee14, this, [[1, 7]]);
|
|
6164
6651
|
}));
|
|
6165
6652
|
|
|
6166
|
-
function setGuestUser(
|
|
6653
|
+
function setGuestUser(_x15) {
|
|
6167
6654
|
return _setGuestUser.apply(this, arguments);
|
|
6168
6655
|
}
|
|
6169
6656
|
|
|
@@ -6474,90 +6961,84 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6474
6961
|
*/
|
|
6475
6962
|
function () {
|
|
6476
6963
|
var _connect = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee15() {
|
|
6477
|
-
var client, warmUpPromise, handshake;
|
|
6478
6964
|
return _regeneratorRuntime__default['default'].wrap(function _callee15$(_context15) {
|
|
6479
6965
|
while (1) {
|
|
6480
6966
|
switch (_context15.prev = _context15.next) {
|
|
6481
6967
|
case 0:
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
if (!(client.userID == null || this._user == null)) {
|
|
6486
|
-
_context15.next = 4;
|
|
6968
|
+
if (!(!this.userID || !this._user)) {
|
|
6969
|
+
_context15.next = 2;
|
|
6487
6970
|
break;
|
|
6488
6971
|
}
|
|
6489
6972
|
|
|
6490
6973
|
throw Error('Call connectUser or connectAnonymousUser before starting the connection');
|
|
6491
6974
|
|
|
6492
|
-
case
|
|
6493
|
-
if (
|
|
6494
|
-
_context15.next =
|
|
6975
|
+
case 2:
|
|
6976
|
+
if (this.wsBaseURL) {
|
|
6977
|
+
_context15.next = 4;
|
|
6495
6978
|
break;
|
|
6496
6979
|
}
|
|
6497
6980
|
|
|
6498
6981
|
throw Error('Websocket base url not set');
|
|
6499
6982
|
|
|
6500
|
-
case
|
|
6501
|
-
if (
|
|
6502
|
-
_context15.next =
|
|
6983
|
+
case 4:
|
|
6984
|
+
if (this.clientID) {
|
|
6985
|
+
_context15.next = 6;
|
|
6503
6986
|
break;
|
|
6504
6987
|
}
|
|
6505
6988
|
|
|
6506
6989
|
throw Error('clientID is not set');
|
|
6507
6990
|
|
|
6508
|
-
case
|
|
6509
|
-
|
|
6991
|
+
case 6:
|
|
6992
|
+
if (!this.wsConnection && (this.options.warmUp || this.options.enableInsights)) {
|
|
6993
|
+
this._sayHi();
|
|
6994
|
+
} // The StableWSConnection handles all the reconnection logic.
|
|
6995
|
+
|
|
6996
|
+
|
|
6510
6997
|
this.wsConnection = new StableWSConnection({
|
|
6511
|
-
|
|
6512
|
-
clientID: client.clientID,
|
|
6513
|
-
userID: client.userID,
|
|
6514
|
-
tokenManager: client.tokenManager,
|
|
6515
|
-
user: this._user,
|
|
6516
|
-
authType: this.getAuthType(),
|
|
6517
|
-
userAgent: this.getUserAgent(),
|
|
6518
|
-
apiKey: this.key,
|
|
6519
|
-
recoverCallback: this.recoverState,
|
|
6520
|
-
messageCallback: this.handleEvent,
|
|
6521
|
-
eventCallback: this.dispatchEvent,
|
|
6522
|
-
logger: this.logger,
|
|
6523
|
-
device: this.options.device,
|
|
6524
|
-
postInsights: this.options.enableInsights ? this.postInsights : undefined,
|
|
6525
|
-
insightMetrics: this.insightMetrics
|
|
6998
|
+
client: this
|
|
6526
6999
|
});
|
|
7000
|
+
_context15.prev = 8;
|
|
7001
|
+
_context15.next = 11;
|
|
7002
|
+
return this.wsConnection.connect(this.options.enableWSFallback ? this.defaultWSTimeoutWithFallback : this.defaultWSTimeout);
|
|
6527
7003
|
|
|
6528
|
-
|
|
6529
|
-
|
|
7004
|
+
case 11:
|
|
7005
|
+
return _context15.abrupt("return", _context15.sent);
|
|
7006
|
+
|
|
7007
|
+
case 14:
|
|
7008
|
+
_context15.prev = 14;
|
|
7009
|
+
_context15.t0 = _context15["catch"](8);
|
|
7010
|
+
|
|
7011
|
+
if (!(this.options.enableWSFallback && isWSFailure(_context15.t0) && isOnline())) {
|
|
7012
|
+
_context15.next = 24;
|
|
7013
|
+
break;
|
|
6530
7014
|
}
|
|
6531
7015
|
|
|
6532
|
-
|
|
6533
|
-
|
|
7016
|
+
this.logger('info', 'client:connect() - WS failed, fallback to longpoll', {
|
|
7017
|
+
tags: ['connection', 'client']
|
|
7018
|
+
});
|
|
6534
7019
|
|
|
6535
|
-
|
|
6536
|
-
handshake = _context15.sent;
|
|
6537
|
-
_context15.prev = 13;
|
|
6538
|
-
_context15.next = 16;
|
|
6539
|
-
return warmUpPromise;
|
|
7020
|
+
this.wsConnection._destroyCurrentWSConnection();
|
|
6540
7021
|
|
|
6541
|
-
|
|
6542
|
-
_context15.next = 21;
|
|
6543
|
-
break;
|
|
7022
|
+
this.wsConnection.disconnect().then(); // close WS so no retry
|
|
6544
7023
|
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
_context15.t0 = _context15["catch"](13);
|
|
6548
|
-
this.logger('error', 'Warmup request failed', {
|
|
6549
|
-
error: _context15.t0
|
|
7024
|
+
this.wsFallback = new WSConnectionFallback({
|
|
7025
|
+
client: this
|
|
6550
7026
|
});
|
|
7027
|
+
_context15.next = 23;
|
|
7028
|
+
return this.wsFallback.connect();
|
|
6551
7029
|
|
|
6552
|
-
case
|
|
6553
|
-
return _context15.abrupt("return",
|
|
7030
|
+
case 23:
|
|
7031
|
+
return _context15.abrupt("return", _context15.sent);
|
|
6554
7032
|
|
|
6555
|
-
case
|
|
7033
|
+
case 24:
|
|
7034
|
+
throw _context15.t0;
|
|
7035
|
+
|
|
7036
|
+
case 25:
|
|
6556
7037
|
case "end":
|
|
6557
7038
|
return _context15.stop();
|
|
6558
7039
|
}
|
|
6559
7040
|
}
|
|
6560
|
-
}, _callee15, this, [[
|
|
7041
|
+
}, _callee15, this, [[8, 14]]);
|
|
6561
7042
|
}));
|
|
6562
7043
|
|
|
6563
7044
|
function connect() {
|
|
@@ -6566,6 +7047,33 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6566
7047
|
|
|
6567
7048
|
return connect;
|
|
6568
7049
|
}()
|
|
7050
|
+
/**
|
|
7051
|
+
* Check the connectivity with server for warmup purpose.
|
|
7052
|
+
*
|
|
7053
|
+
* @private
|
|
7054
|
+
*/
|
|
7055
|
+
|
|
7056
|
+
}, {
|
|
7057
|
+
key: "_sayHi",
|
|
7058
|
+
value: function _sayHi() {
|
|
7059
|
+
var _this4 = this;
|
|
7060
|
+
|
|
7061
|
+
var client_request_id = randomId();
|
|
7062
|
+
var opts = {
|
|
7063
|
+
headers: {
|
|
7064
|
+
'x-client-request-id': client_request_id
|
|
7065
|
+
}
|
|
7066
|
+
};
|
|
7067
|
+
this.doAxiosRequest('get', this.baseURL + '/hi', null, opts).catch(function (e) {
|
|
7068
|
+
if (_this4.options.enableInsights) {
|
|
7069
|
+
postInsights('http_hi_failed', {
|
|
7070
|
+
api_key: _this4.key,
|
|
7071
|
+
err: e,
|
|
7072
|
+
client_request_id: client_request_id
|
|
7073
|
+
});
|
|
7074
|
+
}
|
|
7075
|
+
});
|
|
7076
|
+
}
|
|
6569
7077
|
/**
|
|
6570
7078
|
* queryUsers - Query users and watch user presence
|
|
6571
7079
|
*
|
|
@@ -6626,7 +7134,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6626
7134
|
}, _callee16, this);
|
|
6627
7135
|
}));
|
|
6628
7136
|
|
|
6629
|
-
function queryUsers(
|
|
7137
|
+
function queryUsers(_x16) {
|
|
6630
7138
|
return _queryUsers.apply(this, arguments);
|
|
6631
7139
|
}
|
|
6632
7140
|
|
|
@@ -6845,7 +7353,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6845
7353
|
}, _callee19, this);
|
|
6846
7354
|
}));
|
|
6847
7355
|
|
|
6848
|
-
function queryChannels(
|
|
7356
|
+
function queryChannels(_x17) {
|
|
6849
7357
|
return _queryChannels.apply(this, arguments);
|
|
6850
7358
|
}
|
|
6851
7359
|
|
|
@@ -6931,7 +7439,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6931
7439
|
}, _callee20, this);
|
|
6932
7440
|
}));
|
|
6933
7441
|
|
|
6934
|
-
function search(
|
|
7442
|
+
function search(_x18, _x19) {
|
|
6935
7443
|
return _search.apply(this, arguments);
|
|
6936
7444
|
}
|
|
6937
7445
|
|
|
@@ -6949,7 +7457,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6949
7457
|
}, {
|
|
6950
7458
|
key: "setLocalDevice",
|
|
6951
7459
|
value: function setLocalDevice(device) {
|
|
6952
|
-
if (this.wsConnection) {
|
|
7460
|
+
if (this.wsConnection || this.wsFallback) {
|
|
6953
7461
|
throw new Error('you can only set device before opening a websocket connection');
|
|
6954
7462
|
}
|
|
6955
7463
|
|
|
@@ -6991,7 +7499,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6991
7499
|
}, _callee21, this);
|
|
6992
7500
|
}));
|
|
6993
7501
|
|
|
6994
|
-
function addDevice(_x21, _x22
|
|
7502
|
+
function addDevice(_x20, _x21, _x22) {
|
|
6995
7503
|
return _addDevice.apply(this, arguments);
|
|
6996
7504
|
}
|
|
6997
7505
|
|
|
@@ -7029,7 +7537,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7029
7537
|
}, _callee22, this);
|
|
7030
7538
|
}));
|
|
7031
7539
|
|
|
7032
|
-
function getDevices(
|
|
7540
|
+
function getDevices(_x23) {
|
|
7033
7541
|
return _getDevices.apply(this, arguments);
|
|
7034
7542
|
}
|
|
7035
7543
|
|
|
@@ -7069,7 +7577,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7069
7577
|
}, _callee23, this);
|
|
7070
7578
|
}));
|
|
7071
7579
|
|
|
7072
|
-
function removeDevice(
|
|
7580
|
+
function removeDevice(_x24, _x25) {
|
|
7073
7581
|
return _removeDevice.apply(this, arguments);
|
|
7074
7582
|
}
|
|
7075
7583
|
|
|
@@ -7110,7 +7618,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7110
7618
|
}, _callee24, this);
|
|
7111
7619
|
}));
|
|
7112
7620
|
|
|
7113
|
-
function getRateLimits(
|
|
7621
|
+
function getRateLimits(_x26) {
|
|
7114
7622
|
return _getRateLimits.apply(this, arguments);
|
|
7115
7623
|
}
|
|
7116
7624
|
|
|
@@ -7211,7 +7719,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7211
7719
|
}, _callee25, this);
|
|
7212
7720
|
}));
|
|
7213
7721
|
|
|
7214
|
-
function partialUpdateUser(
|
|
7722
|
+
function partialUpdateUser(_x27) {
|
|
7215
7723
|
return _partialUpdateUser.apply(this, arguments);
|
|
7216
7724
|
}
|
|
7217
7725
|
|
|
@@ -7297,7 +7805,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7297
7805
|
}, _callee26, this, [[2, 13, 16, 19]]);
|
|
7298
7806
|
}));
|
|
7299
7807
|
|
|
7300
|
-
function upsertUsers(
|
|
7808
|
+
function upsertUsers(_x28) {
|
|
7301
7809
|
return _upsertUsers.apply(this, arguments);
|
|
7302
7810
|
}
|
|
7303
7811
|
|
|
@@ -7410,7 +7918,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7410
7918
|
}, _callee27, this, [[1, 11, 14, 17]]);
|
|
7411
7919
|
}));
|
|
7412
7920
|
|
|
7413
|
-
function partialUpdateUsers(
|
|
7921
|
+
function partialUpdateUsers(_x29) {
|
|
7414
7922
|
return _partialUpdateUsers.apply(this, arguments);
|
|
7415
7923
|
}
|
|
7416
7924
|
|
|
@@ -7438,7 +7946,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7438
7946
|
}, _callee28, this);
|
|
7439
7947
|
}));
|
|
7440
7948
|
|
|
7441
|
-
function deleteUser(
|
|
7949
|
+
function deleteUser(_x30, _x31) {
|
|
7442
7950
|
return _deleteUser.apply(this, arguments);
|
|
7443
7951
|
}
|
|
7444
7952
|
|
|
@@ -7466,7 +7974,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7466
7974
|
}, _callee29, this);
|
|
7467
7975
|
}));
|
|
7468
7976
|
|
|
7469
|
-
function reactivateUser(
|
|
7977
|
+
function reactivateUser(_x32, _x33) {
|
|
7470
7978
|
return _reactivateUser.apply(this, arguments);
|
|
7471
7979
|
}
|
|
7472
7980
|
|
|
@@ -7494,7 +8002,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7494
8002
|
}, _callee30, this);
|
|
7495
8003
|
}));
|
|
7496
8004
|
|
|
7497
|
-
function deactivateUser(
|
|
8005
|
+
function deactivateUser(_x34, _x35) {
|
|
7498
8006
|
return _deactivateUser.apply(this, arguments);
|
|
7499
8007
|
}
|
|
7500
8008
|
|
|
@@ -7522,7 +8030,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7522
8030
|
}, _callee31, this);
|
|
7523
8031
|
}));
|
|
7524
8032
|
|
|
7525
|
-
function exportUser(
|
|
8033
|
+
function exportUser(_x36, _x37) {
|
|
7526
8034
|
return _exportUser.apply(this, arguments);
|
|
7527
8035
|
}
|
|
7528
8036
|
|
|
@@ -7571,7 +8079,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7571
8079
|
}, _callee32, this);
|
|
7572
8080
|
}));
|
|
7573
8081
|
|
|
7574
|
-
function banUser(
|
|
8082
|
+
function banUser(_x38, _x39) {
|
|
7575
8083
|
return _banUser.apply(this, arguments);
|
|
7576
8084
|
}
|
|
7577
8085
|
|
|
@@ -7608,7 +8116,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7608
8116
|
}, _callee33, this);
|
|
7609
8117
|
}));
|
|
7610
8118
|
|
|
7611
|
-
function unbanUser(
|
|
8119
|
+
function unbanUser(_x40, _x41) {
|
|
7612
8120
|
return _unbanUser.apply(this, arguments);
|
|
7613
8121
|
}
|
|
7614
8122
|
|
|
@@ -7645,7 +8153,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7645
8153
|
}, _callee34, this);
|
|
7646
8154
|
}));
|
|
7647
8155
|
|
|
7648
|
-
function shadowBan(
|
|
8156
|
+
function shadowBan(_x42, _x43) {
|
|
7649
8157
|
return _shadowBan.apply(this, arguments);
|
|
7650
8158
|
}
|
|
7651
8159
|
|
|
@@ -7682,7 +8190,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7682
8190
|
}, _callee35, this);
|
|
7683
8191
|
}));
|
|
7684
8192
|
|
|
7685
|
-
function removeShadowBan(
|
|
8193
|
+
function removeShadowBan(_x44, _x45) {
|
|
7686
8194
|
return _removeShadowBan.apply(this, arguments);
|
|
7687
8195
|
}
|
|
7688
8196
|
|
|
@@ -7725,7 +8233,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7725
8233
|
}, _callee36, this);
|
|
7726
8234
|
}));
|
|
7727
8235
|
|
|
7728
|
-
function muteUser(
|
|
8236
|
+
function muteUser(_x46, _x47) {
|
|
7729
8237
|
return _muteUser.apply(this, arguments);
|
|
7730
8238
|
}
|
|
7731
8239
|
|
|
@@ -7764,7 +8272,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7764
8272
|
}, _callee37, this);
|
|
7765
8273
|
}));
|
|
7766
8274
|
|
|
7767
|
-
function unmuteUser(
|
|
8275
|
+
function unmuteUser(_x48, _x49) {
|
|
7768
8276
|
return _unmuteUser.apply(this, arguments);
|
|
7769
8277
|
}
|
|
7770
8278
|
|
|
@@ -7823,7 +8331,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7823
8331
|
}, _callee38, this);
|
|
7824
8332
|
}));
|
|
7825
8333
|
|
|
7826
|
-
function flagMessage(
|
|
8334
|
+
function flagMessage(_x50) {
|
|
7827
8335
|
return _flagMessage.apply(this, arguments);
|
|
7828
8336
|
}
|
|
7829
8337
|
|
|
@@ -7863,7 +8371,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7863
8371
|
}, _callee39, this);
|
|
7864
8372
|
}));
|
|
7865
8373
|
|
|
7866
|
-
function flagUser(
|
|
8374
|
+
function flagUser(_x51) {
|
|
7867
8375
|
return _flagUser.apply(this, arguments);
|
|
7868
8376
|
}
|
|
7869
8377
|
|
|
@@ -7903,7 +8411,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7903
8411
|
}, _callee40, this);
|
|
7904
8412
|
}));
|
|
7905
8413
|
|
|
7906
|
-
function unflagMessage(
|
|
8414
|
+
function unflagMessage(_x52) {
|
|
7907
8415
|
return _unflagMessage.apply(this, arguments);
|
|
7908
8416
|
}
|
|
7909
8417
|
|
|
@@ -7943,7 +8451,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7943
8451
|
}, _callee41, this);
|
|
7944
8452
|
}));
|
|
7945
8453
|
|
|
7946
|
-
function unflagUser(
|
|
8454
|
+
function unflagUser(_x53) {
|
|
7947
8455
|
return _unflagUser.apply(this, arguments);
|
|
7948
8456
|
}
|
|
7949
8457
|
|
|
@@ -8082,7 +8590,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8082
8590
|
}, _callee43, this);
|
|
8083
8591
|
}));
|
|
8084
8592
|
|
|
8085
|
-
function translateMessage(
|
|
8593
|
+
function translateMessage(_x54, _x55) {
|
|
8086
8594
|
return _translateMessage.apply(this, arguments);
|
|
8087
8595
|
}
|
|
8088
8596
|
|
|
@@ -8198,7 +8706,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8198
8706
|
case 2:
|
|
8199
8707
|
clonedMessage = _extends__default['default']({}, message);
|
|
8200
8708
|
delete clonedMessage.id;
|
|
8201
|
-
reservedMessageFields = ['command', 'created_at', 'html', 'latest_reactions', 'own_reactions', 'reaction_counts', 'reply_count', 'type', 'updated_at', 'user', '__html'];
|
|
8709
|
+
reservedMessageFields = ['command', 'created_at', 'html', 'latest_reactions', 'own_reactions', 'quoted_message', 'reaction_counts', 'reply_count', 'type', 'updated_at', 'user', '__html'];
|
|
8202
8710
|
reservedMessageFields.forEach(function (item) {
|
|
8203
8711
|
if (clonedMessage[item] != null) {
|
|
8204
8712
|
delete clonedMessage[item];
|
|
@@ -8242,7 +8750,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8242
8750
|
}, _callee44, this);
|
|
8243
8751
|
}));
|
|
8244
8752
|
|
|
8245
|
-
function updateMessage(_x57, _x58
|
|
8753
|
+
function updateMessage(_x56, _x57, _x58) {
|
|
8246
8754
|
return _updateMessage.apply(this, arguments);
|
|
8247
8755
|
}
|
|
8248
8756
|
|
|
@@ -8303,7 +8811,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8303
8811
|
}, _callee45, this);
|
|
8304
8812
|
}));
|
|
8305
8813
|
|
|
8306
|
-
function partialUpdateMessage(_x60, _x61, _x62
|
|
8814
|
+
function partialUpdateMessage(_x59, _x60, _x61, _x62) {
|
|
8307
8815
|
return _partialUpdateMessage.apply(this, arguments);
|
|
8308
8816
|
}
|
|
8309
8817
|
|
|
@@ -8340,7 +8848,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8340
8848
|
}, _callee46, this);
|
|
8341
8849
|
}));
|
|
8342
8850
|
|
|
8343
|
-
function deleteMessage(
|
|
8851
|
+
function deleteMessage(_x63, _x64) {
|
|
8344
8852
|
return _deleteMessage.apply(this, arguments);
|
|
8345
8853
|
}
|
|
8346
8854
|
|
|
@@ -8368,7 +8876,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8368
8876
|
}, _callee47, this);
|
|
8369
8877
|
}));
|
|
8370
8878
|
|
|
8371
|
-
function getMessage(
|
|
8879
|
+
function getMessage(_x65) {
|
|
8372
8880
|
return _getMessage.apply(this, arguments);
|
|
8373
8881
|
}
|
|
8374
8882
|
|
|
@@ -8377,7 +8885,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8377
8885
|
}, {
|
|
8378
8886
|
key: "getUserAgent",
|
|
8379
8887
|
value: function getUserAgent() {
|
|
8380
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "4.
|
|
8888
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "4.5.0-beta.0");
|
|
8381
8889
|
}
|
|
8382
8890
|
}, {
|
|
8383
8891
|
key: "setUserAgent",
|
|
@@ -8391,7 +8899,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8391
8899
|
}, {
|
|
8392
8900
|
key: "_enrichAxiosOptions",
|
|
8393
8901
|
value: function _enrichAxiosOptions() {
|
|
8394
|
-
var
|
|
8902
|
+
var _options$headers;
|
|
8395
8903
|
|
|
8396
8904
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
8397
8905
|
params: {},
|
|
@@ -8401,15 +8909,24 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8401
8909
|
|
|
8402
8910
|
var token = this._getToken();
|
|
8403
8911
|
|
|
8912
|
+
var authorization = token ? {
|
|
8913
|
+
Authorization: token
|
|
8914
|
+
} : undefined;
|
|
8915
|
+
|
|
8916
|
+
if (!((_options$headers = options.headers) !== null && _options$headers !== void 0 && _options$headers['x-client-request-id'])) {
|
|
8917
|
+
options.headers = _objectSpread(_objectSpread({}, options.headers), {}, {
|
|
8918
|
+
'x-client-request-id': randomId()
|
|
8919
|
+
});
|
|
8920
|
+
}
|
|
8921
|
+
|
|
8404
8922
|
return _objectSpread({
|
|
8405
8923
|
params: _objectSpread(_objectSpread({
|
|
8406
8924
|
user_id: this.userID
|
|
8407
8925
|
}, options.params), {}, {
|
|
8408
8926
|
api_key: this.key,
|
|
8409
|
-
connection_id:
|
|
8927
|
+
connection_id: this._getConnectionID()
|
|
8410
8928
|
}),
|
|
8411
|
-
headers: _objectSpread({
|
|
8412
|
-
Authorization: token,
|
|
8929
|
+
headers: _objectSpread(_objectSpread({}, authorization), {}, {
|
|
8413
8930
|
'stream-auth-type': this.getAuthType(),
|
|
8414
8931
|
'X-Stream-Client': this.getUserAgent()
|
|
8415
8932
|
}, options.headers)
|
|
@@ -8439,6 +8956,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8439
8956
|
}
|
|
8440
8957
|
}, 500);
|
|
8441
8958
|
}
|
|
8959
|
+
/**
|
|
8960
|
+
* encode ws url payload
|
|
8961
|
+
* @private
|
|
8962
|
+
* @returns json string
|
|
8963
|
+
*/
|
|
8964
|
+
|
|
8442
8965
|
}, {
|
|
8443
8966
|
key: "verifyWebhook",
|
|
8444
8967
|
value: function verifyWebhook(requestBody, xSignature) {
|
|
@@ -8579,7 +9102,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8579
9102
|
}, _callee48, this);
|
|
8580
9103
|
}));
|
|
8581
9104
|
|
|
8582
|
-
function sendUserCustomEvent(
|
|
9105
|
+
function sendUserCustomEvent(_x66, _x67) {
|
|
8583
9106
|
return _sendUserCustomEvent.apply(this, arguments);
|
|
8584
9107
|
}
|
|
8585
9108
|
|
|
@@ -8667,7 +9190,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8667
9190
|
}, _callee49, this);
|
|
8668
9191
|
}));
|
|
8669
9192
|
|
|
8670
|
-
function createSegment(
|
|
9193
|
+
function createSegment(_x68) {
|
|
8671
9194
|
return _createSegment.apply(this, arguments);
|
|
8672
9195
|
}
|
|
8673
9196
|
|
|
@@ -8707,7 +9230,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8707
9230
|
}, _callee50, this);
|
|
8708
9231
|
}));
|
|
8709
9232
|
|
|
8710
|
-
function getSegment(
|
|
9233
|
+
function getSegment(_x69) {
|
|
8711
9234
|
return _getSegment.apply(this, arguments);
|
|
8712
9235
|
}
|
|
8713
9236
|
|
|
@@ -8746,7 +9269,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8746
9269
|
}, _callee51, this);
|
|
8747
9270
|
}));
|
|
8748
9271
|
|
|
8749
|
-
function listSegments(
|
|
9272
|
+
function listSegments(_x70) {
|
|
8750
9273
|
return _listSegments.apply(this, arguments);
|
|
8751
9274
|
}
|
|
8752
9275
|
|
|
@@ -8789,7 +9312,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8789
9312
|
}, _callee52, this);
|
|
8790
9313
|
}));
|
|
8791
9314
|
|
|
8792
|
-
function updateSegment(
|
|
9315
|
+
function updateSegment(_x71, _x72) {
|
|
8793
9316
|
return _updateSegment.apply(this, arguments);
|
|
8794
9317
|
}
|
|
8795
9318
|
|
|
@@ -8821,7 +9344,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8821
9344
|
}, _callee53, this);
|
|
8822
9345
|
}));
|
|
8823
9346
|
|
|
8824
|
-
function deleteSegment(
|
|
9347
|
+
function deleteSegment(_x73) {
|
|
8825
9348
|
return _deleteSegment.apply(this, arguments);
|
|
8826
9349
|
}
|
|
8827
9350
|
|
|
@@ -8863,7 +9386,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8863
9386
|
}, _callee54, this);
|
|
8864
9387
|
}));
|
|
8865
9388
|
|
|
8866
|
-
function createCampaign(
|
|
9389
|
+
function createCampaign(_x74) {
|
|
8867
9390
|
return _createCampaign.apply(this, arguments);
|
|
8868
9391
|
}
|
|
8869
9392
|
|
|
@@ -8903,7 +9426,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8903
9426
|
}, _callee55, this);
|
|
8904
9427
|
}));
|
|
8905
9428
|
|
|
8906
|
-
function getCampaign(
|
|
9429
|
+
function getCampaign(_x75) {
|
|
8907
9430
|
return _getCampaign.apply(this, arguments);
|
|
8908
9431
|
}
|
|
8909
9432
|
|
|
@@ -8942,7 +9465,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8942
9465
|
}, _callee56, this);
|
|
8943
9466
|
}));
|
|
8944
9467
|
|
|
8945
|
-
function listCampaigns(
|
|
9468
|
+
function listCampaigns(_x76) {
|
|
8946
9469
|
return _listCampaigns.apply(this, arguments);
|
|
8947
9470
|
}
|
|
8948
9471
|
|
|
@@ -8985,7 +9508,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8985
9508
|
}, _callee57, this);
|
|
8986
9509
|
}));
|
|
8987
9510
|
|
|
8988
|
-
function updateCampaign(
|
|
9511
|
+
function updateCampaign(_x77, _x78) {
|
|
8989
9512
|
return _updateCampaign.apply(this, arguments);
|
|
8990
9513
|
}
|
|
8991
9514
|
|
|
@@ -9017,7 +9540,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9017
9540
|
}, _callee58, this);
|
|
9018
9541
|
}));
|
|
9019
9542
|
|
|
9020
|
-
function deleteCampaign(
|
|
9543
|
+
function deleteCampaign(_x79) {
|
|
9021
9544
|
return _deleteCampaign.apply(this, arguments);
|
|
9022
9545
|
}
|
|
9023
9546
|
|
|
@@ -9061,7 +9584,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9061
9584
|
}, _callee59, this);
|
|
9062
9585
|
}));
|
|
9063
9586
|
|
|
9064
|
-
function scheduleCampaign(
|
|
9587
|
+
function scheduleCampaign(_x80, _x81) {
|
|
9065
9588
|
return _scheduleCampaign.apply(this, arguments);
|
|
9066
9589
|
}
|
|
9067
9590
|
|
|
@@ -9101,7 +9624,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9101
9624
|
}, _callee60, this);
|
|
9102
9625
|
}));
|
|
9103
9626
|
|
|
9104
|
-
function stopCampaign(
|
|
9627
|
+
function stopCampaign(_x82) {
|
|
9105
9628
|
return _stopCampaign.apply(this, arguments);
|
|
9106
9629
|
}
|
|
9107
9630
|
|
|
@@ -9141,7 +9664,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9141
9664
|
}, _callee61, this);
|
|
9142
9665
|
}));
|
|
9143
9666
|
|
|
9144
|
-
function resumeCampaign(
|
|
9667
|
+
function resumeCampaign(_x83) {
|
|
9145
9668
|
return _resumeCampaign.apply(this, arguments);
|
|
9146
9669
|
}
|
|
9147
9670
|
|
|
@@ -9184,7 +9707,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9184
9707
|
}, _callee62, this);
|
|
9185
9708
|
}));
|
|
9186
9709
|
|
|
9187
|
-
function testCampaign(
|
|
9710
|
+
function testCampaign(_x84, _x85) {
|
|
9188
9711
|
return _testCampaign.apply(this, arguments);
|
|
9189
9712
|
}
|
|
9190
9713
|
|
|
@@ -9217,7 +9740,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9217
9740
|
}, _callee63, this);
|
|
9218
9741
|
}));
|
|
9219
9742
|
|
|
9220
|
-
function enrichURL(
|
|
9743
|
+
function enrichURL(_x86) {
|
|
9221
9744
|
return _enrichURL.apply(this, arguments);
|
|
9222
9745
|
}
|
|
9223
9746
|
|
|
@@ -9249,7 +9772,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9249
9772
|
}, _callee64, this);
|
|
9250
9773
|
}));
|
|
9251
9774
|
|
|
9252
|
-
function getTask(
|
|
9775
|
+
function getTask(_x87) {
|
|
9253
9776
|
return _getTask.apply(this, arguments);
|
|
9254
9777
|
}
|
|
9255
9778
|
|
|
@@ -9291,15 +9814,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9291
9814
|
}, _callee65, this);
|
|
9292
9815
|
}));
|
|
9293
9816
|
|
|
9294
|
-
function deleteChannels(
|
|
9817
|
+
function deleteChannels(_x88) {
|
|
9295
9818
|
return _deleteChannels.apply(this, arguments);
|
|
9296
9819
|
}
|
|
9297
9820
|
|
|
9298
9821
|
return deleteChannels;
|
|
9299
9822
|
}()
|
|
9300
|
-
}, {
|
|
9301
|
-
key: "deleteUsers",
|
|
9302
|
-
value:
|
|
9303
9823
|
/**
|
|
9304
9824
|
* deleteUsers - Batch Delete Users
|
|
9305
9825
|
*
|
|
@@ -9308,7 +9828,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9308
9828
|
*
|
|
9309
9829
|
* @return {APIResponse} A task ID
|
|
9310
9830
|
*/
|
|
9311
|
-
|
|
9831
|
+
|
|
9832
|
+
}, {
|
|
9833
|
+
key: "deleteUsers",
|
|
9834
|
+
value: function () {
|
|
9312
9835
|
var _deleteUsers = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee66(user_ids, options) {
|
|
9313
9836
|
return _regeneratorRuntime__default['default'].wrap(function _callee66$(_context66) {
|
|
9314
9837
|
while (1) {
|
|
@@ -9354,7 +9877,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9354
9877
|
}, _callee66, this);
|
|
9355
9878
|
}));
|
|
9356
9879
|
|
|
9357
|
-
function deleteUsers(
|
|
9880
|
+
function deleteUsers(_x89, _x90) {
|
|
9358
9881
|
return _deleteUsers.apply(this, arguments);
|
|
9359
9882
|
}
|
|
9360
9883
|
|
|
@@ -9486,4 +10009,5 @@ exports.encodeBase64 = encodeBase64;
|
|
|
9486
10009
|
exports.isOwnUser = isOwnUser;
|
|
9487
10010
|
exports.isValidEventType = isValidEventType;
|
|
9488
10011
|
exports.logChatPromiseExecution = logChatPromiseExecution;
|
|
10012
|
+
exports.postInsights = postInsights;
|
|
9489
10013
|
//# sourceMappingURL=browser.js.map
|