stream-chat 4.4.3-dev.3 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -13
- package/dist/browser.es.js +1258 -722
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.full-bundle.min.js +1 -1
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/browser.js +1258 -721
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +1258 -722
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1258 -721
- package/dist/index.js.map +1 -1
- package/dist/types/base64.d.ts.map +1 -1
- package/dist/types/channel.d.ts +19 -15
- package/dist/types/channel.d.ts.map +1 -1
- package/dist/types/channel_state.d.ts +2 -2
- package/dist/types/channel_state.d.ts.map +1 -1
- package/dist/types/client.d.ts +25 -42
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/client_state.d.ts +2 -2
- package/dist/types/client_state.d.ts.map +1 -1
- package/dist/types/connection.d.ts +14 -49
- package/dist/types/connection.d.ts.map +1 -1
- package/dist/types/connection_fallback.d.ts +41 -0
- package/dist/types/connection_fallback.d.ts.map +1 -0
- package/dist/types/errors.d.ts +14 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/insights.d.ts +16 -9
- package/dist/types/insights.d.ts.map +1 -1
- package/dist/types/permissions.d.ts.map +1 -1
- package/dist/types/signing.d.ts +3 -3
- package/dist/types/signing.d.ts.map +1 -1
- package/dist/types/token_manager.d.ts +2 -2
- package/dist/types/token_manager.d.ts.map +1 -1
- package/dist/types/types.d.ts +95 -89
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +13 -3
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/base64.ts +1 -4
- package/src/channel.ts +133 -461
- package/src/channel_state.ts +31 -158
- package/src/client.ts +298 -712
- package/src/client_state.ts +2 -2
- package/src/connection.ts +146 -395
- package/src/connection_fallback.ts +209 -0
- package/src/errors.ts +58 -0
- package/src/insights.ts +37 -31
- package/src/permissions.ts +3 -24
- package/src/signing.ts +6 -17
- package/src/token_manager.ts +6 -18
- package/src/types.ts +269 -512
- package/src/utils.ts +58 -24
- package/CHANGELOG.md +0 -844
package/dist/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,55 @@ 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 for browser env
|
|
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
|
+
|
|
977
|
+
if (!nav) {
|
|
978
|
+
console.warn('isOnline failed to access window.navigator and assume browser is online');
|
|
979
|
+
return true;
|
|
980
|
+
} // RN navigator has undefined for onLine
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
if (typeof nav.onLine !== 'boolean') {
|
|
984
|
+
return true;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
return nav.onLine;
|
|
988
|
+
}
|
|
989
|
+
/**
|
|
990
|
+
* listenForConnectionChanges - Adds an event listener fired on browser going online or offline
|
|
991
|
+
*/
|
|
992
|
+
|
|
993
|
+
function addConnectionEventListeners(cb) {
|
|
994
|
+
if (typeof window !== 'undefined' && window.addEventListener) {
|
|
995
|
+
window.addEventListener('offline', cb);
|
|
996
|
+
window.addEventListener('online', cb);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
function removeConnectionEventListeners(cb) {
|
|
1000
|
+
if (typeof window !== 'undefined' && window.removeEventListener) {
|
|
1001
|
+
window.removeEventListener('offline', cb);
|
|
1002
|
+
window.removeEventListener('online', cb);
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
962
1005
|
|
|
963
1006
|
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
1007
|
|
|
@@ -966,9 +1009,9 @@ function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o
|
|
|
966
1009
|
|
|
967
1010
|
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
1011
|
|
|
969
|
-
function ownKeys$
|
|
1012
|
+
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
1013
|
|
|
971
|
-
function _objectSpread$
|
|
1014
|
+
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
1015
|
|
|
973
1016
|
/**
|
|
974
1017
|
* Channel - The Channel class manages it's own state.
|
|
@@ -1088,7 +1131,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1088
1131
|
|
|
1089
1132
|
this.data = data; // this._data is used for the requests...
|
|
1090
1133
|
|
|
1091
|
-
this._data = _objectSpread$
|
|
1134
|
+
this._data = _objectSpread$5({}, data);
|
|
1092
1135
|
this.cid = "".concat(type, ":").concat(id);
|
|
1093
1136
|
this.listeners = {}; // perhaps the state variable should be private
|
|
1094
1137
|
|
|
@@ -1146,7 +1189,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1146
1189
|
switch (_context2.prev = _context2.next) {
|
|
1147
1190
|
case 0:
|
|
1148
1191
|
_context2.next = 2;
|
|
1149
|
-
return this.getClient().post(this._channelURL() + '/message', _objectSpread$
|
|
1192
|
+
return this.getClient().post(this._channelURL() + '/message', _objectSpread$5({
|
|
1150
1193
|
message: message
|
|
1151
1194
|
}, options));
|
|
1152
1195
|
|
|
@@ -1265,7 +1308,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1265
1308
|
|
|
1266
1309
|
case 3:
|
|
1267
1310
|
// Return a list of channels
|
|
1268
|
-
payload = _objectSpread$
|
|
1311
|
+
payload = _objectSpread$5(_objectSpread$5({
|
|
1269
1312
|
filter_conditions: {
|
|
1270
1313
|
cid: this.cid
|
|
1271
1314
|
}
|
|
@@ -1362,7 +1405,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1362
1405
|
|
|
1363
1406
|
_context5.next = 6;
|
|
1364
1407
|
return this.getClient().get(this.getClient().baseURL + '/members', {
|
|
1365
|
-
payload: _objectSpread$
|
|
1408
|
+
payload: _objectSpread$5({
|
|
1366
1409
|
type: type,
|
|
1367
1410
|
id: id,
|
|
1368
1411
|
members: members,
|
|
@@ -1423,7 +1466,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1423
1466
|
|
|
1424
1467
|
case 4:
|
|
1425
1468
|
_context6.next = 6;
|
|
1426
|
-
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(messageID, "/reaction"), _objectSpread$
|
|
1469
|
+
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(messageID, "/reaction"), _objectSpread$5({
|
|
1427
1470
|
reaction: reaction
|
|
1428
1471
|
}, options));
|
|
1429
1472
|
|
|
@@ -1478,7 +1521,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1478
1521
|
*
|
|
1479
1522
|
* @param {ChannelData<ChannelType>} channelData The object to update the custom properties of this channel with
|
|
1480
1523
|
* @param {Message<AttachmentType, MessageType, UserType>} [updateMessage] Optional message object for channel members notification
|
|
1481
|
-
* @param {
|
|
1524
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1482
1525
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1483
1526
|
*/
|
|
1484
1527
|
|
|
@@ -1504,7 +1547,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1504
1547
|
delete channelData[key];
|
|
1505
1548
|
});
|
|
1506
1549
|
_context7.next = 7;
|
|
1507
|
-
return this._update(_objectSpread$
|
|
1550
|
+
return this._update(_objectSpread$5({
|
|
1508
1551
|
message: updateMessage,
|
|
1509
1552
|
data: channelData
|
|
1510
1553
|
}, options));
|
|
@@ -1677,25 +1720,28 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1677
1720
|
}()
|
|
1678
1721
|
/**
|
|
1679
1722
|
* truncate - Removes all messages from the channel
|
|
1680
|
-
*
|
|
1681
|
-
* @return {Promise<TruncateChannelAPIResponse<ChannelType, CommandType, UserType>>} The server response
|
|
1723
|
+
* @param {TruncateOptions<AttachmentType, MessageType, UserType>} [options] Defines truncation options
|
|
1724
|
+
* @return {Promise<TruncateChannelAPIResponse<ChannelType, CommandType, UserType, MessageType, ReactionType>>} The server response
|
|
1682
1725
|
*/
|
|
1683
1726
|
|
|
1684
1727
|
}, {
|
|
1685
1728
|
key: "truncate",
|
|
1686
1729
|
value: function () {
|
|
1687
1730
|
var _truncate = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee12() {
|
|
1731
|
+
var options,
|
|
1732
|
+
_args12 = arguments;
|
|
1688
1733
|
return _regeneratorRuntime__default['default'].wrap(function _callee12$(_context12) {
|
|
1689
1734
|
while (1) {
|
|
1690
1735
|
switch (_context12.prev = _context12.next) {
|
|
1691
1736
|
case 0:
|
|
1692
|
-
|
|
1693
|
-
|
|
1737
|
+
options = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
|
|
1738
|
+
_context12.next = 3;
|
|
1739
|
+
return this.getClient().post(this._channelURL() + '/truncate', options);
|
|
1694
1740
|
|
|
1695
|
-
case
|
|
1741
|
+
case 3:
|
|
1696
1742
|
return _context12.abrupt("return", _context12.sent);
|
|
1697
1743
|
|
|
1698
|
-
case
|
|
1744
|
+
case 4:
|
|
1699
1745
|
case "end":
|
|
1700
1746
|
return _context12.stop();
|
|
1701
1747
|
}
|
|
@@ -1729,7 +1775,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1729
1775
|
case 0:
|
|
1730
1776
|
options = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
|
|
1731
1777
|
_context13.next = 3;
|
|
1732
|
-
return this._update(_objectSpread$
|
|
1778
|
+
return this._update(_objectSpread$5({
|
|
1733
1779
|
accept_invite: true
|
|
1734
1780
|
}, options));
|
|
1735
1781
|
|
|
@@ -1770,7 +1816,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1770
1816
|
case 0:
|
|
1771
1817
|
options = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
|
|
1772
1818
|
_context14.next = 3;
|
|
1773
|
-
return this._update(_objectSpread$
|
|
1819
|
+
return this._update(_objectSpread$5({
|
|
1774
1820
|
reject_invite: true
|
|
1775
1821
|
}, options));
|
|
1776
1822
|
|
|
@@ -1796,6 +1842,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1796
1842
|
*
|
|
1797
1843
|
* @param {{user_id: string, channel_role?: Role}[]} members An array of members to add to the channel
|
|
1798
1844
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1845
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1799
1846
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1800
1847
|
*/
|
|
1801
1848
|
|
|
@@ -1803,20 +1850,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1803
1850
|
key: "addMembers",
|
|
1804
1851
|
value: function () {
|
|
1805
1852
|
var _addMembers = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee15(members, message) {
|
|
1853
|
+
var options,
|
|
1854
|
+
_args15 = arguments;
|
|
1806
1855
|
return _regeneratorRuntime__default['default'].wrap(function _callee15$(_context15) {
|
|
1807
1856
|
while (1) {
|
|
1808
1857
|
switch (_context15.prev = _context15.next) {
|
|
1809
1858
|
case 0:
|
|
1810
|
-
|
|
1811
|
-
|
|
1859
|
+
options = _args15.length > 2 && _args15[2] !== undefined ? _args15[2] : {};
|
|
1860
|
+
_context15.next = 3;
|
|
1861
|
+
return this._update(_objectSpread$5({
|
|
1812
1862
|
add_members: members,
|
|
1813
1863
|
message: message
|
|
1814
|
-
});
|
|
1864
|
+
}, options));
|
|
1815
1865
|
|
|
1816
|
-
case
|
|
1866
|
+
case 3:
|
|
1817
1867
|
return _context15.abrupt("return", _context15.sent);
|
|
1818
1868
|
|
|
1819
|
-
case
|
|
1869
|
+
case 4:
|
|
1820
1870
|
case "end":
|
|
1821
1871
|
return _context15.stop();
|
|
1822
1872
|
}
|
|
@@ -1835,6 +1885,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1835
1885
|
*
|
|
1836
1886
|
* @param {string[]} members An array of member identifiers
|
|
1837
1887
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1888
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1838
1889
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1839
1890
|
*/
|
|
1840
1891
|
|
|
@@ -1842,20 +1893,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1842
1893
|
key: "addModerators",
|
|
1843
1894
|
value: function () {
|
|
1844
1895
|
var _addModerators = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee16(members, message) {
|
|
1896
|
+
var options,
|
|
1897
|
+
_args16 = arguments;
|
|
1845
1898
|
return _regeneratorRuntime__default['default'].wrap(function _callee16$(_context16) {
|
|
1846
1899
|
while (1) {
|
|
1847
1900
|
switch (_context16.prev = _context16.next) {
|
|
1848
1901
|
case 0:
|
|
1849
|
-
|
|
1850
|
-
|
|
1902
|
+
options = _args16.length > 2 && _args16[2] !== undefined ? _args16[2] : {};
|
|
1903
|
+
_context16.next = 3;
|
|
1904
|
+
return this._update(_objectSpread$5({
|
|
1851
1905
|
add_moderators: members,
|
|
1852
1906
|
message: message
|
|
1853
|
-
});
|
|
1907
|
+
}, options));
|
|
1854
1908
|
|
|
1855
|
-
case
|
|
1909
|
+
case 3:
|
|
1856
1910
|
return _context16.abrupt("return", _context16.sent);
|
|
1857
1911
|
|
|
1858
|
-
case
|
|
1912
|
+
case 4:
|
|
1859
1913
|
case "end":
|
|
1860
1914
|
return _context16.stop();
|
|
1861
1915
|
}
|
|
@@ -1874,6 +1928,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1874
1928
|
*
|
|
1875
1929
|
* @param {{channel_role: Role, user_id: string}[]} roles List of role assignments
|
|
1876
1930
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1931
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1877
1932
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1878
1933
|
*/
|
|
1879
1934
|
|
|
@@ -1881,20 +1936,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1881
1936
|
key: "assignRoles",
|
|
1882
1937
|
value: function () {
|
|
1883
1938
|
var _assignRoles = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee17(roles, message) {
|
|
1939
|
+
var options,
|
|
1940
|
+
_args17 = arguments;
|
|
1884
1941
|
return _regeneratorRuntime__default['default'].wrap(function _callee17$(_context17) {
|
|
1885
1942
|
while (1) {
|
|
1886
1943
|
switch (_context17.prev = _context17.next) {
|
|
1887
1944
|
case 0:
|
|
1888
|
-
|
|
1889
|
-
|
|
1945
|
+
options = _args17.length > 2 && _args17[2] !== undefined ? _args17[2] : {};
|
|
1946
|
+
_context17.next = 3;
|
|
1947
|
+
return this._update(_objectSpread$5({
|
|
1890
1948
|
assign_roles: roles,
|
|
1891
1949
|
message: message
|
|
1892
|
-
});
|
|
1950
|
+
}, options));
|
|
1893
1951
|
|
|
1894
|
-
case
|
|
1952
|
+
case 3:
|
|
1895
1953
|
return _context17.abrupt("return", _context17.sent);
|
|
1896
1954
|
|
|
1897
|
-
case
|
|
1955
|
+
case 4:
|
|
1898
1956
|
case "end":
|
|
1899
1957
|
return _context17.stop();
|
|
1900
1958
|
}
|
|
@@ -1913,6 +1971,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1913
1971
|
*
|
|
1914
1972
|
* @param {{user_id: string, channel_role?: Role}[]} members An array of members to invite to the channel
|
|
1915
1973
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1974
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1916
1975
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1917
1976
|
*/
|
|
1918
1977
|
|
|
@@ -1920,20 +1979,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1920
1979
|
key: "inviteMembers",
|
|
1921
1980
|
value: function () {
|
|
1922
1981
|
var _inviteMembers = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee18(members, message) {
|
|
1982
|
+
var options,
|
|
1983
|
+
_args18 = arguments;
|
|
1923
1984
|
return _regeneratorRuntime__default['default'].wrap(function _callee18$(_context18) {
|
|
1924
1985
|
while (1) {
|
|
1925
1986
|
switch (_context18.prev = _context18.next) {
|
|
1926
1987
|
case 0:
|
|
1927
|
-
|
|
1928
|
-
|
|
1988
|
+
options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
|
|
1989
|
+
_context18.next = 3;
|
|
1990
|
+
return this._update(_objectSpread$5({
|
|
1929
1991
|
invites: members,
|
|
1930
1992
|
message: message
|
|
1931
|
-
});
|
|
1993
|
+
}, options));
|
|
1932
1994
|
|
|
1933
|
-
case
|
|
1995
|
+
case 3:
|
|
1934
1996
|
return _context18.abrupt("return", _context18.sent);
|
|
1935
1997
|
|
|
1936
|
-
case
|
|
1998
|
+
case 4:
|
|
1937
1999
|
case "end":
|
|
1938
2000
|
return _context18.stop();
|
|
1939
2001
|
}
|
|
@@ -1952,6 +2014,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1952
2014
|
*
|
|
1953
2015
|
* @param {string[]} members An array of member identifiers
|
|
1954
2016
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
2017
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1955
2018
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1956
2019
|
*/
|
|
1957
2020
|
|
|
@@ -1959,20 +2022,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1959
2022
|
key: "removeMembers",
|
|
1960
2023
|
value: function () {
|
|
1961
2024
|
var _removeMembers = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee19(members, message) {
|
|
2025
|
+
var options,
|
|
2026
|
+
_args19 = arguments;
|
|
1962
2027
|
return _regeneratorRuntime__default['default'].wrap(function _callee19$(_context19) {
|
|
1963
2028
|
while (1) {
|
|
1964
2029
|
switch (_context19.prev = _context19.next) {
|
|
1965
2030
|
case 0:
|
|
1966
|
-
|
|
1967
|
-
|
|
2031
|
+
options = _args19.length > 2 && _args19[2] !== undefined ? _args19[2] : {};
|
|
2032
|
+
_context19.next = 3;
|
|
2033
|
+
return this._update(_objectSpread$5({
|
|
1968
2034
|
remove_members: members,
|
|
1969
2035
|
message: message
|
|
1970
|
-
});
|
|
2036
|
+
}, options));
|
|
1971
2037
|
|
|
1972
|
-
case
|
|
2038
|
+
case 3:
|
|
1973
2039
|
return _context19.abrupt("return", _context19.sent);
|
|
1974
2040
|
|
|
1975
|
-
case
|
|
2041
|
+
case 4:
|
|
1976
2042
|
case "end":
|
|
1977
2043
|
return _context19.stop();
|
|
1978
2044
|
}
|
|
@@ -1991,6 +2057,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1991
2057
|
*
|
|
1992
2058
|
* @param {string[]} members An array of member identifiers
|
|
1993
2059
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
2060
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1994
2061
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1995
2062
|
*/
|
|
1996
2063
|
|
|
@@ -1998,20 +2065,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1998
2065
|
key: "demoteModerators",
|
|
1999
2066
|
value: function () {
|
|
2000
2067
|
var _demoteModerators = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee20(members, message) {
|
|
2068
|
+
var options,
|
|
2069
|
+
_args20 = arguments;
|
|
2001
2070
|
return _regeneratorRuntime__default['default'].wrap(function _callee20$(_context20) {
|
|
2002
2071
|
while (1) {
|
|
2003
2072
|
switch (_context20.prev = _context20.next) {
|
|
2004
2073
|
case 0:
|
|
2005
|
-
|
|
2006
|
-
|
|
2074
|
+
options = _args20.length > 2 && _args20[2] !== undefined ? _args20[2] : {};
|
|
2075
|
+
_context20.next = 3;
|
|
2076
|
+
return this._update(_objectSpread$5({
|
|
2007
2077
|
demote_moderators: members,
|
|
2008
2078
|
message: message
|
|
2009
|
-
});
|
|
2079
|
+
}, options));
|
|
2010
2080
|
|
|
2011
|
-
case
|
|
2081
|
+
case 3:
|
|
2012
2082
|
return _context20.abrupt("return", _context20.sent);
|
|
2013
2083
|
|
|
2014
|
-
case
|
|
2084
|
+
case 4:
|
|
2015
2085
|
case "end":
|
|
2016
2086
|
return _context20.stop();
|
|
2017
2087
|
}
|
|
@@ -2088,7 +2158,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2088
2158
|
case 0:
|
|
2089
2159
|
opts = _args22.length > 0 && _args22[0] !== undefined ? _args22[0] : {};
|
|
2090
2160
|
_context22.next = 3;
|
|
2091
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$
|
|
2161
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$5({
|
|
2092
2162
|
channel_cid: this.cid
|
|
2093
2163
|
}, opts));
|
|
2094
2164
|
|
|
@@ -2130,7 +2200,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2130
2200
|
case 0:
|
|
2131
2201
|
opts = _args23.length > 0 && _args23[0] !== undefined ? _args23[0] : {};
|
|
2132
2202
|
_context23.next = 3;
|
|
2133
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$
|
|
2203
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$5({
|
|
2134
2204
|
channel_cid: this.cid
|
|
2135
2205
|
}, opts));
|
|
2136
2206
|
|
|
@@ -2339,7 +2409,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2339
2409
|
|
|
2340
2410
|
case 4:
|
|
2341
2411
|
_context26.next = 6;
|
|
2342
|
-
return this.getClient().post(this._channelURL() + '/read', _objectSpread$
|
|
2412
|
+
return this.getClient().post(this._channelURL() + '/read', _objectSpread$5({}, data));
|
|
2343
2413
|
|
|
2344
2414
|
case 6:
|
|
2345
2415
|
return _context26.abrupt("return", _context26.sent);
|
|
@@ -2407,7 +2477,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2407
2477
|
defaultOptions.watch = false;
|
|
2408
2478
|
}
|
|
2409
2479
|
|
|
2410
|
-
combined = _objectSpread$
|
|
2480
|
+
combined = _objectSpread$5(_objectSpread$5({}, defaultOptions), options);
|
|
2411
2481
|
_context27.next = 7;
|
|
2412
2482
|
return this.query(combined);
|
|
2413
2483
|
|
|
@@ -2498,7 +2568,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2498
2568
|
switch (_context29.prev = _context29.next) {
|
|
2499
2569
|
case 0:
|
|
2500
2570
|
_context29.next = 2;
|
|
2501
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(parent_id, "/replies"), _objectSpread$
|
|
2571
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(parent_id, "/replies"), _objectSpread$5({}, options));
|
|
2502
2572
|
|
|
2503
2573
|
case 2:
|
|
2504
2574
|
data = _context29.sent;
|
|
@@ -2536,7 +2606,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2536
2606
|
}, {
|
|
2537
2607
|
key: "getReactions",
|
|
2538
2608
|
value: function getReactions(message_id, options) {
|
|
2539
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(message_id, "/reactions"), _objectSpread$
|
|
2609
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(message_id, "/reactions"), _objectSpread$5({}, options));
|
|
2540
2610
|
}
|
|
2541
2611
|
/**
|
|
2542
2612
|
* getMessagesById - Retrieves a list of messages by ID
|
|
@@ -2668,7 +2738,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2668
2738
|
}
|
|
2669
2739
|
|
|
2670
2740
|
_context30.next = 6;
|
|
2671
|
-
return this.getClient().post(queryURL + '/query', _objectSpread$
|
|
2741
|
+
return this.getClient().post(queryURL + '/query', _objectSpread$5({
|
|
2672
2742
|
data: this._data,
|
|
2673
2743
|
state: true
|
|
2674
2744
|
}, options));
|
|
@@ -2739,7 +2809,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2739
2809
|
this._checkInitialized();
|
|
2740
2810
|
|
|
2741
2811
|
_context31.next = 3;
|
|
2742
|
-
return this.getClient().banUser(targetUserID, _objectSpread$
|
|
2812
|
+
return this.getClient().banUser(targetUserID, _objectSpread$5(_objectSpread$5({}, options), {}, {
|
|
2743
2813
|
type: this.type,
|
|
2744
2814
|
id: this.id
|
|
2745
2815
|
}));
|
|
@@ -2911,7 +2981,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2911
2981
|
this._checkInitialized();
|
|
2912
2982
|
|
|
2913
2983
|
_context35.next = 3;
|
|
2914
|
-
return this.getClient().shadowBan(targetUserID, _objectSpread$
|
|
2984
|
+
return this.getClient().shadowBan(targetUserID, _objectSpread$5(_objectSpread$5({}, options), {}, {
|
|
2915
2985
|
type: this.type,
|
|
2916
2986
|
id: this.id
|
|
2917
2987
|
}));
|
|
@@ -3324,7 +3394,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3324
3394
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
3325
3395
|
var read = _step3.value;
|
|
3326
3396
|
|
|
3327
|
-
var parsedRead = _objectSpread$
|
|
3397
|
+
var parsedRead = _objectSpread$5(_objectSpread$5({}, read), {}, {
|
|
3328
3398
|
last_read: new Date(read.last_read)
|
|
3329
3399
|
});
|
|
3330
3400
|
|
|
@@ -3451,9 +3521,9 @@ var ClientState = /*#__PURE__*/function () {
|
|
|
3451
3521
|
return ClientState;
|
|
3452
3522
|
}();
|
|
3453
3523
|
|
|
3454
|
-
function ownKeys$
|
|
3524
|
+
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
3525
|
|
|
3456
|
-
function _objectSpread$
|
|
3526
|
+
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
3527
|
var InsightMetrics = function InsightMetrics() {
|
|
3458
3528
|
_classCallCheck__default['default'](this, InsightMetrics);
|
|
3459
3529
|
|
|
@@ -3470,32 +3540,94 @@ var InsightMetrics = function InsightMetrics() {
|
|
|
3470
3540
|
this.wsConsecutiveFailures = 0;
|
|
3471
3541
|
this.instanceClientId = randomId();
|
|
3472
3542
|
};
|
|
3543
|
+
/**
|
|
3544
|
+
* postInsights is not supposed to be used by end users directly within chat application, and thus is kept isolated
|
|
3545
|
+
* from all the client/connection code/logic.
|
|
3546
|
+
*
|
|
3547
|
+
* @param insightType
|
|
3548
|
+
* @param insights
|
|
3549
|
+
*/
|
|
3550
|
+
|
|
3551
|
+
var postInsights = /*#__PURE__*/function () {
|
|
3552
|
+
var _ref = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(insightType, insights) {
|
|
3553
|
+
var maxAttempts, i;
|
|
3554
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
3555
|
+
while (1) {
|
|
3556
|
+
switch (_context.prev = _context.next) {
|
|
3557
|
+
case 0:
|
|
3558
|
+
maxAttempts = 3;
|
|
3559
|
+
i = 0;
|
|
3560
|
+
|
|
3561
|
+
case 2:
|
|
3562
|
+
if (!(i < maxAttempts)) {
|
|
3563
|
+
_context.next = 17;
|
|
3564
|
+
break;
|
|
3565
|
+
}
|
|
3566
|
+
|
|
3567
|
+
_context.prev = 3;
|
|
3568
|
+
_context.next = 6;
|
|
3569
|
+
return axios__default['default'].post("https://chat-insights.getstream.io/insights/".concat(insightType), insights);
|
|
3570
|
+
|
|
3571
|
+
case 6:
|
|
3572
|
+
_context.next = 13;
|
|
3573
|
+
break;
|
|
3574
|
+
|
|
3575
|
+
case 8:
|
|
3576
|
+
_context.prev = 8;
|
|
3577
|
+
_context.t0 = _context["catch"](3);
|
|
3578
|
+
_context.next = 12;
|
|
3579
|
+
return sleep((i + 1) * 3000);
|
|
3580
|
+
|
|
3581
|
+
case 12:
|
|
3582
|
+
return _context.abrupt("continue", 14);
|
|
3583
|
+
|
|
3584
|
+
case 13:
|
|
3585
|
+
return _context.abrupt("break", 17);
|
|
3586
|
+
|
|
3587
|
+
case 14:
|
|
3588
|
+
i++;
|
|
3589
|
+
_context.next = 2;
|
|
3590
|
+
break;
|
|
3591
|
+
|
|
3592
|
+
case 17:
|
|
3593
|
+
case "end":
|
|
3594
|
+
return _context.stop();
|
|
3595
|
+
}
|
|
3596
|
+
}
|
|
3597
|
+
}, _callee, null, [[3, 8]]);
|
|
3598
|
+
}));
|
|
3599
|
+
|
|
3600
|
+
return function postInsights(_x, _x2) {
|
|
3601
|
+
return _ref.apply(this, arguments);
|
|
3602
|
+
};
|
|
3603
|
+
}();
|
|
3473
3604
|
function buildWsFatalInsight(connection, event) {
|
|
3474
|
-
return _objectSpread$
|
|
3605
|
+
return _objectSpread$4(_objectSpread$4({}, event), buildWsBaseInsight(connection));
|
|
3475
3606
|
}
|
|
3476
3607
|
|
|
3477
3608
|
function buildWsBaseInsight(connection) {
|
|
3478
3609
|
var _connection$ws, _navigator, _navigator2;
|
|
3479
3610
|
|
|
3611
|
+
var client = connection.client;
|
|
3480
3612
|
return {
|
|
3481
3613
|
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:
|
|
3614
|
+
url: connection._buildUrl(),
|
|
3615
|
+
api_key: client.key,
|
|
3616
|
+
start_ts: client.insightMetrics.connectionStartTimestamp,
|
|
3485
3617
|
end_ts: new Date().getTime(),
|
|
3486
|
-
auth_type:
|
|
3487
|
-
token:
|
|
3488
|
-
user_id:
|
|
3489
|
-
user_details:
|
|
3490
|
-
device:
|
|
3618
|
+
auth_type: client.getAuthType(),
|
|
3619
|
+
token: client.tokenManager.token,
|
|
3620
|
+
user_id: client.userID,
|
|
3621
|
+
user_details: client._user,
|
|
3622
|
+
device: client.options.device,
|
|
3491
3623
|
client_id: connection.connectionID,
|
|
3492
3624
|
ws_details: connection.ws,
|
|
3493
|
-
ws_consecutive_failures:
|
|
3494
|
-
ws_total_failures:
|
|
3625
|
+
ws_consecutive_failures: client.insightMetrics.wsConsecutiveFailures,
|
|
3626
|
+
ws_total_failures: client.insightMetrics.wsTotalFailures,
|
|
3495
3627
|
request_id: connection.requestID,
|
|
3496
3628
|
online: typeof navigator !== 'undefined' ? (_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.onLine : null,
|
|
3497
3629
|
user_agent: typeof navigator !== 'undefined' ? (_navigator2 = navigator) === null || _navigator2 === void 0 ? void 0 : _navigator2.userAgent : null,
|
|
3498
|
-
instance_client_id:
|
|
3630
|
+
instance_client_id: client.insightMetrics.instanceClientId
|
|
3499
3631
|
};
|
|
3500
3632
|
}
|
|
3501
3633
|
|
|
@@ -3503,6 +3635,10 @@ function buildWsSuccessAfterFailureInsight(connection) {
|
|
|
3503
3635
|
return buildWsBaseInsight(connection);
|
|
3504
3636
|
}
|
|
3505
3637
|
|
|
3638
|
+
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; }
|
|
3639
|
+
|
|
3640
|
+
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; }
|
|
3641
|
+
|
|
3506
3642
|
// Type guards to check WebSocket error type
|
|
3507
3643
|
var isCloseEvent = function isCloseEvent(res) {
|
|
3508
3644
|
return res.code !== undefined;
|
|
@@ -3511,7 +3647,6 @@ var isCloseEvent = function isCloseEvent(res) {
|
|
|
3511
3647
|
var isErrorEvent = function isErrorEvent(res) {
|
|
3512
3648
|
return res.error !== undefined;
|
|
3513
3649
|
};
|
|
3514
|
-
|
|
3515
3650
|
/**
|
|
3516
3651
|
* StableWSConnection - A WS connection that reconnects upon failure.
|
|
3517
3652
|
* - the browser will sometimes report that you're online or offline
|
|
@@ -3529,53 +3664,19 @@ var isErrorEvent = function isErrorEvent(res) {
|
|
|
3529
3664
|
* - state can be recovered by querying the channel again
|
|
3530
3665
|
* - if the servers fails to publish a message to the client, the WS connection is destroyed
|
|
3531
3666
|
*/
|
|
3667
|
+
|
|
3668
|
+
|
|
3532
3669
|
var StableWSConnection = /*#__PURE__*/function () {
|
|
3670
|
+
// global from constructor
|
|
3671
|
+
// local vars
|
|
3533
3672
|
function StableWSConnection(_ref) {
|
|
3534
3673
|
var _this = this;
|
|
3535
3674
|
|
|
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;
|
|
3675
|
+
var client = _ref.client;
|
|
3551
3676
|
|
|
3552
3677
|
_classCallCheck__default['default'](this, StableWSConnection);
|
|
3553
3678
|
|
|
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);
|
|
3679
|
+
_defineProperty__default['default'](this, "client", void 0);
|
|
3579
3680
|
|
|
3580
3681
|
_defineProperty__default['default'](this, "connectionID", void 0);
|
|
3581
3682
|
|
|
@@ -3589,6 +3690,8 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3589
3690
|
|
|
3590
3691
|
_defineProperty__default['default'](this, "isConnecting", void 0);
|
|
3591
3692
|
|
|
3693
|
+
_defineProperty__default['default'](this, "isDisconnected", void 0);
|
|
3694
|
+
|
|
3592
3695
|
_defineProperty__default['default'](this, "isHealthy", void 0);
|
|
3593
3696
|
|
|
3594
3697
|
_defineProperty__default['default'](this, "isResolved", void 0);
|
|
@@ -3603,8 +3706,6 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3603
3706
|
|
|
3604
3707
|
_defineProperty__default['default'](this, "requestID", void 0);
|
|
3605
3708
|
|
|
3606
|
-
_defineProperty__default['default'](this, "connectionStartTimestamp", void 0);
|
|
3607
|
-
|
|
3608
3709
|
_defineProperty__default['default'](this, "resolvePromise", void 0);
|
|
3609
3710
|
|
|
3610
3711
|
_defineProperty__default['default'](this, "totalFailures", void 0);
|
|
@@ -3613,32 +3714,18 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3613
3714
|
|
|
3614
3715
|
_defineProperty__default['default'](this, "wsID", void 0);
|
|
3615
3716
|
|
|
3616
|
-
_defineProperty__default['default'](this, "
|
|
3717
|
+
_defineProperty__default['default'](this, "_buildUrl", function () {
|
|
3718
|
+
var qs = encodeURIComponent(_this.client._buildWSPayload(_this.requestID));
|
|
3617
3719
|
|
|
3618
|
-
|
|
3720
|
+
var token = _this.client.tokenManager.getToken();
|
|
3619
3721
|
|
|
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
|
-
client_request_id: reqID
|
|
3628
|
-
};
|
|
3629
|
-
var qs = encodeURIComponent(JSON.stringify(params));
|
|
3630
|
-
|
|
3631
|
-
var token = _this.tokenManager.getToken();
|
|
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);
|
|
3722
|
+
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
3723
|
});
|
|
3635
3724
|
|
|
3636
3725
|
_defineProperty__default['default'](this, "onlineStatusChanged", function (event) {
|
|
3637
3726
|
if (event.type === 'offline') {
|
|
3638
3727
|
// mark the connection as down
|
|
3639
|
-
_this.
|
|
3640
|
-
tags: ['connection']
|
|
3641
|
-
});
|
|
3728
|
+
_this._log('onlineStatusChanged() - Status changing to offline');
|
|
3642
3729
|
|
|
3643
3730
|
_this._setHealth(false);
|
|
3644
3731
|
} else if (event.type === 'online') {
|
|
@@ -3646,9 +3733,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3646
3733
|
// We check this.isHealthy, not sure if it's always
|
|
3647
3734
|
// smart to create a new WS connection if the old one is still up and running.
|
|
3648
3735
|
// it's possible we didn't miss any messages, so this process is just expensive and not needed.
|
|
3649
|
-
_this.
|
|
3650
|
-
tags: ['connection']
|
|
3651
|
-
});
|
|
3736
|
+
_this._log("onlineStatusChanged() - Status changing to online. isHealthy: ".concat(_this.isHealthy));
|
|
3652
3737
|
|
|
3653
3738
|
if (!_this.isHealthy) {
|
|
3654
3739
|
_this._reconnect({
|
|
@@ -3661,8 +3746,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3661
3746
|
_defineProperty__default['default'](this, "onopen", function (wsID) {
|
|
3662
3747
|
if (_this.wsID !== wsID) return;
|
|
3663
3748
|
|
|
3664
|
-
_this.
|
|
3665
|
-
tags: ['connection'],
|
|
3749
|
+
_this._log('onopen() - onopen callback', {
|
|
3666
3750
|
wsID: wsID
|
|
3667
3751
|
});
|
|
3668
3752
|
});
|
|
@@ -3674,27 +3758,26 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3674
3758
|
// after that a ws.onclose..
|
|
3675
3759
|
|
|
3676
3760
|
if (!_this.isResolved && data) {
|
|
3761
|
+
var _this$resolvePromise;
|
|
3762
|
+
|
|
3677
3763
|
_this.isResolved = true;
|
|
3678
3764
|
|
|
3679
|
-
if (data.error
|
|
3765
|
+
if (data.error) {
|
|
3680
3766
|
var _this$rejectPromise;
|
|
3681
3767
|
|
|
3682
3768
|
(_this$rejectPromise = _this.rejectPromise) === null || _this$rejectPromise === void 0 ? void 0 : _this$rejectPromise.call(_this, _this._errorFromWSEvent(data, false));
|
|
3683
3769
|
return;
|
|
3684
|
-
}
|
|
3685
|
-
var _this$resolvePromise;
|
|
3770
|
+
}
|
|
3686
3771
|
|
|
3687
|
-
|
|
3772
|
+
(_this$resolvePromise = _this.resolvePromise) === null || _this$resolvePromise === void 0 ? void 0 : _this$resolvePromise.call(_this, data);
|
|
3688
3773
|
|
|
3689
|
-
|
|
3690
|
-
}
|
|
3774
|
+
_this._setHealth(true);
|
|
3691
3775
|
} // trigger the event..
|
|
3692
3776
|
|
|
3693
3777
|
|
|
3694
3778
|
_this.lastEvent = new Date();
|
|
3695
3779
|
|
|
3696
|
-
_this.
|
|
3697
|
-
tags: ['connection'],
|
|
3780
|
+
_this._log('onmessage() - onmessage callback', {
|
|
3698
3781
|
event: event,
|
|
3699
3782
|
wsID: wsID
|
|
3700
3783
|
});
|
|
@@ -3703,7 +3786,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3703
3786
|
_this.scheduleNextPing();
|
|
3704
3787
|
}
|
|
3705
3788
|
|
|
3706
|
-
_this.
|
|
3789
|
+
_this.client.handleEvent(event);
|
|
3707
3790
|
|
|
3708
3791
|
_this.scheduleConnectionCheck();
|
|
3709
3792
|
});
|
|
@@ -3711,8 +3794,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3711
3794
|
_defineProperty__default['default'](this, "onclose", function (wsID, event) {
|
|
3712
3795
|
if (_this.wsID !== wsID) return;
|
|
3713
3796
|
|
|
3714
|
-
_this.
|
|
3715
|
-
tags: ['connection'],
|
|
3797
|
+
_this._log('onclose() - onclose callback - ' + event.code, {
|
|
3716
3798
|
event: event,
|
|
3717
3799
|
wsID: wsID
|
|
3718
3800
|
});
|
|
@@ -3729,8 +3811,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3729
3811
|
error.target = event.target;
|
|
3730
3812
|
(_this$rejectPromise2 = _this.rejectPromise) === null || _this$rejectPromise2 === void 0 ? void 0 : _this$rejectPromise2.call(_this, error);
|
|
3731
3813
|
|
|
3732
|
-
_this.
|
|
3733
|
-
tags: ['connection'],
|
|
3814
|
+
_this._log("onclose() - WS connection reject with error ".concat(event.reason), {
|
|
3734
3815
|
event: event
|
|
3735
3816
|
});
|
|
3736
3817
|
} else {
|
|
@@ -3744,8 +3825,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3744
3825
|
_this.isConnecting = false;
|
|
3745
3826
|
(_this$rejectPromise3 = _this.rejectPromise) === null || _this$rejectPromise3 === void 0 ? void 0 : _this$rejectPromise3.call(_this, _this._errorFromWSEvent(event));
|
|
3746
3827
|
|
|
3747
|
-
_this.
|
|
3748
|
-
tags: ['connection'],
|
|
3828
|
+
_this._log("onclose() - WS connection closed. Calling reconnect ...", {
|
|
3749
3829
|
event: event
|
|
3750
3830
|
}); // reconnect if its an abnormal failure
|
|
3751
3831
|
|
|
@@ -3766,8 +3846,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3766
3846
|
_this.isConnecting = false;
|
|
3767
3847
|
(_this$rejectPromise4 = _this.rejectPromise) === null || _this$rejectPromise4 === void 0 ? void 0 : _this$rejectPromise4.call(_this, _this._errorFromWSEvent(event));
|
|
3768
3848
|
|
|
3769
|
-
_this.
|
|
3770
|
-
tags: ['connection'],
|
|
3849
|
+
_this._log("onerror() - WS connection resulted into error", {
|
|
3771
3850
|
event: event
|
|
3772
3851
|
});
|
|
3773
3852
|
|
|
@@ -3775,28 +3854,28 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3775
3854
|
});
|
|
3776
3855
|
|
|
3777
3856
|
_defineProperty__default['default'](this, "_setHealth", function (healthy) {
|
|
3778
|
-
if (healthy
|
|
3779
|
-
|
|
3780
|
-
_this.isHealthy = true;
|
|
3857
|
+
if (healthy === _this.isHealthy) return;
|
|
3858
|
+
_this.isHealthy = healthy;
|
|
3781
3859
|
|
|
3782
|
-
|
|
3860
|
+
if (_this.isHealthy) {
|
|
3861
|
+
//@ts-expect-error
|
|
3862
|
+
_this.client.dispatchEvent({
|
|
3783
3863
|
type: 'connection.changed',
|
|
3784
|
-
online:
|
|
3864
|
+
online: _this.isHealthy
|
|
3785
3865
|
});
|
|
3786
|
-
}
|
|
3787
3866
|
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
}
|
|
3799
|
-
}
|
|
3867
|
+
return;
|
|
3868
|
+
} // we're offline, wait few seconds and fire and event if still offline
|
|
3869
|
+
|
|
3870
|
+
|
|
3871
|
+
setTimeout(function () {
|
|
3872
|
+
if (_this.isHealthy) return; //@ts-expect-error
|
|
3873
|
+
|
|
3874
|
+
_this.client.dispatchEvent({
|
|
3875
|
+
type: 'connection.changed',
|
|
3876
|
+
online: _this.isHealthy
|
|
3877
|
+
});
|
|
3878
|
+
}, 5000);
|
|
3800
3879
|
});
|
|
3801
3880
|
|
|
3802
3881
|
_defineProperty__default['default'](this, "_errorFromWSEvent", function (event) {
|
|
@@ -3818,10 +3897,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3818
3897
|
} // Keeping this `warn` level log, to avoid cluttering of error logs from ws failures.
|
|
3819
3898
|
|
|
3820
3899
|
|
|
3821
|
-
_this.
|
|
3822
|
-
tags: ['connection'],
|
|
3900
|
+
_this._log("_errorFromWSEvent() - WS failed with code ".concat(code), {
|
|
3823
3901
|
event: event
|
|
3824
|
-
});
|
|
3902
|
+
}, 'warn');
|
|
3825
3903
|
|
|
3826
3904
|
var error = new Error("WS failed with code ".concat(code, " and reason - ").concat(message));
|
|
3827
3905
|
error.code = code;
|
|
@@ -3835,50 +3913,13 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3835
3913
|
return error;
|
|
3836
3914
|
});
|
|
3837
3915
|
|
|
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
3916
|
_defineProperty__default['default'](this, "_setupConnectionPromise", function () {
|
|
3861
|
-
var that = _this;
|
|
3862
3917
|
_this.isResolved = false;
|
|
3863
3918
|
/** a promise that is resolved once ws.open is called */
|
|
3864
3919
|
|
|
3865
3920
|
_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;
|
|
3921
|
+
_this.resolvePromise = resolve;
|
|
3922
|
+
_this.rejectPromise = reject;
|
|
3882
3923
|
});
|
|
3883
3924
|
});
|
|
3884
3925
|
|
|
@@ -3892,7 +3933,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3892
3933
|
// send the healthcheck.., server replies with a health check event
|
|
3893
3934
|
var data = [{
|
|
3894
3935
|
type: 'health.check',
|
|
3895
|
-
client_id: _this.clientID
|
|
3936
|
+
client_id: _this.client.clientID
|
|
3896
3937
|
}]; // try to send on the connection
|
|
3897
3938
|
|
|
3898
3939
|
try {
|
|
@@ -3913,9 +3954,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3913
3954
|
var now = new Date();
|
|
3914
3955
|
|
|
3915
3956
|
if (_this.lastEvent && now.getTime() - _this.lastEvent.getTime() > _this.connectionCheckTimeout) {
|
|
3916
|
-
_this.
|
|
3917
|
-
tags: ['connection']
|
|
3918
|
-
});
|
|
3957
|
+
_this._log('scheduleConnectionCheck - going to reconnect');
|
|
3919
3958
|
|
|
3920
3959
|
_this._setHealth(false);
|
|
3921
3960
|
|
|
@@ -3924,15 +3963,8 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3924
3963
|
}, _this.connectionCheckTimeout);
|
|
3925
3964
|
});
|
|
3926
3965
|
|
|
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;
|
|
3966
|
+
/** StreamChat client */
|
|
3967
|
+
this.client = client;
|
|
3936
3968
|
/** consecutive failures influence the duration of the timeout */
|
|
3937
3969
|
|
|
3938
3970
|
this.consecutiveFailures = 0;
|
|
@@ -3942,18 +3974,15 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3942
3974
|
/** We only make 1 attempt to reconnect at the same time.. */
|
|
3943
3975
|
|
|
3944
3976
|
this.isConnecting = false;
|
|
3977
|
+
/** To avoid reconnect if client is disconnected */
|
|
3978
|
+
|
|
3979
|
+
this.isDisconnected = false;
|
|
3945
3980
|
/** Boolean that indicates if the connection promise is resolved */
|
|
3946
3981
|
|
|
3947
3982
|
this.isResolved = false;
|
|
3948
3983
|
/** Boolean that indicates if we have a working connection to the server */
|
|
3949
3984
|
|
|
3950
3985
|
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
3986
|
/** Incremented when a new WS connection is made */
|
|
3958
3987
|
|
|
3959
3988
|
this.wsID = 1;
|
|
@@ -3964,74 +3993,82 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3964
3993
|
|
|
3965
3994
|
this.pingInterval = 25 * 1000;
|
|
3966
3995
|
this.connectionCheckTimeout = this.pingInterval + 10 * 1000;
|
|
3967
|
-
|
|
3968
|
-
this._listenForConnectionChanges();
|
|
3969
|
-
|
|
3970
|
-
this.postInsights = postInsights;
|
|
3971
|
-
this.insightMetrics = insightMetrics;
|
|
3996
|
+
addConnectionEventListeners(this.onlineStatusChanged);
|
|
3972
3997
|
}
|
|
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
3998
|
|
|
3980
3999
|
_createClass__default['default'](StableWSConnection, [{
|
|
4000
|
+
key: "_log",
|
|
4001
|
+
value: function _log(msg) {
|
|
4002
|
+
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
4003
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
4004
|
+
this.client.logger(level, 'connection:' + msg, _objectSpread$3({
|
|
4005
|
+
tags: ['connection']
|
|
4006
|
+
}, extra));
|
|
4007
|
+
}
|
|
4008
|
+
/**
|
|
4009
|
+
* connect - Connect to the WS URL
|
|
4010
|
+
* the default 15s timeout allows between 2~3 tries
|
|
4011
|
+
* @return {ConnectAPIResponse<ChannelType, CommandType, UserType>} Promise that completes once the first health check message is received
|
|
4012
|
+
*/
|
|
4013
|
+
|
|
4014
|
+
}, {
|
|
3981
4015
|
key: "connect",
|
|
3982
4016
|
value: function () {
|
|
3983
4017
|
var _connect2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee() {
|
|
3984
|
-
var
|
|
4018
|
+
var timeout,
|
|
4019
|
+
healthCheck,
|
|
4020
|
+
_args = arguments;
|
|
3985
4021
|
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
3986
4022
|
while (1) {
|
|
3987
4023
|
switch (_context.prev = _context.next) {
|
|
3988
4024
|
case 0:
|
|
4025
|
+
timeout = _args.length > 0 && _args[0] !== undefined ? _args[0] : 15000;
|
|
4026
|
+
|
|
3989
4027
|
if (!this.isConnecting) {
|
|
3990
|
-
_context.next =
|
|
4028
|
+
_context.next = 3;
|
|
3991
4029
|
break;
|
|
3992
4030
|
}
|
|
3993
4031
|
|
|
3994
4032
|
throw Error("You've called connect twice, can only attempt 1 connection at the time");
|
|
3995
4033
|
|
|
3996
|
-
case
|
|
3997
|
-
|
|
3998
|
-
_context.
|
|
4034
|
+
case 3:
|
|
4035
|
+
this.isDisconnected = false;
|
|
4036
|
+
_context.prev = 4;
|
|
4037
|
+
_context.next = 7;
|
|
3999
4038
|
return this._connect();
|
|
4000
4039
|
|
|
4001
|
-
case
|
|
4040
|
+
case 7:
|
|
4002
4041
|
healthCheck = _context.sent;
|
|
4003
4042
|
this.consecutiveFailures = 0;
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
_context.next =
|
|
4043
|
+
|
|
4044
|
+
this._log("connect() - Established ws connection with healthcheck: ".concat(healthCheck));
|
|
4045
|
+
|
|
4046
|
+
_context.next = 23;
|
|
4008
4047
|
break;
|
|
4009
4048
|
|
|
4010
|
-
case
|
|
4011
|
-
_context.prev =
|
|
4012
|
-
_context.t0 = _context["catch"](
|
|
4049
|
+
case 12:
|
|
4050
|
+
_context.prev = 12;
|
|
4051
|
+
_context.t0 = _context["catch"](4);
|
|
4013
4052
|
this.isHealthy = false;
|
|
4014
4053
|
this.consecutiveFailures += 1;
|
|
4015
4054
|
|
|
4016
|
-
if (!(_context.t0.code === chatCodes.TOKEN_EXPIRED && !this.tokenManager.isStatic())) {
|
|
4017
|
-
_context.next =
|
|
4055
|
+
if (!(_context.t0.code === chatCodes.TOKEN_EXPIRED && !this.client.tokenManager.isStatic())) {
|
|
4056
|
+
_context.next = 21;
|
|
4018
4057
|
break;
|
|
4019
4058
|
}
|
|
4020
4059
|
|
|
4021
|
-
this.
|
|
4022
|
-
tags: ['connection']
|
|
4023
|
-
});
|
|
4060
|
+
this._log('connect() - WS failure due to expired token, so going to try to reload token and reconnect');
|
|
4024
4061
|
|
|
4025
4062
|
this._reconnect({
|
|
4026
4063
|
refreshToken: true
|
|
4027
4064
|
});
|
|
4028
4065
|
|
|
4029
|
-
_context.next =
|
|
4066
|
+
_context.next = 23;
|
|
4030
4067
|
break;
|
|
4031
4068
|
|
|
4032
|
-
case
|
|
4069
|
+
case 21:
|
|
4033
4070
|
if (_context.t0.isWSFailure) {
|
|
4034
|
-
_context.next =
|
|
4071
|
+
_context.next = 23;
|
|
4035
4072
|
break;
|
|
4036
4073
|
}
|
|
4037
4074
|
|
|
@@ -4042,19 +4079,19 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4042
4079
|
isWSFailure: _context.t0.isWSFailure
|
|
4043
4080
|
}));
|
|
4044
4081
|
|
|
4045
|
-
case 21:
|
|
4046
|
-
_context.next = 23;
|
|
4047
|
-
return this._waitForHealthy();
|
|
4048
|
-
|
|
4049
4082
|
case 23:
|
|
4083
|
+
_context.next = 25;
|
|
4084
|
+
return this._waitForHealthy(timeout);
|
|
4085
|
+
|
|
4086
|
+
case 25:
|
|
4050
4087
|
return _context.abrupt("return", _context.sent);
|
|
4051
4088
|
|
|
4052
|
-
case
|
|
4089
|
+
case 26:
|
|
4053
4090
|
case "end":
|
|
4054
4091
|
return _context.stop();
|
|
4055
4092
|
}
|
|
4056
4093
|
}
|
|
4057
|
-
}, _callee, this, [[
|
|
4094
|
+
}, _callee, this, [[4, 12]]);
|
|
4058
4095
|
}));
|
|
4059
4096
|
|
|
4060
4097
|
function connect() {
|
|
@@ -4145,6 +4182,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4145
4182
|
return sleep(timeout);
|
|
4146
4183
|
|
|
4147
4184
|
case 2:
|
|
4185
|
+
_this2.isConnecting = false;
|
|
4148
4186
|
throw new Error(JSON.stringify({
|
|
4149
4187
|
code: '',
|
|
4150
4188
|
StatusCode: '',
|
|
@@ -4152,7 +4190,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4152
4190
|
isWSFailure: true
|
|
4153
4191
|
}));
|
|
4154
4192
|
|
|
4155
|
-
case
|
|
4193
|
+
case 4:
|
|
4156
4194
|
case "end":
|
|
4157
4195
|
return _context3.stop();
|
|
4158
4196
|
}
|
|
@@ -4176,7 +4214,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4176
4214
|
}()
|
|
4177
4215
|
/**
|
|
4178
4216
|
* Builds and returns the url for websocket.
|
|
4179
|
-
* @
|
|
4217
|
+
* @private
|
|
4180
4218
|
* @returns url string
|
|
4181
4219
|
*/
|
|
4182
4220
|
|
|
@@ -4190,10 +4228,11 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4190
4228
|
function disconnect(timeout) {
|
|
4191
4229
|
var _this3 = this;
|
|
4192
4230
|
|
|
4193
|
-
this.
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
this.
|
|
4231
|
+
this._log("disconnect() - Closing the websocket connection for wsID ".concat(this.wsID));
|
|
4232
|
+
|
|
4233
|
+
this.wsID += 1;
|
|
4234
|
+
this.isConnecting = false;
|
|
4235
|
+
this.isDisconnected = true; // start by removing all the listeners
|
|
4197
4236
|
|
|
4198
4237
|
if (this.healthCheckTimeoutRef) {
|
|
4199
4238
|
clearInterval(this.healthCheckTimeoutRef);
|
|
@@ -4203,8 +4242,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4203
4242
|
clearInterval(this.connectionCheckTimeoutRef);
|
|
4204
4243
|
}
|
|
4205
4244
|
|
|
4206
|
-
this.
|
|
4207
|
-
|
|
4245
|
+
removeConnectionEventListeners(this.onlineStatusChanged);
|
|
4208
4246
|
this.isHealthy = false; // remove ws handlers...
|
|
4209
4247
|
|
|
4210
4248
|
if (this.ws && this.ws.removeAllListeners) {
|
|
@@ -4220,8 +4258,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4220
4258
|
if (ws && ws.close && ws.readyState === ws.OPEN) {
|
|
4221
4259
|
isClosedPromise = new Promise(function (resolve) {
|
|
4222
4260
|
var onclose = function onclose(event) {
|
|
4223
|
-
_this3.
|
|
4224
|
-
tags: ['connection'],
|
|
4261
|
+
_this3._log("disconnect() - resolving isClosedPromise ".concat(event ? 'with' : 'without', " close frame"), {
|
|
4225
4262
|
event: event
|
|
4226
4263
|
});
|
|
4227
4264
|
|
|
@@ -4233,14 +4270,13 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4233
4270
|
|
|
4234
4271
|
setTimeout(onclose, timeout != null ? timeout : 1000);
|
|
4235
4272
|
});
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4273
|
+
|
|
4274
|
+
this._log("disconnect() - Manually closed connection by calling client.disconnect()");
|
|
4275
|
+
|
|
4239
4276
|
ws.close(chatCodes.WS_CLOSED_SUCCESS, 'Manually closed connection by calling client.disconnect()');
|
|
4240
4277
|
} else {
|
|
4241
|
-
this.
|
|
4242
|
-
|
|
4243
|
-
});
|
|
4278
|
+
this._log("disconnect() - ws connection doesn't exist or it is already closed.");
|
|
4279
|
+
|
|
4244
4280
|
isClosedPromise = Promise.resolve();
|
|
4245
4281
|
}
|
|
4246
4282
|
|
|
@@ -4257,13 +4293,12 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4257
4293
|
key: "_connect",
|
|
4258
4294
|
value: function () {
|
|
4259
4295
|
var _connect3 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5() {
|
|
4260
|
-
var wsURL, response,
|
|
4261
|
-
|
|
4296
|
+
var wsURL, response, insights;
|
|
4262
4297
|
return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
|
|
4263
4298
|
while (1) {
|
|
4264
4299
|
switch (_context5.prev = _context5.next) {
|
|
4265
4300
|
case 0:
|
|
4266
|
-
if (!this.isConnecting) {
|
|
4301
|
+
if (!(this.isConnecting || this.isDisconnected)) {
|
|
4267
4302
|
_context5.next = 2;
|
|
4268
4303
|
break;
|
|
4269
4304
|
}
|
|
@@ -4274,15 +4309,15 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4274
4309
|
// simply ignore _connect if it's currently trying to connect
|
|
4275
4310
|
this.isConnecting = true;
|
|
4276
4311
|
this.requestID = randomId();
|
|
4277
|
-
this.insightMetrics.connectionStartTimestamp = new Date().getTime();
|
|
4312
|
+
this.client.insightMetrics.connectionStartTimestamp = new Date().getTime();
|
|
4278
4313
|
_context5.prev = 5;
|
|
4279
4314
|
_context5.next = 8;
|
|
4280
|
-
return this.tokenManager.tokenReady();
|
|
4315
|
+
return this.client.tokenManager.tokenReady();
|
|
4281
4316
|
|
|
4282
4317
|
case 8:
|
|
4283
4318
|
this._setupConnectionPromise();
|
|
4284
4319
|
|
|
4285
|
-
wsURL = this._buildUrl(
|
|
4320
|
+
wsURL = this._buildUrl();
|
|
4286
4321
|
this.ws = new WebSocket__default['default'](wsURL);
|
|
4287
4322
|
this.ws.onopen = this.onopen.bind(this, this.wsID);
|
|
4288
4323
|
this.ws.onclose = this.onclose.bind(this, this.wsID);
|
|
@@ -4302,9 +4337,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4302
4337
|
|
|
4303
4338
|
this.connectionID = response.connection_id;
|
|
4304
4339
|
|
|
4305
|
-
if (this.insightMetrics.wsConsecutiveFailures > 0 && this.
|
|
4306
|
-
|
|
4307
|
-
this.insightMetrics.wsConsecutiveFailures = 0;
|
|
4340
|
+
if (this.client.insightMetrics.wsConsecutiveFailures > 0 && this.client.options.enableInsights) {
|
|
4341
|
+
postInsights('ws_success_after_failure', buildWsSuccessAfterFailureInsight(this));
|
|
4342
|
+
this.client.insightMetrics.wsConsecutiveFailures = 0;
|
|
4308
4343
|
}
|
|
4309
4344
|
|
|
4310
4345
|
return _context5.abrupt("return", response);
|
|
@@ -4318,12 +4353,11 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4318
4353
|
_context5.t0 = _context5["catch"](5);
|
|
4319
4354
|
this.isConnecting = false;
|
|
4320
4355
|
|
|
4321
|
-
if (this.
|
|
4322
|
-
this.insightMetrics.wsConsecutiveFailures++;
|
|
4323
|
-
this.insightMetrics.wsTotalFailures++;
|
|
4324
|
-
|
|
4356
|
+
if (this.client.options.enableInsights) {
|
|
4357
|
+
this.client.insightMetrics.wsConsecutiveFailures++;
|
|
4358
|
+
this.client.insightMetrics.wsTotalFailures++;
|
|
4325
4359
|
insights = buildWsFatalInsight(this, convertErrorToJson(_context5.t0));
|
|
4326
|
-
|
|
4360
|
+
postInsights === null || postInsights === void 0 ? void 0 : postInsights('ws_fatal', insights);
|
|
4327
4361
|
}
|
|
4328
4362
|
|
|
4329
4363
|
throw _context5.t0;
|
|
@@ -4357,26 +4391,23 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4357
4391
|
var _reconnect2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee6() {
|
|
4358
4392
|
var options,
|
|
4359
4393
|
interval,
|
|
4360
|
-
_open,
|
|
4361
4394
|
_args6 = arguments;
|
|
4362
|
-
|
|
4363
4395
|
return _regeneratorRuntime__default['default'].wrap(function _callee6$(_context6) {
|
|
4364
4396
|
while (1) {
|
|
4365
4397
|
switch (_context6.prev = _context6.next) {
|
|
4366
4398
|
case 0:
|
|
4367
4399
|
options = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4400
|
+
|
|
4401
|
+
this._log('_reconnect() - Initiating the reconnect'); // only allow 1 connection at the time
|
|
4402
|
+
|
|
4371
4403
|
|
|
4372
4404
|
if (!(this.isConnecting || this.isHealthy)) {
|
|
4373
4405
|
_context6.next = 5;
|
|
4374
4406
|
break;
|
|
4375
4407
|
}
|
|
4376
4408
|
|
|
4377
|
-
this.
|
|
4378
|
-
|
|
4379
|
-
});
|
|
4409
|
+
this._log('_reconnect() - Abort (1) since already connecting or healthy');
|
|
4410
|
+
|
|
4380
4411
|
return _context6.abrupt("return");
|
|
4381
4412
|
|
|
4382
4413
|
case 5:
|
|
@@ -4398,95 +4429,86 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4398
4429
|
break;
|
|
4399
4430
|
}
|
|
4400
4431
|
|
|
4401
|
-
this.
|
|
4402
|
-
|
|
4403
|
-
});
|
|
4432
|
+
this._log('_reconnect() - Abort (2) since already connecting or healthy');
|
|
4433
|
+
|
|
4404
4434
|
return _context6.abrupt("return");
|
|
4405
4435
|
|
|
4406
4436
|
case 12:
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
}
|
|
4437
|
+
if (!this.isDisconnected) {
|
|
4438
|
+
_context6.next = 15;
|
|
4439
|
+
break;
|
|
4440
|
+
}
|
|
4441
|
+
|
|
4442
|
+
this._log('_reconnect() - Abort (3) since disconnect() is called');
|
|
4443
|
+
|
|
4444
|
+
return _context6.abrupt("return");
|
|
4445
|
+
|
|
4446
|
+
case 15:
|
|
4447
|
+
this._log('_reconnect() - Destroying current WS connection'); // cleanup the old connection
|
|
4448
|
+
|
|
4411
4449
|
|
|
4412
4450
|
this._destroyCurrentWSConnection();
|
|
4413
4451
|
|
|
4414
4452
|
if (!options.refreshToken) {
|
|
4415
|
-
_context6.next =
|
|
4453
|
+
_context6.next = 20;
|
|
4416
4454
|
break;
|
|
4417
4455
|
}
|
|
4418
4456
|
|
|
4419
|
-
_context6.next = 17;
|
|
4420
|
-
return this.tokenManager.loadToken();
|
|
4421
|
-
|
|
4422
|
-
case 17:
|
|
4423
|
-
_context6.prev = 17;
|
|
4424
4457
|
_context6.next = 20;
|
|
4425
|
-
return this.
|
|
4458
|
+
return this.client.tokenManager.loadToken();
|
|
4426
4459
|
|
|
4427
4460
|
case 20:
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
_context6.next = 26;
|
|
4432
|
-
break;
|
|
4433
|
-
}
|
|
4461
|
+
_context6.prev = 20;
|
|
4462
|
+
_context6.next = 23;
|
|
4463
|
+
return this._connect();
|
|
4434
4464
|
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
});
|
|
4438
|
-
_context6.next = 25;
|
|
4439
|
-
return this.recoverCallback(_open);
|
|
4465
|
+
case 23:
|
|
4466
|
+
this._log('_reconnect() - Waiting for recoverCallBack');
|
|
4440
4467
|
|
|
4441
|
-
|
|
4442
|
-
this.
|
|
4443
|
-
tags: ['connection']
|
|
4444
|
-
});
|
|
4468
|
+
_context6.next = 26;
|
|
4469
|
+
return this.client.recoverState();
|
|
4445
4470
|
|
|
4446
4471
|
case 26:
|
|
4472
|
+
this._log('_reconnect() - Finished recoverCallBack');
|
|
4473
|
+
|
|
4447
4474
|
this.consecutiveFailures = 0;
|
|
4448
|
-
_context6.next =
|
|
4475
|
+
_context6.next = 38;
|
|
4449
4476
|
break;
|
|
4450
4477
|
|
|
4451
|
-
case
|
|
4452
|
-
_context6.prev =
|
|
4453
|
-
_context6.t0 = _context6["catch"](
|
|
4478
|
+
case 30:
|
|
4479
|
+
_context6.prev = 30;
|
|
4480
|
+
_context6.t0 = _context6["catch"](20);
|
|
4454
4481
|
this.isHealthy = false;
|
|
4455
4482
|
this.consecutiveFailures += 1;
|
|
4456
4483
|
|
|
4457
|
-
if (!(_context6.t0.code === chatCodes.TOKEN_EXPIRED && !this.tokenManager.isStatic())) {
|
|
4458
|
-
_context6.next =
|
|
4484
|
+
if (!(_context6.t0.code === chatCodes.TOKEN_EXPIRED && !this.client.tokenManager.isStatic())) {
|
|
4485
|
+
_context6.next = 37;
|
|
4459
4486
|
break;
|
|
4460
4487
|
}
|
|
4461
4488
|
|
|
4462
|
-
this.
|
|
4463
|
-
|
|
4464
|
-
});
|
|
4489
|
+
this._log('_reconnect() - WS failure due to expired token, so going to try to reload token and reconnect');
|
|
4490
|
+
|
|
4465
4491
|
return _context6.abrupt("return", this._reconnect({
|
|
4466
4492
|
refreshToken: true
|
|
4467
4493
|
}));
|
|
4468
4494
|
|
|
4469
|
-
case
|
|
4495
|
+
case 37:
|
|
4470
4496
|
// reconnect on WS failures, don't reconnect if there is a code bug
|
|
4471
4497
|
if (_context6.t0.isWSFailure) {
|
|
4472
|
-
this.
|
|
4473
|
-
tags: ['connection']
|
|
4474
|
-
});
|
|
4498
|
+
this._log('_reconnect() - WS failure, so going to try to reconnect');
|
|
4475
4499
|
|
|
4476
4500
|
this._reconnect();
|
|
4477
4501
|
}
|
|
4478
4502
|
|
|
4479
|
-
case 37:
|
|
4480
|
-
this.logger('info', 'connection:_reconnect() - == END ==', {
|
|
4481
|
-
tags: ['connection']
|
|
4482
|
-
});
|
|
4483
|
-
|
|
4484
4503
|
case 38:
|
|
4504
|
+
this._log('_reconnect() - == END ==');
|
|
4505
|
+
|
|
4506
|
+
case 39:
|
|
4485
4507
|
case "end":
|
|
4486
4508
|
return _context6.stop();
|
|
4487
4509
|
}
|
|
4488
4510
|
}
|
|
4489
|
-
}, _callee6, this, [[
|
|
4511
|
+
}, _callee6, this, [[20, 30]]);
|
|
4490
4512
|
}));
|
|
4491
4513
|
|
|
4492
4514
|
function _reconnect() {
|
|
@@ -4515,13 +4537,10 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4515
4537
|
this.wsID += 1;
|
|
4516
4538
|
|
|
4517
4539
|
try {
|
|
4518
|
-
|
|
4519
|
-
this.ws.removeAllListeners();
|
|
4520
|
-
}
|
|
4540
|
+
var _this$ws2, _this$ws3;
|
|
4521
4541
|
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
}
|
|
4542
|
+
this === null || this === void 0 ? void 0 : (_this$ws2 = this.ws) === null || _this$ws2 === void 0 ? void 0 : _this$ws2.removeAllListeners();
|
|
4543
|
+
this === null || this === void 0 ? void 0 : (_this$ws3 = this.ws) === null || _this$ws3 === void 0 ? void 0 : _this$ws3.close();
|
|
4525
4544
|
} catch (e) {// we don't care
|
|
4526
4545
|
}
|
|
4527
4546
|
}
|
|
@@ -4538,9 +4557,9 @@ var jwt = null;
|
|
|
4538
4557
|
|
|
4539
4558
|
var crypto$1 = null;
|
|
4540
4559
|
|
|
4541
|
-
function ownKeys$
|
|
4560
|
+
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
4542
4561
|
|
|
4543
|
-
function _objectSpread$
|
|
4562
|
+
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(Object(source), true).forEach(function (key) { _defineProperty__default['default'](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
4544
4563
|
|
|
4545
4564
|
/**
|
|
4546
4565
|
* Creates the JWT token that can be used for a UserSession
|
|
@@ -4549,7 +4568,7 @@ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) {
|
|
|
4549
4568
|
* @private
|
|
4550
4569
|
* @param {Secret} apiSecret - API Secret key
|
|
4551
4570
|
* @param {string} userId - The user_id key in the JWT payload
|
|
4552
|
-
* @param {
|
|
4571
|
+
* @param {UR} [extraData] - Extra that should be part of the JWT token
|
|
4553
4572
|
* @param {SignOptions} [jwtOptions] - Options that can be past to jwt.sign
|
|
4554
4573
|
* @return {string} JWT Token
|
|
4555
4574
|
*/
|
|
@@ -4561,7 +4580,7 @@ function JWTUserToken(apiSecret, userId) {
|
|
|
4561
4580
|
throw new TypeError('userId should be a string');
|
|
4562
4581
|
}
|
|
4563
4582
|
|
|
4564
|
-
var payload = _objectSpread$
|
|
4583
|
+
var payload = _objectSpread$2({
|
|
4565
4584
|
user_id: userId
|
|
4566
4585
|
}, extraData); // make sure we return a clear error when jwt is shimmed (ie. browser build)
|
|
4567
4586
|
|
|
@@ -4742,76 +4761,586 @@ function TokenManager(secret) {
|
|
|
4742
4761
|
break;
|
|
4743
4762
|
}
|
|
4744
4763
|
|
|
4745
|
-
return _context2.abrupt("return", resolve(_this.token));
|
|
4764
|
+
return _context2.abrupt("return", resolve(_this.token));
|
|
4765
|
+
|
|
4766
|
+
case 2:
|
|
4767
|
+
if (!(_this.tokenProvider && typeof _this.tokenProvider !== 'string')) {
|
|
4768
|
+
_context2.next = 7;
|
|
4769
|
+
break;
|
|
4770
|
+
}
|
|
4771
|
+
|
|
4772
|
+
_context2.next = 5;
|
|
4773
|
+
return _this.tokenProvider();
|
|
4774
|
+
|
|
4775
|
+
case 5:
|
|
4776
|
+
_this.token = _context2.sent;
|
|
4777
|
+
resolve(_this.token);
|
|
4778
|
+
|
|
4779
|
+
case 7:
|
|
4780
|
+
case "end":
|
|
4781
|
+
return _context2.stop();
|
|
4782
|
+
}
|
|
4783
|
+
}
|
|
4784
|
+
}, _callee2);
|
|
4785
|
+
}));
|
|
4786
|
+
|
|
4787
|
+
return function (_x3) {
|
|
4788
|
+
return _ref2.apply(this, arguments);
|
|
4789
|
+
};
|
|
4790
|
+
}());
|
|
4791
|
+
return _this.loadTokenPromise;
|
|
4792
|
+
});
|
|
4793
|
+
|
|
4794
|
+
_defineProperty__default['default'](this, "getToken", function () {
|
|
4795
|
+
if (_this.token) {
|
|
4796
|
+
return _this.token;
|
|
4797
|
+
}
|
|
4798
|
+
|
|
4799
|
+
if (_this.user && _this.user.anon && !_this.token) {
|
|
4800
|
+
return _this.token;
|
|
4801
|
+
}
|
|
4802
|
+
|
|
4803
|
+
if (_this.secret) {
|
|
4804
|
+
return JWTServerToken(_this.secret);
|
|
4805
|
+
}
|
|
4806
|
+
|
|
4807
|
+
throw new Error("Both secret and user tokens are not set. Either client.connectUser wasn't called or client.disconnect was called");
|
|
4808
|
+
});
|
|
4809
|
+
|
|
4810
|
+
_defineProperty__default['default'](this, "isStatic", function () {
|
|
4811
|
+
return _this.type === 'static';
|
|
4812
|
+
});
|
|
4813
|
+
|
|
4814
|
+
this.loadTokenPromise = null;
|
|
4815
|
+
|
|
4816
|
+
if (secret) {
|
|
4817
|
+
this.secret = secret;
|
|
4818
|
+
}
|
|
4819
|
+
|
|
4820
|
+
this.type = 'static';
|
|
4821
|
+
|
|
4822
|
+
if (this.secret) {
|
|
4823
|
+
this.token = JWTServerToken(this.secret);
|
|
4824
|
+
}
|
|
4825
|
+
}
|
|
4826
|
+
/**
|
|
4827
|
+
* Set the static string token or token provider.
|
|
4828
|
+
* Token provider should return a token string or a promise which resolves to string token.
|
|
4829
|
+
*
|
|
4830
|
+
* @param {TokenOrProvider} tokenOrProvider
|
|
4831
|
+
* @param {UserResponse<UserType>} user
|
|
4832
|
+
*/
|
|
4833
|
+
;
|
|
4834
|
+
|
|
4835
|
+
var APIErrorCodes = {
|
|
4836
|
+
'-1': {
|
|
4837
|
+
name: 'InternalSystemError',
|
|
4838
|
+
retryable: true
|
|
4839
|
+
},
|
|
4840
|
+
'2': {
|
|
4841
|
+
name: 'AccessKeyError',
|
|
4842
|
+
retryable: false
|
|
4843
|
+
},
|
|
4844
|
+
'3': {
|
|
4845
|
+
name: 'AuthenticationFailedError',
|
|
4846
|
+
retryable: true
|
|
4847
|
+
},
|
|
4848
|
+
'4': {
|
|
4849
|
+
name: 'InputError',
|
|
4850
|
+
retryable: false
|
|
4851
|
+
},
|
|
4852
|
+
'6': {
|
|
4853
|
+
name: 'DuplicateUsernameError',
|
|
4854
|
+
retryable: false
|
|
4855
|
+
},
|
|
4856
|
+
'9': {
|
|
4857
|
+
name: 'RateLimitError',
|
|
4858
|
+
retryable: true
|
|
4859
|
+
},
|
|
4860
|
+
'16': {
|
|
4861
|
+
name: 'DoesNotExistError',
|
|
4862
|
+
retryable: false
|
|
4863
|
+
},
|
|
4864
|
+
'17': {
|
|
4865
|
+
name: 'NotAllowedError',
|
|
4866
|
+
retryable: false
|
|
4867
|
+
},
|
|
4868
|
+
'18': {
|
|
4869
|
+
name: 'EventNotSupportedError',
|
|
4870
|
+
retryable: false
|
|
4871
|
+
},
|
|
4872
|
+
'19': {
|
|
4873
|
+
name: 'ChannelFeatureNotSupportedError',
|
|
4874
|
+
retryable: false
|
|
4875
|
+
},
|
|
4876
|
+
'20': {
|
|
4877
|
+
name: 'MessageTooLongError',
|
|
4878
|
+
retryable: false
|
|
4879
|
+
},
|
|
4880
|
+
'21': {
|
|
4881
|
+
name: 'MultipleNestingLevelError',
|
|
4882
|
+
retryable: false
|
|
4883
|
+
},
|
|
4884
|
+
'22': {
|
|
4885
|
+
name: 'PayloadTooBigError',
|
|
4886
|
+
retryable: false
|
|
4887
|
+
},
|
|
4888
|
+
'23': {
|
|
4889
|
+
name: 'RequestTimeoutError',
|
|
4890
|
+
retryable: true
|
|
4891
|
+
},
|
|
4892
|
+
'24': {
|
|
4893
|
+
name: 'MaxHeaderSizeExceededError',
|
|
4894
|
+
retryable: false
|
|
4895
|
+
},
|
|
4896
|
+
'40': {
|
|
4897
|
+
name: 'AuthErrorTokenExpired',
|
|
4898
|
+
retryable: false
|
|
4899
|
+
},
|
|
4900
|
+
'41': {
|
|
4901
|
+
name: 'AuthErrorTokenNotValidYet',
|
|
4902
|
+
retryable: false
|
|
4903
|
+
},
|
|
4904
|
+
'42': {
|
|
4905
|
+
name: 'AuthErrorTokenUsedBeforeIssuedAt',
|
|
4906
|
+
retryable: false
|
|
4907
|
+
},
|
|
4908
|
+
'43': {
|
|
4909
|
+
name: 'AuthErrorTokenSignatureInvalid',
|
|
4910
|
+
retryable: false
|
|
4911
|
+
},
|
|
4912
|
+
'44': {
|
|
4913
|
+
name: 'CustomCommandEndpointMissingError',
|
|
4914
|
+
retryable: false
|
|
4915
|
+
},
|
|
4916
|
+
'45': {
|
|
4917
|
+
name: 'CustomCommandEndpointCallError',
|
|
4918
|
+
retryable: true
|
|
4919
|
+
},
|
|
4920
|
+
'46': {
|
|
4921
|
+
name: 'ConnectionIDNotFoundError',
|
|
4922
|
+
retryable: false
|
|
4923
|
+
},
|
|
4924
|
+
'60': {
|
|
4925
|
+
name: 'CoolDownError',
|
|
4926
|
+
retryable: true
|
|
4927
|
+
},
|
|
4928
|
+
'69': {
|
|
4929
|
+
name: 'ErrWrongRegion',
|
|
4930
|
+
retryable: false
|
|
4931
|
+
},
|
|
4932
|
+
'70': {
|
|
4933
|
+
name: 'ErrQueryChannelPermissions',
|
|
4934
|
+
retryable: false
|
|
4935
|
+
},
|
|
4936
|
+
'71': {
|
|
4937
|
+
name: 'ErrTooManyConnections',
|
|
4938
|
+
retryable: true
|
|
4939
|
+
},
|
|
4940
|
+
'99': {
|
|
4941
|
+
name: 'AppSuspendedError',
|
|
4942
|
+
retryable: false
|
|
4943
|
+
}
|
|
4944
|
+
};
|
|
4945
|
+
function isAPIError(error) {
|
|
4946
|
+
return error.code !== undefined;
|
|
4947
|
+
}
|
|
4948
|
+
function isErrorRetryable(error) {
|
|
4949
|
+
if (!error.code) return false;
|
|
4950
|
+
var err = APIErrorCodes["".concat(error.code)];
|
|
4951
|
+
if (!err) return false;
|
|
4952
|
+
return err.retryable;
|
|
4953
|
+
}
|
|
4954
|
+
function isConnectionIDError(error) {
|
|
4955
|
+
return error.code === 46; // ConnectionIDNotFoundError
|
|
4956
|
+
}
|
|
4957
|
+
function isWSFailure(err) {
|
|
4958
|
+
if (typeof err.isWSFailure === 'boolean') {
|
|
4959
|
+
return err.isWSFailure;
|
|
4960
|
+
}
|
|
4961
|
+
|
|
4962
|
+
try {
|
|
4963
|
+
return JSON.parse(err.message).isWSFailure;
|
|
4964
|
+
} catch (_) {
|
|
4965
|
+
return false;
|
|
4966
|
+
}
|
|
4967
|
+
}
|
|
4968
|
+
|
|
4969
|
+
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; }
|
|
4970
|
+
|
|
4971
|
+
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; }
|
|
4972
|
+
var ConnectionState;
|
|
4973
|
+
|
|
4974
|
+
(function (ConnectionState) {
|
|
4975
|
+
ConnectionState["Closed"] = "CLOSED";
|
|
4976
|
+
ConnectionState["Connected"] = "CONNECTED";
|
|
4977
|
+
ConnectionState["Connecting"] = "CONNECTING";
|
|
4978
|
+
ConnectionState["Disconnected"] = "DISCONNECTED";
|
|
4979
|
+
ConnectionState["Init"] = "INIT";
|
|
4980
|
+
})(ConnectionState || (ConnectionState = {}));
|
|
4981
|
+
|
|
4982
|
+
var WSConnectionFallback = /*#__PURE__*/function () {
|
|
4983
|
+
function WSConnectionFallback(_ref) {
|
|
4984
|
+
var _this = this;
|
|
4985
|
+
|
|
4986
|
+
var client = _ref.client;
|
|
4987
|
+
|
|
4988
|
+
_classCallCheck__default['default'](this, WSConnectionFallback);
|
|
4989
|
+
|
|
4990
|
+
_defineProperty__default['default'](this, "client", void 0);
|
|
4991
|
+
|
|
4992
|
+
_defineProperty__default['default'](this, "state", void 0);
|
|
4993
|
+
|
|
4994
|
+
_defineProperty__default['default'](this, "consecutiveFailures", void 0);
|
|
4995
|
+
|
|
4996
|
+
_defineProperty__default['default'](this, "connectionID", void 0);
|
|
4997
|
+
|
|
4998
|
+
_defineProperty__default['default'](this, "cancelToken", void 0);
|
|
4999
|
+
|
|
5000
|
+
_defineProperty__default['default'](this, "_onlineStatusChanged", function (event) {
|
|
5001
|
+
_this._log("_onlineStatusChanged() - ".concat(event.type));
|
|
5002
|
+
|
|
5003
|
+
if (event.type === 'offline') {
|
|
5004
|
+
var _this$cancelToken;
|
|
5005
|
+
|
|
5006
|
+
_this._setState(ConnectionState.Closed);
|
|
5007
|
+
|
|
5008
|
+
(_this$cancelToken = _this.cancelToken) === null || _this$cancelToken === void 0 ? void 0 : _this$cancelToken.cancel('disconnect() is called');
|
|
5009
|
+
_this.cancelToken = undefined;
|
|
5010
|
+
return;
|
|
5011
|
+
}
|
|
5012
|
+
|
|
5013
|
+
if (event.type === 'online' && _this.state === ConnectionState.Closed) {
|
|
5014
|
+
_this.connect(true);
|
|
5015
|
+
}
|
|
5016
|
+
});
|
|
5017
|
+
|
|
5018
|
+
_defineProperty__default['default'](this, "_req", /*#__PURE__*/function () {
|
|
5019
|
+
var _ref2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee(params, config, retry) {
|
|
5020
|
+
var _this$cancelToken2, res;
|
|
5021
|
+
|
|
5022
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee$(_context) {
|
|
5023
|
+
while (1) {
|
|
5024
|
+
switch (_context.prev = _context.next) {
|
|
5025
|
+
case 0:
|
|
5026
|
+
if (!_this.cancelToken && !params.close) {
|
|
5027
|
+
_this.cancelToken = axios__default['default'].CancelToken.source();
|
|
5028
|
+
}
|
|
5029
|
+
|
|
5030
|
+
_context.prev = 1;
|
|
5031
|
+
_context.next = 4;
|
|
5032
|
+
return _this.client.doAxiosRequest('get', _this.client.baseURL.replace(':3030', ':8900') + '/longpoll', // replace port if present for testing with local API
|
|
5033
|
+
undefined, {
|
|
5034
|
+
config: _objectSpread$1(_objectSpread$1({}, config), {}, {
|
|
5035
|
+
cancelToken: (_this$cancelToken2 = _this.cancelToken) === null || _this$cancelToken2 === void 0 ? void 0 : _this$cancelToken2.token
|
|
5036
|
+
}),
|
|
5037
|
+
params: params
|
|
5038
|
+
});
|
|
5039
|
+
|
|
5040
|
+
case 4:
|
|
5041
|
+
res = _context.sent;
|
|
5042
|
+
_this.consecutiveFailures = 0; // always reset in case of no error
|
|
5043
|
+
|
|
5044
|
+
return _context.abrupt("return", res);
|
|
5045
|
+
|
|
5046
|
+
case 9:
|
|
5047
|
+
_context.prev = 9;
|
|
5048
|
+
_context.t0 = _context["catch"](1);
|
|
5049
|
+
_this.consecutiveFailures += 1;
|
|
5050
|
+
|
|
5051
|
+
if (!(retry && isErrorRetryable(_context.t0))) {
|
|
5052
|
+
_context.next = 17;
|
|
5053
|
+
break;
|
|
5054
|
+
}
|
|
5055
|
+
|
|
5056
|
+
_this._log("_req() - Retryable error, retrying request");
|
|
5057
|
+
|
|
5058
|
+
_context.next = 16;
|
|
5059
|
+
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5060
|
+
|
|
5061
|
+
case 16:
|
|
5062
|
+
return _context.abrupt("return", _this._req(params, config, retry));
|
|
5063
|
+
|
|
5064
|
+
case 17:
|
|
5065
|
+
throw _context.t0;
|
|
5066
|
+
|
|
5067
|
+
case 18:
|
|
5068
|
+
case "end":
|
|
5069
|
+
return _context.stop();
|
|
5070
|
+
}
|
|
5071
|
+
}
|
|
5072
|
+
}, _callee, null, [[1, 9]]);
|
|
5073
|
+
}));
|
|
5074
|
+
|
|
5075
|
+
return function (_x, _x2, _x3) {
|
|
5076
|
+
return _ref2.apply(this, arguments);
|
|
5077
|
+
};
|
|
5078
|
+
}());
|
|
5079
|
+
|
|
5080
|
+
_defineProperty__default['default'](this, "_poll", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2() {
|
|
5081
|
+
var _data$events, data, i;
|
|
5082
|
+
|
|
5083
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
5084
|
+
while (1) {
|
|
5085
|
+
switch (_context2.prev = _context2.next) {
|
|
5086
|
+
case 0:
|
|
5087
|
+
if (!(_this.state === ConnectionState.Connected)) {
|
|
5088
|
+
_context2.next = 25;
|
|
5089
|
+
break;
|
|
5090
|
+
}
|
|
5091
|
+
|
|
5092
|
+
_context2.prev = 1;
|
|
5093
|
+
_context2.next = 4;
|
|
5094
|
+
return _this._req({}, {
|
|
5095
|
+
timeout: 30000
|
|
5096
|
+
}, true);
|
|
5097
|
+
|
|
5098
|
+
case 4:
|
|
5099
|
+
data = _context2.sent;
|
|
5100
|
+
|
|
5101
|
+
// 30s => API responds in 20s if there is no event
|
|
5102
|
+
if ((_data$events = data.events) !== null && _data$events !== void 0 && _data$events.length) {
|
|
5103
|
+
for (i = 0; i < data.events.length; i++) {
|
|
5104
|
+
_this.client.dispatchEvent(data.events[i]);
|
|
5105
|
+
}
|
|
5106
|
+
}
|
|
5107
|
+
|
|
5108
|
+
_context2.next = 23;
|
|
5109
|
+
break;
|
|
5110
|
+
|
|
5111
|
+
case 8:
|
|
5112
|
+
_context2.prev = 8;
|
|
5113
|
+
_context2.t0 = _context2["catch"](1);
|
|
5114
|
+
|
|
5115
|
+
if (!axios__default['default'].isCancel(_context2.t0)) {
|
|
5116
|
+
_context2.next = 13;
|
|
5117
|
+
break;
|
|
5118
|
+
}
|
|
5119
|
+
|
|
5120
|
+
_this._log("_poll() - axios canceled request");
|
|
5121
|
+
|
|
5122
|
+
return _context2.abrupt("return");
|
|
5123
|
+
|
|
5124
|
+
case 13:
|
|
5125
|
+
if (!isConnectionIDError(_context2.t0)) {
|
|
5126
|
+
_context2.next = 18;
|
|
5127
|
+
break;
|
|
5128
|
+
}
|
|
5129
|
+
|
|
5130
|
+
_this._log("_poll() - ConnectionID error, connecting without ID...");
|
|
5131
|
+
|
|
5132
|
+
_this._setState(ConnectionState.Disconnected);
|
|
5133
|
+
|
|
5134
|
+
_this.connect(true);
|
|
5135
|
+
|
|
5136
|
+
return _context2.abrupt("return");
|
|
5137
|
+
|
|
5138
|
+
case 18:
|
|
5139
|
+
if (!(isAPIError(_context2.t0) && !isErrorRetryable(_context2.t0))) {
|
|
5140
|
+
_context2.next = 21;
|
|
5141
|
+
break;
|
|
5142
|
+
}
|
|
5143
|
+
|
|
5144
|
+
_this._setState(ConnectionState.Closed);
|
|
5145
|
+
|
|
5146
|
+
return _context2.abrupt("return");
|
|
5147
|
+
|
|
5148
|
+
case 21:
|
|
5149
|
+
_context2.next = 23;
|
|
5150
|
+
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5151
|
+
|
|
5152
|
+
case 23:
|
|
5153
|
+
_context2.next = 0;
|
|
5154
|
+
break;
|
|
5155
|
+
|
|
5156
|
+
case 25:
|
|
5157
|
+
case "end":
|
|
5158
|
+
return _context2.stop();
|
|
5159
|
+
}
|
|
5160
|
+
}
|
|
5161
|
+
}, _callee2, null, [[1, 8]]);
|
|
5162
|
+
})));
|
|
5163
|
+
|
|
5164
|
+
_defineProperty__default['default'](this, "connect", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
5165
|
+
var reconnect,
|
|
5166
|
+
_yield$_this$_req,
|
|
5167
|
+
event,
|
|
5168
|
+
_args3 = arguments;
|
|
5169
|
+
|
|
5170
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
5171
|
+
while (1) {
|
|
5172
|
+
switch (_context3.prev = _context3.next) {
|
|
5173
|
+
case 0:
|
|
5174
|
+
reconnect = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : false;
|
|
5175
|
+
|
|
5176
|
+
if (!(_this.state === ConnectionState.Connecting)) {
|
|
5177
|
+
_context3.next = 4;
|
|
5178
|
+
break;
|
|
5179
|
+
}
|
|
5180
|
+
|
|
5181
|
+
_this._log('connect() - connecting already in progress', {
|
|
5182
|
+
reconnect: reconnect
|
|
5183
|
+
}, 'warn');
|
|
5184
|
+
|
|
5185
|
+
return _context3.abrupt("return");
|
|
5186
|
+
|
|
5187
|
+
case 4:
|
|
5188
|
+
if (!(_this.state === ConnectionState.Connected)) {
|
|
5189
|
+
_context3.next = 7;
|
|
5190
|
+
break;
|
|
5191
|
+
}
|
|
5192
|
+
|
|
5193
|
+
_this._log('connect() - already connected and polling', {
|
|
5194
|
+
reconnect: reconnect
|
|
5195
|
+
}, 'warn');
|
|
5196
|
+
|
|
5197
|
+
return _context3.abrupt("return");
|
|
5198
|
+
|
|
5199
|
+
case 7:
|
|
5200
|
+
_this._setState(ConnectionState.Connecting);
|
|
5201
|
+
|
|
5202
|
+
_this.connectionID = undefined; // connect should be sent with empty connection_id so API creates one
|
|
5203
|
+
|
|
5204
|
+
_context3.prev = 9;
|
|
5205
|
+
_context3.next = 12;
|
|
5206
|
+
return _this._req({
|
|
5207
|
+
json: _this.client._buildWSPayload()
|
|
5208
|
+
}, {
|
|
5209
|
+
timeout: 8000
|
|
5210
|
+
}, // 8s
|
|
5211
|
+
reconnect);
|
|
5212
|
+
|
|
5213
|
+
case 12:
|
|
5214
|
+
_yield$_this$_req = _context3.sent;
|
|
5215
|
+
event = _yield$_this$_req.event;
|
|
5216
|
+
|
|
5217
|
+
_this._setState(ConnectionState.Connected);
|
|
5218
|
+
|
|
5219
|
+
_this.connectionID = event.connection_id;
|
|
5220
|
+
|
|
5221
|
+
_this._poll();
|
|
5222
|
+
|
|
5223
|
+
if (reconnect) {
|
|
5224
|
+
_this.client.recoverState();
|
|
5225
|
+
}
|
|
5226
|
+
|
|
5227
|
+
return _context3.abrupt("return", event);
|
|
5228
|
+
|
|
5229
|
+
case 21:
|
|
5230
|
+
_context3.prev = 21;
|
|
5231
|
+
_context3.t0 = _context3["catch"](9);
|
|
5232
|
+
|
|
5233
|
+
_this._setState(ConnectionState.Closed);
|
|
5234
|
+
|
|
5235
|
+
throw _context3.t0;
|
|
5236
|
+
|
|
5237
|
+
case 25:
|
|
5238
|
+
case "end":
|
|
5239
|
+
return _context3.stop();
|
|
5240
|
+
}
|
|
5241
|
+
}
|
|
5242
|
+
}, _callee3, null, [[9, 21]]);
|
|
5243
|
+
})));
|
|
5244
|
+
|
|
5245
|
+
_defineProperty__default['default'](this, "isHealthy", function () {
|
|
5246
|
+
return _this.connectionID && _this.state === ConnectionState.Connected;
|
|
5247
|
+
});
|
|
4746
5248
|
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
_context2.next = 7;
|
|
4750
|
-
break;
|
|
4751
|
-
}
|
|
5249
|
+
_defineProperty__default['default'](this, "disconnect", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4() {
|
|
5250
|
+
var _this$cancelToken3;
|
|
4752
5251
|
|
|
4753
|
-
|
|
4754
|
-
|
|
5252
|
+
var timeout,
|
|
5253
|
+
connection_id,
|
|
5254
|
+
_args4 = arguments;
|
|
5255
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
5256
|
+
while (1) {
|
|
5257
|
+
switch (_context4.prev = _context4.next) {
|
|
5258
|
+
case 0:
|
|
5259
|
+
timeout = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : 2000;
|
|
5260
|
+
removeConnectionEventListeners(_this._onlineStatusChanged);
|
|
5261
|
+
|
|
5262
|
+
_this._setState(ConnectionState.Disconnected);
|
|
5263
|
+
|
|
5264
|
+
(_this$cancelToken3 = _this.cancelToken) === null || _this$cancelToken3 === void 0 ? void 0 : _this$cancelToken3.cancel('disconnect() is called');
|
|
5265
|
+
_this.cancelToken = undefined;
|
|
5266
|
+
connection_id = _this.connectionID;
|
|
5267
|
+
_this.connectionID = undefined;
|
|
5268
|
+
_context4.prev = 7;
|
|
5269
|
+
_context4.next = 10;
|
|
5270
|
+
return _this._req({
|
|
5271
|
+
close: true,
|
|
5272
|
+
connection_id: connection_id
|
|
5273
|
+
}, {
|
|
5274
|
+
timeout: timeout
|
|
5275
|
+
}, false);
|
|
4755
5276
|
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
resolve(_this.token);
|
|
5277
|
+
case 10:
|
|
5278
|
+
_this._log("disconnect() - Closed connectionID");
|
|
4759
5279
|
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
return _context2.stop();
|
|
4763
|
-
}
|
|
4764
|
-
}
|
|
4765
|
-
}, _callee2);
|
|
4766
|
-
}));
|
|
5280
|
+
_context4.next = 16;
|
|
5281
|
+
break;
|
|
4767
5282
|
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
}());
|
|
4772
|
-
return _this.loadTokenPromise;
|
|
4773
|
-
});
|
|
5283
|
+
case 13:
|
|
5284
|
+
_context4.prev = 13;
|
|
5285
|
+
_context4.t0 = _context4["catch"](7);
|
|
4774
5286
|
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
}
|
|
5287
|
+
_this._log("disconnect() - Failed", {
|
|
5288
|
+
err: _context4.t0
|
|
5289
|
+
}, 'error');
|
|
4779
5290
|
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
5291
|
+
case 16:
|
|
5292
|
+
case "end":
|
|
5293
|
+
return _context4.stop();
|
|
5294
|
+
}
|
|
5295
|
+
}
|
|
5296
|
+
}, _callee4, null, [[7, 13]]);
|
|
5297
|
+
})));
|
|
4783
5298
|
|
|
4784
|
-
|
|
4785
|
-
|
|
5299
|
+
this.client = client;
|
|
5300
|
+
this.state = ConnectionState.Init;
|
|
5301
|
+
this.consecutiveFailures = 0;
|
|
5302
|
+
addConnectionEventListeners(this._onlineStatusChanged);
|
|
5303
|
+
}
|
|
5304
|
+
|
|
5305
|
+
_createClass__default['default'](WSConnectionFallback, [{
|
|
5306
|
+
key: "_log",
|
|
5307
|
+
value: function _log(msg) {
|
|
5308
|
+
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5309
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
5310
|
+
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$1({
|
|
5311
|
+
tags: ['connection_fallback', 'connection']
|
|
5312
|
+
}, extra));
|
|
4786
5313
|
}
|
|
5314
|
+
}, {
|
|
5315
|
+
key: "_setState",
|
|
5316
|
+
value: function _setState(state) {
|
|
5317
|
+
this._log("_setState() - ".concat(state)); // transition from connecting => connected
|
|
4787
5318
|
|
|
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
5319
|
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
5320
|
+
if (this.state === ConnectionState.Connecting && state === ConnectionState.Connected) {
|
|
5321
|
+
//@ts-expect-error
|
|
5322
|
+
this.client.dispatchEvent({
|
|
5323
|
+
type: 'connection.changed',
|
|
5324
|
+
online: true
|
|
5325
|
+
});
|
|
5326
|
+
}
|
|
4794
5327
|
|
|
4795
|
-
|
|
5328
|
+
if (state === ConnectionState.Closed || state === ConnectionState.Disconnected) {
|
|
5329
|
+
//@ts-expect-error
|
|
5330
|
+
this.client.dispatchEvent({
|
|
5331
|
+
type: 'connection.changed',
|
|
5332
|
+
online: false
|
|
5333
|
+
});
|
|
5334
|
+
}
|
|
4796
5335
|
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
5336
|
+
this.state = state;
|
|
5337
|
+
}
|
|
5338
|
+
/** @private */
|
|
4800
5339
|
|
|
4801
|
-
|
|
5340
|
+
}]);
|
|
4802
5341
|
|
|
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
|
-
;
|
|
5342
|
+
return WSConnectionFallback;
|
|
5343
|
+
}();
|
|
4815
5344
|
|
|
4816
5345
|
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
5346
|
|
|
@@ -4851,10 +5380,6 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4851
5380
|
|
|
4852
5381
|
_defineProperty__default['default'](this, "configs", void 0);
|
|
4853
5382
|
|
|
4854
|
-
_defineProperty__default['default'](this, "connectionID", void 0);
|
|
4855
|
-
|
|
4856
|
-
_defineProperty__default['default'](this, "failures", void 0);
|
|
4857
|
-
|
|
4858
5383
|
_defineProperty__default['default'](this, "key", void 0);
|
|
4859
5384
|
|
|
4860
5385
|
_defineProperty__default['default'](this, "listeners", void 0);
|
|
@@ -4889,16 +5414,26 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4889
5414
|
|
|
4890
5415
|
_defineProperty__default['default'](this, "wsConnection", void 0);
|
|
4891
5416
|
|
|
5417
|
+
_defineProperty__default['default'](this, "wsFallback", void 0);
|
|
5418
|
+
|
|
4892
5419
|
_defineProperty__default['default'](this, "wsPromise", void 0);
|
|
4893
5420
|
|
|
4894
5421
|
_defineProperty__default['default'](this, "consecutiveFailures", void 0);
|
|
4895
5422
|
|
|
4896
5423
|
_defineProperty__default['default'](this, "insightMetrics", void 0);
|
|
4897
5424
|
|
|
4898
|
-
_defineProperty__default['default'](this, "
|
|
4899
|
-
var _this$wsConnection;
|
|
5425
|
+
_defineProperty__default['default'](this, "defaultWSTimeoutWithFallback", void 0);
|
|
4900
5426
|
|
|
4901
|
-
|
|
5427
|
+
_defineProperty__default['default'](this, "defaultWSTimeout", void 0);
|
|
5428
|
+
|
|
5429
|
+
_defineProperty__default['default'](this, "_getConnectionID", function () {
|
|
5430
|
+
var _this$wsConnection, _this$wsFallback;
|
|
5431
|
+
|
|
5432
|
+
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);
|
|
5433
|
+
});
|
|
5434
|
+
|
|
5435
|
+
_defineProperty__default['default'](this, "_hasConnectionID", function () {
|
|
5436
|
+
return Boolean(_this._getConnectionID());
|
|
4902
5437
|
});
|
|
4903
5438
|
|
|
4904
5439
|
_defineProperty__default['default'](this, "connectUser", /*#__PURE__*/function () {
|
|
@@ -4984,36 +5519,55 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4984
5519
|
return _this.tokenManager.setTokenOrProvider(userTokenOrProvider, user);
|
|
4985
5520
|
});
|
|
4986
5521
|
|
|
4987
|
-
_defineProperty__default['default'](this, "closeConnection", function (
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
_this.cleaningIntervalRef = undefined;
|
|
4991
|
-
}
|
|
5522
|
+
_defineProperty__default['default'](this, "closeConnection", /*#__PURE__*/function () {
|
|
5523
|
+
var _ref2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2(timeout) {
|
|
5524
|
+
var _this$wsConnection2, _this$wsFallback2;
|
|
4992
5525
|
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
5526
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
5527
|
+
while (1) {
|
|
5528
|
+
switch (_context2.prev = _context2.next) {
|
|
5529
|
+
case 0:
|
|
5530
|
+
if (_this.cleaningIntervalRef != null) {
|
|
5531
|
+
clearInterval(_this.cleaningIntervalRef);
|
|
5532
|
+
_this.cleaningIntervalRef = undefined;
|
|
5533
|
+
}
|
|
4996
5534
|
|
|
4997
|
-
|
|
4998
|
-
|
|
5535
|
+
_context2.next = 3;
|
|
5536
|
+
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
5537
|
|
|
5000
|
-
|
|
5001
|
-
|
|
5538
|
+
case 3:
|
|
5539
|
+
return _context2.abrupt("return", Promise.resolve());
|
|
5002
5540
|
|
|
5003
|
-
|
|
5541
|
+
case 4:
|
|
5542
|
+
case "end":
|
|
5543
|
+
return _context2.stop();
|
|
5544
|
+
}
|
|
5545
|
+
}
|
|
5546
|
+
}, _callee2);
|
|
5547
|
+
}));
|
|
5548
|
+
|
|
5549
|
+
return function (_x3) {
|
|
5550
|
+
return _ref2.apply(this, arguments);
|
|
5551
|
+
};
|
|
5552
|
+
}());
|
|
5553
|
+
|
|
5554
|
+
_defineProperty__default['default'](this, "openConnection", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
5555
|
+
var _this$wsConnection3, _this$wsFallback3;
|
|
5556
|
+
|
|
5557
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
5004
5558
|
while (1) {
|
|
5005
|
-
switch (
|
|
5559
|
+
switch (_context3.prev = _context3.next) {
|
|
5006
5560
|
case 0:
|
|
5007
5561
|
if (_this.userID) {
|
|
5008
|
-
|
|
5562
|
+
_context3.next = 2;
|
|
5009
5563
|
break;
|
|
5010
5564
|
}
|
|
5011
5565
|
|
|
5012
5566
|
throw Error('User is not set on client, use client.connectUser or client.connectAnonymousUser instead');
|
|
5013
5567
|
|
|
5014
5568
|
case 2:
|
|
5015
|
-
if (!((_this$
|
|
5016
|
-
|
|
5569
|
+
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())) {
|
|
5570
|
+
_context3.next = 5;
|
|
5017
5571
|
break;
|
|
5018
5572
|
}
|
|
5019
5573
|
|
|
@@ -5021,7 +5575,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5021
5575
|
tags: ['connection', 'client']
|
|
5022
5576
|
});
|
|
5023
5577
|
|
|
5024
|
-
return
|
|
5578
|
+
return _context3.abrupt("return", Promise.resolve());
|
|
5025
5579
|
|
|
5026
5580
|
case 5:
|
|
5027
5581
|
_this.clientID = "".concat(_this.userID, "--").concat(randomId());
|
|
@@ -5029,14 +5583,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5029
5583
|
|
|
5030
5584
|
_this._startCleaning();
|
|
5031
5585
|
|
|
5032
|
-
return
|
|
5586
|
+
return _context3.abrupt("return", _this.wsPromise);
|
|
5033
5587
|
|
|
5034
5588
|
case 9:
|
|
5035
5589
|
case "end":
|
|
5036
|
-
return
|
|
5590
|
+
return _context3.stop();
|
|
5037
5591
|
}
|
|
5038
5592
|
}
|
|
5039
|
-
},
|
|
5593
|
+
}, _callee3);
|
|
5040
5594
|
})));
|
|
5041
5595
|
|
|
5042
5596
|
_defineProperty__default['default'](this, "_setupConnection", this.openConnection);
|
|
@@ -5054,12 +5608,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5054
5608
|
});
|
|
5055
5609
|
|
|
5056
5610
|
_defineProperty__default['default'](this, "disconnectUser", /*#__PURE__*/function () {
|
|
5057
|
-
var
|
|
5611
|
+
var _ref4 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4(timeout) {
|
|
5058
5612
|
var closePromise, _i, _Object$values, _channel;
|
|
5059
5613
|
|
|
5060
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
5614
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
5061
5615
|
while (1) {
|
|
5062
|
-
switch (
|
|
5616
|
+
switch (_context4.prev = _context4.next) {
|
|
5063
5617
|
case 0:
|
|
5064
5618
|
_this.logger('info', 'client:disconnect() - Disconnecting the client', {
|
|
5065
5619
|
tags: ['connection', 'client']
|
|
@@ -5083,21 +5637,21 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5083
5637
|
|
|
5084
5638
|
_this.state = new ClientState(); // reset token manager
|
|
5085
5639
|
|
|
5086
|
-
_this.tokenManager.reset
|
|
5087
|
-
|
|
5640
|
+
setTimeout(_this.tokenManager.reset); // delay reseting to use token for disconnect calls
|
|
5641
|
+
// close the WS connection
|
|
5088
5642
|
|
|
5089
|
-
return
|
|
5643
|
+
return _context4.abrupt("return", closePromise);
|
|
5090
5644
|
|
|
5091
5645
|
case 11:
|
|
5092
5646
|
case "end":
|
|
5093
|
-
return
|
|
5647
|
+
return _context4.stop();
|
|
5094
5648
|
}
|
|
5095
5649
|
}
|
|
5096
|
-
},
|
|
5650
|
+
}, _callee4);
|
|
5097
5651
|
}));
|
|
5098
5652
|
|
|
5099
|
-
return function (
|
|
5100
|
-
return
|
|
5653
|
+
return function (_x4) {
|
|
5654
|
+
return _ref4.apply(this, arguments);
|
|
5101
5655
|
};
|
|
5102
5656
|
}());
|
|
5103
5657
|
|
|
@@ -5125,78 +5679,78 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5125
5679
|
_defineProperty__default['default'](this, "setAnonymousUser", this.connectAnonymousUser);
|
|
5126
5680
|
|
|
5127
5681
|
_defineProperty__default['default'](this, "doAxiosRequest", /*#__PURE__*/function () {
|
|
5128
|
-
var
|
|
5682
|
+
var _ref5 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(type, url, data) {
|
|
5129
5683
|
var options,
|
|
5130
5684
|
requestConfig,
|
|
5131
5685
|
response,
|
|
5132
5686
|
_requestConfig$header,
|
|
5133
|
-
|
|
5687
|
+
_args5 = arguments;
|
|
5134
5688
|
|
|
5135
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
5689
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
|
|
5136
5690
|
while (1) {
|
|
5137
|
-
switch (
|
|
5691
|
+
switch (_context5.prev = _context5.next) {
|
|
5138
5692
|
case 0:
|
|
5139
|
-
options =
|
|
5140
|
-
|
|
5693
|
+
options = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : {};
|
|
5694
|
+
_context5.next = 3;
|
|
5141
5695
|
return _this.tokenManager.tokenReady();
|
|
5142
5696
|
|
|
5143
5697
|
case 3:
|
|
5144
5698
|
requestConfig = _this._enrichAxiosOptions(options);
|
|
5145
|
-
|
|
5699
|
+
_context5.prev = 4;
|
|
5146
5700
|
|
|
5147
5701
|
_this._logApiRequest(type, url, data, requestConfig);
|
|
5148
5702
|
|
|
5149
|
-
|
|
5150
|
-
|
|
5703
|
+
_context5.t0 = type;
|
|
5704
|
+
_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;
|
|
5151
5705
|
break;
|
|
5152
5706
|
|
|
5153
5707
|
case 9:
|
|
5154
|
-
|
|
5708
|
+
_context5.next = 11;
|
|
5155
5709
|
return _this.axiosInstance.get(url, requestConfig);
|
|
5156
5710
|
|
|
5157
5711
|
case 11:
|
|
5158
|
-
response =
|
|
5159
|
-
return
|
|
5712
|
+
response = _context5.sent;
|
|
5713
|
+
return _context5.abrupt("break", 34);
|
|
5160
5714
|
|
|
5161
5715
|
case 13:
|
|
5162
|
-
|
|
5716
|
+
_context5.next = 15;
|
|
5163
5717
|
return _this.axiosInstance.delete(url, requestConfig);
|
|
5164
5718
|
|
|
5165
5719
|
case 15:
|
|
5166
|
-
response =
|
|
5167
|
-
return
|
|
5720
|
+
response = _context5.sent;
|
|
5721
|
+
return _context5.abrupt("break", 34);
|
|
5168
5722
|
|
|
5169
5723
|
case 17:
|
|
5170
|
-
|
|
5724
|
+
_context5.next = 19;
|
|
5171
5725
|
return _this.axiosInstance.post(url, data, requestConfig);
|
|
5172
5726
|
|
|
5173
5727
|
case 19:
|
|
5174
|
-
response =
|
|
5175
|
-
return
|
|
5728
|
+
response = _context5.sent;
|
|
5729
|
+
return _context5.abrupt("break", 34);
|
|
5176
5730
|
|
|
5177
5731
|
case 21:
|
|
5178
|
-
|
|
5732
|
+
_context5.next = 23;
|
|
5179
5733
|
return _this.axiosInstance.put(url, data, requestConfig);
|
|
5180
5734
|
|
|
5181
5735
|
case 23:
|
|
5182
|
-
response =
|
|
5183
|
-
return
|
|
5736
|
+
response = _context5.sent;
|
|
5737
|
+
return _context5.abrupt("break", 34);
|
|
5184
5738
|
|
|
5185
5739
|
case 25:
|
|
5186
|
-
|
|
5740
|
+
_context5.next = 27;
|
|
5187
5741
|
return _this.axiosInstance.patch(url, data, requestConfig);
|
|
5188
5742
|
|
|
5189
5743
|
case 27:
|
|
5190
|
-
response =
|
|
5191
|
-
return
|
|
5744
|
+
response = _context5.sent;
|
|
5745
|
+
return _context5.abrupt("break", 34);
|
|
5192
5746
|
|
|
5193
5747
|
case 29:
|
|
5194
|
-
|
|
5748
|
+
_context5.next = 31;
|
|
5195
5749
|
return _this.axiosInstance.options(url, requestConfig);
|
|
5196
5750
|
|
|
5197
5751
|
case 31:
|
|
5198
|
-
response =
|
|
5199
|
-
return
|
|
5752
|
+
response = _context5.sent;
|
|
5753
|
+
return _context5.abrupt("break", 34);
|
|
5200
5754
|
|
|
5201
5755
|
case 33:
|
|
5202
5756
|
throw new Error('Invalid request type');
|
|
@@ -5205,65 +5759,66 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5205
5759
|
_this._logApiResponse(type, url, response);
|
|
5206
5760
|
|
|
5207
5761
|
_this.consecutiveFailures = 0;
|
|
5208
|
-
return
|
|
5762
|
+
return _context5.abrupt("return", _this.handleResponse(response));
|
|
5209
5763
|
|
|
5210
5764
|
case 39:
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5765
|
+
_context5.prev = 39;
|
|
5766
|
+
_context5.t1 = _context5["catch"](4);
|
|
5767
|
+
_context5.t1.client_request_id = (_requestConfig$header = requestConfig.headers) === null || _requestConfig$header === void 0 ? void 0 : _requestConfig$header['x-client-request-id'];
|
|
5214
5768
|
|
|
5215
|
-
_this._logApiError(type, url,
|
|
5769
|
+
_this._logApiError(type, url, _context5.t1);
|
|
5216
5770
|
|
|
5217
5771
|
_this.consecutiveFailures += 1;
|
|
5218
5772
|
|
|
5219
|
-
if (!
|
|
5220
|
-
|
|
5773
|
+
if (!_context5.t1.response) {
|
|
5774
|
+
_context5.next = 56;
|
|
5221
5775
|
break;
|
|
5222
5776
|
}
|
|
5223
5777
|
|
|
5224
|
-
if (!(
|
|
5225
|
-
|
|
5778
|
+
if (!(_context5.t1.response.data.code === chatCodes.TOKEN_EXPIRED && !_this.tokenManager.isStatic())) {
|
|
5779
|
+
_context5.next = 53;
|
|
5226
5780
|
break;
|
|
5227
5781
|
}
|
|
5228
5782
|
|
|
5229
5783
|
if (!(_this.consecutiveFailures > 1)) {
|
|
5230
|
-
|
|
5784
|
+
_context5.next = 49;
|
|
5231
5785
|
break;
|
|
5232
5786
|
}
|
|
5233
5787
|
|
|
5234
|
-
|
|
5788
|
+
_context5.next = 49;
|
|
5235
5789
|
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5236
5790
|
|
|
5237
5791
|
case 49:
|
|
5238
5792
|
_this.tokenManager.loadToken();
|
|
5239
5793
|
|
|
5240
|
-
|
|
5794
|
+
_context5.next = 52;
|
|
5241
5795
|
return _this.doAxiosRequest(type, url, data, options);
|
|
5242
5796
|
|
|
5243
5797
|
case 52:
|
|
5244
|
-
return
|
|
5798
|
+
return _context5.abrupt("return", _context5.sent);
|
|
5245
5799
|
|
|
5246
5800
|
case 53:
|
|
5247
|
-
return
|
|
5801
|
+
return _context5.abrupt("return", _this.handleResponse(_context5.t1.response));
|
|
5248
5802
|
|
|
5249
5803
|
case 56:
|
|
5250
|
-
throw
|
|
5804
|
+
throw _context5.t1;
|
|
5251
5805
|
|
|
5252
5806
|
case 57:
|
|
5253
5807
|
case "end":
|
|
5254
|
-
return
|
|
5808
|
+
return _context5.stop();
|
|
5255
5809
|
}
|
|
5256
5810
|
}
|
|
5257
|
-
},
|
|
5811
|
+
}, _callee5, null, [[4, 39]]);
|
|
5258
5812
|
}));
|
|
5259
5813
|
|
|
5260
|
-
return function (
|
|
5261
|
-
return
|
|
5814
|
+
return function (_x5, _x6, _x7) {
|
|
5815
|
+
return _ref5.apply(this, arguments);
|
|
5262
5816
|
};
|
|
5263
5817
|
}());
|
|
5264
5818
|
|
|
5265
5819
|
_defineProperty__default['default'](this, "dispatchEvent", function (event) {
|
|
5266
|
-
// client event handlers
|
|
5820
|
+
if (!event.received_at) event.received_at = new Date(); // client event handlers
|
|
5821
|
+
|
|
5267
5822
|
var postListenerCallbacks = _this._handleClientEvent(event); // channel event handlers
|
|
5268
5823
|
|
|
5269
5824
|
|
|
@@ -5289,7 +5844,6 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5289
5844
|
// dispatch the event to the channel listeners
|
|
5290
5845
|
var jsonString = messageEvent.data;
|
|
5291
5846
|
var event = JSON.parse(jsonString);
|
|
5292
|
-
event.received_at = new Date();
|
|
5293
5847
|
|
|
5294
5848
|
_this.dispatchEvent(event);
|
|
5295
5849
|
});
|
|
@@ -5410,22 +5964,20 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5410
5964
|
}
|
|
5411
5965
|
});
|
|
5412
5966
|
|
|
5413
|
-
_defineProperty__default['default'](this, "recoverState", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
5414
|
-
var _this$wsConnection3;
|
|
5415
|
-
|
|
5967
|
+
_defineProperty__default['default'](this, "recoverState", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee6() {
|
|
5416
5968
|
var cids;
|
|
5417
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
5969
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee6$(_context6) {
|
|
5418
5970
|
while (1) {
|
|
5419
|
-
switch (
|
|
5971
|
+
switch (_context6.prev = _context6.next) {
|
|
5420
5972
|
case 0:
|
|
5421
|
-
_this.logger('info', "client:recoverState() - Start of recoverState with connectionID ".concat(
|
|
5973
|
+
_this.logger('info', "client:recoverState() - Start of recoverState with connectionID ".concat(_this._getConnectionID()), {
|
|
5422
5974
|
tags: ['connection']
|
|
5423
5975
|
});
|
|
5424
5976
|
|
|
5425
5977
|
cids = Object.keys(_this.activeChannels);
|
|
5426
5978
|
|
|
5427
5979
|
if (!(cids.length && _this.recoverStateOnReconnect)) {
|
|
5428
|
-
|
|
5980
|
+
_context6.next = 10;
|
|
5429
5981
|
break;
|
|
5430
5982
|
}
|
|
5431
5983
|
|
|
@@ -5433,7 +5985,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5433
5985
|
tags: ['connection', 'client']
|
|
5434
5986
|
});
|
|
5435
5987
|
|
|
5436
|
-
|
|
5988
|
+
_context6.next = 6;
|
|
5437
5989
|
return _this.queryChannels({
|
|
5438
5990
|
cid: {
|
|
5439
5991
|
$in: cids
|
|
@@ -5453,7 +6005,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5453
6005
|
type: 'connection.recovered'
|
|
5454
6006
|
});
|
|
5455
6007
|
|
|
5456
|
-
|
|
6008
|
+
_context6.next = 11;
|
|
5457
6009
|
break;
|
|
5458
6010
|
|
|
5459
6011
|
case 10:
|
|
@@ -5467,10 +6019,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5467
6019
|
|
|
5468
6020
|
case 13:
|
|
5469
6021
|
case "end":
|
|
5470
|
-
return
|
|
6022
|
+
return _context6.stop();
|
|
5471
6023
|
}
|
|
5472
6024
|
}
|
|
5473
|
-
},
|
|
6025
|
+
}, _callee6);
|
|
5474
6026
|
})));
|
|
5475
6027
|
|
|
5476
6028
|
_defineProperty__default['default'](this, "getChannelByMembers", function (channelType, custom) {
|
|
@@ -5550,66 +6102,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5550
6102
|
return !!_this.secret;
|
|
5551
6103
|
});
|
|
5552
6104
|
|
|
5553
|
-
_defineProperty__default['default'](this, "
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
i = 0;
|
|
5562
|
-
|
|
5563
|
-
case 2:
|
|
5564
|
-
if (!(i < maxAttempts)) {
|
|
5565
|
-
_context6.next = 18;
|
|
5566
|
-
break;
|
|
5567
|
-
}
|
|
5568
|
-
|
|
5569
|
-
_context6.prev = 3;
|
|
5570
|
-
_context6.next = 6;
|
|
5571
|
-
return _this.axiosInstance.post("https://chat-insights.getstream.io/insights/".concat(insightType), insights);
|
|
5572
|
-
|
|
5573
|
-
case 6:
|
|
5574
|
-
_context6.next = 14;
|
|
5575
|
-
break;
|
|
5576
|
-
|
|
5577
|
-
case 8:
|
|
5578
|
-
_context6.prev = 8;
|
|
5579
|
-
_context6.t0 = _context6["catch"](3);
|
|
5580
|
-
|
|
5581
|
-
_this.logger('warn', "failed to send insights event ".concat(insightType), {
|
|
5582
|
-
tags: ['insights', 'connection'],
|
|
5583
|
-
error: _context6.t0,
|
|
5584
|
-
insights: insights
|
|
5585
|
-
});
|
|
5586
|
-
|
|
5587
|
-
_context6.next = 13;
|
|
5588
|
-
return sleep((i + 1) * 3000);
|
|
5589
|
-
|
|
5590
|
-
case 13:
|
|
5591
|
-
return _context6.abrupt("continue", 15);
|
|
5592
|
-
|
|
5593
|
-
case 14:
|
|
5594
|
-
return _context6.abrupt("break", 18);
|
|
5595
|
-
|
|
5596
|
-
case 15:
|
|
5597
|
-
i++;
|
|
5598
|
-
_context6.next = 2;
|
|
5599
|
-
break;
|
|
5600
|
-
|
|
5601
|
-
case 18:
|
|
5602
|
-
case "end":
|
|
5603
|
-
return _context6.stop();
|
|
5604
|
-
}
|
|
5605
|
-
}
|
|
5606
|
-
}, _callee6, null, [[3, 8]]);
|
|
5607
|
-
}));
|
|
5608
|
-
|
|
5609
|
-
return function (_x7, _x8) {
|
|
5610
|
-
return _ref6.apply(this, arguments);
|
|
5611
|
-
};
|
|
5612
|
-
}());
|
|
6105
|
+
_defineProperty__default['default'](this, "_buildWSPayload", function (client_request_id) {
|
|
6106
|
+
return JSON.stringify({
|
|
6107
|
+
user_id: _this.userID,
|
|
6108
|
+
user_details: _this._user,
|
|
6109
|
+
device: _this.options.device,
|
|
6110
|
+
client_request_id: client_request_id
|
|
6111
|
+
});
|
|
6112
|
+
});
|
|
5613
6113
|
|
|
5614
6114
|
// set the key
|
|
5615
6115
|
this.key = _key;
|
|
@@ -5667,6 +6167,8 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5667
6167
|
this.tokenManager = new TokenManager(this.secret);
|
|
5668
6168
|
this.consecutiveFailures = 0;
|
|
5669
6169
|
this.insightMetrics = new InsightMetrics();
|
|
6170
|
+
this.defaultWSTimeoutWithFallback = 6000;
|
|
6171
|
+
this.defaultWSTimeout = 15000;
|
|
5670
6172
|
/**
|
|
5671
6173
|
* logger function should accept 3 parameters:
|
|
5672
6174
|
* @param logLevel string
|
|
@@ -5840,7 +6342,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5840
6342
|
}, _callee7, this);
|
|
5841
6343
|
}));
|
|
5842
6344
|
|
|
5843
|
-
function updateAppSettings(
|
|
6345
|
+
function updateAppSettings(_x8) {
|
|
5844
6346
|
return _updateAppSettings.apply(this, arguments);
|
|
5845
6347
|
}
|
|
5846
6348
|
|
|
@@ -5874,7 +6376,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5874
6376
|
}, _callee8, this);
|
|
5875
6377
|
}));
|
|
5876
6378
|
|
|
5877
|
-
function revokeTokens(
|
|
6379
|
+
function revokeTokens(_x9) {
|
|
5878
6380
|
return _revokeTokens.apply(this, arguments);
|
|
5879
6381
|
}
|
|
5880
6382
|
|
|
@@ -5906,7 +6408,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5906
6408
|
}, _callee9, this);
|
|
5907
6409
|
}));
|
|
5908
6410
|
|
|
5909
|
-
function revokeUserToken(
|
|
6411
|
+
function revokeUserToken(_x10, _x11) {
|
|
5910
6412
|
return _revokeUserToken.apply(this, arguments);
|
|
5911
6413
|
}
|
|
5912
6414
|
|
|
@@ -5965,7 +6467,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5965
6467
|
}, _callee10, this);
|
|
5966
6468
|
}));
|
|
5967
6469
|
|
|
5968
|
-
function revokeUsersToken(
|
|
6470
|
+
function revokeUsersToken(_x12, _x13) {
|
|
5969
6471
|
return _revokeUsersToken.apply(this, arguments);
|
|
5970
6472
|
}
|
|
5971
6473
|
|
|
@@ -6057,7 +6559,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6057
6559
|
}, _callee12, this);
|
|
6058
6560
|
}));
|
|
6059
6561
|
|
|
6060
|
-
function testPushSettings(
|
|
6562
|
+
function testPushSettings(_x14) {
|
|
6061
6563
|
return _testPushSettings.apply(this, arguments);
|
|
6062
6564
|
}
|
|
6063
6565
|
|
|
@@ -6166,7 +6668,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6166
6668
|
}, _callee14, this, [[1, 7]]);
|
|
6167
6669
|
}));
|
|
6168
6670
|
|
|
6169
|
-
function setGuestUser(
|
|
6671
|
+
function setGuestUser(_x15) {
|
|
6170
6672
|
return _setGuestUser.apply(this, arguments);
|
|
6171
6673
|
}
|
|
6172
6674
|
|
|
@@ -6477,72 +6979,102 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6477
6979
|
*/
|
|
6478
6980
|
function () {
|
|
6479
6981
|
var _connect = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee15() {
|
|
6480
|
-
var client;
|
|
6481
6982
|
return _regeneratorRuntime__default['default'].wrap(function _callee15$(_context15) {
|
|
6482
6983
|
while (1) {
|
|
6483
6984
|
switch (_context15.prev = _context15.next) {
|
|
6484
6985
|
case 0:
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
if (!(client.userID == null || this._user == null)) {
|
|
6489
|
-
_context15.next = 4;
|
|
6986
|
+
if (!(!this.userID || !this._user)) {
|
|
6987
|
+
_context15.next = 2;
|
|
6490
6988
|
break;
|
|
6491
6989
|
}
|
|
6492
6990
|
|
|
6493
6991
|
throw Error('Call connectUser or connectAnonymousUser before starting the connection');
|
|
6494
6992
|
|
|
6495
|
-
case
|
|
6496
|
-
if (
|
|
6497
|
-
_context15.next =
|
|
6993
|
+
case 2:
|
|
6994
|
+
if (this.wsBaseURL) {
|
|
6995
|
+
_context15.next = 4;
|
|
6498
6996
|
break;
|
|
6499
6997
|
}
|
|
6500
6998
|
|
|
6501
6999
|
throw Error('Websocket base url not set');
|
|
6502
7000
|
|
|
6503
|
-
case
|
|
6504
|
-
if (
|
|
6505
|
-
_context15.next =
|
|
7001
|
+
case 4:
|
|
7002
|
+
if (this.clientID) {
|
|
7003
|
+
_context15.next = 6;
|
|
6506
7004
|
break;
|
|
6507
7005
|
}
|
|
6508
7006
|
|
|
6509
7007
|
throw Error('clientID is not set');
|
|
6510
7008
|
|
|
6511
|
-
case
|
|
7009
|
+
case 6:
|
|
6512
7010
|
if (!this.wsConnection && (this.options.warmUp || this.options.enableInsights)) {
|
|
6513
|
-
this.
|
|
7011
|
+
this._sayHi();
|
|
6514
7012
|
} // The StableWSConnection handles all the reconnection logic.
|
|
6515
7013
|
|
|
6516
7014
|
|
|
6517
7015
|
this.wsConnection = new StableWSConnection({
|
|
6518
|
-
|
|
6519
|
-
clientID: client.clientID,
|
|
6520
|
-
userID: client.userID,
|
|
6521
|
-
tokenManager: client.tokenManager,
|
|
6522
|
-
user: this._user,
|
|
6523
|
-
authType: this.getAuthType(),
|
|
6524
|
-
userAgent: this.getUserAgent(),
|
|
6525
|
-
apiKey: this.key,
|
|
6526
|
-
recoverCallback: this.recoverState,
|
|
6527
|
-
messageCallback: this.handleEvent,
|
|
6528
|
-
eventCallback: this.dispatchEvent,
|
|
6529
|
-
logger: this.logger,
|
|
6530
|
-
device: this.options.device,
|
|
6531
|
-
postInsights: this.options.enableInsights ? this.postInsights : undefined,
|
|
6532
|
-
insightMetrics: this.insightMetrics
|
|
7016
|
+
client: this
|
|
6533
7017
|
});
|
|
7018
|
+
_context15.prev = 8;
|
|
7019
|
+
|
|
7020
|
+
if (!this.wsFallback) {
|
|
7021
|
+
_context15.next = 13;
|
|
7022
|
+
break;
|
|
7023
|
+
}
|
|
7024
|
+
|
|
6534
7025
|
_context15.next = 12;
|
|
6535
|
-
return this.
|
|
7026
|
+
return this.wsFallback.connect();
|
|
6536
7027
|
|
|
6537
7028
|
case 12:
|
|
6538
7029
|
return _context15.abrupt("return", _context15.sent);
|
|
6539
7030
|
|
|
6540
7031
|
case 13:
|
|
7032
|
+
_context15.next = 15;
|
|
7033
|
+
return this.wsConnection.connect(this.options.enableWSFallback ? this.defaultWSTimeoutWithFallback : this.defaultWSTimeout);
|
|
7034
|
+
|
|
7035
|
+
case 15:
|
|
7036
|
+
return _context15.abrupt("return", _context15.sent);
|
|
7037
|
+
|
|
7038
|
+
case 18:
|
|
7039
|
+
_context15.prev = 18;
|
|
7040
|
+
_context15.t0 = _context15["catch"](8);
|
|
7041
|
+
|
|
7042
|
+
if (!(this.options.enableWSFallback && isWSFailure(_context15.t0) && isOnline())) {
|
|
7043
|
+
_context15.next = 29;
|
|
7044
|
+
break;
|
|
7045
|
+
}
|
|
7046
|
+
|
|
7047
|
+
this.logger('info', 'client:connect() - WS failed, fallback to longpoll', {
|
|
7048
|
+
tags: ['connection', 'client']
|
|
7049
|
+
}); // @ts-expect-error
|
|
7050
|
+
|
|
7051
|
+
this.dispatchEvent({
|
|
7052
|
+
type: 'transport.changed',
|
|
7053
|
+
mode: 'longpoll'
|
|
7054
|
+
});
|
|
7055
|
+
|
|
7056
|
+
this.wsConnection._destroyCurrentWSConnection();
|
|
7057
|
+
|
|
7058
|
+
this.wsConnection.disconnect().then(); // close WS so no retry
|
|
7059
|
+
|
|
7060
|
+
this.wsFallback = new WSConnectionFallback({
|
|
7061
|
+
client: this
|
|
7062
|
+
});
|
|
7063
|
+
_context15.next = 28;
|
|
7064
|
+
return this.wsFallback.connect();
|
|
7065
|
+
|
|
7066
|
+
case 28:
|
|
7067
|
+
return _context15.abrupt("return", _context15.sent);
|
|
7068
|
+
|
|
7069
|
+
case 29:
|
|
7070
|
+
throw _context15.t0;
|
|
7071
|
+
|
|
7072
|
+
case 30:
|
|
6541
7073
|
case "end":
|
|
6542
7074
|
return _context15.stop();
|
|
6543
7075
|
}
|
|
6544
7076
|
}
|
|
6545
|
-
}, _callee15, this);
|
|
7077
|
+
}, _callee15, this, [[8, 18]]);
|
|
6546
7078
|
}));
|
|
6547
7079
|
|
|
6548
7080
|
function connect() {
|
|
@@ -6551,9 +7083,15 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6551
7083
|
|
|
6552
7084
|
return connect;
|
|
6553
7085
|
}()
|
|
7086
|
+
/**
|
|
7087
|
+
* Check the connectivity with server for warmup purpose.
|
|
7088
|
+
*
|
|
7089
|
+
* @private
|
|
7090
|
+
*/
|
|
7091
|
+
|
|
6554
7092
|
}, {
|
|
6555
|
-
key: "
|
|
6556
|
-
value: function
|
|
7093
|
+
key: "_sayHi",
|
|
7094
|
+
value: function _sayHi() {
|
|
6557
7095
|
var _this4 = this;
|
|
6558
7096
|
|
|
6559
7097
|
var client_request_id = randomId();
|
|
@@ -6563,11 +7101,13 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6563
7101
|
}
|
|
6564
7102
|
};
|
|
6565
7103
|
this.doAxiosRequest('get', this.baseURL + '/hi', null, opts).catch(function (e) {
|
|
6566
|
-
_this4.
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
7104
|
+
if (_this4.options.enableInsights) {
|
|
7105
|
+
postInsights('http_hi_failed', {
|
|
7106
|
+
api_key: _this4.key,
|
|
7107
|
+
err: e,
|
|
7108
|
+
client_request_id: client_request_id
|
|
7109
|
+
});
|
|
7110
|
+
}
|
|
6571
7111
|
});
|
|
6572
7112
|
}
|
|
6573
7113
|
/**
|
|
@@ -6630,7 +7170,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6630
7170
|
}, _callee16, this);
|
|
6631
7171
|
}));
|
|
6632
7172
|
|
|
6633
|
-
function queryUsers(
|
|
7173
|
+
function queryUsers(_x16) {
|
|
6634
7174
|
return _queryUsers.apply(this, arguments);
|
|
6635
7175
|
}
|
|
6636
7176
|
|
|
@@ -6849,7 +7389,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6849
7389
|
}, _callee19, this);
|
|
6850
7390
|
}));
|
|
6851
7391
|
|
|
6852
|
-
function queryChannels(
|
|
7392
|
+
function queryChannels(_x17) {
|
|
6853
7393
|
return _queryChannels.apply(this, arguments);
|
|
6854
7394
|
}
|
|
6855
7395
|
|
|
@@ -6935,7 +7475,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6935
7475
|
}, _callee20, this);
|
|
6936
7476
|
}));
|
|
6937
7477
|
|
|
6938
|
-
function search(
|
|
7478
|
+
function search(_x18, _x19) {
|
|
6939
7479
|
return _search.apply(this, arguments);
|
|
6940
7480
|
}
|
|
6941
7481
|
|
|
@@ -6953,7 +7493,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6953
7493
|
}, {
|
|
6954
7494
|
key: "setLocalDevice",
|
|
6955
7495
|
value: function setLocalDevice(device) {
|
|
6956
|
-
if (this.wsConnection) {
|
|
7496
|
+
if (this.wsConnection || this.wsFallback) {
|
|
6957
7497
|
throw new Error('you can only set device before opening a websocket connection');
|
|
6958
7498
|
}
|
|
6959
7499
|
|
|
@@ -6995,7 +7535,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6995
7535
|
}, _callee21, this);
|
|
6996
7536
|
}));
|
|
6997
7537
|
|
|
6998
|
-
function addDevice(_x21, _x22
|
|
7538
|
+
function addDevice(_x20, _x21, _x22) {
|
|
6999
7539
|
return _addDevice.apply(this, arguments);
|
|
7000
7540
|
}
|
|
7001
7541
|
|
|
@@ -7033,7 +7573,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7033
7573
|
}, _callee22, this);
|
|
7034
7574
|
}));
|
|
7035
7575
|
|
|
7036
|
-
function getDevices(
|
|
7576
|
+
function getDevices(_x23) {
|
|
7037
7577
|
return _getDevices.apply(this, arguments);
|
|
7038
7578
|
}
|
|
7039
7579
|
|
|
@@ -7073,7 +7613,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7073
7613
|
}, _callee23, this);
|
|
7074
7614
|
}));
|
|
7075
7615
|
|
|
7076
|
-
function removeDevice(
|
|
7616
|
+
function removeDevice(_x24, _x25) {
|
|
7077
7617
|
return _removeDevice.apply(this, arguments);
|
|
7078
7618
|
}
|
|
7079
7619
|
|
|
@@ -7114,7 +7654,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7114
7654
|
}, _callee24, this);
|
|
7115
7655
|
}));
|
|
7116
7656
|
|
|
7117
|
-
function getRateLimits(
|
|
7657
|
+
function getRateLimits(_x26) {
|
|
7118
7658
|
return _getRateLimits.apply(this, arguments);
|
|
7119
7659
|
}
|
|
7120
7660
|
|
|
@@ -7215,7 +7755,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7215
7755
|
}, _callee25, this);
|
|
7216
7756
|
}));
|
|
7217
7757
|
|
|
7218
|
-
function partialUpdateUser(
|
|
7758
|
+
function partialUpdateUser(_x27) {
|
|
7219
7759
|
return _partialUpdateUser.apply(this, arguments);
|
|
7220
7760
|
}
|
|
7221
7761
|
|
|
@@ -7301,7 +7841,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7301
7841
|
}, _callee26, this, [[2, 13, 16, 19]]);
|
|
7302
7842
|
}));
|
|
7303
7843
|
|
|
7304
|
-
function upsertUsers(
|
|
7844
|
+
function upsertUsers(_x28) {
|
|
7305
7845
|
return _upsertUsers.apply(this, arguments);
|
|
7306
7846
|
}
|
|
7307
7847
|
|
|
@@ -7414,7 +7954,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7414
7954
|
}, _callee27, this, [[1, 11, 14, 17]]);
|
|
7415
7955
|
}));
|
|
7416
7956
|
|
|
7417
|
-
function partialUpdateUsers(
|
|
7957
|
+
function partialUpdateUsers(_x29) {
|
|
7418
7958
|
return _partialUpdateUsers.apply(this, arguments);
|
|
7419
7959
|
}
|
|
7420
7960
|
|
|
@@ -7442,7 +7982,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7442
7982
|
}, _callee28, this);
|
|
7443
7983
|
}));
|
|
7444
7984
|
|
|
7445
|
-
function deleteUser(
|
|
7985
|
+
function deleteUser(_x30, _x31) {
|
|
7446
7986
|
return _deleteUser.apply(this, arguments);
|
|
7447
7987
|
}
|
|
7448
7988
|
|
|
@@ -7470,7 +8010,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7470
8010
|
}, _callee29, this);
|
|
7471
8011
|
}));
|
|
7472
8012
|
|
|
7473
|
-
function reactivateUser(
|
|
8013
|
+
function reactivateUser(_x32, _x33) {
|
|
7474
8014
|
return _reactivateUser.apply(this, arguments);
|
|
7475
8015
|
}
|
|
7476
8016
|
|
|
@@ -7498,7 +8038,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7498
8038
|
}, _callee30, this);
|
|
7499
8039
|
}));
|
|
7500
8040
|
|
|
7501
|
-
function deactivateUser(
|
|
8041
|
+
function deactivateUser(_x34, _x35) {
|
|
7502
8042
|
return _deactivateUser.apply(this, arguments);
|
|
7503
8043
|
}
|
|
7504
8044
|
|
|
@@ -7526,7 +8066,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7526
8066
|
}, _callee31, this);
|
|
7527
8067
|
}));
|
|
7528
8068
|
|
|
7529
|
-
function exportUser(
|
|
8069
|
+
function exportUser(_x36, _x37) {
|
|
7530
8070
|
return _exportUser.apply(this, arguments);
|
|
7531
8071
|
}
|
|
7532
8072
|
|
|
@@ -7547,27 +8087,15 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7547
8087
|
while (1) {
|
|
7548
8088
|
switch (_context32.prev = _context32.next) {
|
|
7549
8089
|
case 0:
|
|
7550
|
-
|
|
7551
|
-
options.banned_by_id = options.user_id;
|
|
7552
|
-
delete options.user_id;
|
|
7553
|
-
console.warn("banUser: 'user_id' is deprecated, please consider switching to 'banned_by_id'");
|
|
7554
|
-
}
|
|
7555
|
-
|
|
7556
|
-
if ((options === null || options === void 0 ? void 0 : options.user) !== undefined) {
|
|
7557
|
-
options.banned_by = options.user;
|
|
7558
|
-
delete options.user;
|
|
7559
|
-
console.warn("banUser: 'user' is deprecated, please consider switching to 'banned_by'");
|
|
7560
|
-
}
|
|
7561
|
-
|
|
7562
|
-
_context32.next = 4;
|
|
8090
|
+
_context32.next = 2;
|
|
7563
8091
|
return this.post(this.baseURL + '/moderation/ban', _objectSpread({
|
|
7564
8092
|
target_user_id: targetUserID
|
|
7565
8093
|
}, options));
|
|
7566
8094
|
|
|
7567
|
-
case
|
|
8095
|
+
case 2:
|
|
7568
8096
|
return _context32.abrupt("return", _context32.sent);
|
|
7569
8097
|
|
|
7570
|
-
case
|
|
8098
|
+
case 3:
|
|
7571
8099
|
case "end":
|
|
7572
8100
|
return _context32.stop();
|
|
7573
8101
|
}
|
|
@@ -7575,7 +8103,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7575
8103
|
}, _callee32, this);
|
|
7576
8104
|
}));
|
|
7577
8105
|
|
|
7578
|
-
function banUser(
|
|
8106
|
+
function banUser(_x38, _x39) {
|
|
7579
8107
|
return _banUser.apply(this, arguments);
|
|
7580
8108
|
}
|
|
7581
8109
|
|
|
@@ -7612,7 +8140,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7612
8140
|
}, _callee33, this);
|
|
7613
8141
|
}));
|
|
7614
8142
|
|
|
7615
|
-
function unbanUser(
|
|
8143
|
+
function unbanUser(_x40, _x41) {
|
|
7616
8144
|
return _unbanUser.apply(this, arguments);
|
|
7617
8145
|
}
|
|
7618
8146
|
|
|
@@ -7649,7 +8177,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7649
8177
|
}, _callee34, this);
|
|
7650
8178
|
}));
|
|
7651
8179
|
|
|
7652
|
-
function shadowBan(
|
|
8180
|
+
function shadowBan(_x42, _x43) {
|
|
7653
8181
|
return _shadowBan.apply(this, arguments);
|
|
7654
8182
|
}
|
|
7655
8183
|
|
|
@@ -7686,7 +8214,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7686
8214
|
}, _callee35, this);
|
|
7687
8215
|
}));
|
|
7688
8216
|
|
|
7689
|
-
function removeShadowBan(
|
|
8217
|
+
function removeShadowBan(_x44, _x45) {
|
|
7690
8218
|
return _removeShadowBan.apply(this, arguments);
|
|
7691
8219
|
}
|
|
7692
8220
|
|
|
@@ -7729,7 +8257,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7729
8257
|
}, _callee36, this);
|
|
7730
8258
|
}));
|
|
7731
8259
|
|
|
7732
|
-
function muteUser(
|
|
8260
|
+
function muteUser(_x46, _x47) {
|
|
7733
8261
|
return _muteUser.apply(this, arguments);
|
|
7734
8262
|
}
|
|
7735
8263
|
|
|
@@ -7768,7 +8296,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7768
8296
|
}, _callee37, this);
|
|
7769
8297
|
}));
|
|
7770
8298
|
|
|
7771
|
-
function unmuteUser(
|
|
8299
|
+
function unmuteUser(_x48, _x49) {
|
|
7772
8300
|
return _unmuteUser.apply(this, arguments);
|
|
7773
8301
|
}
|
|
7774
8302
|
|
|
@@ -7827,7 +8355,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7827
8355
|
}, _callee38, this);
|
|
7828
8356
|
}));
|
|
7829
8357
|
|
|
7830
|
-
function flagMessage(
|
|
8358
|
+
function flagMessage(_x50) {
|
|
7831
8359
|
return _flagMessage.apply(this, arguments);
|
|
7832
8360
|
}
|
|
7833
8361
|
|
|
@@ -7867,7 +8395,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7867
8395
|
}, _callee39, this);
|
|
7868
8396
|
}));
|
|
7869
8397
|
|
|
7870
|
-
function flagUser(
|
|
8398
|
+
function flagUser(_x51) {
|
|
7871
8399
|
return _flagUser.apply(this, arguments);
|
|
7872
8400
|
}
|
|
7873
8401
|
|
|
@@ -7907,7 +8435,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7907
8435
|
}, _callee40, this);
|
|
7908
8436
|
}));
|
|
7909
8437
|
|
|
7910
|
-
function unflagMessage(
|
|
8438
|
+
function unflagMessage(_x52) {
|
|
7911
8439
|
return _unflagMessage.apply(this, arguments);
|
|
7912
8440
|
}
|
|
7913
8441
|
|
|
@@ -7947,7 +8475,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7947
8475
|
}, _callee41, this);
|
|
7948
8476
|
}));
|
|
7949
8477
|
|
|
7950
|
-
function unflagUser(
|
|
8478
|
+
function unflagUser(_x53) {
|
|
7951
8479
|
return _unflagUser.apply(this, arguments);
|
|
7952
8480
|
}
|
|
7953
8481
|
|
|
@@ -8086,7 +8614,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8086
8614
|
}, _callee43, this);
|
|
8087
8615
|
}));
|
|
8088
8616
|
|
|
8089
|
-
function translateMessage(
|
|
8617
|
+
function translateMessage(_x54, _x55) {
|
|
8090
8618
|
return _translateMessage.apply(this, arguments);
|
|
8091
8619
|
}
|
|
8092
8620
|
|
|
@@ -8202,7 +8730,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8202
8730
|
case 2:
|
|
8203
8731
|
clonedMessage = _extends__default['default']({}, message);
|
|
8204
8732
|
delete clonedMessage.id;
|
|
8205
|
-
reservedMessageFields = ['command', 'created_at', 'html', 'latest_reactions', 'own_reactions', 'reaction_counts', 'reply_count', 'type', 'updated_at', 'user', '__html'];
|
|
8733
|
+
reservedMessageFields = ['command', 'created_at', 'html', 'latest_reactions', 'own_reactions', 'quoted_message', 'reaction_counts', 'reply_count', 'type', 'updated_at', 'user', '__html'];
|
|
8206
8734
|
reservedMessageFields.forEach(function (item) {
|
|
8207
8735
|
if (clonedMessage[item] != null) {
|
|
8208
8736
|
delete clonedMessage[item];
|
|
@@ -8246,7 +8774,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8246
8774
|
}, _callee44, this);
|
|
8247
8775
|
}));
|
|
8248
8776
|
|
|
8249
|
-
function updateMessage(_x57, _x58
|
|
8777
|
+
function updateMessage(_x56, _x57, _x58) {
|
|
8250
8778
|
return _updateMessage.apply(this, arguments);
|
|
8251
8779
|
}
|
|
8252
8780
|
|
|
@@ -8307,7 +8835,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8307
8835
|
}, _callee45, this);
|
|
8308
8836
|
}));
|
|
8309
8837
|
|
|
8310
|
-
function partialUpdateMessage(_x60, _x61, _x62
|
|
8838
|
+
function partialUpdateMessage(_x59, _x60, _x61, _x62) {
|
|
8311
8839
|
return _partialUpdateMessage.apply(this, arguments);
|
|
8312
8840
|
}
|
|
8313
8841
|
|
|
@@ -8344,7 +8872,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8344
8872
|
}, _callee46, this);
|
|
8345
8873
|
}));
|
|
8346
8874
|
|
|
8347
|
-
function deleteMessage(
|
|
8875
|
+
function deleteMessage(_x63, _x64) {
|
|
8348
8876
|
return _deleteMessage.apply(this, arguments);
|
|
8349
8877
|
}
|
|
8350
8878
|
|
|
@@ -8372,7 +8900,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8372
8900
|
}, _callee47, this);
|
|
8373
8901
|
}));
|
|
8374
8902
|
|
|
8375
|
-
function getMessage(
|
|
8903
|
+
function getMessage(_x65) {
|
|
8376
8904
|
return _getMessage.apply(this, arguments);
|
|
8377
8905
|
}
|
|
8378
8906
|
|
|
@@ -8381,7 +8909,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8381
8909
|
}, {
|
|
8382
8910
|
key: "getUserAgent",
|
|
8383
8911
|
value: function getUserAgent() {
|
|
8384
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "
|
|
8912
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "5.0.1");
|
|
8385
8913
|
}
|
|
8386
8914
|
}, {
|
|
8387
8915
|
key: "setUserAgent",
|
|
@@ -8395,7 +8923,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8395
8923
|
}, {
|
|
8396
8924
|
key: "_enrichAxiosOptions",
|
|
8397
8925
|
value: function _enrichAxiosOptions() {
|
|
8398
|
-
var _options$headers
|
|
8926
|
+
var _options$headers;
|
|
8399
8927
|
|
|
8400
8928
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
8401
8929
|
params: {},
|
|
@@ -8405,21 +8933,23 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8405
8933
|
|
|
8406
8934
|
var token = this._getToken();
|
|
8407
8935
|
|
|
8936
|
+
var authorization = token ? {
|
|
8937
|
+
Authorization: token
|
|
8938
|
+
} : undefined;
|
|
8939
|
+
|
|
8408
8940
|
if (!((_options$headers = options.headers) !== null && _options$headers !== void 0 && _options$headers['x-client-request-id'])) {
|
|
8409
|
-
options.headers = {
|
|
8941
|
+
options.headers = _objectSpread(_objectSpread({}, options.headers), {}, {
|
|
8410
8942
|
'x-client-request-id': randomId()
|
|
8411
|
-
};
|
|
8943
|
+
});
|
|
8412
8944
|
}
|
|
8413
8945
|
|
|
8414
8946
|
return _objectSpread({
|
|
8415
|
-
params: _objectSpread(
|
|
8416
|
-
user_id: this.userID
|
|
8417
|
-
|
|
8418
|
-
api_key: this.key
|
|
8419
|
-
|
|
8420
|
-
}),
|
|
8421
|
-
headers: _objectSpread({
|
|
8422
|
-
Authorization: token,
|
|
8947
|
+
params: _objectSpread({
|
|
8948
|
+
user_id: this.userID,
|
|
8949
|
+
connection_id: this._getConnectionID(),
|
|
8950
|
+
api_key: this.key
|
|
8951
|
+
}, options.params),
|
|
8952
|
+
headers: _objectSpread(_objectSpread({}, authorization), {}, {
|
|
8423
8953
|
'stream-auth-type': this.getAuthType(),
|
|
8424
8954
|
'X-Stream-Client': this.getUserAgent()
|
|
8425
8955
|
}, options.headers)
|
|
@@ -8449,6 +8979,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8449
8979
|
}
|
|
8450
8980
|
}, 500);
|
|
8451
8981
|
}
|
|
8982
|
+
/**
|
|
8983
|
+
* encode ws url payload
|
|
8984
|
+
* @private
|
|
8985
|
+
* @returns json string
|
|
8986
|
+
*/
|
|
8987
|
+
|
|
8452
8988
|
}, {
|
|
8453
8989
|
key: "verifyWebhook",
|
|
8454
8990
|
value: function verifyWebhook(requestBody, xSignature) {
|
|
@@ -8589,7 +9125,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8589
9125
|
}, _callee48, this);
|
|
8590
9126
|
}));
|
|
8591
9127
|
|
|
8592
|
-
function sendUserCustomEvent(
|
|
9128
|
+
function sendUserCustomEvent(_x66, _x67) {
|
|
8593
9129
|
return _sendUserCustomEvent.apply(this, arguments);
|
|
8594
9130
|
}
|
|
8595
9131
|
|
|
@@ -8677,7 +9213,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8677
9213
|
}, _callee49, this);
|
|
8678
9214
|
}));
|
|
8679
9215
|
|
|
8680
|
-
function createSegment(
|
|
9216
|
+
function createSegment(_x68) {
|
|
8681
9217
|
return _createSegment.apply(this, arguments);
|
|
8682
9218
|
}
|
|
8683
9219
|
|
|
@@ -8717,7 +9253,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8717
9253
|
}, _callee50, this);
|
|
8718
9254
|
}));
|
|
8719
9255
|
|
|
8720
|
-
function getSegment(
|
|
9256
|
+
function getSegment(_x69) {
|
|
8721
9257
|
return _getSegment.apply(this, arguments);
|
|
8722
9258
|
}
|
|
8723
9259
|
|
|
@@ -8756,7 +9292,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8756
9292
|
}, _callee51, this);
|
|
8757
9293
|
}));
|
|
8758
9294
|
|
|
8759
|
-
function listSegments(
|
|
9295
|
+
function listSegments(_x70) {
|
|
8760
9296
|
return _listSegments.apply(this, arguments);
|
|
8761
9297
|
}
|
|
8762
9298
|
|
|
@@ -8799,7 +9335,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8799
9335
|
}, _callee52, this);
|
|
8800
9336
|
}));
|
|
8801
9337
|
|
|
8802
|
-
function updateSegment(
|
|
9338
|
+
function updateSegment(_x71, _x72) {
|
|
8803
9339
|
return _updateSegment.apply(this, arguments);
|
|
8804
9340
|
}
|
|
8805
9341
|
|
|
@@ -8831,7 +9367,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8831
9367
|
}, _callee53, this);
|
|
8832
9368
|
}));
|
|
8833
9369
|
|
|
8834
|
-
function deleteSegment(
|
|
9370
|
+
function deleteSegment(_x73) {
|
|
8835
9371
|
return _deleteSegment.apply(this, arguments);
|
|
8836
9372
|
}
|
|
8837
9373
|
|
|
@@ -8873,7 +9409,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8873
9409
|
}, _callee54, this);
|
|
8874
9410
|
}));
|
|
8875
9411
|
|
|
8876
|
-
function createCampaign(
|
|
9412
|
+
function createCampaign(_x74) {
|
|
8877
9413
|
return _createCampaign.apply(this, arguments);
|
|
8878
9414
|
}
|
|
8879
9415
|
|
|
@@ -8913,7 +9449,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8913
9449
|
}, _callee55, this);
|
|
8914
9450
|
}));
|
|
8915
9451
|
|
|
8916
|
-
function getCampaign(
|
|
9452
|
+
function getCampaign(_x75) {
|
|
8917
9453
|
return _getCampaign.apply(this, arguments);
|
|
8918
9454
|
}
|
|
8919
9455
|
|
|
@@ -8952,7 +9488,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8952
9488
|
}, _callee56, this);
|
|
8953
9489
|
}));
|
|
8954
9490
|
|
|
8955
|
-
function listCampaigns(
|
|
9491
|
+
function listCampaigns(_x76) {
|
|
8956
9492
|
return _listCampaigns.apply(this, arguments);
|
|
8957
9493
|
}
|
|
8958
9494
|
|
|
@@ -8995,7 +9531,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8995
9531
|
}, _callee57, this);
|
|
8996
9532
|
}));
|
|
8997
9533
|
|
|
8998
|
-
function updateCampaign(
|
|
9534
|
+
function updateCampaign(_x77, _x78) {
|
|
8999
9535
|
return _updateCampaign.apply(this, arguments);
|
|
9000
9536
|
}
|
|
9001
9537
|
|
|
@@ -9027,7 +9563,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9027
9563
|
}, _callee58, this);
|
|
9028
9564
|
}));
|
|
9029
9565
|
|
|
9030
|
-
function deleteCampaign(
|
|
9566
|
+
function deleteCampaign(_x79) {
|
|
9031
9567
|
return _deleteCampaign.apply(this, arguments);
|
|
9032
9568
|
}
|
|
9033
9569
|
|
|
@@ -9071,7 +9607,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9071
9607
|
}, _callee59, this);
|
|
9072
9608
|
}));
|
|
9073
9609
|
|
|
9074
|
-
function scheduleCampaign(
|
|
9610
|
+
function scheduleCampaign(_x80, _x81) {
|
|
9075
9611
|
return _scheduleCampaign.apply(this, arguments);
|
|
9076
9612
|
}
|
|
9077
9613
|
|
|
@@ -9111,7 +9647,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9111
9647
|
}, _callee60, this);
|
|
9112
9648
|
}));
|
|
9113
9649
|
|
|
9114
|
-
function stopCampaign(
|
|
9650
|
+
function stopCampaign(_x82) {
|
|
9115
9651
|
return _stopCampaign.apply(this, arguments);
|
|
9116
9652
|
}
|
|
9117
9653
|
|
|
@@ -9151,7 +9687,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9151
9687
|
}, _callee61, this);
|
|
9152
9688
|
}));
|
|
9153
9689
|
|
|
9154
|
-
function resumeCampaign(
|
|
9690
|
+
function resumeCampaign(_x83) {
|
|
9155
9691
|
return _resumeCampaign.apply(this, arguments);
|
|
9156
9692
|
}
|
|
9157
9693
|
|
|
@@ -9194,7 +9730,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9194
9730
|
}, _callee62, this);
|
|
9195
9731
|
}));
|
|
9196
9732
|
|
|
9197
|
-
function testCampaign(
|
|
9733
|
+
function testCampaign(_x84, _x85) {
|
|
9198
9734
|
return _testCampaign.apply(this, arguments);
|
|
9199
9735
|
}
|
|
9200
9736
|
|
|
@@ -9227,7 +9763,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9227
9763
|
}, _callee63, this);
|
|
9228
9764
|
}));
|
|
9229
9765
|
|
|
9230
|
-
function enrichURL(
|
|
9766
|
+
function enrichURL(_x86) {
|
|
9231
9767
|
return _enrichURL.apply(this, arguments);
|
|
9232
9768
|
}
|
|
9233
9769
|
|
|
@@ -9259,7 +9795,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9259
9795
|
}, _callee64, this);
|
|
9260
9796
|
}));
|
|
9261
9797
|
|
|
9262
|
-
function getTask(
|
|
9798
|
+
function getTask(_x87) {
|
|
9263
9799
|
return _getTask.apply(this, arguments);
|
|
9264
9800
|
}
|
|
9265
9801
|
|
|
@@ -9301,15 +9837,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9301
9837
|
}, _callee65, this);
|
|
9302
9838
|
}));
|
|
9303
9839
|
|
|
9304
|
-
function deleteChannels(
|
|
9840
|
+
function deleteChannels(_x88) {
|
|
9305
9841
|
return _deleteChannels.apply(this, arguments);
|
|
9306
9842
|
}
|
|
9307
9843
|
|
|
9308
9844
|
return deleteChannels;
|
|
9309
9845
|
}()
|
|
9310
|
-
}, {
|
|
9311
|
-
key: "deleteUsers",
|
|
9312
|
-
value:
|
|
9313
9846
|
/**
|
|
9314
9847
|
* deleteUsers - Batch Delete Users
|
|
9315
9848
|
*
|
|
@@ -9318,7 +9851,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9318
9851
|
*
|
|
9319
9852
|
* @return {APIResponse} A task ID
|
|
9320
9853
|
*/
|
|
9321
|
-
|
|
9854
|
+
|
|
9855
|
+
}, {
|
|
9856
|
+
key: "deleteUsers",
|
|
9857
|
+
value: function () {
|
|
9322
9858
|
var _deleteUsers = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee66(user_ids, options) {
|
|
9323
9859
|
return _regeneratorRuntime__default['default'].wrap(function _callee66$(_context66) {
|
|
9324
9860
|
while (1) {
|
|
@@ -9364,7 +9900,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9364
9900
|
}, _callee66, this);
|
|
9365
9901
|
}));
|
|
9366
9902
|
|
|
9367
|
-
function deleteUsers(
|
|
9903
|
+
function deleteUsers(_x89, _x90) {
|
|
9368
9904
|
return _deleteUsers.apply(this, arguments);
|
|
9369
9905
|
}
|
|
9370
9906
|
|
|
@@ -9496,4 +10032,5 @@ exports.encodeBase64 = encodeBase64;
|
|
|
9496
10032
|
exports.isOwnUser = isOwnUser;
|
|
9497
10033
|
exports.isValidEventType = isValidEventType;
|
|
9498
10034
|
exports.logChatPromiseExecution = logChatPromiseExecution;
|
|
10035
|
+
exports.postInsights = postInsights;
|
|
9499
10036
|
//# sourceMappingURL=browser.js.map
|