stream-chat 4.4.3-dev.3 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -13
- package/dist/browser.es.js +1258 -722
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.full-bundle.min.js +1 -1
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/browser.js +1258 -721
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +1258 -722
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1258 -721
- package/dist/index.js.map +1 -1
- package/dist/types/base64.d.ts.map +1 -1
- package/dist/types/channel.d.ts +19 -15
- package/dist/types/channel.d.ts.map +1 -1
- package/dist/types/channel_state.d.ts +2 -2
- package/dist/types/channel_state.d.ts.map +1 -1
- package/dist/types/client.d.ts +25 -42
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/client_state.d.ts +2 -2
- package/dist/types/client_state.d.ts.map +1 -1
- package/dist/types/connection.d.ts +14 -49
- package/dist/types/connection.d.ts.map +1 -1
- package/dist/types/connection_fallback.d.ts +41 -0
- package/dist/types/connection_fallback.d.ts.map +1 -0
- package/dist/types/errors.d.ts +14 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/insights.d.ts +16 -9
- package/dist/types/insights.d.ts.map +1 -1
- package/dist/types/permissions.d.ts.map +1 -1
- package/dist/types/signing.d.ts +3 -3
- package/dist/types/signing.d.ts.map +1 -1
- package/dist/types/token_manager.d.ts +2 -2
- package/dist/types/token_manager.d.ts.map +1 -1
- package/dist/types/types.d.ts +95 -89
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +13 -3
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/base64.ts +1 -4
- package/src/channel.ts +133 -461
- package/src/channel_state.ts +31 -158
- package/src/client.ts +298 -712
- package/src/client_state.ts +2 -2
- package/src/connection.ts +146 -395
- package/src/connection_fallback.ts +209 -0
- package/src/errors.ts +58 -0
- package/src/insights.ts +37 -31
- package/src/permissions.ts +3 -24
- package/src/signing.ts +6 -17
- package/src/token_manager.ts +6 -18
- package/src/types.ts +269 -512
- package/src/utils.ts +58 -24
- package/CHANGELOG.md +0 -844
package/dist/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, "
|
|
3698
|
+
_defineProperty(this, "_buildUrl", function () {
|
|
3699
|
+
var qs = encodeURIComponent(_this.client._buildWSPayload(_this.requestID));
|
|
3598
3700
|
|
|
3599
|
-
|
|
3701
|
+
var token = _this.client.tokenManager.getToken();
|
|
3600
3702
|
|
|
3601
|
-
|
|
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));
|
|
3611
|
-
|
|
3612
|
-
var token = _this.tokenManager.getToken();
|
|
3613
|
-
|
|
3614
|
-
return "".concat(_this.wsBaseURL, "/connect?json=").concat(qs, "&api_key=").concat(_this.apiKey, "&authorization=").concat(token, "&stream-auth-type=").concat(_this.authType, "&X-Stream-Client=").concat(_this.userAgent);
|
|
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,586 @@ 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 = 4;
|
|
5161
|
+
break;
|
|
5162
|
+
}
|
|
5163
|
+
|
|
5164
|
+
_this._log('connect() - connecting already in progress', {
|
|
5165
|
+
reconnect: reconnect
|
|
5166
|
+
}, 'warn');
|
|
5167
|
+
|
|
5168
|
+
return _context3.abrupt("return");
|
|
5169
|
+
|
|
5170
|
+
case 4:
|
|
5171
|
+
if (!(_this.state === ConnectionState.Connected)) {
|
|
5172
|
+
_context3.next = 7;
|
|
5173
|
+
break;
|
|
5174
|
+
}
|
|
5175
|
+
|
|
5176
|
+
_this._log('connect() - already connected and polling', {
|
|
5177
|
+
reconnect: reconnect
|
|
5178
|
+
}, 'warn');
|
|
5179
|
+
|
|
5180
|
+
return _context3.abrupt("return");
|
|
5181
|
+
|
|
5182
|
+
case 7:
|
|
5183
|
+
_this._setState(ConnectionState.Connecting);
|
|
5184
|
+
|
|
5185
|
+
_this.connectionID = undefined; // connect should be sent with empty connection_id so API creates one
|
|
5186
|
+
|
|
5187
|
+
_context3.prev = 9;
|
|
5188
|
+
_context3.next = 12;
|
|
5189
|
+
return _this._req({
|
|
5190
|
+
json: _this.client._buildWSPayload()
|
|
5191
|
+
}, {
|
|
5192
|
+
timeout: 8000
|
|
5193
|
+
}, // 8s
|
|
5194
|
+
reconnect);
|
|
5195
|
+
|
|
5196
|
+
case 12:
|
|
5197
|
+
_yield$_this$_req = _context3.sent;
|
|
5198
|
+
event = _yield$_this$_req.event;
|
|
5199
|
+
|
|
5200
|
+
_this._setState(ConnectionState.Connected);
|
|
5201
|
+
|
|
5202
|
+
_this.connectionID = event.connection_id;
|
|
5203
|
+
|
|
5204
|
+
_this._poll();
|
|
5205
|
+
|
|
5206
|
+
if (reconnect) {
|
|
5207
|
+
_this.client.recoverState();
|
|
5208
|
+
}
|
|
5209
|
+
|
|
5210
|
+
return _context3.abrupt("return", event);
|
|
5211
|
+
|
|
5212
|
+
case 21:
|
|
5213
|
+
_context3.prev = 21;
|
|
5214
|
+
_context3.t0 = _context3["catch"](9);
|
|
5215
|
+
|
|
5216
|
+
_this._setState(ConnectionState.Closed);
|
|
5217
|
+
|
|
5218
|
+
throw _context3.t0;
|
|
5219
|
+
|
|
5220
|
+
case 25:
|
|
5221
|
+
case "end":
|
|
5222
|
+
return _context3.stop();
|
|
5223
|
+
}
|
|
5224
|
+
}
|
|
5225
|
+
}, _callee3, null, [[9, 21]]);
|
|
5226
|
+
})));
|
|
5227
|
+
|
|
5228
|
+
_defineProperty(this, "isHealthy", function () {
|
|
5229
|
+
return _this.connectionID && _this.state === ConnectionState.Connected;
|
|
5230
|
+
});
|
|
4729
5231
|
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
_context2.next = 7;
|
|
4733
|
-
break;
|
|
4734
|
-
}
|
|
5232
|
+
_defineProperty(this, "disconnect", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
5233
|
+
var _this$cancelToken3;
|
|
4735
5234
|
|
|
4736
|
-
|
|
4737
|
-
|
|
5235
|
+
var timeout,
|
|
5236
|
+
connection_id,
|
|
5237
|
+
_args4 = arguments;
|
|
5238
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
5239
|
+
while (1) {
|
|
5240
|
+
switch (_context4.prev = _context4.next) {
|
|
5241
|
+
case 0:
|
|
5242
|
+
timeout = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : 2000;
|
|
5243
|
+
removeConnectionEventListeners(_this._onlineStatusChanged);
|
|
5244
|
+
|
|
5245
|
+
_this._setState(ConnectionState.Disconnected);
|
|
5246
|
+
|
|
5247
|
+
(_this$cancelToken3 = _this.cancelToken) === null || _this$cancelToken3 === void 0 ? void 0 : _this$cancelToken3.cancel('disconnect() is called');
|
|
5248
|
+
_this.cancelToken = undefined;
|
|
5249
|
+
connection_id = _this.connectionID;
|
|
5250
|
+
_this.connectionID = undefined;
|
|
5251
|
+
_context4.prev = 7;
|
|
5252
|
+
_context4.next = 10;
|
|
5253
|
+
return _this._req({
|
|
5254
|
+
close: true,
|
|
5255
|
+
connection_id: connection_id
|
|
5256
|
+
}, {
|
|
5257
|
+
timeout: timeout
|
|
5258
|
+
}, false);
|
|
4738
5259
|
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
resolve(_this.token);
|
|
5260
|
+
case 10:
|
|
5261
|
+
_this._log("disconnect() - Closed connectionID");
|
|
4742
5262
|
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
return _context2.stop();
|
|
4746
|
-
}
|
|
4747
|
-
}
|
|
4748
|
-
}, _callee2);
|
|
4749
|
-
}));
|
|
5263
|
+
_context4.next = 16;
|
|
5264
|
+
break;
|
|
4750
5265
|
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
}());
|
|
4755
|
-
return _this.loadTokenPromise;
|
|
4756
|
-
});
|
|
5266
|
+
case 13:
|
|
5267
|
+
_context4.prev = 13;
|
|
5268
|
+
_context4.t0 = _context4["catch"](7);
|
|
4757
5269
|
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
}
|
|
5270
|
+
_this._log("disconnect() - Failed", {
|
|
5271
|
+
err: _context4.t0
|
|
5272
|
+
}, 'error');
|
|
4762
5273
|
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
5274
|
+
case 16:
|
|
5275
|
+
case "end":
|
|
5276
|
+
return _context4.stop();
|
|
5277
|
+
}
|
|
5278
|
+
}
|
|
5279
|
+
}, _callee4, null, [[7, 13]]);
|
|
5280
|
+
})));
|
|
4766
5281
|
|
|
4767
|
-
|
|
4768
|
-
|
|
5282
|
+
this.client = client;
|
|
5283
|
+
this.state = ConnectionState.Init;
|
|
5284
|
+
this.consecutiveFailures = 0;
|
|
5285
|
+
addConnectionEventListeners(this._onlineStatusChanged);
|
|
5286
|
+
}
|
|
5287
|
+
|
|
5288
|
+
_createClass(WSConnectionFallback, [{
|
|
5289
|
+
key: "_log",
|
|
5290
|
+
value: function _log(msg) {
|
|
5291
|
+
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5292
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
5293
|
+
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$1({
|
|
5294
|
+
tags: ['connection_fallback', 'connection']
|
|
5295
|
+
}, extra));
|
|
4769
5296
|
}
|
|
5297
|
+
}, {
|
|
5298
|
+
key: "_setState",
|
|
5299
|
+
value: function _setState(state) {
|
|
5300
|
+
this._log("_setState() - ".concat(state)); // transition from connecting => connected
|
|
4770
5301
|
|
|
4771
|
-
throw new Error("Both secret and user tokens are not set. Either client.connectUser wasn't called or client.disconnect was called");
|
|
4772
|
-
});
|
|
4773
5302
|
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
5303
|
+
if (this.state === ConnectionState.Connecting && state === ConnectionState.Connected) {
|
|
5304
|
+
//@ts-expect-error
|
|
5305
|
+
this.client.dispatchEvent({
|
|
5306
|
+
type: 'connection.changed',
|
|
5307
|
+
online: true
|
|
5308
|
+
});
|
|
5309
|
+
}
|
|
4777
5310
|
|
|
4778
|
-
|
|
5311
|
+
if (state === ConnectionState.Closed || state === ConnectionState.Disconnected) {
|
|
5312
|
+
//@ts-expect-error
|
|
5313
|
+
this.client.dispatchEvent({
|
|
5314
|
+
type: 'connection.changed',
|
|
5315
|
+
online: false
|
|
5316
|
+
});
|
|
5317
|
+
}
|
|
4779
5318
|
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
5319
|
+
this.state = state;
|
|
5320
|
+
}
|
|
5321
|
+
/** @private */
|
|
4783
5322
|
|
|
4784
|
-
|
|
5323
|
+
}]);
|
|
4785
5324
|
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
}
|
|
4789
|
-
}
|
|
4790
|
-
/**
|
|
4791
|
-
* Set the static string token or token provider.
|
|
4792
|
-
* Token provider should return a token string or a promise which resolves to string token.
|
|
4793
|
-
*
|
|
4794
|
-
* @param {TokenOrProvider} tokenOrProvider
|
|
4795
|
-
* @param {UserResponse<UserType>} user
|
|
4796
|
-
*/
|
|
4797
|
-
;
|
|
5325
|
+
return WSConnectionFallback;
|
|
5326
|
+
}();
|
|
4798
5327
|
|
|
4799
5328
|
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
5329
|
|
|
@@ -4834,10 +5363,6 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4834
5363
|
|
|
4835
5364
|
_defineProperty(this, "configs", void 0);
|
|
4836
5365
|
|
|
4837
|
-
_defineProperty(this, "connectionID", void 0);
|
|
4838
|
-
|
|
4839
|
-
_defineProperty(this, "failures", void 0);
|
|
4840
|
-
|
|
4841
5366
|
_defineProperty(this, "key", void 0);
|
|
4842
5367
|
|
|
4843
5368
|
_defineProperty(this, "listeners", void 0);
|
|
@@ -4872,16 +5397,26 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4872
5397
|
|
|
4873
5398
|
_defineProperty(this, "wsConnection", void 0);
|
|
4874
5399
|
|
|
5400
|
+
_defineProperty(this, "wsFallback", void 0);
|
|
5401
|
+
|
|
4875
5402
|
_defineProperty(this, "wsPromise", void 0);
|
|
4876
5403
|
|
|
4877
5404
|
_defineProperty(this, "consecutiveFailures", void 0);
|
|
4878
5405
|
|
|
4879
5406
|
_defineProperty(this, "insightMetrics", void 0);
|
|
4880
5407
|
|
|
4881
|
-
_defineProperty(this, "
|
|
4882
|
-
var _this$wsConnection;
|
|
5408
|
+
_defineProperty(this, "defaultWSTimeoutWithFallback", void 0);
|
|
4883
5409
|
|
|
4884
|
-
|
|
5410
|
+
_defineProperty(this, "defaultWSTimeout", void 0);
|
|
5411
|
+
|
|
5412
|
+
_defineProperty(this, "_getConnectionID", function () {
|
|
5413
|
+
var _this$wsConnection, _this$wsFallback;
|
|
5414
|
+
|
|
5415
|
+
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);
|
|
5416
|
+
});
|
|
5417
|
+
|
|
5418
|
+
_defineProperty(this, "_hasConnectionID", function () {
|
|
5419
|
+
return Boolean(_this._getConnectionID());
|
|
4885
5420
|
});
|
|
4886
5421
|
|
|
4887
5422
|
_defineProperty(this, "connectUser", /*#__PURE__*/function () {
|
|
@@ -4967,36 +5502,55 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4967
5502
|
return _this.tokenManager.setTokenOrProvider(userTokenOrProvider, user);
|
|
4968
5503
|
});
|
|
4969
5504
|
|
|
4970
|
-
_defineProperty(this, "closeConnection", function (
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
_this.cleaningIntervalRef = undefined;
|
|
4974
|
-
}
|
|
5505
|
+
_defineProperty(this, "closeConnection", /*#__PURE__*/function () {
|
|
5506
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(timeout) {
|
|
5507
|
+
var _this$wsConnection2, _this$wsFallback2;
|
|
4975
5508
|
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
5509
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
5510
|
+
while (1) {
|
|
5511
|
+
switch (_context2.prev = _context2.next) {
|
|
5512
|
+
case 0:
|
|
5513
|
+
if (_this.cleaningIntervalRef != null) {
|
|
5514
|
+
clearInterval(_this.cleaningIntervalRef);
|
|
5515
|
+
_this.cleaningIntervalRef = undefined;
|
|
5516
|
+
}
|
|
4979
5517
|
|
|
4980
|
-
|
|
4981
|
-
|
|
5518
|
+
_context2.next = 3;
|
|
5519
|
+
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
5520
|
|
|
4983
|
-
|
|
4984
|
-
|
|
5521
|
+
case 3:
|
|
5522
|
+
return _context2.abrupt("return", Promise.resolve());
|
|
4985
5523
|
|
|
4986
|
-
|
|
5524
|
+
case 4:
|
|
5525
|
+
case "end":
|
|
5526
|
+
return _context2.stop();
|
|
5527
|
+
}
|
|
5528
|
+
}
|
|
5529
|
+
}, _callee2);
|
|
5530
|
+
}));
|
|
5531
|
+
|
|
5532
|
+
return function (_x3) {
|
|
5533
|
+
return _ref2.apply(this, arguments);
|
|
5534
|
+
};
|
|
5535
|
+
}());
|
|
5536
|
+
|
|
5537
|
+
_defineProperty(this, "openConnection", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
5538
|
+
var _this$wsConnection3, _this$wsFallback3;
|
|
5539
|
+
|
|
5540
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
4987
5541
|
while (1) {
|
|
4988
|
-
switch (
|
|
5542
|
+
switch (_context3.prev = _context3.next) {
|
|
4989
5543
|
case 0:
|
|
4990
5544
|
if (_this.userID) {
|
|
4991
|
-
|
|
5545
|
+
_context3.next = 2;
|
|
4992
5546
|
break;
|
|
4993
5547
|
}
|
|
4994
5548
|
|
|
4995
5549
|
throw Error('User is not set on client, use client.connectUser or client.connectAnonymousUser instead');
|
|
4996
5550
|
|
|
4997
5551
|
case 2:
|
|
4998
|
-
if (!((_this$
|
|
4999
|
-
|
|
5552
|
+
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())) {
|
|
5553
|
+
_context3.next = 5;
|
|
5000
5554
|
break;
|
|
5001
5555
|
}
|
|
5002
5556
|
|
|
@@ -5004,7 +5558,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5004
5558
|
tags: ['connection', 'client']
|
|
5005
5559
|
});
|
|
5006
5560
|
|
|
5007
|
-
return
|
|
5561
|
+
return _context3.abrupt("return", Promise.resolve());
|
|
5008
5562
|
|
|
5009
5563
|
case 5:
|
|
5010
5564
|
_this.clientID = "".concat(_this.userID, "--").concat(randomId());
|
|
@@ -5012,14 +5566,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5012
5566
|
|
|
5013
5567
|
_this._startCleaning();
|
|
5014
5568
|
|
|
5015
|
-
return
|
|
5569
|
+
return _context3.abrupt("return", _this.wsPromise);
|
|
5016
5570
|
|
|
5017
5571
|
case 9:
|
|
5018
5572
|
case "end":
|
|
5019
|
-
return
|
|
5573
|
+
return _context3.stop();
|
|
5020
5574
|
}
|
|
5021
5575
|
}
|
|
5022
|
-
},
|
|
5576
|
+
}, _callee3);
|
|
5023
5577
|
})));
|
|
5024
5578
|
|
|
5025
5579
|
_defineProperty(this, "_setupConnection", this.openConnection);
|
|
@@ -5037,12 +5591,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5037
5591
|
});
|
|
5038
5592
|
|
|
5039
5593
|
_defineProperty(this, "disconnectUser", /*#__PURE__*/function () {
|
|
5040
|
-
var
|
|
5594
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(timeout) {
|
|
5041
5595
|
var closePromise, _i, _Object$values, _channel;
|
|
5042
5596
|
|
|
5043
|
-
return _regeneratorRuntime.wrap(function
|
|
5597
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
5044
5598
|
while (1) {
|
|
5045
|
-
switch (
|
|
5599
|
+
switch (_context4.prev = _context4.next) {
|
|
5046
5600
|
case 0:
|
|
5047
5601
|
_this.logger('info', 'client:disconnect() - Disconnecting the client', {
|
|
5048
5602
|
tags: ['connection', 'client']
|
|
@@ -5066,21 +5620,21 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5066
5620
|
|
|
5067
5621
|
_this.state = new ClientState(); // reset token manager
|
|
5068
5622
|
|
|
5069
|
-
_this.tokenManager.reset
|
|
5070
|
-
|
|
5623
|
+
setTimeout(_this.tokenManager.reset); // delay reseting to use token for disconnect calls
|
|
5624
|
+
// close the WS connection
|
|
5071
5625
|
|
|
5072
|
-
return
|
|
5626
|
+
return _context4.abrupt("return", closePromise);
|
|
5073
5627
|
|
|
5074
5628
|
case 11:
|
|
5075
5629
|
case "end":
|
|
5076
|
-
return
|
|
5630
|
+
return _context4.stop();
|
|
5077
5631
|
}
|
|
5078
5632
|
}
|
|
5079
|
-
},
|
|
5633
|
+
}, _callee4);
|
|
5080
5634
|
}));
|
|
5081
5635
|
|
|
5082
|
-
return function (
|
|
5083
|
-
return
|
|
5636
|
+
return function (_x4) {
|
|
5637
|
+
return _ref4.apply(this, arguments);
|
|
5084
5638
|
};
|
|
5085
5639
|
}());
|
|
5086
5640
|
|
|
@@ -5108,78 +5662,78 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5108
5662
|
_defineProperty(this, "setAnonymousUser", this.connectAnonymousUser);
|
|
5109
5663
|
|
|
5110
5664
|
_defineProperty(this, "doAxiosRequest", /*#__PURE__*/function () {
|
|
5111
|
-
var
|
|
5665
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(type, url, data) {
|
|
5112
5666
|
var options,
|
|
5113
5667
|
requestConfig,
|
|
5114
5668
|
response,
|
|
5115
5669
|
_requestConfig$header,
|
|
5116
|
-
|
|
5670
|
+
_args5 = arguments;
|
|
5117
5671
|
|
|
5118
|
-
return _regeneratorRuntime.wrap(function
|
|
5672
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
5119
5673
|
while (1) {
|
|
5120
|
-
switch (
|
|
5674
|
+
switch (_context5.prev = _context5.next) {
|
|
5121
5675
|
case 0:
|
|
5122
|
-
options =
|
|
5123
|
-
|
|
5676
|
+
options = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : {};
|
|
5677
|
+
_context5.next = 3;
|
|
5124
5678
|
return _this.tokenManager.tokenReady();
|
|
5125
5679
|
|
|
5126
5680
|
case 3:
|
|
5127
5681
|
requestConfig = _this._enrichAxiosOptions(options);
|
|
5128
|
-
|
|
5682
|
+
_context5.prev = 4;
|
|
5129
5683
|
|
|
5130
5684
|
_this._logApiRequest(type, url, data, requestConfig);
|
|
5131
5685
|
|
|
5132
|
-
|
|
5133
|
-
|
|
5686
|
+
_context5.t0 = type;
|
|
5687
|
+
_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
5688
|
break;
|
|
5135
5689
|
|
|
5136
5690
|
case 9:
|
|
5137
|
-
|
|
5691
|
+
_context5.next = 11;
|
|
5138
5692
|
return _this.axiosInstance.get(url, requestConfig);
|
|
5139
5693
|
|
|
5140
5694
|
case 11:
|
|
5141
|
-
response =
|
|
5142
|
-
return
|
|
5695
|
+
response = _context5.sent;
|
|
5696
|
+
return _context5.abrupt("break", 34);
|
|
5143
5697
|
|
|
5144
5698
|
case 13:
|
|
5145
|
-
|
|
5699
|
+
_context5.next = 15;
|
|
5146
5700
|
return _this.axiosInstance.delete(url, requestConfig);
|
|
5147
5701
|
|
|
5148
5702
|
case 15:
|
|
5149
|
-
response =
|
|
5150
|
-
return
|
|
5703
|
+
response = _context5.sent;
|
|
5704
|
+
return _context5.abrupt("break", 34);
|
|
5151
5705
|
|
|
5152
5706
|
case 17:
|
|
5153
|
-
|
|
5707
|
+
_context5.next = 19;
|
|
5154
5708
|
return _this.axiosInstance.post(url, data, requestConfig);
|
|
5155
5709
|
|
|
5156
5710
|
case 19:
|
|
5157
|
-
response =
|
|
5158
|
-
return
|
|
5711
|
+
response = _context5.sent;
|
|
5712
|
+
return _context5.abrupt("break", 34);
|
|
5159
5713
|
|
|
5160
5714
|
case 21:
|
|
5161
|
-
|
|
5715
|
+
_context5.next = 23;
|
|
5162
5716
|
return _this.axiosInstance.put(url, data, requestConfig);
|
|
5163
5717
|
|
|
5164
5718
|
case 23:
|
|
5165
|
-
response =
|
|
5166
|
-
return
|
|
5719
|
+
response = _context5.sent;
|
|
5720
|
+
return _context5.abrupt("break", 34);
|
|
5167
5721
|
|
|
5168
5722
|
case 25:
|
|
5169
|
-
|
|
5723
|
+
_context5.next = 27;
|
|
5170
5724
|
return _this.axiosInstance.patch(url, data, requestConfig);
|
|
5171
5725
|
|
|
5172
5726
|
case 27:
|
|
5173
|
-
response =
|
|
5174
|
-
return
|
|
5727
|
+
response = _context5.sent;
|
|
5728
|
+
return _context5.abrupt("break", 34);
|
|
5175
5729
|
|
|
5176
5730
|
case 29:
|
|
5177
|
-
|
|
5731
|
+
_context5.next = 31;
|
|
5178
5732
|
return _this.axiosInstance.options(url, requestConfig);
|
|
5179
5733
|
|
|
5180
5734
|
case 31:
|
|
5181
|
-
response =
|
|
5182
|
-
return
|
|
5735
|
+
response = _context5.sent;
|
|
5736
|
+
return _context5.abrupt("break", 34);
|
|
5183
5737
|
|
|
5184
5738
|
case 33:
|
|
5185
5739
|
throw new Error('Invalid request type');
|
|
@@ -5188,65 +5742,66 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5188
5742
|
_this._logApiResponse(type, url, response);
|
|
5189
5743
|
|
|
5190
5744
|
_this.consecutiveFailures = 0;
|
|
5191
|
-
return
|
|
5745
|
+
return _context5.abrupt("return", _this.handleResponse(response));
|
|
5192
5746
|
|
|
5193
5747
|
case 39:
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5748
|
+
_context5.prev = 39;
|
|
5749
|
+
_context5.t1 = _context5["catch"](4);
|
|
5750
|
+
_context5.t1.client_request_id = (_requestConfig$header = requestConfig.headers) === null || _requestConfig$header === void 0 ? void 0 : _requestConfig$header['x-client-request-id'];
|
|
5197
5751
|
|
|
5198
|
-
_this._logApiError(type, url,
|
|
5752
|
+
_this._logApiError(type, url, _context5.t1);
|
|
5199
5753
|
|
|
5200
5754
|
_this.consecutiveFailures += 1;
|
|
5201
5755
|
|
|
5202
|
-
if (!
|
|
5203
|
-
|
|
5756
|
+
if (!_context5.t1.response) {
|
|
5757
|
+
_context5.next = 56;
|
|
5204
5758
|
break;
|
|
5205
5759
|
}
|
|
5206
5760
|
|
|
5207
|
-
if (!(
|
|
5208
|
-
|
|
5761
|
+
if (!(_context5.t1.response.data.code === chatCodes.TOKEN_EXPIRED && !_this.tokenManager.isStatic())) {
|
|
5762
|
+
_context5.next = 53;
|
|
5209
5763
|
break;
|
|
5210
5764
|
}
|
|
5211
5765
|
|
|
5212
5766
|
if (!(_this.consecutiveFailures > 1)) {
|
|
5213
|
-
|
|
5767
|
+
_context5.next = 49;
|
|
5214
5768
|
break;
|
|
5215
5769
|
}
|
|
5216
5770
|
|
|
5217
|
-
|
|
5771
|
+
_context5.next = 49;
|
|
5218
5772
|
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5219
5773
|
|
|
5220
5774
|
case 49:
|
|
5221
5775
|
_this.tokenManager.loadToken();
|
|
5222
5776
|
|
|
5223
|
-
|
|
5777
|
+
_context5.next = 52;
|
|
5224
5778
|
return _this.doAxiosRequest(type, url, data, options);
|
|
5225
5779
|
|
|
5226
5780
|
case 52:
|
|
5227
|
-
return
|
|
5781
|
+
return _context5.abrupt("return", _context5.sent);
|
|
5228
5782
|
|
|
5229
5783
|
case 53:
|
|
5230
|
-
return
|
|
5784
|
+
return _context5.abrupt("return", _this.handleResponse(_context5.t1.response));
|
|
5231
5785
|
|
|
5232
5786
|
case 56:
|
|
5233
|
-
throw
|
|
5787
|
+
throw _context5.t1;
|
|
5234
5788
|
|
|
5235
5789
|
case 57:
|
|
5236
5790
|
case "end":
|
|
5237
|
-
return
|
|
5791
|
+
return _context5.stop();
|
|
5238
5792
|
}
|
|
5239
5793
|
}
|
|
5240
|
-
},
|
|
5794
|
+
}, _callee5, null, [[4, 39]]);
|
|
5241
5795
|
}));
|
|
5242
5796
|
|
|
5243
|
-
return function (
|
|
5244
|
-
return
|
|
5797
|
+
return function (_x5, _x6, _x7) {
|
|
5798
|
+
return _ref5.apply(this, arguments);
|
|
5245
5799
|
};
|
|
5246
5800
|
}());
|
|
5247
5801
|
|
|
5248
5802
|
_defineProperty(this, "dispatchEvent", function (event) {
|
|
5249
|
-
// client event handlers
|
|
5803
|
+
if (!event.received_at) event.received_at = new Date(); // client event handlers
|
|
5804
|
+
|
|
5250
5805
|
var postListenerCallbacks = _this._handleClientEvent(event); // channel event handlers
|
|
5251
5806
|
|
|
5252
5807
|
|
|
@@ -5272,7 +5827,6 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5272
5827
|
// dispatch the event to the channel listeners
|
|
5273
5828
|
var jsonString = messageEvent.data;
|
|
5274
5829
|
var event = JSON.parse(jsonString);
|
|
5275
|
-
event.received_at = new Date();
|
|
5276
5830
|
|
|
5277
5831
|
_this.dispatchEvent(event);
|
|
5278
5832
|
});
|
|
@@ -5393,22 +5947,20 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5393
5947
|
}
|
|
5394
5948
|
});
|
|
5395
5949
|
|
|
5396
|
-
_defineProperty(this, "recoverState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
5397
|
-
var _this$wsConnection3;
|
|
5398
|
-
|
|
5950
|
+
_defineProperty(this, "recoverState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
5399
5951
|
var cids;
|
|
5400
|
-
return _regeneratorRuntime.wrap(function
|
|
5952
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
5401
5953
|
while (1) {
|
|
5402
|
-
switch (
|
|
5954
|
+
switch (_context6.prev = _context6.next) {
|
|
5403
5955
|
case 0:
|
|
5404
|
-
_this.logger('info', "client:recoverState() - Start of recoverState with connectionID ".concat(
|
|
5956
|
+
_this.logger('info', "client:recoverState() - Start of recoverState with connectionID ".concat(_this._getConnectionID()), {
|
|
5405
5957
|
tags: ['connection']
|
|
5406
5958
|
});
|
|
5407
5959
|
|
|
5408
5960
|
cids = Object.keys(_this.activeChannels);
|
|
5409
5961
|
|
|
5410
5962
|
if (!(cids.length && _this.recoverStateOnReconnect)) {
|
|
5411
|
-
|
|
5963
|
+
_context6.next = 10;
|
|
5412
5964
|
break;
|
|
5413
5965
|
}
|
|
5414
5966
|
|
|
@@ -5416,7 +5968,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5416
5968
|
tags: ['connection', 'client']
|
|
5417
5969
|
});
|
|
5418
5970
|
|
|
5419
|
-
|
|
5971
|
+
_context6.next = 6;
|
|
5420
5972
|
return _this.queryChannels({
|
|
5421
5973
|
cid: {
|
|
5422
5974
|
$in: cids
|
|
@@ -5436,7 +5988,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5436
5988
|
type: 'connection.recovered'
|
|
5437
5989
|
});
|
|
5438
5990
|
|
|
5439
|
-
|
|
5991
|
+
_context6.next = 11;
|
|
5440
5992
|
break;
|
|
5441
5993
|
|
|
5442
5994
|
case 10:
|
|
@@ -5450,10 +6002,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5450
6002
|
|
|
5451
6003
|
case 13:
|
|
5452
6004
|
case "end":
|
|
5453
|
-
return
|
|
6005
|
+
return _context6.stop();
|
|
5454
6006
|
}
|
|
5455
6007
|
}
|
|
5456
|
-
},
|
|
6008
|
+
}, _callee6);
|
|
5457
6009
|
})));
|
|
5458
6010
|
|
|
5459
6011
|
_defineProperty(this, "getChannelByMembers", function (channelType, custom) {
|
|
@@ -5533,66 +6085,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5533
6085
|
return !!_this.secret;
|
|
5534
6086
|
});
|
|
5535
6087
|
|
|
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
|
-
}());
|
|
6088
|
+
_defineProperty(this, "_buildWSPayload", function (client_request_id) {
|
|
6089
|
+
return JSON.stringify({
|
|
6090
|
+
user_id: _this.userID,
|
|
6091
|
+
user_details: _this._user,
|
|
6092
|
+
device: _this.options.device,
|
|
6093
|
+
client_request_id: client_request_id
|
|
6094
|
+
});
|
|
6095
|
+
});
|
|
5596
6096
|
|
|
5597
6097
|
// set the key
|
|
5598
6098
|
this.key = _key;
|
|
@@ -5650,6 +6150,8 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5650
6150
|
this.tokenManager = new TokenManager(this.secret);
|
|
5651
6151
|
this.consecutiveFailures = 0;
|
|
5652
6152
|
this.insightMetrics = new InsightMetrics();
|
|
6153
|
+
this.defaultWSTimeoutWithFallback = 6000;
|
|
6154
|
+
this.defaultWSTimeout = 15000;
|
|
5653
6155
|
/**
|
|
5654
6156
|
* logger function should accept 3 parameters:
|
|
5655
6157
|
* @param logLevel string
|
|
@@ -5823,7 +6325,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5823
6325
|
}, _callee7, this);
|
|
5824
6326
|
}));
|
|
5825
6327
|
|
|
5826
|
-
function updateAppSettings(
|
|
6328
|
+
function updateAppSettings(_x8) {
|
|
5827
6329
|
return _updateAppSettings.apply(this, arguments);
|
|
5828
6330
|
}
|
|
5829
6331
|
|
|
@@ -5857,7 +6359,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5857
6359
|
}, _callee8, this);
|
|
5858
6360
|
}));
|
|
5859
6361
|
|
|
5860
|
-
function revokeTokens(
|
|
6362
|
+
function revokeTokens(_x9) {
|
|
5861
6363
|
return _revokeTokens.apply(this, arguments);
|
|
5862
6364
|
}
|
|
5863
6365
|
|
|
@@ -5889,7 +6391,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5889
6391
|
}, _callee9, this);
|
|
5890
6392
|
}));
|
|
5891
6393
|
|
|
5892
|
-
function revokeUserToken(
|
|
6394
|
+
function revokeUserToken(_x10, _x11) {
|
|
5893
6395
|
return _revokeUserToken.apply(this, arguments);
|
|
5894
6396
|
}
|
|
5895
6397
|
|
|
@@ -5948,7 +6450,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5948
6450
|
}, _callee10, this);
|
|
5949
6451
|
}));
|
|
5950
6452
|
|
|
5951
|
-
function revokeUsersToken(
|
|
6453
|
+
function revokeUsersToken(_x12, _x13) {
|
|
5952
6454
|
return _revokeUsersToken.apply(this, arguments);
|
|
5953
6455
|
}
|
|
5954
6456
|
|
|
@@ -6040,7 +6542,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6040
6542
|
}, _callee12, this);
|
|
6041
6543
|
}));
|
|
6042
6544
|
|
|
6043
|
-
function testPushSettings(
|
|
6545
|
+
function testPushSettings(_x14) {
|
|
6044
6546
|
return _testPushSettings.apply(this, arguments);
|
|
6045
6547
|
}
|
|
6046
6548
|
|
|
@@ -6149,7 +6651,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6149
6651
|
}, _callee14, this, [[1, 7]]);
|
|
6150
6652
|
}));
|
|
6151
6653
|
|
|
6152
|
-
function setGuestUser(
|
|
6654
|
+
function setGuestUser(_x15) {
|
|
6153
6655
|
return _setGuestUser.apply(this, arguments);
|
|
6154
6656
|
}
|
|
6155
6657
|
|
|
@@ -6460,72 +6962,102 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6460
6962
|
*/
|
|
6461
6963
|
function () {
|
|
6462
6964
|
var _connect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() {
|
|
6463
|
-
var client;
|
|
6464
6965
|
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
6465
6966
|
while (1) {
|
|
6466
6967
|
switch (_context15.prev = _context15.next) {
|
|
6467
6968
|
case 0:
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
if (!(client.userID == null || this._user == null)) {
|
|
6472
|
-
_context15.next = 4;
|
|
6969
|
+
if (!(!this.userID || !this._user)) {
|
|
6970
|
+
_context15.next = 2;
|
|
6473
6971
|
break;
|
|
6474
6972
|
}
|
|
6475
6973
|
|
|
6476
6974
|
throw Error('Call connectUser or connectAnonymousUser before starting the connection');
|
|
6477
6975
|
|
|
6478
|
-
case
|
|
6479
|
-
if (
|
|
6480
|
-
_context15.next =
|
|
6976
|
+
case 2:
|
|
6977
|
+
if (this.wsBaseURL) {
|
|
6978
|
+
_context15.next = 4;
|
|
6481
6979
|
break;
|
|
6482
6980
|
}
|
|
6483
6981
|
|
|
6484
6982
|
throw Error('Websocket base url not set');
|
|
6485
6983
|
|
|
6486
|
-
case
|
|
6487
|
-
if (
|
|
6488
|
-
_context15.next =
|
|
6984
|
+
case 4:
|
|
6985
|
+
if (this.clientID) {
|
|
6986
|
+
_context15.next = 6;
|
|
6489
6987
|
break;
|
|
6490
6988
|
}
|
|
6491
6989
|
|
|
6492
6990
|
throw Error('clientID is not set');
|
|
6493
6991
|
|
|
6494
|
-
case
|
|
6992
|
+
case 6:
|
|
6495
6993
|
if (!this.wsConnection && (this.options.warmUp || this.options.enableInsights)) {
|
|
6496
|
-
this.
|
|
6994
|
+
this._sayHi();
|
|
6497
6995
|
} // The StableWSConnection handles all the reconnection logic.
|
|
6498
6996
|
|
|
6499
6997
|
|
|
6500
6998
|
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
|
|
6999
|
+
client: this
|
|
6516
7000
|
});
|
|
7001
|
+
_context15.prev = 8;
|
|
7002
|
+
|
|
7003
|
+
if (!this.wsFallback) {
|
|
7004
|
+
_context15.next = 13;
|
|
7005
|
+
break;
|
|
7006
|
+
}
|
|
7007
|
+
|
|
6517
7008
|
_context15.next = 12;
|
|
6518
|
-
return this.
|
|
7009
|
+
return this.wsFallback.connect();
|
|
6519
7010
|
|
|
6520
7011
|
case 12:
|
|
6521
7012
|
return _context15.abrupt("return", _context15.sent);
|
|
6522
7013
|
|
|
6523
7014
|
case 13:
|
|
7015
|
+
_context15.next = 15;
|
|
7016
|
+
return this.wsConnection.connect(this.options.enableWSFallback ? this.defaultWSTimeoutWithFallback : this.defaultWSTimeout);
|
|
7017
|
+
|
|
7018
|
+
case 15:
|
|
7019
|
+
return _context15.abrupt("return", _context15.sent);
|
|
7020
|
+
|
|
7021
|
+
case 18:
|
|
7022
|
+
_context15.prev = 18;
|
|
7023
|
+
_context15.t0 = _context15["catch"](8);
|
|
7024
|
+
|
|
7025
|
+
if (!(this.options.enableWSFallback && isWSFailure(_context15.t0) && isOnline())) {
|
|
7026
|
+
_context15.next = 29;
|
|
7027
|
+
break;
|
|
7028
|
+
}
|
|
7029
|
+
|
|
7030
|
+
this.logger('info', 'client:connect() - WS failed, fallback to longpoll', {
|
|
7031
|
+
tags: ['connection', 'client']
|
|
7032
|
+
}); // @ts-expect-error
|
|
7033
|
+
|
|
7034
|
+
this.dispatchEvent({
|
|
7035
|
+
type: 'transport.changed',
|
|
7036
|
+
mode: 'longpoll'
|
|
7037
|
+
});
|
|
7038
|
+
|
|
7039
|
+
this.wsConnection._destroyCurrentWSConnection();
|
|
7040
|
+
|
|
7041
|
+
this.wsConnection.disconnect().then(); // close WS so no retry
|
|
7042
|
+
|
|
7043
|
+
this.wsFallback = new WSConnectionFallback({
|
|
7044
|
+
client: this
|
|
7045
|
+
});
|
|
7046
|
+
_context15.next = 28;
|
|
7047
|
+
return this.wsFallback.connect();
|
|
7048
|
+
|
|
7049
|
+
case 28:
|
|
7050
|
+
return _context15.abrupt("return", _context15.sent);
|
|
7051
|
+
|
|
7052
|
+
case 29:
|
|
7053
|
+
throw _context15.t0;
|
|
7054
|
+
|
|
7055
|
+
case 30:
|
|
6524
7056
|
case "end":
|
|
6525
7057
|
return _context15.stop();
|
|
6526
7058
|
}
|
|
6527
7059
|
}
|
|
6528
|
-
}, _callee15, this);
|
|
7060
|
+
}, _callee15, this, [[8, 18]]);
|
|
6529
7061
|
}));
|
|
6530
7062
|
|
|
6531
7063
|
function connect() {
|
|
@@ -6534,9 +7066,15 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6534
7066
|
|
|
6535
7067
|
return connect;
|
|
6536
7068
|
}()
|
|
7069
|
+
/**
|
|
7070
|
+
* Check the connectivity with server for warmup purpose.
|
|
7071
|
+
*
|
|
7072
|
+
* @private
|
|
7073
|
+
*/
|
|
7074
|
+
|
|
6537
7075
|
}, {
|
|
6538
|
-
key: "
|
|
6539
|
-
value: function
|
|
7076
|
+
key: "_sayHi",
|
|
7077
|
+
value: function _sayHi() {
|
|
6540
7078
|
var _this4 = this;
|
|
6541
7079
|
|
|
6542
7080
|
var client_request_id = randomId();
|
|
@@ -6546,11 +7084,13 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6546
7084
|
}
|
|
6547
7085
|
};
|
|
6548
7086
|
this.doAxiosRequest('get', this.baseURL + '/hi', null, opts).catch(function (e) {
|
|
6549
|
-
_this4.
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
7087
|
+
if (_this4.options.enableInsights) {
|
|
7088
|
+
postInsights('http_hi_failed', {
|
|
7089
|
+
api_key: _this4.key,
|
|
7090
|
+
err: e,
|
|
7091
|
+
client_request_id: client_request_id
|
|
7092
|
+
});
|
|
7093
|
+
}
|
|
6554
7094
|
});
|
|
6555
7095
|
}
|
|
6556
7096
|
/**
|
|
@@ -6613,7 +7153,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6613
7153
|
}, _callee16, this);
|
|
6614
7154
|
}));
|
|
6615
7155
|
|
|
6616
|
-
function queryUsers(
|
|
7156
|
+
function queryUsers(_x16) {
|
|
6617
7157
|
return _queryUsers.apply(this, arguments);
|
|
6618
7158
|
}
|
|
6619
7159
|
|
|
@@ -6832,7 +7372,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6832
7372
|
}, _callee19, this);
|
|
6833
7373
|
}));
|
|
6834
7374
|
|
|
6835
|
-
function queryChannels(
|
|
7375
|
+
function queryChannels(_x17) {
|
|
6836
7376
|
return _queryChannels.apply(this, arguments);
|
|
6837
7377
|
}
|
|
6838
7378
|
|
|
@@ -6918,7 +7458,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6918
7458
|
}, _callee20, this);
|
|
6919
7459
|
}));
|
|
6920
7460
|
|
|
6921
|
-
function search(
|
|
7461
|
+
function search(_x18, _x19) {
|
|
6922
7462
|
return _search.apply(this, arguments);
|
|
6923
7463
|
}
|
|
6924
7464
|
|
|
@@ -6936,7 +7476,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6936
7476
|
}, {
|
|
6937
7477
|
key: "setLocalDevice",
|
|
6938
7478
|
value: function setLocalDevice(device) {
|
|
6939
|
-
if (this.wsConnection) {
|
|
7479
|
+
if (this.wsConnection || this.wsFallback) {
|
|
6940
7480
|
throw new Error('you can only set device before opening a websocket connection');
|
|
6941
7481
|
}
|
|
6942
7482
|
|
|
@@ -6978,7 +7518,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6978
7518
|
}, _callee21, this);
|
|
6979
7519
|
}));
|
|
6980
7520
|
|
|
6981
|
-
function addDevice(_x21, _x22
|
|
7521
|
+
function addDevice(_x20, _x21, _x22) {
|
|
6982
7522
|
return _addDevice.apply(this, arguments);
|
|
6983
7523
|
}
|
|
6984
7524
|
|
|
@@ -7016,7 +7556,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7016
7556
|
}, _callee22, this);
|
|
7017
7557
|
}));
|
|
7018
7558
|
|
|
7019
|
-
function getDevices(
|
|
7559
|
+
function getDevices(_x23) {
|
|
7020
7560
|
return _getDevices.apply(this, arguments);
|
|
7021
7561
|
}
|
|
7022
7562
|
|
|
@@ -7056,7 +7596,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7056
7596
|
}, _callee23, this);
|
|
7057
7597
|
}));
|
|
7058
7598
|
|
|
7059
|
-
function removeDevice(
|
|
7599
|
+
function removeDevice(_x24, _x25) {
|
|
7060
7600
|
return _removeDevice.apply(this, arguments);
|
|
7061
7601
|
}
|
|
7062
7602
|
|
|
@@ -7097,7 +7637,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7097
7637
|
}, _callee24, this);
|
|
7098
7638
|
}));
|
|
7099
7639
|
|
|
7100
|
-
function getRateLimits(
|
|
7640
|
+
function getRateLimits(_x26) {
|
|
7101
7641
|
return _getRateLimits.apply(this, arguments);
|
|
7102
7642
|
}
|
|
7103
7643
|
|
|
@@ -7198,7 +7738,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7198
7738
|
}, _callee25, this);
|
|
7199
7739
|
}));
|
|
7200
7740
|
|
|
7201
|
-
function partialUpdateUser(
|
|
7741
|
+
function partialUpdateUser(_x27) {
|
|
7202
7742
|
return _partialUpdateUser.apply(this, arguments);
|
|
7203
7743
|
}
|
|
7204
7744
|
|
|
@@ -7284,7 +7824,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7284
7824
|
}, _callee26, this, [[2, 13, 16, 19]]);
|
|
7285
7825
|
}));
|
|
7286
7826
|
|
|
7287
|
-
function upsertUsers(
|
|
7827
|
+
function upsertUsers(_x28) {
|
|
7288
7828
|
return _upsertUsers.apply(this, arguments);
|
|
7289
7829
|
}
|
|
7290
7830
|
|
|
@@ -7397,7 +7937,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7397
7937
|
}, _callee27, this, [[1, 11, 14, 17]]);
|
|
7398
7938
|
}));
|
|
7399
7939
|
|
|
7400
|
-
function partialUpdateUsers(
|
|
7940
|
+
function partialUpdateUsers(_x29) {
|
|
7401
7941
|
return _partialUpdateUsers.apply(this, arguments);
|
|
7402
7942
|
}
|
|
7403
7943
|
|
|
@@ -7425,7 +7965,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7425
7965
|
}, _callee28, this);
|
|
7426
7966
|
}));
|
|
7427
7967
|
|
|
7428
|
-
function deleteUser(
|
|
7968
|
+
function deleteUser(_x30, _x31) {
|
|
7429
7969
|
return _deleteUser.apply(this, arguments);
|
|
7430
7970
|
}
|
|
7431
7971
|
|
|
@@ -7453,7 +7993,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7453
7993
|
}, _callee29, this);
|
|
7454
7994
|
}));
|
|
7455
7995
|
|
|
7456
|
-
function reactivateUser(
|
|
7996
|
+
function reactivateUser(_x32, _x33) {
|
|
7457
7997
|
return _reactivateUser.apply(this, arguments);
|
|
7458
7998
|
}
|
|
7459
7999
|
|
|
@@ -7481,7 +8021,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7481
8021
|
}, _callee30, this);
|
|
7482
8022
|
}));
|
|
7483
8023
|
|
|
7484
|
-
function deactivateUser(
|
|
8024
|
+
function deactivateUser(_x34, _x35) {
|
|
7485
8025
|
return _deactivateUser.apply(this, arguments);
|
|
7486
8026
|
}
|
|
7487
8027
|
|
|
@@ -7509,7 +8049,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7509
8049
|
}, _callee31, this);
|
|
7510
8050
|
}));
|
|
7511
8051
|
|
|
7512
|
-
function exportUser(
|
|
8052
|
+
function exportUser(_x36, _x37) {
|
|
7513
8053
|
return _exportUser.apply(this, arguments);
|
|
7514
8054
|
}
|
|
7515
8055
|
|
|
@@ -7530,27 +8070,15 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7530
8070
|
while (1) {
|
|
7531
8071
|
switch (_context32.prev = _context32.next) {
|
|
7532
8072
|
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;
|
|
8073
|
+
_context32.next = 2;
|
|
7546
8074
|
return this.post(this.baseURL + '/moderation/ban', _objectSpread({
|
|
7547
8075
|
target_user_id: targetUserID
|
|
7548
8076
|
}, options));
|
|
7549
8077
|
|
|
7550
|
-
case
|
|
8078
|
+
case 2:
|
|
7551
8079
|
return _context32.abrupt("return", _context32.sent);
|
|
7552
8080
|
|
|
7553
|
-
case
|
|
8081
|
+
case 3:
|
|
7554
8082
|
case "end":
|
|
7555
8083
|
return _context32.stop();
|
|
7556
8084
|
}
|
|
@@ -7558,7 +8086,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7558
8086
|
}, _callee32, this);
|
|
7559
8087
|
}));
|
|
7560
8088
|
|
|
7561
|
-
function banUser(
|
|
8089
|
+
function banUser(_x38, _x39) {
|
|
7562
8090
|
return _banUser.apply(this, arguments);
|
|
7563
8091
|
}
|
|
7564
8092
|
|
|
@@ -7595,7 +8123,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7595
8123
|
}, _callee33, this);
|
|
7596
8124
|
}));
|
|
7597
8125
|
|
|
7598
|
-
function unbanUser(
|
|
8126
|
+
function unbanUser(_x40, _x41) {
|
|
7599
8127
|
return _unbanUser.apply(this, arguments);
|
|
7600
8128
|
}
|
|
7601
8129
|
|
|
@@ -7632,7 +8160,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7632
8160
|
}, _callee34, this);
|
|
7633
8161
|
}));
|
|
7634
8162
|
|
|
7635
|
-
function shadowBan(
|
|
8163
|
+
function shadowBan(_x42, _x43) {
|
|
7636
8164
|
return _shadowBan.apply(this, arguments);
|
|
7637
8165
|
}
|
|
7638
8166
|
|
|
@@ -7669,7 +8197,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7669
8197
|
}, _callee35, this);
|
|
7670
8198
|
}));
|
|
7671
8199
|
|
|
7672
|
-
function removeShadowBan(
|
|
8200
|
+
function removeShadowBan(_x44, _x45) {
|
|
7673
8201
|
return _removeShadowBan.apply(this, arguments);
|
|
7674
8202
|
}
|
|
7675
8203
|
|
|
@@ -7712,7 +8240,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7712
8240
|
}, _callee36, this);
|
|
7713
8241
|
}));
|
|
7714
8242
|
|
|
7715
|
-
function muteUser(
|
|
8243
|
+
function muteUser(_x46, _x47) {
|
|
7716
8244
|
return _muteUser.apply(this, arguments);
|
|
7717
8245
|
}
|
|
7718
8246
|
|
|
@@ -7751,7 +8279,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7751
8279
|
}, _callee37, this);
|
|
7752
8280
|
}));
|
|
7753
8281
|
|
|
7754
|
-
function unmuteUser(
|
|
8282
|
+
function unmuteUser(_x48, _x49) {
|
|
7755
8283
|
return _unmuteUser.apply(this, arguments);
|
|
7756
8284
|
}
|
|
7757
8285
|
|
|
@@ -7810,7 +8338,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7810
8338
|
}, _callee38, this);
|
|
7811
8339
|
}));
|
|
7812
8340
|
|
|
7813
|
-
function flagMessage(
|
|
8341
|
+
function flagMessage(_x50) {
|
|
7814
8342
|
return _flagMessage.apply(this, arguments);
|
|
7815
8343
|
}
|
|
7816
8344
|
|
|
@@ -7850,7 +8378,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7850
8378
|
}, _callee39, this);
|
|
7851
8379
|
}));
|
|
7852
8380
|
|
|
7853
|
-
function flagUser(
|
|
8381
|
+
function flagUser(_x51) {
|
|
7854
8382
|
return _flagUser.apply(this, arguments);
|
|
7855
8383
|
}
|
|
7856
8384
|
|
|
@@ -7890,7 +8418,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7890
8418
|
}, _callee40, this);
|
|
7891
8419
|
}));
|
|
7892
8420
|
|
|
7893
|
-
function unflagMessage(
|
|
8421
|
+
function unflagMessage(_x52) {
|
|
7894
8422
|
return _unflagMessage.apply(this, arguments);
|
|
7895
8423
|
}
|
|
7896
8424
|
|
|
@@ -7930,7 +8458,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7930
8458
|
}, _callee41, this);
|
|
7931
8459
|
}));
|
|
7932
8460
|
|
|
7933
|
-
function unflagUser(
|
|
8461
|
+
function unflagUser(_x53) {
|
|
7934
8462
|
return _unflagUser.apply(this, arguments);
|
|
7935
8463
|
}
|
|
7936
8464
|
|
|
@@ -8069,7 +8597,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8069
8597
|
}, _callee43, this);
|
|
8070
8598
|
}));
|
|
8071
8599
|
|
|
8072
|
-
function translateMessage(
|
|
8600
|
+
function translateMessage(_x54, _x55) {
|
|
8073
8601
|
return _translateMessage.apply(this, arguments);
|
|
8074
8602
|
}
|
|
8075
8603
|
|
|
@@ -8185,7 +8713,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8185
8713
|
case 2:
|
|
8186
8714
|
clonedMessage = _extends({}, message);
|
|
8187
8715
|
delete clonedMessage.id;
|
|
8188
|
-
reservedMessageFields = ['command', 'created_at', 'html', 'latest_reactions', 'own_reactions', 'reaction_counts', 'reply_count', 'type', 'updated_at', 'user', '__html'];
|
|
8716
|
+
reservedMessageFields = ['command', 'created_at', 'html', 'latest_reactions', 'own_reactions', 'quoted_message', 'reaction_counts', 'reply_count', 'type', 'updated_at', 'user', '__html'];
|
|
8189
8717
|
reservedMessageFields.forEach(function (item) {
|
|
8190
8718
|
if (clonedMessage[item] != null) {
|
|
8191
8719
|
delete clonedMessage[item];
|
|
@@ -8229,7 +8757,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8229
8757
|
}, _callee44, this);
|
|
8230
8758
|
}));
|
|
8231
8759
|
|
|
8232
|
-
function updateMessage(_x57, _x58
|
|
8760
|
+
function updateMessage(_x56, _x57, _x58) {
|
|
8233
8761
|
return _updateMessage.apply(this, arguments);
|
|
8234
8762
|
}
|
|
8235
8763
|
|
|
@@ -8290,7 +8818,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8290
8818
|
}, _callee45, this);
|
|
8291
8819
|
}));
|
|
8292
8820
|
|
|
8293
|
-
function partialUpdateMessage(_x60, _x61, _x62
|
|
8821
|
+
function partialUpdateMessage(_x59, _x60, _x61, _x62) {
|
|
8294
8822
|
return _partialUpdateMessage.apply(this, arguments);
|
|
8295
8823
|
}
|
|
8296
8824
|
|
|
@@ -8327,7 +8855,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8327
8855
|
}, _callee46, this);
|
|
8328
8856
|
}));
|
|
8329
8857
|
|
|
8330
|
-
function deleteMessage(
|
|
8858
|
+
function deleteMessage(_x63, _x64) {
|
|
8331
8859
|
return _deleteMessage.apply(this, arguments);
|
|
8332
8860
|
}
|
|
8333
8861
|
|
|
@@ -8355,7 +8883,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8355
8883
|
}, _callee47, this);
|
|
8356
8884
|
}));
|
|
8357
8885
|
|
|
8358
|
-
function getMessage(
|
|
8886
|
+
function getMessage(_x65) {
|
|
8359
8887
|
return _getMessage.apply(this, arguments);
|
|
8360
8888
|
}
|
|
8361
8889
|
|
|
@@ -8364,7 +8892,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8364
8892
|
}, {
|
|
8365
8893
|
key: "getUserAgent",
|
|
8366
8894
|
value: function getUserAgent() {
|
|
8367
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "
|
|
8895
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "5.0.1");
|
|
8368
8896
|
}
|
|
8369
8897
|
}, {
|
|
8370
8898
|
key: "setUserAgent",
|
|
@@ -8378,7 +8906,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8378
8906
|
}, {
|
|
8379
8907
|
key: "_enrichAxiosOptions",
|
|
8380
8908
|
value: function _enrichAxiosOptions() {
|
|
8381
|
-
var _options$headers
|
|
8909
|
+
var _options$headers;
|
|
8382
8910
|
|
|
8383
8911
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
8384
8912
|
params: {},
|
|
@@ -8388,21 +8916,23 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8388
8916
|
|
|
8389
8917
|
var token = this._getToken();
|
|
8390
8918
|
|
|
8919
|
+
var authorization = token ? {
|
|
8920
|
+
Authorization: token
|
|
8921
|
+
} : undefined;
|
|
8922
|
+
|
|
8391
8923
|
if (!((_options$headers = options.headers) !== null && _options$headers !== void 0 && _options$headers['x-client-request-id'])) {
|
|
8392
|
-
options.headers = {
|
|
8924
|
+
options.headers = _objectSpread(_objectSpread({}, options.headers), {}, {
|
|
8393
8925
|
'x-client-request-id': randomId()
|
|
8394
|
-
};
|
|
8926
|
+
});
|
|
8395
8927
|
}
|
|
8396
8928
|
|
|
8397
8929
|
return _objectSpread({
|
|
8398
|
-
params: _objectSpread(
|
|
8399
|
-
user_id: this.userID
|
|
8400
|
-
|
|
8401
|
-
api_key: this.key
|
|
8402
|
-
|
|
8403
|
-
}),
|
|
8404
|
-
headers: _objectSpread({
|
|
8405
|
-
Authorization: token,
|
|
8930
|
+
params: _objectSpread({
|
|
8931
|
+
user_id: this.userID,
|
|
8932
|
+
connection_id: this._getConnectionID(),
|
|
8933
|
+
api_key: this.key
|
|
8934
|
+
}, options.params),
|
|
8935
|
+
headers: _objectSpread(_objectSpread({}, authorization), {}, {
|
|
8406
8936
|
'stream-auth-type': this.getAuthType(),
|
|
8407
8937
|
'X-Stream-Client': this.getUserAgent()
|
|
8408
8938
|
}, options.headers)
|
|
@@ -8432,6 +8962,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8432
8962
|
}
|
|
8433
8963
|
}, 500);
|
|
8434
8964
|
}
|
|
8965
|
+
/**
|
|
8966
|
+
* encode ws url payload
|
|
8967
|
+
* @private
|
|
8968
|
+
* @returns json string
|
|
8969
|
+
*/
|
|
8970
|
+
|
|
8435
8971
|
}, {
|
|
8436
8972
|
key: "verifyWebhook",
|
|
8437
8973
|
value: function verifyWebhook(requestBody, xSignature) {
|
|
@@ -8572,7 +9108,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8572
9108
|
}, _callee48, this);
|
|
8573
9109
|
}));
|
|
8574
9110
|
|
|
8575
|
-
function sendUserCustomEvent(
|
|
9111
|
+
function sendUserCustomEvent(_x66, _x67) {
|
|
8576
9112
|
return _sendUserCustomEvent.apply(this, arguments);
|
|
8577
9113
|
}
|
|
8578
9114
|
|
|
@@ -8660,7 +9196,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8660
9196
|
}, _callee49, this);
|
|
8661
9197
|
}));
|
|
8662
9198
|
|
|
8663
|
-
function createSegment(
|
|
9199
|
+
function createSegment(_x68) {
|
|
8664
9200
|
return _createSegment.apply(this, arguments);
|
|
8665
9201
|
}
|
|
8666
9202
|
|
|
@@ -8700,7 +9236,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8700
9236
|
}, _callee50, this);
|
|
8701
9237
|
}));
|
|
8702
9238
|
|
|
8703
|
-
function getSegment(
|
|
9239
|
+
function getSegment(_x69) {
|
|
8704
9240
|
return _getSegment.apply(this, arguments);
|
|
8705
9241
|
}
|
|
8706
9242
|
|
|
@@ -8739,7 +9275,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8739
9275
|
}, _callee51, this);
|
|
8740
9276
|
}));
|
|
8741
9277
|
|
|
8742
|
-
function listSegments(
|
|
9278
|
+
function listSegments(_x70) {
|
|
8743
9279
|
return _listSegments.apply(this, arguments);
|
|
8744
9280
|
}
|
|
8745
9281
|
|
|
@@ -8782,7 +9318,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8782
9318
|
}, _callee52, this);
|
|
8783
9319
|
}));
|
|
8784
9320
|
|
|
8785
|
-
function updateSegment(
|
|
9321
|
+
function updateSegment(_x71, _x72) {
|
|
8786
9322
|
return _updateSegment.apply(this, arguments);
|
|
8787
9323
|
}
|
|
8788
9324
|
|
|
@@ -8814,7 +9350,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8814
9350
|
}, _callee53, this);
|
|
8815
9351
|
}));
|
|
8816
9352
|
|
|
8817
|
-
function deleteSegment(
|
|
9353
|
+
function deleteSegment(_x73) {
|
|
8818
9354
|
return _deleteSegment.apply(this, arguments);
|
|
8819
9355
|
}
|
|
8820
9356
|
|
|
@@ -8856,7 +9392,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8856
9392
|
}, _callee54, this);
|
|
8857
9393
|
}));
|
|
8858
9394
|
|
|
8859
|
-
function createCampaign(
|
|
9395
|
+
function createCampaign(_x74) {
|
|
8860
9396
|
return _createCampaign.apply(this, arguments);
|
|
8861
9397
|
}
|
|
8862
9398
|
|
|
@@ -8896,7 +9432,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8896
9432
|
}, _callee55, this);
|
|
8897
9433
|
}));
|
|
8898
9434
|
|
|
8899
|
-
function getCampaign(
|
|
9435
|
+
function getCampaign(_x75) {
|
|
8900
9436
|
return _getCampaign.apply(this, arguments);
|
|
8901
9437
|
}
|
|
8902
9438
|
|
|
@@ -8935,7 +9471,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8935
9471
|
}, _callee56, this);
|
|
8936
9472
|
}));
|
|
8937
9473
|
|
|
8938
|
-
function listCampaigns(
|
|
9474
|
+
function listCampaigns(_x76) {
|
|
8939
9475
|
return _listCampaigns.apply(this, arguments);
|
|
8940
9476
|
}
|
|
8941
9477
|
|
|
@@ -8978,7 +9514,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8978
9514
|
}, _callee57, this);
|
|
8979
9515
|
}));
|
|
8980
9516
|
|
|
8981
|
-
function updateCampaign(
|
|
9517
|
+
function updateCampaign(_x77, _x78) {
|
|
8982
9518
|
return _updateCampaign.apply(this, arguments);
|
|
8983
9519
|
}
|
|
8984
9520
|
|
|
@@ -9010,7 +9546,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9010
9546
|
}, _callee58, this);
|
|
9011
9547
|
}));
|
|
9012
9548
|
|
|
9013
|
-
function deleteCampaign(
|
|
9549
|
+
function deleteCampaign(_x79) {
|
|
9014
9550
|
return _deleteCampaign.apply(this, arguments);
|
|
9015
9551
|
}
|
|
9016
9552
|
|
|
@@ -9054,7 +9590,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9054
9590
|
}, _callee59, this);
|
|
9055
9591
|
}));
|
|
9056
9592
|
|
|
9057
|
-
function scheduleCampaign(
|
|
9593
|
+
function scheduleCampaign(_x80, _x81) {
|
|
9058
9594
|
return _scheduleCampaign.apply(this, arguments);
|
|
9059
9595
|
}
|
|
9060
9596
|
|
|
@@ -9094,7 +9630,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9094
9630
|
}, _callee60, this);
|
|
9095
9631
|
}));
|
|
9096
9632
|
|
|
9097
|
-
function stopCampaign(
|
|
9633
|
+
function stopCampaign(_x82) {
|
|
9098
9634
|
return _stopCampaign.apply(this, arguments);
|
|
9099
9635
|
}
|
|
9100
9636
|
|
|
@@ -9134,7 +9670,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9134
9670
|
}, _callee61, this);
|
|
9135
9671
|
}));
|
|
9136
9672
|
|
|
9137
|
-
function resumeCampaign(
|
|
9673
|
+
function resumeCampaign(_x83) {
|
|
9138
9674
|
return _resumeCampaign.apply(this, arguments);
|
|
9139
9675
|
}
|
|
9140
9676
|
|
|
@@ -9177,7 +9713,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9177
9713
|
}, _callee62, this);
|
|
9178
9714
|
}));
|
|
9179
9715
|
|
|
9180
|
-
function testCampaign(
|
|
9716
|
+
function testCampaign(_x84, _x85) {
|
|
9181
9717
|
return _testCampaign.apply(this, arguments);
|
|
9182
9718
|
}
|
|
9183
9719
|
|
|
@@ -9210,7 +9746,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9210
9746
|
}, _callee63, this);
|
|
9211
9747
|
}));
|
|
9212
9748
|
|
|
9213
|
-
function enrichURL(
|
|
9749
|
+
function enrichURL(_x86) {
|
|
9214
9750
|
return _enrichURL.apply(this, arguments);
|
|
9215
9751
|
}
|
|
9216
9752
|
|
|
@@ -9242,7 +9778,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9242
9778
|
}, _callee64, this);
|
|
9243
9779
|
}));
|
|
9244
9780
|
|
|
9245
|
-
function getTask(
|
|
9781
|
+
function getTask(_x87) {
|
|
9246
9782
|
return _getTask.apply(this, arguments);
|
|
9247
9783
|
}
|
|
9248
9784
|
|
|
@@ -9284,15 +9820,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9284
9820
|
}, _callee65, this);
|
|
9285
9821
|
}));
|
|
9286
9822
|
|
|
9287
|
-
function deleteChannels(
|
|
9823
|
+
function deleteChannels(_x88) {
|
|
9288
9824
|
return _deleteChannels.apply(this, arguments);
|
|
9289
9825
|
}
|
|
9290
9826
|
|
|
9291
9827
|
return deleteChannels;
|
|
9292
9828
|
}()
|
|
9293
|
-
}, {
|
|
9294
|
-
key: "deleteUsers",
|
|
9295
|
-
value:
|
|
9296
9829
|
/**
|
|
9297
9830
|
* deleteUsers - Batch Delete Users
|
|
9298
9831
|
*
|
|
@@ -9301,7 +9834,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9301
9834
|
*
|
|
9302
9835
|
* @return {APIResponse} A task ID
|
|
9303
9836
|
*/
|
|
9304
|
-
|
|
9837
|
+
|
|
9838
|
+
}, {
|
|
9839
|
+
key: "deleteUsers",
|
|
9840
|
+
value: function () {
|
|
9305
9841
|
var _deleteUsers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee66(user_ids, options) {
|
|
9306
9842
|
return _regeneratorRuntime.wrap(function _callee66$(_context66) {
|
|
9307
9843
|
while (1) {
|
|
@@ -9347,7 +9883,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9347
9883
|
}, _callee66, this);
|
|
9348
9884
|
}));
|
|
9349
9885
|
|
|
9350
|
-
function deleteUsers(
|
|
9886
|
+
function deleteUsers(_x89, _x90) {
|
|
9351
9887
|
return _deleteUsers.apply(this, arguments);
|
|
9352
9888
|
}
|
|
9353
9889
|
|
|
@@ -9447,5 +9983,5 @@ var BuiltinPermissions = {
|
|
|
9447
9983
|
UseFrozenChannel: 'Send messages and reactions to frozen channels'
|
|
9448
9984
|
};
|
|
9449
9985
|
|
|
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 };
|
|
9986
|
+
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
9987
|
//# sourceMappingURL=index.es.js.map
|