stream-chat 4.4.3-dev.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -13
- package/dist/browser.es.js +1229 -720
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.full-bundle.min.js +1 -1
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/browser.js +1229 -719
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +1229 -720
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1229 -719
- package/dist/index.js.map +1 -1
- package/dist/types/base64.d.ts.map +1 -1
- package/dist/types/channel.d.ts +19 -15
- package/dist/types/channel.d.ts.map +1 -1
- package/dist/types/channel_state.d.ts +2 -2
- package/dist/types/channel_state.d.ts.map +1 -1
- package/dist/types/client.d.ts +25 -42
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/client_state.d.ts +2 -2
- package/dist/types/client_state.d.ts.map +1 -1
- package/dist/types/connection.d.ts +14 -49
- package/dist/types/connection.d.ts.map +1 -1
- package/dist/types/connection_fallback.d.ts +41 -0
- package/dist/types/connection_fallback.d.ts.map +1 -0
- package/dist/types/errors.d.ts +14 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/insights.d.ts +17 -10
- package/dist/types/insights.d.ts.map +1 -1
- package/dist/types/permissions.d.ts.map +1 -1
- package/dist/types/signing.d.ts +3 -3
- package/dist/types/signing.d.ts.map +1 -1
- package/dist/types/token_manager.d.ts +2 -2
- package/dist/types/token_manager.d.ts.map +1 -1
- package/dist/types/types.d.ts +94 -88
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +13 -3
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/base64.ts +1 -4
- package/src/channel.ts +133 -461
- package/src/channel_state.ts +31 -158
- package/src/client.ts +291 -712
- package/src/client_state.ts +2 -2
- package/src/connection.ts +146 -395
- package/src/connection_fallback.ts +205 -0
- package/src/errors.ts +58 -0
- package/src/insights.ts +38 -32
- package/src/permissions.ts +3 -24
- package/src/signing.ts +6 -17
- package/src/token_manager.ts +6 -18
- package/src/types.ts +268 -512
- package/src/utils.ts +58 -24
- package/CHANGELOG.md +0 -844
package/dist/index.es.js
CHANGED
|
@@ -89,9 +89,9 @@ var decodeBase64 = function decodeBase64(s) {
|
|
|
89
89
|
return r;
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
-
function ownKeys$
|
|
92
|
+
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; }
|
|
93
93
|
|
|
94
|
-
function _objectSpread$
|
|
94
|
+
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(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; }
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
97
|
* ChannelState - A container class for the channel state.
|
|
@@ -159,7 +159,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
159
159
|
var m = messages[i];
|
|
160
160
|
|
|
161
161
|
if (((_m$user = m.user) === null || _m$user === void 0 ? void 0 : _m$user.id) === user.id) {
|
|
162
|
-
messages[i] = _objectSpread$
|
|
162
|
+
messages[i] = _objectSpread$7(_objectSpread$7({}, m), {}, {
|
|
163
163
|
user: user
|
|
164
164
|
});
|
|
165
165
|
}
|
|
@@ -212,7 +212,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
212
212
|
user: m.user
|
|
213
213
|
};
|
|
214
214
|
} else {
|
|
215
|
-
messages[i] = _objectSpread$
|
|
215
|
+
messages[i] = _objectSpread$7(_objectSpread$7({}, m), {}, {
|
|
216
216
|
type: 'deleted',
|
|
217
217
|
deleted_at: user.deleted_at
|
|
218
218
|
});
|
|
@@ -280,7 +280,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
280
280
|
}, {
|
|
281
281
|
key: "formatMessage",
|
|
282
282
|
value: function formatMessage(message) {
|
|
283
|
-
return _objectSpread$
|
|
283
|
+
return _objectSpread$7(_objectSpread$7({}, message), {}, {
|
|
284
284
|
/**
|
|
285
285
|
* @deprecated please use `html`
|
|
286
286
|
*/
|
|
@@ -470,7 +470,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
470
470
|
var parseMessage = function parseMessage(m) {
|
|
471
471
|
var _m$pinned_at, _m$updated_at;
|
|
472
472
|
|
|
473
|
-
return _objectSpread$
|
|
473
|
+
return _objectSpread$7(_objectSpread$7({}, m), {}, {
|
|
474
474
|
created_at: m.created_at.toString(),
|
|
475
475
|
pinned_at: (_m$pinned_at = m.pinned_at) === null || _m$pinned_at === void 0 ? void 0 : _m$pinned_at.toString(),
|
|
476
476
|
updated_at: (_m$updated_at = m.updated_at) === null || _m$updated_at === void 0 ? void 0 : _m$updated_at.toString()
|
|
@@ -480,8 +480,8 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
480
480
|
var updatedMessages = this.messages.filter(function (msg) {
|
|
481
481
|
return msg.quoted_message_id === message.id;
|
|
482
482
|
}).map(parseMessage).map(function (msg) {
|
|
483
|
-
return _objectSpread$
|
|
484
|
-
quoted_message: _objectSpread$
|
|
483
|
+
return _objectSpread$7(_objectSpread$7({}, msg), {}, {
|
|
484
|
+
quoted_message: _objectSpread$7(_objectSpread$7({}, message), {}, {
|
|
485
485
|
attachments: []
|
|
486
486
|
})
|
|
487
487
|
});
|
|
@@ -701,9 +701,9 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
701
701
|
return ChannelState;
|
|
702
702
|
}();
|
|
703
703
|
|
|
704
|
-
function ownKeys$
|
|
704
|
+
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; }
|
|
705
705
|
|
|
706
|
-
function _objectSpread$
|
|
706
|
+
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(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; }
|
|
707
707
|
|
|
708
708
|
var EVENT_MAP = {
|
|
709
709
|
'channel.created': true,
|
|
@@ -750,7 +750,7 @@ var EVENT_MAP = {
|
|
|
750
750
|
'connection.recovered': true
|
|
751
751
|
};
|
|
752
752
|
|
|
753
|
-
var IS_VALID_EVENT_MAP_TYPE = _objectSpread$
|
|
753
|
+
var IS_VALID_EVENT_MAP_TYPE = _objectSpread$6(_objectSpread$6({}, EVENT_MAP), {}, {
|
|
754
754
|
all: true
|
|
755
755
|
});
|
|
756
756
|
|
|
@@ -758,7 +758,7 @@ var isValidEventType = function isValidEventType(eventType) {
|
|
|
758
758
|
return IS_VALID_EVENT_MAP_TYPE[eventType] || false;
|
|
759
759
|
};
|
|
760
760
|
|
|
761
|
-
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) {
|
|
761
|
+
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; } } }; }
|
|
762
762
|
|
|
763
763
|
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); }
|
|
764
764
|
|
|
@@ -934,12 +934,55 @@ function getRandomBytes(length) {
|
|
|
934
934
|
function convertErrorToJson(err) {
|
|
935
935
|
var jsonObj = {};
|
|
936
936
|
if (!err) return jsonObj;
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
937
|
+
|
|
938
|
+
try {
|
|
939
|
+
Object.getOwnPropertyNames(err).forEach(function (key) {
|
|
940
|
+
jsonObj[key] = Object.getOwnPropertyDescriptor(err, key);
|
|
941
|
+
});
|
|
942
|
+
} catch (_) {
|
|
943
|
+
return {
|
|
944
|
+
error: 'failed to serialize the error'
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
|
|
941
948
|
return jsonObj;
|
|
942
949
|
}
|
|
950
|
+
/**
|
|
951
|
+
* isOnline safely return the navigator.online value for browser env
|
|
952
|
+
* if navigator is not in global object, it always return true
|
|
953
|
+
*/
|
|
954
|
+
|
|
955
|
+
function isOnline() {
|
|
956
|
+
var nav = typeof navigator !== 'undefined' ? navigator : typeof window !== 'undefined' && window.navigator ? window.navigator : undefined;
|
|
957
|
+
|
|
958
|
+
if (!nav) {
|
|
959
|
+
console.warn('isOnline failed to access window.navigator and assume browser is online');
|
|
960
|
+
return true;
|
|
961
|
+
} // RN navigator has undefined for onLine
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
if (typeof nav.onLine !== 'boolean') {
|
|
965
|
+
return true;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
return nav.onLine;
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* listenForConnectionChanges - Adds an event listener fired on browser going online or offline
|
|
972
|
+
*/
|
|
973
|
+
|
|
974
|
+
function addConnectionEventListeners(cb) {
|
|
975
|
+
if (typeof window !== 'undefined' && window.addEventListener) {
|
|
976
|
+
window.addEventListener('offline', cb);
|
|
977
|
+
window.addEventListener('online', cb);
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
function removeConnectionEventListeners(cb) {
|
|
981
|
+
if (typeof window !== 'undefined' && window.removeEventListener) {
|
|
982
|
+
window.removeEventListener('offline', cb);
|
|
983
|
+
window.removeEventListener('online', cb);
|
|
984
|
+
}
|
|
985
|
+
}
|
|
943
986
|
|
|
944
987
|
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; } } }; }
|
|
945
988
|
|
|
@@ -947,9 +990,9 @@ function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o
|
|
|
947
990
|
|
|
948
991
|
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; }
|
|
949
992
|
|
|
950
|
-
function ownKeys$
|
|
993
|
+
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; }
|
|
951
994
|
|
|
952
|
-
function _objectSpread$
|
|
995
|
+
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(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; }
|
|
953
996
|
|
|
954
997
|
/**
|
|
955
998
|
* Channel - The Channel class manages it's own state.
|
|
@@ -1069,7 +1112,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1069
1112
|
|
|
1070
1113
|
this.data = data; // this._data is used for the requests...
|
|
1071
1114
|
|
|
1072
|
-
this._data = _objectSpread$
|
|
1115
|
+
this._data = _objectSpread$5({}, data);
|
|
1073
1116
|
this.cid = "".concat(type, ":").concat(id);
|
|
1074
1117
|
this.listeners = {}; // perhaps the state variable should be private
|
|
1075
1118
|
|
|
@@ -1127,7 +1170,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1127
1170
|
switch (_context2.prev = _context2.next) {
|
|
1128
1171
|
case 0:
|
|
1129
1172
|
_context2.next = 2;
|
|
1130
|
-
return this.getClient().post(this._channelURL() + '/message', _objectSpread$
|
|
1173
|
+
return this.getClient().post(this._channelURL() + '/message', _objectSpread$5({
|
|
1131
1174
|
message: message
|
|
1132
1175
|
}, options));
|
|
1133
1176
|
|
|
@@ -1246,7 +1289,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1246
1289
|
|
|
1247
1290
|
case 3:
|
|
1248
1291
|
// Return a list of channels
|
|
1249
|
-
payload = _objectSpread$
|
|
1292
|
+
payload = _objectSpread$5(_objectSpread$5({
|
|
1250
1293
|
filter_conditions: {
|
|
1251
1294
|
cid: this.cid
|
|
1252
1295
|
}
|
|
@@ -1343,7 +1386,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1343
1386
|
|
|
1344
1387
|
_context5.next = 6;
|
|
1345
1388
|
return this.getClient().get(this.getClient().baseURL + '/members', {
|
|
1346
|
-
payload: _objectSpread$
|
|
1389
|
+
payload: _objectSpread$5({
|
|
1347
1390
|
type: type,
|
|
1348
1391
|
id: id,
|
|
1349
1392
|
members: members,
|
|
@@ -1404,7 +1447,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1404
1447
|
|
|
1405
1448
|
case 4:
|
|
1406
1449
|
_context6.next = 6;
|
|
1407
|
-
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(messageID, "/reaction"), _objectSpread$
|
|
1450
|
+
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(messageID, "/reaction"), _objectSpread$5({
|
|
1408
1451
|
reaction: reaction
|
|
1409
1452
|
}, options));
|
|
1410
1453
|
|
|
@@ -1459,7 +1502,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1459
1502
|
*
|
|
1460
1503
|
* @param {ChannelData<ChannelType>} channelData The object to update the custom properties of this channel with
|
|
1461
1504
|
* @param {Message<AttachmentType, MessageType, UserType>} [updateMessage] Optional message object for channel members notification
|
|
1462
|
-
* @param {
|
|
1505
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1463
1506
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1464
1507
|
*/
|
|
1465
1508
|
|
|
@@ -1485,7 +1528,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1485
1528
|
delete channelData[key];
|
|
1486
1529
|
});
|
|
1487
1530
|
_context7.next = 7;
|
|
1488
|
-
return this._update(_objectSpread$
|
|
1531
|
+
return this._update(_objectSpread$5({
|
|
1489
1532
|
message: updateMessage,
|
|
1490
1533
|
data: channelData
|
|
1491
1534
|
}, options));
|
|
@@ -1658,25 +1701,28 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1658
1701
|
}()
|
|
1659
1702
|
/**
|
|
1660
1703
|
* truncate - Removes all messages from the channel
|
|
1661
|
-
*
|
|
1662
|
-
* @return {Promise<TruncateChannelAPIResponse<ChannelType, CommandType, UserType>>} The server response
|
|
1704
|
+
* @param {TruncateOptions<AttachmentType, MessageType, UserType>} [options] Defines truncation options
|
|
1705
|
+
* @return {Promise<TruncateChannelAPIResponse<ChannelType, CommandType, UserType, MessageType, ReactionType>>} The server response
|
|
1663
1706
|
*/
|
|
1664
1707
|
|
|
1665
1708
|
}, {
|
|
1666
1709
|
key: "truncate",
|
|
1667
1710
|
value: function () {
|
|
1668
1711
|
var _truncate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
|
1712
|
+
var options,
|
|
1713
|
+
_args12 = arguments;
|
|
1669
1714
|
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
1670
1715
|
while (1) {
|
|
1671
1716
|
switch (_context12.prev = _context12.next) {
|
|
1672
1717
|
case 0:
|
|
1673
|
-
|
|
1674
|
-
|
|
1718
|
+
options = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
|
|
1719
|
+
_context12.next = 3;
|
|
1720
|
+
return this.getClient().post(this._channelURL() + '/truncate', options);
|
|
1675
1721
|
|
|
1676
|
-
case
|
|
1722
|
+
case 3:
|
|
1677
1723
|
return _context12.abrupt("return", _context12.sent);
|
|
1678
1724
|
|
|
1679
|
-
case
|
|
1725
|
+
case 4:
|
|
1680
1726
|
case "end":
|
|
1681
1727
|
return _context12.stop();
|
|
1682
1728
|
}
|
|
@@ -1710,7 +1756,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1710
1756
|
case 0:
|
|
1711
1757
|
options = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
|
|
1712
1758
|
_context13.next = 3;
|
|
1713
|
-
return this._update(_objectSpread$
|
|
1759
|
+
return this._update(_objectSpread$5({
|
|
1714
1760
|
accept_invite: true
|
|
1715
1761
|
}, options));
|
|
1716
1762
|
|
|
@@ -1751,7 +1797,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1751
1797
|
case 0:
|
|
1752
1798
|
options = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
|
|
1753
1799
|
_context14.next = 3;
|
|
1754
|
-
return this._update(_objectSpread$
|
|
1800
|
+
return this._update(_objectSpread$5({
|
|
1755
1801
|
reject_invite: true
|
|
1756
1802
|
}, options));
|
|
1757
1803
|
|
|
@@ -1777,6 +1823,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1777
1823
|
*
|
|
1778
1824
|
* @param {{user_id: string, channel_role?: Role}[]} members An array of members to add to the channel
|
|
1779
1825
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1826
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1780
1827
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1781
1828
|
*/
|
|
1782
1829
|
|
|
@@ -1784,20 +1831,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1784
1831
|
key: "addMembers",
|
|
1785
1832
|
value: function () {
|
|
1786
1833
|
var _addMembers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(members, message) {
|
|
1834
|
+
var options,
|
|
1835
|
+
_args15 = arguments;
|
|
1787
1836
|
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
1788
1837
|
while (1) {
|
|
1789
1838
|
switch (_context15.prev = _context15.next) {
|
|
1790
1839
|
case 0:
|
|
1791
|
-
|
|
1792
|
-
|
|
1840
|
+
options = _args15.length > 2 && _args15[2] !== undefined ? _args15[2] : {};
|
|
1841
|
+
_context15.next = 3;
|
|
1842
|
+
return this._update(_objectSpread$5({
|
|
1793
1843
|
add_members: members,
|
|
1794
1844
|
message: message
|
|
1795
|
-
});
|
|
1845
|
+
}, options));
|
|
1796
1846
|
|
|
1797
|
-
case
|
|
1847
|
+
case 3:
|
|
1798
1848
|
return _context15.abrupt("return", _context15.sent);
|
|
1799
1849
|
|
|
1800
|
-
case
|
|
1850
|
+
case 4:
|
|
1801
1851
|
case "end":
|
|
1802
1852
|
return _context15.stop();
|
|
1803
1853
|
}
|
|
@@ -1816,6 +1866,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1816
1866
|
*
|
|
1817
1867
|
* @param {string[]} members An array of member identifiers
|
|
1818
1868
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1869
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1819
1870
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1820
1871
|
*/
|
|
1821
1872
|
|
|
@@ -1823,20 +1874,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1823
1874
|
key: "addModerators",
|
|
1824
1875
|
value: function () {
|
|
1825
1876
|
var _addModerators = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(members, message) {
|
|
1877
|
+
var options,
|
|
1878
|
+
_args16 = arguments;
|
|
1826
1879
|
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
1827
1880
|
while (1) {
|
|
1828
1881
|
switch (_context16.prev = _context16.next) {
|
|
1829
1882
|
case 0:
|
|
1830
|
-
|
|
1831
|
-
|
|
1883
|
+
options = _args16.length > 2 && _args16[2] !== undefined ? _args16[2] : {};
|
|
1884
|
+
_context16.next = 3;
|
|
1885
|
+
return this._update(_objectSpread$5({
|
|
1832
1886
|
add_moderators: members,
|
|
1833
1887
|
message: message
|
|
1834
|
-
});
|
|
1888
|
+
}, options));
|
|
1835
1889
|
|
|
1836
|
-
case
|
|
1890
|
+
case 3:
|
|
1837
1891
|
return _context16.abrupt("return", _context16.sent);
|
|
1838
1892
|
|
|
1839
|
-
case
|
|
1893
|
+
case 4:
|
|
1840
1894
|
case "end":
|
|
1841
1895
|
return _context16.stop();
|
|
1842
1896
|
}
|
|
@@ -1855,6 +1909,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1855
1909
|
*
|
|
1856
1910
|
* @param {{channel_role: Role, user_id: string}[]} roles List of role assignments
|
|
1857
1911
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1912
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1858
1913
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1859
1914
|
*/
|
|
1860
1915
|
|
|
@@ -1862,20 +1917,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1862
1917
|
key: "assignRoles",
|
|
1863
1918
|
value: function () {
|
|
1864
1919
|
var _assignRoles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(roles, message) {
|
|
1920
|
+
var options,
|
|
1921
|
+
_args17 = arguments;
|
|
1865
1922
|
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1866
1923
|
while (1) {
|
|
1867
1924
|
switch (_context17.prev = _context17.next) {
|
|
1868
1925
|
case 0:
|
|
1869
|
-
|
|
1870
|
-
|
|
1926
|
+
options = _args17.length > 2 && _args17[2] !== undefined ? _args17[2] : {};
|
|
1927
|
+
_context17.next = 3;
|
|
1928
|
+
return this._update(_objectSpread$5({
|
|
1871
1929
|
assign_roles: roles,
|
|
1872
1930
|
message: message
|
|
1873
|
-
});
|
|
1931
|
+
}, options));
|
|
1874
1932
|
|
|
1875
|
-
case
|
|
1933
|
+
case 3:
|
|
1876
1934
|
return _context17.abrupt("return", _context17.sent);
|
|
1877
1935
|
|
|
1878
|
-
case
|
|
1936
|
+
case 4:
|
|
1879
1937
|
case "end":
|
|
1880
1938
|
return _context17.stop();
|
|
1881
1939
|
}
|
|
@@ -1894,6 +1952,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1894
1952
|
*
|
|
1895
1953
|
* @param {{user_id: string, channel_role?: Role}[]} members An array of members to invite to the channel
|
|
1896
1954
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1955
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1897
1956
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1898
1957
|
*/
|
|
1899
1958
|
|
|
@@ -1901,20 +1960,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1901
1960
|
key: "inviteMembers",
|
|
1902
1961
|
value: function () {
|
|
1903
1962
|
var _inviteMembers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(members, message) {
|
|
1963
|
+
var options,
|
|
1964
|
+
_args18 = arguments;
|
|
1904
1965
|
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1905
1966
|
while (1) {
|
|
1906
1967
|
switch (_context18.prev = _context18.next) {
|
|
1907
1968
|
case 0:
|
|
1908
|
-
|
|
1909
|
-
|
|
1969
|
+
options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
|
|
1970
|
+
_context18.next = 3;
|
|
1971
|
+
return this._update(_objectSpread$5({
|
|
1910
1972
|
invites: members,
|
|
1911
1973
|
message: message
|
|
1912
|
-
});
|
|
1974
|
+
}, options));
|
|
1913
1975
|
|
|
1914
|
-
case
|
|
1976
|
+
case 3:
|
|
1915
1977
|
return _context18.abrupt("return", _context18.sent);
|
|
1916
1978
|
|
|
1917
|
-
case
|
|
1979
|
+
case 4:
|
|
1918
1980
|
case "end":
|
|
1919
1981
|
return _context18.stop();
|
|
1920
1982
|
}
|
|
@@ -1933,6 +1995,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1933
1995
|
*
|
|
1934
1996
|
* @param {string[]} members An array of member identifiers
|
|
1935
1997
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1998
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1936
1999
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1937
2000
|
*/
|
|
1938
2001
|
|
|
@@ -1940,20 +2003,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1940
2003
|
key: "removeMembers",
|
|
1941
2004
|
value: function () {
|
|
1942
2005
|
var _removeMembers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(members, message) {
|
|
2006
|
+
var options,
|
|
2007
|
+
_args19 = arguments;
|
|
1943
2008
|
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
1944
2009
|
while (1) {
|
|
1945
2010
|
switch (_context19.prev = _context19.next) {
|
|
1946
2011
|
case 0:
|
|
1947
|
-
|
|
1948
|
-
|
|
2012
|
+
options = _args19.length > 2 && _args19[2] !== undefined ? _args19[2] : {};
|
|
2013
|
+
_context19.next = 3;
|
|
2014
|
+
return this._update(_objectSpread$5({
|
|
1949
2015
|
remove_members: members,
|
|
1950
2016
|
message: message
|
|
1951
|
-
});
|
|
2017
|
+
}, options));
|
|
1952
2018
|
|
|
1953
|
-
case
|
|
2019
|
+
case 3:
|
|
1954
2020
|
return _context19.abrupt("return", _context19.sent);
|
|
1955
2021
|
|
|
1956
|
-
case
|
|
2022
|
+
case 4:
|
|
1957
2023
|
case "end":
|
|
1958
2024
|
return _context19.stop();
|
|
1959
2025
|
}
|
|
@@ -1972,6 +2038,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1972
2038
|
*
|
|
1973
2039
|
* @param {string[]} members An array of member identifiers
|
|
1974
2040
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
2041
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1975
2042
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1976
2043
|
*/
|
|
1977
2044
|
|
|
@@ -1979,20 +2046,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1979
2046
|
key: "demoteModerators",
|
|
1980
2047
|
value: function () {
|
|
1981
2048
|
var _demoteModerators = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(members, message) {
|
|
2049
|
+
var options,
|
|
2050
|
+
_args20 = arguments;
|
|
1982
2051
|
return _regeneratorRuntime.wrap(function _callee20$(_context20) {
|
|
1983
2052
|
while (1) {
|
|
1984
2053
|
switch (_context20.prev = _context20.next) {
|
|
1985
2054
|
case 0:
|
|
1986
|
-
|
|
1987
|
-
|
|
2055
|
+
options = _args20.length > 2 && _args20[2] !== undefined ? _args20[2] : {};
|
|
2056
|
+
_context20.next = 3;
|
|
2057
|
+
return this._update(_objectSpread$5({
|
|
1988
2058
|
demote_moderators: members,
|
|
1989
2059
|
message: message
|
|
1990
|
-
});
|
|
2060
|
+
}, options));
|
|
1991
2061
|
|
|
1992
|
-
case
|
|
2062
|
+
case 3:
|
|
1993
2063
|
return _context20.abrupt("return", _context20.sent);
|
|
1994
2064
|
|
|
1995
|
-
case
|
|
2065
|
+
case 4:
|
|
1996
2066
|
case "end":
|
|
1997
2067
|
return _context20.stop();
|
|
1998
2068
|
}
|
|
@@ -2069,7 +2139,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2069
2139
|
case 0:
|
|
2070
2140
|
opts = _args22.length > 0 && _args22[0] !== undefined ? _args22[0] : {};
|
|
2071
2141
|
_context22.next = 3;
|
|
2072
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$
|
|
2142
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$5({
|
|
2073
2143
|
channel_cid: this.cid
|
|
2074
2144
|
}, opts));
|
|
2075
2145
|
|
|
@@ -2111,7 +2181,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2111
2181
|
case 0:
|
|
2112
2182
|
opts = _args23.length > 0 && _args23[0] !== undefined ? _args23[0] : {};
|
|
2113
2183
|
_context23.next = 3;
|
|
2114
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$
|
|
2184
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$5({
|
|
2115
2185
|
channel_cid: this.cid
|
|
2116
2186
|
}, opts));
|
|
2117
2187
|
|
|
@@ -2320,7 +2390,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2320
2390
|
|
|
2321
2391
|
case 4:
|
|
2322
2392
|
_context26.next = 6;
|
|
2323
|
-
return this.getClient().post(this._channelURL() + '/read', _objectSpread$
|
|
2393
|
+
return this.getClient().post(this._channelURL() + '/read', _objectSpread$5({}, data));
|
|
2324
2394
|
|
|
2325
2395
|
case 6:
|
|
2326
2396
|
return _context26.abrupt("return", _context26.sent);
|
|
@@ -2388,7 +2458,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2388
2458
|
defaultOptions.watch = false;
|
|
2389
2459
|
}
|
|
2390
2460
|
|
|
2391
|
-
combined = _objectSpread$
|
|
2461
|
+
combined = _objectSpread$5(_objectSpread$5({}, defaultOptions), options);
|
|
2392
2462
|
_context27.next = 7;
|
|
2393
2463
|
return this.query(combined);
|
|
2394
2464
|
|
|
@@ -2479,7 +2549,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2479
2549
|
switch (_context29.prev = _context29.next) {
|
|
2480
2550
|
case 0:
|
|
2481
2551
|
_context29.next = 2;
|
|
2482
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(parent_id, "/replies"), _objectSpread$
|
|
2552
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(parent_id, "/replies"), _objectSpread$5({}, options));
|
|
2483
2553
|
|
|
2484
2554
|
case 2:
|
|
2485
2555
|
data = _context29.sent;
|
|
@@ -2517,7 +2587,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2517
2587
|
}, {
|
|
2518
2588
|
key: "getReactions",
|
|
2519
2589
|
value: function getReactions(message_id, options) {
|
|
2520
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(message_id, "/reactions"), _objectSpread$
|
|
2590
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(message_id, "/reactions"), _objectSpread$5({}, options));
|
|
2521
2591
|
}
|
|
2522
2592
|
/**
|
|
2523
2593
|
* getMessagesById - Retrieves a list of messages by ID
|
|
@@ -2649,7 +2719,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2649
2719
|
}
|
|
2650
2720
|
|
|
2651
2721
|
_context30.next = 6;
|
|
2652
|
-
return this.getClient().post(queryURL + '/query', _objectSpread$
|
|
2722
|
+
return this.getClient().post(queryURL + '/query', _objectSpread$5({
|
|
2653
2723
|
data: this._data,
|
|
2654
2724
|
state: true
|
|
2655
2725
|
}, options));
|
|
@@ -2720,7 +2790,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2720
2790
|
this._checkInitialized();
|
|
2721
2791
|
|
|
2722
2792
|
_context31.next = 3;
|
|
2723
|
-
return this.getClient().banUser(targetUserID, _objectSpread$
|
|
2793
|
+
return this.getClient().banUser(targetUserID, _objectSpread$5(_objectSpread$5({}, options), {}, {
|
|
2724
2794
|
type: this.type,
|
|
2725
2795
|
id: this.id
|
|
2726
2796
|
}));
|
|
@@ -2892,7 +2962,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2892
2962
|
this._checkInitialized();
|
|
2893
2963
|
|
|
2894
2964
|
_context35.next = 3;
|
|
2895
|
-
return this.getClient().shadowBan(targetUserID, _objectSpread$
|
|
2965
|
+
return this.getClient().shadowBan(targetUserID, _objectSpread$5(_objectSpread$5({}, options), {}, {
|
|
2896
2966
|
type: this.type,
|
|
2897
2967
|
id: this.id
|
|
2898
2968
|
}));
|
|
@@ -3305,7 +3375,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3305
3375
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
3306
3376
|
var read = _step3.value;
|
|
3307
3377
|
|
|
3308
|
-
var parsedRead = _objectSpread$
|
|
3378
|
+
var parsedRead = _objectSpread$5(_objectSpread$5({}, read), {}, {
|
|
3309
3379
|
last_read: new Date(read.last_read)
|
|
3310
3380
|
});
|
|
3311
3381
|
|
|
@@ -3432,9 +3502,9 @@ var ClientState = /*#__PURE__*/function () {
|
|
|
3432
3502
|
return ClientState;
|
|
3433
3503
|
}();
|
|
3434
3504
|
|
|
3435
|
-
function ownKeys$
|
|
3505
|
+
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; }
|
|
3436
3506
|
|
|
3437
|
-
function _objectSpread$
|
|
3507
|
+
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(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; }
|
|
3438
3508
|
var InsightMetrics = function InsightMetrics() {
|
|
3439
3509
|
_classCallCheck(this, InsightMetrics);
|
|
3440
3510
|
|
|
@@ -3451,32 +3521,94 @@ var InsightMetrics = function InsightMetrics() {
|
|
|
3451
3521
|
this.wsConsecutiveFailures = 0;
|
|
3452
3522
|
this.instanceClientId = randomId();
|
|
3453
3523
|
};
|
|
3524
|
+
/**
|
|
3525
|
+
* postInsights is not supposed to be used by end users directly within chat application, and thus is kept isolated
|
|
3526
|
+
* from all the client/connection code/logic.
|
|
3527
|
+
*
|
|
3528
|
+
* @param insightType
|
|
3529
|
+
* @param insights
|
|
3530
|
+
*/
|
|
3531
|
+
|
|
3532
|
+
var postInsights = /*#__PURE__*/function () {
|
|
3533
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(insightType, insights) {
|
|
3534
|
+
var maxAttempts, i;
|
|
3535
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
3536
|
+
while (1) {
|
|
3537
|
+
switch (_context.prev = _context.next) {
|
|
3538
|
+
case 0:
|
|
3539
|
+
maxAttempts = 3;
|
|
3540
|
+
i = 0;
|
|
3541
|
+
|
|
3542
|
+
case 2:
|
|
3543
|
+
if (!(i < maxAttempts)) {
|
|
3544
|
+
_context.next = 17;
|
|
3545
|
+
break;
|
|
3546
|
+
}
|
|
3547
|
+
|
|
3548
|
+
_context.prev = 3;
|
|
3549
|
+
_context.next = 6;
|
|
3550
|
+
return axios.post("https://chat-insights.getstream.io/insights/".concat(insightType), insights);
|
|
3551
|
+
|
|
3552
|
+
case 6:
|
|
3553
|
+
_context.next = 13;
|
|
3554
|
+
break;
|
|
3555
|
+
|
|
3556
|
+
case 8:
|
|
3557
|
+
_context.prev = 8;
|
|
3558
|
+
_context.t0 = _context["catch"](3);
|
|
3559
|
+
_context.next = 12;
|
|
3560
|
+
return sleep((i + 1) * 3000);
|
|
3561
|
+
|
|
3562
|
+
case 12:
|
|
3563
|
+
return _context.abrupt("continue", 14);
|
|
3564
|
+
|
|
3565
|
+
case 13:
|
|
3566
|
+
return _context.abrupt("break", 17);
|
|
3567
|
+
|
|
3568
|
+
case 14:
|
|
3569
|
+
i++;
|
|
3570
|
+
_context.next = 2;
|
|
3571
|
+
break;
|
|
3572
|
+
|
|
3573
|
+
case 17:
|
|
3574
|
+
case "end":
|
|
3575
|
+
return _context.stop();
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3578
|
+
}, _callee, null, [[3, 8]]);
|
|
3579
|
+
}));
|
|
3580
|
+
|
|
3581
|
+
return function postInsights(_x, _x2) {
|
|
3582
|
+
return _ref.apply(this, arguments);
|
|
3583
|
+
};
|
|
3584
|
+
}();
|
|
3454
3585
|
function buildWsFatalInsight(connection, event) {
|
|
3455
|
-
return _objectSpread$
|
|
3586
|
+
return _objectSpread$4(_objectSpread$4({}, event), buildWsBaseInsight(connection));
|
|
3456
3587
|
}
|
|
3457
3588
|
|
|
3458
3589
|
function buildWsBaseInsight(connection) {
|
|
3459
3590
|
var _connection$ws, _navigator, _navigator2;
|
|
3460
3591
|
|
|
3592
|
+
var client = connection.client;
|
|
3461
3593
|
return {
|
|
3462
3594
|
ready_state: (_connection$ws = connection.ws) === null || _connection$ws === void 0 ? void 0 : _connection$ws.readyState,
|
|
3463
|
-
url: connection._buildUrl(
|
|
3464
|
-
api_key:
|
|
3465
|
-
start_ts:
|
|
3595
|
+
url: connection._buildUrl(),
|
|
3596
|
+
api_key: client.key,
|
|
3597
|
+
start_ts: client.insightMetrics.connectionStartTimestamp,
|
|
3466
3598
|
end_ts: new Date().getTime(),
|
|
3467
|
-
auth_type:
|
|
3468
|
-
token:
|
|
3469
|
-
user_id:
|
|
3470
|
-
user_details:
|
|
3471
|
-
device:
|
|
3599
|
+
auth_type: client.getAuthType(),
|
|
3600
|
+
token: client.tokenManager.token,
|
|
3601
|
+
user_id: client.userID,
|
|
3602
|
+
user_details: client._user,
|
|
3603
|
+
device: client.options.device,
|
|
3472
3604
|
client_id: connection.connectionID,
|
|
3473
3605
|
ws_details: connection.ws,
|
|
3474
|
-
ws_consecutive_failures:
|
|
3475
|
-
ws_total_failures:
|
|
3606
|
+
ws_consecutive_failures: client.insightMetrics.wsConsecutiveFailures,
|
|
3607
|
+
ws_total_failures: client.insightMetrics.wsTotalFailures,
|
|
3476
3608
|
request_id: connection.requestID,
|
|
3477
3609
|
online: typeof navigator !== 'undefined' ? (_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.onLine : null,
|
|
3478
3610
|
user_agent: typeof navigator !== 'undefined' ? (_navigator2 = navigator) === null || _navigator2 === void 0 ? void 0 : _navigator2.userAgent : null,
|
|
3479
|
-
instance_client_id:
|
|
3611
|
+
instance_client_id: client.insightMetrics.instanceClientId
|
|
3480
3612
|
};
|
|
3481
3613
|
}
|
|
3482
3614
|
|
|
@@ -3484,6 +3616,10 @@ function buildWsSuccessAfterFailureInsight(connection) {
|
|
|
3484
3616
|
return buildWsBaseInsight(connection);
|
|
3485
3617
|
}
|
|
3486
3618
|
|
|
3619
|
+
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; }
|
|
3620
|
+
|
|
3621
|
+
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(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; }
|
|
3622
|
+
|
|
3487
3623
|
// Type guards to check WebSocket error type
|
|
3488
3624
|
var isCloseEvent = function isCloseEvent(res) {
|
|
3489
3625
|
return res.code !== undefined;
|
|
@@ -3492,7 +3628,6 @@ var isCloseEvent = function isCloseEvent(res) {
|
|
|
3492
3628
|
var isErrorEvent = function isErrorEvent(res) {
|
|
3493
3629
|
return res.error !== undefined;
|
|
3494
3630
|
};
|
|
3495
|
-
|
|
3496
3631
|
/**
|
|
3497
3632
|
* StableWSConnection - A WS connection that reconnects upon failure.
|
|
3498
3633
|
* - the browser will sometimes report that you're online or offline
|
|
@@ -3510,53 +3645,19 @@ var isErrorEvent = function isErrorEvent(res) {
|
|
|
3510
3645
|
* - state can be recovered by querying the channel again
|
|
3511
3646
|
* - if the servers fails to publish a message to the client, the WS connection is destroyed
|
|
3512
3647
|
*/
|
|
3648
|
+
|
|
3649
|
+
|
|
3513
3650
|
var StableWSConnection = /*#__PURE__*/function () {
|
|
3651
|
+
// global from constructor
|
|
3652
|
+
// local vars
|
|
3514
3653
|
function StableWSConnection(_ref) {
|
|
3515
3654
|
var _this = this;
|
|
3516
3655
|
|
|
3517
|
-
var
|
|
3518
|
-
authType = _ref.authType,
|
|
3519
|
-
clientID = _ref.clientID,
|
|
3520
|
-
eventCallback = _ref.eventCallback,
|
|
3521
|
-
logger = _ref.logger,
|
|
3522
|
-
messageCallback = _ref.messageCallback,
|
|
3523
|
-
recoverCallback = _ref.recoverCallback,
|
|
3524
|
-
tokenManager = _ref.tokenManager,
|
|
3525
|
-
user = _ref.user,
|
|
3526
|
-
userAgent = _ref.userAgent,
|
|
3527
|
-
userID = _ref.userID,
|
|
3528
|
-
wsBaseURL = _ref.wsBaseURL,
|
|
3529
|
-
device = _ref.device,
|
|
3530
|
-
postInsights = _ref.postInsights,
|
|
3531
|
-
insightMetrics = _ref.insightMetrics;
|
|
3656
|
+
var client = _ref.client;
|
|
3532
3657
|
|
|
3533
3658
|
_classCallCheck(this, StableWSConnection);
|
|
3534
3659
|
|
|
3535
|
-
_defineProperty(this, "
|
|
3536
|
-
|
|
3537
|
-
_defineProperty(this, "authType", void 0);
|
|
3538
|
-
|
|
3539
|
-
_defineProperty(this, "clientID", void 0);
|
|
3540
|
-
|
|
3541
|
-
_defineProperty(this, "eventCallback", void 0);
|
|
3542
|
-
|
|
3543
|
-
_defineProperty(this, "logger", void 0);
|
|
3544
|
-
|
|
3545
|
-
_defineProperty(this, "messageCallback", void 0);
|
|
3546
|
-
|
|
3547
|
-
_defineProperty(this, "recoverCallback", void 0);
|
|
3548
|
-
|
|
3549
|
-
_defineProperty(this, "tokenManager", void 0);
|
|
3550
|
-
|
|
3551
|
-
_defineProperty(this, "user", void 0);
|
|
3552
|
-
|
|
3553
|
-
_defineProperty(this, "userAgent", void 0);
|
|
3554
|
-
|
|
3555
|
-
_defineProperty(this, "userID", void 0);
|
|
3556
|
-
|
|
3557
|
-
_defineProperty(this, "wsBaseURL", void 0);
|
|
3558
|
-
|
|
3559
|
-
_defineProperty(this, "device", void 0);
|
|
3660
|
+
_defineProperty(this, "client", void 0);
|
|
3560
3661
|
|
|
3561
3662
|
_defineProperty(this, "connectionID", void 0);
|
|
3562
3663
|
|
|
@@ -3570,6 +3671,8 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3570
3671
|
|
|
3571
3672
|
_defineProperty(this, "isConnecting", void 0);
|
|
3572
3673
|
|
|
3674
|
+
_defineProperty(this, "isDisconnected", void 0);
|
|
3675
|
+
|
|
3573
3676
|
_defineProperty(this, "isHealthy", void 0);
|
|
3574
3677
|
|
|
3575
3678
|
_defineProperty(this, "isResolved", void 0);
|
|
@@ -3584,8 +3687,6 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3584
3687
|
|
|
3585
3688
|
_defineProperty(this, "requestID", void 0);
|
|
3586
3689
|
|
|
3587
|
-
_defineProperty(this, "connectionStartTimestamp", void 0);
|
|
3588
|
-
|
|
3589
3690
|
_defineProperty(this, "resolvePromise", void 0);
|
|
3590
3691
|
|
|
3591
3692
|
_defineProperty(this, "totalFailures", void 0);
|
|
@@ -3594,32 +3695,18 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3594
3695
|
|
|
3595
3696
|
_defineProperty(this, "wsID", void 0);
|
|
3596
3697
|
|
|
3597
|
-
_defineProperty(this, "
|
|
3598
|
-
|
|
3599
|
-
_defineProperty(this, "insightMetrics", void 0);
|
|
3600
|
-
|
|
3601
|
-
_defineProperty(this, "_buildUrl", function (reqID) {
|
|
3602
|
-
var params = {
|
|
3603
|
-
user_id: _this.user.id,
|
|
3604
|
-
user_details: _this.user,
|
|
3605
|
-
user_token: _this.tokenManager.getToken(),
|
|
3606
|
-
server_determines_connection_id: true,
|
|
3607
|
-
device: _this.device,
|
|
3608
|
-
client_request_id: reqID
|
|
3609
|
-
};
|
|
3610
|
-
var qs = encodeURIComponent(JSON.stringify(params));
|
|
3698
|
+
_defineProperty(this, "_buildUrl", function () {
|
|
3699
|
+
var qs = encodeURIComponent(_this.client._buildWSPayload(_this.requestID));
|
|
3611
3700
|
|
|
3612
|
-
var token = _this.tokenManager.getToken();
|
|
3701
|
+
var token = _this.client.tokenManager.getToken();
|
|
3613
3702
|
|
|
3614
|
-
return "".concat(_this.wsBaseURL, "/connect?json=").concat(qs, "&api_key=").concat(_this.
|
|
3703
|
+
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());
|
|
3615
3704
|
});
|
|
3616
3705
|
|
|
3617
3706
|
_defineProperty(this, "onlineStatusChanged", function (event) {
|
|
3618
3707
|
if (event.type === 'offline') {
|
|
3619
3708
|
// mark the connection as down
|
|
3620
|
-
_this.
|
|
3621
|
-
tags: ['connection']
|
|
3622
|
-
});
|
|
3709
|
+
_this._log('onlineStatusChanged() - Status changing to offline');
|
|
3623
3710
|
|
|
3624
3711
|
_this._setHealth(false);
|
|
3625
3712
|
} else if (event.type === 'online') {
|
|
@@ -3627,9 +3714,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3627
3714
|
// We check this.isHealthy, not sure if it's always
|
|
3628
3715
|
// smart to create a new WS connection if the old one is still up and running.
|
|
3629
3716
|
// it's possible we didn't miss any messages, so this process is just expensive and not needed.
|
|
3630
|
-
_this.
|
|
3631
|
-
tags: ['connection']
|
|
3632
|
-
});
|
|
3717
|
+
_this._log("onlineStatusChanged() - Status changing to online. isHealthy: ".concat(_this.isHealthy));
|
|
3633
3718
|
|
|
3634
3719
|
if (!_this.isHealthy) {
|
|
3635
3720
|
_this._reconnect({
|
|
@@ -3642,8 +3727,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3642
3727
|
_defineProperty(this, "onopen", function (wsID) {
|
|
3643
3728
|
if (_this.wsID !== wsID) return;
|
|
3644
3729
|
|
|
3645
|
-
_this.
|
|
3646
|
-
tags: ['connection'],
|
|
3730
|
+
_this._log('onopen() - onopen callback', {
|
|
3647
3731
|
wsID: wsID
|
|
3648
3732
|
});
|
|
3649
3733
|
});
|
|
@@ -3655,27 +3739,26 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3655
3739
|
// after that a ws.onclose..
|
|
3656
3740
|
|
|
3657
3741
|
if (!_this.isResolved && data) {
|
|
3742
|
+
var _this$resolvePromise;
|
|
3743
|
+
|
|
3658
3744
|
_this.isResolved = true;
|
|
3659
3745
|
|
|
3660
|
-
if (data.error
|
|
3746
|
+
if (data.error) {
|
|
3661
3747
|
var _this$rejectPromise;
|
|
3662
3748
|
|
|
3663
3749
|
(_this$rejectPromise = _this.rejectPromise) === null || _this$rejectPromise === void 0 ? void 0 : _this$rejectPromise.call(_this, _this._errorFromWSEvent(data, false));
|
|
3664
3750
|
return;
|
|
3665
|
-
}
|
|
3666
|
-
var _this$resolvePromise;
|
|
3751
|
+
}
|
|
3667
3752
|
|
|
3668
|
-
|
|
3753
|
+
(_this$resolvePromise = _this.resolvePromise) === null || _this$resolvePromise === void 0 ? void 0 : _this$resolvePromise.call(_this, data);
|
|
3669
3754
|
|
|
3670
|
-
|
|
3671
|
-
}
|
|
3755
|
+
_this._setHealth(true);
|
|
3672
3756
|
} // trigger the event..
|
|
3673
3757
|
|
|
3674
3758
|
|
|
3675
3759
|
_this.lastEvent = new Date();
|
|
3676
3760
|
|
|
3677
|
-
_this.
|
|
3678
|
-
tags: ['connection'],
|
|
3761
|
+
_this._log('onmessage() - onmessage callback', {
|
|
3679
3762
|
event: event,
|
|
3680
3763
|
wsID: wsID
|
|
3681
3764
|
});
|
|
@@ -3684,7 +3767,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3684
3767
|
_this.scheduleNextPing();
|
|
3685
3768
|
}
|
|
3686
3769
|
|
|
3687
|
-
_this.
|
|
3770
|
+
_this.client.handleEvent(event);
|
|
3688
3771
|
|
|
3689
3772
|
_this.scheduleConnectionCheck();
|
|
3690
3773
|
});
|
|
@@ -3692,8 +3775,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3692
3775
|
_defineProperty(this, "onclose", function (wsID, event) {
|
|
3693
3776
|
if (_this.wsID !== wsID) return;
|
|
3694
3777
|
|
|
3695
|
-
_this.
|
|
3696
|
-
tags: ['connection'],
|
|
3778
|
+
_this._log('onclose() - onclose callback - ' + event.code, {
|
|
3697
3779
|
event: event,
|
|
3698
3780
|
wsID: wsID
|
|
3699
3781
|
});
|
|
@@ -3710,8 +3792,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3710
3792
|
error.target = event.target;
|
|
3711
3793
|
(_this$rejectPromise2 = _this.rejectPromise) === null || _this$rejectPromise2 === void 0 ? void 0 : _this$rejectPromise2.call(_this, error);
|
|
3712
3794
|
|
|
3713
|
-
_this.
|
|
3714
|
-
tags: ['connection'],
|
|
3795
|
+
_this._log("onclose() - WS connection reject with error ".concat(event.reason), {
|
|
3715
3796
|
event: event
|
|
3716
3797
|
});
|
|
3717
3798
|
} else {
|
|
@@ -3725,8 +3806,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3725
3806
|
_this.isConnecting = false;
|
|
3726
3807
|
(_this$rejectPromise3 = _this.rejectPromise) === null || _this$rejectPromise3 === void 0 ? void 0 : _this$rejectPromise3.call(_this, _this._errorFromWSEvent(event));
|
|
3727
3808
|
|
|
3728
|
-
_this.
|
|
3729
|
-
tags: ['connection'],
|
|
3809
|
+
_this._log("onclose() - WS connection closed. Calling reconnect ...", {
|
|
3730
3810
|
event: event
|
|
3731
3811
|
}); // reconnect if its an abnormal failure
|
|
3732
3812
|
|
|
@@ -3747,8 +3827,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3747
3827
|
_this.isConnecting = false;
|
|
3748
3828
|
(_this$rejectPromise4 = _this.rejectPromise) === null || _this$rejectPromise4 === void 0 ? void 0 : _this$rejectPromise4.call(_this, _this._errorFromWSEvent(event));
|
|
3749
3829
|
|
|
3750
|
-
_this.
|
|
3751
|
-
tags: ['connection'],
|
|
3830
|
+
_this._log("onerror() - WS connection resulted into error", {
|
|
3752
3831
|
event: event
|
|
3753
3832
|
});
|
|
3754
3833
|
|
|
@@ -3756,28 +3835,28 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3756
3835
|
});
|
|
3757
3836
|
|
|
3758
3837
|
_defineProperty(this, "_setHealth", function (healthy) {
|
|
3759
|
-
if (healthy
|
|
3760
|
-
|
|
3761
|
-
_this.isHealthy = true;
|
|
3838
|
+
if (healthy === _this.isHealthy) return;
|
|
3839
|
+
_this.isHealthy = healthy;
|
|
3762
3840
|
|
|
3763
|
-
|
|
3841
|
+
if (_this.isHealthy) {
|
|
3842
|
+
//@ts-expect-error
|
|
3843
|
+
_this.client.dispatchEvent({
|
|
3764
3844
|
type: 'connection.changed',
|
|
3765
|
-
online:
|
|
3845
|
+
online: _this.isHealthy
|
|
3766
3846
|
});
|
|
3767
|
-
}
|
|
3768
3847
|
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
}
|
|
3780
|
-
}
|
|
3848
|
+
return;
|
|
3849
|
+
} // we're offline, wait few seconds and fire and event if still offline
|
|
3850
|
+
|
|
3851
|
+
|
|
3852
|
+
setTimeout(function () {
|
|
3853
|
+
if (_this.isHealthy) return; //@ts-expect-error
|
|
3854
|
+
|
|
3855
|
+
_this.client.dispatchEvent({
|
|
3856
|
+
type: 'connection.changed',
|
|
3857
|
+
online: _this.isHealthy
|
|
3858
|
+
});
|
|
3859
|
+
}, 5000);
|
|
3781
3860
|
});
|
|
3782
3861
|
|
|
3783
3862
|
_defineProperty(this, "_errorFromWSEvent", function (event) {
|
|
@@ -3799,10 +3878,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3799
3878
|
} // Keeping this `warn` level log, to avoid cluttering of error logs from ws failures.
|
|
3800
3879
|
|
|
3801
3880
|
|
|
3802
|
-
_this.
|
|
3803
|
-
tags: ['connection'],
|
|
3881
|
+
_this._log("_errorFromWSEvent() - WS failed with code ".concat(code), {
|
|
3804
3882
|
event: event
|
|
3805
|
-
});
|
|
3883
|
+
}, 'warn');
|
|
3806
3884
|
|
|
3807
3885
|
var error = new Error("WS failed with code ".concat(code, " and reason - ").concat(message));
|
|
3808
3886
|
error.code = code;
|
|
@@ -3816,50 +3894,13 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3816
3894
|
return error;
|
|
3817
3895
|
});
|
|
3818
3896
|
|
|
3819
|
-
_defineProperty(this, "_listenForConnectionChanges", function () {
|
|
3820
|
-
var _window;
|
|
3821
|
-
|
|
3822
|
-
// (typeof window !== 'undefined') check is for environments where window is not defined, such as nextjs environment,
|
|
3823
|
-
// and thus (window === undefined) will result in ReferenceError.
|
|
3824
|
-
if (typeof window !== 'undefined' && (_window = window) !== null && _window !== void 0 && _window.addEventListener) {
|
|
3825
|
-
window.addEventListener('offline', _this.onlineStatusChanged);
|
|
3826
|
-
window.addEventListener('online', _this.onlineStatusChanged);
|
|
3827
|
-
}
|
|
3828
|
-
});
|
|
3829
|
-
|
|
3830
|
-
_defineProperty(this, "_removeConnectionListeners", function () {
|
|
3831
|
-
var _window2;
|
|
3832
|
-
|
|
3833
|
-
// (typeof window !== 'undefined') check is for environments where window is not defined, such as nextjs environment,
|
|
3834
|
-
// and thus (window === undefined) will result in ReferenceError.
|
|
3835
|
-
if (typeof window !== 'undefined' && (_window2 = window) !== null && _window2 !== void 0 && _window2.removeEventListener) {
|
|
3836
|
-
window.removeEventListener('offline', _this.onlineStatusChanged);
|
|
3837
|
-
window.removeEventListener('online', _this.onlineStatusChanged);
|
|
3838
|
-
}
|
|
3839
|
-
});
|
|
3840
|
-
|
|
3841
3897
|
_defineProperty(this, "_setupConnectionPromise", function () {
|
|
3842
|
-
var that = _this;
|
|
3843
3898
|
_this.isResolved = false;
|
|
3844
3899
|
/** a promise that is resolved once ws.open is called */
|
|
3845
3900
|
|
|
3846
3901
|
_this.connectionOpen = new Promise(function (resolve, reject) {
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
}).then(function (e) {
|
|
3850
|
-
if (e.data && typeof e.data === 'string') {
|
|
3851
|
-
var data = JSON.parse(e.data);
|
|
3852
|
-
|
|
3853
|
-
if (data && data.error != null) {
|
|
3854
|
-
throw new Error(JSON.stringify(data.error));
|
|
3855
|
-
}
|
|
3856
|
-
|
|
3857
|
-
return data;
|
|
3858
|
-
} else {
|
|
3859
|
-
return undefined;
|
|
3860
|
-
}
|
|
3861
|
-
}, function (error) {
|
|
3862
|
-
throw error;
|
|
3902
|
+
_this.resolvePromise = resolve;
|
|
3903
|
+
_this.rejectPromise = reject;
|
|
3863
3904
|
});
|
|
3864
3905
|
});
|
|
3865
3906
|
|
|
@@ -3873,7 +3914,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3873
3914
|
// send the healthcheck.., server replies with a health check event
|
|
3874
3915
|
var data = [{
|
|
3875
3916
|
type: 'health.check',
|
|
3876
|
-
client_id: _this.clientID
|
|
3917
|
+
client_id: _this.client.clientID
|
|
3877
3918
|
}]; // try to send on the connection
|
|
3878
3919
|
|
|
3879
3920
|
try {
|
|
@@ -3894,9 +3935,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3894
3935
|
var now = new Date();
|
|
3895
3936
|
|
|
3896
3937
|
if (_this.lastEvent && now.getTime() - _this.lastEvent.getTime() > _this.connectionCheckTimeout) {
|
|
3897
|
-
_this.
|
|
3898
|
-
tags: ['connection']
|
|
3899
|
-
});
|
|
3938
|
+
_this._log('scheduleConnectionCheck - going to reconnect');
|
|
3900
3939
|
|
|
3901
3940
|
_this._setHealth(false);
|
|
3902
3941
|
|
|
@@ -3905,15 +3944,8 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3905
3944
|
}, _this.connectionCheckTimeout);
|
|
3906
3945
|
});
|
|
3907
3946
|
|
|
3908
|
-
|
|
3909
|
-
this.
|
|
3910
|
-
this.userID = userID;
|
|
3911
|
-
this.user = user;
|
|
3912
|
-
this.authType = authType;
|
|
3913
|
-
this.userAgent = userAgent;
|
|
3914
|
-
this.apiKey = apiKey;
|
|
3915
|
-
this.tokenManager = tokenManager;
|
|
3916
|
-
this.device = device;
|
|
3947
|
+
/** StreamChat client */
|
|
3948
|
+
this.client = client;
|
|
3917
3949
|
/** consecutive failures influence the duration of the timeout */
|
|
3918
3950
|
|
|
3919
3951
|
this.consecutiveFailures = 0;
|
|
@@ -3923,18 +3955,15 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3923
3955
|
/** We only make 1 attempt to reconnect at the same time.. */
|
|
3924
3956
|
|
|
3925
3957
|
this.isConnecting = false;
|
|
3958
|
+
/** To avoid reconnect if client is disconnected */
|
|
3959
|
+
|
|
3960
|
+
this.isDisconnected = false;
|
|
3926
3961
|
/** Boolean that indicates if the connection promise is resolved */
|
|
3927
3962
|
|
|
3928
3963
|
this.isResolved = false;
|
|
3929
3964
|
/** Boolean that indicates if we have a working connection to the server */
|
|
3930
3965
|
|
|
3931
3966
|
this.isHealthy = false;
|
|
3932
|
-
/** Callback when the connection fails and recovers */
|
|
3933
|
-
|
|
3934
|
-
this.recoverCallback = recoverCallback;
|
|
3935
|
-
this.messageCallback = messageCallback;
|
|
3936
|
-
this.eventCallback = eventCallback;
|
|
3937
|
-
this.logger = logger;
|
|
3938
3967
|
/** Incremented when a new WS connection is made */
|
|
3939
3968
|
|
|
3940
3969
|
this.wsID = 1;
|
|
@@ -3945,74 +3974,82 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3945
3974
|
|
|
3946
3975
|
this.pingInterval = 25 * 1000;
|
|
3947
3976
|
this.connectionCheckTimeout = this.pingInterval + 10 * 1000;
|
|
3948
|
-
|
|
3949
|
-
this._listenForConnectionChanges();
|
|
3950
|
-
|
|
3951
|
-
this.postInsights = postInsights;
|
|
3952
|
-
this.insightMetrics = insightMetrics;
|
|
3977
|
+
addConnectionEventListeners(this.onlineStatusChanged);
|
|
3953
3978
|
}
|
|
3954
|
-
/**
|
|
3955
|
-
* connect - Connect to the WS URL
|
|
3956
|
-
*
|
|
3957
|
-
* @return {ConnectAPIResponse<ChannelType, CommandType, UserType>} Promise that completes once the first health check message is received
|
|
3958
|
-
*/
|
|
3959
|
-
|
|
3960
3979
|
|
|
3961
3980
|
_createClass(StableWSConnection, [{
|
|
3981
|
+
key: "_log",
|
|
3982
|
+
value: function _log(msg) {
|
|
3983
|
+
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
3984
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
3985
|
+
this.client.logger(level, 'connection:' + msg, _objectSpread$3({
|
|
3986
|
+
tags: ['connection']
|
|
3987
|
+
}, extra));
|
|
3988
|
+
}
|
|
3989
|
+
/**
|
|
3990
|
+
* connect - Connect to the WS URL
|
|
3991
|
+
* the default 15s timeout allows between 2~3 tries
|
|
3992
|
+
* @return {ConnectAPIResponse<ChannelType, CommandType, UserType>} Promise that completes once the first health check message is received
|
|
3993
|
+
*/
|
|
3994
|
+
|
|
3995
|
+
}, {
|
|
3962
3996
|
key: "connect",
|
|
3963
3997
|
value: function () {
|
|
3964
3998
|
var _connect2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
3965
|
-
var
|
|
3999
|
+
var timeout,
|
|
4000
|
+
healthCheck,
|
|
4001
|
+
_args = arguments;
|
|
3966
4002
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
3967
4003
|
while (1) {
|
|
3968
4004
|
switch (_context.prev = _context.next) {
|
|
3969
4005
|
case 0:
|
|
4006
|
+
timeout = _args.length > 0 && _args[0] !== undefined ? _args[0] : 15000;
|
|
4007
|
+
|
|
3970
4008
|
if (!this.isConnecting) {
|
|
3971
|
-
_context.next =
|
|
4009
|
+
_context.next = 3;
|
|
3972
4010
|
break;
|
|
3973
4011
|
}
|
|
3974
4012
|
|
|
3975
4013
|
throw Error("You've called connect twice, can only attempt 1 connection at the time");
|
|
3976
4014
|
|
|
3977
|
-
case
|
|
3978
|
-
|
|
3979
|
-
_context.
|
|
4015
|
+
case 3:
|
|
4016
|
+
this.isDisconnected = false;
|
|
4017
|
+
_context.prev = 4;
|
|
4018
|
+
_context.next = 7;
|
|
3980
4019
|
return this._connect();
|
|
3981
4020
|
|
|
3982
|
-
case
|
|
4021
|
+
case 7:
|
|
3983
4022
|
healthCheck = _context.sent;
|
|
3984
4023
|
this.consecutiveFailures = 0;
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
_context.next =
|
|
4024
|
+
|
|
4025
|
+
this._log("connect() - Established ws connection with healthcheck: ".concat(healthCheck));
|
|
4026
|
+
|
|
4027
|
+
_context.next = 23;
|
|
3989
4028
|
break;
|
|
3990
4029
|
|
|
3991
|
-
case
|
|
3992
|
-
_context.prev =
|
|
3993
|
-
_context.t0 = _context["catch"](
|
|
4030
|
+
case 12:
|
|
4031
|
+
_context.prev = 12;
|
|
4032
|
+
_context.t0 = _context["catch"](4);
|
|
3994
4033
|
this.isHealthy = false;
|
|
3995
4034
|
this.consecutiveFailures += 1;
|
|
3996
4035
|
|
|
3997
|
-
if (!(_context.t0.code === chatCodes.TOKEN_EXPIRED && !this.tokenManager.isStatic())) {
|
|
3998
|
-
_context.next =
|
|
4036
|
+
if (!(_context.t0.code === chatCodes.TOKEN_EXPIRED && !this.client.tokenManager.isStatic())) {
|
|
4037
|
+
_context.next = 21;
|
|
3999
4038
|
break;
|
|
4000
4039
|
}
|
|
4001
4040
|
|
|
4002
|
-
this.
|
|
4003
|
-
tags: ['connection']
|
|
4004
|
-
});
|
|
4041
|
+
this._log('connect() - WS failure due to expired token, so going to try to reload token and reconnect');
|
|
4005
4042
|
|
|
4006
4043
|
this._reconnect({
|
|
4007
4044
|
refreshToken: true
|
|
4008
4045
|
});
|
|
4009
4046
|
|
|
4010
|
-
_context.next =
|
|
4047
|
+
_context.next = 23;
|
|
4011
4048
|
break;
|
|
4012
4049
|
|
|
4013
|
-
case
|
|
4050
|
+
case 21:
|
|
4014
4051
|
if (_context.t0.isWSFailure) {
|
|
4015
|
-
_context.next =
|
|
4052
|
+
_context.next = 23;
|
|
4016
4053
|
break;
|
|
4017
4054
|
}
|
|
4018
4055
|
|
|
@@ -4023,19 +4060,19 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4023
4060
|
isWSFailure: _context.t0.isWSFailure
|
|
4024
4061
|
}));
|
|
4025
4062
|
|
|
4026
|
-
case 21:
|
|
4027
|
-
_context.next = 23;
|
|
4028
|
-
return this._waitForHealthy();
|
|
4029
|
-
|
|
4030
4063
|
case 23:
|
|
4064
|
+
_context.next = 25;
|
|
4065
|
+
return this._waitForHealthy(timeout);
|
|
4066
|
+
|
|
4067
|
+
case 25:
|
|
4031
4068
|
return _context.abrupt("return", _context.sent);
|
|
4032
4069
|
|
|
4033
|
-
case
|
|
4070
|
+
case 26:
|
|
4034
4071
|
case "end":
|
|
4035
4072
|
return _context.stop();
|
|
4036
4073
|
}
|
|
4037
4074
|
}
|
|
4038
|
-
}, _callee, this, [[
|
|
4075
|
+
}, _callee, this, [[4, 12]]);
|
|
4039
4076
|
}));
|
|
4040
4077
|
|
|
4041
4078
|
function connect() {
|
|
@@ -4126,6 +4163,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4126
4163
|
return sleep(timeout);
|
|
4127
4164
|
|
|
4128
4165
|
case 2:
|
|
4166
|
+
_this2.isConnecting = false;
|
|
4129
4167
|
throw new Error(JSON.stringify({
|
|
4130
4168
|
code: '',
|
|
4131
4169
|
StatusCode: '',
|
|
@@ -4133,7 +4171,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4133
4171
|
isWSFailure: true
|
|
4134
4172
|
}));
|
|
4135
4173
|
|
|
4136
|
-
case
|
|
4174
|
+
case 4:
|
|
4137
4175
|
case "end":
|
|
4138
4176
|
return _context3.stop();
|
|
4139
4177
|
}
|
|
@@ -4157,7 +4195,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4157
4195
|
}()
|
|
4158
4196
|
/**
|
|
4159
4197
|
* Builds and returns the url for websocket.
|
|
4160
|
-
* @
|
|
4198
|
+
* @private
|
|
4161
4199
|
* @returns url string
|
|
4162
4200
|
*/
|
|
4163
4201
|
|
|
@@ -4171,10 +4209,11 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4171
4209
|
function disconnect(timeout) {
|
|
4172
4210
|
var _this3 = this;
|
|
4173
4211
|
|
|
4174
|
-
this.
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
this.
|
|
4212
|
+
this._log("disconnect() - Closing the websocket connection for wsID ".concat(this.wsID));
|
|
4213
|
+
|
|
4214
|
+
this.wsID += 1;
|
|
4215
|
+
this.isConnecting = false;
|
|
4216
|
+
this.isDisconnected = true; // start by removing all the listeners
|
|
4178
4217
|
|
|
4179
4218
|
if (this.healthCheckTimeoutRef) {
|
|
4180
4219
|
clearInterval(this.healthCheckTimeoutRef);
|
|
@@ -4184,8 +4223,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4184
4223
|
clearInterval(this.connectionCheckTimeoutRef);
|
|
4185
4224
|
}
|
|
4186
4225
|
|
|
4187
|
-
this.
|
|
4188
|
-
|
|
4226
|
+
removeConnectionEventListeners(this.onlineStatusChanged);
|
|
4189
4227
|
this.isHealthy = false; // remove ws handlers...
|
|
4190
4228
|
|
|
4191
4229
|
if (this.ws && this.ws.removeAllListeners) {
|
|
@@ -4201,8 +4239,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4201
4239
|
if (ws && ws.close && ws.readyState === ws.OPEN) {
|
|
4202
4240
|
isClosedPromise = new Promise(function (resolve) {
|
|
4203
4241
|
var onclose = function onclose(event) {
|
|
4204
|
-
_this3.
|
|
4205
|
-
tags: ['connection'],
|
|
4242
|
+
_this3._log("disconnect() - resolving isClosedPromise ".concat(event ? 'with' : 'without', " close frame"), {
|
|
4206
4243
|
event: event
|
|
4207
4244
|
});
|
|
4208
4245
|
|
|
@@ -4214,14 +4251,13 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4214
4251
|
|
|
4215
4252
|
setTimeout(onclose, timeout != null ? timeout : 1000);
|
|
4216
4253
|
});
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4254
|
+
|
|
4255
|
+
this._log("disconnect() - Manually closed connection by calling client.disconnect()");
|
|
4256
|
+
|
|
4220
4257
|
ws.close(chatCodes.WS_CLOSED_SUCCESS, 'Manually closed connection by calling client.disconnect()');
|
|
4221
4258
|
} else {
|
|
4222
|
-
this.
|
|
4223
|
-
|
|
4224
|
-
});
|
|
4259
|
+
this._log("disconnect() - ws connection doesn't exist or it is already closed.");
|
|
4260
|
+
|
|
4225
4261
|
isClosedPromise = Promise.resolve();
|
|
4226
4262
|
}
|
|
4227
4263
|
|
|
@@ -4238,13 +4274,12 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4238
4274
|
key: "_connect",
|
|
4239
4275
|
value: function () {
|
|
4240
4276
|
var _connect3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
4241
|
-
var wsURL, response,
|
|
4242
|
-
|
|
4277
|
+
var wsURL, response, insights;
|
|
4243
4278
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
4244
4279
|
while (1) {
|
|
4245
4280
|
switch (_context5.prev = _context5.next) {
|
|
4246
4281
|
case 0:
|
|
4247
|
-
if (!this.isConnecting) {
|
|
4282
|
+
if (!(this.isConnecting || this.isDisconnected)) {
|
|
4248
4283
|
_context5.next = 2;
|
|
4249
4284
|
break;
|
|
4250
4285
|
}
|
|
@@ -4255,15 +4290,15 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4255
4290
|
// simply ignore _connect if it's currently trying to connect
|
|
4256
4291
|
this.isConnecting = true;
|
|
4257
4292
|
this.requestID = randomId();
|
|
4258
|
-
this.insightMetrics.connectionStartTimestamp = new Date().getTime();
|
|
4293
|
+
this.client.insightMetrics.connectionStartTimestamp = new Date().getTime();
|
|
4259
4294
|
_context5.prev = 5;
|
|
4260
4295
|
_context5.next = 8;
|
|
4261
|
-
return this.tokenManager.tokenReady();
|
|
4296
|
+
return this.client.tokenManager.tokenReady();
|
|
4262
4297
|
|
|
4263
4298
|
case 8:
|
|
4264
4299
|
this._setupConnectionPromise();
|
|
4265
4300
|
|
|
4266
|
-
wsURL = this._buildUrl(
|
|
4301
|
+
wsURL = this._buildUrl();
|
|
4267
4302
|
this.ws = new WebSocket(wsURL);
|
|
4268
4303
|
this.ws.onopen = this.onopen.bind(this, this.wsID);
|
|
4269
4304
|
this.ws.onclose = this.onclose.bind(this, this.wsID);
|
|
@@ -4283,9 +4318,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4283
4318
|
|
|
4284
4319
|
this.connectionID = response.connection_id;
|
|
4285
4320
|
|
|
4286
|
-
if (this.insightMetrics.wsConsecutiveFailures > 0 && this.
|
|
4287
|
-
|
|
4288
|
-
this.insightMetrics.wsConsecutiveFailures = 0;
|
|
4321
|
+
if (this.client.insightMetrics.wsConsecutiveFailures > 0 && this.client.options.enableInsights) {
|
|
4322
|
+
postInsights('ws_success_after_failure', buildWsSuccessAfterFailureInsight(this));
|
|
4323
|
+
this.client.insightMetrics.wsConsecutiveFailures = 0;
|
|
4289
4324
|
}
|
|
4290
4325
|
|
|
4291
4326
|
return _context5.abrupt("return", response);
|
|
@@ -4299,12 +4334,11 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4299
4334
|
_context5.t0 = _context5["catch"](5);
|
|
4300
4335
|
this.isConnecting = false;
|
|
4301
4336
|
|
|
4302
|
-
if (this.
|
|
4303
|
-
this.insightMetrics.wsConsecutiveFailures++;
|
|
4304
|
-
this.insightMetrics.wsTotalFailures++;
|
|
4305
|
-
|
|
4337
|
+
if (this.client.options.enableInsights) {
|
|
4338
|
+
this.client.insightMetrics.wsConsecutiveFailures++;
|
|
4339
|
+
this.client.insightMetrics.wsTotalFailures++;
|
|
4306
4340
|
insights = buildWsFatalInsight(this, convertErrorToJson(_context5.t0));
|
|
4307
|
-
|
|
4341
|
+
postInsights === null || postInsights === void 0 ? void 0 : postInsights('ws_fatal', insights);
|
|
4308
4342
|
}
|
|
4309
4343
|
|
|
4310
4344
|
throw _context5.t0;
|
|
@@ -4338,26 +4372,23 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4338
4372
|
var _reconnect2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
4339
4373
|
var options,
|
|
4340
4374
|
interval,
|
|
4341
|
-
_open,
|
|
4342
4375
|
_args6 = arguments;
|
|
4343
|
-
|
|
4344
4376
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
4345
4377
|
while (1) {
|
|
4346
4378
|
switch (_context6.prev = _context6.next) {
|
|
4347
4379
|
case 0:
|
|
4348
4380
|
options = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4381
|
+
|
|
4382
|
+
this._log('_reconnect() - Initiating the reconnect'); // only allow 1 connection at the time
|
|
4383
|
+
|
|
4352
4384
|
|
|
4353
4385
|
if (!(this.isConnecting || this.isHealthy)) {
|
|
4354
4386
|
_context6.next = 5;
|
|
4355
4387
|
break;
|
|
4356
4388
|
}
|
|
4357
4389
|
|
|
4358
|
-
this.
|
|
4359
|
-
|
|
4360
|
-
});
|
|
4390
|
+
this._log('_reconnect() - Abort (1) since already connecting or healthy');
|
|
4391
|
+
|
|
4361
4392
|
return _context6.abrupt("return");
|
|
4362
4393
|
|
|
4363
4394
|
case 5:
|
|
@@ -4379,95 +4410,86 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4379
4410
|
break;
|
|
4380
4411
|
}
|
|
4381
4412
|
|
|
4382
|
-
this.
|
|
4383
|
-
|
|
4384
|
-
});
|
|
4413
|
+
this._log('_reconnect() - Abort (2) since already connecting or healthy');
|
|
4414
|
+
|
|
4385
4415
|
return _context6.abrupt("return");
|
|
4386
4416
|
|
|
4387
4417
|
case 12:
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
}
|
|
4418
|
+
if (!this.isDisconnected) {
|
|
4419
|
+
_context6.next = 15;
|
|
4420
|
+
break;
|
|
4421
|
+
}
|
|
4422
|
+
|
|
4423
|
+
this._log('_reconnect() - Abort (3) since disconnect() is called');
|
|
4424
|
+
|
|
4425
|
+
return _context6.abrupt("return");
|
|
4426
|
+
|
|
4427
|
+
case 15:
|
|
4428
|
+
this._log('_reconnect() - Destroying current WS connection'); // cleanup the old connection
|
|
4429
|
+
|
|
4392
4430
|
|
|
4393
4431
|
this._destroyCurrentWSConnection();
|
|
4394
4432
|
|
|
4395
4433
|
if (!options.refreshToken) {
|
|
4396
|
-
_context6.next =
|
|
4434
|
+
_context6.next = 20;
|
|
4397
4435
|
break;
|
|
4398
4436
|
}
|
|
4399
4437
|
|
|
4400
|
-
_context6.next = 17;
|
|
4401
|
-
return this.tokenManager.loadToken();
|
|
4402
|
-
|
|
4403
|
-
case 17:
|
|
4404
|
-
_context6.prev = 17;
|
|
4405
4438
|
_context6.next = 20;
|
|
4406
|
-
return this.
|
|
4439
|
+
return this.client.tokenManager.loadToken();
|
|
4407
4440
|
|
|
4408
4441
|
case 20:
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
_context6.next = 26;
|
|
4413
|
-
break;
|
|
4414
|
-
}
|
|
4442
|
+
_context6.prev = 20;
|
|
4443
|
+
_context6.next = 23;
|
|
4444
|
+
return this._connect();
|
|
4415
4445
|
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
});
|
|
4419
|
-
_context6.next = 25;
|
|
4420
|
-
return this.recoverCallback(_open);
|
|
4446
|
+
case 23:
|
|
4447
|
+
this._log('_reconnect() - Waiting for recoverCallBack');
|
|
4421
4448
|
|
|
4422
|
-
|
|
4423
|
-
this.
|
|
4424
|
-
tags: ['connection']
|
|
4425
|
-
});
|
|
4449
|
+
_context6.next = 26;
|
|
4450
|
+
return this.client.recoverState();
|
|
4426
4451
|
|
|
4427
4452
|
case 26:
|
|
4453
|
+
this._log('_reconnect() - Finished recoverCallBack');
|
|
4454
|
+
|
|
4428
4455
|
this.consecutiveFailures = 0;
|
|
4429
|
-
_context6.next =
|
|
4456
|
+
_context6.next = 38;
|
|
4430
4457
|
break;
|
|
4431
4458
|
|
|
4432
|
-
case
|
|
4433
|
-
_context6.prev =
|
|
4434
|
-
_context6.t0 = _context6["catch"](
|
|
4459
|
+
case 30:
|
|
4460
|
+
_context6.prev = 30;
|
|
4461
|
+
_context6.t0 = _context6["catch"](20);
|
|
4435
4462
|
this.isHealthy = false;
|
|
4436
4463
|
this.consecutiveFailures += 1;
|
|
4437
4464
|
|
|
4438
|
-
if (!(_context6.t0.code === chatCodes.TOKEN_EXPIRED && !this.tokenManager.isStatic())) {
|
|
4439
|
-
_context6.next =
|
|
4465
|
+
if (!(_context6.t0.code === chatCodes.TOKEN_EXPIRED && !this.client.tokenManager.isStatic())) {
|
|
4466
|
+
_context6.next = 37;
|
|
4440
4467
|
break;
|
|
4441
4468
|
}
|
|
4442
4469
|
|
|
4443
|
-
this.
|
|
4444
|
-
|
|
4445
|
-
});
|
|
4470
|
+
this._log('_reconnect() - WS failure due to expired token, so going to try to reload token and reconnect');
|
|
4471
|
+
|
|
4446
4472
|
return _context6.abrupt("return", this._reconnect({
|
|
4447
4473
|
refreshToken: true
|
|
4448
4474
|
}));
|
|
4449
4475
|
|
|
4450
|
-
case
|
|
4476
|
+
case 37:
|
|
4451
4477
|
// reconnect on WS failures, don't reconnect if there is a code bug
|
|
4452
4478
|
if (_context6.t0.isWSFailure) {
|
|
4453
|
-
this.
|
|
4454
|
-
tags: ['connection']
|
|
4455
|
-
});
|
|
4479
|
+
this._log('_reconnect() - WS failure, so going to try to reconnect');
|
|
4456
4480
|
|
|
4457
4481
|
this._reconnect();
|
|
4458
4482
|
}
|
|
4459
4483
|
|
|
4460
|
-
case 37:
|
|
4461
|
-
this.logger('info', 'connection:_reconnect() - == END ==', {
|
|
4462
|
-
tags: ['connection']
|
|
4463
|
-
});
|
|
4464
|
-
|
|
4465
4484
|
case 38:
|
|
4485
|
+
this._log('_reconnect() - == END ==');
|
|
4486
|
+
|
|
4487
|
+
case 39:
|
|
4466
4488
|
case "end":
|
|
4467
4489
|
return _context6.stop();
|
|
4468
4490
|
}
|
|
4469
4491
|
}
|
|
4470
|
-
}, _callee6, this, [[
|
|
4492
|
+
}, _callee6, this, [[20, 30]]);
|
|
4471
4493
|
}));
|
|
4472
4494
|
|
|
4473
4495
|
function _reconnect() {
|
|
@@ -4496,13 +4518,10 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4496
4518
|
this.wsID += 1;
|
|
4497
4519
|
|
|
4498
4520
|
try {
|
|
4499
|
-
|
|
4500
|
-
this.ws.removeAllListeners();
|
|
4501
|
-
}
|
|
4521
|
+
var _this$ws2, _this$ws3;
|
|
4502
4522
|
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
}
|
|
4523
|
+
this === null || this === void 0 ? void 0 : (_this$ws2 = this.ws) === null || _this$ws2 === void 0 ? void 0 : _this$ws2.removeAllListeners();
|
|
4524
|
+
this === null || this === void 0 ? void 0 : (_this$ws3 = this.ws) === null || _this$ws3 === void 0 ? void 0 : _this$ws3.close();
|
|
4506
4525
|
} catch (e) {// we don't care
|
|
4507
4526
|
}
|
|
4508
4527
|
}
|
|
@@ -4515,9 +4534,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4515
4534
|
return StableWSConnection;
|
|
4516
4535
|
}();
|
|
4517
4536
|
|
|
4518
|
-
function ownKeys$
|
|
4537
|
+
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; }
|
|
4519
4538
|
|
|
4520
|
-
function _objectSpread$
|
|
4539
|
+
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(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; }
|
|
4521
4540
|
|
|
4522
4541
|
/**
|
|
4523
4542
|
* Creates the JWT token that can be used for a UserSession
|
|
@@ -4526,7 +4545,7 @@ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) {
|
|
|
4526
4545
|
* @private
|
|
4527
4546
|
* @param {Secret} apiSecret - API Secret key
|
|
4528
4547
|
* @param {string} userId - The user_id key in the JWT payload
|
|
4529
|
-
* @param {
|
|
4548
|
+
* @param {UR} [extraData] - Extra that should be part of the JWT token
|
|
4530
4549
|
* @param {SignOptions} [jwtOptions] - Options that can be past to jwt.sign
|
|
4531
4550
|
* @return {string} JWT Token
|
|
4532
4551
|
*/
|
|
@@ -4538,7 +4557,7 @@ function JWTUserToken(apiSecret, userId) {
|
|
|
4538
4557
|
throw new TypeError('userId should be a string');
|
|
4539
4558
|
}
|
|
4540
4559
|
|
|
4541
|
-
var payload = _objectSpread$
|
|
4560
|
+
var payload = _objectSpread$2({
|
|
4542
4561
|
user_id: userId
|
|
4543
4562
|
}, extraData); // make sure we return a clear error when jwt is shimmed (ie. browser build)
|
|
4544
4563
|
|
|
@@ -4725,76 +4744,576 @@ function TokenManager(secret) {
|
|
|
4725
4744
|
break;
|
|
4726
4745
|
}
|
|
4727
4746
|
|
|
4728
|
-
return _context2.abrupt("return", resolve(_this.token));
|
|
4747
|
+
return _context2.abrupt("return", resolve(_this.token));
|
|
4748
|
+
|
|
4749
|
+
case 2:
|
|
4750
|
+
if (!(_this.tokenProvider && typeof _this.tokenProvider !== 'string')) {
|
|
4751
|
+
_context2.next = 7;
|
|
4752
|
+
break;
|
|
4753
|
+
}
|
|
4754
|
+
|
|
4755
|
+
_context2.next = 5;
|
|
4756
|
+
return _this.tokenProvider();
|
|
4757
|
+
|
|
4758
|
+
case 5:
|
|
4759
|
+
_this.token = _context2.sent;
|
|
4760
|
+
resolve(_this.token);
|
|
4761
|
+
|
|
4762
|
+
case 7:
|
|
4763
|
+
case "end":
|
|
4764
|
+
return _context2.stop();
|
|
4765
|
+
}
|
|
4766
|
+
}
|
|
4767
|
+
}, _callee2);
|
|
4768
|
+
}));
|
|
4769
|
+
|
|
4770
|
+
return function (_x3) {
|
|
4771
|
+
return _ref2.apply(this, arguments);
|
|
4772
|
+
};
|
|
4773
|
+
}());
|
|
4774
|
+
return _this.loadTokenPromise;
|
|
4775
|
+
});
|
|
4776
|
+
|
|
4777
|
+
_defineProperty(this, "getToken", function () {
|
|
4778
|
+
if (_this.token) {
|
|
4779
|
+
return _this.token;
|
|
4780
|
+
}
|
|
4781
|
+
|
|
4782
|
+
if (_this.user && _this.user.anon && !_this.token) {
|
|
4783
|
+
return _this.token;
|
|
4784
|
+
}
|
|
4785
|
+
|
|
4786
|
+
if (_this.secret) {
|
|
4787
|
+
return JWTServerToken(_this.secret);
|
|
4788
|
+
}
|
|
4789
|
+
|
|
4790
|
+
throw new Error("Both secret and user tokens are not set. Either client.connectUser wasn't called or client.disconnect was called");
|
|
4791
|
+
});
|
|
4792
|
+
|
|
4793
|
+
_defineProperty(this, "isStatic", function () {
|
|
4794
|
+
return _this.type === 'static';
|
|
4795
|
+
});
|
|
4796
|
+
|
|
4797
|
+
this.loadTokenPromise = null;
|
|
4798
|
+
|
|
4799
|
+
if (secret) {
|
|
4800
|
+
this.secret = secret;
|
|
4801
|
+
}
|
|
4802
|
+
|
|
4803
|
+
this.type = 'static';
|
|
4804
|
+
|
|
4805
|
+
if (this.secret) {
|
|
4806
|
+
this.token = JWTServerToken(this.secret);
|
|
4807
|
+
}
|
|
4808
|
+
}
|
|
4809
|
+
/**
|
|
4810
|
+
* Set the static string token or token provider.
|
|
4811
|
+
* Token provider should return a token string or a promise which resolves to string token.
|
|
4812
|
+
*
|
|
4813
|
+
* @param {TokenOrProvider} tokenOrProvider
|
|
4814
|
+
* @param {UserResponse<UserType>} user
|
|
4815
|
+
*/
|
|
4816
|
+
;
|
|
4817
|
+
|
|
4818
|
+
var APIErrorCodes = {
|
|
4819
|
+
'-1': {
|
|
4820
|
+
name: 'InternalSystemError',
|
|
4821
|
+
retryable: true
|
|
4822
|
+
},
|
|
4823
|
+
'2': {
|
|
4824
|
+
name: 'AccessKeyError',
|
|
4825
|
+
retryable: false
|
|
4826
|
+
},
|
|
4827
|
+
'3': {
|
|
4828
|
+
name: 'AuthenticationFailedError',
|
|
4829
|
+
retryable: true
|
|
4830
|
+
},
|
|
4831
|
+
'4': {
|
|
4832
|
+
name: 'InputError',
|
|
4833
|
+
retryable: false
|
|
4834
|
+
},
|
|
4835
|
+
'6': {
|
|
4836
|
+
name: 'DuplicateUsernameError',
|
|
4837
|
+
retryable: false
|
|
4838
|
+
},
|
|
4839
|
+
'9': {
|
|
4840
|
+
name: 'RateLimitError',
|
|
4841
|
+
retryable: true
|
|
4842
|
+
},
|
|
4843
|
+
'16': {
|
|
4844
|
+
name: 'DoesNotExistError',
|
|
4845
|
+
retryable: false
|
|
4846
|
+
},
|
|
4847
|
+
'17': {
|
|
4848
|
+
name: 'NotAllowedError',
|
|
4849
|
+
retryable: false
|
|
4850
|
+
},
|
|
4851
|
+
'18': {
|
|
4852
|
+
name: 'EventNotSupportedError',
|
|
4853
|
+
retryable: false
|
|
4854
|
+
},
|
|
4855
|
+
'19': {
|
|
4856
|
+
name: 'ChannelFeatureNotSupportedError',
|
|
4857
|
+
retryable: false
|
|
4858
|
+
},
|
|
4859
|
+
'20': {
|
|
4860
|
+
name: 'MessageTooLongError',
|
|
4861
|
+
retryable: false
|
|
4862
|
+
},
|
|
4863
|
+
'21': {
|
|
4864
|
+
name: 'MultipleNestingLevelError',
|
|
4865
|
+
retryable: false
|
|
4866
|
+
},
|
|
4867
|
+
'22': {
|
|
4868
|
+
name: 'PayloadTooBigError',
|
|
4869
|
+
retryable: false
|
|
4870
|
+
},
|
|
4871
|
+
'23': {
|
|
4872
|
+
name: 'RequestTimeoutError',
|
|
4873
|
+
retryable: true
|
|
4874
|
+
},
|
|
4875
|
+
'24': {
|
|
4876
|
+
name: 'MaxHeaderSizeExceededError',
|
|
4877
|
+
retryable: false
|
|
4878
|
+
},
|
|
4879
|
+
'40': {
|
|
4880
|
+
name: 'AuthErrorTokenExpired',
|
|
4881
|
+
retryable: false
|
|
4882
|
+
},
|
|
4883
|
+
'41': {
|
|
4884
|
+
name: 'AuthErrorTokenNotValidYet',
|
|
4885
|
+
retryable: false
|
|
4886
|
+
},
|
|
4887
|
+
'42': {
|
|
4888
|
+
name: 'AuthErrorTokenUsedBeforeIssuedAt',
|
|
4889
|
+
retryable: false
|
|
4890
|
+
},
|
|
4891
|
+
'43': {
|
|
4892
|
+
name: 'AuthErrorTokenSignatureInvalid',
|
|
4893
|
+
retryable: false
|
|
4894
|
+
},
|
|
4895
|
+
'44': {
|
|
4896
|
+
name: 'CustomCommandEndpointMissingError',
|
|
4897
|
+
retryable: false
|
|
4898
|
+
},
|
|
4899
|
+
'45': {
|
|
4900
|
+
name: 'CustomCommandEndpointCallError',
|
|
4901
|
+
retryable: true
|
|
4902
|
+
},
|
|
4903
|
+
'46': {
|
|
4904
|
+
name: 'ConnectionIDNotFoundError',
|
|
4905
|
+
retryable: false
|
|
4906
|
+
},
|
|
4907
|
+
'60': {
|
|
4908
|
+
name: 'CoolDownError',
|
|
4909
|
+
retryable: true
|
|
4910
|
+
},
|
|
4911
|
+
'69': {
|
|
4912
|
+
name: 'ErrWrongRegion',
|
|
4913
|
+
retryable: false
|
|
4914
|
+
},
|
|
4915
|
+
'70': {
|
|
4916
|
+
name: 'ErrQueryChannelPermissions',
|
|
4917
|
+
retryable: false
|
|
4918
|
+
},
|
|
4919
|
+
'71': {
|
|
4920
|
+
name: 'ErrTooManyConnections',
|
|
4921
|
+
retryable: true
|
|
4922
|
+
},
|
|
4923
|
+
'99': {
|
|
4924
|
+
name: 'AppSuspendedError',
|
|
4925
|
+
retryable: false
|
|
4926
|
+
}
|
|
4927
|
+
};
|
|
4928
|
+
function isAPIError(error) {
|
|
4929
|
+
return error.code !== undefined;
|
|
4930
|
+
}
|
|
4931
|
+
function isErrorRetryable(error) {
|
|
4932
|
+
if (!error.code) return false;
|
|
4933
|
+
var err = APIErrorCodes["".concat(error.code)];
|
|
4934
|
+
if (!err) return false;
|
|
4935
|
+
return err.retryable;
|
|
4936
|
+
}
|
|
4937
|
+
function isConnectionIDError(error) {
|
|
4938
|
+
return error.code === 46; // ConnectionIDNotFoundError
|
|
4939
|
+
}
|
|
4940
|
+
function isWSFailure(err) {
|
|
4941
|
+
if (typeof err.isWSFailure === 'boolean') {
|
|
4942
|
+
return err.isWSFailure;
|
|
4943
|
+
}
|
|
4944
|
+
|
|
4945
|
+
try {
|
|
4946
|
+
return JSON.parse(err.message).isWSFailure;
|
|
4947
|
+
} catch (_) {
|
|
4948
|
+
return false;
|
|
4949
|
+
}
|
|
4950
|
+
}
|
|
4951
|
+
|
|
4952
|
+
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; }
|
|
4953
|
+
|
|
4954
|
+
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(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; }
|
|
4955
|
+
var ConnectionState;
|
|
4956
|
+
|
|
4957
|
+
(function (ConnectionState) {
|
|
4958
|
+
ConnectionState["Closed"] = "CLOSED";
|
|
4959
|
+
ConnectionState["Connected"] = "CONNECTED";
|
|
4960
|
+
ConnectionState["Connecting"] = "CONNECTING";
|
|
4961
|
+
ConnectionState["Disconnected"] = "DISCONNECTED";
|
|
4962
|
+
ConnectionState["Init"] = "INIT";
|
|
4963
|
+
})(ConnectionState || (ConnectionState = {}));
|
|
4964
|
+
|
|
4965
|
+
var WSConnectionFallback = /*#__PURE__*/function () {
|
|
4966
|
+
function WSConnectionFallback(_ref) {
|
|
4967
|
+
var _this = this;
|
|
4968
|
+
|
|
4969
|
+
var client = _ref.client;
|
|
4970
|
+
|
|
4971
|
+
_classCallCheck(this, WSConnectionFallback);
|
|
4972
|
+
|
|
4973
|
+
_defineProperty(this, "client", void 0);
|
|
4974
|
+
|
|
4975
|
+
_defineProperty(this, "state", void 0);
|
|
4976
|
+
|
|
4977
|
+
_defineProperty(this, "consecutiveFailures", void 0);
|
|
4978
|
+
|
|
4979
|
+
_defineProperty(this, "connectionID", void 0);
|
|
4980
|
+
|
|
4981
|
+
_defineProperty(this, "cancelToken", void 0);
|
|
4982
|
+
|
|
4983
|
+
_defineProperty(this, "_onlineStatusChanged", function (event) {
|
|
4984
|
+
_this._log("_onlineStatusChanged() - ".concat(event.type));
|
|
4985
|
+
|
|
4986
|
+
if (event.type === 'offline') {
|
|
4987
|
+
var _this$cancelToken;
|
|
4988
|
+
|
|
4989
|
+
_this._setState(ConnectionState.Closed);
|
|
4990
|
+
|
|
4991
|
+
(_this$cancelToken = _this.cancelToken) === null || _this$cancelToken === void 0 ? void 0 : _this$cancelToken.cancel('disconnect() is called');
|
|
4992
|
+
_this.cancelToken = undefined;
|
|
4993
|
+
return;
|
|
4994
|
+
}
|
|
4995
|
+
|
|
4996
|
+
if (event.type === 'online' && _this.state === ConnectionState.Closed) {
|
|
4997
|
+
_this.connect(true);
|
|
4998
|
+
}
|
|
4999
|
+
});
|
|
5000
|
+
|
|
5001
|
+
_defineProperty(this, "_req", /*#__PURE__*/function () {
|
|
5002
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params, config, retry) {
|
|
5003
|
+
var _this$cancelToken2, res;
|
|
5004
|
+
|
|
5005
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
5006
|
+
while (1) {
|
|
5007
|
+
switch (_context.prev = _context.next) {
|
|
5008
|
+
case 0:
|
|
5009
|
+
if (!_this.cancelToken && !params.close) {
|
|
5010
|
+
_this.cancelToken = axios.CancelToken.source();
|
|
5011
|
+
}
|
|
5012
|
+
|
|
5013
|
+
_context.prev = 1;
|
|
5014
|
+
_context.next = 4;
|
|
5015
|
+
return _this.client.doAxiosRequest('get', _this.client.baseURL.replace(':3030', ':8900') + '/longpoll', // replace port if present for testing with local API
|
|
5016
|
+
undefined, {
|
|
5017
|
+
config: _objectSpread$1(_objectSpread$1({}, config), {}, {
|
|
5018
|
+
cancelToken: (_this$cancelToken2 = _this.cancelToken) === null || _this$cancelToken2 === void 0 ? void 0 : _this$cancelToken2.token
|
|
5019
|
+
}),
|
|
5020
|
+
params: params
|
|
5021
|
+
});
|
|
5022
|
+
|
|
5023
|
+
case 4:
|
|
5024
|
+
res = _context.sent;
|
|
5025
|
+
_this.consecutiveFailures = 0; // always reset in case of no error
|
|
5026
|
+
|
|
5027
|
+
return _context.abrupt("return", res);
|
|
5028
|
+
|
|
5029
|
+
case 9:
|
|
5030
|
+
_context.prev = 9;
|
|
5031
|
+
_context.t0 = _context["catch"](1);
|
|
5032
|
+
_this.consecutiveFailures += 1;
|
|
5033
|
+
|
|
5034
|
+
if (!(retry && isErrorRetryable(_context.t0))) {
|
|
5035
|
+
_context.next = 17;
|
|
5036
|
+
break;
|
|
5037
|
+
}
|
|
5038
|
+
|
|
5039
|
+
_this._log("_req() - Retryable error, retrying request");
|
|
5040
|
+
|
|
5041
|
+
_context.next = 16;
|
|
5042
|
+
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5043
|
+
|
|
5044
|
+
case 16:
|
|
5045
|
+
return _context.abrupt("return", _this._req(params, config, retry));
|
|
5046
|
+
|
|
5047
|
+
case 17:
|
|
5048
|
+
throw _context.t0;
|
|
5049
|
+
|
|
5050
|
+
case 18:
|
|
5051
|
+
case "end":
|
|
5052
|
+
return _context.stop();
|
|
5053
|
+
}
|
|
5054
|
+
}
|
|
5055
|
+
}, _callee, null, [[1, 9]]);
|
|
5056
|
+
}));
|
|
5057
|
+
|
|
5058
|
+
return function (_x, _x2, _x3) {
|
|
5059
|
+
return _ref2.apply(this, arguments);
|
|
5060
|
+
};
|
|
5061
|
+
}());
|
|
5062
|
+
|
|
5063
|
+
_defineProperty(this, "_poll", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
5064
|
+
var _data$events, data, i;
|
|
5065
|
+
|
|
5066
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
5067
|
+
while (1) {
|
|
5068
|
+
switch (_context2.prev = _context2.next) {
|
|
5069
|
+
case 0:
|
|
5070
|
+
if (!(_this.state === ConnectionState.Connected)) {
|
|
5071
|
+
_context2.next = 25;
|
|
5072
|
+
break;
|
|
5073
|
+
}
|
|
5074
|
+
|
|
5075
|
+
_context2.prev = 1;
|
|
5076
|
+
_context2.next = 4;
|
|
5077
|
+
return _this._req({}, {
|
|
5078
|
+
timeout: 30000
|
|
5079
|
+
}, true);
|
|
5080
|
+
|
|
5081
|
+
case 4:
|
|
5082
|
+
data = _context2.sent;
|
|
5083
|
+
|
|
5084
|
+
// 30s => API responds in 20s if there is no event
|
|
5085
|
+
if ((_data$events = data.events) !== null && _data$events !== void 0 && _data$events.length) {
|
|
5086
|
+
for (i = 0; i < data.events.length; i++) {
|
|
5087
|
+
_this.client.dispatchEvent(data.events[i]);
|
|
5088
|
+
}
|
|
5089
|
+
}
|
|
5090
|
+
|
|
5091
|
+
_context2.next = 23;
|
|
5092
|
+
break;
|
|
5093
|
+
|
|
5094
|
+
case 8:
|
|
5095
|
+
_context2.prev = 8;
|
|
5096
|
+
_context2.t0 = _context2["catch"](1);
|
|
5097
|
+
|
|
5098
|
+
if (!axios.isCancel(_context2.t0)) {
|
|
5099
|
+
_context2.next = 13;
|
|
5100
|
+
break;
|
|
5101
|
+
}
|
|
5102
|
+
|
|
5103
|
+
_this._log("_poll() - axios canceled request");
|
|
5104
|
+
|
|
5105
|
+
return _context2.abrupt("return");
|
|
5106
|
+
|
|
5107
|
+
case 13:
|
|
5108
|
+
if (!isConnectionIDError(_context2.t0)) {
|
|
5109
|
+
_context2.next = 18;
|
|
5110
|
+
break;
|
|
5111
|
+
}
|
|
5112
|
+
|
|
5113
|
+
_this._log("_poll() - ConnectionID error, connecting without ID...");
|
|
5114
|
+
|
|
5115
|
+
_this._setState(ConnectionState.Disconnected);
|
|
5116
|
+
|
|
5117
|
+
_this.connect(true);
|
|
5118
|
+
|
|
5119
|
+
return _context2.abrupt("return");
|
|
5120
|
+
|
|
5121
|
+
case 18:
|
|
5122
|
+
if (!(isAPIError(_context2.t0) && !isErrorRetryable(_context2.t0))) {
|
|
5123
|
+
_context2.next = 21;
|
|
5124
|
+
break;
|
|
5125
|
+
}
|
|
5126
|
+
|
|
5127
|
+
_this._setState(ConnectionState.Closed);
|
|
5128
|
+
|
|
5129
|
+
return _context2.abrupt("return");
|
|
5130
|
+
|
|
5131
|
+
case 21:
|
|
5132
|
+
_context2.next = 23;
|
|
5133
|
+
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5134
|
+
|
|
5135
|
+
case 23:
|
|
5136
|
+
_context2.next = 0;
|
|
5137
|
+
break;
|
|
5138
|
+
|
|
5139
|
+
case 25:
|
|
5140
|
+
case "end":
|
|
5141
|
+
return _context2.stop();
|
|
5142
|
+
}
|
|
5143
|
+
}
|
|
5144
|
+
}, _callee2, null, [[1, 8]]);
|
|
5145
|
+
})));
|
|
5146
|
+
|
|
5147
|
+
_defineProperty(this, "connect", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
5148
|
+
var reconnect,
|
|
5149
|
+
_yield$_this$_req,
|
|
5150
|
+
event,
|
|
5151
|
+
_args3 = arguments;
|
|
5152
|
+
|
|
5153
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
5154
|
+
while (1) {
|
|
5155
|
+
switch (_context3.prev = _context3.next) {
|
|
5156
|
+
case 0:
|
|
5157
|
+
reconnect = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : false;
|
|
5158
|
+
|
|
5159
|
+
if (!(_this.state === ConnectionState.Connecting)) {
|
|
5160
|
+
_context3.next = 3;
|
|
5161
|
+
break;
|
|
5162
|
+
}
|
|
5163
|
+
|
|
5164
|
+
throw new Error('connecting already in progress');
|
|
5165
|
+
|
|
5166
|
+
case 3:
|
|
5167
|
+
if (!(_this.state === ConnectionState.Connected)) {
|
|
5168
|
+
_context3.next = 5;
|
|
5169
|
+
break;
|
|
5170
|
+
}
|
|
5171
|
+
|
|
5172
|
+
throw new Error('already connected and polling');
|
|
5173
|
+
|
|
5174
|
+
case 5:
|
|
5175
|
+
_this._setState(ConnectionState.Connecting);
|
|
5176
|
+
|
|
5177
|
+
_this.connectionID = undefined; // connect should be sent with empty connection_id so API creates one
|
|
5178
|
+
|
|
5179
|
+
_context3.prev = 7;
|
|
5180
|
+
_context3.next = 10;
|
|
5181
|
+
return _this._req({
|
|
5182
|
+
json: _this.client._buildWSPayload()
|
|
5183
|
+
}, {
|
|
5184
|
+
timeout: 8000
|
|
5185
|
+
}, // 8s
|
|
5186
|
+
reconnect);
|
|
5187
|
+
|
|
5188
|
+
case 10:
|
|
5189
|
+
_yield$_this$_req = _context3.sent;
|
|
5190
|
+
event = _yield$_this$_req.event;
|
|
5191
|
+
|
|
5192
|
+
_this._setState(ConnectionState.Connected);
|
|
5193
|
+
|
|
5194
|
+
_this.connectionID = event.connection_id;
|
|
5195
|
+
|
|
5196
|
+
_this._poll();
|
|
5197
|
+
|
|
5198
|
+
if (reconnect) {
|
|
5199
|
+
_this.client.recoverState();
|
|
5200
|
+
}
|
|
5201
|
+
|
|
5202
|
+
return _context3.abrupt("return", event);
|
|
4729
5203
|
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
break;
|
|
4734
|
-
}
|
|
5204
|
+
case 19:
|
|
5205
|
+
_context3.prev = 19;
|
|
5206
|
+
_context3.t0 = _context3["catch"](7);
|
|
4735
5207
|
|
|
4736
|
-
|
|
4737
|
-
return _this.tokenProvider();
|
|
5208
|
+
_this._setState(ConnectionState.Closed);
|
|
4738
5209
|
|
|
4739
|
-
|
|
4740
|
-
_this.token = _context2.sent;
|
|
4741
|
-
resolve(_this.token);
|
|
5210
|
+
throw _context3.t0;
|
|
4742
5211
|
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
}
|
|
5212
|
+
case 23:
|
|
5213
|
+
case "end":
|
|
5214
|
+
return _context3.stop();
|
|
4747
5215
|
}
|
|
4748
|
-
}
|
|
4749
|
-
})
|
|
5216
|
+
}
|
|
5217
|
+
}, _callee3, null, [[7, 19]]);
|
|
5218
|
+
})));
|
|
4750
5219
|
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
}());
|
|
4755
|
-
return _this.loadTokenPromise;
|
|
4756
|
-
});
|
|
5220
|
+
_defineProperty(this, "isHealthy", function () {
|
|
5221
|
+
return _this.connectionID && _this.state === ConnectionState.Connected;
|
|
5222
|
+
});
|
|
4757
5223
|
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
return _this.token;
|
|
4761
|
-
}
|
|
5224
|
+
_defineProperty(this, "disconnect", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
5225
|
+
var _this$cancelToken3;
|
|
4762
5226
|
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
5227
|
+
var timeout,
|
|
5228
|
+
_args4 = arguments;
|
|
5229
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
5230
|
+
while (1) {
|
|
5231
|
+
switch (_context4.prev = _context4.next) {
|
|
5232
|
+
case 0:
|
|
5233
|
+
timeout = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : 2000;
|
|
5234
|
+
removeConnectionEventListeners(_this._onlineStatusChanged);
|
|
4766
5235
|
|
|
4767
|
-
|
|
4768
|
-
return JWTServerToken(_this.secret);
|
|
4769
|
-
}
|
|
5236
|
+
_this._setState(ConnectionState.Disconnected);
|
|
4770
5237
|
|
|
4771
|
-
|
|
4772
|
-
|
|
5238
|
+
(_this$cancelToken3 = _this.cancelToken) === null || _this$cancelToken3 === void 0 ? void 0 : _this$cancelToken3.cancel('disconnect() is called');
|
|
5239
|
+
_this.cancelToken = undefined;
|
|
5240
|
+
_context4.prev = 5;
|
|
5241
|
+
_context4.next = 8;
|
|
5242
|
+
return _this._req({
|
|
5243
|
+
close: true
|
|
5244
|
+
}, {
|
|
5245
|
+
timeout: timeout
|
|
5246
|
+
}, false);
|
|
4773
5247
|
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
});
|
|
5248
|
+
case 8:
|
|
5249
|
+
_this.connectionID = undefined;
|
|
4777
5250
|
|
|
4778
|
-
|
|
5251
|
+
_this._log("disconnect() - Closed connectionID");
|
|
4779
5252
|
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
}
|
|
5253
|
+
_context4.next = 15;
|
|
5254
|
+
break;
|
|
4783
5255
|
|
|
4784
|
-
|
|
5256
|
+
case 12:
|
|
5257
|
+
_context4.prev = 12;
|
|
5258
|
+
_context4.t0 = _context4["catch"](5);
|
|
4785
5259
|
|
|
4786
|
-
|
|
4787
|
-
|
|
5260
|
+
_this._log("disconnect() - Failed", {
|
|
5261
|
+
err: _context4.t0
|
|
5262
|
+
}, 'error');
|
|
5263
|
+
|
|
5264
|
+
case 15:
|
|
5265
|
+
case "end":
|
|
5266
|
+
return _context4.stop();
|
|
5267
|
+
}
|
|
5268
|
+
}
|
|
5269
|
+
}, _callee4, null, [[5, 12]]);
|
|
5270
|
+
})));
|
|
5271
|
+
|
|
5272
|
+
this.client = client;
|
|
5273
|
+
this.state = ConnectionState.Init;
|
|
5274
|
+
this.consecutiveFailures = 0;
|
|
5275
|
+
addConnectionEventListeners(this._onlineStatusChanged);
|
|
4788
5276
|
}
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
;
|
|
5277
|
+
|
|
5278
|
+
_createClass(WSConnectionFallback, [{
|
|
5279
|
+
key: "_log",
|
|
5280
|
+
value: function _log(msg) {
|
|
5281
|
+
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5282
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
5283
|
+
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$1({
|
|
5284
|
+
tags: ['connection_fallback', 'connection']
|
|
5285
|
+
}, extra));
|
|
5286
|
+
}
|
|
5287
|
+
}, {
|
|
5288
|
+
key: "_setState",
|
|
5289
|
+
value: function _setState(state) {
|
|
5290
|
+
this._log("_setState() - ".concat(state)); // transition from connecting => connected
|
|
5291
|
+
|
|
5292
|
+
|
|
5293
|
+
if (this.state === ConnectionState.Connecting && state === ConnectionState.Connected) {
|
|
5294
|
+
//@ts-expect-error
|
|
5295
|
+
this.client.dispatchEvent({
|
|
5296
|
+
type: 'connection.changed',
|
|
5297
|
+
online: true
|
|
5298
|
+
});
|
|
5299
|
+
}
|
|
5300
|
+
|
|
5301
|
+
if (state === ConnectionState.Closed || state === ConnectionState.Disconnected) {
|
|
5302
|
+
//@ts-expect-error
|
|
5303
|
+
this.client.dispatchEvent({
|
|
5304
|
+
type: 'connection.changed',
|
|
5305
|
+
online: false
|
|
5306
|
+
});
|
|
5307
|
+
}
|
|
5308
|
+
|
|
5309
|
+
this.state = state;
|
|
5310
|
+
}
|
|
5311
|
+
/** @private */
|
|
5312
|
+
|
|
5313
|
+
}]);
|
|
5314
|
+
|
|
5315
|
+
return WSConnectionFallback;
|
|
5316
|
+
}();
|
|
4798
5317
|
|
|
4799
5318
|
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; } } }; }
|
|
4800
5319
|
|
|
@@ -4834,10 +5353,6 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4834
5353
|
|
|
4835
5354
|
_defineProperty(this, "configs", void 0);
|
|
4836
5355
|
|
|
4837
|
-
_defineProperty(this, "connectionID", void 0);
|
|
4838
|
-
|
|
4839
|
-
_defineProperty(this, "failures", void 0);
|
|
4840
|
-
|
|
4841
5356
|
_defineProperty(this, "key", void 0);
|
|
4842
5357
|
|
|
4843
5358
|
_defineProperty(this, "listeners", void 0);
|
|
@@ -4872,16 +5387,26 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4872
5387
|
|
|
4873
5388
|
_defineProperty(this, "wsConnection", void 0);
|
|
4874
5389
|
|
|
5390
|
+
_defineProperty(this, "wsFallback", void 0);
|
|
5391
|
+
|
|
4875
5392
|
_defineProperty(this, "wsPromise", void 0);
|
|
4876
5393
|
|
|
4877
5394
|
_defineProperty(this, "consecutiveFailures", void 0);
|
|
4878
5395
|
|
|
4879
5396
|
_defineProperty(this, "insightMetrics", void 0);
|
|
4880
5397
|
|
|
4881
|
-
_defineProperty(this, "
|
|
4882
|
-
|
|
5398
|
+
_defineProperty(this, "defaultWSTimeoutWithFallback", void 0);
|
|
5399
|
+
|
|
5400
|
+
_defineProperty(this, "defaultWSTimeout", void 0);
|
|
5401
|
+
|
|
5402
|
+
_defineProperty(this, "_getConnectionID", function () {
|
|
5403
|
+
var _this$wsConnection, _this$wsFallback;
|
|
5404
|
+
|
|
5405
|
+
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);
|
|
5406
|
+
});
|
|
4883
5407
|
|
|
4884
|
-
|
|
5408
|
+
_defineProperty(this, "_hasConnectionID", function () {
|
|
5409
|
+
return Boolean(_this._getConnectionID());
|
|
4885
5410
|
});
|
|
4886
5411
|
|
|
4887
5412
|
_defineProperty(this, "connectUser", /*#__PURE__*/function () {
|
|
@@ -4967,36 +5492,55 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4967
5492
|
return _this.tokenManager.setTokenOrProvider(userTokenOrProvider, user);
|
|
4968
5493
|
});
|
|
4969
5494
|
|
|
4970
|
-
_defineProperty(this, "closeConnection", function (
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
_this.cleaningIntervalRef = undefined;
|
|
4974
|
-
}
|
|
5495
|
+
_defineProperty(this, "closeConnection", /*#__PURE__*/function () {
|
|
5496
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(timeout) {
|
|
5497
|
+
var _this$wsConnection2, _this$wsFallback2;
|
|
4975
5498
|
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
5499
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
5500
|
+
while (1) {
|
|
5501
|
+
switch (_context2.prev = _context2.next) {
|
|
5502
|
+
case 0:
|
|
5503
|
+
if (_this.cleaningIntervalRef != null) {
|
|
5504
|
+
clearInterval(_this.cleaningIntervalRef);
|
|
5505
|
+
_this.cleaningIntervalRef = undefined;
|
|
5506
|
+
}
|
|
4979
5507
|
|
|
4980
|
-
|
|
4981
|
-
|
|
5508
|
+
_context2.next = 3;
|
|
5509
|
+
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)]);
|
|
4982
5510
|
|
|
4983
|
-
|
|
4984
|
-
|
|
5511
|
+
case 3:
|
|
5512
|
+
return _context2.abrupt("return", Promise.resolve());
|
|
4985
5513
|
|
|
4986
|
-
|
|
5514
|
+
case 4:
|
|
5515
|
+
case "end":
|
|
5516
|
+
return _context2.stop();
|
|
5517
|
+
}
|
|
5518
|
+
}
|
|
5519
|
+
}, _callee2);
|
|
5520
|
+
}));
|
|
5521
|
+
|
|
5522
|
+
return function (_x3) {
|
|
5523
|
+
return _ref2.apply(this, arguments);
|
|
5524
|
+
};
|
|
5525
|
+
}());
|
|
5526
|
+
|
|
5527
|
+
_defineProperty(this, "openConnection", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
5528
|
+
var _this$wsConnection3, _this$wsFallback3;
|
|
5529
|
+
|
|
5530
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
4987
5531
|
while (1) {
|
|
4988
|
-
switch (
|
|
5532
|
+
switch (_context3.prev = _context3.next) {
|
|
4989
5533
|
case 0:
|
|
4990
5534
|
if (_this.userID) {
|
|
4991
|
-
|
|
5535
|
+
_context3.next = 2;
|
|
4992
5536
|
break;
|
|
4993
5537
|
}
|
|
4994
5538
|
|
|
4995
5539
|
throw Error('User is not set on client, use client.connectUser or client.connectAnonymousUser instead');
|
|
4996
5540
|
|
|
4997
5541
|
case 2:
|
|
4998
|
-
if (!((_this$
|
|
4999
|
-
|
|
5542
|
+
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())) {
|
|
5543
|
+
_context3.next = 5;
|
|
5000
5544
|
break;
|
|
5001
5545
|
}
|
|
5002
5546
|
|
|
@@ -5004,7 +5548,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5004
5548
|
tags: ['connection', 'client']
|
|
5005
5549
|
});
|
|
5006
5550
|
|
|
5007
|
-
return
|
|
5551
|
+
return _context3.abrupt("return", Promise.resolve());
|
|
5008
5552
|
|
|
5009
5553
|
case 5:
|
|
5010
5554
|
_this.clientID = "".concat(_this.userID, "--").concat(randomId());
|
|
@@ -5012,14 +5556,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5012
5556
|
|
|
5013
5557
|
_this._startCleaning();
|
|
5014
5558
|
|
|
5015
|
-
return
|
|
5559
|
+
return _context3.abrupt("return", _this.wsPromise);
|
|
5016
5560
|
|
|
5017
5561
|
case 9:
|
|
5018
5562
|
case "end":
|
|
5019
|
-
return
|
|
5563
|
+
return _context3.stop();
|
|
5020
5564
|
}
|
|
5021
5565
|
}
|
|
5022
|
-
},
|
|
5566
|
+
}, _callee3);
|
|
5023
5567
|
})));
|
|
5024
5568
|
|
|
5025
5569
|
_defineProperty(this, "_setupConnection", this.openConnection);
|
|
@@ -5037,12 +5581,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5037
5581
|
});
|
|
5038
5582
|
|
|
5039
5583
|
_defineProperty(this, "disconnectUser", /*#__PURE__*/function () {
|
|
5040
|
-
var
|
|
5584
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(timeout) {
|
|
5041
5585
|
var closePromise, _i, _Object$values, _channel;
|
|
5042
5586
|
|
|
5043
|
-
return _regeneratorRuntime.wrap(function
|
|
5587
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
5044
5588
|
while (1) {
|
|
5045
|
-
switch (
|
|
5589
|
+
switch (_context4.prev = _context4.next) {
|
|
5046
5590
|
case 0:
|
|
5047
5591
|
_this.logger('info', 'client:disconnect() - Disconnecting the client', {
|
|
5048
5592
|
tags: ['connection', 'client']
|
|
@@ -5066,21 +5610,21 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5066
5610
|
|
|
5067
5611
|
_this.state = new ClientState(); // reset token manager
|
|
5068
5612
|
|
|
5069
|
-
_this.tokenManager.reset
|
|
5613
|
+
setTimeout(_this.tokenManager.reset); // delay reseting to use token for disconnect calls
|
|
5614
|
+
// close the WS connection
|
|
5070
5615
|
|
|
5071
|
-
|
|
5072
|
-
return _context3.abrupt("return", closePromise);
|
|
5616
|
+
return _context4.abrupt("return", closePromise);
|
|
5073
5617
|
|
|
5074
5618
|
case 11:
|
|
5075
5619
|
case "end":
|
|
5076
|
-
return
|
|
5620
|
+
return _context4.stop();
|
|
5077
5621
|
}
|
|
5078
5622
|
}
|
|
5079
|
-
},
|
|
5623
|
+
}, _callee4);
|
|
5080
5624
|
}));
|
|
5081
5625
|
|
|
5082
|
-
return function (
|
|
5083
|
-
return
|
|
5626
|
+
return function (_x4) {
|
|
5627
|
+
return _ref4.apply(this, arguments);
|
|
5084
5628
|
};
|
|
5085
5629
|
}());
|
|
5086
5630
|
|
|
@@ -5108,78 +5652,78 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5108
5652
|
_defineProperty(this, "setAnonymousUser", this.connectAnonymousUser);
|
|
5109
5653
|
|
|
5110
5654
|
_defineProperty(this, "doAxiosRequest", /*#__PURE__*/function () {
|
|
5111
|
-
var
|
|
5655
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(type, url, data) {
|
|
5112
5656
|
var options,
|
|
5113
5657
|
requestConfig,
|
|
5114
5658
|
response,
|
|
5115
5659
|
_requestConfig$header,
|
|
5116
|
-
|
|
5660
|
+
_args5 = arguments;
|
|
5117
5661
|
|
|
5118
|
-
return _regeneratorRuntime.wrap(function
|
|
5662
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
5119
5663
|
while (1) {
|
|
5120
|
-
switch (
|
|
5664
|
+
switch (_context5.prev = _context5.next) {
|
|
5121
5665
|
case 0:
|
|
5122
|
-
options =
|
|
5123
|
-
|
|
5666
|
+
options = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : {};
|
|
5667
|
+
_context5.next = 3;
|
|
5124
5668
|
return _this.tokenManager.tokenReady();
|
|
5125
5669
|
|
|
5126
5670
|
case 3:
|
|
5127
5671
|
requestConfig = _this._enrichAxiosOptions(options);
|
|
5128
|
-
|
|
5672
|
+
_context5.prev = 4;
|
|
5129
5673
|
|
|
5130
5674
|
_this._logApiRequest(type, url, data, requestConfig);
|
|
5131
5675
|
|
|
5132
|
-
|
|
5133
|
-
|
|
5676
|
+
_context5.t0 = type;
|
|
5677
|
+
_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;
|
|
5134
5678
|
break;
|
|
5135
5679
|
|
|
5136
5680
|
case 9:
|
|
5137
|
-
|
|
5681
|
+
_context5.next = 11;
|
|
5138
5682
|
return _this.axiosInstance.get(url, requestConfig);
|
|
5139
5683
|
|
|
5140
5684
|
case 11:
|
|
5141
|
-
response =
|
|
5142
|
-
return
|
|
5685
|
+
response = _context5.sent;
|
|
5686
|
+
return _context5.abrupt("break", 34);
|
|
5143
5687
|
|
|
5144
5688
|
case 13:
|
|
5145
|
-
|
|
5689
|
+
_context5.next = 15;
|
|
5146
5690
|
return _this.axiosInstance.delete(url, requestConfig);
|
|
5147
5691
|
|
|
5148
5692
|
case 15:
|
|
5149
|
-
response =
|
|
5150
|
-
return
|
|
5693
|
+
response = _context5.sent;
|
|
5694
|
+
return _context5.abrupt("break", 34);
|
|
5151
5695
|
|
|
5152
5696
|
case 17:
|
|
5153
|
-
|
|
5697
|
+
_context5.next = 19;
|
|
5154
5698
|
return _this.axiosInstance.post(url, data, requestConfig);
|
|
5155
5699
|
|
|
5156
5700
|
case 19:
|
|
5157
|
-
response =
|
|
5158
|
-
return
|
|
5701
|
+
response = _context5.sent;
|
|
5702
|
+
return _context5.abrupt("break", 34);
|
|
5159
5703
|
|
|
5160
5704
|
case 21:
|
|
5161
|
-
|
|
5705
|
+
_context5.next = 23;
|
|
5162
5706
|
return _this.axiosInstance.put(url, data, requestConfig);
|
|
5163
5707
|
|
|
5164
5708
|
case 23:
|
|
5165
|
-
response =
|
|
5166
|
-
return
|
|
5709
|
+
response = _context5.sent;
|
|
5710
|
+
return _context5.abrupt("break", 34);
|
|
5167
5711
|
|
|
5168
5712
|
case 25:
|
|
5169
|
-
|
|
5713
|
+
_context5.next = 27;
|
|
5170
5714
|
return _this.axiosInstance.patch(url, data, requestConfig);
|
|
5171
5715
|
|
|
5172
5716
|
case 27:
|
|
5173
|
-
response =
|
|
5174
|
-
return
|
|
5717
|
+
response = _context5.sent;
|
|
5718
|
+
return _context5.abrupt("break", 34);
|
|
5175
5719
|
|
|
5176
5720
|
case 29:
|
|
5177
|
-
|
|
5721
|
+
_context5.next = 31;
|
|
5178
5722
|
return _this.axiosInstance.options(url, requestConfig);
|
|
5179
5723
|
|
|
5180
5724
|
case 31:
|
|
5181
|
-
response =
|
|
5182
|
-
return
|
|
5725
|
+
response = _context5.sent;
|
|
5726
|
+
return _context5.abrupt("break", 34);
|
|
5183
5727
|
|
|
5184
5728
|
case 33:
|
|
5185
5729
|
throw new Error('Invalid request type');
|
|
@@ -5188,65 +5732,66 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5188
5732
|
_this._logApiResponse(type, url, response);
|
|
5189
5733
|
|
|
5190
5734
|
_this.consecutiveFailures = 0;
|
|
5191
|
-
return
|
|
5735
|
+
return _context5.abrupt("return", _this.handleResponse(response));
|
|
5192
5736
|
|
|
5193
5737
|
case 39:
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5738
|
+
_context5.prev = 39;
|
|
5739
|
+
_context5.t1 = _context5["catch"](4);
|
|
5740
|
+
_context5.t1.client_request_id = (_requestConfig$header = requestConfig.headers) === null || _requestConfig$header === void 0 ? void 0 : _requestConfig$header['x-client-request-id'];
|
|
5197
5741
|
|
|
5198
|
-
_this._logApiError(type, url,
|
|
5742
|
+
_this._logApiError(type, url, _context5.t1);
|
|
5199
5743
|
|
|
5200
5744
|
_this.consecutiveFailures += 1;
|
|
5201
5745
|
|
|
5202
|
-
if (!
|
|
5203
|
-
|
|
5746
|
+
if (!_context5.t1.response) {
|
|
5747
|
+
_context5.next = 56;
|
|
5204
5748
|
break;
|
|
5205
5749
|
}
|
|
5206
5750
|
|
|
5207
|
-
if (!(
|
|
5208
|
-
|
|
5751
|
+
if (!(_context5.t1.response.data.code === chatCodes.TOKEN_EXPIRED && !_this.tokenManager.isStatic())) {
|
|
5752
|
+
_context5.next = 53;
|
|
5209
5753
|
break;
|
|
5210
5754
|
}
|
|
5211
5755
|
|
|
5212
5756
|
if (!(_this.consecutiveFailures > 1)) {
|
|
5213
|
-
|
|
5757
|
+
_context5.next = 49;
|
|
5214
5758
|
break;
|
|
5215
5759
|
}
|
|
5216
5760
|
|
|
5217
|
-
|
|
5761
|
+
_context5.next = 49;
|
|
5218
5762
|
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5219
5763
|
|
|
5220
5764
|
case 49:
|
|
5221
5765
|
_this.tokenManager.loadToken();
|
|
5222
5766
|
|
|
5223
|
-
|
|
5767
|
+
_context5.next = 52;
|
|
5224
5768
|
return _this.doAxiosRequest(type, url, data, options);
|
|
5225
5769
|
|
|
5226
5770
|
case 52:
|
|
5227
|
-
return
|
|
5771
|
+
return _context5.abrupt("return", _context5.sent);
|
|
5228
5772
|
|
|
5229
5773
|
case 53:
|
|
5230
|
-
return
|
|
5774
|
+
return _context5.abrupt("return", _this.handleResponse(_context5.t1.response));
|
|
5231
5775
|
|
|
5232
5776
|
case 56:
|
|
5233
|
-
throw
|
|
5777
|
+
throw _context5.t1;
|
|
5234
5778
|
|
|
5235
5779
|
case 57:
|
|
5236
5780
|
case "end":
|
|
5237
|
-
return
|
|
5781
|
+
return _context5.stop();
|
|
5238
5782
|
}
|
|
5239
5783
|
}
|
|
5240
|
-
},
|
|
5784
|
+
}, _callee5, null, [[4, 39]]);
|
|
5241
5785
|
}));
|
|
5242
5786
|
|
|
5243
|
-
return function (
|
|
5244
|
-
return
|
|
5787
|
+
return function (_x5, _x6, _x7) {
|
|
5788
|
+
return _ref5.apply(this, arguments);
|
|
5245
5789
|
};
|
|
5246
5790
|
}());
|
|
5247
5791
|
|
|
5248
5792
|
_defineProperty(this, "dispatchEvent", function (event) {
|
|
5249
|
-
// client event handlers
|
|
5793
|
+
if (!event.received_at) event.received_at = new Date(); // client event handlers
|
|
5794
|
+
|
|
5250
5795
|
var postListenerCallbacks = _this._handleClientEvent(event); // channel event handlers
|
|
5251
5796
|
|
|
5252
5797
|
|
|
@@ -5272,7 +5817,6 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5272
5817
|
// dispatch the event to the channel listeners
|
|
5273
5818
|
var jsonString = messageEvent.data;
|
|
5274
5819
|
var event = JSON.parse(jsonString);
|
|
5275
|
-
event.received_at = new Date();
|
|
5276
5820
|
|
|
5277
5821
|
_this.dispatchEvent(event);
|
|
5278
5822
|
});
|
|
@@ -5393,22 +5937,20 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5393
5937
|
}
|
|
5394
5938
|
});
|
|
5395
5939
|
|
|
5396
|
-
_defineProperty(this, "recoverState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
5397
|
-
var _this$wsConnection3;
|
|
5398
|
-
|
|
5940
|
+
_defineProperty(this, "recoverState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
5399
5941
|
var cids;
|
|
5400
|
-
return _regeneratorRuntime.wrap(function
|
|
5942
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
5401
5943
|
while (1) {
|
|
5402
|
-
switch (
|
|
5944
|
+
switch (_context6.prev = _context6.next) {
|
|
5403
5945
|
case 0:
|
|
5404
|
-
_this.logger('info', "client:recoverState() - Start of recoverState with connectionID ".concat(
|
|
5946
|
+
_this.logger('info', "client:recoverState() - Start of recoverState with connectionID ".concat(_this._getConnectionID()), {
|
|
5405
5947
|
tags: ['connection']
|
|
5406
5948
|
});
|
|
5407
5949
|
|
|
5408
5950
|
cids = Object.keys(_this.activeChannels);
|
|
5409
5951
|
|
|
5410
5952
|
if (!(cids.length && _this.recoverStateOnReconnect)) {
|
|
5411
|
-
|
|
5953
|
+
_context6.next = 10;
|
|
5412
5954
|
break;
|
|
5413
5955
|
}
|
|
5414
5956
|
|
|
@@ -5416,7 +5958,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5416
5958
|
tags: ['connection', 'client']
|
|
5417
5959
|
});
|
|
5418
5960
|
|
|
5419
|
-
|
|
5961
|
+
_context6.next = 6;
|
|
5420
5962
|
return _this.queryChannels({
|
|
5421
5963
|
cid: {
|
|
5422
5964
|
$in: cids
|
|
@@ -5436,7 +5978,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5436
5978
|
type: 'connection.recovered'
|
|
5437
5979
|
});
|
|
5438
5980
|
|
|
5439
|
-
|
|
5981
|
+
_context6.next = 11;
|
|
5440
5982
|
break;
|
|
5441
5983
|
|
|
5442
5984
|
case 10:
|
|
@@ -5450,10 +5992,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5450
5992
|
|
|
5451
5993
|
case 13:
|
|
5452
5994
|
case "end":
|
|
5453
|
-
return
|
|
5995
|
+
return _context6.stop();
|
|
5454
5996
|
}
|
|
5455
5997
|
}
|
|
5456
|
-
},
|
|
5998
|
+
}, _callee6);
|
|
5457
5999
|
})));
|
|
5458
6000
|
|
|
5459
6001
|
_defineProperty(this, "getChannelByMembers", function (channelType, custom) {
|
|
@@ -5533,66 +6075,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5533
6075
|
return !!_this.secret;
|
|
5534
6076
|
});
|
|
5535
6077
|
|
|
5536
|
-
_defineProperty(this, "
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
i = 0;
|
|
5545
|
-
|
|
5546
|
-
case 2:
|
|
5547
|
-
if (!(i < maxAttempts)) {
|
|
5548
|
-
_context6.next = 18;
|
|
5549
|
-
break;
|
|
5550
|
-
}
|
|
5551
|
-
|
|
5552
|
-
_context6.prev = 3;
|
|
5553
|
-
_context6.next = 6;
|
|
5554
|
-
return _this.axiosInstance.post("https://chat-insights.getstream.io/insights/".concat(insightType), insights);
|
|
5555
|
-
|
|
5556
|
-
case 6:
|
|
5557
|
-
_context6.next = 14;
|
|
5558
|
-
break;
|
|
5559
|
-
|
|
5560
|
-
case 8:
|
|
5561
|
-
_context6.prev = 8;
|
|
5562
|
-
_context6.t0 = _context6["catch"](3);
|
|
5563
|
-
|
|
5564
|
-
_this.logger('warn', "failed to send insights event ".concat(insightType), {
|
|
5565
|
-
tags: ['insights', 'connection'],
|
|
5566
|
-
error: _context6.t0,
|
|
5567
|
-
insights: insights
|
|
5568
|
-
});
|
|
5569
|
-
|
|
5570
|
-
_context6.next = 13;
|
|
5571
|
-
return sleep((i + 1) * 3000);
|
|
5572
|
-
|
|
5573
|
-
case 13:
|
|
5574
|
-
return _context6.abrupt("continue", 15);
|
|
5575
|
-
|
|
5576
|
-
case 14:
|
|
5577
|
-
return _context6.abrupt("break", 18);
|
|
5578
|
-
|
|
5579
|
-
case 15:
|
|
5580
|
-
i++;
|
|
5581
|
-
_context6.next = 2;
|
|
5582
|
-
break;
|
|
5583
|
-
|
|
5584
|
-
case 18:
|
|
5585
|
-
case "end":
|
|
5586
|
-
return _context6.stop();
|
|
5587
|
-
}
|
|
5588
|
-
}
|
|
5589
|
-
}, _callee6, null, [[3, 8]]);
|
|
5590
|
-
}));
|
|
5591
|
-
|
|
5592
|
-
return function (_x7, _x8) {
|
|
5593
|
-
return _ref6.apply(this, arguments);
|
|
5594
|
-
};
|
|
5595
|
-
}());
|
|
6078
|
+
_defineProperty(this, "_buildWSPayload", function (client_request_id) {
|
|
6079
|
+
return JSON.stringify({
|
|
6080
|
+
user_id: _this.userID,
|
|
6081
|
+
user_details: _this._user,
|
|
6082
|
+
device: _this.options.device,
|
|
6083
|
+
client_request_id: client_request_id
|
|
6084
|
+
});
|
|
6085
|
+
});
|
|
5596
6086
|
|
|
5597
6087
|
// set the key
|
|
5598
6088
|
this.key = _key;
|
|
@@ -5650,6 +6140,8 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5650
6140
|
this.tokenManager = new TokenManager(this.secret);
|
|
5651
6141
|
this.consecutiveFailures = 0;
|
|
5652
6142
|
this.insightMetrics = new InsightMetrics();
|
|
6143
|
+
this.defaultWSTimeoutWithFallback = 6000;
|
|
6144
|
+
this.defaultWSTimeout = 15000;
|
|
5653
6145
|
/**
|
|
5654
6146
|
* logger function should accept 3 parameters:
|
|
5655
6147
|
* @param logLevel string
|
|
@@ -5823,7 +6315,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5823
6315
|
}, _callee7, this);
|
|
5824
6316
|
}));
|
|
5825
6317
|
|
|
5826
|
-
function updateAppSettings(
|
|
6318
|
+
function updateAppSettings(_x8) {
|
|
5827
6319
|
return _updateAppSettings.apply(this, arguments);
|
|
5828
6320
|
}
|
|
5829
6321
|
|
|
@@ -5857,7 +6349,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5857
6349
|
}, _callee8, this);
|
|
5858
6350
|
}));
|
|
5859
6351
|
|
|
5860
|
-
function revokeTokens(
|
|
6352
|
+
function revokeTokens(_x9) {
|
|
5861
6353
|
return _revokeTokens.apply(this, arguments);
|
|
5862
6354
|
}
|
|
5863
6355
|
|
|
@@ -5889,7 +6381,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5889
6381
|
}, _callee9, this);
|
|
5890
6382
|
}));
|
|
5891
6383
|
|
|
5892
|
-
function revokeUserToken(
|
|
6384
|
+
function revokeUserToken(_x10, _x11) {
|
|
5893
6385
|
return _revokeUserToken.apply(this, arguments);
|
|
5894
6386
|
}
|
|
5895
6387
|
|
|
@@ -5948,7 +6440,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5948
6440
|
}, _callee10, this);
|
|
5949
6441
|
}));
|
|
5950
6442
|
|
|
5951
|
-
function revokeUsersToken(
|
|
6443
|
+
function revokeUsersToken(_x12, _x13) {
|
|
5952
6444
|
return _revokeUsersToken.apply(this, arguments);
|
|
5953
6445
|
}
|
|
5954
6446
|
|
|
@@ -6040,7 +6532,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6040
6532
|
}, _callee12, this);
|
|
6041
6533
|
}));
|
|
6042
6534
|
|
|
6043
|
-
function testPushSettings(
|
|
6535
|
+
function testPushSettings(_x14) {
|
|
6044
6536
|
return _testPushSettings.apply(this, arguments);
|
|
6045
6537
|
}
|
|
6046
6538
|
|
|
@@ -6149,7 +6641,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6149
6641
|
}, _callee14, this, [[1, 7]]);
|
|
6150
6642
|
}));
|
|
6151
6643
|
|
|
6152
|
-
function setGuestUser(
|
|
6644
|
+
function setGuestUser(_x15) {
|
|
6153
6645
|
return _setGuestUser.apply(this, arguments);
|
|
6154
6646
|
}
|
|
6155
6647
|
|
|
@@ -6460,72 +6952,84 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6460
6952
|
*/
|
|
6461
6953
|
function () {
|
|
6462
6954
|
var _connect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() {
|
|
6463
|
-
var client;
|
|
6464
6955
|
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
6465
6956
|
while (1) {
|
|
6466
6957
|
switch (_context15.prev = _context15.next) {
|
|
6467
6958
|
case 0:
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
if (!(client.userID == null || this._user == null)) {
|
|
6472
|
-
_context15.next = 4;
|
|
6959
|
+
if (!(!this.userID || !this._user)) {
|
|
6960
|
+
_context15.next = 2;
|
|
6473
6961
|
break;
|
|
6474
6962
|
}
|
|
6475
6963
|
|
|
6476
6964
|
throw Error('Call connectUser or connectAnonymousUser before starting the connection');
|
|
6477
6965
|
|
|
6478
|
-
case
|
|
6479
|
-
if (
|
|
6480
|
-
_context15.next =
|
|
6966
|
+
case 2:
|
|
6967
|
+
if (this.wsBaseURL) {
|
|
6968
|
+
_context15.next = 4;
|
|
6481
6969
|
break;
|
|
6482
6970
|
}
|
|
6483
6971
|
|
|
6484
6972
|
throw Error('Websocket base url not set');
|
|
6485
6973
|
|
|
6486
|
-
case
|
|
6487
|
-
if (
|
|
6488
|
-
_context15.next =
|
|
6974
|
+
case 4:
|
|
6975
|
+
if (this.clientID) {
|
|
6976
|
+
_context15.next = 6;
|
|
6489
6977
|
break;
|
|
6490
6978
|
}
|
|
6491
6979
|
|
|
6492
6980
|
throw Error('clientID is not set');
|
|
6493
6981
|
|
|
6494
|
-
case
|
|
6982
|
+
case 6:
|
|
6495
6983
|
if (!this.wsConnection && (this.options.warmUp || this.options.enableInsights)) {
|
|
6496
|
-
this.
|
|
6984
|
+
this._sayHi();
|
|
6497
6985
|
} // The StableWSConnection handles all the reconnection logic.
|
|
6498
6986
|
|
|
6499
6987
|
|
|
6500
6988
|
this.wsConnection = new StableWSConnection({
|
|
6501
|
-
|
|
6502
|
-
clientID: client.clientID,
|
|
6503
|
-
userID: client.userID,
|
|
6504
|
-
tokenManager: client.tokenManager,
|
|
6505
|
-
user: this._user,
|
|
6506
|
-
authType: this.getAuthType(),
|
|
6507
|
-
userAgent: this.getUserAgent(),
|
|
6508
|
-
apiKey: this.key,
|
|
6509
|
-
recoverCallback: this.recoverState,
|
|
6510
|
-
messageCallback: this.handleEvent,
|
|
6511
|
-
eventCallback: this.dispatchEvent,
|
|
6512
|
-
logger: this.logger,
|
|
6513
|
-
device: this.options.device,
|
|
6514
|
-
postInsights: this.options.enableInsights ? this.postInsights : undefined,
|
|
6515
|
-
insightMetrics: this.insightMetrics
|
|
6989
|
+
client: this
|
|
6516
6990
|
});
|
|
6517
|
-
_context15.
|
|
6518
|
-
|
|
6991
|
+
_context15.prev = 8;
|
|
6992
|
+
_context15.next = 11;
|
|
6993
|
+
return this.wsConnection.connect(this.options.enableWSFallback ? this.defaultWSTimeoutWithFallback : this.defaultWSTimeout);
|
|
6519
6994
|
|
|
6520
|
-
case
|
|
6995
|
+
case 11:
|
|
6521
6996
|
return _context15.abrupt("return", _context15.sent);
|
|
6522
6997
|
|
|
6523
|
-
case
|
|
6998
|
+
case 14:
|
|
6999
|
+
_context15.prev = 14;
|
|
7000
|
+
_context15.t0 = _context15["catch"](8);
|
|
7001
|
+
|
|
7002
|
+
if (!(this.options.enableWSFallback && isWSFailure(_context15.t0) && isOnline())) {
|
|
7003
|
+
_context15.next = 24;
|
|
7004
|
+
break;
|
|
7005
|
+
}
|
|
7006
|
+
|
|
7007
|
+
this.logger('info', 'client:connect() - WS failed, fallback to longpoll', {
|
|
7008
|
+
tags: ['connection', 'client']
|
|
7009
|
+
});
|
|
7010
|
+
|
|
7011
|
+
this.wsConnection._destroyCurrentWSConnection();
|
|
7012
|
+
|
|
7013
|
+
this.wsConnection.disconnect().then(); // close WS so no retry
|
|
7014
|
+
|
|
7015
|
+
this.wsFallback = new WSConnectionFallback({
|
|
7016
|
+
client: this
|
|
7017
|
+
});
|
|
7018
|
+
_context15.next = 23;
|
|
7019
|
+
return this.wsFallback.connect();
|
|
7020
|
+
|
|
7021
|
+
case 23:
|
|
7022
|
+
return _context15.abrupt("return", _context15.sent);
|
|
7023
|
+
|
|
7024
|
+
case 24:
|
|
7025
|
+
throw _context15.t0;
|
|
7026
|
+
|
|
7027
|
+
case 25:
|
|
6524
7028
|
case "end":
|
|
6525
7029
|
return _context15.stop();
|
|
6526
7030
|
}
|
|
6527
7031
|
}
|
|
6528
|
-
}, _callee15, this);
|
|
7032
|
+
}, _callee15, this, [[8, 14]]);
|
|
6529
7033
|
}));
|
|
6530
7034
|
|
|
6531
7035
|
function connect() {
|
|
@@ -6534,9 +7038,15 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6534
7038
|
|
|
6535
7039
|
return connect;
|
|
6536
7040
|
}()
|
|
7041
|
+
/**
|
|
7042
|
+
* Check the connectivity with server for warmup purpose.
|
|
7043
|
+
*
|
|
7044
|
+
* @private
|
|
7045
|
+
*/
|
|
7046
|
+
|
|
6537
7047
|
}, {
|
|
6538
|
-
key: "
|
|
6539
|
-
value: function
|
|
7048
|
+
key: "_sayHi",
|
|
7049
|
+
value: function _sayHi() {
|
|
6540
7050
|
var _this4 = this;
|
|
6541
7051
|
|
|
6542
7052
|
var client_request_id = randomId();
|
|
@@ -6545,12 +7055,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6545
7055
|
'x-client-request-id': client_request_id
|
|
6546
7056
|
}
|
|
6547
7057
|
};
|
|
6548
|
-
this.doAxiosRequest('get', this.baseURL + '/
|
|
6549
|
-
_this4.
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
7058
|
+
this.doAxiosRequest('get', this.baseURL + '/hi', null, opts).catch(function (e) {
|
|
7059
|
+
if (_this4.options.enableInsights) {
|
|
7060
|
+
postInsights('http_hi_failed', {
|
|
7061
|
+
api_key: _this4.key,
|
|
7062
|
+
err: e,
|
|
7063
|
+
client_request_id: client_request_id
|
|
7064
|
+
});
|
|
7065
|
+
}
|
|
6554
7066
|
});
|
|
6555
7067
|
}
|
|
6556
7068
|
/**
|
|
@@ -6613,7 +7125,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6613
7125
|
}, _callee16, this);
|
|
6614
7126
|
}));
|
|
6615
7127
|
|
|
6616
|
-
function queryUsers(
|
|
7128
|
+
function queryUsers(_x16) {
|
|
6617
7129
|
return _queryUsers.apply(this, arguments);
|
|
6618
7130
|
}
|
|
6619
7131
|
|
|
@@ -6832,7 +7344,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6832
7344
|
}, _callee19, this);
|
|
6833
7345
|
}));
|
|
6834
7346
|
|
|
6835
|
-
function queryChannels(
|
|
7347
|
+
function queryChannels(_x17) {
|
|
6836
7348
|
return _queryChannels.apply(this, arguments);
|
|
6837
7349
|
}
|
|
6838
7350
|
|
|
@@ -6918,7 +7430,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6918
7430
|
}, _callee20, this);
|
|
6919
7431
|
}));
|
|
6920
7432
|
|
|
6921
|
-
function search(
|
|
7433
|
+
function search(_x18, _x19) {
|
|
6922
7434
|
return _search.apply(this, arguments);
|
|
6923
7435
|
}
|
|
6924
7436
|
|
|
@@ -6936,7 +7448,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6936
7448
|
}, {
|
|
6937
7449
|
key: "setLocalDevice",
|
|
6938
7450
|
value: function setLocalDevice(device) {
|
|
6939
|
-
if (this.wsConnection) {
|
|
7451
|
+
if (this.wsConnection || this.wsFallback) {
|
|
6940
7452
|
throw new Error('you can only set device before opening a websocket connection');
|
|
6941
7453
|
}
|
|
6942
7454
|
|
|
@@ -6978,7 +7490,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6978
7490
|
}, _callee21, this);
|
|
6979
7491
|
}));
|
|
6980
7492
|
|
|
6981
|
-
function addDevice(_x21, _x22
|
|
7493
|
+
function addDevice(_x20, _x21, _x22) {
|
|
6982
7494
|
return _addDevice.apply(this, arguments);
|
|
6983
7495
|
}
|
|
6984
7496
|
|
|
@@ -7016,7 +7528,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7016
7528
|
}, _callee22, this);
|
|
7017
7529
|
}));
|
|
7018
7530
|
|
|
7019
|
-
function getDevices(
|
|
7531
|
+
function getDevices(_x23) {
|
|
7020
7532
|
return _getDevices.apply(this, arguments);
|
|
7021
7533
|
}
|
|
7022
7534
|
|
|
@@ -7056,7 +7568,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7056
7568
|
}, _callee23, this);
|
|
7057
7569
|
}));
|
|
7058
7570
|
|
|
7059
|
-
function removeDevice(
|
|
7571
|
+
function removeDevice(_x24, _x25) {
|
|
7060
7572
|
return _removeDevice.apply(this, arguments);
|
|
7061
7573
|
}
|
|
7062
7574
|
|
|
@@ -7097,7 +7609,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7097
7609
|
}, _callee24, this);
|
|
7098
7610
|
}));
|
|
7099
7611
|
|
|
7100
|
-
function getRateLimits(
|
|
7612
|
+
function getRateLimits(_x26) {
|
|
7101
7613
|
return _getRateLimits.apply(this, arguments);
|
|
7102
7614
|
}
|
|
7103
7615
|
|
|
@@ -7198,7 +7710,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7198
7710
|
}, _callee25, this);
|
|
7199
7711
|
}));
|
|
7200
7712
|
|
|
7201
|
-
function partialUpdateUser(
|
|
7713
|
+
function partialUpdateUser(_x27) {
|
|
7202
7714
|
return _partialUpdateUser.apply(this, arguments);
|
|
7203
7715
|
}
|
|
7204
7716
|
|
|
@@ -7284,7 +7796,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7284
7796
|
}, _callee26, this, [[2, 13, 16, 19]]);
|
|
7285
7797
|
}));
|
|
7286
7798
|
|
|
7287
|
-
function upsertUsers(
|
|
7799
|
+
function upsertUsers(_x28) {
|
|
7288
7800
|
return _upsertUsers.apply(this, arguments);
|
|
7289
7801
|
}
|
|
7290
7802
|
|
|
@@ -7397,7 +7909,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7397
7909
|
}, _callee27, this, [[1, 11, 14, 17]]);
|
|
7398
7910
|
}));
|
|
7399
7911
|
|
|
7400
|
-
function partialUpdateUsers(
|
|
7912
|
+
function partialUpdateUsers(_x29) {
|
|
7401
7913
|
return _partialUpdateUsers.apply(this, arguments);
|
|
7402
7914
|
}
|
|
7403
7915
|
|
|
@@ -7425,7 +7937,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7425
7937
|
}, _callee28, this);
|
|
7426
7938
|
}));
|
|
7427
7939
|
|
|
7428
|
-
function deleteUser(
|
|
7940
|
+
function deleteUser(_x30, _x31) {
|
|
7429
7941
|
return _deleteUser.apply(this, arguments);
|
|
7430
7942
|
}
|
|
7431
7943
|
|
|
@@ -7453,7 +7965,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7453
7965
|
}, _callee29, this);
|
|
7454
7966
|
}));
|
|
7455
7967
|
|
|
7456
|
-
function reactivateUser(
|
|
7968
|
+
function reactivateUser(_x32, _x33) {
|
|
7457
7969
|
return _reactivateUser.apply(this, arguments);
|
|
7458
7970
|
}
|
|
7459
7971
|
|
|
@@ -7481,7 +7993,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7481
7993
|
}, _callee30, this);
|
|
7482
7994
|
}));
|
|
7483
7995
|
|
|
7484
|
-
function deactivateUser(
|
|
7996
|
+
function deactivateUser(_x34, _x35) {
|
|
7485
7997
|
return _deactivateUser.apply(this, arguments);
|
|
7486
7998
|
}
|
|
7487
7999
|
|
|
@@ -7509,7 +8021,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7509
8021
|
}, _callee31, this);
|
|
7510
8022
|
}));
|
|
7511
8023
|
|
|
7512
|
-
function exportUser(
|
|
8024
|
+
function exportUser(_x36, _x37) {
|
|
7513
8025
|
return _exportUser.apply(this, arguments);
|
|
7514
8026
|
}
|
|
7515
8027
|
|
|
@@ -7530,27 +8042,15 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7530
8042
|
while (1) {
|
|
7531
8043
|
switch (_context32.prev = _context32.next) {
|
|
7532
8044
|
case 0:
|
|
7533
|
-
|
|
7534
|
-
options.banned_by_id = options.user_id;
|
|
7535
|
-
delete options.user_id;
|
|
7536
|
-
console.warn("banUser: 'user_id' is deprecated, please consider switching to 'banned_by_id'");
|
|
7537
|
-
}
|
|
7538
|
-
|
|
7539
|
-
if ((options === null || options === void 0 ? void 0 : options.user) !== undefined) {
|
|
7540
|
-
options.banned_by = options.user;
|
|
7541
|
-
delete options.user;
|
|
7542
|
-
console.warn("banUser: 'user' is deprecated, please consider switching to 'banned_by'");
|
|
7543
|
-
}
|
|
7544
|
-
|
|
7545
|
-
_context32.next = 4;
|
|
8045
|
+
_context32.next = 2;
|
|
7546
8046
|
return this.post(this.baseURL + '/moderation/ban', _objectSpread({
|
|
7547
8047
|
target_user_id: targetUserID
|
|
7548
8048
|
}, options));
|
|
7549
8049
|
|
|
7550
|
-
case
|
|
8050
|
+
case 2:
|
|
7551
8051
|
return _context32.abrupt("return", _context32.sent);
|
|
7552
8052
|
|
|
7553
|
-
case
|
|
8053
|
+
case 3:
|
|
7554
8054
|
case "end":
|
|
7555
8055
|
return _context32.stop();
|
|
7556
8056
|
}
|
|
@@ -7558,7 +8058,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7558
8058
|
}, _callee32, this);
|
|
7559
8059
|
}));
|
|
7560
8060
|
|
|
7561
|
-
function banUser(
|
|
8061
|
+
function banUser(_x38, _x39) {
|
|
7562
8062
|
return _banUser.apply(this, arguments);
|
|
7563
8063
|
}
|
|
7564
8064
|
|
|
@@ -7595,7 +8095,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7595
8095
|
}, _callee33, this);
|
|
7596
8096
|
}));
|
|
7597
8097
|
|
|
7598
|
-
function unbanUser(
|
|
8098
|
+
function unbanUser(_x40, _x41) {
|
|
7599
8099
|
return _unbanUser.apply(this, arguments);
|
|
7600
8100
|
}
|
|
7601
8101
|
|
|
@@ -7632,7 +8132,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7632
8132
|
}, _callee34, this);
|
|
7633
8133
|
}));
|
|
7634
8134
|
|
|
7635
|
-
function shadowBan(
|
|
8135
|
+
function shadowBan(_x42, _x43) {
|
|
7636
8136
|
return _shadowBan.apply(this, arguments);
|
|
7637
8137
|
}
|
|
7638
8138
|
|
|
@@ -7669,7 +8169,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7669
8169
|
}, _callee35, this);
|
|
7670
8170
|
}));
|
|
7671
8171
|
|
|
7672
|
-
function removeShadowBan(
|
|
8172
|
+
function removeShadowBan(_x44, _x45) {
|
|
7673
8173
|
return _removeShadowBan.apply(this, arguments);
|
|
7674
8174
|
}
|
|
7675
8175
|
|
|
@@ -7712,7 +8212,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7712
8212
|
}, _callee36, this);
|
|
7713
8213
|
}));
|
|
7714
8214
|
|
|
7715
|
-
function muteUser(
|
|
8215
|
+
function muteUser(_x46, _x47) {
|
|
7716
8216
|
return _muteUser.apply(this, arguments);
|
|
7717
8217
|
}
|
|
7718
8218
|
|
|
@@ -7751,7 +8251,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7751
8251
|
}, _callee37, this);
|
|
7752
8252
|
}));
|
|
7753
8253
|
|
|
7754
|
-
function unmuteUser(
|
|
8254
|
+
function unmuteUser(_x48, _x49) {
|
|
7755
8255
|
return _unmuteUser.apply(this, arguments);
|
|
7756
8256
|
}
|
|
7757
8257
|
|
|
@@ -7810,7 +8310,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7810
8310
|
}, _callee38, this);
|
|
7811
8311
|
}));
|
|
7812
8312
|
|
|
7813
|
-
function flagMessage(
|
|
8313
|
+
function flagMessage(_x50) {
|
|
7814
8314
|
return _flagMessage.apply(this, arguments);
|
|
7815
8315
|
}
|
|
7816
8316
|
|
|
@@ -7850,7 +8350,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7850
8350
|
}, _callee39, this);
|
|
7851
8351
|
}));
|
|
7852
8352
|
|
|
7853
|
-
function flagUser(
|
|
8353
|
+
function flagUser(_x51) {
|
|
7854
8354
|
return _flagUser.apply(this, arguments);
|
|
7855
8355
|
}
|
|
7856
8356
|
|
|
@@ -7890,7 +8390,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7890
8390
|
}, _callee40, this);
|
|
7891
8391
|
}));
|
|
7892
8392
|
|
|
7893
|
-
function unflagMessage(
|
|
8393
|
+
function unflagMessage(_x52) {
|
|
7894
8394
|
return _unflagMessage.apply(this, arguments);
|
|
7895
8395
|
}
|
|
7896
8396
|
|
|
@@ -7930,7 +8430,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7930
8430
|
}, _callee41, this);
|
|
7931
8431
|
}));
|
|
7932
8432
|
|
|
7933
|
-
function unflagUser(
|
|
8433
|
+
function unflagUser(_x53) {
|
|
7934
8434
|
return _unflagUser.apply(this, arguments);
|
|
7935
8435
|
}
|
|
7936
8436
|
|
|
@@ -8069,7 +8569,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8069
8569
|
}, _callee43, this);
|
|
8070
8570
|
}));
|
|
8071
8571
|
|
|
8072
|
-
function translateMessage(
|
|
8572
|
+
function translateMessage(_x54, _x55) {
|
|
8073
8573
|
return _translateMessage.apply(this, arguments);
|
|
8074
8574
|
}
|
|
8075
8575
|
|
|
@@ -8185,7 +8685,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8185
8685
|
case 2:
|
|
8186
8686
|
clonedMessage = _extends({}, message);
|
|
8187
8687
|
delete clonedMessage.id;
|
|
8188
|
-
reservedMessageFields = ['command', 'created_at', 'html', 'latest_reactions', 'own_reactions', 'reaction_counts', 'reply_count', 'type', 'updated_at', 'user', '__html'];
|
|
8688
|
+
reservedMessageFields = ['command', 'created_at', 'html', 'latest_reactions', 'own_reactions', 'quoted_message', 'reaction_counts', 'reply_count', 'type', 'updated_at', 'user', '__html'];
|
|
8189
8689
|
reservedMessageFields.forEach(function (item) {
|
|
8190
8690
|
if (clonedMessage[item] != null) {
|
|
8191
8691
|
delete clonedMessage[item];
|
|
@@ -8229,7 +8729,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8229
8729
|
}, _callee44, this);
|
|
8230
8730
|
}));
|
|
8231
8731
|
|
|
8232
|
-
function updateMessage(_x57, _x58
|
|
8732
|
+
function updateMessage(_x56, _x57, _x58) {
|
|
8233
8733
|
return _updateMessage.apply(this, arguments);
|
|
8234
8734
|
}
|
|
8235
8735
|
|
|
@@ -8290,7 +8790,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8290
8790
|
}, _callee45, this);
|
|
8291
8791
|
}));
|
|
8292
8792
|
|
|
8293
|
-
function partialUpdateMessage(_x60, _x61, _x62
|
|
8793
|
+
function partialUpdateMessage(_x59, _x60, _x61, _x62) {
|
|
8294
8794
|
return _partialUpdateMessage.apply(this, arguments);
|
|
8295
8795
|
}
|
|
8296
8796
|
|
|
@@ -8327,7 +8827,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8327
8827
|
}, _callee46, this);
|
|
8328
8828
|
}));
|
|
8329
8829
|
|
|
8330
|
-
function deleteMessage(
|
|
8830
|
+
function deleteMessage(_x63, _x64) {
|
|
8331
8831
|
return _deleteMessage.apply(this, arguments);
|
|
8332
8832
|
}
|
|
8333
8833
|
|
|
@@ -8355,7 +8855,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8355
8855
|
}, _callee47, this);
|
|
8356
8856
|
}));
|
|
8357
8857
|
|
|
8358
|
-
function getMessage(
|
|
8858
|
+
function getMessage(_x65) {
|
|
8359
8859
|
return _getMessage.apply(this, arguments);
|
|
8360
8860
|
}
|
|
8361
8861
|
|
|
@@ -8364,7 +8864,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8364
8864
|
}, {
|
|
8365
8865
|
key: "getUserAgent",
|
|
8366
8866
|
value: function getUserAgent() {
|
|
8367
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "
|
|
8867
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "5.0.0");
|
|
8368
8868
|
}
|
|
8369
8869
|
}, {
|
|
8370
8870
|
key: "setUserAgent",
|
|
@@ -8378,7 +8878,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8378
8878
|
}, {
|
|
8379
8879
|
key: "_enrichAxiosOptions",
|
|
8380
8880
|
value: function _enrichAxiosOptions() {
|
|
8381
|
-
var _options$headers
|
|
8881
|
+
var _options$headers;
|
|
8382
8882
|
|
|
8383
8883
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
8384
8884
|
params: {},
|
|
@@ -8388,10 +8888,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8388
8888
|
|
|
8389
8889
|
var token = this._getToken();
|
|
8390
8890
|
|
|
8891
|
+
var authorization = token ? {
|
|
8892
|
+
Authorization: token
|
|
8893
|
+
} : undefined;
|
|
8894
|
+
|
|
8391
8895
|
if (!((_options$headers = options.headers) !== null && _options$headers !== void 0 && _options$headers['x-client-request-id'])) {
|
|
8392
|
-
options.headers = {
|
|
8896
|
+
options.headers = _objectSpread(_objectSpread({}, options.headers), {}, {
|
|
8393
8897
|
'x-client-request-id': randomId()
|
|
8394
|
-
};
|
|
8898
|
+
});
|
|
8395
8899
|
}
|
|
8396
8900
|
|
|
8397
8901
|
return _objectSpread({
|
|
@@ -8399,10 +8903,9 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8399
8903
|
user_id: this.userID
|
|
8400
8904
|
}, options.params), {}, {
|
|
8401
8905
|
api_key: this.key,
|
|
8402
|
-
connection_id:
|
|
8906
|
+
connection_id: this._getConnectionID()
|
|
8403
8907
|
}),
|
|
8404
|
-
headers: _objectSpread({
|
|
8405
|
-
Authorization: token,
|
|
8908
|
+
headers: _objectSpread(_objectSpread({}, authorization), {}, {
|
|
8406
8909
|
'stream-auth-type': this.getAuthType(),
|
|
8407
8910
|
'X-Stream-Client': this.getUserAgent()
|
|
8408
8911
|
}, options.headers)
|
|
@@ -8432,6 +8935,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8432
8935
|
}
|
|
8433
8936
|
}, 500);
|
|
8434
8937
|
}
|
|
8938
|
+
/**
|
|
8939
|
+
* encode ws url payload
|
|
8940
|
+
* @private
|
|
8941
|
+
* @returns json string
|
|
8942
|
+
*/
|
|
8943
|
+
|
|
8435
8944
|
}, {
|
|
8436
8945
|
key: "verifyWebhook",
|
|
8437
8946
|
value: function verifyWebhook(requestBody, xSignature) {
|
|
@@ -8572,7 +9081,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8572
9081
|
}, _callee48, this);
|
|
8573
9082
|
}));
|
|
8574
9083
|
|
|
8575
|
-
function sendUserCustomEvent(
|
|
9084
|
+
function sendUserCustomEvent(_x66, _x67) {
|
|
8576
9085
|
return _sendUserCustomEvent.apply(this, arguments);
|
|
8577
9086
|
}
|
|
8578
9087
|
|
|
@@ -8660,7 +9169,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8660
9169
|
}, _callee49, this);
|
|
8661
9170
|
}));
|
|
8662
9171
|
|
|
8663
|
-
function createSegment(
|
|
9172
|
+
function createSegment(_x68) {
|
|
8664
9173
|
return _createSegment.apply(this, arguments);
|
|
8665
9174
|
}
|
|
8666
9175
|
|
|
@@ -8700,7 +9209,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8700
9209
|
}, _callee50, this);
|
|
8701
9210
|
}));
|
|
8702
9211
|
|
|
8703
|
-
function getSegment(
|
|
9212
|
+
function getSegment(_x69) {
|
|
8704
9213
|
return _getSegment.apply(this, arguments);
|
|
8705
9214
|
}
|
|
8706
9215
|
|
|
@@ -8739,7 +9248,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8739
9248
|
}, _callee51, this);
|
|
8740
9249
|
}));
|
|
8741
9250
|
|
|
8742
|
-
function listSegments(
|
|
9251
|
+
function listSegments(_x70) {
|
|
8743
9252
|
return _listSegments.apply(this, arguments);
|
|
8744
9253
|
}
|
|
8745
9254
|
|
|
@@ -8782,7 +9291,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8782
9291
|
}, _callee52, this);
|
|
8783
9292
|
}));
|
|
8784
9293
|
|
|
8785
|
-
function updateSegment(
|
|
9294
|
+
function updateSegment(_x71, _x72) {
|
|
8786
9295
|
return _updateSegment.apply(this, arguments);
|
|
8787
9296
|
}
|
|
8788
9297
|
|
|
@@ -8814,7 +9323,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8814
9323
|
}, _callee53, this);
|
|
8815
9324
|
}));
|
|
8816
9325
|
|
|
8817
|
-
function deleteSegment(
|
|
9326
|
+
function deleteSegment(_x73) {
|
|
8818
9327
|
return _deleteSegment.apply(this, arguments);
|
|
8819
9328
|
}
|
|
8820
9329
|
|
|
@@ -8856,7 +9365,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8856
9365
|
}, _callee54, this);
|
|
8857
9366
|
}));
|
|
8858
9367
|
|
|
8859
|
-
function createCampaign(
|
|
9368
|
+
function createCampaign(_x74) {
|
|
8860
9369
|
return _createCampaign.apply(this, arguments);
|
|
8861
9370
|
}
|
|
8862
9371
|
|
|
@@ -8896,7 +9405,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8896
9405
|
}, _callee55, this);
|
|
8897
9406
|
}));
|
|
8898
9407
|
|
|
8899
|
-
function getCampaign(
|
|
9408
|
+
function getCampaign(_x75) {
|
|
8900
9409
|
return _getCampaign.apply(this, arguments);
|
|
8901
9410
|
}
|
|
8902
9411
|
|
|
@@ -8935,7 +9444,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8935
9444
|
}, _callee56, this);
|
|
8936
9445
|
}));
|
|
8937
9446
|
|
|
8938
|
-
function listCampaigns(
|
|
9447
|
+
function listCampaigns(_x76) {
|
|
8939
9448
|
return _listCampaigns.apply(this, arguments);
|
|
8940
9449
|
}
|
|
8941
9450
|
|
|
@@ -8978,7 +9487,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8978
9487
|
}, _callee57, this);
|
|
8979
9488
|
}));
|
|
8980
9489
|
|
|
8981
|
-
function updateCampaign(
|
|
9490
|
+
function updateCampaign(_x77, _x78) {
|
|
8982
9491
|
return _updateCampaign.apply(this, arguments);
|
|
8983
9492
|
}
|
|
8984
9493
|
|
|
@@ -9010,7 +9519,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9010
9519
|
}, _callee58, this);
|
|
9011
9520
|
}));
|
|
9012
9521
|
|
|
9013
|
-
function deleteCampaign(
|
|
9522
|
+
function deleteCampaign(_x79) {
|
|
9014
9523
|
return _deleteCampaign.apply(this, arguments);
|
|
9015
9524
|
}
|
|
9016
9525
|
|
|
@@ -9054,7 +9563,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9054
9563
|
}, _callee59, this);
|
|
9055
9564
|
}));
|
|
9056
9565
|
|
|
9057
|
-
function scheduleCampaign(
|
|
9566
|
+
function scheduleCampaign(_x80, _x81) {
|
|
9058
9567
|
return _scheduleCampaign.apply(this, arguments);
|
|
9059
9568
|
}
|
|
9060
9569
|
|
|
@@ -9094,7 +9603,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9094
9603
|
}, _callee60, this);
|
|
9095
9604
|
}));
|
|
9096
9605
|
|
|
9097
|
-
function stopCampaign(
|
|
9606
|
+
function stopCampaign(_x82) {
|
|
9098
9607
|
return _stopCampaign.apply(this, arguments);
|
|
9099
9608
|
}
|
|
9100
9609
|
|
|
@@ -9134,7 +9643,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9134
9643
|
}, _callee61, this);
|
|
9135
9644
|
}));
|
|
9136
9645
|
|
|
9137
|
-
function resumeCampaign(
|
|
9646
|
+
function resumeCampaign(_x83) {
|
|
9138
9647
|
return _resumeCampaign.apply(this, arguments);
|
|
9139
9648
|
}
|
|
9140
9649
|
|
|
@@ -9177,7 +9686,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9177
9686
|
}, _callee62, this);
|
|
9178
9687
|
}));
|
|
9179
9688
|
|
|
9180
|
-
function testCampaign(
|
|
9689
|
+
function testCampaign(_x84, _x85) {
|
|
9181
9690
|
return _testCampaign.apply(this, arguments);
|
|
9182
9691
|
}
|
|
9183
9692
|
|
|
@@ -9210,7 +9719,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9210
9719
|
}, _callee63, this);
|
|
9211
9720
|
}));
|
|
9212
9721
|
|
|
9213
|
-
function enrichURL(
|
|
9722
|
+
function enrichURL(_x86) {
|
|
9214
9723
|
return _enrichURL.apply(this, arguments);
|
|
9215
9724
|
}
|
|
9216
9725
|
|
|
@@ -9242,7 +9751,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9242
9751
|
}, _callee64, this);
|
|
9243
9752
|
}));
|
|
9244
9753
|
|
|
9245
|
-
function getTask(
|
|
9754
|
+
function getTask(_x87) {
|
|
9246
9755
|
return _getTask.apply(this, arguments);
|
|
9247
9756
|
}
|
|
9248
9757
|
|
|
@@ -9284,15 +9793,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9284
9793
|
}, _callee65, this);
|
|
9285
9794
|
}));
|
|
9286
9795
|
|
|
9287
|
-
function deleteChannels(
|
|
9796
|
+
function deleteChannels(_x88) {
|
|
9288
9797
|
return _deleteChannels.apply(this, arguments);
|
|
9289
9798
|
}
|
|
9290
9799
|
|
|
9291
9800
|
return deleteChannels;
|
|
9292
9801
|
}()
|
|
9293
|
-
}, {
|
|
9294
|
-
key: "deleteUsers",
|
|
9295
|
-
value:
|
|
9296
9802
|
/**
|
|
9297
9803
|
* deleteUsers - Batch Delete Users
|
|
9298
9804
|
*
|
|
@@ -9301,7 +9807,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9301
9807
|
*
|
|
9302
9808
|
* @return {APIResponse} A task ID
|
|
9303
9809
|
*/
|
|
9304
|
-
|
|
9810
|
+
|
|
9811
|
+
}, {
|
|
9812
|
+
key: "deleteUsers",
|
|
9813
|
+
value: function () {
|
|
9305
9814
|
var _deleteUsers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee66(user_ids, options) {
|
|
9306
9815
|
return _regeneratorRuntime.wrap(function _callee66$(_context66) {
|
|
9307
9816
|
while (1) {
|
|
@@ -9347,7 +9856,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9347
9856
|
}, _callee66, this);
|
|
9348
9857
|
}));
|
|
9349
9858
|
|
|
9350
|
-
function deleteUsers(
|
|
9859
|
+
function deleteUsers(_x89, _x90) {
|
|
9351
9860
|
return _deleteUsers.apply(this, arguments);
|
|
9352
9861
|
}
|
|
9353
9862
|
|
|
@@ -9447,5 +9956,5 @@ var BuiltinPermissions = {
|
|
|
9447
9956
|
UseFrozenChannel: 'Send messages and reactions to frozen channels'
|
|
9448
9957
|
};
|
|
9449
9958
|
|
|
9450
|
-
export { Allow, AllowAll, AnyResource, AnyRole, BuiltinPermissions, BuiltinRoles, Channel, ChannelState, CheckSignature, ClientState, Deny, DenyAll, DevToken, EVENT_MAP, InsightMetrics, JWTServerToken, JWTUserToken, MaxPriority, MinPriority, Permission, StableWSConnection, StreamChat, TokenManager, UserFromToken, buildWsFatalInsight, buildWsSuccessAfterFailureInsight, chatCodes, decodeBase64, encodeBase64, isOwnUser, isValidEventType, logChatPromiseExecution };
|
|
9959
|
+
export { Allow, AllowAll, AnyResource, AnyRole, BuiltinPermissions, BuiltinRoles, Channel, ChannelState, CheckSignature, ClientState, Deny, DenyAll, DevToken, EVENT_MAP, InsightMetrics, JWTServerToken, JWTUserToken, MaxPriority, MinPriority, Permission, StableWSConnection, StreamChat, TokenManager, UserFromToken, buildWsFatalInsight, buildWsSuccessAfterFailureInsight, chatCodes, decodeBase64, encodeBase64, isOwnUser, isValidEventType, logChatPromiseExecution, postInsights };
|
|
9451
9960
|
//# sourceMappingURL=index.es.js.map
|