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