stream-chat 4.4.3-dev.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -13
- package/dist/browser.es.js +1229 -720
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.full-bundle.min.js +1 -1
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/browser.js +1229 -719
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +1229 -720
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1229 -719
- package/dist/index.js.map +1 -1
- package/dist/types/base64.d.ts.map +1 -1
- package/dist/types/channel.d.ts +19 -15
- package/dist/types/channel.d.ts.map +1 -1
- package/dist/types/channel_state.d.ts +2 -2
- package/dist/types/channel_state.d.ts.map +1 -1
- package/dist/types/client.d.ts +25 -42
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/client_state.d.ts +2 -2
- package/dist/types/client_state.d.ts.map +1 -1
- package/dist/types/connection.d.ts +14 -49
- package/dist/types/connection.d.ts.map +1 -1
- package/dist/types/connection_fallback.d.ts +41 -0
- package/dist/types/connection_fallback.d.ts.map +1 -0
- package/dist/types/errors.d.ts +14 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/insights.d.ts +17 -10
- package/dist/types/insights.d.ts.map +1 -1
- package/dist/types/permissions.d.ts.map +1 -1
- package/dist/types/signing.d.ts +3 -3
- package/dist/types/signing.d.ts.map +1 -1
- package/dist/types/token_manager.d.ts +2 -2
- package/dist/types/token_manager.d.ts.map +1 -1
- package/dist/types/types.d.ts +94 -88
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +13 -3
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/base64.ts +1 -4
- package/src/channel.ts +133 -461
- package/src/channel_state.ts +31 -158
- package/src/client.ts +291 -712
- package/src/client_state.ts +2 -2
- package/src/connection.ts +146 -395
- package/src/connection_fallback.ts +205 -0
- package/src/errors.ts +58 -0
- package/src/insights.ts +38 -32
- package/src/permissions.ts +3 -24
- package/src/signing.ts +6 -17
- package/src/token_manager.ts +6 -18
- package/src/types.ts +268 -512
- package/src/utils.ts +58 -24
- package/CHANGELOG.md +0 -844
package/dist/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, "
|
|
3617
|
-
|
|
3618
|
-
_defineProperty__default['default'](this, "insightMetrics", void 0);
|
|
3619
|
-
|
|
3620
|
-
_defineProperty__default['default'](this, "_buildUrl", function (reqID) {
|
|
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));
|
|
3717
|
+
_defineProperty__default['default'](this, "_buildUrl", function () {
|
|
3718
|
+
var qs = encodeURIComponent(_this.client._buildWSPayload(_this.requestID));
|
|
3630
3719
|
|
|
3631
|
-
var token = _this.tokenManager.getToken();
|
|
3720
|
+
var token = _this.client.tokenManager.getToken();
|
|
3632
3721
|
|
|
3633
|
-
return "".concat(_this.wsBaseURL, "/connect?json=").concat(qs, "&api_key=").concat(_this.
|
|
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,576 @@ 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 = 3;
|
|
5178
|
+
break;
|
|
5179
|
+
}
|
|
5180
|
+
|
|
5181
|
+
throw new Error('connecting already in progress');
|
|
5182
|
+
|
|
5183
|
+
case 3:
|
|
5184
|
+
if (!(_this.state === ConnectionState.Connected)) {
|
|
5185
|
+
_context3.next = 5;
|
|
5186
|
+
break;
|
|
5187
|
+
}
|
|
5188
|
+
|
|
5189
|
+
throw new Error('already connected and polling');
|
|
5190
|
+
|
|
5191
|
+
case 5:
|
|
5192
|
+
_this._setState(ConnectionState.Connecting);
|
|
5193
|
+
|
|
5194
|
+
_this.connectionID = undefined; // connect should be sent with empty connection_id so API creates one
|
|
5195
|
+
|
|
5196
|
+
_context3.prev = 7;
|
|
5197
|
+
_context3.next = 10;
|
|
5198
|
+
return _this._req({
|
|
5199
|
+
json: _this.client._buildWSPayload()
|
|
5200
|
+
}, {
|
|
5201
|
+
timeout: 8000
|
|
5202
|
+
}, // 8s
|
|
5203
|
+
reconnect);
|
|
5204
|
+
|
|
5205
|
+
case 10:
|
|
5206
|
+
_yield$_this$_req = _context3.sent;
|
|
5207
|
+
event = _yield$_this$_req.event;
|
|
5208
|
+
|
|
5209
|
+
_this._setState(ConnectionState.Connected);
|
|
5210
|
+
|
|
5211
|
+
_this.connectionID = event.connection_id;
|
|
5212
|
+
|
|
5213
|
+
_this._poll();
|
|
5214
|
+
|
|
5215
|
+
if (reconnect) {
|
|
5216
|
+
_this.client.recoverState();
|
|
5217
|
+
}
|
|
5218
|
+
|
|
5219
|
+
return _context3.abrupt("return", event);
|
|
4746
5220
|
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
break;
|
|
4751
|
-
}
|
|
5221
|
+
case 19:
|
|
5222
|
+
_context3.prev = 19;
|
|
5223
|
+
_context3.t0 = _context3["catch"](7);
|
|
4752
5224
|
|
|
4753
|
-
|
|
4754
|
-
return _this.tokenProvider();
|
|
5225
|
+
_this._setState(ConnectionState.Closed);
|
|
4755
5226
|
|
|
4756
|
-
|
|
4757
|
-
_this.token = _context2.sent;
|
|
4758
|
-
resolve(_this.token);
|
|
5227
|
+
throw _context3.t0;
|
|
4759
5228
|
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
}
|
|
5229
|
+
case 23:
|
|
5230
|
+
case "end":
|
|
5231
|
+
return _context3.stop();
|
|
4764
5232
|
}
|
|
4765
|
-
}
|
|
4766
|
-
})
|
|
5233
|
+
}
|
|
5234
|
+
}, _callee3, null, [[7, 19]]);
|
|
5235
|
+
})));
|
|
4767
5236
|
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
}());
|
|
4772
|
-
return _this.loadTokenPromise;
|
|
4773
|
-
});
|
|
5237
|
+
_defineProperty__default['default'](this, "isHealthy", function () {
|
|
5238
|
+
return _this.connectionID && _this.state === ConnectionState.Connected;
|
|
5239
|
+
});
|
|
4774
5240
|
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
return _this.token;
|
|
4778
|
-
}
|
|
5241
|
+
_defineProperty__default['default'](this, "disconnect", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4() {
|
|
5242
|
+
var _this$cancelToken3;
|
|
4779
5243
|
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
5244
|
+
var timeout,
|
|
5245
|
+
_args4 = arguments;
|
|
5246
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
5247
|
+
while (1) {
|
|
5248
|
+
switch (_context4.prev = _context4.next) {
|
|
5249
|
+
case 0:
|
|
5250
|
+
timeout = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : 2000;
|
|
5251
|
+
removeConnectionEventListeners(_this._onlineStatusChanged);
|
|
4783
5252
|
|
|
4784
|
-
|
|
4785
|
-
return JWTServerToken(_this.secret);
|
|
4786
|
-
}
|
|
5253
|
+
_this._setState(ConnectionState.Disconnected);
|
|
4787
5254
|
|
|
4788
|
-
|
|
4789
|
-
|
|
5255
|
+
(_this$cancelToken3 = _this.cancelToken) === null || _this$cancelToken3 === void 0 ? void 0 : _this$cancelToken3.cancel('disconnect() is called');
|
|
5256
|
+
_this.cancelToken = undefined;
|
|
5257
|
+
_context4.prev = 5;
|
|
5258
|
+
_context4.next = 8;
|
|
5259
|
+
return _this._req({
|
|
5260
|
+
close: true
|
|
5261
|
+
}, {
|
|
5262
|
+
timeout: timeout
|
|
5263
|
+
}, false);
|
|
4790
5264
|
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
});
|
|
5265
|
+
case 8:
|
|
5266
|
+
_this.connectionID = undefined;
|
|
4794
5267
|
|
|
4795
|
-
|
|
5268
|
+
_this._log("disconnect() - Closed connectionID");
|
|
4796
5269
|
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
}
|
|
5270
|
+
_context4.next = 15;
|
|
5271
|
+
break;
|
|
4800
5272
|
|
|
4801
|
-
|
|
5273
|
+
case 12:
|
|
5274
|
+
_context4.prev = 12;
|
|
5275
|
+
_context4.t0 = _context4["catch"](5);
|
|
4802
5276
|
|
|
4803
|
-
|
|
4804
|
-
|
|
5277
|
+
_this._log("disconnect() - Failed", {
|
|
5278
|
+
err: _context4.t0
|
|
5279
|
+
}, 'error');
|
|
5280
|
+
|
|
5281
|
+
case 15:
|
|
5282
|
+
case "end":
|
|
5283
|
+
return _context4.stop();
|
|
5284
|
+
}
|
|
5285
|
+
}
|
|
5286
|
+
}, _callee4, null, [[5, 12]]);
|
|
5287
|
+
})));
|
|
5288
|
+
|
|
5289
|
+
this.client = client;
|
|
5290
|
+
this.state = ConnectionState.Init;
|
|
5291
|
+
this.consecutiveFailures = 0;
|
|
5292
|
+
addConnectionEventListeners(this._onlineStatusChanged);
|
|
4805
5293
|
}
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
;
|
|
5294
|
+
|
|
5295
|
+
_createClass__default['default'](WSConnectionFallback, [{
|
|
5296
|
+
key: "_log",
|
|
5297
|
+
value: function _log(msg) {
|
|
5298
|
+
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5299
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
5300
|
+
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$1({
|
|
5301
|
+
tags: ['connection_fallback', 'connection']
|
|
5302
|
+
}, extra));
|
|
5303
|
+
}
|
|
5304
|
+
}, {
|
|
5305
|
+
key: "_setState",
|
|
5306
|
+
value: function _setState(state) {
|
|
5307
|
+
this._log("_setState() - ".concat(state)); // transition from connecting => connected
|
|
5308
|
+
|
|
5309
|
+
|
|
5310
|
+
if (this.state === ConnectionState.Connecting && state === ConnectionState.Connected) {
|
|
5311
|
+
//@ts-expect-error
|
|
5312
|
+
this.client.dispatchEvent({
|
|
5313
|
+
type: 'connection.changed',
|
|
5314
|
+
online: true
|
|
5315
|
+
});
|
|
5316
|
+
}
|
|
5317
|
+
|
|
5318
|
+
if (state === ConnectionState.Closed || state === ConnectionState.Disconnected) {
|
|
5319
|
+
//@ts-expect-error
|
|
5320
|
+
this.client.dispatchEvent({
|
|
5321
|
+
type: 'connection.changed',
|
|
5322
|
+
online: false
|
|
5323
|
+
});
|
|
5324
|
+
}
|
|
5325
|
+
|
|
5326
|
+
this.state = state;
|
|
5327
|
+
}
|
|
5328
|
+
/** @private */
|
|
5329
|
+
|
|
5330
|
+
}]);
|
|
5331
|
+
|
|
5332
|
+
return WSConnectionFallback;
|
|
5333
|
+
}();
|
|
4815
5334
|
|
|
4816
5335
|
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
5336
|
|
|
@@ -4851,10 +5370,6 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4851
5370
|
|
|
4852
5371
|
_defineProperty__default['default'](this, "configs", void 0);
|
|
4853
5372
|
|
|
4854
|
-
_defineProperty__default['default'](this, "connectionID", void 0);
|
|
4855
|
-
|
|
4856
|
-
_defineProperty__default['default'](this, "failures", void 0);
|
|
4857
|
-
|
|
4858
5373
|
_defineProperty__default['default'](this, "key", void 0);
|
|
4859
5374
|
|
|
4860
5375
|
_defineProperty__default['default'](this, "listeners", void 0);
|
|
@@ -4889,16 +5404,26 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4889
5404
|
|
|
4890
5405
|
_defineProperty__default['default'](this, "wsConnection", void 0);
|
|
4891
5406
|
|
|
5407
|
+
_defineProperty__default['default'](this, "wsFallback", void 0);
|
|
5408
|
+
|
|
4892
5409
|
_defineProperty__default['default'](this, "wsPromise", void 0);
|
|
4893
5410
|
|
|
4894
5411
|
_defineProperty__default['default'](this, "consecutiveFailures", void 0);
|
|
4895
5412
|
|
|
4896
5413
|
_defineProperty__default['default'](this, "insightMetrics", void 0);
|
|
4897
5414
|
|
|
4898
|
-
_defineProperty__default['default'](this, "
|
|
4899
|
-
|
|
5415
|
+
_defineProperty__default['default'](this, "defaultWSTimeoutWithFallback", void 0);
|
|
5416
|
+
|
|
5417
|
+
_defineProperty__default['default'](this, "defaultWSTimeout", void 0);
|
|
5418
|
+
|
|
5419
|
+
_defineProperty__default['default'](this, "_getConnectionID", function () {
|
|
5420
|
+
var _this$wsConnection, _this$wsFallback;
|
|
5421
|
+
|
|
5422
|
+
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);
|
|
5423
|
+
});
|
|
4900
5424
|
|
|
4901
|
-
|
|
5425
|
+
_defineProperty__default['default'](this, "_hasConnectionID", function () {
|
|
5426
|
+
return Boolean(_this._getConnectionID());
|
|
4902
5427
|
});
|
|
4903
5428
|
|
|
4904
5429
|
_defineProperty__default['default'](this, "connectUser", /*#__PURE__*/function () {
|
|
@@ -4984,36 +5509,55 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4984
5509
|
return _this.tokenManager.setTokenOrProvider(userTokenOrProvider, user);
|
|
4985
5510
|
});
|
|
4986
5511
|
|
|
4987
|
-
_defineProperty__default['default'](this, "closeConnection", function (
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
_this.cleaningIntervalRef = undefined;
|
|
4991
|
-
}
|
|
5512
|
+
_defineProperty__default['default'](this, "closeConnection", /*#__PURE__*/function () {
|
|
5513
|
+
var _ref2 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee2(timeout) {
|
|
5514
|
+
var _this$wsConnection2, _this$wsFallback2;
|
|
4992
5515
|
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
5516
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee2$(_context2) {
|
|
5517
|
+
while (1) {
|
|
5518
|
+
switch (_context2.prev = _context2.next) {
|
|
5519
|
+
case 0:
|
|
5520
|
+
if (_this.cleaningIntervalRef != null) {
|
|
5521
|
+
clearInterval(_this.cleaningIntervalRef);
|
|
5522
|
+
_this.cleaningIntervalRef = undefined;
|
|
5523
|
+
}
|
|
4996
5524
|
|
|
4997
|
-
|
|
4998
|
-
|
|
5525
|
+
_context2.next = 3;
|
|
5526
|
+
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
5527
|
|
|
5000
|
-
|
|
5001
|
-
|
|
5528
|
+
case 3:
|
|
5529
|
+
return _context2.abrupt("return", Promise.resolve());
|
|
5002
5530
|
|
|
5003
|
-
|
|
5531
|
+
case 4:
|
|
5532
|
+
case "end":
|
|
5533
|
+
return _context2.stop();
|
|
5534
|
+
}
|
|
5535
|
+
}
|
|
5536
|
+
}, _callee2);
|
|
5537
|
+
}));
|
|
5538
|
+
|
|
5539
|
+
return function (_x3) {
|
|
5540
|
+
return _ref2.apply(this, arguments);
|
|
5541
|
+
};
|
|
5542
|
+
}());
|
|
5543
|
+
|
|
5544
|
+
_defineProperty__default['default'](this, "openConnection", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee3() {
|
|
5545
|
+
var _this$wsConnection3, _this$wsFallback3;
|
|
5546
|
+
|
|
5547
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee3$(_context3) {
|
|
5004
5548
|
while (1) {
|
|
5005
|
-
switch (
|
|
5549
|
+
switch (_context3.prev = _context3.next) {
|
|
5006
5550
|
case 0:
|
|
5007
5551
|
if (_this.userID) {
|
|
5008
|
-
|
|
5552
|
+
_context3.next = 2;
|
|
5009
5553
|
break;
|
|
5010
5554
|
}
|
|
5011
5555
|
|
|
5012
5556
|
throw Error('User is not set on client, use client.connectUser or client.connectAnonymousUser instead');
|
|
5013
5557
|
|
|
5014
5558
|
case 2:
|
|
5015
|
-
if (!((_this$
|
|
5016
|
-
|
|
5559
|
+
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())) {
|
|
5560
|
+
_context3.next = 5;
|
|
5017
5561
|
break;
|
|
5018
5562
|
}
|
|
5019
5563
|
|
|
@@ -5021,7 +5565,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5021
5565
|
tags: ['connection', 'client']
|
|
5022
5566
|
});
|
|
5023
5567
|
|
|
5024
|
-
return
|
|
5568
|
+
return _context3.abrupt("return", Promise.resolve());
|
|
5025
5569
|
|
|
5026
5570
|
case 5:
|
|
5027
5571
|
_this.clientID = "".concat(_this.userID, "--").concat(randomId());
|
|
@@ -5029,14 +5573,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5029
5573
|
|
|
5030
5574
|
_this._startCleaning();
|
|
5031
5575
|
|
|
5032
|
-
return
|
|
5576
|
+
return _context3.abrupt("return", _this.wsPromise);
|
|
5033
5577
|
|
|
5034
5578
|
case 9:
|
|
5035
5579
|
case "end":
|
|
5036
|
-
return
|
|
5580
|
+
return _context3.stop();
|
|
5037
5581
|
}
|
|
5038
5582
|
}
|
|
5039
|
-
},
|
|
5583
|
+
}, _callee3);
|
|
5040
5584
|
})));
|
|
5041
5585
|
|
|
5042
5586
|
_defineProperty__default['default'](this, "_setupConnection", this.openConnection);
|
|
@@ -5054,12 +5598,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5054
5598
|
});
|
|
5055
5599
|
|
|
5056
5600
|
_defineProperty__default['default'](this, "disconnectUser", /*#__PURE__*/function () {
|
|
5057
|
-
var
|
|
5601
|
+
var _ref4 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee4(timeout) {
|
|
5058
5602
|
var closePromise, _i, _Object$values, _channel;
|
|
5059
5603
|
|
|
5060
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
5604
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee4$(_context4) {
|
|
5061
5605
|
while (1) {
|
|
5062
|
-
switch (
|
|
5606
|
+
switch (_context4.prev = _context4.next) {
|
|
5063
5607
|
case 0:
|
|
5064
5608
|
_this.logger('info', 'client:disconnect() - Disconnecting the client', {
|
|
5065
5609
|
tags: ['connection', 'client']
|
|
@@ -5083,21 +5627,21 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5083
5627
|
|
|
5084
5628
|
_this.state = new ClientState(); // reset token manager
|
|
5085
5629
|
|
|
5086
|
-
_this.tokenManager.reset
|
|
5630
|
+
setTimeout(_this.tokenManager.reset); // delay reseting to use token for disconnect calls
|
|
5631
|
+
// close the WS connection
|
|
5087
5632
|
|
|
5088
|
-
|
|
5089
|
-
return _context3.abrupt("return", closePromise);
|
|
5633
|
+
return _context4.abrupt("return", closePromise);
|
|
5090
5634
|
|
|
5091
5635
|
case 11:
|
|
5092
5636
|
case "end":
|
|
5093
|
-
return
|
|
5637
|
+
return _context4.stop();
|
|
5094
5638
|
}
|
|
5095
5639
|
}
|
|
5096
|
-
},
|
|
5640
|
+
}, _callee4);
|
|
5097
5641
|
}));
|
|
5098
5642
|
|
|
5099
|
-
return function (
|
|
5100
|
-
return
|
|
5643
|
+
return function (_x4) {
|
|
5644
|
+
return _ref4.apply(this, arguments);
|
|
5101
5645
|
};
|
|
5102
5646
|
}());
|
|
5103
5647
|
|
|
@@ -5125,78 +5669,78 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5125
5669
|
_defineProperty__default['default'](this, "setAnonymousUser", this.connectAnonymousUser);
|
|
5126
5670
|
|
|
5127
5671
|
_defineProperty__default['default'](this, "doAxiosRequest", /*#__PURE__*/function () {
|
|
5128
|
-
var
|
|
5672
|
+
var _ref5 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5(type, url, data) {
|
|
5129
5673
|
var options,
|
|
5130
5674
|
requestConfig,
|
|
5131
5675
|
response,
|
|
5132
5676
|
_requestConfig$header,
|
|
5133
|
-
|
|
5677
|
+
_args5 = arguments;
|
|
5134
5678
|
|
|
5135
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
5679
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
|
|
5136
5680
|
while (1) {
|
|
5137
|
-
switch (
|
|
5681
|
+
switch (_context5.prev = _context5.next) {
|
|
5138
5682
|
case 0:
|
|
5139
|
-
options =
|
|
5140
|
-
|
|
5683
|
+
options = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : {};
|
|
5684
|
+
_context5.next = 3;
|
|
5141
5685
|
return _this.tokenManager.tokenReady();
|
|
5142
5686
|
|
|
5143
5687
|
case 3:
|
|
5144
5688
|
requestConfig = _this._enrichAxiosOptions(options);
|
|
5145
|
-
|
|
5689
|
+
_context5.prev = 4;
|
|
5146
5690
|
|
|
5147
5691
|
_this._logApiRequest(type, url, data, requestConfig);
|
|
5148
5692
|
|
|
5149
|
-
|
|
5150
|
-
|
|
5693
|
+
_context5.t0 = type;
|
|
5694
|
+
_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
5695
|
break;
|
|
5152
5696
|
|
|
5153
5697
|
case 9:
|
|
5154
|
-
|
|
5698
|
+
_context5.next = 11;
|
|
5155
5699
|
return _this.axiosInstance.get(url, requestConfig);
|
|
5156
5700
|
|
|
5157
5701
|
case 11:
|
|
5158
|
-
response =
|
|
5159
|
-
return
|
|
5702
|
+
response = _context5.sent;
|
|
5703
|
+
return _context5.abrupt("break", 34);
|
|
5160
5704
|
|
|
5161
5705
|
case 13:
|
|
5162
|
-
|
|
5706
|
+
_context5.next = 15;
|
|
5163
5707
|
return _this.axiosInstance.delete(url, requestConfig);
|
|
5164
5708
|
|
|
5165
5709
|
case 15:
|
|
5166
|
-
response =
|
|
5167
|
-
return
|
|
5710
|
+
response = _context5.sent;
|
|
5711
|
+
return _context5.abrupt("break", 34);
|
|
5168
5712
|
|
|
5169
5713
|
case 17:
|
|
5170
|
-
|
|
5714
|
+
_context5.next = 19;
|
|
5171
5715
|
return _this.axiosInstance.post(url, data, requestConfig);
|
|
5172
5716
|
|
|
5173
5717
|
case 19:
|
|
5174
|
-
response =
|
|
5175
|
-
return
|
|
5718
|
+
response = _context5.sent;
|
|
5719
|
+
return _context5.abrupt("break", 34);
|
|
5176
5720
|
|
|
5177
5721
|
case 21:
|
|
5178
|
-
|
|
5722
|
+
_context5.next = 23;
|
|
5179
5723
|
return _this.axiosInstance.put(url, data, requestConfig);
|
|
5180
5724
|
|
|
5181
5725
|
case 23:
|
|
5182
|
-
response =
|
|
5183
|
-
return
|
|
5726
|
+
response = _context5.sent;
|
|
5727
|
+
return _context5.abrupt("break", 34);
|
|
5184
5728
|
|
|
5185
5729
|
case 25:
|
|
5186
|
-
|
|
5730
|
+
_context5.next = 27;
|
|
5187
5731
|
return _this.axiosInstance.patch(url, data, requestConfig);
|
|
5188
5732
|
|
|
5189
5733
|
case 27:
|
|
5190
|
-
response =
|
|
5191
|
-
return
|
|
5734
|
+
response = _context5.sent;
|
|
5735
|
+
return _context5.abrupt("break", 34);
|
|
5192
5736
|
|
|
5193
5737
|
case 29:
|
|
5194
|
-
|
|
5738
|
+
_context5.next = 31;
|
|
5195
5739
|
return _this.axiosInstance.options(url, requestConfig);
|
|
5196
5740
|
|
|
5197
5741
|
case 31:
|
|
5198
|
-
response =
|
|
5199
|
-
return
|
|
5742
|
+
response = _context5.sent;
|
|
5743
|
+
return _context5.abrupt("break", 34);
|
|
5200
5744
|
|
|
5201
5745
|
case 33:
|
|
5202
5746
|
throw new Error('Invalid request type');
|
|
@@ -5205,65 +5749,66 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5205
5749
|
_this._logApiResponse(type, url, response);
|
|
5206
5750
|
|
|
5207
5751
|
_this.consecutiveFailures = 0;
|
|
5208
|
-
return
|
|
5752
|
+
return _context5.abrupt("return", _this.handleResponse(response));
|
|
5209
5753
|
|
|
5210
5754
|
case 39:
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
|
|
5755
|
+
_context5.prev = 39;
|
|
5756
|
+
_context5.t1 = _context5["catch"](4);
|
|
5757
|
+
_context5.t1.client_request_id = (_requestConfig$header = requestConfig.headers) === null || _requestConfig$header === void 0 ? void 0 : _requestConfig$header['x-client-request-id'];
|
|
5214
5758
|
|
|
5215
|
-
_this._logApiError(type, url,
|
|
5759
|
+
_this._logApiError(type, url, _context5.t1);
|
|
5216
5760
|
|
|
5217
5761
|
_this.consecutiveFailures += 1;
|
|
5218
5762
|
|
|
5219
|
-
if (!
|
|
5220
|
-
|
|
5763
|
+
if (!_context5.t1.response) {
|
|
5764
|
+
_context5.next = 56;
|
|
5221
5765
|
break;
|
|
5222
5766
|
}
|
|
5223
5767
|
|
|
5224
|
-
if (!(
|
|
5225
|
-
|
|
5768
|
+
if (!(_context5.t1.response.data.code === chatCodes.TOKEN_EXPIRED && !_this.tokenManager.isStatic())) {
|
|
5769
|
+
_context5.next = 53;
|
|
5226
5770
|
break;
|
|
5227
5771
|
}
|
|
5228
5772
|
|
|
5229
5773
|
if (!(_this.consecutiveFailures > 1)) {
|
|
5230
|
-
|
|
5774
|
+
_context5.next = 49;
|
|
5231
5775
|
break;
|
|
5232
5776
|
}
|
|
5233
5777
|
|
|
5234
|
-
|
|
5778
|
+
_context5.next = 49;
|
|
5235
5779
|
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5236
5780
|
|
|
5237
5781
|
case 49:
|
|
5238
5782
|
_this.tokenManager.loadToken();
|
|
5239
5783
|
|
|
5240
|
-
|
|
5784
|
+
_context5.next = 52;
|
|
5241
5785
|
return _this.doAxiosRequest(type, url, data, options);
|
|
5242
5786
|
|
|
5243
5787
|
case 52:
|
|
5244
|
-
return
|
|
5788
|
+
return _context5.abrupt("return", _context5.sent);
|
|
5245
5789
|
|
|
5246
5790
|
case 53:
|
|
5247
|
-
return
|
|
5791
|
+
return _context5.abrupt("return", _this.handleResponse(_context5.t1.response));
|
|
5248
5792
|
|
|
5249
5793
|
case 56:
|
|
5250
|
-
throw
|
|
5794
|
+
throw _context5.t1;
|
|
5251
5795
|
|
|
5252
5796
|
case 57:
|
|
5253
5797
|
case "end":
|
|
5254
|
-
return
|
|
5798
|
+
return _context5.stop();
|
|
5255
5799
|
}
|
|
5256
5800
|
}
|
|
5257
|
-
},
|
|
5801
|
+
}, _callee5, null, [[4, 39]]);
|
|
5258
5802
|
}));
|
|
5259
5803
|
|
|
5260
|
-
return function (
|
|
5261
|
-
return
|
|
5804
|
+
return function (_x5, _x6, _x7) {
|
|
5805
|
+
return _ref5.apply(this, arguments);
|
|
5262
5806
|
};
|
|
5263
5807
|
}());
|
|
5264
5808
|
|
|
5265
5809
|
_defineProperty__default['default'](this, "dispatchEvent", function (event) {
|
|
5266
|
-
// client event handlers
|
|
5810
|
+
if (!event.received_at) event.received_at = new Date(); // client event handlers
|
|
5811
|
+
|
|
5267
5812
|
var postListenerCallbacks = _this._handleClientEvent(event); // channel event handlers
|
|
5268
5813
|
|
|
5269
5814
|
|
|
@@ -5289,7 +5834,6 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5289
5834
|
// dispatch the event to the channel listeners
|
|
5290
5835
|
var jsonString = messageEvent.data;
|
|
5291
5836
|
var event = JSON.parse(jsonString);
|
|
5292
|
-
event.received_at = new Date();
|
|
5293
5837
|
|
|
5294
5838
|
_this.dispatchEvent(event);
|
|
5295
5839
|
});
|
|
@@ -5410,22 +5954,20 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5410
5954
|
}
|
|
5411
5955
|
});
|
|
5412
5956
|
|
|
5413
|
-
_defineProperty__default['default'](this, "recoverState", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function
|
|
5414
|
-
var _this$wsConnection3;
|
|
5415
|
-
|
|
5957
|
+
_defineProperty__default['default'](this, "recoverState", /*#__PURE__*/_asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee6() {
|
|
5416
5958
|
var cids;
|
|
5417
|
-
return _regeneratorRuntime__default['default'].wrap(function
|
|
5959
|
+
return _regeneratorRuntime__default['default'].wrap(function _callee6$(_context6) {
|
|
5418
5960
|
while (1) {
|
|
5419
|
-
switch (
|
|
5961
|
+
switch (_context6.prev = _context6.next) {
|
|
5420
5962
|
case 0:
|
|
5421
|
-
_this.logger('info', "client:recoverState() - Start of recoverState with connectionID ".concat(
|
|
5963
|
+
_this.logger('info', "client:recoverState() - Start of recoverState with connectionID ".concat(_this._getConnectionID()), {
|
|
5422
5964
|
tags: ['connection']
|
|
5423
5965
|
});
|
|
5424
5966
|
|
|
5425
5967
|
cids = Object.keys(_this.activeChannels);
|
|
5426
5968
|
|
|
5427
5969
|
if (!(cids.length && _this.recoverStateOnReconnect)) {
|
|
5428
|
-
|
|
5970
|
+
_context6.next = 10;
|
|
5429
5971
|
break;
|
|
5430
5972
|
}
|
|
5431
5973
|
|
|
@@ -5433,7 +5975,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5433
5975
|
tags: ['connection', 'client']
|
|
5434
5976
|
});
|
|
5435
5977
|
|
|
5436
|
-
|
|
5978
|
+
_context6.next = 6;
|
|
5437
5979
|
return _this.queryChannels({
|
|
5438
5980
|
cid: {
|
|
5439
5981
|
$in: cids
|
|
@@ -5453,7 +5995,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5453
5995
|
type: 'connection.recovered'
|
|
5454
5996
|
});
|
|
5455
5997
|
|
|
5456
|
-
|
|
5998
|
+
_context6.next = 11;
|
|
5457
5999
|
break;
|
|
5458
6000
|
|
|
5459
6001
|
case 10:
|
|
@@ -5467,10 +6009,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5467
6009
|
|
|
5468
6010
|
case 13:
|
|
5469
6011
|
case "end":
|
|
5470
|
-
return
|
|
6012
|
+
return _context6.stop();
|
|
5471
6013
|
}
|
|
5472
6014
|
}
|
|
5473
|
-
},
|
|
6015
|
+
}, _callee6);
|
|
5474
6016
|
})));
|
|
5475
6017
|
|
|
5476
6018
|
_defineProperty__default['default'](this, "getChannelByMembers", function (channelType, custom) {
|
|
@@ -5550,66 +6092,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5550
6092
|
return !!_this.secret;
|
|
5551
6093
|
});
|
|
5552
6094
|
|
|
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
|
-
}());
|
|
6095
|
+
_defineProperty__default['default'](this, "_buildWSPayload", function (client_request_id) {
|
|
6096
|
+
return JSON.stringify({
|
|
6097
|
+
user_id: _this.userID,
|
|
6098
|
+
user_details: _this._user,
|
|
6099
|
+
device: _this.options.device,
|
|
6100
|
+
client_request_id: client_request_id
|
|
6101
|
+
});
|
|
6102
|
+
});
|
|
5613
6103
|
|
|
5614
6104
|
// set the key
|
|
5615
6105
|
this.key = _key;
|
|
@@ -5667,6 +6157,8 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5667
6157
|
this.tokenManager = new TokenManager(this.secret);
|
|
5668
6158
|
this.consecutiveFailures = 0;
|
|
5669
6159
|
this.insightMetrics = new InsightMetrics();
|
|
6160
|
+
this.defaultWSTimeoutWithFallback = 6000;
|
|
6161
|
+
this.defaultWSTimeout = 15000;
|
|
5670
6162
|
/**
|
|
5671
6163
|
* logger function should accept 3 parameters:
|
|
5672
6164
|
* @param logLevel string
|
|
@@ -5840,7 +6332,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5840
6332
|
}, _callee7, this);
|
|
5841
6333
|
}));
|
|
5842
6334
|
|
|
5843
|
-
function updateAppSettings(
|
|
6335
|
+
function updateAppSettings(_x8) {
|
|
5844
6336
|
return _updateAppSettings.apply(this, arguments);
|
|
5845
6337
|
}
|
|
5846
6338
|
|
|
@@ -5874,7 +6366,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5874
6366
|
}, _callee8, this);
|
|
5875
6367
|
}));
|
|
5876
6368
|
|
|
5877
|
-
function revokeTokens(
|
|
6369
|
+
function revokeTokens(_x9) {
|
|
5878
6370
|
return _revokeTokens.apply(this, arguments);
|
|
5879
6371
|
}
|
|
5880
6372
|
|
|
@@ -5906,7 +6398,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5906
6398
|
}, _callee9, this);
|
|
5907
6399
|
}));
|
|
5908
6400
|
|
|
5909
|
-
function revokeUserToken(
|
|
6401
|
+
function revokeUserToken(_x10, _x11) {
|
|
5910
6402
|
return _revokeUserToken.apply(this, arguments);
|
|
5911
6403
|
}
|
|
5912
6404
|
|
|
@@ -5965,7 +6457,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5965
6457
|
}, _callee10, this);
|
|
5966
6458
|
}));
|
|
5967
6459
|
|
|
5968
|
-
function revokeUsersToken(
|
|
6460
|
+
function revokeUsersToken(_x12, _x13) {
|
|
5969
6461
|
return _revokeUsersToken.apply(this, arguments);
|
|
5970
6462
|
}
|
|
5971
6463
|
|
|
@@ -6057,7 +6549,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6057
6549
|
}, _callee12, this);
|
|
6058
6550
|
}));
|
|
6059
6551
|
|
|
6060
|
-
function testPushSettings(
|
|
6552
|
+
function testPushSettings(_x14) {
|
|
6061
6553
|
return _testPushSettings.apply(this, arguments);
|
|
6062
6554
|
}
|
|
6063
6555
|
|
|
@@ -6166,7 +6658,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6166
6658
|
}, _callee14, this, [[1, 7]]);
|
|
6167
6659
|
}));
|
|
6168
6660
|
|
|
6169
|
-
function setGuestUser(
|
|
6661
|
+
function setGuestUser(_x15) {
|
|
6170
6662
|
return _setGuestUser.apply(this, arguments);
|
|
6171
6663
|
}
|
|
6172
6664
|
|
|
@@ -6477,72 +6969,84 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6477
6969
|
*/
|
|
6478
6970
|
function () {
|
|
6479
6971
|
var _connect = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee15() {
|
|
6480
|
-
var client;
|
|
6481
6972
|
return _regeneratorRuntime__default['default'].wrap(function _callee15$(_context15) {
|
|
6482
6973
|
while (1) {
|
|
6483
6974
|
switch (_context15.prev = _context15.next) {
|
|
6484
6975
|
case 0:
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
if (!(client.userID == null || this._user == null)) {
|
|
6489
|
-
_context15.next = 4;
|
|
6976
|
+
if (!(!this.userID || !this._user)) {
|
|
6977
|
+
_context15.next = 2;
|
|
6490
6978
|
break;
|
|
6491
6979
|
}
|
|
6492
6980
|
|
|
6493
6981
|
throw Error('Call connectUser or connectAnonymousUser before starting the connection');
|
|
6494
6982
|
|
|
6495
|
-
case
|
|
6496
|
-
if (
|
|
6497
|
-
_context15.next =
|
|
6983
|
+
case 2:
|
|
6984
|
+
if (this.wsBaseURL) {
|
|
6985
|
+
_context15.next = 4;
|
|
6498
6986
|
break;
|
|
6499
6987
|
}
|
|
6500
6988
|
|
|
6501
6989
|
throw Error('Websocket base url not set');
|
|
6502
6990
|
|
|
6503
|
-
case
|
|
6504
|
-
if (
|
|
6505
|
-
_context15.next =
|
|
6991
|
+
case 4:
|
|
6992
|
+
if (this.clientID) {
|
|
6993
|
+
_context15.next = 6;
|
|
6506
6994
|
break;
|
|
6507
6995
|
}
|
|
6508
6996
|
|
|
6509
6997
|
throw Error('clientID is not set');
|
|
6510
6998
|
|
|
6511
|
-
case
|
|
6999
|
+
case 6:
|
|
6512
7000
|
if (!this.wsConnection && (this.options.warmUp || this.options.enableInsights)) {
|
|
6513
|
-
this.
|
|
7001
|
+
this._sayHi();
|
|
6514
7002
|
} // The StableWSConnection handles all the reconnection logic.
|
|
6515
7003
|
|
|
6516
7004
|
|
|
6517
7005
|
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
|
|
7006
|
+
client: this
|
|
6533
7007
|
});
|
|
6534
|
-
_context15.
|
|
6535
|
-
|
|
7008
|
+
_context15.prev = 8;
|
|
7009
|
+
_context15.next = 11;
|
|
7010
|
+
return this.wsConnection.connect(this.options.enableWSFallback ? this.defaultWSTimeoutWithFallback : this.defaultWSTimeout);
|
|
6536
7011
|
|
|
6537
|
-
case
|
|
7012
|
+
case 11:
|
|
6538
7013
|
return _context15.abrupt("return", _context15.sent);
|
|
6539
7014
|
|
|
6540
|
-
case
|
|
7015
|
+
case 14:
|
|
7016
|
+
_context15.prev = 14;
|
|
7017
|
+
_context15.t0 = _context15["catch"](8);
|
|
7018
|
+
|
|
7019
|
+
if (!(this.options.enableWSFallback && isWSFailure(_context15.t0) && isOnline())) {
|
|
7020
|
+
_context15.next = 24;
|
|
7021
|
+
break;
|
|
7022
|
+
}
|
|
7023
|
+
|
|
7024
|
+
this.logger('info', 'client:connect() - WS failed, fallback to longpoll', {
|
|
7025
|
+
tags: ['connection', 'client']
|
|
7026
|
+
});
|
|
7027
|
+
|
|
7028
|
+
this.wsConnection._destroyCurrentWSConnection();
|
|
7029
|
+
|
|
7030
|
+
this.wsConnection.disconnect().then(); // close WS so no retry
|
|
7031
|
+
|
|
7032
|
+
this.wsFallback = new WSConnectionFallback({
|
|
7033
|
+
client: this
|
|
7034
|
+
});
|
|
7035
|
+
_context15.next = 23;
|
|
7036
|
+
return this.wsFallback.connect();
|
|
7037
|
+
|
|
7038
|
+
case 23:
|
|
7039
|
+
return _context15.abrupt("return", _context15.sent);
|
|
7040
|
+
|
|
7041
|
+
case 24:
|
|
7042
|
+
throw _context15.t0;
|
|
7043
|
+
|
|
7044
|
+
case 25:
|
|
6541
7045
|
case "end":
|
|
6542
7046
|
return _context15.stop();
|
|
6543
7047
|
}
|
|
6544
7048
|
}
|
|
6545
|
-
}, _callee15, this);
|
|
7049
|
+
}, _callee15, this, [[8, 14]]);
|
|
6546
7050
|
}));
|
|
6547
7051
|
|
|
6548
7052
|
function connect() {
|
|
@@ -6551,9 +7055,15 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6551
7055
|
|
|
6552
7056
|
return connect;
|
|
6553
7057
|
}()
|
|
7058
|
+
/**
|
|
7059
|
+
* Check the connectivity with server for warmup purpose.
|
|
7060
|
+
*
|
|
7061
|
+
* @private
|
|
7062
|
+
*/
|
|
7063
|
+
|
|
6554
7064
|
}, {
|
|
6555
|
-
key: "
|
|
6556
|
-
value: function
|
|
7065
|
+
key: "_sayHi",
|
|
7066
|
+
value: function _sayHi() {
|
|
6557
7067
|
var _this4 = this;
|
|
6558
7068
|
|
|
6559
7069
|
var client_request_id = randomId();
|
|
@@ -6562,12 +7072,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6562
7072
|
'x-client-request-id': client_request_id
|
|
6563
7073
|
}
|
|
6564
7074
|
};
|
|
6565
|
-
this.doAxiosRequest('get', this.baseURL + '/
|
|
6566
|
-
_this4.
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
7075
|
+
this.doAxiosRequest('get', this.baseURL + '/hi', null, opts).catch(function (e) {
|
|
7076
|
+
if (_this4.options.enableInsights) {
|
|
7077
|
+
postInsights('http_hi_failed', {
|
|
7078
|
+
api_key: _this4.key,
|
|
7079
|
+
err: e,
|
|
7080
|
+
client_request_id: client_request_id
|
|
7081
|
+
});
|
|
7082
|
+
}
|
|
6571
7083
|
});
|
|
6572
7084
|
}
|
|
6573
7085
|
/**
|
|
@@ -6630,7 +7142,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6630
7142
|
}, _callee16, this);
|
|
6631
7143
|
}));
|
|
6632
7144
|
|
|
6633
|
-
function queryUsers(
|
|
7145
|
+
function queryUsers(_x16) {
|
|
6634
7146
|
return _queryUsers.apply(this, arguments);
|
|
6635
7147
|
}
|
|
6636
7148
|
|
|
@@ -6849,7 +7361,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6849
7361
|
}, _callee19, this);
|
|
6850
7362
|
}));
|
|
6851
7363
|
|
|
6852
|
-
function queryChannels(
|
|
7364
|
+
function queryChannels(_x17) {
|
|
6853
7365
|
return _queryChannels.apply(this, arguments);
|
|
6854
7366
|
}
|
|
6855
7367
|
|
|
@@ -6935,7 +7447,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6935
7447
|
}, _callee20, this);
|
|
6936
7448
|
}));
|
|
6937
7449
|
|
|
6938
|
-
function search(
|
|
7450
|
+
function search(_x18, _x19) {
|
|
6939
7451
|
return _search.apply(this, arguments);
|
|
6940
7452
|
}
|
|
6941
7453
|
|
|
@@ -6953,7 +7465,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6953
7465
|
}, {
|
|
6954
7466
|
key: "setLocalDevice",
|
|
6955
7467
|
value: function setLocalDevice(device) {
|
|
6956
|
-
if (this.wsConnection) {
|
|
7468
|
+
if (this.wsConnection || this.wsFallback) {
|
|
6957
7469
|
throw new Error('you can only set device before opening a websocket connection');
|
|
6958
7470
|
}
|
|
6959
7471
|
|
|
@@ -6995,7 +7507,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6995
7507
|
}, _callee21, this);
|
|
6996
7508
|
}));
|
|
6997
7509
|
|
|
6998
|
-
function addDevice(_x21, _x22
|
|
7510
|
+
function addDevice(_x20, _x21, _x22) {
|
|
6999
7511
|
return _addDevice.apply(this, arguments);
|
|
7000
7512
|
}
|
|
7001
7513
|
|
|
@@ -7033,7 +7545,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7033
7545
|
}, _callee22, this);
|
|
7034
7546
|
}));
|
|
7035
7547
|
|
|
7036
|
-
function getDevices(
|
|
7548
|
+
function getDevices(_x23) {
|
|
7037
7549
|
return _getDevices.apply(this, arguments);
|
|
7038
7550
|
}
|
|
7039
7551
|
|
|
@@ -7073,7 +7585,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7073
7585
|
}, _callee23, this);
|
|
7074
7586
|
}));
|
|
7075
7587
|
|
|
7076
|
-
function removeDevice(
|
|
7588
|
+
function removeDevice(_x24, _x25) {
|
|
7077
7589
|
return _removeDevice.apply(this, arguments);
|
|
7078
7590
|
}
|
|
7079
7591
|
|
|
@@ -7114,7 +7626,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7114
7626
|
}, _callee24, this);
|
|
7115
7627
|
}));
|
|
7116
7628
|
|
|
7117
|
-
function getRateLimits(
|
|
7629
|
+
function getRateLimits(_x26) {
|
|
7118
7630
|
return _getRateLimits.apply(this, arguments);
|
|
7119
7631
|
}
|
|
7120
7632
|
|
|
@@ -7215,7 +7727,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7215
7727
|
}, _callee25, this);
|
|
7216
7728
|
}));
|
|
7217
7729
|
|
|
7218
|
-
function partialUpdateUser(
|
|
7730
|
+
function partialUpdateUser(_x27) {
|
|
7219
7731
|
return _partialUpdateUser.apply(this, arguments);
|
|
7220
7732
|
}
|
|
7221
7733
|
|
|
@@ -7301,7 +7813,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7301
7813
|
}, _callee26, this, [[2, 13, 16, 19]]);
|
|
7302
7814
|
}));
|
|
7303
7815
|
|
|
7304
|
-
function upsertUsers(
|
|
7816
|
+
function upsertUsers(_x28) {
|
|
7305
7817
|
return _upsertUsers.apply(this, arguments);
|
|
7306
7818
|
}
|
|
7307
7819
|
|
|
@@ -7414,7 +7926,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7414
7926
|
}, _callee27, this, [[1, 11, 14, 17]]);
|
|
7415
7927
|
}));
|
|
7416
7928
|
|
|
7417
|
-
function partialUpdateUsers(
|
|
7929
|
+
function partialUpdateUsers(_x29) {
|
|
7418
7930
|
return _partialUpdateUsers.apply(this, arguments);
|
|
7419
7931
|
}
|
|
7420
7932
|
|
|
@@ -7442,7 +7954,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7442
7954
|
}, _callee28, this);
|
|
7443
7955
|
}));
|
|
7444
7956
|
|
|
7445
|
-
function deleteUser(
|
|
7957
|
+
function deleteUser(_x30, _x31) {
|
|
7446
7958
|
return _deleteUser.apply(this, arguments);
|
|
7447
7959
|
}
|
|
7448
7960
|
|
|
@@ -7470,7 +7982,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7470
7982
|
}, _callee29, this);
|
|
7471
7983
|
}));
|
|
7472
7984
|
|
|
7473
|
-
function reactivateUser(
|
|
7985
|
+
function reactivateUser(_x32, _x33) {
|
|
7474
7986
|
return _reactivateUser.apply(this, arguments);
|
|
7475
7987
|
}
|
|
7476
7988
|
|
|
@@ -7498,7 +8010,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7498
8010
|
}, _callee30, this);
|
|
7499
8011
|
}));
|
|
7500
8012
|
|
|
7501
|
-
function deactivateUser(
|
|
8013
|
+
function deactivateUser(_x34, _x35) {
|
|
7502
8014
|
return _deactivateUser.apply(this, arguments);
|
|
7503
8015
|
}
|
|
7504
8016
|
|
|
@@ -7526,7 +8038,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7526
8038
|
}, _callee31, this);
|
|
7527
8039
|
}));
|
|
7528
8040
|
|
|
7529
|
-
function exportUser(
|
|
8041
|
+
function exportUser(_x36, _x37) {
|
|
7530
8042
|
return _exportUser.apply(this, arguments);
|
|
7531
8043
|
}
|
|
7532
8044
|
|
|
@@ -7547,27 +8059,15 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7547
8059
|
while (1) {
|
|
7548
8060
|
switch (_context32.prev = _context32.next) {
|
|
7549
8061
|
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;
|
|
8062
|
+
_context32.next = 2;
|
|
7563
8063
|
return this.post(this.baseURL + '/moderation/ban', _objectSpread({
|
|
7564
8064
|
target_user_id: targetUserID
|
|
7565
8065
|
}, options));
|
|
7566
8066
|
|
|
7567
|
-
case
|
|
8067
|
+
case 2:
|
|
7568
8068
|
return _context32.abrupt("return", _context32.sent);
|
|
7569
8069
|
|
|
7570
|
-
case
|
|
8070
|
+
case 3:
|
|
7571
8071
|
case "end":
|
|
7572
8072
|
return _context32.stop();
|
|
7573
8073
|
}
|
|
@@ -7575,7 +8075,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7575
8075
|
}, _callee32, this);
|
|
7576
8076
|
}));
|
|
7577
8077
|
|
|
7578
|
-
function banUser(
|
|
8078
|
+
function banUser(_x38, _x39) {
|
|
7579
8079
|
return _banUser.apply(this, arguments);
|
|
7580
8080
|
}
|
|
7581
8081
|
|
|
@@ -7612,7 +8112,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7612
8112
|
}, _callee33, this);
|
|
7613
8113
|
}));
|
|
7614
8114
|
|
|
7615
|
-
function unbanUser(
|
|
8115
|
+
function unbanUser(_x40, _x41) {
|
|
7616
8116
|
return _unbanUser.apply(this, arguments);
|
|
7617
8117
|
}
|
|
7618
8118
|
|
|
@@ -7649,7 +8149,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7649
8149
|
}, _callee34, this);
|
|
7650
8150
|
}));
|
|
7651
8151
|
|
|
7652
|
-
function shadowBan(
|
|
8152
|
+
function shadowBan(_x42, _x43) {
|
|
7653
8153
|
return _shadowBan.apply(this, arguments);
|
|
7654
8154
|
}
|
|
7655
8155
|
|
|
@@ -7686,7 +8186,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7686
8186
|
}, _callee35, this);
|
|
7687
8187
|
}));
|
|
7688
8188
|
|
|
7689
|
-
function removeShadowBan(
|
|
8189
|
+
function removeShadowBan(_x44, _x45) {
|
|
7690
8190
|
return _removeShadowBan.apply(this, arguments);
|
|
7691
8191
|
}
|
|
7692
8192
|
|
|
@@ -7729,7 +8229,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7729
8229
|
}, _callee36, this);
|
|
7730
8230
|
}));
|
|
7731
8231
|
|
|
7732
|
-
function muteUser(
|
|
8232
|
+
function muteUser(_x46, _x47) {
|
|
7733
8233
|
return _muteUser.apply(this, arguments);
|
|
7734
8234
|
}
|
|
7735
8235
|
|
|
@@ -7768,7 +8268,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7768
8268
|
}, _callee37, this);
|
|
7769
8269
|
}));
|
|
7770
8270
|
|
|
7771
|
-
function unmuteUser(
|
|
8271
|
+
function unmuteUser(_x48, _x49) {
|
|
7772
8272
|
return _unmuteUser.apply(this, arguments);
|
|
7773
8273
|
}
|
|
7774
8274
|
|
|
@@ -7827,7 +8327,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7827
8327
|
}, _callee38, this);
|
|
7828
8328
|
}));
|
|
7829
8329
|
|
|
7830
|
-
function flagMessage(
|
|
8330
|
+
function flagMessage(_x50) {
|
|
7831
8331
|
return _flagMessage.apply(this, arguments);
|
|
7832
8332
|
}
|
|
7833
8333
|
|
|
@@ -7867,7 +8367,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7867
8367
|
}, _callee39, this);
|
|
7868
8368
|
}));
|
|
7869
8369
|
|
|
7870
|
-
function flagUser(
|
|
8370
|
+
function flagUser(_x51) {
|
|
7871
8371
|
return _flagUser.apply(this, arguments);
|
|
7872
8372
|
}
|
|
7873
8373
|
|
|
@@ -7907,7 +8407,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7907
8407
|
}, _callee40, this);
|
|
7908
8408
|
}));
|
|
7909
8409
|
|
|
7910
|
-
function unflagMessage(
|
|
8410
|
+
function unflagMessage(_x52) {
|
|
7911
8411
|
return _unflagMessage.apply(this, arguments);
|
|
7912
8412
|
}
|
|
7913
8413
|
|
|
@@ -7947,7 +8447,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7947
8447
|
}, _callee41, this);
|
|
7948
8448
|
}));
|
|
7949
8449
|
|
|
7950
|
-
function unflagUser(
|
|
8450
|
+
function unflagUser(_x53) {
|
|
7951
8451
|
return _unflagUser.apply(this, arguments);
|
|
7952
8452
|
}
|
|
7953
8453
|
|
|
@@ -8086,7 +8586,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8086
8586
|
}, _callee43, this);
|
|
8087
8587
|
}));
|
|
8088
8588
|
|
|
8089
|
-
function translateMessage(
|
|
8589
|
+
function translateMessage(_x54, _x55) {
|
|
8090
8590
|
return _translateMessage.apply(this, arguments);
|
|
8091
8591
|
}
|
|
8092
8592
|
|
|
@@ -8202,7 +8702,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8202
8702
|
case 2:
|
|
8203
8703
|
clonedMessage = _extends__default['default']({}, message);
|
|
8204
8704
|
delete clonedMessage.id;
|
|
8205
|
-
reservedMessageFields = ['command', 'created_at', 'html', 'latest_reactions', 'own_reactions', 'reaction_counts', 'reply_count', 'type', 'updated_at', 'user', '__html'];
|
|
8705
|
+
reservedMessageFields = ['command', 'created_at', 'html', 'latest_reactions', 'own_reactions', 'quoted_message', 'reaction_counts', 'reply_count', 'type', 'updated_at', 'user', '__html'];
|
|
8206
8706
|
reservedMessageFields.forEach(function (item) {
|
|
8207
8707
|
if (clonedMessage[item] != null) {
|
|
8208
8708
|
delete clonedMessage[item];
|
|
@@ -8246,7 +8746,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8246
8746
|
}, _callee44, this);
|
|
8247
8747
|
}));
|
|
8248
8748
|
|
|
8249
|
-
function updateMessage(_x57, _x58
|
|
8749
|
+
function updateMessage(_x56, _x57, _x58) {
|
|
8250
8750
|
return _updateMessage.apply(this, arguments);
|
|
8251
8751
|
}
|
|
8252
8752
|
|
|
@@ -8307,7 +8807,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8307
8807
|
}, _callee45, this);
|
|
8308
8808
|
}));
|
|
8309
8809
|
|
|
8310
|
-
function partialUpdateMessage(_x60, _x61, _x62
|
|
8810
|
+
function partialUpdateMessage(_x59, _x60, _x61, _x62) {
|
|
8311
8811
|
return _partialUpdateMessage.apply(this, arguments);
|
|
8312
8812
|
}
|
|
8313
8813
|
|
|
@@ -8344,7 +8844,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8344
8844
|
}, _callee46, this);
|
|
8345
8845
|
}));
|
|
8346
8846
|
|
|
8347
|
-
function deleteMessage(
|
|
8847
|
+
function deleteMessage(_x63, _x64) {
|
|
8348
8848
|
return _deleteMessage.apply(this, arguments);
|
|
8349
8849
|
}
|
|
8350
8850
|
|
|
@@ -8372,7 +8872,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8372
8872
|
}, _callee47, this);
|
|
8373
8873
|
}));
|
|
8374
8874
|
|
|
8375
|
-
function getMessage(
|
|
8875
|
+
function getMessage(_x65) {
|
|
8376
8876
|
return _getMessage.apply(this, arguments);
|
|
8377
8877
|
}
|
|
8378
8878
|
|
|
@@ -8381,7 +8881,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8381
8881
|
}, {
|
|
8382
8882
|
key: "getUserAgent",
|
|
8383
8883
|
value: function getUserAgent() {
|
|
8384
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "
|
|
8884
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "5.0.0");
|
|
8385
8885
|
}
|
|
8386
8886
|
}, {
|
|
8387
8887
|
key: "setUserAgent",
|
|
@@ -8395,7 +8895,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8395
8895
|
}, {
|
|
8396
8896
|
key: "_enrichAxiosOptions",
|
|
8397
8897
|
value: function _enrichAxiosOptions() {
|
|
8398
|
-
var _options$headers
|
|
8898
|
+
var _options$headers;
|
|
8399
8899
|
|
|
8400
8900
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
8401
8901
|
params: {},
|
|
@@ -8405,10 +8905,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8405
8905
|
|
|
8406
8906
|
var token = this._getToken();
|
|
8407
8907
|
|
|
8908
|
+
var authorization = token ? {
|
|
8909
|
+
Authorization: token
|
|
8910
|
+
} : undefined;
|
|
8911
|
+
|
|
8408
8912
|
if (!((_options$headers = options.headers) !== null && _options$headers !== void 0 && _options$headers['x-client-request-id'])) {
|
|
8409
|
-
options.headers = {
|
|
8913
|
+
options.headers = _objectSpread(_objectSpread({}, options.headers), {}, {
|
|
8410
8914
|
'x-client-request-id': randomId()
|
|
8411
|
-
};
|
|
8915
|
+
});
|
|
8412
8916
|
}
|
|
8413
8917
|
|
|
8414
8918
|
return _objectSpread({
|
|
@@ -8416,10 +8920,9 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8416
8920
|
user_id: this.userID
|
|
8417
8921
|
}, options.params), {}, {
|
|
8418
8922
|
api_key: this.key,
|
|
8419
|
-
connection_id:
|
|
8923
|
+
connection_id: this._getConnectionID()
|
|
8420
8924
|
}),
|
|
8421
|
-
headers: _objectSpread({
|
|
8422
|
-
Authorization: token,
|
|
8925
|
+
headers: _objectSpread(_objectSpread({}, authorization), {}, {
|
|
8423
8926
|
'stream-auth-type': this.getAuthType(),
|
|
8424
8927
|
'X-Stream-Client': this.getUserAgent()
|
|
8425
8928
|
}, options.headers)
|
|
@@ -8449,6 +8952,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8449
8952
|
}
|
|
8450
8953
|
}, 500);
|
|
8451
8954
|
}
|
|
8955
|
+
/**
|
|
8956
|
+
* encode ws url payload
|
|
8957
|
+
* @private
|
|
8958
|
+
* @returns json string
|
|
8959
|
+
*/
|
|
8960
|
+
|
|
8452
8961
|
}, {
|
|
8453
8962
|
key: "verifyWebhook",
|
|
8454
8963
|
value: function verifyWebhook(requestBody, xSignature) {
|
|
@@ -8589,7 +9098,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8589
9098
|
}, _callee48, this);
|
|
8590
9099
|
}));
|
|
8591
9100
|
|
|
8592
|
-
function sendUserCustomEvent(
|
|
9101
|
+
function sendUserCustomEvent(_x66, _x67) {
|
|
8593
9102
|
return _sendUserCustomEvent.apply(this, arguments);
|
|
8594
9103
|
}
|
|
8595
9104
|
|
|
@@ -8677,7 +9186,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8677
9186
|
}, _callee49, this);
|
|
8678
9187
|
}));
|
|
8679
9188
|
|
|
8680
|
-
function createSegment(
|
|
9189
|
+
function createSegment(_x68) {
|
|
8681
9190
|
return _createSegment.apply(this, arguments);
|
|
8682
9191
|
}
|
|
8683
9192
|
|
|
@@ -8717,7 +9226,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8717
9226
|
}, _callee50, this);
|
|
8718
9227
|
}));
|
|
8719
9228
|
|
|
8720
|
-
function getSegment(
|
|
9229
|
+
function getSegment(_x69) {
|
|
8721
9230
|
return _getSegment.apply(this, arguments);
|
|
8722
9231
|
}
|
|
8723
9232
|
|
|
@@ -8756,7 +9265,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8756
9265
|
}, _callee51, this);
|
|
8757
9266
|
}));
|
|
8758
9267
|
|
|
8759
|
-
function listSegments(
|
|
9268
|
+
function listSegments(_x70) {
|
|
8760
9269
|
return _listSegments.apply(this, arguments);
|
|
8761
9270
|
}
|
|
8762
9271
|
|
|
@@ -8799,7 +9308,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8799
9308
|
}, _callee52, this);
|
|
8800
9309
|
}));
|
|
8801
9310
|
|
|
8802
|
-
function updateSegment(
|
|
9311
|
+
function updateSegment(_x71, _x72) {
|
|
8803
9312
|
return _updateSegment.apply(this, arguments);
|
|
8804
9313
|
}
|
|
8805
9314
|
|
|
@@ -8831,7 +9340,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8831
9340
|
}, _callee53, this);
|
|
8832
9341
|
}));
|
|
8833
9342
|
|
|
8834
|
-
function deleteSegment(
|
|
9343
|
+
function deleteSegment(_x73) {
|
|
8835
9344
|
return _deleteSegment.apply(this, arguments);
|
|
8836
9345
|
}
|
|
8837
9346
|
|
|
@@ -8873,7 +9382,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8873
9382
|
}, _callee54, this);
|
|
8874
9383
|
}));
|
|
8875
9384
|
|
|
8876
|
-
function createCampaign(
|
|
9385
|
+
function createCampaign(_x74) {
|
|
8877
9386
|
return _createCampaign.apply(this, arguments);
|
|
8878
9387
|
}
|
|
8879
9388
|
|
|
@@ -8913,7 +9422,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8913
9422
|
}, _callee55, this);
|
|
8914
9423
|
}));
|
|
8915
9424
|
|
|
8916
|
-
function getCampaign(
|
|
9425
|
+
function getCampaign(_x75) {
|
|
8917
9426
|
return _getCampaign.apply(this, arguments);
|
|
8918
9427
|
}
|
|
8919
9428
|
|
|
@@ -8952,7 +9461,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8952
9461
|
}, _callee56, this);
|
|
8953
9462
|
}));
|
|
8954
9463
|
|
|
8955
|
-
function listCampaigns(
|
|
9464
|
+
function listCampaigns(_x76) {
|
|
8956
9465
|
return _listCampaigns.apply(this, arguments);
|
|
8957
9466
|
}
|
|
8958
9467
|
|
|
@@ -8995,7 +9504,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8995
9504
|
}, _callee57, this);
|
|
8996
9505
|
}));
|
|
8997
9506
|
|
|
8998
|
-
function updateCampaign(
|
|
9507
|
+
function updateCampaign(_x77, _x78) {
|
|
8999
9508
|
return _updateCampaign.apply(this, arguments);
|
|
9000
9509
|
}
|
|
9001
9510
|
|
|
@@ -9027,7 +9536,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9027
9536
|
}, _callee58, this);
|
|
9028
9537
|
}));
|
|
9029
9538
|
|
|
9030
|
-
function deleteCampaign(
|
|
9539
|
+
function deleteCampaign(_x79) {
|
|
9031
9540
|
return _deleteCampaign.apply(this, arguments);
|
|
9032
9541
|
}
|
|
9033
9542
|
|
|
@@ -9071,7 +9580,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9071
9580
|
}, _callee59, this);
|
|
9072
9581
|
}));
|
|
9073
9582
|
|
|
9074
|
-
function scheduleCampaign(
|
|
9583
|
+
function scheduleCampaign(_x80, _x81) {
|
|
9075
9584
|
return _scheduleCampaign.apply(this, arguments);
|
|
9076
9585
|
}
|
|
9077
9586
|
|
|
@@ -9111,7 +9620,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9111
9620
|
}, _callee60, this);
|
|
9112
9621
|
}));
|
|
9113
9622
|
|
|
9114
|
-
function stopCampaign(
|
|
9623
|
+
function stopCampaign(_x82) {
|
|
9115
9624
|
return _stopCampaign.apply(this, arguments);
|
|
9116
9625
|
}
|
|
9117
9626
|
|
|
@@ -9151,7 +9660,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9151
9660
|
}, _callee61, this);
|
|
9152
9661
|
}));
|
|
9153
9662
|
|
|
9154
|
-
function resumeCampaign(
|
|
9663
|
+
function resumeCampaign(_x83) {
|
|
9155
9664
|
return _resumeCampaign.apply(this, arguments);
|
|
9156
9665
|
}
|
|
9157
9666
|
|
|
@@ -9194,7 +9703,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9194
9703
|
}, _callee62, this);
|
|
9195
9704
|
}));
|
|
9196
9705
|
|
|
9197
|
-
function testCampaign(
|
|
9706
|
+
function testCampaign(_x84, _x85) {
|
|
9198
9707
|
return _testCampaign.apply(this, arguments);
|
|
9199
9708
|
}
|
|
9200
9709
|
|
|
@@ -9227,7 +9736,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9227
9736
|
}, _callee63, this);
|
|
9228
9737
|
}));
|
|
9229
9738
|
|
|
9230
|
-
function enrichURL(
|
|
9739
|
+
function enrichURL(_x86) {
|
|
9231
9740
|
return _enrichURL.apply(this, arguments);
|
|
9232
9741
|
}
|
|
9233
9742
|
|
|
@@ -9259,7 +9768,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9259
9768
|
}, _callee64, this);
|
|
9260
9769
|
}));
|
|
9261
9770
|
|
|
9262
|
-
function getTask(
|
|
9771
|
+
function getTask(_x87) {
|
|
9263
9772
|
return _getTask.apply(this, arguments);
|
|
9264
9773
|
}
|
|
9265
9774
|
|
|
@@ -9301,15 +9810,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9301
9810
|
}, _callee65, this);
|
|
9302
9811
|
}));
|
|
9303
9812
|
|
|
9304
|
-
function deleteChannels(
|
|
9813
|
+
function deleteChannels(_x88) {
|
|
9305
9814
|
return _deleteChannels.apply(this, arguments);
|
|
9306
9815
|
}
|
|
9307
9816
|
|
|
9308
9817
|
return deleteChannels;
|
|
9309
9818
|
}()
|
|
9310
|
-
}, {
|
|
9311
|
-
key: "deleteUsers",
|
|
9312
|
-
value:
|
|
9313
9819
|
/**
|
|
9314
9820
|
* deleteUsers - Batch Delete Users
|
|
9315
9821
|
*
|
|
@@ -9318,7 +9824,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9318
9824
|
*
|
|
9319
9825
|
* @return {APIResponse} A task ID
|
|
9320
9826
|
*/
|
|
9321
|
-
|
|
9827
|
+
|
|
9828
|
+
}, {
|
|
9829
|
+
key: "deleteUsers",
|
|
9830
|
+
value: function () {
|
|
9322
9831
|
var _deleteUsers = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee66(user_ids, options) {
|
|
9323
9832
|
return _regeneratorRuntime__default['default'].wrap(function _callee66$(_context66) {
|
|
9324
9833
|
while (1) {
|
|
@@ -9364,7 +9873,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9364
9873
|
}, _callee66, this);
|
|
9365
9874
|
}));
|
|
9366
9875
|
|
|
9367
|
-
function deleteUsers(
|
|
9876
|
+
function deleteUsers(_x89, _x90) {
|
|
9368
9877
|
return _deleteUsers.apply(this, arguments);
|
|
9369
9878
|
}
|
|
9370
9879
|
|
|
@@ -9496,4 +10005,5 @@ exports.encodeBase64 = encodeBase64;
|
|
|
9496
10005
|
exports.isOwnUser = isOwnUser;
|
|
9497
10006
|
exports.isValidEventType = isValidEventType;
|
|
9498
10007
|
exports.logChatPromiseExecution = logChatPromiseExecution;
|
|
10008
|
+
exports.postInsights = postInsights;
|
|
9499
10009
|
//# sourceMappingURL=browser.js.map
|