stream-chat 4.4.3-dev.1 → 4.5.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -13
- package/dist/browser.es.js +1239 -716
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.full-bundle.min.js +1 -1
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/browser.js +1239 -715
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +1239 -716
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1239 -715
- package/dist/index.js.map +1 -1
- package/dist/types/base64.d.ts.map +1 -1
- package/dist/types/channel.d.ts +19 -15
- package/dist/types/channel.d.ts.map +1 -1
- package/dist/types/channel_state.d.ts +2 -2
- package/dist/types/channel_state.d.ts.map +1 -1
- package/dist/types/client.d.ts +25 -49
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/client_state.d.ts +2 -2
- package/dist/types/client_state.d.ts.map +1 -1
- package/dist/types/connection.d.ts +14 -49
- package/dist/types/connection.d.ts.map +1 -1
- package/dist/types/connection_fallback.d.ts +42 -0
- package/dist/types/connection_fallback.d.ts.map +1 -0
- package/dist/types/errors.d.ts +14 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/insights.d.ts +17 -10
- package/dist/types/insights.d.ts.map +1 -1
- package/dist/types/permissions.d.ts.map +1 -1
- package/dist/types/signing.d.ts +3 -3
- package/dist/types/signing.d.ts.map +1 -1
- package/dist/types/token_manager.d.ts +2 -2
- package/dist/types/token_manager.d.ts.map +1 -1
- package/dist/types/types.d.ts +95 -80
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +13 -3
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/base64.ts +1 -4
- package/src/channel.ts +133 -461
- package/src/channel_state.ts +31 -158
- package/src/client.ts +307 -708
- package/src/client_state.ts +2 -2
- package/src/connection.ts +146 -395
- package/src/connection_fallback.ts +205 -0
- package/src/errors.ts +58 -0
- package/src/insights.ts +38 -32
- package/src/permissions.ts +3 -24
- package/src/signing.ts +6 -17
- package/src/token_manager.ts +6 -18
- package/src/types.ts +270 -504
- package/src/utils.ts +49 -24
- package/CHANGELOG.md +0 -844
package/dist/browser.es.js
CHANGED
|
@@ -88,9 +88,9 @@ var decodeBase64 = function decodeBase64(s) {
|
|
|
88
88
|
|
|
89
89
|
var https = null;
|
|
90
90
|
|
|
91
|
-
function ownKeys$
|
|
91
|
+
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; }
|
|
92
92
|
|
|
93
|
-
function _objectSpread$
|
|
93
|
+
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; }
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
96
|
* ChannelState - A container class for the channel state.
|
|
@@ -158,7 +158,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
158
158
|
var m = messages[i];
|
|
159
159
|
|
|
160
160
|
if (((_m$user = m.user) === null || _m$user === void 0 ? void 0 : _m$user.id) === user.id) {
|
|
161
|
-
messages[i] = _objectSpread$
|
|
161
|
+
messages[i] = _objectSpread$7(_objectSpread$7({}, m), {}, {
|
|
162
162
|
user: user
|
|
163
163
|
});
|
|
164
164
|
}
|
|
@@ -211,7 +211,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
211
211
|
user: m.user
|
|
212
212
|
};
|
|
213
213
|
} else {
|
|
214
|
-
messages[i] = _objectSpread$
|
|
214
|
+
messages[i] = _objectSpread$7(_objectSpread$7({}, m), {}, {
|
|
215
215
|
type: 'deleted',
|
|
216
216
|
deleted_at: user.deleted_at
|
|
217
217
|
});
|
|
@@ -279,7 +279,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
279
279
|
}, {
|
|
280
280
|
key: "formatMessage",
|
|
281
281
|
value: function formatMessage(message) {
|
|
282
|
-
return _objectSpread$
|
|
282
|
+
return _objectSpread$7(_objectSpread$7({}, message), {}, {
|
|
283
283
|
/**
|
|
284
284
|
* @deprecated please use `html`
|
|
285
285
|
*/
|
|
@@ -469,7 +469,7 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
469
469
|
var parseMessage = function parseMessage(m) {
|
|
470
470
|
var _m$pinned_at, _m$updated_at;
|
|
471
471
|
|
|
472
|
-
return _objectSpread$
|
|
472
|
+
return _objectSpread$7(_objectSpread$7({}, m), {}, {
|
|
473
473
|
created_at: m.created_at.toString(),
|
|
474
474
|
pinned_at: (_m$pinned_at = m.pinned_at) === null || _m$pinned_at === void 0 ? void 0 : _m$pinned_at.toString(),
|
|
475
475
|
updated_at: (_m$updated_at = m.updated_at) === null || _m$updated_at === void 0 ? void 0 : _m$updated_at.toString()
|
|
@@ -479,8 +479,8 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
479
479
|
var updatedMessages = this.messages.filter(function (msg) {
|
|
480
480
|
return msg.quoted_message_id === message.id;
|
|
481
481
|
}).map(parseMessage).map(function (msg) {
|
|
482
|
-
return _objectSpread$
|
|
483
|
-
quoted_message: _objectSpread$
|
|
482
|
+
return _objectSpread$7(_objectSpread$7({}, msg), {}, {
|
|
483
|
+
quoted_message: _objectSpread$7(_objectSpread$7({}, message), {}, {
|
|
484
484
|
attachments: []
|
|
485
485
|
})
|
|
486
486
|
});
|
|
@@ -700,9 +700,9 @@ var ChannelState = /*#__PURE__*/function () {
|
|
|
700
700
|
return ChannelState;
|
|
701
701
|
}();
|
|
702
702
|
|
|
703
|
-
function ownKeys$
|
|
703
|
+
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; }
|
|
704
704
|
|
|
705
|
-
function _objectSpread$
|
|
705
|
+
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; }
|
|
706
706
|
|
|
707
707
|
var EVENT_MAP = {
|
|
708
708
|
'channel.created': true,
|
|
@@ -749,7 +749,7 @@ var EVENT_MAP = {
|
|
|
749
749
|
'connection.recovered': true
|
|
750
750
|
};
|
|
751
751
|
|
|
752
|
-
var IS_VALID_EVENT_MAP_TYPE = _objectSpread$
|
|
752
|
+
var IS_VALID_EVENT_MAP_TYPE = _objectSpread$6(_objectSpread$6({}, EVENT_MAP), {}, {
|
|
753
753
|
all: true
|
|
754
754
|
});
|
|
755
755
|
|
|
@@ -757,7 +757,7 @@ var isValidEventType = function isValidEventType(eventType) {
|
|
|
757
757
|
return IS_VALID_EVENT_MAP_TYPE[eventType] || false;
|
|
758
758
|
};
|
|
759
759
|
|
|
760
|
-
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) {
|
|
760
|
+
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; } } }; }
|
|
761
761
|
|
|
762
762
|
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); }
|
|
763
763
|
|
|
@@ -933,12 +933,45 @@ function getRandomBytes(length) {
|
|
|
933
933
|
function convertErrorToJson(err) {
|
|
934
934
|
var jsonObj = {};
|
|
935
935
|
if (!err) return jsonObj;
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
936
|
+
|
|
937
|
+
try {
|
|
938
|
+
Object.getOwnPropertyNames(err).forEach(function (key) {
|
|
939
|
+
jsonObj[key] = Object.getOwnPropertyDescriptor(err, key);
|
|
940
|
+
});
|
|
941
|
+
} catch (_) {
|
|
942
|
+
return {
|
|
943
|
+
error: 'failed to serialize the error'
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
|
|
940
947
|
return jsonObj;
|
|
941
948
|
}
|
|
949
|
+
/**
|
|
950
|
+
* isOnline safely return the navigator.online value
|
|
951
|
+
* if navigator is not in global object, it always return true
|
|
952
|
+
*/
|
|
953
|
+
|
|
954
|
+
function isOnline() {
|
|
955
|
+
var nav = typeof navigator !== 'undefined' ? navigator : typeof window !== 'undefined' && window.navigator ? window.navigator : undefined;
|
|
956
|
+
if (!nav) return true;
|
|
957
|
+
return nav.onLine;
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* listenForConnectionChanges - Adds an event listener fired on browser going online or offline
|
|
961
|
+
*/
|
|
962
|
+
|
|
963
|
+
function addConnectionEventListeners(cb) {
|
|
964
|
+
if (typeof window !== 'undefined' && window.addEventListener) {
|
|
965
|
+
window.addEventListener('offline', cb);
|
|
966
|
+
window.addEventListener('online', cb);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
function removeConnectionEventListeners(cb) {
|
|
970
|
+
if (typeof window !== 'undefined' && window.removeEventListener) {
|
|
971
|
+
window.removeEventListener('offline', cb);
|
|
972
|
+
window.removeEventListener('online', cb);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
942
975
|
|
|
943
976
|
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; } } }; }
|
|
944
977
|
|
|
@@ -946,9 +979,9 @@ function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o
|
|
|
946
979
|
|
|
947
980
|
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; }
|
|
948
981
|
|
|
949
|
-
function ownKeys$
|
|
982
|
+
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; }
|
|
950
983
|
|
|
951
|
-
function _objectSpread$
|
|
984
|
+
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; }
|
|
952
985
|
|
|
953
986
|
/**
|
|
954
987
|
* Channel - The Channel class manages it's own state.
|
|
@@ -1068,7 +1101,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1068
1101
|
|
|
1069
1102
|
this.data = data; // this._data is used for the requests...
|
|
1070
1103
|
|
|
1071
|
-
this._data = _objectSpread$
|
|
1104
|
+
this._data = _objectSpread$5({}, data);
|
|
1072
1105
|
this.cid = "".concat(type, ":").concat(id);
|
|
1073
1106
|
this.listeners = {}; // perhaps the state variable should be private
|
|
1074
1107
|
|
|
@@ -1126,7 +1159,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1126
1159
|
switch (_context2.prev = _context2.next) {
|
|
1127
1160
|
case 0:
|
|
1128
1161
|
_context2.next = 2;
|
|
1129
|
-
return this.getClient().post(this._channelURL() + '/message', _objectSpread$
|
|
1162
|
+
return this.getClient().post(this._channelURL() + '/message', _objectSpread$5({
|
|
1130
1163
|
message: message
|
|
1131
1164
|
}, options));
|
|
1132
1165
|
|
|
@@ -1245,7 +1278,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1245
1278
|
|
|
1246
1279
|
case 3:
|
|
1247
1280
|
// Return a list of channels
|
|
1248
|
-
payload = _objectSpread$
|
|
1281
|
+
payload = _objectSpread$5(_objectSpread$5({
|
|
1249
1282
|
filter_conditions: {
|
|
1250
1283
|
cid: this.cid
|
|
1251
1284
|
}
|
|
@@ -1342,7 +1375,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1342
1375
|
|
|
1343
1376
|
_context5.next = 6;
|
|
1344
1377
|
return this.getClient().get(this.getClient().baseURL + '/members', {
|
|
1345
|
-
payload: _objectSpread$
|
|
1378
|
+
payload: _objectSpread$5({
|
|
1346
1379
|
type: type,
|
|
1347
1380
|
id: id,
|
|
1348
1381
|
members: members,
|
|
@@ -1403,7 +1436,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1403
1436
|
|
|
1404
1437
|
case 4:
|
|
1405
1438
|
_context6.next = 6;
|
|
1406
|
-
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(messageID, "/reaction"), _objectSpread$
|
|
1439
|
+
return this.getClient().post(this.getClient().baseURL + "/messages/".concat(messageID, "/reaction"), _objectSpread$5({
|
|
1407
1440
|
reaction: reaction
|
|
1408
1441
|
}, options));
|
|
1409
1442
|
|
|
@@ -1458,7 +1491,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1458
1491
|
*
|
|
1459
1492
|
* @param {ChannelData<ChannelType>} channelData The object to update the custom properties of this channel with
|
|
1460
1493
|
* @param {Message<AttachmentType, MessageType, UserType>} [updateMessage] Optional message object for channel members notification
|
|
1461
|
-
* @param {
|
|
1494
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1462
1495
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1463
1496
|
*/
|
|
1464
1497
|
|
|
@@ -1484,7 +1517,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1484
1517
|
delete channelData[key];
|
|
1485
1518
|
});
|
|
1486
1519
|
_context7.next = 7;
|
|
1487
|
-
return this._update(_objectSpread$
|
|
1520
|
+
return this._update(_objectSpread$5({
|
|
1488
1521
|
message: updateMessage,
|
|
1489
1522
|
data: channelData
|
|
1490
1523
|
}, options));
|
|
@@ -1657,25 +1690,28 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1657
1690
|
}()
|
|
1658
1691
|
/**
|
|
1659
1692
|
* truncate - Removes all messages from the channel
|
|
1660
|
-
*
|
|
1661
|
-
* @return {Promise<TruncateChannelAPIResponse<ChannelType, CommandType, UserType>>} The server response
|
|
1693
|
+
* @param {TruncateOptions<AttachmentType, MessageType, UserType>} [options] Defines truncation options
|
|
1694
|
+
* @return {Promise<TruncateChannelAPIResponse<ChannelType, CommandType, UserType, MessageType, ReactionType>>} The server response
|
|
1662
1695
|
*/
|
|
1663
1696
|
|
|
1664
1697
|
}, {
|
|
1665
1698
|
key: "truncate",
|
|
1666
1699
|
value: function () {
|
|
1667
1700
|
var _truncate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
|
1701
|
+
var options,
|
|
1702
|
+
_args12 = arguments;
|
|
1668
1703
|
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
1669
1704
|
while (1) {
|
|
1670
1705
|
switch (_context12.prev = _context12.next) {
|
|
1671
1706
|
case 0:
|
|
1672
|
-
|
|
1673
|
-
|
|
1707
|
+
options = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
|
|
1708
|
+
_context12.next = 3;
|
|
1709
|
+
return this.getClient().post(this._channelURL() + '/truncate', options);
|
|
1674
1710
|
|
|
1675
|
-
case
|
|
1711
|
+
case 3:
|
|
1676
1712
|
return _context12.abrupt("return", _context12.sent);
|
|
1677
1713
|
|
|
1678
|
-
case
|
|
1714
|
+
case 4:
|
|
1679
1715
|
case "end":
|
|
1680
1716
|
return _context12.stop();
|
|
1681
1717
|
}
|
|
@@ -1709,7 +1745,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1709
1745
|
case 0:
|
|
1710
1746
|
options = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
|
|
1711
1747
|
_context13.next = 3;
|
|
1712
|
-
return this._update(_objectSpread$
|
|
1748
|
+
return this._update(_objectSpread$5({
|
|
1713
1749
|
accept_invite: true
|
|
1714
1750
|
}, options));
|
|
1715
1751
|
|
|
@@ -1750,7 +1786,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1750
1786
|
case 0:
|
|
1751
1787
|
options = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
|
|
1752
1788
|
_context14.next = 3;
|
|
1753
|
-
return this._update(_objectSpread$
|
|
1789
|
+
return this._update(_objectSpread$5({
|
|
1754
1790
|
reject_invite: true
|
|
1755
1791
|
}, options));
|
|
1756
1792
|
|
|
@@ -1776,6 +1812,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1776
1812
|
*
|
|
1777
1813
|
* @param {{user_id: string, channel_role?: Role}[]} members An array of members to add to the channel
|
|
1778
1814
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1815
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1779
1816
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1780
1817
|
*/
|
|
1781
1818
|
|
|
@@ -1783,20 +1820,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1783
1820
|
key: "addMembers",
|
|
1784
1821
|
value: function () {
|
|
1785
1822
|
var _addMembers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(members, message) {
|
|
1823
|
+
var options,
|
|
1824
|
+
_args15 = arguments;
|
|
1786
1825
|
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
1787
1826
|
while (1) {
|
|
1788
1827
|
switch (_context15.prev = _context15.next) {
|
|
1789
1828
|
case 0:
|
|
1790
|
-
|
|
1791
|
-
|
|
1829
|
+
options = _args15.length > 2 && _args15[2] !== undefined ? _args15[2] : {};
|
|
1830
|
+
_context15.next = 3;
|
|
1831
|
+
return this._update(_objectSpread$5({
|
|
1792
1832
|
add_members: members,
|
|
1793
1833
|
message: message
|
|
1794
|
-
});
|
|
1834
|
+
}, options));
|
|
1795
1835
|
|
|
1796
|
-
case
|
|
1836
|
+
case 3:
|
|
1797
1837
|
return _context15.abrupt("return", _context15.sent);
|
|
1798
1838
|
|
|
1799
|
-
case
|
|
1839
|
+
case 4:
|
|
1800
1840
|
case "end":
|
|
1801
1841
|
return _context15.stop();
|
|
1802
1842
|
}
|
|
@@ -1815,6 +1855,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1815
1855
|
*
|
|
1816
1856
|
* @param {string[]} members An array of member identifiers
|
|
1817
1857
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1858
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1818
1859
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1819
1860
|
*/
|
|
1820
1861
|
|
|
@@ -1822,20 +1863,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1822
1863
|
key: "addModerators",
|
|
1823
1864
|
value: function () {
|
|
1824
1865
|
var _addModerators = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(members, message) {
|
|
1866
|
+
var options,
|
|
1867
|
+
_args16 = arguments;
|
|
1825
1868
|
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
1826
1869
|
while (1) {
|
|
1827
1870
|
switch (_context16.prev = _context16.next) {
|
|
1828
1871
|
case 0:
|
|
1829
|
-
|
|
1830
|
-
|
|
1872
|
+
options = _args16.length > 2 && _args16[2] !== undefined ? _args16[2] : {};
|
|
1873
|
+
_context16.next = 3;
|
|
1874
|
+
return this._update(_objectSpread$5({
|
|
1831
1875
|
add_moderators: members,
|
|
1832
1876
|
message: message
|
|
1833
|
-
});
|
|
1877
|
+
}, options));
|
|
1834
1878
|
|
|
1835
|
-
case
|
|
1879
|
+
case 3:
|
|
1836
1880
|
return _context16.abrupt("return", _context16.sent);
|
|
1837
1881
|
|
|
1838
|
-
case
|
|
1882
|
+
case 4:
|
|
1839
1883
|
case "end":
|
|
1840
1884
|
return _context16.stop();
|
|
1841
1885
|
}
|
|
@@ -1854,6 +1898,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1854
1898
|
*
|
|
1855
1899
|
* @param {{channel_role: Role, user_id: string}[]} roles List of role assignments
|
|
1856
1900
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1901
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1857
1902
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1858
1903
|
*/
|
|
1859
1904
|
|
|
@@ -1861,20 +1906,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1861
1906
|
key: "assignRoles",
|
|
1862
1907
|
value: function () {
|
|
1863
1908
|
var _assignRoles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(roles, message) {
|
|
1909
|
+
var options,
|
|
1910
|
+
_args17 = arguments;
|
|
1864
1911
|
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1865
1912
|
while (1) {
|
|
1866
1913
|
switch (_context17.prev = _context17.next) {
|
|
1867
1914
|
case 0:
|
|
1868
|
-
|
|
1869
|
-
|
|
1915
|
+
options = _args17.length > 2 && _args17[2] !== undefined ? _args17[2] : {};
|
|
1916
|
+
_context17.next = 3;
|
|
1917
|
+
return this._update(_objectSpread$5({
|
|
1870
1918
|
assign_roles: roles,
|
|
1871
1919
|
message: message
|
|
1872
|
-
});
|
|
1920
|
+
}, options));
|
|
1873
1921
|
|
|
1874
|
-
case
|
|
1922
|
+
case 3:
|
|
1875
1923
|
return _context17.abrupt("return", _context17.sent);
|
|
1876
1924
|
|
|
1877
|
-
case
|
|
1925
|
+
case 4:
|
|
1878
1926
|
case "end":
|
|
1879
1927
|
return _context17.stop();
|
|
1880
1928
|
}
|
|
@@ -1893,6 +1941,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1893
1941
|
*
|
|
1894
1942
|
* @param {{user_id: string, channel_role?: Role}[]} members An array of members to invite to the channel
|
|
1895
1943
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1944
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1896
1945
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1897
1946
|
*/
|
|
1898
1947
|
|
|
@@ -1900,20 +1949,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1900
1949
|
key: "inviteMembers",
|
|
1901
1950
|
value: function () {
|
|
1902
1951
|
var _inviteMembers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(members, message) {
|
|
1952
|
+
var options,
|
|
1953
|
+
_args18 = arguments;
|
|
1903
1954
|
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1904
1955
|
while (1) {
|
|
1905
1956
|
switch (_context18.prev = _context18.next) {
|
|
1906
1957
|
case 0:
|
|
1907
|
-
|
|
1908
|
-
|
|
1958
|
+
options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
|
|
1959
|
+
_context18.next = 3;
|
|
1960
|
+
return this._update(_objectSpread$5({
|
|
1909
1961
|
invites: members,
|
|
1910
1962
|
message: message
|
|
1911
|
-
});
|
|
1963
|
+
}, options));
|
|
1912
1964
|
|
|
1913
|
-
case
|
|
1965
|
+
case 3:
|
|
1914
1966
|
return _context18.abrupt("return", _context18.sent);
|
|
1915
1967
|
|
|
1916
|
-
case
|
|
1968
|
+
case 4:
|
|
1917
1969
|
case "end":
|
|
1918
1970
|
return _context18.stop();
|
|
1919
1971
|
}
|
|
@@ -1932,6 +1984,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1932
1984
|
*
|
|
1933
1985
|
* @param {string[]} members An array of member identifiers
|
|
1934
1986
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
1987
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1935
1988
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1936
1989
|
*/
|
|
1937
1990
|
|
|
@@ -1939,20 +1992,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1939
1992
|
key: "removeMembers",
|
|
1940
1993
|
value: function () {
|
|
1941
1994
|
var _removeMembers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(members, message) {
|
|
1995
|
+
var options,
|
|
1996
|
+
_args19 = arguments;
|
|
1942
1997
|
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
1943
1998
|
while (1) {
|
|
1944
1999
|
switch (_context19.prev = _context19.next) {
|
|
1945
2000
|
case 0:
|
|
1946
|
-
|
|
1947
|
-
|
|
2001
|
+
options = _args19.length > 2 && _args19[2] !== undefined ? _args19[2] : {};
|
|
2002
|
+
_context19.next = 3;
|
|
2003
|
+
return this._update(_objectSpread$5({
|
|
1948
2004
|
remove_members: members,
|
|
1949
2005
|
message: message
|
|
1950
|
-
});
|
|
2006
|
+
}, options));
|
|
1951
2007
|
|
|
1952
|
-
case
|
|
2008
|
+
case 3:
|
|
1953
2009
|
return _context19.abrupt("return", _context19.sent);
|
|
1954
2010
|
|
|
1955
|
-
case
|
|
2011
|
+
case 4:
|
|
1956
2012
|
case "end":
|
|
1957
2013
|
return _context19.stop();
|
|
1958
2014
|
}
|
|
@@ -1971,6 +2027,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1971
2027
|
*
|
|
1972
2028
|
* @param {string[]} members An array of member identifiers
|
|
1973
2029
|
* @param {Message<AttachmentType, MessageType, UserType>} [message] Optional message object for channel members notification
|
|
2030
|
+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
|
|
1974
2031
|
* @return {Promise<UpdateChannelAPIResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>>} The server response
|
|
1975
2032
|
*/
|
|
1976
2033
|
|
|
@@ -1978,20 +2035,23 @@ var Channel = /*#__PURE__*/function () {
|
|
|
1978
2035
|
key: "demoteModerators",
|
|
1979
2036
|
value: function () {
|
|
1980
2037
|
var _demoteModerators = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(members, message) {
|
|
2038
|
+
var options,
|
|
2039
|
+
_args20 = arguments;
|
|
1981
2040
|
return _regeneratorRuntime.wrap(function _callee20$(_context20) {
|
|
1982
2041
|
while (1) {
|
|
1983
2042
|
switch (_context20.prev = _context20.next) {
|
|
1984
2043
|
case 0:
|
|
1985
|
-
|
|
1986
|
-
|
|
2044
|
+
options = _args20.length > 2 && _args20[2] !== undefined ? _args20[2] : {};
|
|
2045
|
+
_context20.next = 3;
|
|
2046
|
+
return this._update(_objectSpread$5({
|
|
1987
2047
|
demote_moderators: members,
|
|
1988
2048
|
message: message
|
|
1989
|
-
});
|
|
2049
|
+
}, options));
|
|
1990
2050
|
|
|
1991
|
-
case
|
|
2051
|
+
case 3:
|
|
1992
2052
|
return _context20.abrupt("return", _context20.sent);
|
|
1993
2053
|
|
|
1994
|
-
case
|
|
2054
|
+
case 4:
|
|
1995
2055
|
case "end":
|
|
1996
2056
|
return _context20.stop();
|
|
1997
2057
|
}
|
|
@@ -2068,7 +2128,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2068
2128
|
case 0:
|
|
2069
2129
|
opts = _args22.length > 0 && _args22[0] !== undefined ? _args22[0] : {};
|
|
2070
2130
|
_context22.next = 3;
|
|
2071
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$
|
|
2131
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/mute/channel', _objectSpread$5({
|
|
2072
2132
|
channel_cid: this.cid
|
|
2073
2133
|
}, opts));
|
|
2074
2134
|
|
|
@@ -2110,7 +2170,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2110
2170
|
case 0:
|
|
2111
2171
|
opts = _args23.length > 0 && _args23[0] !== undefined ? _args23[0] : {};
|
|
2112
2172
|
_context23.next = 3;
|
|
2113
|
-
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$
|
|
2173
|
+
return this.getClient().post(this.getClient().baseURL + '/moderation/unmute/channel', _objectSpread$5({
|
|
2114
2174
|
channel_cid: this.cid
|
|
2115
2175
|
}, opts));
|
|
2116
2176
|
|
|
@@ -2319,7 +2379,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2319
2379
|
|
|
2320
2380
|
case 4:
|
|
2321
2381
|
_context26.next = 6;
|
|
2322
|
-
return this.getClient().post(this._channelURL() + '/read', _objectSpread$
|
|
2382
|
+
return this.getClient().post(this._channelURL() + '/read', _objectSpread$5({}, data));
|
|
2323
2383
|
|
|
2324
2384
|
case 6:
|
|
2325
2385
|
return _context26.abrupt("return", _context26.sent);
|
|
@@ -2387,7 +2447,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2387
2447
|
defaultOptions.watch = false;
|
|
2388
2448
|
}
|
|
2389
2449
|
|
|
2390
|
-
combined = _objectSpread$
|
|
2450
|
+
combined = _objectSpread$5(_objectSpread$5({}, defaultOptions), options);
|
|
2391
2451
|
_context27.next = 7;
|
|
2392
2452
|
return this.query(combined);
|
|
2393
2453
|
|
|
@@ -2478,7 +2538,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2478
2538
|
switch (_context29.prev = _context29.next) {
|
|
2479
2539
|
case 0:
|
|
2480
2540
|
_context29.next = 2;
|
|
2481
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(parent_id, "/replies"), _objectSpread$
|
|
2541
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(parent_id, "/replies"), _objectSpread$5({}, options));
|
|
2482
2542
|
|
|
2483
2543
|
case 2:
|
|
2484
2544
|
data = _context29.sent;
|
|
@@ -2516,7 +2576,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2516
2576
|
}, {
|
|
2517
2577
|
key: "getReactions",
|
|
2518
2578
|
value: function getReactions(message_id, options) {
|
|
2519
|
-
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(message_id, "/reactions"), _objectSpread$
|
|
2579
|
+
return this.getClient().get(this.getClient().baseURL + "/messages/".concat(message_id, "/reactions"), _objectSpread$5({}, options));
|
|
2520
2580
|
}
|
|
2521
2581
|
/**
|
|
2522
2582
|
* getMessagesById - Retrieves a list of messages by ID
|
|
@@ -2648,7 +2708,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2648
2708
|
}
|
|
2649
2709
|
|
|
2650
2710
|
_context30.next = 6;
|
|
2651
|
-
return this.getClient().post(queryURL + '/query', _objectSpread$
|
|
2711
|
+
return this.getClient().post(queryURL + '/query', _objectSpread$5({
|
|
2652
2712
|
data: this._data,
|
|
2653
2713
|
state: true
|
|
2654
2714
|
}, options));
|
|
@@ -2719,7 +2779,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2719
2779
|
this._checkInitialized();
|
|
2720
2780
|
|
|
2721
2781
|
_context31.next = 3;
|
|
2722
|
-
return this.getClient().banUser(targetUserID, _objectSpread$
|
|
2782
|
+
return this.getClient().banUser(targetUserID, _objectSpread$5(_objectSpread$5({}, options), {}, {
|
|
2723
2783
|
type: this.type,
|
|
2724
2784
|
id: this.id
|
|
2725
2785
|
}));
|
|
@@ -2891,7 +2951,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
2891
2951
|
this._checkInitialized();
|
|
2892
2952
|
|
|
2893
2953
|
_context35.next = 3;
|
|
2894
|
-
return this.getClient().shadowBan(targetUserID, _objectSpread$
|
|
2954
|
+
return this.getClient().shadowBan(targetUserID, _objectSpread$5(_objectSpread$5({}, options), {}, {
|
|
2895
2955
|
type: this.type,
|
|
2896
2956
|
id: this.id
|
|
2897
2957
|
}));
|
|
@@ -3304,7 +3364,7 @@ var Channel = /*#__PURE__*/function () {
|
|
|
3304
3364
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
3305
3365
|
var read = _step3.value;
|
|
3306
3366
|
|
|
3307
|
-
var parsedRead = _objectSpread$
|
|
3367
|
+
var parsedRead = _objectSpread$5(_objectSpread$5({}, read), {}, {
|
|
3308
3368
|
last_read: new Date(read.last_read)
|
|
3309
3369
|
});
|
|
3310
3370
|
|
|
@@ -3431,9 +3491,9 @@ var ClientState = /*#__PURE__*/function () {
|
|
|
3431
3491
|
return ClientState;
|
|
3432
3492
|
}();
|
|
3433
3493
|
|
|
3434
|
-
function ownKeys$
|
|
3494
|
+
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; }
|
|
3435
3495
|
|
|
3436
|
-
function _objectSpread$
|
|
3496
|
+
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; }
|
|
3437
3497
|
var InsightMetrics = function InsightMetrics() {
|
|
3438
3498
|
_classCallCheck(this, InsightMetrics);
|
|
3439
3499
|
|
|
@@ -3450,32 +3510,94 @@ var InsightMetrics = function InsightMetrics() {
|
|
|
3450
3510
|
this.wsConsecutiveFailures = 0;
|
|
3451
3511
|
this.instanceClientId = randomId();
|
|
3452
3512
|
};
|
|
3513
|
+
/**
|
|
3514
|
+
* postInsights is not supposed to be used by end users directly within chat application, and thus is kept isolated
|
|
3515
|
+
* from all the client/connection code/logic.
|
|
3516
|
+
*
|
|
3517
|
+
* @param insightType
|
|
3518
|
+
* @param insights
|
|
3519
|
+
*/
|
|
3520
|
+
|
|
3521
|
+
var postInsights = /*#__PURE__*/function () {
|
|
3522
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(insightType, insights) {
|
|
3523
|
+
var maxAttempts, i;
|
|
3524
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
3525
|
+
while (1) {
|
|
3526
|
+
switch (_context.prev = _context.next) {
|
|
3527
|
+
case 0:
|
|
3528
|
+
maxAttempts = 3;
|
|
3529
|
+
i = 0;
|
|
3530
|
+
|
|
3531
|
+
case 2:
|
|
3532
|
+
if (!(i < maxAttempts)) {
|
|
3533
|
+
_context.next = 17;
|
|
3534
|
+
break;
|
|
3535
|
+
}
|
|
3536
|
+
|
|
3537
|
+
_context.prev = 3;
|
|
3538
|
+
_context.next = 6;
|
|
3539
|
+
return axios.post("https://chat-insights.getstream.io/insights/".concat(insightType), insights);
|
|
3540
|
+
|
|
3541
|
+
case 6:
|
|
3542
|
+
_context.next = 13;
|
|
3543
|
+
break;
|
|
3544
|
+
|
|
3545
|
+
case 8:
|
|
3546
|
+
_context.prev = 8;
|
|
3547
|
+
_context.t0 = _context["catch"](3);
|
|
3548
|
+
_context.next = 12;
|
|
3549
|
+
return sleep((i + 1) * 3000);
|
|
3550
|
+
|
|
3551
|
+
case 12:
|
|
3552
|
+
return _context.abrupt("continue", 14);
|
|
3553
|
+
|
|
3554
|
+
case 13:
|
|
3555
|
+
return _context.abrupt("break", 17);
|
|
3556
|
+
|
|
3557
|
+
case 14:
|
|
3558
|
+
i++;
|
|
3559
|
+
_context.next = 2;
|
|
3560
|
+
break;
|
|
3561
|
+
|
|
3562
|
+
case 17:
|
|
3563
|
+
case "end":
|
|
3564
|
+
return _context.stop();
|
|
3565
|
+
}
|
|
3566
|
+
}
|
|
3567
|
+
}, _callee, null, [[3, 8]]);
|
|
3568
|
+
}));
|
|
3569
|
+
|
|
3570
|
+
return function postInsights(_x, _x2) {
|
|
3571
|
+
return _ref.apply(this, arguments);
|
|
3572
|
+
};
|
|
3573
|
+
}();
|
|
3453
3574
|
function buildWsFatalInsight(connection, event) {
|
|
3454
|
-
return _objectSpread$
|
|
3575
|
+
return _objectSpread$4(_objectSpread$4({}, event), buildWsBaseInsight(connection));
|
|
3455
3576
|
}
|
|
3456
3577
|
|
|
3457
3578
|
function buildWsBaseInsight(connection) {
|
|
3458
3579
|
var _connection$ws, _navigator, _navigator2;
|
|
3459
3580
|
|
|
3581
|
+
var client = connection.client;
|
|
3460
3582
|
return {
|
|
3461
3583
|
ready_state: (_connection$ws = connection.ws) === null || _connection$ws === void 0 ? void 0 : _connection$ws.readyState,
|
|
3462
|
-
url: connection._buildUrl(
|
|
3463
|
-
api_key:
|
|
3464
|
-
start_ts:
|
|
3584
|
+
url: connection._buildUrl(),
|
|
3585
|
+
api_key: client.key,
|
|
3586
|
+
start_ts: client.insightMetrics.connectionStartTimestamp,
|
|
3465
3587
|
end_ts: new Date().getTime(),
|
|
3466
|
-
auth_type:
|
|
3467
|
-
token:
|
|
3468
|
-
user_id:
|
|
3469
|
-
user_details:
|
|
3470
|
-
device:
|
|
3588
|
+
auth_type: client.getAuthType(),
|
|
3589
|
+
token: client.tokenManager.token,
|
|
3590
|
+
user_id: client.userID,
|
|
3591
|
+
user_details: client._user,
|
|
3592
|
+
device: client.options.device,
|
|
3471
3593
|
client_id: connection.connectionID,
|
|
3472
3594
|
ws_details: connection.ws,
|
|
3473
|
-
ws_consecutive_failures:
|
|
3474
|
-
ws_total_failures:
|
|
3595
|
+
ws_consecutive_failures: client.insightMetrics.wsConsecutiveFailures,
|
|
3596
|
+
ws_total_failures: client.insightMetrics.wsTotalFailures,
|
|
3475
3597
|
request_id: connection.requestID,
|
|
3476
3598
|
online: typeof navigator !== 'undefined' ? (_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.onLine : null,
|
|
3477
3599
|
user_agent: typeof navigator !== 'undefined' ? (_navigator2 = navigator) === null || _navigator2 === void 0 ? void 0 : _navigator2.userAgent : null,
|
|
3478
|
-
instance_client_id:
|
|
3600
|
+
instance_client_id: client.insightMetrics.instanceClientId
|
|
3479
3601
|
};
|
|
3480
3602
|
}
|
|
3481
3603
|
|
|
@@ -3483,6 +3605,10 @@ function buildWsSuccessAfterFailureInsight(connection) {
|
|
|
3483
3605
|
return buildWsBaseInsight(connection);
|
|
3484
3606
|
}
|
|
3485
3607
|
|
|
3608
|
+
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; }
|
|
3609
|
+
|
|
3610
|
+
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; }
|
|
3611
|
+
|
|
3486
3612
|
// Type guards to check WebSocket error type
|
|
3487
3613
|
var isCloseEvent = function isCloseEvent(res) {
|
|
3488
3614
|
return res.code !== undefined;
|
|
@@ -3491,7 +3617,6 @@ var isCloseEvent = function isCloseEvent(res) {
|
|
|
3491
3617
|
var isErrorEvent = function isErrorEvent(res) {
|
|
3492
3618
|
return res.error !== undefined;
|
|
3493
3619
|
};
|
|
3494
|
-
|
|
3495
3620
|
/**
|
|
3496
3621
|
* StableWSConnection - A WS connection that reconnects upon failure.
|
|
3497
3622
|
* - the browser will sometimes report that you're online or offline
|
|
@@ -3509,53 +3634,19 @@ var isErrorEvent = function isErrorEvent(res) {
|
|
|
3509
3634
|
* - state can be recovered by querying the channel again
|
|
3510
3635
|
* - if the servers fails to publish a message to the client, the WS connection is destroyed
|
|
3511
3636
|
*/
|
|
3637
|
+
|
|
3638
|
+
|
|
3512
3639
|
var StableWSConnection = /*#__PURE__*/function () {
|
|
3640
|
+
// global from constructor
|
|
3641
|
+
// local vars
|
|
3513
3642
|
function StableWSConnection(_ref) {
|
|
3514
3643
|
var _this = this;
|
|
3515
3644
|
|
|
3516
|
-
var
|
|
3517
|
-
authType = _ref.authType,
|
|
3518
|
-
clientID = _ref.clientID,
|
|
3519
|
-
eventCallback = _ref.eventCallback,
|
|
3520
|
-
logger = _ref.logger,
|
|
3521
|
-
messageCallback = _ref.messageCallback,
|
|
3522
|
-
recoverCallback = _ref.recoverCallback,
|
|
3523
|
-
tokenManager = _ref.tokenManager,
|
|
3524
|
-
user = _ref.user,
|
|
3525
|
-
userAgent = _ref.userAgent,
|
|
3526
|
-
userID = _ref.userID,
|
|
3527
|
-
wsBaseURL = _ref.wsBaseURL,
|
|
3528
|
-
device = _ref.device,
|
|
3529
|
-
postInsights = _ref.postInsights,
|
|
3530
|
-
insightMetrics = _ref.insightMetrics;
|
|
3645
|
+
var client = _ref.client;
|
|
3531
3646
|
|
|
3532
3647
|
_classCallCheck(this, StableWSConnection);
|
|
3533
3648
|
|
|
3534
|
-
_defineProperty(this, "
|
|
3535
|
-
|
|
3536
|
-
_defineProperty(this, "authType", void 0);
|
|
3537
|
-
|
|
3538
|
-
_defineProperty(this, "clientID", void 0);
|
|
3539
|
-
|
|
3540
|
-
_defineProperty(this, "eventCallback", void 0);
|
|
3541
|
-
|
|
3542
|
-
_defineProperty(this, "logger", void 0);
|
|
3543
|
-
|
|
3544
|
-
_defineProperty(this, "messageCallback", void 0);
|
|
3545
|
-
|
|
3546
|
-
_defineProperty(this, "recoverCallback", void 0);
|
|
3547
|
-
|
|
3548
|
-
_defineProperty(this, "tokenManager", void 0);
|
|
3549
|
-
|
|
3550
|
-
_defineProperty(this, "user", void 0);
|
|
3551
|
-
|
|
3552
|
-
_defineProperty(this, "userAgent", void 0);
|
|
3553
|
-
|
|
3554
|
-
_defineProperty(this, "userID", void 0);
|
|
3555
|
-
|
|
3556
|
-
_defineProperty(this, "wsBaseURL", void 0);
|
|
3557
|
-
|
|
3558
|
-
_defineProperty(this, "device", void 0);
|
|
3649
|
+
_defineProperty(this, "client", void 0);
|
|
3559
3650
|
|
|
3560
3651
|
_defineProperty(this, "connectionID", void 0);
|
|
3561
3652
|
|
|
@@ -3569,6 +3660,8 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3569
3660
|
|
|
3570
3661
|
_defineProperty(this, "isConnecting", void 0);
|
|
3571
3662
|
|
|
3663
|
+
_defineProperty(this, "isDisconnected", void 0);
|
|
3664
|
+
|
|
3572
3665
|
_defineProperty(this, "isHealthy", void 0);
|
|
3573
3666
|
|
|
3574
3667
|
_defineProperty(this, "isResolved", void 0);
|
|
@@ -3583,8 +3676,6 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3583
3676
|
|
|
3584
3677
|
_defineProperty(this, "requestID", void 0);
|
|
3585
3678
|
|
|
3586
|
-
_defineProperty(this, "connectionStartTimestamp", void 0);
|
|
3587
|
-
|
|
3588
3679
|
_defineProperty(this, "resolvePromise", void 0);
|
|
3589
3680
|
|
|
3590
3681
|
_defineProperty(this, "totalFailures", void 0);
|
|
@@ -3593,32 +3684,18 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3593
3684
|
|
|
3594
3685
|
_defineProperty(this, "wsID", void 0);
|
|
3595
3686
|
|
|
3596
|
-
_defineProperty(this, "
|
|
3597
|
-
|
|
3598
|
-
_defineProperty(this, "insightMetrics", void 0);
|
|
3687
|
+
_defineProperty(this, "_buildUrl", function () {
|
|
3688
|
+
var qs = encodeURIComponent(_this.client._buildWSPayload(_this.requestID));
|
|
3599
3689
|
|
|
3600
|
-
|
|
3601
|
-
var params = {
|
|
3602
|
-
user_id: _this.user.id,
|
|
3603
|
-
user_details: _this.user,
|
|
3604
|
-
user_token: _this.tokenManager.getToken(),
|
|
3605
|
-
server_determines_connection_id: true,
|
|
3606
|
-
device: _this.device,
|
|
3607
|
-
request_id: reqID
|
|
3608
|
-
};
|
|
3609
|
-
var qs = encodeURIComponent(JSON.stringify(params));
|
|
3690
|
+
var token = _this.client.tokenManager.getToken();
|
|
3610
3691
|
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
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);
|
|
3692
|
+
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());
|
|
3614
3693
|
});
|
|
3615
3694
|
|
|
3616
3695
|
_defineProperty(this, "onlineStatusChanged", function (event) {
|
|
3617
3696
|
if (event.type === 'offline') {
|
|
3618
3697
|
// mark the connection as down
|
|
3619
|
-
_this.
|
|
3620
|
-
tags: ['connection']
|
|
3621
|
-
});
|
|
3698
|
+
_this._log('onlineStatusChanged() - Status changing to offline');
|
|
3622
3699
|
|
|
3623
3700
|
_this._setHealth(false);
|
|
3624
3701
|
} else if (event.type === 'online') {
|
|
@@ -3626,9 +3703,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3626
3703
|
// We check this.isHealthy, not sure if it's always
|
|
3627
3704
|
// smart to create a new WS connection if the old one is still up and running.
|
|
3628
3705
|
// it's possible we didn't miss any messages, so this process is just expensive and not needed.
|
|
3629
|
-
_this.
|
|
3630
|
-
tags: ['connection']
|
|
3631
|
-
});
|
|
3706
|
+
_this._log("onlineStatusChanged() - Status changing to online. isHealthy: ".concat(_this.isHealthy));
|
|
3632
3707
|
|
|
3633
3708
|
if (!_this.isHealthy) {
|
|
3634
3709
|
_this._reconnect({
|
|
@@ -3641,8 +3716,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3641
3716
|
_defineProperty(this, "onopen", function (wsID) {
|
|
3642
3717
|
if (_this.wsID !== wsID) return;
|
|
3643
3718
|
|
|
3644
|
-
_this.
|
|
3645
|
-
tags: ['connection'],
|
|
3719
|
+
_this._log('onopen() - onopen callback', {
|
|
3646
3720
|
wsID: wsID
|
|
3647
3721
|
});
|
|
3648
3722
|
});
|
|
@@ -3654,27 +3728,26 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3654
3728
|
// after that a ws.onclose..
|
|
3655
3729
|
|
|
3656
3730
|
if (!_this.isResolved && data) {
|
|
3731
|
+
var _this$resolvePromise;
|
|
3732
|
+
|
|
3657
3733
|
_this.isResolved = true;
|
|
3658
3734
|
|
|
3659
|
-
if (data.error
|
|
3735
|
+
if (data.error) {
|
|
3660
3736
|
var _this$rejectPromise;
|
|
3661
3737
|
|
|
3662
3738
|
(_this$rejectPromise = _this.rejectPromise) === null || _this$rejectPromise === void 0 ? void 0 : _this$rejectPromise.call(_this, _this._errorFromWSEvent(data, false));
|
|
3663
3739
|
return;
|
|
3664
|
-
}
|
|
3665
|
-
var _this$resolvePromise;
|
|
3740
|
+
}
|
|
3666
3741
|
|
|
3667
|
-
|
|
3742
|
+
(_this$resolvePromise = _this.resolvePromise) === null || _this$resolvePromise === void 0 ? void 0 : _this$resolvePromise.call(_this, data);
|
|
3668
3743
|
|
|
3669
|
-
|
|
3670
|
-
}
|
|
3744
|
+
_this._setHealth(true);
|
|
3671
3745
|
} // trigger the event..
|
|
3672
3746
|
|
|
3673
3747
|
|
|
3674
3748
|
_this.lastEvent = new Date();
|
|
3675
3749
|
|
|
3676
|
-
_this.
|
|
3677
|
-
tags: ['connection'],
|
|
3750
|
+
_this._log('onmessage() - onmessage callback', {
|
|
3678
3751
|
event: event,
|
|
3679
3752
|
wsID: wsID
|
|
3680
3753
|
});
|
|
@@ -3683,7 +3756,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3683
3756
|
_this.scheduleNextPing();
|
|
3684
3757
|
}
|
|
3685
3758
|
|
|
3686
|
-
_this.
|
|
3759
|
+
_this.client.handleEvent(event);
|
|
3687
3760
|
|
|
3688
3761
|
_this.scheduleConnectionCheck();
|
|
3689
3762
|
});
|
|
@@ -3691,8 +3764,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3691
3764
|
_defineProperty(this, "onclose", function (wsID, event) {
|
|
3692
3765
|
if (_this.wsID !== wsID) return;
|
|
3693
3766
|
|
|
3694
|
-
_this.
|
|
3695
|
-
tags: ['connection'],
|
|
3767
|
+
_this._log('onclose() - onclose callback - ' + event.code, {
|
|
3696
3768
|
event: event,
|
|
3697
3769
|
wsID: wsID
|
|
3698
3770
|
});
|
|
@@ -3709,8 +3781,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3709
3781
|
error.target = event.target;
|
|
3710
3782
|
(_this$rejectPromise2 = _this.rejectPromise) === null || _this$rejectPromise2 === void 0 ? void 0 : _this$rejectPromise2.call(_this, error);
|
|
3711
3783
|
|
|
3712
|
-
_this.
|
|
3713
|
-
tags: ['connection'],
|
|
3784
|
+
_this._log("onclose() - WS connection reject with error ".concat(event.reason), {
|
|
3714
3785
|
event: event
|
|
3715
3786
|
});
|
|
3716
3787
|
} else {
|
|
@@ -3724,8 +3795,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3724
3795
|
_this.isConnecting = false;
|
|
3725
3796
|
(_this$rejectPromise3 = _this.rejectPromise) === null || _this$rejectPromise3 === void 0 ? void 0 : _this$rejectPromise3.call(_this, _this._errorFromWSEvent(event));
|
|
3726
3797
|
|
|
3727
|
-
_this.
|
|
3728
|
-
tags: ['connection'],
|
|
3798
|
+
_this._log("onclose() - WS connection closed. Calling reconnect ...", {
|
|
3729
3799
|
event: event
|
|
3730
3800
|
}); // reconnect if its an abnormal failure
|
|
3731
3801
|
|
|
@@ -3746,8 +3816,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3746
3816
|
_this.isConnecting = false;
|
|
3747
3817
|
(_this$rejectPromise4 = _this.rejectPromise) === null || _this$rejectPromise4 === void 0 ? void 0 : _this$rejectPromise4.call(_this, _this._errorFromWSEvent(event));
|
|
3748
3818
|
|
|
3749
|
-
_this.
|
|
3750
|
-
tags: ['connection'],
|
|
3819
|
+
_this._log("onerror() - WS connection resulted into error", {
|
|
3751
3820
|
event: event
|
|
3752
3821
|
});
|
|
3753
3822
|
|
|
@@ -3755,28 +3824,28 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3755
3824
|
});
|
|
3756
3825
|
|
|
3757
3826
|
_defineProperty(this, "_setHealth", function (healthy) {
|
|
3758
|
-
if (healthy
|
|
3759
|
-
|
|
3760
|
-
_this.isHealthy = true;
|
|
3827
|
+
if (healthy === _this.isHealthy) return;
|
|
3828
|
+
_this.isHealthy = healthy;
|
|
3761
3829
|
|
|
3762
|
-
|
|
3830
|
+
if (_this.isHealthy) {
|
|
3831
|
+
//@ts-expect-error
|
|
3832
|
+
_this.client.dispatchEvent({
|
|
3763
3833
|
type: 'connection.changed',
|
|
3764
|
-
online:
|
|
3834
|
+
online: _this.isHealthy
|
|
3765
3835
|
});
|
|
3766
|
-
}
|
|
3767
3836
|
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
}
|
|
3779
|
-
}
|
|
3837
|
+
return;
|
|
3838
|
+
} // we're offline, wait few seconds and fire and event if still offline
|
|
3839
|
+
|
|
3840
|
+
|
|
3841
|
+
setTimeout(function () {
|
|
3842
|
+
if (_this.isHealthy) return; //@ts-expect-error
|
|
3843
|
+
|
|
3844
|
+
_this.client.dispatchEvent({
|
|
3845
|
+
type: 'connection.changed',
|
|
3846
|
+
online: _this.isHealthy
|
|
3847
|
+
});
|
|
3848
|
+
}, 5000);
|
|
3780
3849
|
});
|
|
3781
3850
|
|
|
3782
3851
|
_defineProperty(this, "_errorFromWSEvent", function (event) {
|
|
@@ -3798,10 +3867,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3798
3867
|
} // Keeping this `warn` level log, to avoid cluttering of error logs from ws failures.
|
|
3799
3868
|
|
|
3800
3869
|
|
|
3801
|
-
_this.
|
|
3802
|
-
tags: ['connection'],
|
|
3870
|
+
_this._log("_errorFromWSEvent() - WS failed with code ".concat(code), {
|
|
3803
3871
|
event: event
|
|
3804
|
-
});
|
|
3872
|
+
}, 'warn');
|
|
3805
3873
|
|
|
3806
3874
|
var error = new Error("WS failed with code ".concat(code, " and reason - ").concat(message));
|
|
3807
3875
|
error.code = code;
|
|
@@ -3815,50 +3883,13 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3815
3883
|
return error;
|
|
3816
3884
|
});
|
|
3817
3885
|
|
|
3818
|
-
_defineProperty(this, "_listenForConnectionChanges", function () {
|
|
3819
|
-
var _window;
|
|
3820
|
-
|
|
3821
|
-
// (typeof window !== 'undefined') check is for environments where window is not defined, such as nextjs environment,
|
|
3822
|
-
// and thus (window === undefined) will result in ReferenceError.
|
|
3823
|
-
if (typeof window !== 'undefined' && (_window = window) !== null && _window !== void 0 && _window.addEventListener) {
|
|
3824
|
-
window.addEventListener('offline', _this.onlineStatusChanged);
|
|
3825
|
-
window.addEventListener('online', _this.onlineStatusChanged);
|
|
3826
|
-
}
|
|
3827
|
-
});
|
|
3828
|
-
|
|
3829
|
-
_defineProperty(this, "_removeConnectionListeners", function () {
|
|
3830
|
-
var _window2;
|
|
3831
|
-
|
|
3832
|
-
// (typeof window !== 'undefined') check is for environments where window is not defined, such as nextjs environment,
|
|
3833
|
-
// and thus (window === undefined) will result in ReferenceError.
|
|
3834
|
-
if (typeof window !== 'undefined' && (_window2 = window) !== null && _window2 !== void 0 && _window2.removeEventListener) {
|
|
3835
|
-
window.removeEventListener('offline', _this.onlineStatusChanged);
|
|
3836
|
-
window.removeEventListener('online', _this.onlineStatusChanged);
|
|
3837
|
-
}
|
|
3838
|
-
});
|
|
3839
|
-
|
|
3840
3886
|
_defineProperty(this, "_setupConnectionPromise", function () {
|
|
3841
|
-
var that = _this;
|
|
3842
3887
|
_this.isResolved = false;
|
|
3843
3888
|
/** a promise that is resolved once ws.open is called */
|
|
3844
3889
|
|
|
3845
3890
|
_this.connectionOpen = new Promise(function (resolve, reject) {
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
}).then(function (e) {
|
|
3849
|
-
if (e.data && typeof e.data === 'string') {
|
|
3850
|
-
var data = JSON.parse(e.data);
|
|
3851
|
-
|
|
3852
|
-
if (data && data.error != null) {
|
|
3853
|
-
throw new Error(JSON.stringify(data.error));
|
|
3854
|
-
}
|
|
3855
|
-
|
|
3856
|
-
return data;
|
|
3857
|
-
} else {
|
|
3858
|
-
return undefined;
|
|
3859
|
-
}
|
|
3860
|
-
}, function (error) {
|
|
3861
|
-
throw error;
|
|
3891
|
+
_this.resolvePromise = resolve;
|
|
3892
|
+
_this.rejectPromise = reject;
|
|
3862
3893
|
});
|
|
3863
3894
|
});
|
|
3864
3895
|
|
|
@@ -3872,7 +3903,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3872
3903
|
// send the healthcheck.., server replies with a health check event
|
|
3873
3904
|
var data = [{
|
|
3874
3905
|
type: 'health.check',
|
|
3875
|
-
client_id: _this.clientID
|
|
3906
|
+
client_id: _this.client.clientID
|
|
3876
3907
|
}]; // try to send on the connection
|
|
3877
3908
|
|
|
3878
3909
|
try {
|
|
@@ -3893,9 +3924,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3893
3924
|
var now = new Date();
|
|
3894
3925
|
|
|
3895
3926
|
if (_this.lastEvent && now.getTime() - _this.lastEvent.getTime() > _this.connectionCheckTimeout) {
|
|
3896
|
-
_this.
|
|
3897
|
-
tags: ['connection']
|
|
3898
|
-
});
|
|
3927
|
+
_this._log('scheduleConnectionCheck - going to reconnect');
|
|
3899
3928
|
|
|
3900
3929
|
_this._setHealth(false);
|
|
3901
3930
|
|
|
@@ -3904,15 +3933,8 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3904
3933
|
}, _this.connectionCheckTimeout);
|
|
3905
3934
|
});
|
|
3906
3935
|
|
|
3907
|
-
|
|
3908
|
-
this.
|
|
3909
|
-
this.userID = userID;
|
|
3910
|
-
this.user = user;
|
|
3911
|
-
this.authType = authType;
|
|
3912
|
-
this.userAgent = userAgent;
|
|
3913
|
-
this.apiKey = apiKey;
|
|
3914
|
-
this.tokenManager = tokenManager;
|
|
3915
|
-
this.device = device;
|
|
3936
|
+
/** StreamChat client */
|
|
3937
|
+
this.client = client;
|
|
3916
3938
|
/** consecutive failures influence the duration of the timeout */
|
|
3917
3939
|
|
|
3918
3940
|
this.consecutiveFailures = 0;
|
|
@@ -3922,18 +3944,15 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3922
3944
|
/** We only make 1 attempt to reconnect at the same time.. */
|
|
3923
3945
|
|
|
3924
3946
|
this.isConnecting = false;
|
|
3947
|
+
/** To avoid reconnect if client is disconnected */
|
|
3948
|
+
|
|
3949
|
+
this.isDisconnected = false;
|
|
3925
3950
|
/** Boolean that indicates if the connection promise is resolved */
|
|
3926
3951
|
|
|
3927
3952
|
this.isResolved = false;
|
|
3928
3953
|
/** Boolean that indicates if we have a working connection to the server */
|
|
3929
3954
|
|
|
3930
3955
|
this.isHealthy = false;
|
|
3931
|
-
/** Callback when the connection fails and recovers */
|
|
3932
|
-
|
|
3933
|
-
this.recoverCallback = recoverCallback;
|
|
3934
|
-
this.messageCallback = messageCallback;
|
|
3935
|
-
this.eventCallback = eventCallback;
|
|
3936
|
-
this.logger = logger;
|
|
3937
3956
|
/** Incremented when a new WS connection is made */
|
|
3938
3957
|
|
|
3939
3958
|
this.wsID = 1;
|
|
@@ -3944,74 +3963,82 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3944
3963
|
|
|
3945
3964
|
this.pingInterval = 25 * 1000;
|
|
3946
3965
|
this.connectionCheckTimeout = this.pingInterval + 10 * 1000;
|
|
3947
|
-
|
|
3948
|
-
this._listenForConnectionChanges();
|
|
3949
|
-
|
|
3950
|
-
this.postInsights = postInsights;
|
|
3951
|
-
this.insightMetrics = insightMetrics;
|
|
3966
|
+
addConnectionEventListeners(this.onlineStatusChanged);
|
|
3952
3967
|
}
|
|
3953
|
-
/**
|
|
3954
|
-
* connect - Connect to the WS URL
|
|
3955
|
-
*
|
|
3956
|
-
* @return {ConnectAPIResponse<ChannelType, CommandType, UserType>} Promise that completes once the first health check message is received
|
|
3957
|
-
*/
|
|
3958
|
-
|
|
3959
3968
|
|
|
3960
3969
|
_createClass(StableWSConnection, [{
|
|
3970
|
+
key: "_log",
|
|
3971
|
+
value: function _log(msg) {
|
|
3972
|
+
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
3973
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
3974
|
+
this.client.logger(level, 'connection:' + msg, _objectSpread$3({
|
|
3975
|
+
tags: ['connection']
|
|
3976
|
+
}, extra));
|
|
3977
|
+
}
|
|
3978
|
+
/**
|
|
3979
|
+
* connect - Connect to the WS URL
|
|
3980
|
+
* the default 15s timeout allows between 2~3 tries
|
|
3981
|
+
* @return {ConnectAPIResponse<ChannelType, CommandType, UserType>} Promise that completes once the first health check message is received
|
|
3982
|
+
*/
|
|
3983
|
+
|
|
3984
|
+
}, {
|
|
3961
3985
|
key: "connect",
|
|
3962
3986
|
value: function () {
|
|
3963
3987
|
var _connect2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
3964
|
-
var
|
|
3988
|
+
var timeout,
|
|
3989
|
+
healthCheck,
|
|
3990
|
+
_args = arguments;
|
|
3965
3991
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
3966
3992
|
while (1) {
|
|
3967
3993
|
switch (_context.prev = _context.next) {
|
|
3968
3994
|
case 0:
|
|
3995
|
+
timeout = _args.length > 0 && _args[0] !== undefined ? _args[0] : 15000;
|
|
3996
|
+
|
|
3969
3997
|
if (!this.isConnecting) {
|
|
3970
|
-
_context.next =
|
|
3998
|
+
_context.next = 3;
|
|
3971
3999
|
break;
|
|
3972
4000
|
}
|
|
3973
4001
|
|
|
3974
4002
|
throw Error("You've called connect twice, can only attempt 1 connection at the time");
|
|
3975
4003
|
|
|
3976
|
-
case
|
|
3977
|
-
|
|
3978
|
-
_context.
|
|
4004
|
+
case 3:
|
|
4005
|
+
this.isDisconnected = false;
|
|
4006
|
+
_context.prev = 4;
|
|
4007
|
+
_context.next = 7;
|
|
3979
4008
|
return this._connect();
|
|
3980
4009
|
|
|
3981
|
-
case
|
|
4010
|
+
case 7:
|
|
3982
4011
|
healthCheck = _context.sent;
|
|
3983
4012
|
this.consecutiveFailures = 0;
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
_context.next =
|
|
4013
|
+
|
|
4014
|
+
this._log("connect() - Established ws connection with healthcheck: ".concat(healthCheck));
|
|
4015
|
+
|
|
4016
|
+
_context.next = 23;
|
|
3988
4017
|
break;
|
|
3989
4018
|
|
|
3990
|
-
case
|
|
3991
|
-
_context.prev =
|
|
3992
|
-
_context.t0 = _context["catch"](
|
|
4019
|
+
case 12:
|
|
4020
|
+
_context.prev = 12;
|
|
4021
|
+
_context.t0 = _context["catch"](4);
|
|
3993
4022
|
this.isHealthy = false;
|
|
3994
4023
|
this.consecutiveFailures += 1;
|
|
3995
4024
|
|
|
3996
|
-
if (!(_context.t0.code === chatCodes.TOKEN_EXPIRED && !this.tokenManager.isStatic())) {
|
|
3997
|
-
_context.next =
|
|
4025
|
+
if (!(_context.t0.code === chatCodes.TOKEN_EXPIRED && !this.client.tokenManager.isStatic())) {
|
|
4026
|
+
_context.next = 21;
|
|
3998
4027
|
break;
|
|
3999
4028
|
}
|
|
4000
4029
|
|
|
4001
|
-
this.
|
|
4002
|
-
tags: ['connection']
|
|
4003
|
-
});
|
|
4030
|
+
this._log('connect() - WS failure due to expired token, so going to try to reload token and reconnect');
|
|
4004
4031
|
|
|
4005
4032
|
this._reconnect({
|
|
4006
4033
|
refreshToken: true
|
|
4007
4034
|
});
|
|
4008
4035
|
|
|
4009
|
-
_context.next =
|
|
4036
|
+
_context.next = 23;
|
|
4010
4037
|
break;
|
|
4011
4038
|
|
|
4012
|
-
case
|
|
4039
|
+
case 21:
|
|
4013
4040
|
if (_context.t0.isWSFailure) {
|
|
4014
|
-
_context.next =
|
|
4041
|
+
_context.next = 23;
|
|
4015
4042
|
break;
|
|
4016
4043
|
}
|
|
4017
4044
|
|
|
@@ -4022,19 +4049,19 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4022
4049
|
isWSFailure: _context.t0.isWSFailure
|
|
4023
4050
|
}));
|
|
4024
4051
|
|
|
4025
|
-
case 21:
|
|
4026
|
-
_context.next = 23;
|
|
4027
|
-
return this._waitForHealthy();
|
|
4028
|
-
|
|
4029
4052
|
case 23:
|
|
4053
|
+
_context.next = 25;
|
|
4054
|
+
return this._waitForHealthy(timeout);
|
|
4055
|
+
|
|
4056
|
+
case 25:
|
|
4030
4057
|
return _context.abrupt("return", _context.sent);
|
|
4031
4058
|
|
|
4032
|
-
case
|
|
4059
|
+
case 26:
|
|
4033
4060
|
case "end":
|
|
4034
4061
|
return _context.stop();
|
|
4035
4062
|
}
|
|
4036
4063
|
}
|
|
4037
|
-
}, _callee, this, [[
|
|
4064
|
+
}, _callee, this, [[4, 12]]);
|
|
4038
4065
|
}));
|
|
4039
4066
|
|
|
4040
4067
|
function connect() {
|
|
@@ -4125,6 +4152,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4125
4152
|
return sleep(timeout);
|
|
4126
4153
|
|
|
4127
4154
|
case 2:
|
|
4155
|
+
_this2.isConnecting = false;
|
|
4128
4156
|
throw new Error(JSON.stringify({
|
|
4129
4157
|
code: '',
|
|
4130
4158
|
StatusCode: '',
|
|
@@ -4132,7 +4160,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4132
4160
|
isWSFailure: true
|
|
4133
4161
|
}));
|
|
4134
4162
|
|
|
4135
|
-
case
|
|
4163
|
+
case 4:
|
|
4136
4164
|
case "end":
|
|
4137
4165
|
return _context3.stop();
|
|
4138
4166
|
}
|
|
@@ -4156,7 +4184,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4156
4184
|
}()
|
|
4157
4185
|
/**
|
|
4158
4186
|
* Builds and returns the url for websocket.
|
|
4159
|
-
* @
|
|
4187
|
+
* @private
|
|
4160
4188
|
* @returns url string
|
|
4161
4189
|
*/
|
|
4162
4190
|
|
|
@@ -4170,10 +4198,11 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4170
4198
|
function disconnect(timeout) {
|
|
4171
4199
|
var _this3 = this;
|
|
4172
4200
|
|
|
4173
|
-
this.
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
this.
|
|
4201
|
+
this._log("disconnect() - Closing the websocket connection for wsID ".concat(this.wsID));
|
|
4202
|
+
|
|
4203
|
+
this.wsID += 1;
|
|
4204
|
+
this.isConnecting = false;
|
|
4205
|
+
this.isDisconnected = true; // start by removing all the listeners
|
|
4177
4206
|
|
|
4178
4207
|
if (this.healthCheckTimeoutRef) {
|
|
4179
4208
|
clearInterval(this.healthCheckTimeoutRef);
|
|
@@ -4183,8 +4212,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4183
4212
|
clearInterval(this.connectionCheckTimeoutRef);
|
|
4184
4213
|
}
|
|
4185
4214
|
|
|
4186
|
-
this.
|
|
4187
|
-
|
|
4215
|
+
removeConnectionEventListeners(this.onlineStatusChanged);
|
|
4188
4216
|
this.isHealthy = false; // remove ws handlers...
|
|
4189
4217
|
|
|
4190
4218
|
if (this.ws && this.ws.removeAllListeners) {
|
|
@@ -4200,8 +4228,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4200
4228
|
if (ws && ws.close && ws.readyState === ws.OPEN) {
|
|
4201
4229
|
isClosedPromise = new Promise(function (resolve) {
|
|
4202
4230
|
var onclose = function onclose(event) {
|
|
4203
|
-
_this3.
|
|
4204
|
-
tags: ['connection'],
|
|
4231
|
+
_this3._log("disconnect() - resolving isClosedPromise ".concat(event ? 'with' : 'without', " close frame"), {
|
|
4205
4232
|
event: event
|
|
4206
4233
|
});
|
|
4207
4234
|
|
|
@@ -4213,14 +4240,13 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4213
4240
|
|
|
4214
4241
|
setTimeout(onclose, timeout != null ? timeout : 1000);
|
|
4215
4242
|
});
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4243
|
+
|
|
4244
|
+
this._log("disconnect() - Manually closed connection by calling client.disconnect()");
|
|
4245
|
+
|
|
4219
4246
|
ws.close(chatCodes.WS_CLOSED_SUCCESS, 'Manually closed connection by calling client.disconnect()');
|
|
4220
4247
|
} else {
|
|
4221
|
-
this.
|
|
4222
|
-
|
|
4223
|
-
});
|
|
4248
|
+
this._log("disconnect() - ws connection doesn't exist or it is already closed.");
|
|
4249
|
+
|
|
4224
4250
|
isClosedPromise = Promise.resolve();
|
|
4225
4251
|
}
|
|
4226
4252
|
|
|
@@ -4237,13 +4263,12 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4237
4263
|
key: "_connect",
|
|
4238
4264
|
value: function () {
|
|
4239
4265
|
var _connect3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
4240
|
-
var wsURL, response,
|
|
4241
|
-
|
|
4266
|
+
var wsURL, response, insights;
|
|
4242
4267
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
4243
4268
|
while (1) {
|
|
4244
4269
|
switch (_context5.prev = _context5.next) {
|
|
4245
4270
|
case 0:
|
|
4246
|
-
if (!this.isConnecting) {
|
|
4271
|
+
if (!(this.isConnecting || this.isDisconnected)) {
|
|
4247
4272
|
_context5.next = 2;
|
|
4248
4273
|
break;
|
|
4249
4274
|
}
|
|
@@ -4254,15 +4279,15 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4254
4279
|
// simply ignore _connect if it's currently trying to connect
|
|
4255
4280
|
this.isConnecting = true;
|
|
4256
4281
|
this.requestID = randomId();
|
|
4257
|
-
this.insightMetrics.connectionStartTimestamp = new Date().getTime();
|
|
4282
|
+
this.client.insightMetrics.connectionStartTimestamp = new Date().getTime();
|
|
4258
4283
|
_context5.prev = 5;
|
|
4259
4284
|
_context5.next = 8;
|
|
4260
|
-
return this.tokenManager.tokenReady();
|
|
4285
|
+
return this.client.tokenManager.tokenReady();
|
|
4261
4286
|
|
|
4262
4287
|
case 8:
|
|
4263
4288
|
this._setupConnectionPromise();
|
|
4264
4289
|
|
|
4265
|
-
wsURL = this._buildUrl(
|
|
4290
|
+
wsURL = this._buildUrl();
|
|
4266
4291
|
this.ws = new WebSocket(wsURL);
|
|
4267
4292
|
this.ws.onopen = this.onopen.bind(this, this.wsID);
|
|
4268
4293
|
this.ws.onclose = this.onclose.bind(this, this.wsID);
|
|
@@ -4282,9 +4307,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4282
4307
|
|
|
4283
4308
|
this.connectionID = response.connection_id;
|
|
4284
4309
|
|
|
4285
|
-
if (this.insightMetrics.wsConsecutiveFailures > 0 && this.
|
|
4286
|
-
|
|
4287
|
-
this.insightMetrics.wsConsecutiveFailures = 0;
|
|
4310
|
+
if (this.client.insightMetrics.wsConsecutiveFailures > 0 && this.client.options.enableInsights) {
|
|
4311
|
+
postInsights('ws_success_after_failure', buildWsSuccessAfterFailureInsight(this));
|
|
4312
|
+
this.client.insightMetrics.wsConsecutiveFailures = 0;
|
|
4288
4313
|
}
|
|
4289
4314
|
|
|
4290
4315
|
return _context5.abrupt("return", response);
|
|
@@ -4298,12 +4323,11 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4298
4323
|
_context5.t0 = _context5["catch"](5);
|
|
4299
4324
|
this.isConnecting = false;
|
|
4300
4325
|
|
|
4301
|
-
if (this.
|
|
4302
|
-
this.insightMetrics.wsConsecutiveFailures++;
|
|
4303
|
-
this.insightMetrics.wsTotalFailures++;
|
|
4304
|
-
|
|
4326
|
+
if (this.client.options.enableInsights) {
|
|
4327
|
+
this.client.insightMetrics.wsConsecutiveFailures++;
|
|
4328
|
+
this.client.insightMetrics.wsTotalFailures++;
|
|
4305
4329
|
insights = buildWsFatalInsight(this, convertErrorToJson(_context5.t0));
|
|
4306
|
-
|
|
4330
|
+
postInsights === null || postInsights === void 0 ? void 0 : postInsights('ws_fatal', insights);
|
|
4307
4331
|
}
|
|
4308
4332
|
|
|
4309
4333
|
throw _context5.t0;
|
|
@@ -4337,26 +4361,23 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4337
4361
|
var _reconnect2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
4338
4362
|
var options,
|
|
4339
4363
|
interval,
|
|
4340
|
-
_open,
|
|
4341
4364
|
_args6 = arguments;
|
|
4342
|
-
|
|
4343
4365
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
4344
4366
|
while (1) {
|
|
4345
4367
|
switch (_context6.prev = _context6.next) {
|
|
4346
4368
|
case 0:
|
|
4347
4369
|
options = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4370
|
+
|
|
4371
|
+
this._log('_reconnect() - Initiating the reconnect'); // only allow 1 connection at the time
|
|
4372
|
+
|
|
4351
4373
|
|
|
4352
4374
|
if (!(this.isConnecting || this.isHealthy)) {
|
|
4353
4375
|
_context6.next = 5;
|
|
4354
4376
|
break;
|
|
4355
4377
|
}
|
|
4356
4378
|
|
|
4357
|
-
this.
|
|
4358
|
-
|
|
4359
|
-
});
|
|
4379
|
+
this._log('_reconnect() - Abort (1) since already connecting or healthy');
|
|
4380
|
+
|
|
4360
4381
|
return _context6.abrupt("return");
|
|
4361
4382
|
|
|
4362
4383
|
case 5:
|
|
@@ -4378,95 +4399,86 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4378
4399
|
break;
|
|
4379
4400
|
}
|
|
4380
4401
|
|
|
4381
|
-
this.
|
|
4382
|
-
|
|
4383
|
-
});
|
|
4402
|
+
this._log('_reconnect() - Abort (2) since already connecting or healthy');
|
|
4403
|
+
|
|
4384
4404
|
return _context6.abrupt("return");
|
|
4385
4405
|
|
|
4386
4406
|
case 12:
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
}
|
|
4407
|
+
if (!this.isDisconnected) {
|
|
4408
|
+
_context6.next = 15;
|
|
4409
|
+
break;
|
|
4410
|
+
}
|
|
4411
|
+
|
|
4412
|
+
this._log('_reconnect() - Abort (3) since disconnect() is called');
|
|
4413
|
+
|
|
4414
|
+
return _context6.abrupt("return");
|
|
4415
|
+
|
|
4416
|
+
case 15:
|
|
4417
|
+
this._log('_reconnect() - Destroying current WS connection'); // cleanup the old connection
|
|
4418
|
+
|
|
4391
4419
|
|
|
4392
4420
|
this._destroyCurrentWSConnection();
|
|
4393
4421
|
|
|
4394
4422
|
if (!options.refreshToken) {
|
|
4395
|
-
_context6.next =
|
|
4423
|
+
_context6.next = 20;
|
|
4396
4424
|
break;
|
|
4397
4425
|
}
|
|
4398
4426
|
|
|
4399
|
-
_context6.next = 17;
|
|
4400
|
-
return this.tokenManager.loadToken();
|
|
4401
|
-
|
|
4402
|
-
case 17:
|
|
4403
|
-
_context6.prev = 17;
|
|
4404
4427
|
_context6.next = 20;
|
|
4405
|
-
return this.
|
|
4428
|
+
return this.client.tokenManager.loadToken();
|
|
4406
4429
|
|
|
4407
4430
|
case 20:
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
_context6.next = 26;
|
|
4412
|
-
break;
|
|
4413
|
-
}
|
|
4431
|
+
_context6.prev = 20;
|
|
4432
|
+
_context6.next = 23;
|
|
4433
|
+
return this._connect();
|
|
4414
4434
|
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
});
|
|
4418
|
-
_context6.next = 25;
|
|
4419
|
-
return this.recoverCallback(_open);
|
|
4435
|
+
case 23:
|
|
4436
|
+
this._log('_reconnect() - Waiting for recoverCallBack');
|
|
4420
4437
|
|
|
4421
|
-
|
|
4422
|
-
this.
|
|
4423
|
-
tags: ['connection']
|
|
4424
|
-
});
|
|
4438
|
+
_context6.next = 26;
|
|
4439
|
+
return this.client.recoverState();
|
|
4425
4440
|
|
|
4426
4441
|
case 26:
|
|
4442
|
+
this._log('_reconnect() - Finished recoverCallBack');
|
|
4443
|
+
|
|
4427
4444
|
this.consecutiveFailures = 0;
|
|
4428
|
-
_context6.next =
|
|
4445
|
+
_context6.next = 38;
|
|
4429
4446
|
break;
|
|
4430
4447
|
|
|
4431
|
-
case
|
|
4432
|
-
_context6.prev =
|
|
4433
|
-
_context6.t0 = _context6["catch"](
|
|
4448
|
+
case 30:
|
|
4449
|
+
_context6.prev = 30;
|
|
4450
|
+
_context6.t0 = _context6["catch"](20);
|
|
4434
4451
|
this.isHealthy = false;
|
|
4435
4452
|
this.consecutiveFailures += 1;
|
|
4436
4453
|
|
|
4437
|
-
if (!(_context6.t0.code === chatCodes.TOKEN_EXPIRED && !this.tokenManager.isStatic())) {
|
|
4438
|
-
_context6.next =
|
|
4454
|
+
if (!(_context6.t0.code === chatCodes.TOKEN_EXPIRED && !this.client.tokenManager.isStatic())) {
|
|
4455
|
+
_context6.next = 37;
|
|
4439
4456
|
break;
|
|
4440
4457
|
}
|
|
4441
4458
|
|
|
4442
|
-
this.
|
|
4443
|
-
|
|
4444
|
-
});
|
|
4459
|
+
this._log('_reconnect() - WS failure due to expired token, so going to try to reload token and reconnect');
|
|
4460
|
+
|
|
4445
4461
|
return _context6.abrupt("return", this._reconnect({
|
|
4446
4462
|
refreshToken: true
|
|
4447
4463
|
}));
|
|
4448
4464
|
|
|
4449
|
-
case
|
|
4465
|
+
case 37:
|
|
4450
4466
|
// reconnect on WS failures, don't reconnect if there is a code bug
|
|
4451
4467
|
if (_context6.t0.isWSFailure) {
|
|
4452
|
-
this.
|
|
4453
|
-
tags: ['connection']
|
|
4454
|
-
});
|
|
4468
|
+
this._log('_reconnect() - WS failure, so going to try to reconnect');
|
|
4455
4469
|
|
|
4456
4470
|
this._reconnect();
|
|
4457
4471
|
}
|
|
4458
4472
|
|
|
4459
|
-
case 37:
|
|
4460
|
-
this.logger('info', 'connection:_reconnect() - == END ==', {
|
|
4461
|
-
tags: ['connection']
|
|
4462
|
-
});
|
|
4463
|
-
|
|
4464
4473
|
case 38:
|
|
4474
|
+
this._log('_reconnect() - == END ==');
|
|
4475
|
+
|
|
4476
|
+
case 39:
|
|
4465
4477
|
case "end":
|
|
4466
4478
|
return _context6.stop();
|
|
4467
4479
|
}
|
|
4468
4480
|
}
|
|
4469
|
-
}, _callee6, this, [[
|
|
4481
|
+
}, _callee6, this, [[20, 30]]);
|
|
4470
4482
|
}));
|
|
4471
4483
|
|
|
4472
4484
|
function _reconnect() {
|
|
@@ -4495,13 +4507,10 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4495
4507
|
this.wsID += 1;
|
|
4496
4508
|
|
|
4497
4509
|
try {
|
|
4498
|
-
|
|
4499
|
-
this.ws.removeAllListeners();
|
|
4500
|
-
}
|
|
4510
|
+
var _this$ws2, _this$ws3;
|
|
4501
4511
|
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
}
|
|
4512
|
+
this === null || this === void 0 ? void 0 : (_this$ws2 = this.ws) === null || _this$ws2 === void 0 ? void 0 : _this$ws2.removeAllListeners();
|
|
4513
|
+
this === null || this === void 0 ? void 0 : (_this$ws3 = this.ws) === null || _this$ws3 === void 0 ? void 0 : _this$ws3.close();
|
|
4505
4514
|
} catch (e) {// we don't care
|
|
4506
4515
|
}
|
|
4507
4516
|
}
|
|
@@ -4518,9 +4527,9 @@ var jwt = null;
|
|
|
4518
4527
|
|
|
4519
4528
|
var crypto$1 = null;
|
|
4520
4529
|
|
|
4521
|
-
function ownKeys$
|
|
4530
|
+
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; }
|
|
4522
4531
|
|
|
4523
|
-
function _objectSpread$
|
|
4532
|
+
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; }
|
|
4524
4533
|
|
|
4525
4534
|
/**
|
|
4526
4535
|
* Creates the JWT token that can be used for a UserSession
|
|
@@ -4529,7 +4538,7 @@ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) {
|
|
|
4529
4538
|
* @private
|
|
4530
4539
|
* @param {Secret} apiSecret - API Secret key
|
|
4531
4540
|
* @param {string} userId - The user_id key in the JWT payload
|
|
4532
|
-
* @param {
|
|
4541
|
+
* @param {UR} [extraData] - Extra that should be part of the JWT token
|
|
4533
4542
|
* @param {SignOptions} [jwtOptions] - Options that can be past to jwt.sign
|
|
4534
4543
|
* @return {string} JWT Token
|
|
4535
4544
|
*/
|
|
@@ -4541,7 +4550,7 @@ function JWTUserToken(apiSecret, userId) {
|
|
|
4541
4550
|
throw new TypeError('userId should be a string');
|
|
4542
4551
|
}
|
|
4543
4552
|
|
|
4544
|
-
var payload = _objectSpread$
|
|
4553
|
+
var payload = _objectSpread$2({
|
|
4545
4554
|
user_id: userId
|
|
4546
4555
|
}, extraData); // make sure we return a clear error when jwt is shimmed (ie. browser build)
|
|
4547
4556
|
|
|
@@ -4722,76 +4731,576 @@ function TokenManager(secret) {
|
|
|
4722
4731
|
break;
|
|
4723
4732
|
}
|
|
4724
4733
|
|
|
4725
|
-
return _context2.abrupt("return", resolve(_this.token));
|
|
4734
|
+
return _context2.abrupt("return", resolve(_this.token));
|
|
4735
|
+
|
|
4736
|
+
case 2:
|
|
4737
|
+
if (!(_this.tokenProvider && typeof _this.tokenProvider !== 'string')) {
|
|
4738
|
+
_context2.next = 7;
|
|
4739
|
+
break;
|
|
4740
|
+
}
|
|
4741
|
+
|
|
4742
|
+
_context2.next = 5;
|
|
4743
|
+
return _this.tokenProvider();
|
|
4744
|
+
|
|
4745
|
+
case 5:
|
|
4746
|
+
_this.token = _context2.sent;
|
|
4747
|
+
resolve(_this.token);
|
|
4748
|
+
|
|
4749
|
+
case 7:
|
|
4750
|
+
case "end":
|
|
4751
|
+
return _context2.stop();
|
|
4752
|
+
}
|
|
4753
|
+
}
|
|
4754
|
+
}, _callee2);
|
|
4755
|
+
}));
|
|
4756
|
+
|
|
4757
|
+
return function (_x3) {
|
|
4758
|
+
return _ref2.apply(this, arguments);
|
|
4759
|
+
};
|
|
4760
|
+
}());
|
|
4761
|
+
return _this.loadTokenPromise;
|
|
4762
|
+
});
|
|
4763
|
+
|
|
4764
|
+
_defineProperty(this, "getToken", function () {
|
|
4765
|
+
if (_this.token) {
|
|
4766
|
+
return _this.token;
|
|
4767
|
+
}
|
|
4768
|
+
|
|
4769
|
+
if (_this.user && _this.user.anon && !_this.token) {
|
|
4770
|
+
return _this.token;
|
|
4771
|
+
}
|
|
4772
|
+
|
|
4773
|
+
if (_this.secret) {
|
|
4774
|
+
return JWTServerToken(_this.secret);
|
|
4775
|
+
}
|
|
4776
|
+
|
|
4777
|
+
throw new Error("Both secret and user tokens are not set. Either client.connectUser wasn't called or client.disconnect was called");
|
|
4778
|
+
});
|
|
4779
|
+
|
|
4780
|
+
_defineProperty(this, "isStatic", function () {
|
|
4781
|
+
return _this.type === 'static';
|
|
4782
|
+
});
|
|
4783
|
+
|
|
4784
|
+
this.loadTokenPromise = null;
|
|
4785
|
+
|
|
4786
|
+
if (secret) {
|
|
4787
|
+
this.secret = secret;
|
|
4788
|
+
}
|
|
4789
|
+
|
|
4790
|
+
this.type = 'static';
|
|
4791
|
+
|
|
4792
|
+
if (this.secret) {
|
|
4793
|
+
this.token = JWTServerToken(this.secret);
|
|
4794
|
+
}
|
|
4795
|
+
}
|
|
4796
|
+
/**
|
|
4797
|
+
* Set the static string token or token provider.
|
|
4798
|
+
* Token provider should return a token string or a promise which resolves to string token.
|
|
4799
|
+
*
|
|
4800
|
+
* @param {TokenOrProvider} tokenOrProvider
|
|
4801
|
+
* @param {UserResponse<UserType>} user
|
|
4802
|
+
*/
|
|
4803
|
+
;
|
|
4804
|
+
|
|
4805
|
+
var APIErrorCodes = {
|
|
4806
|
+
'-1': {
|
|
4807
|
+
name: 'InternalSystemError',
|
|
4808
|
+
retryable: true
|
|
4809
|
+
},
|
|
4810
|
+
'2': {
|
|
4811
|
+
name: 'AccessKeyError',
|
|
4812
|
+
retryable: false
|
|
4813
|
+
},
|
|
4814
|
+
'3': {
|
|
4815
|
+
name: 'AuthenticationFailedError',
|
|
4816
|
+
retryable: true
|
|
4817
|
+
},
|
|
4818
|
+
'4': {
|
|
4819
|
+
name: 'InputError',
|
|
4820
|
+
retryable: false
|
|
4821
|
+
},
|
|
4822
|
+
'6': {
|
|
4823
|
+
name: 'DuplicateUsernameError',
|
|
4824
|
+
retryable: false
|
|
4825
|
+
},
|
|
4826
|
+
'9': {
|
|
4827
|
+
name: 'RateLimitError',
|
|
4828
|
+
retryable: true
|
|
4829
|
+
},
|
|
4830
|
+
'16': {
|
|
4831
|
+
name: 'DoesNotExistError',
|
|
4832
|
+
retryable: false
|
|
4833
|
+
},
|
|
4834
|
+
'17': {
|
|
4835
|
+
name: 'NotAllowedError',
|
|
4836
|
+
retryable: false
|
|
4837
|
+
},
|
|
4838
|
+
'18': {
|
|
4839
|
+
name: 'EventNotSupportedError',
|
|
4840
|
+
retryable: false
|
|
4841
|
+
},
|
|
4842
|
+
'19': {
|
|
4843
|
+
name: 'ChannelFeatureNotSupportedError',
|
|
4844
|
+
retryable: false
|
|
4845
|
+
},
|
|
4846
|
+
'20': {
|
|
4847
|
+
name: 'MessageTooLongError',
|
|
4848
|
+
retryable: false
|
|
4849
|
+
},
|
|
4850
|
+
'21': {
|
|
4851
|
+
name: 'MultipleNestingLevelError',
|
|
4852
|
+
retryable: false
|
|
4853
|
+
},
|
|
4854
|
+
'22': {
|
|
4855
|
+
name: 'PayloadTooBigError',
|
|
4856
|
+
retryable: false
|
|
4857
|
+
},
|
|
4858
|
+
'23': {
|
|
4859
|
+
name: 'RequestTimeoutError',
|
|
4860
|
+
retryable: true
|
|
4861
|
+
},
|
|
4862
|
+
'24': {
|
|
4863
|
+
name: 'MaxHeaderSizeExceededError',
|
|
4864
|
+
retryable: false
|
|
4865
|
+
},
|
|
4866
|
+
'40': {
|
|
4867
|
+
name: 'AuthErrorTokenExpired',
|
|
4868
|
+
retryable: false
|
|
4869
|
+
},
|
|
4870
|
+
'41': {
|
|
4871
|
+
name: 'AuthErrorTokenNotValidYet',
|
|
4872
|
+
retryable: false
|
|
4873
|
+
},
|
|
4874
|
+
'42': {
|
|
4875
|
+
name: 'AuthErrorTokenUsedBeforeIssuedAt',
|
|
4876
|
+
retryable: false
|
|
4877
|
+
},
|
|
4878
|
+
'43': {
|
|
4879
|
+
name: 'AuthErrorTokenSignatureInvalid',
|
|
4880
|
+
retryable: false
|
|
4881
|
+
},
|
|
4882
|
+
'44': {
|
|
4883
|
+
name: 'CustomCommandEndpointMissingError',
|
|
4884
|
+
retryable: false
|
|
4885
|
+
},
|
|
4886
|
+
'45': {
|
|
4887
|
+
name: 'CustomCommandEndpointCallError',
|
|
4888
|
+
retryable: true
|
|
4889
|
+
},
|
|
4890
|
+
'46': {
|
|
4891
|
+
name: 'ConnectionIDNotFoundError',
|
|
4892
|
+
retryable: false
|
|
4893
|
+
},
|
|
4894
|
+
'60': {
|
|
4895
|
+
name: 'CoolDownError',
|
|
4896
|
+
retryable: true
|
|
4897
|
+
},
|
|
4898
|
+
'69': {
|
|
4899
|
+
name: 'ErrWrongRegion',
|
|
4900
|
+
retryable: false
|
|
4901
|
+
},
|
|
4902
|
+
'70': {
|
|
4903
|
+
name: 'ErrQueryChannelPermissions',
|
|
4904
|
+
retryable: false
|
|
4905
|
+
},
|
|
4906
|
+
'71': {
|
|
4907
|
+
name: 'ErrTooManyConnections',
|
|
4908
|
+
retryable: true
|
|
4909
|
+
},
|
|
4910
|
+
'99': {
|
|
4911
|
+
name: 'AppSuspendedError',
|
|
4912
|
+
retryable: false
|
|
4913
|
+
}
|
|
4914
|
+
};
|
|
4915
|
+
function isAPIError(error) {
|
|
4916
|
+
return error.code !== undefined;
|
|
4917
|
+
}
|
|
4918
|
+
function isErrorRetryable(error) {
|
|
4919
|
+
if (!error.code) return false;
|
|
4920
|
+
var err = APIErrorCodes["".concat(error.code)];
|
|
4921
|
+
if (!err) return false;
|
|
4922
|
+
return err.retryable;
|
|
4923
|
+
}
|
|
4924
|
+
function isConnectionIDError(error) {
|
|
4925
|
+
return error.code === 46; // ConnectionIDNotFoundError
|
|
4926
|
+
}
|
|
4927
|
+
function isWSFailure(err) {
|
|
4928
|
+
if (typeof err.isWSFailure === 'boolean') {
|
|
4929
|
+
return err.isWSFailure;
|
|
4930
|
+
}
|
|
4931
|
+
|
|
4932
|
+
try {
|
|
4933
|
+
return JSON.parse(err.message).isWSFailure;
|
|
4934
|
+
} catch (_) {
|
|
4935
|
+
return false;
|
|
4936
|
+
}
|
|
4937
|
+
}
|
|
4938
|
+
|
|
4939
|
+
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; }
|
|
4940
|
+
|
|
4941
|
+
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; }
|
|
4942
|
+
var ConnectionState;
|
|
4943
|
+
|
|
4944
|
+
(function (ConnectionState) {
|
|
4945
|
+
ConnectionState["Closed"] = "CLOSED";
|
|
4946
|
+
ConnectionState["Connected"] = "CONNECTED";
|
|
4947
|
+
ConnectionState["Connecting"] = "CONNECTING";
|
|
4948
|
+
ConnectionState["Disconnected"] = "DISCONNECTED";
|
|
4949
|
+
ConnectionState["Init"] = "INIT";
|
|
4950
|
+
})(ConnectionState || (ConnectionState = {}));
|
|
4951
|
+
|
|
4952
|
+
var WSConnectionFallback = /*#__PURE__*/function () {
|
|
4953
|
+
function WSConnectionFallback(_ref) {
|
|
4954
|
+
var _this = this;
|
|
4955
|
+
|
|
4956
|
+
var client = _ref.client;
|
|
4957
|
+
|
|
4958
|
+
_classCallCheck(this, WSConnectionFallback);
|
|
4959
|
+
|
|
4960
|
+
_defineProperty(this, "client", void 0);
|
|
4961
|
+
|
|
4962
|
+
_defineProperty(this, "state", void 0);
|
|
4963
|
+
|
|
4964
|
+
_defineProperty(this, "consecutiveFailures", void 0);
|
|
4965
|
+
|
|
4966
|
+
_defineProperty(this, "connectionID", void 0);
|
|
4967
|
+
|
|
4968
|
+
_defineProperty(this, "cancelToken", void 0);
|
|
4969
|
+
|
|
4970
|
+
_defineProperty(this, "_onlineStatusChanged", function (event) {
|
|
4971
|
+
_this._log("_onlineStatusChanged() - ".concat(event.type));
|
|
4972
|
+
|
|
4973
|
+
if (event.type === 'offline') {
|
|
4974
|
+
var _this$cancelToken;
|
|
4975
|
+
|
|
4976
|
+
_this._setState(ConnectionState.Closed);
|
|
4977
|
+
|
|
4978
|
+
(_this$cancelToken = _this.cancelToken) === null || _this$cancelToken === void 0 ? void 0 : _this$cancelToken.cancel('disconnect() is called');
|
|
4979
|
+
_this.cancelToken = undefined;
|
|
4980
|
+
return;
|
|
4981
|
+
}
|
|
4982
|
+
|
|
4983
|
+
if (event.type === 'online' && _this.state === ConnectionState.Closed) {
|
|
4984
|
+
_this.connect(true);
|
|
4985
|
+
}
|
|
4986
|
+
});
|
|
4987
|
+
|
|
4988
|
+
_defineProperty(this, "_req", /*#__PURE__*/function () {
|
|
4989
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params, config, retry) {
|
|
4990
|
+
var _this$cancelToken2, res;
|
|
4991
|
+
|
|
4992
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
4993
|
+
while (1) {
|
|
4994
|
+
switch (_context.prev = _context.next) {
|
|
4995
|
+
case 0:
|
|
4996
|
+
if (!_this.cancelToken && !params.close) {
|
|
4997
|
+
_this.cancelToken = axios.CancelToken.source();
|
|
4998
|
+
}
|
|
4999
|
+
|
|
5000
|
+
_context.prev = 1;
|
|
5001
|
+
_context.next = 4;
|
|
5002
|
+
return _this.client.doAxiosRequest('get', _this.client.baseURL.replace(':3030', ':8900') + '/longpoll', // replace port if present for testing with local API
|
|
5003
|
+
undefined, {
|
|
5004
|
+
config: _objectSpread$1(_objectSpread$1({}, config), {}, {
|
|
5005
|
+
cancelToken: (_this$cancelToken2 = _this.cancelToken) === null || _this$cancelToken2 === void 0 ? void 0 : _this$cancelToken2.token
|
|
5006
|
+
}),
|
|
5007
|
+
params: params
|
|
5008
|
+
});
|
|
5009
|
+
|
|
5010
|
+
case 4:
|
|
5011
|
+
res = _context.sent;
|
|
5012
|
+
_this.consecutiveFailures = 0; // always reset in case of no error
|
|
5013
|
+
|
|
5014
|
+
return _context.abrupt("return", res);
|
|
5015
|
+
|
|
5016
|
+
case 9:
|
|
5017
|
+
_context.prev = 9;
|
|
5018
|
+
_context.t0 = _context["catch"](1);
|
|
5019
|
+
_this.consecutiveFailures += 1;
|
|
5020
|
+
|
|
5021
|
+
if (!(retry && isErrorRetryable(_context.t0))) {
|
|
5022
|
+
_context.next = 17;
|
|
5023
|
+
break;
|
|
5024
|
+
}
|
|
5025
|
+
|
|
5026
|
+
_this._log("_req() - Retryable error, retrying request");
|
|
5027
|
+
|
|
5028
|
+
_context.next = 16;
|
|
5029
|
+
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5030
|
+
|
|
5031
|
+
case 16:
|
|
5032
|
+
return _context.abrupt("return", _this._req(params, config, retry));
|
|
5033
|
+
|
|
5034
|
+
case 17:
|
|
5035
|
+
throw _context.t0;
|
|
5036
|
+
|
|
5037
|
+
case 18:
|
|
5038
|
+
case "end":
|
|
5039
|
+
return _context.stop();
|
|
5040
|
+
}
|
|
5041
|
+
}
|
|
5042
|
+
}, _callee, null, [[1, 9]]);
|
|
5043
|
+
}));
|
|
5044
|
+
|
|
5045
|
+
return function (_x, _x2, _x3) {
|
|
5046
|
+
return _ref2.apply(this, arguments);
|
|
5047
|
+
};
|
|
5048
|
+
}());
|
|
5049
|
+
|
|
5050
|
+
_defineProperty(this, "_poll", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
5051
|
+
var _data$events, data, i;
|
|
5052
|
+
|
|
5053
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
5054
|
+
while (1) {
|
|
5055
|
+
switch (_context2.prev = _context2.next) {
|
|
5056
|
+
case 0:
|
|
5057
|
+
if (!(_this.state === ConnectionState.Connected)) {
|
|
5058
|
+
_context2.next = 25;
|
|
5059
|
+
break;
|
|
5060
|
+
}
|
|
5061
|
+
|
|
5062
|
+
_context2.prev = 1;
|
|
5063
|
+
_context2.next = 4;
|
|
5064
|
+
return _this._req({}, {
|
|
5065
|
+
timeout: 30000
|
|
5066
|
+
}, true);
|
|
5067
|
+
|
|
5068
|
+
case 4:
|
|
5069
|
+
data = _context2.sent;
|
|
5070
|
+
|
|
5071
|
+
// 30s => API responds in 20s if there is no event
|
|
5072
|
+
if ((_data$events = data.events) !== null && _data$events !== void 0 && _data$events.length) {
|
|
5073
|
+
for (i = 0; i < data.events.length; i++) {
|
|
5074
|
+
_this.client.dispatchEvent(data.events[i]);
|
|
5075
|
+
}
|
|
5076
|
+
}
|
|
5077
|
+
|
|
5078
|
+
_context2.next = 23;
|
|
5079
|
+
break;
|
|
5080
|
+
|
|
5081
|
+
case 8:
|
|
5082
|
+
_context2.prev = 8;
|
|
5083
|
+
_context2.t0 = _context2["catch"](1);
|
|
5084
|
+
|
|
5085
|
+
if (!axios.isCancel(_context2.t0)) {
|
|
5086
|
+
_context2.next = 13;
|
|
5087
|
+
break;
|
|
5088
|
+
}
|
|
5089
|
+
|
|
5090
|
+
_this._log("_poll() - axios canceled request");
|
|
5091
|
+
|
|
5092
|
+
return _context2.abrupt("return");
|
|
5093
|
+
|
|
5094
|
+
case 13:
|
|
5095
|
+
if (!isConnectionIDError(_context2.t0)) {
|
|
5096
|
+
_context2.next = 18;
|
|
5097
|
+
break;
|
|
5098
|
+
}
|
|
5099
|
+
|
|
5100
|
+
_this._log("_poll() - ConnectionID error, connecting without ID...");
|
|
5101
|
+
|
|
5102
|
+
_this._setState(ConnectionState.Disconnected);
|
|
5103
|
+
|
|
5104
|
+
_this.connect(true);
|
|
5105
|
+
|
|
5106
|
+
return _context2.abrupt("return");
|
|
5107
|
+
|
|
5108
|
+
case 18:
|
|
5109
|
+
if (!(isAPIError(_context2.t0) && !isErrorRetryable(_context2.t0))) {
|
|
5110
|
+
_context2.next = 21;
|
|
5111
|
+
break;
|
|
5112
|
+
}
|
|
5113
|
+
|
|
5114
|
+
_this._setState(ConnectionState.Closed);
|
|
5115
|
+
|
|
5116
|
+
return _context2.abrupt("return");
|
|
5117
|
+
|
|
5118
|
+
case 21:
|
|
5119
|
+
_context2.next = 23;
|
|
5120
|
+
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5121
|
+
|
|
5122
|
+
case 23:
|
|
5123
|
+
_context2.next = 0;
|
|
5124
|
+
break;
|
|
5125
|
+
|
|
5126
|
+
case 25:
|
|
5127
|
+
case "end":
|
|
5128
|
+
return _context2.stop();
|
|
5129
|
+
}
|
|
5130
|
+
}
|
|
5131
|
+
}, _callee2, null, [[1, 8]]);
|
|
5132
|
+
})));
|
|
5133
|
+
|
|
5134
|
+
_defineProperty(this, "connect", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
5135
|
+
var reconnect,
|
|
5136
|
+
_yield$_this$_req,
|
|
5137
|
+
event,
|
|
5138
|
+
_args3 = arguments;
|
|
5139
|
+
|
|
5140
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
5141
|
+
while (1) {
|
|
5142
|
+
switch (_context3.prev = _context3.next) {
|
|
5143
|
+
case 0:
|
|
5144
|
+
reconnect = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : false;
|
|
5145
|
+
|
|
5146
|
+
if (!(_this.state === ConnectionState.Connecting)) {
|
|
5147
|
+
_context3.next = 3;
|
|
5148
|
+
break;
|
|
5149
|
+
}
|
|
5150
|
+
|
|
5151
|
+
throw new Error('connecting already in progress');
|
|
5152
|
+
|
|
5153
|
+
case 3:
|
|
5154
|
+
if (!(_this.state === ConnectionState.Connected)) {
|
|
5155
|
+
_context3.next = 5;
|
|
5156
|
+
break;
|
|
5157
|
+
}
|
|
5158
|
+
|
|
5159
|
+
throw new Error('already connected and polling');
|
|
5160
|
+
|
|
5161
|
+
case 5:
|
|
5162
|
+
_this._setState(ConnectionState.Connecting);
|
|
5163
|
+
|
|
5164
|
+
_this.connectionID = undefined; // connect should be sent with empty connection_id so API creates one
|
|
5165
|
+
|
|
5166
|
+
_context3.prev = 7;
|
|
5167
|
+
_context3.next = 10;
|
|
5168
|
+
return _this._req({
|
|
5169
|
+
json: _this.client._buildWSPayload()
|
|
5170
|
+
}, {
|
|
5171
|
+
timeout: 8000
|
|
5172
|
+
}, // 8s
|
|
5173
|
+
reconnect);
|
|
5174
|
+
|
|
5175
|
+
case 10:
|
|
5176
|
+
_yield$_this$_req = _context3.sent;
|
|
5177
|
+
event = _yield$_this$_req.event;
|
|
5178
|
+
|
|
5179
|
+
_this._setState(ConnectionState.Connected);
|
|
5180
|
+
|
|
5181
|
+
_this.connectionID = event.connection_id;
|
|
5182
|
+
|
|
5183
|
+
_this._poll();
|
|
5184
|
+
|
|
5185
|
+
if (reconnect) {
|
|
5186
|
+
_this.client.recoverState();
|
|
5187
|
+
}
|
|
5188
|
+
|
|
5189
|
+
return _context3.abrupt("return", event);
|
|
5190
|
+
|
|
5191
|
+
case 19:
|
|
5192
|
+
_context3.prev = 19;
|
|
5193
|
+
_context3.t0 = _context3["catch"](7);
|
|
5194
|
+
|
|
5195
|
+
_this._setState(ConnectionState.Closed);
|
|
5196
|
+
|
|
5197
|
+
throw _context3.t0;
|
|
5198
|
+
|
|
5199
|
+
case 23:
|
|
5200
|
+
case "end":
|
|
5201
|
+
return _context3.stop();
|
|
5202
|
+
}
|
|
5203
|
+
}
|
|
5204
|
+
}, _callee3, null, [[7, 19]]);
|
|
5205
|
+
})));
|
|
5206
|
+
|
|
5207
|
+
_defineProperty(this, "isHealthy", function () {
|
|
5208
|
+
return _this.connectionID && _this.state === ConnectionState.Connected;
|
|
5209
|
+
});
|
|
4726
5210
|
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
_context2.next = 7;
|
|
4730
|
-
break;
|
|
4731
|
-
}
|
|
5211
|
+
_defineProperty(this, "disconnect", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
5212
|
+
var _this$cancelToken3;
|
|
4732
5213
|
|
|
4733
|
-
|
|
4734
|
-
|
|
5214
|
+
var timeout,
|
|
5215
|
+
_args4 = arguments;
|
|
5216
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
5217
|
+
while (1) {
|
|
5218
|
+
switch (_context4.prev = _context4.next) {
|
|
5219
|
+
case 0:
|
|
5220
|
+
timeout = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : 2000;
|
|
5221
|
+
removeConnectionEventListeners(_this._onlineStatusChanged);
|
|
4735
5222
|
|
|
4736
|
-
|
|
4737
|
-
_this.token = _context2.sent;
|
|
4738
|
-
resolve(_this.token);
|
|
5223
|
+
_this._setState(ConnectionState.Disconnected);
|
|
4739
5224
|
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
5225
|
+
(_this$cancelToken3 = _this.cancelToken) === null || _this$cancelToken3 === void 0 ? void 0 : _this$cancelToken3.cancel('disconnect() is called');
|
|
5226
|
+
_this.cancelToken = undefined;
|
|
5227
|
+
_context4.prev = 5;
|
|
5228
|
+
_context4.next = 8;
|
|
5229
|
+
return _this._req({
|
|
5230
|
+
close: true
|
|
5231
|
+
}, {
|
|
5232
|
+
timeout: timeout
|
|
5233
|
+
}, false);
|
|
4747
5234
|
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
};
|
|
4751
|
-
}());
|
|
4752
|
-
return _this.loadTokenPromise;
|
|
4753
|
-
});
|
|
5235
|
+
case 8:
|
|
5236
|
+
_this.connectionID = undefined;
|
|
4754
5237
|
|
|
4755
|
-
|
|
4756
|
-
if (_this.token) {
|
|
4757
|
-
return _this.token;
|
|
4758
|
-
}
|
|
5238
|
+
_this._log("disconnect() - Closed connectionID");
|
|
4759
5239
|
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
}
|
|
5240
|
+
_context4.next = 15;
|
|
5241
|
+
break;
|
|
4763
5242
|
|
|
4764
|
-
|
|
4765
|
-
|
|
5243
|
+
case 12:
|
|
5244
|
+
_context4.prev = 12;
|
|
5245
|
+
_context4.t0 = _context4["catch"](5);
|
|
5246
|
+
|
|
5247
|
+
_this._log("disconnect() - Failed", {
|
|
5248
|
+
err: _context4.t0
|
|
5249
|
+
});
|
|
5250
|
+
|
|
5251
|
+
case 15:
|
|
5252
|
+
case "end":
|
|
5253
|
+
return _context4.stop();
|
|
5254
|
+
}
|
|
5255
|
+
}
|
|
5256
|
+
}, _callee4, null, [[5, 12]]);
|
|
5257
|
+
})));
|
|
5258
|
+
|
|
5259
|
+
this.client = client;
|
|
5260
|
+
this.state = ConnectionState.Init;
|
|
5261
|
+
this.consecutiveFailures = 0;
|
|
5262
|
+
addConnectionEventListeners(this._onlineStatusChanged);
|
|
5263
|
+
}
|
|
5264
|
+
|
|
5265
|
+
_createClass(WSConnectionFallback, [{
|
|
5266
|
+
key: "_log",
|
|
5267
|
+
value: function _log(msg) {
|
|
5268
|
+
var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5269
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'info';
|
|
5270
|
+
this.client.logger(level, 'WSConnectionFallback:' + msg, _objectSpread$1({
|
|
5271
|
+
tags: ['connection_fallback', 'connection']
|
|
5272
|
+
}, extra));
|
|
4766
5273
|
}
|
|
5274
|
+
}, {
|
|
5275
|
+
key: "_setState",
|
|
5276
|
+
value: function _setState(state) {
|
|
5277
|
+
this._log("_setState() - ".concat(state)); // transition from connecting => connected
|
|
4767
5278
|
|
|
4768
|
-
throw new Error("Both secret and user tokens are not set. Either client.connectUser wasn't called or client.disconnect was called");
|
|
4769
|
-
});
|
|
4770
5279
|
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
5280
|
+
if (this.state === ConnectionState.Connecting && state === ConnectionState.Connected) {
|
|
5281
|
+
//@ts-expect-error
|
|
5282
|
+
this.client.dispatchEvent({
|
|
5283
|
+
type: 'connection.changed',
|
|
5284
|
+
online: true
|
|
5285
|
+
});
|
|
5286
|
+
}
|
|
4774
5287
|
|
|
4775
|
-
|
|
5288
|
+
if (state === ConnectionState.Closed || state === ConnectionState.Disconnected) {
|
|
5289
|
+
//@ts-expect-error
|
|
5290
|
+
this.client.dispatchEvent({
|
|
5291
|
+
type: 'connection.changed',
|
|
5292
|
+
online: false
|
|
5293
|
+
});
|
|
5294
|
+
}
|
|
4776
5295
|
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
5296
|
+
this.state = state;
|
|
5297
|
+
}
|
|
5298
|
+
/** @private */
|
|
4780
5299
|
|
|
4781
|
-
|
|
5300
|
+
}]);
|
|
4782
5301
|
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
}
|
|
4786
|
-
}
|
|
4787
|
-
/**
|
|
4788
|
-
* Set the static string token or token provider.
|
|
4789
|
-
* Token provider should return a token string or a promise which resolves to string token.
|
|
4790
|
-
*
|
|
4791
|
-
* @param {TokenOrProvider} tokenOrProvider
|
|
4792
|
-
* @param {UserResponse<UserType>} user
|
|
4793
|
-
*/
|
|
4794
|
-
;
|
|
5302
|
+
return WSConnectionFallback;
|
|
5303
|
+
}();
|
|
4795
5304
|
|
|
4796
5305
|
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; } } }; }
|
|
4797
5306
|
|
|
@@ -4831,10 +5340,6 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4831
5340
|
|
|
4832
5341
|
_defineProperty(this, "configs", void 0);
|
|
4833
5342
|
|
|
4834
|
-
_defineProperty(this, "connectionID", void 0);
|
|
4835
|
-
|
|
4836
|
-
_defineProperty(this, "failures", void 0);
|
|
4837
|
-
|
|
4838
5343
|
_defineProperty(this, "key", void 0);
|
|
4839
5344
|
|
|
4840
5345
|
_defineProperty(this, "listeners", void 0);
|
|
@@ -4869,16 +5374,26 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4869
5374
|
|
|
4870
5375
|
_defineProperty(this, "wsConnection", void 0);
|
|
4871
5376
|
|
|
5377
|
+
_defineProperty(this, "wsFallback", void 0);
|
|
5378
|
+
|
|
4872
5379
|
_defineProperty(this, "wsPromise", void 0);
|
|
4873
5380
|
|
|
4874
5381
|
_defineProperty(this, "consecutiveFailures", void 0);
|
|
4875
5382
|
|
|
4876
5383
|
_defineProperty(this, "insightMetrics", void 0);
|
|
4877
5384
|
|
|
4878
|
-
_defineProperty(this, "
|
|
4879
|
-
|
|
5385
|
+
_defineProperty(this, "defaultWSTimeoutWithFallback", void 0);
|
|
5386
|
+
|
|
5387
|
+
_defineProperty(this, "defaultWSTimeout", void 0);
|
|
5388
|
+
|
|
5389
|
+
_defineProperty(this, "_getConnectionID", function () {
|
|
5390
|
+
var _this$wsConnection, _this$wsFallback;
|
|
4880
5391
|
|
|
4881
|
-
return
|
|
5392
|
+
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);
|
|
5393
|
+
});
|
|
5394
|
+
|
|
5395
|
+
_defineProperty(this, "_hasConnectionID", function () {
|
|
5396
|
+
return Boolean(_this._getConnectionID());
|
|
4882
5397
|
});
|
|
4883
5398
|
|
|
4884
5399
|
_defineProperty(this, "connectUser", /*#__PURE__*/function () {
|
|
@@ -4964,36 +5479,55 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
4964
5479
|
return _this.tokenManager.setTokenOrProvider(userTokenOrProvider, user);
|
|
4965
5480
|
});
|
|
4966
5481
|
|
|
4967
|
-
_defineProperty(this, "closeConnection", function (
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
_this.cleaningIntervalRef = undefined;
|
|
4971
|
-
}
|
|
5482
|
+
_defineProperty(this, "closeConnection", /*#__PURE__*/function () {
|
|
5483
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(timeout) {
|
|
5484
|
+
var _this$wsConnection2, _this$wsFallback2;
|
|
4972
5485
|
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
5486
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
5487
|
+
while (1) {
|
|
5488
|
+
switch (_context2.prev = _context2.next) {
|
|
5489
|
+
case 0:
|
|
5490
|
+
if (_this.cleaningIntervalRef != null) {
|
|
5491
|
+
clearInterval(_this.cleaningIntervalRef);
|
|
5492
|
+
_this.cleaningIntervalRef = undefined;
|
|
5493
|
+
}
|
|
4976
5494
|
|
|
4977
|
-
|
|
4978
|
-
|
|
5495
|
+
_context2.next = 3;
|
|
5496
|
+
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)]);
|
|
4979
5497
|
|
|
4980
|
-
|
|
4981
|
-
|
|
5498
|
+
case 3:
|
|
5499
|
+
return _context2.abrupt("return", Promise.resolve());
|
|
4982
5500
|
|
|
4983
|
-
|
|
5501
|
+
case 4:
|
|
5502
|
+
case "end":
|
|
5503
|
+
return _context2.stop();
|
|
5504
|
+
}
|
|
5505
|
+
}
|
|
5506
|
+
}, _callee2);
|
|
5507
|
+
}));
|
|
5508
|
+
|
|
5509
|
+
return function (_x3) {
|
|
5510
|
+
return _ref2.apply(this, arguments);
|
|
5511
|
+
};
|
|
5512
|
+
}());
|
|
5513
|
+
|
|
5514
|
+
_defineProperty(this, "openConnection", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
5515
|
+
var _this$wsConnection3, _this$wsFallback3;
|
|
5516
|
+
|
|
5517
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
4984
5518
|
while (1) {
|
|
4985
|
-
switch (
|
|
5519
|
+
switch (_context3.prev = _context3.next) {
|
|
4986
5520
|
case 0:
|
|
4987
5521
|
if (_this.userID) {
|
|
4988
|
-
|
|
5522
|
+
_context3.next = 2;
|
|
4989
5523
|
break;
|
|
4990
5524
|
}
|
|
4991
5525
|
|
|
4992
5526
|
throw Error('User is not set on client, use client.connectUser or client.connectAnonymousUser instead');
|
|
4993
5527
|
|
|
4994
5528
|
case 2:
|
|
4995
|
-
if (!((_this$
|
|
4996
|
-
|
|
5529
|
+
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())) {
|
|
5530
|
+
_context3.next = 5;
|
|
4997
5531
|
break;
|
|
4998
5532
|
}
|
|
4999
5533
|
|
|
@@ -5001,7 +5535,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5001
5535
|
tags: ['connection', 'client']
|
|
5002
5536
|
});
|
|
5003
5537
|
|
|
5004
|
-
return
|
|
5538
|
+
return _context3.abrupt("return", Promise.resolve());
|
|
5005
5539
|
|
|
5006
5540
|
case 5:
|
|
5007
5541
|
_this.clientID = "".concat(_this.userID, "--").concat(randomId());
|
|
@@ -5009,14 +5543,14 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5009
5543
|
|
|
5010
5544
|
_this._startCleaning();
|
|
5011
5545
|
|
|
5012
|
-
return
|
|
5546
|
+
return _context3.abrupt("return", _this.wsPromise);
|
|
5013
5547
|
|
|
5014
5548
|
case 9:
|
|
5015
5549
|
case "end":
|
|
5016
|
-
return
|
|
5550
|
+
return _context3.stop();
|
|
5017
5551
|
}
|
|
5018
5552
|
}
|
|
5019
|
-
},
|
|
5553
|
+
}, _callee3);
|
|
5020
5554
|
})));
|
|
5021
5555
|
|
|
5022
5556
|
_defineProperty(this, "_setupConnection", this.openConnection);
|
|
@@ -5034,12 +5568,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5034
5568
|
});
|
|
5035
5569
|
|
|
5036
5570
|
_defineProperty(this, "disconnectUser", /*#__PURE__*/function () {
|
|
5037
|
-
var
|
|
5571
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(timeout) {
|
|
5038
5572
|
var closePromise, _i, _Object$values, _channel;
|
|
5039
5573
|
|
|
5040
|
-
return _regeneratorRuntime.wrap(function
|
|
5574
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
5041
5575
|
while (1) {
|
|
5042
|
-
switch (
|
|
5576
|
+
switch (_context4.prev = _context4.next) {
|
|
5043
5577
|
case 0:
|
|
5044
5578
|
_this.logger('info', 'client:disconnect() - Disconnecting the client', {
|
|
5045
5579
|
tags: ['connection', 'client']
|
|
@@ -5063,21 +5597,21 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5063
5597
|
|
|
5064
5598
|
_this.state = new ClientState(); // reset token manager
|
|
5065
5599
|
|
|
5066
|
-
_this.tokenManager.reset
|
|
5067
|
-
|
|
5600
|
+
setTimeout(_this.tokenManager.reset); // delay reseting to use token for disconnect calls
|
|
5601
|
+
// close the WS connection
|
|
5068
5602
|
|
|
5069
|
-
return
|
|
5603
|
+
return _context4.abrupt("return", closePromise);
|
|
5070
5604
|
|
|
5071
5605
|
case 11:
|
|
5072
5606
|
case "end":
|
|
5073
|
-
return
|
|
5607
|
+
return _context4.stop();
|
|
5074
5608
|
}
|
|
5075
5609
|
}
|
|
5076
|
-
},
|
|
5610
|
+
}, _callee4);
|
|
5077
5611
|
}));
|
|
5078
5612
|
|
|
5079
|
-
return function (
|
|
5080
|
-
return
|
|
5613
|
+
return function (_x4) {
|
|
5614
|
+
return _ref4.apply(this, arguments);
|
|
5081
5615
|
};
|
|
5082
5616
|
}());
|
|
5083
5617
|
|
|
@@ -5105,76 +5639,78 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5105
5639
|
_defineProperty(this, "setAnonymousUser", this.connectAnonymousUser);
|
|
5106
5640
|
|
|
5107
5641
|
_defineProperty(this, "doAxiosRequest", /*#__PURE__*/function () {
|
|
5108
|
-
var
|
|
5642
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(type, url, data) {
|
|
5109
5643
|
var options,
|
|
5110
5644
|
requestConfig,
|
|
5111
5645
|
response,
|
|
5112
|
-
|
|
5113
|
-
|
|
5646
|
+
_requestConfig$header,
|
|
5647
|
+
_args5 = arguments;
|
|
5648
|
+
|
|
5649
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
5114
5650
|
while (1) {
|
|
5115
|
-
switch (
|
|
5651
|
+
switch (_context5.prev = _context5.next) {
|
|
5116
5652
|
case 0:
|
|
5117
|
-
options =
|
|
5118
|
-
|
|
5653
|
+
options = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : {};
|
|
5654
|
+
_context5.next = 3;
|
|
5119
5655
|
return _this.tokenManager.tokenReady();
|
|
5120
5656
|
|
|
5121
5657
|
case 3:
|
|
5122
5658
|
requestConfig = _this._enrichAxiosOptions(options);
|
|
5123
|
-
|
|
5659
|
+
_context5.prev = 4;
|
|
5124
5660
|
|
|
5125
5661
|
_this._logApiRequest(type, url, data, requestConfig);
|
|
5126
5662
|
|
|
5127
|
-
|
|
5128
|
-
|
|
5663
|
+
_context5.t0 = type;
|
|
5664
|
+
_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;
|
|
5129
5665
|
break;
|
|
5130
5666
|
|
|
5131
5667
|
case 9:
|
|
5132
|
-
|
|
5668
|
+
_context5.next = 11;
|
|
5133
5669
|
return _this.axiosInstance.get(url, requestConfig);
|
|
5134
5670
|
|
|
5135
5671
|
case 11:
|
|
5136
|
-
response =
|
|
5137
|
-
return
|
|
5672
|
+
response = _context5.sent;
|
|
5673
|
+
return _context5.abrupt("break", 34);
|
|
5138
5674
|
|
|
5139
5675
|
case 13:
|
|
5140
|
-
|
|
5676
|
+
_context5.next = 15;
|
|
5141
5677
|
return _this.axiosInstance.delete(url, requestConfig);
|
|
5142
5678
|
|
|
5143
5679
|
case 15:
|
|
5144
|
-
response =
|
|
5145
|
-
return
|
|
5680
|
+
response = _context5.sent;
|
|
5681
|
+
return _context5.abrupt("break", 34);
|
|
5146
5682
|
|
|
5147
5683
|
case 17:
|
|
5148
|
-
|
|
5684
|
+
_context5.next = 19;
|
|
5149
5685
|
return _this.axiosInstance.post(url, data, requestConfig);
|
|
5150
5686
|
|
|
5151
5687
|
case 19:
|
|
5152
|
-
response =
|
|
5153
|
-
return
|
|
5688
|
+
response = _context5.sent;
|
|
5689
|
+
return _context5.abrupt("break", 34);
|
|
5154
5690
|
|
|
5155
5691
|
case 21:
|
|
5156
|
-
|
|
5692
|
+
_context5.next = 23;
|
|
5157
5693
|
return _this.axiosInstance.put(url, data, requestConfig);
|
|
5158
5694
|
|
|
5159
5695
|
case 23:
|
|
5160
|
-
response =
|
|
5161
|
-
return
|
|
5696
|
+
response = _context5.sent;
|
|
5697
|
+
return _context5.abrupt("break", 34);
|
|
5162
5698
|
|
|
5163
5699
|
case 25:
|
|
5164
|
-
|
|
5700
|
+
_context5.next = 27;
|
|
5165
5701
|
return _this.axiosInstance.patch(url, data, requestConfig);
|
|
5166
5702
|
|
|
5167
5703
|
case 27:
|
|
5168
|
-
response =
|
|
5169
|
-
return
|
|
5704
|
+
response = _context5.sent;
|
|
5705
|
+
return _context5.abrupt("break", 34);
|
|
5170
5706
|
|
|
5171
5707
|
case 29:
|
|
5172
|
-
|
|
5708
|
+
_context5.next = 31;
|
|
5173
5709
|
return _this.axiosInstance.options(url, requestConfig);
|
|
5174
5710
|
|
|
5175
5711
|
case 31:
|
|
5176
|
-
response =
|
|
5177
|
-
return
|
|
5712
|
+
response = _context5.sent;
|
|
5713
|
+
return _context5.abrupt("break", 34);
|
|
5178
5714
|
|
|
5179
5715
|
case 33:
|
|
5180
5716
|
throw new Error('Invalid request type');
|
|
@@ -5183,64 +5719,66 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5183
5719
|
_this._logApiResponse(type, url, response);
|
|
5184
5720
|
|
|
5185
5721
|
_this.consecutiveFailures = 0;
|
|
5186
|
-
return
|
|
5722
|
+
return _context5.abrupt("return", _this.handleResponse(response));
|
|
5187
5723
|
|
|
5188
5724
|
case 39:
|
|
5189
|
-
|
|
5190
|
-
|
|
5725
|
+
_context5.prev = 39;
|
|
5726
|
+
_context5.t1 = _context5["catch"](4);
|
|
5727
|
+
_context5.t1.client_request_id = (_requestConfig$header = requestConfig.headers) === null || _requestConfig$header === void 0 ? void 0 : _requestConfig$header['x-client-request-id'];
|
|
5191
5728
|
|
|
5192
|
-
_this._logApiError(type, url,
|
|
5729
|
+
_this._logApiError(type, url, _context5.t1);
|
|
5193
5730
|
|
|
5194
5731
|
_this.consecutiveFailures += 1;
|
|
5195
5732
|
|
|
5196
|
-
if (!
|
|
5197
|
-
|
|
5733
|
+
if (!_context5.t1.response) {
|
|
5734
|
+
_context5.next = 56;
|
|
5198
5735
|
break;
|
|
5199
5736
|
}
|
|
5200
5737
|
|
|
5201
|
-
if (!(
|
|
5202
|
-
|
|
5738
|
+
if (!(_context5.t1.response.data.code === chatCodes.TOKEN_EXPIRED && !_this.tokenManager.isStatic())) {
|
|
5739
|
+
_context5.next = 53;
|
|
5203
5740
|
break;
|
|
5204
5741
|
}
|
|
5205
5742
|
|
|
5206
5743
|
if (!(_this.consecutiveFailures > 1)) {
|
|
5207
|
-
|
|
5744
|
+
_context5.next = 49;
|
|
5208
5745
|
break;
|
|
5209
5746
|
}
|
|
5210
5747
|
|
|
5211
|
-
|
|
5748
|
+
_context5.next = 49;
|
|
5212
5749
|
return sleep(retryInterval(_this.consecutiveFailures));
|
|
5213
5750
|
|
|
5214
|
-
case
|
|
5751
|
+
case 49:
|
|
5215
5752
|
_this.tokenManager.loadToken();
|
|
5216
5753
|
|
|
5217
|
-
|
|
5754
|
+
_context5.next = 52;
|
|
5218
5755
|
return _this.doAxiosRequest(type, url, data, options);
|
|
5219
5756
|
|
|
5220
|
-
case 51:
|
|
5221
|
-
return _context4.abrupt("return", _context4.sent);
|
|
5222
|
-
|
|
5223
5757
|
case 52:
|
|
5224
|
-
return
|
|
5758
|
+
return _context5.abrupt("return", _context5.sent);
|
|
5225
5759
|
|
|
5226
|
-
case
|
|
5227
|
-
|
|
5760
|
+
case 53:
|
|
5761
|
+
return _context5.abrupt("return", _this.handleResponse(_context5.t1.response));
|
|
5228
5762
|
|
|
5229
5763
|
case 56:
|
|
5764
|
+
throw _context5.t1;
|
|
5765
|
+
|
|
5766
|
+
case 57:
|
|
5230
5767
|
case "end":
|
|
5231
|
-
return
|
|
5768
|
+
return _context5.stop();
|
|
5232
5769
|
}
|
|
5233
5770
|
}
|
|
5234
|
-
},
|
|
5771
|
+
}, _callee5, null, [[4, 39]]);
|
|
5235
5772
|
}));
|
|
5236
5773
|
|
|
5237
|
-
return function (
|
|
5238
|
-
return
|
|
5774
|
+
return function (_x5, _x6, _x7) {
|
|
5775
|
+
return _ref5.apply(this, arguments);
|
|
5239
5776
|
};
|
|
5240
5777
|
}());
|
|
5241
5778
|
|
|
5242
5779
|
_defineProperty(this, "dispatchEvent", function (event) {
|
|
5243
|
-
// client event handlers
|
|
5780
|
+
if (!event.received_at) event.received_at = new Date(); // client event handlers
|
|
5781
|
+
|
|
5244
5782
|
var postListenerCallbacks = _this._handleClientEvent(event); // channel event handlers
|
|
5245
5783
|
|
|
5246
5784
|
|
|
@@ -5266,7 +5804,6 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5266
5804
|
// dispatch the event to the channel listeners
|
|
5267
5805
|
var jsonString = messageEvent.data;
|
|
5268
5806
|
var event = JSON.parse(jsonString);
|
|
5269
|
-
event.received_at = new Date();
|
|
5270
5807
|
|
|
5271
5808
|
_this.dispatchEvent(event);
|
|
5272
5809
|
});
|
|
@@ -5387,22 +5924,20 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5387
5924
|
}
|
|
5388
5925
|
});
|
|
5389
5926
|
|
|
5390
|
-
_defineProperty(this, "recoverState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
5391
|
-
var _this$wsConnection3;
|
|
5392
|
-
|
|
5927
|
+
_defineProperty(this, "recoverState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
5393
5928
|
var cids;
|
|
5394
|
-
return _regeneratorRuntime.wrap(function
|
|
5929
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
5395
5930
|
while (1) {
|
|
5396
|
-
switch (
|
|
5931
|
+
switch (_context6.prev = _context6.next) {
|
|
5397
5932
|
case 0:
|
|
5398
|
-
_this.logger('info', "client:recoverState() - Start of recoverState with connectionID ".concat(
|
|
5933
|
+
_this.logger('info', "client:recoverState() - Start of recoverState with connectionID ".concat(_this._getConnectionID()), {
|
|
5399
5934
|
tags: ['connection']
|
|
5400
5935
|
});
|
|
5401
5936
|
|
|
5402
5937
|
cids = Object.keys(_this.activeChannels);
|
|
5403
5938
|
|
|
5404
5939
|
if (!(cids.length && _this.recoverStateOnReconnect)) {
|
|
5405
|
-
|
|
5940
|
+
_context6.next = 10;
|
|
5406
5941
|
break;
|
|
5407
5942
|
}
|
|
5408
5943
|
|
|
@@ -5410,7 +5945,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5410
5945
|
tags: ['connection', 'client']
|
|
5411
5946
|
});
|
|
5412
5947
|
|
|
5413
|
-
|
|
5948
|
+
_context6.next = 6;
|
|
5414
5949
|
return _this.queryChannels({
|
|
5415
5950
|
cid: {
|
|
5416
5951
|
$in: cids
|
|
@@ -5430,7 +5965,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5430
5965
|
type: 'connection.recovered'
|
|
5431
5966
|
});
|
|
5432
5967
|
|
|
5433
|
-
|
|
5968
|
+
_context6.next = 11;
|
|
5434
5969
|
break;
|
|
5435
5970
|
|
|
5436
5971
|
case 10:
|
|
@@ -5444,10 +5979,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5444
5979
|
|
|
5445
5980
|
case 13:
|
|
5446
5981
|
case "end":
|
|
5447
|
-
return
|
|
5982
|
+
return _context6.stop();
|
|
5448
5983
|
}
|
|
5449
5984
|
}
|
|
5450
|
-
},
|
|
5985
|
+
}, _callee6);
|
|
5451
5986
|
})));
|
|
5452
5987
|
|
|
5453
5988
|
_defineProperty(this, "getChannelByMembers", function (channelType, custom) {
|
|
@@ -5527,66 +6062,16 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5527
6062
|
return !!_this.secret;
|
|
5528
6063
|
});
|
|
5529
6064
|
|
|
5530
|
-
_defineProperty(this, "
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
case 2:
|
|
5541
|
-
if (!(i < maxAttempts)) {
|
|
5542
|
-
_context6.next = 18;
|
|
5543
|
-
break;
|
|
5544
|
-
}
|
|
5545
|
-
|
|
5546
|
-
_context6.prev = 3;
|
|
5547
|
-
_context6.next = 6;
|
|
5548
|
-
return _this.axiosInstance.post("https://chat-insights.getstream.io/insights/".concat(insightType), insights);
|
|
5549
|
-
|
|
5550
|
-
case 6:
|
|
5551
|
-
_context6.next = 14;
|
|
5552
|
-
break;
|
|
5553
|
-
|
|
5554
|
-
case 8:
|
|
5555
|
-
_context6.prev = 8;
|
|
5556
|
-
_context6.t0 = _context6["catch"](3);
|
|
5557
|
-
|
|
5558
|
-
_this.logger('warn', "failed to send insights event ".concat(insightType), {
|
|
5559
|
-
tags: ['insights', 'connection'],
|
|
5560
|
-
error: _context6.t0,
|
|
5561
|
-
insights: insights
|
|
5562
|
-
});
|
|
5563
|
-
|
|
5564
|
-
_context6.next = 13;
|
|
5565
|
-
return sleep((i + 1) * 3000);
|
|
5566
|
-
|
|
5567
|
-
case 13:
|
|
5568
|
-
return _context6.abrupt("continue", 15);
|
|
5569
|
-
|
|
5570
|
-
case 14:
|
|
5571
|
-
return _context6.abrupt("break", 18);
|
|
5572
|
-
|
|
5573
|
-
case 15:
|
|
5574
|
-
i++;
|
|
5575
|
-
_context6.next = 2;
|
|
5576
|
-
break;
|
|
5577
|
-
|
|
5578
|
-
case 18:
|
|
5579
|
-
case "end":
|
|
5580
|
-
return _context6.stop();
|
|
5581
|
-
}
|
|
5582
|
-
}
|
|
5583
|
-
}, _callee6, null, [[3, 8]]);
|
|
5584
|
-
}));
|
|
5585
|
-
|
|
5586
|
-
return function (_x7, _x8) {
|
|
5587
|
-
return _ref6.apply(this, arguments);
|
|
5588
|
-
};
|
|
5589
|
-
}());
|
|
6065
|
+
_defineProperty(this, "_buildWSPayload", function (client_request_id) {
|
|
6066
|
+
return JSON.stringify({
|
|
6067
|
+
user_id: _this.userID,
|
|
6068
|
+
user_details: _this._user,
|
|
6069
|
+
user_token: _this.tokenManager.getToken(),
|
|
6070
|
+
server_determines_connection_id: true,
|
|
6071
|
+
device: _this.options.device,
|
|
6072
|
+
client_request_id: client_request_id
|
|
6073
|
+
});
|
|
6074
|
+
});
|
|
5590
6075
|
|
|
5591
6076
|
// set the key
|
|
5592
6077
|
this.key = _key;
|
|
@@ -5620,7 +6105,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5620
6105
|
}
|
|
5621
6106
|
|
|
5622
6107
|
this.axiosInstance = axios.create(this.options);
|
|
5623
|
-
this.setBaseURL(this.options.baseURL || 'https://chat
|
|
6108
|
+
this.setBaseURL(this.options.baseURL || 'https://chat.stream-io-api.com');
|
|
5624
6109
|
|
|
5625
6110
|
if (typeof process !== 'undefined' && process.env.STREAM_LOCAL_TEST_RUN) {
|
|
5626
6111
|
this.setBaseURL('http://localhost:3030');
|
|
@@ -5644,6 +6129,8 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5644
6129
|
this.tokenManager = new TokenManager(this.secret);
|
|
5645
6130
|
this.consecutiveFailures = 0;
|
|
5646
6131
|
this.insightMetrics = new InsightMetrics();
|
|
6132
|
+
this.defaultWSTimeoutWithFallback = 6000;
|
|
6133
|
+
this.defaultWSTimeout = 15000;
|
|
5647
6134
|
/**
|
|
5648
6135
|
* logger function should accept 3 parameters:
|
|
5649
6136
|
* @param logLevel string
|
|
@@ -5817,7 +6304,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5817
6304
|
}, _callee7, this);
|
|
5818
6305
|
}));
|
|
5819
6306
|
|
|
5820
|
-
function updateAppSettings(
|
|
6307
|
+
function updateAppSettings(_x8) {
|
|
5821
6308
|
return _updateAppSettings.apply(this, arguments);
|
|
5822
6309
|
}
|
|
5823
6310
|
|
|
@@ -5851,7 +6338,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5851
6338
|
}, _callee8, this);
|
|
5852
6339
|
}));
|
|
5853
6340
|
|
|
5854
|
-
function revokeTokens(
|
|
6341
|
+
function revokeTokens(_x9) {
|
|
5855
6342
|
return _revokeTokens.apply(this, arguments);
|
|
5856
6343
|
}
|
|
5857
6344
|
|
|
@@ -5883,7 +6370,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5883
6370
|
}, _callee9, this);
|
|
5884
6371
|
}));
|
|
5885
6372
|
|
|
5886
|
-
function revokeUserToken(
|
|
6373
|
+
function revokeUserToken(_x10, _x11) {
|
|
5887
6374
|
return _revokeUserToken.apply(this, arguments);
|
|
5888
6375
|
}
|
|
5889
6376
|
|
|
@@ -5942,7 +6429,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
5942
6429
|
}, _callee10, this);
|
|
5943
6430
|
}));
|
|
5944
6431
|
|
|
5945
|
-
function revokeUsersToken(
|
|
6432
|
+
function revokeUsersToken(_x12, _x13) {
|
|
5946
6433
|
return _revokeUsersToken.apply(this, arguments);
|
|
5947
6434
|
}
|
|
5948
6435
|
|
|
@@ -6034,7 +6521,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6034
6521
|
}, _callee12, this);
|
|
6035
6522
|
}));
|
|
6036
6523
|
|
|
6037
|
-
function testPushSettings(
|
|
6524
|
+
function testPushSettings(_x14) {
|
|
6038
6525
|
return _testPushSettings.apply(this, arguments);
|
|
6039
6526
|
}
|
|
6040
6527
|
|
|
@@ -6143,7 +6630,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6143
6630
|
}, _callee14, this, [[1, 7]]);
|
|
6144
6631
|
}));
|
|
6145
6632
|
|
|
6146
|
-
function setGuestUser(
|
|
6633
|
+
function setGuestUser(_x15) {
|
|
6147
6634
|
return _setGuestUser.apply(this, arguments);
|
|
6148
6635
|
}
|
|
6149
6636
|
|
|
@@ -6454,90 +6941,84 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6454
6941
|
*/
|
|
6455
6942
|
function () {
|
|
6456
6943
|
var _connect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15() {
|
|
6457
|
-
var client, warmUpPromise, handshake;
|
|
6458
6944
|
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
6459
6945
|
while (1) {
|
|
6460
6946
|
switch (_context15.prev = _context15.next) {
|
|
6461
6947
|
case 0:
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
if (!(client.userID == null || this._user == null)) {
|
|
6466
|
-
_context15.next = 4;
|
|
6948
|
+
if (!(!this.userID || !this._user)) {
|
|
6949
|
+
_context15.next = 2;
|
|
6467
6950
|
break;
|
|
6468
6951
|
}
|
|
6469
6952
|
|
|
6470
6953
|
throw Error('Call connectUser or connectAnonymousUser before starting the connection');
|
|
6471
6954
|
|
|
6472
|
-
case
|
|
6473
|
-
if (
|
|
6474
|
-
_context15.next =
|
|
6955
|
+
case 2:
|
|
6956
|
+
if (this.wsBaseURL) {
|
|
6957
|
+
_context15.next = 4;
|
|
6475
6958
|
break;
|
|
6476
6959
|
}
|
|
6477
6960
|
|
|
6478
6961
|
throw Error('Websocket base url not set');
|
|
6479
6962
|
|
|
6480
|
-
case
|
|
6481
|
-
if (
|
|
6482
|
-
_context15.next =
|
|
6963
|
+
case 4:
|
|
6964
|
+
if (this.clientID) {
|
|
6965
|
+
_context15.next = 6;
|
|
6483
6966
|
break;
|
|
6484
6967
|
}
|
|
6485
6968
|
|
|
6486
6969
|
throw Error('clientID is not set');
|
|
6487
6970
|
|
|
6488
|
-
case
|
|
6489
|
-
|
|
6971
|
+
case 6:
|
|
6972
|
+
if (!this.wsConnection && (this.options.warmUp || this.options.enableInsights)) {
|
|
6973
|
+
this._sayHi();
|
|
6974
|
+
} // The StableWSConnection handles all the reconnection logic.
|
|
6975
|
+
|
|
6976
|
+
|
|
6490
6977
|
this.wsConnection = new StableWSConnection({
|
|
6491
|
-
|
|
6492
|
-
clientID: client.clientID,
|
|
6493
|
-
userID: client.userID,
|
|
6494
|
-
tokenManager: client.tokenManager,
|
|
6495
|
-
user: this._user,
|
|
6496
|
-
authType: this.getAuthType(),
|
|
6497
|
-
userAgent: this.getUserAgent(),
|
|
6498
|
-
apiKey: this.key,
|
|
6499
|
-
recoverCallback: this.recoverState,
|
|
6500
|
-
messageCallback: this.handleEvent,
|
|
6501
|
-
eventCallback: this.dispatchEvent,
|
|
6502
|
-
logger: this.logger,
|
|
6503
|
-
device: this.options.device,
|
|
6504
|
-
postInsights: this.options.enableInsights ? this.postInsights : undefined,
|
|
6505
|
-
insightMetrics: this.insightMetrics
|
|
6978
|
+
client: this
|
|
6506
6979
|
});
|
|
6980
|
+
_context15.prev = 8;
|
|
6981
|
+
_context15.next = 11;
|
|
6982
|
+
return this.wsConnection.connect(this.options.enableWSFallback ? this.defaultWSTimeoutWithFallback : this.defaultWSTimeout);
|
|
6507
6983
|
|
|
6508
|
-
|
|
6509
|
-
|
|
6984
|
+
case 11:
|
|
6985
|
+
return _context15.abrupt("return", _context15.sent);
|
|
6986
|
+
|
|
6987
|
+
case 14:
|
|
6988
|
+
_context15.prev = 14;
|
|
6989
|
+
_context15.t0 = _context15["catch"](8);
|
|
6990
|
+
|
|
6991
|
+
if (!(this.options.enableWSFallback && isWSFailure(_context15.t0) && isOnline())) {
|
|
6992
|
+
_context15.next = 24;
|
|
6993
|
+
break;
|
|
6510
6994
|
}
|
|
6511
6995
|
|
|
6512
|
-
|
|
6513
|
-
|
|
6996
|
+
this.logger('info', 'client:connect() - WS failed, fallback to longpoll', {
|
|
6997
|
+
tags: ['connection', 'client']
|
|
6998
|
+
});
|
|
6514
6999
|
|
|
6515
|
-
|
|
6516
|
-
handshake = _context15.sent;
|
|
6517
|
-
_context15.prev = 13;
|
|
6518
|
-
_context15.next = 16;
|
|
6519
|
-
return warmUpPromise;
|
|
7000
|
+
this.wsConnection._destroyCurrentWSConnection();
|
|
6520
7001
|
|
|
6521
|
-
|
|
6522
|
-
_context15.next = 21;
|
|
6523
|
-
break;
|
|
7002
|
+
this.wsConnection.disconnect().then(); // close WS so no retry
|
|
6524
7003
|
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
_context15.t0 = _context15["catch"](13);
|
|
6528
|
-
this.logger('error', 'Warmup request failed', {
|
|
6529
|
-
error: _context15.t0
|
|
7004
|
+
this.wsFallback = new WSConnectionFallback({
|
|
7005
|
+
client: this
|
|
6530
7006
|
});
|
|
7007
|
+
_context15.next = 23;
|
|
7008
|
+
return this.wsFallback.connect();
|
|
6531
7009
|
|
|
6532
|
-
case
|
|
6533
|
-
return _context15.abrupt("return",
|
|
7010
|
+
case 23:
|
|
7011
|
+
return _context15.abrupt("return", _context15.sent);
|
|
6534
7012
|
|
|
6535
|
-
case
|
|
7013
|
+
case 24:
|
|
7014
|
+
throw _context15.t0;
|
|
7015
|
+
|
|
7016
|
+
case 25:
|
|
6536
7017
|
case "end":
|
|
6537
7018
|
return _context15.stop();
|
|
6538
7019
|
}
|
|
6539
7020
|
}
|
|
6540
|
-
}, _callee15, this, [[
|
|
7021
|
+
}, _callee15, this, [[8, 14]]);
|
|
6541
7022
|
}));
|
|
6542
7023
|
|
|
6543
7024
|
function connect() {
|
|
@@ -6546,6 +7027,33 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6546
7027
|
|
|
6547
7028
|
return connect;
|
|
6548
7029
|
}()
|
|
7030
|
+
/**
|
|
7031
|
+
* Check the connectivity with server for warmup purpose.
|
|
7032
|
+
*
|
|
7033
|
+
* @private
|
|
7034
|
+
*/
|
|
7035
|
+
|
|
7036
|
+
}, {
|
|
7037
|
+
key: "_sayHi",
|
|
7038
|
+
value: function _sayHi() {
|
|
7039
|
+
var _this4 = this;
|
|
7040
|
+
|
|
7041
|
+
var client_request_id = randomId();
|
|
7042
|
+
var opts = {
|
|
7043
|
+
headers: {
|
|
7044
|
+
'x-client-request-id': client_request_id
|
|
7045
|
+
}
|
|
7046
|
+
};
|
|
7047
|
+
this.doAxiosRequest('get', this.baseURL + '/hi', null, opts).catch(function (e) {
|
|
7048
|
+
if (_this4.options.enableInsights) {
|
|
7049
|
+
postInsights('http_hi_failed', {
|
|
7050
|
+
api_key: _this4.key,
|
|
7051
|
+
err: e,
|
|
7052
|
+
client_request_id: client_request_id
|
|
7053
|
+
});
|
|
7054
|
+
}
|
|
7055
|
+
});
|
|
7056
|
+
}
|
|
6549
7057
|
/**
|
|
6550
7058
|
* queryUsers - Query users and watch user presence
|
|
6551
7059
|
*
|
|
@@ -6606,7 +7114,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6606
7114
|
}, _callee16, this);
|
|
6607
7115
|
}));
|
|
6608
7116
|
|
|
6609
|
-
function queryUsers(
|
|
7117
|
+
function queryUsers(_x16) {
|
|
6610
7118
|
return _queryUsers.apply(this, arguments);
|
|
6611
7119
|
}
|
|
6612
7120
|
|
|
@@ -6825,7 +7333,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6825
7333
|
}, _callee19, this);
|
|
6826
7334
|
}));
|
|
6827
7335
|
|
|
6828
|
-
function queryChannels(
|
|
7336
|
+
function queryChannels(_x17) {
|
|
6829
7337
|
return _queryChannels.apply(this, arguments);
|
|
6830
7338
|
}
|
|
6831
7339
|
|
|
@@ -6911,7 +7419,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6911
7419
|
}, _callee20, this);
|
|
6912
7420
|
}));
|
|
6913
7421
|
|
|
6914
|
-
function search(
|
|
7422
|
+
function search(_x18, _x19) {
|
|
6915
7423
|
return _search.apply(this, arguments);
|
|
6916
7424
|
}
|
|
6917
7425
|
|
|
@@ -6929,7 +7437,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6929
7437
|
}, {
|
|
6930
7438
|
key: "setLocalDevice",
|
|
6931
7439
|
value: function setLocalDevice(device) {
|
|
6932
|
-
if (this.wsConnection) {
|
|
7440
|
+
if (this.wsConnection || this.wsFallback) {
|
|
6933
7441
|
throw new Error('you can only set device before opening a websocket connection');
|
|
6934
7442
|
}
|
|
6935
7443
|
|
|
@@ -6971,7 +7479,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
6971
7479
|
}, _callee21, this);
|
|
6972
7480
|
}));
|
|
6973
7481
|
|
|
6974
|
-
function addDevice(_x21, _x22
|
|
7482
|
+
function addDevice(_x20, _x21, _x22) {
|
|
6975
7483
|
return _addDevice.apply(this, arguments);
|
|
6976
7484
|
}
|
|
6977
7485
|
|
|
@@ -7009,7 +7517,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7009
7517
|
}, _callee22, this);
|
|
7010
7518
|
}));
|
|
7011
7519
|
|
|
7012
|
-
function getDevices(
|
|
7520
|
+
function getDevices(_x23) {
|
|
7013
7521
|
return _getDevices.apply(this, arguments);
|
|
7014
7522
|
}
|
|
7015
7523
|
|
|
@@ -7049,7 +7557,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7049
7557
|
}, _callee23, this);
|
|
7050
7558
|
}));
|
|
7051
7559
|
|
|
7052
|
-
function removeDevice(
|
|
7560
|
+
function removeDevice(_x24, _x25) {
|
|
7053
7561
|
return _removeDevice.apply(this, arguments);
|
|
7054
7562
|
}
|
|
7055
7563
|
|
|
@@ -7090,7 +7598,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7090
7598
|
}, _callee24, this);
|
|
7091
7599
|
}));
|
|
7092
7600
|
|
|
7093
|
-
function getRateLimits(
|
|
7601
|
+
function getRateLimits(_x26) {
|
|
7094
7602
|
return _getRateLimits.apply(this, arguments);
|
|
7095
7603
|
}
|
|
7096
7604
|
|
|
@@ -7191,7 +7699,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7191
7699
|
}, _callee25, this);
|
|
7192
7700
|
}));
|
|
7193
7701
|
|
|
7194
|
-
function partialUpdateUser(
|
|
7702
|
+
function partialUpdateUser(_x27) {
|
|
7195
7703
|
return _partialUpdateUser.apply(this, arguments);
|
|
7196
7704
|
}
|
|
7197
7705
|
|
|
@@ -7277,7 +7785,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7277
7785
|
}, _callee26, this, [[2, 13, 16, 19]]);
|
|
7278
7786
|
}));
|
|
7279
7787
|
|
|
7280
|
-
function upsertUsers(
|
|
7788
|
+
function upsertUsers(_x28) {
|
|
7281
7789
|
return _upsertUsers.apply(this, arguments);
|
|
7282
7790
|
}
|
|
7283
7791
|
|
|
@@ -7390,7 +7898,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7390
7898
|
}, _callee27, this, [[1, 11, 14, 17]]);
|
|
7391
7899
|
}));
|
|
7392
7900
|
|
|
7393
|
-
function partialUpdateUsers(
|
|
7901
|
+
function partialUpdateUsers(_x29) {
|
|
7394
7902
|
return _partialUpdateUsers.apply(this, arguments);
|
|
7395
7903
|
}
|
|
7396
7904
|
|
|
@@ -7418,7 +7926,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7418
7926
|
}, _callee28, this);
|
|
7419
7927
|
}));
|
|
7420
7928
|
|
|
7421
|
-
function deleteUser(
|
|
7929
|
+
function deleteUser(_x30, _x31) {
|
|
7422
7930
|
return _deleteUser.apply(this, arguments);
|
|
7423
7931
|
}
|
|
7424
7932
|
|
|
@@ -7446,7 +7954,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7446
7954
|
}, _callee29, this);
|
|
7447
7955
|
}));
|
|
7448
7956
|
|
|
7449
|
-
function reactivateUser(
|
|
7957
|
+
function reactivateUser(_x32, _x33) {
|
|
7450
7958
|
return _reactivateUser.apply(this, arguments);
|
|
7451
7959
|
}
|
|
7452
7960
|
|
|
@@ -7474,7 +7982,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7474
7982
|
}, _callee30, this);
|
|
7475
7983
|
}));
|
|
7476
7984
|
|
|
7477
|
-
function deactivateUser(
|
|
7985
|
+
function deactivateUser(_x34, _x35) {
|
|
7478
7986
|
return _deactivateUser.apply(this, arguments);
|
|
7479
7987
|
}
|
|
7480
7988
|
|
|
@@ -7502,7 +8010,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7502
8010
|
}, _callee31, this);
|
|
7503
8011
|
}));
|
|
7504
8012
|
|
|
7505
|
-
function exportUser(
|
|
8013
|
+
function exportUser(_x36, _x37) {
|
|
7506
8014
|
return _exportUser.apply(this, arguments);
|
|
7507
8015
|
}
|
|
7508
8016
|
|
|
@@ -7551,7 +8059,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7551
8059
|
}, _callee32, this);
|
|
7552
8060
|
}));
|
|
7553
8061
|
|
|
7554
|
-
function banUser(
|
|
8062
|
+
function banUser(_x38, _x39) {
|
|
7555
8063
|
return _banUser.apply(this, arguments);
|
|
7556
8064
|
}
|
|
7557
8065
|
|
|
@@ -7588,7 +8096,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7588
8096
|
}, _callee33, this);
|
|
7589
8097
|
}));
|
|
7590
8098
|
|
|
7591
|
-
function unbanUser(
|
|
8099
|
+
function unbanUser(_x40, _x41) {
|
|
7592
8100
|
return _unbanUser.apply(this, arguments);
|
|
7593
8101
|
}
|
|
7594
8102
|
|
|
@@ -7625,7 +8133,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7625
8133
|
}, _callee34, this);
|
|
7626
8134
|
}));
|
|
7627
8135
|
|
|
7628
|
-
function shadowBan(
|
|
8136
|
+
function shadowBan(_x42, _x43) {
|
|
7629
8137
|
return _shadowBan.apply(this, arguments);
|
|
7630
8138
|
}
|
|
7631
8139
|
|
|
@@ -7662,7 +8170,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7662
8170
|
}, _callee35, this);
|
|
7663
8171
|
}));
|
|
7664
8172
|
|
|
7665
|
-
function removeShadowBan(
|
|
8173
|
+
function removeShadowBan(_x44, _x45) {
|
|
7666
8174
|
return _removeShadowBan.apply(this, arguments);
|
|
7667
8175
|
}
|
|
7668
8176
|
|
|
@@ -7705,7 +8213,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7705
8213
|
}, _callee36, this);
|
|
7706
8214
|
}));
|
|
7707
8215
|
|
|
7708
|
-
function muteUser(
|
|
8216
|
+
function muteUser(_x46, _x47) {
|
|
7709
8217
|
return _muteUser.apply(this, arguments);
|
|
7710
8218
|
}
|
|
7711
8219
|
|
|
@@ -7744,7 +8252,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7744
8252
|
}, _callee37, this);
|
|
7745
8253
|
}));
|
|
7746
8254
|
|
|
7747
|
-
function unmuteUser(
|
|
8255
|
+
function unmuteUser(_x48, _x49) {
|
|
7748
8256
|
return _unmuteUser.apply(this, arguments);
|
|
7749
8257
|
}
|
|
7750
8258
|
|
|
@@ -7803,7 +8311,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7803
8311
|
}, _callee38, this);
|
|
7804
8312
|
}));
|
|
7805
8313
|
|
|
7806
|
-
function flagMessage(
|
|
8314
|
+
function flagMessage(_x50) {
|
|
7807
8315
|
return _flagMessage.apply(this, arguments);
|
|
7808
8316
|
}
|
|
7809
8317
|
|
|
@@ -7843,7 +8351,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7843
8351
|
}, _callee39, this);
|
|
7844
8352
|
}));
|
|
7845
8353
|
|
|
7846
|
-
function flagUser(
|
|
8354
|
+
function flagUser(_x51) {
|
|
7847
8355
|
return _flagUser.apply(this, arguments);
|
|
7848
8356
|
}
|
|
7849
8357
|
|
|
@@ -7883,7 +8391,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7883
8391
|
}, _callee40, this);
|
|
7884
8392
|
}));
|
|
7885
8393
|
|
|
7886
|
-
function unflagMessage(
|
|
8394
|
+
function unflagMessage(_x52) {
|
|
7887
8395
|
return _unflagMessage.apply(this, arguments);
|
|
7888
8396
|
}
|
|
7889
8397
|
|
|
@@ -7923,7 +8431,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
7923
8431
|
}, _callee41, this);
|
|
7924
8432
|
}));
|
|
7925
8433
|
|
|
7926
|
-
function unflagUser(
|
|
8434
|
+
function unflagUser(_x53) {
|
|
7927
8435
|
return _unflagUser.apply(this, arguments);
|
|
7928
8436
|
}
|
|
7929
8437
|
|
|
@@ -8062,7 +8570,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8062
8570
|
}, _callee43, this);
|
|
8063
8571
|
}));
|
|
8064
8572
|
|
|
8065
|
-
function translateMessage(
|
|
8573
|
+
function translateMessage(_x54, _x55) {
|
|
8066
8574
|
return _translateMessage.apply(this, arguments);
|
|
8067
8575
|
}
|
|
8068
8576
|
|
|
@@ -8178,7 +8686,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8178
8686
|
case 2:
|
|
8179
8687
|
clonedMessage = _extends({}, message);
|
|
8180
8688
|
delete clonedMessage.id;
|
|
8181
|
-
reservedMessageFields = ['command', 'created_at', 'html', 'latest_reactions', 'own_reactions', 'reaction_counts', 'reply_count', 'type', 'updated_at', 'user', '__html'];
|
|
8689
|
+
reservedMessageFields = ['command', 'created_at', 'html', 'latest_reactions', 'own_reactions', 'quoted_message', 'reaction_counts', 'reply_count', 'type', 'updated_at', 'user', '__html'];
|
|
8182
8690
|
reservedMessageFields.forEach(function (item) {
|
|
8183
8691
|
if (clonedMessage[item] != null) {
|
|
8184
8692
|
delete clonedMessage[item];
|
|
@@ -8222,7 +8730,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8222
8730
|
}, _callee44, this);
|
|
8223
8731
|
}));
|
|
8224
8732
|
|
|
8225
|
-
function updateMessage(_x57, _x58
|
|
8733
|
+
function updateMessage(_x56, _x57, _x58) {
|
|
8226
8734
|
return _updateMessage.apply(this, arguments);
|
|
8227
8735
|
}
|
|
8228
8736
|
|
|
@@ -8283,7 +8791,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8283
8791
|
}, _callee45, this);
|
|
8284
8792
|
}));
|
|
8285
8793
|
|
|
8286
|
-
function partialUpdateMessage(_x60, _x61, _x62
|
|
8794
|
+
function partialUpdateMessage(_x59, _x60, _x61, _x62) {
|
|
8287
8795
|
return _partialUpdateMessage.apply(this, arguments);
|
|
8288
8796
|
}
|
|
8289
8797
|
|
|
@@ -8320,7 +8828,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8320
8828
|
}, _callee46, this);
|
|
8321
8829
|
}));
|
|
8322
8830
|
|
|
8323
|
-
function deleteMessage(
|
|
8831
|
+
function deleteMessage(_x63, _x64) {
|
|
8324
8832
|
return _deleteMessage.apply(this, arguments);
|
|
8325
8833
|
}
|
|
8326
8834
|
|
|
@@ -8348,7 +8856,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8348
8856
|
}, _callee47, this);
|
|
8349
8857
|
}));
|
|
8350
8858
|
|
|
8351
|
-
function getMessage(
|
|
8859
|
+
function getMessage(_x65) {
|
|
8352
8860
|
return _getMessage.apply(this, arguments);
|
|
8353
8861
|
}
|
|
8354
8862
|
|
|
@@ -8357,7 +8865,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8357
8865
|
}, {
|
|
8358
8866
|
key: "getUserAgent",
|
|
8359
8867
|
value: function getUserAgent() {
|
|
8360
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "4.
|
|
8868
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "4.5.0-beta.0");
|
|
8361
8869
|
}
|
|
8362
8870
|
}, {
|
|
8363
8871
|
key: "setUserAgent",
|
|
@@ -8371,7 +8879,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8371
8879
|
}, {
|
|
8372
8880
|
key: "_enrichAxiosOptions",
|
|
8373
8881
|
value: function _enrichAxiosOptions() {
|
|
8374
|
-
var
|
|
8882
|
+
var _options$headers;
|
|
8375
8883
|
|
|
8376
8884
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
8377
8885
|
params: {},
|
|
@@ -8381,15 +8889,24 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8381
8889
|
|
|
8382
8890
|
var token = this._getToken();
|
|
8383
8891
|
|
|
8892
|
+
var authorization = token ? {
|
|
8893
|
+
Authorization: token
|
|
8894
|
+
} : undefined;
|
|
8895
|
+
|
|
8896
|
+
if (!((_options$headers = options.headers) !== null && _options$headers !== void 0 && _options$headers['x-client-request-id'])) {
|
|
8897
|
+
options.headers = _objectSpread(_objectSpread({}, options.headers), {}, {
|
|
8898
|
+
'x-client-request-id': randomId()
|
|
8899
|
+
});
|
|
8900
|
+
}
|
|
8901
|
+
|
|
8384
8902
|
return _objectSpread({
|
|
8385
8903
|
params: _objectSpread(_objectSpread({
|
|
8386
8904
|
user_id: this.userID
|
|
8387
8905
|
}, options.params), {}, {
|
|
8388
8906
|
api_key: this.key,
|
|
8389
|
-
connection_id:
|
|
8907
|
+
connection_id: this._getConnectionID()
|
|
8390
8908
|
}),
|
|
8391
|
-
headers: _objectSpread({
|
|
8392
|
-
Authorization: token,
|
|
8909
|
+
headers: _objectSpread(_objectSpread({}, authorization), {}, {
|
|
8393
8910
|
'stream-auth-type': this.getAuthType(),
|
|
8394
8911
|
'X-Stream-Client': this.getUserAgent()
|
|
8395
8912
|
}, options.headers)
|
|
@@ -8419,6 +8936,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8419
8936
|
}
|
|
8420
8937
|
}, 500);
|
|
8421
8938
|
}
|
|
8939
|
+
/**
|
|
8940
|
+
* encode ws url payload
|
|
8941
|
+
* @private
|
|
8942
|
+
* @returns json string
|
|
8943
|
+
*/
|
|
8944
|
+
|
|
8422
8945
|
}, {
|
|
8423
8946
|
key: "verifyWebhook",
|
|
8424
8947
|
value: function verifyWebhook(requestBody, xSignature) {
|
|
@@ -8559,7 +9082,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8559
9082
|
}, _callee48, this);
|
|
8560
9083
|
}));
|
|
8561
9084
|
|
|
8562
|
-
function sendUserCustomEvent(
|
|
9085
|
+
function sendUserCustomEvent(_x66, _x67) {
|
|
8563
9086
|
return _sendUserCustomEvent.apply(this, arguments);
|
|
8564
9087
|
}
|
|
8565
9088
|
|
|
@@ -8647,7 +9170,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8647
9170
|
}, _callee49, this);
|
|
8648
9171
|
}));
|
|
8649
9172
|
|
|
8650
|
-
function createSegment(
|
|
9173
|
+
function createSegment(_x68) {
|
|
8651
9174
|
return _createSegment.apply(this, arguments);
|
|
8652
9175
|
}
|
|
8653
9176
|
|
|
@@ -8687,7 +9210,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8687
9210
|
}, _callee50, this);
|
|
8688
9211
|
}));
|
|
8689
9212
|
|
|
8690
|
-
function getSegment(
|
|
9213
|
+
function getSegment(_x69) {
|
|
8691
9214
|
return _getSegment.apply(this, arguments);
|
|
8692
9215
|
}
|
|
8693
9216
|
|
|
@@ -8726,7 +9249,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8726
9249
|
}, _callee51, this);
|
|
8727
9250
|
}));
|
|
8728
9251
|
|
|
8729
|
-
function listSegments(
|
|
9252
|
+
function listSegments(_x70) {
|
|
8730
9253
|
return _listSegments.apply(this, arguments);
|
|
8731
9254
|
}
|
|
8732
9255
|
|
|
@@ -8769,7 +9292,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8769
9292
|
}, _callee52, this);
|
|
8770
9293
|
}));
|
|
8771
9294
|
|
|
8772
|
-
function updateSegment(
|
|
9295
|
+
function updateSegment(_x71, _x72) {
|
|
8773
9296
|
return _updateSegment.apply(this, arguments);
|
|
8774
9297
|
}
|
|
8775
9298
|
|
|
@@ -8801,7 +9324,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8801
9324
|
}, _callee53, this);
|
|
8802
9325
|
}));
|
|
8803
9326
|
|
|
8804
|
-
function deleteSegment(
|
|
9327
|
+
function deleteSegment(_x73) {
|
|
8805
9328
|
return _deleteSegment.apply(this, arguments);
|
|
8806
9329
|
}
|
|
8807
9330
|
|
|
@@ -8843,7 +9366,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8843
9366
|
}, _callee54, this);
|
|
8844
9367
|
}));
|
|
8845
9368
|
|
|
8846
|
-
function createCampaign(
|
|
9369
|
+
function createCampaign(_x74) {
|
|
8847
9370
|
return _createCampaign.apply(this, arguments);
|
|
8848
9371
|
}
|
|
8849
9372
|
|
|
@@ -8883,7 +9406,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8883
9406
|
}, _callee55, this);
|
|
8884
9407
|
}));
|
|
8885
9408
|
|
|
8886
|
-
function getCampaign(
|
|
9409
|
+
function getCampaign(_x75) {
|
|
8887
9410
|
return _getCampaign.apply(this, arguments);
|
|
8888
9411
|
}
|
|
8889
9412
|
|
|
@@ -8922,7 +9445,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8922
9445
|
}, _callee56, this);
|
|
8923
9446
|
}));
|
|
8924
9447
|
|
|
8925
|
-
function listCampaigns(
|
|
9448
|
+
function listCampaigns(_x76) {
|
|
8926
9449
|
return _listCampaigns.apply(this, arguments);
|
|
8927
9450
|
}
|
|
8928
9451
|
|
|
@@ -8965,7 +9488,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8965
9488
|
}, _callee57, this);
|
|
8966
9489
|
}));
|
|
8967
9490
|
|
|
8968
|
-
function updateCampaign(
|
|
9491
|
+
function updateCampaign(_x77, _x78) {
|
|
8969
9492
|
return _updateCampaign.apply(this, arguments);
|
|
8970
9493
|
}
|
|
8971
9494
|
|
|
@@ -8997,7 +9520,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8997
9520
|
}, _callee58, this);
|
|
8998
9521
|
}));
|
|
8999
9522
|
|
|
9000
|
-
function deleteCampaign(
|
|
9523
|
+
function deleteCampaign(_x79) {
|
|
9001
9524
|
return _deleteCampaign.apply(this, arguments);
|
|
9002
9525
|
}
|
|
9003
9526
|
|
|
@@ -9041,7 +9564,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9041
9564
|
}, _callee59, this);
|
|
9042
9565
|
}));
|
|
9043
9566
|
|
|
9044
|
-
function scheduleCampaign(
|
|
9567
|
+
function scheduleCampaign(_x80, _x81) {
|
|
9045
9568
|
return _scheduleCampaign.apply(this, arguments);
|
|
9046
9569
|
}
|
|
9047
9570
|
|
|
@@ -9081,7 +9604,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9081
9604
|
}, _callee60, this);
|
|
9082
9605
|
}));
|
|
9083
9606
|
|
|
9084
|
-
function stopCampaign(
|
|
9607
|
+
function stopCampaign(_x82) {
|
|
9085
9608
|
return _stopCampaign.apply(this, arguments);
|
|
9086
9609
|
}
|
|
9087
9610
|
|
|
@@ -9121,7 +9644,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9121
9644
|
}, _callee61, this);
|
|
9122
9645
|
}));
|
|
9123
9646
|
|
|
9124
|
-
function resumeCampaign(
|
|
9647
|
+
function resumeCampaign(_x83) {
|
|
9125
9648
|
return _resumeCampaign.apply(this, arguments);
|
|
9126
9649
|
}
|
|
9127
9650
|
|
|
@@ -9164,7 +9687,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9164
9687
|
}, _callee62, this);
|
|
9165
9688
|
}));
|
|
9166
9689
|
|
|
9167
|
-
function testCampaign(
|
|
9690
|
+
function testCampaign(_x84, _x85) {
|
|
9168
9691
|
return _testCampaign.apply(this, arguments);
|
|
9169
9692
|
}
|
|
9170
9693
|
|
|
@@ -9197,7 +9720,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9197
9720
|
}, _callee63, this);
|
|
9198
9721
|
}));
|
|
9199
9722
|
|
|
9200
|
-
function enrichURL(
|
|
9723
|
+
function enrichURL(_x86) {
|
|
9201
9724
|
return _enrichURL.apply(this, arguments);
|
|
9202
9725
|
}
|
|
9203
9726
|
|
|
@@ -9229,7 +9752,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9229
9752
|
}, _callee64, this);
|
|
9230
9753
|
}));
|
|
9231
9754
|
|
|
9232
|
-
function getTask(
|
|
9755
|
+
function getTask(_x87) {
|
|
9233
9756
|
return _getTask.apply(this, arguments);
|
|
9234
9757
|
}
|
|
9235
9758
|
|
|
@@ -9271,15 +9794,12 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9271
9794
|
}, _callee65, this);
|
|
9272
9795
|
}));
|
|
9273
9796
|
|
|
9274
|
-
function deleteChannels(
|
|
9797
|
+
function deleteChannels(_x88) {
|
|
9275
9798
|
return _deleteChannels.apply(this, arguments);
|
|
9276
9799
|
}
|
|
9277
9800
|
|
|
9278
9801
|
return deleteChannels;
|
|
9279
9802
|
}()
|
|
9280
|
-
}, {
|
|
9281
|
-
key: "deleteUsers",
|
|
9282
|
-
value:
|
|
9283
9803
|
/**
|
|
9284
9804
|
* deleteUsers - Batch Delete Users
|
|
9285
9805
|
*
|
|
@@ -9288,7 +9808,10 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9288
9808
|
*
|
|
9289
9809
|
* @return {APIResponse} A task ID
|
|
9290
9810
|
*/
|
|
9291
|
-
|
|
9811
|
+
|
|
9812
|
+
}, {
|
|
9813
|
+
key: "deleteUsers",
|
|
9814
|
+
value: function () {
|
|
9292
9815
|
var _deleteUsers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee66(user_ids, options) {
|
|
9293
9816
|
return _regeneratorRuntime.wrap(function _callee66$(_context66) {
|
|
9294
9817
|
while (1) {
|
|
@@ -9334,7 +9857,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
9334
9857
|
}, _callee66, this);
|
|
9335
9858
|
}));
|
|
9336
9859
|
|
|
9337
|
-
function deleteUsers(
|
|
9860
|
+
function deleteUsers(_x89, _x90) {
|
|
9338
9861
|
return _deleteUsers.apply(this, arguments);
|
|
9339
9862
|
}
|
|
9340
9863
|
|
|
@@ -9434,5 +9957,5 @@ var BuiltinPermissions = {
|
|
|
9434
9957
|
UseFrozenChannel: 'Send messages and reactions to frozen channels'
|
|
9435
9958
|
};
|
|
9436
9959
|
|
|
9437
|
-
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 };
|
|
9960
|
+
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 };
|
|
9438
9961
|
//# sourceMappingURL=browser.es.js.map
|