qiscus-sdk-core 2.13.3 → 2.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/qiscus-sdk-core.js +485 -239
- package/dist/qiscus-sdk-core.js.map +1 -1
- package/dist/qiscus-sdk-core.min.js +3 -3
- package/dist/qiscus-sdk-core.min.js.map +1 -1
- package/lib/index.js +238 -108
- package/lib/lib/adapters/custom-event.js +3 -3
- package/lib/lib/adapters/expired-token.js +4 -5
- package/lib/lib/adapters/http.js +156 -82
- package/lib/lib/adapters/mqtt.js +51 -25
- package/lib/lib/adapters/sync.js +20 -7
- package/package.json +1 -1
package/dist/qiscus-sdk-core.js
CHANGED
|
@@ -29966,7 +29966,7 @@ function extend() {
|
|
|
29966
29966
|
/*! exports provided: name, version, description, license, main, browser, unpkg, files, scripts, devDependencies, dependencies, babel, prettier, engines, packageManager, default */
|
|
29967
29967
|
/***/ (function(module) {
|
|
29968
29968
|
|
|
29969
|
-
module.exports = JSON.parse("{\"name\":\"qiscus-sdk-core\",\"version\":\"2.
|
|
29969
|
+
module.exports = JSON.parse("{\"name\":\"qiscus-sdk-core\",\"version\":\"2.14.1\",\"description\":\"Qiscus Web SDK Core\",\"license\":\"MIT\",\"main\":\"lib/index.js\",\"browser\":\"dist/qiscus-sdk-core.min.js\",\"unpkg\":\"dist/qiscus-sdk-core.min.js\",\"files\":[\"lib\",\"dist\"],\"scripts\":{\"build\":\"npm-run-all --parallel build:node build:web build:web:dev\",\"build:dev\":\"npm-run-all --parallel build:node build:web:dev\",\"build:dev:watch\":\"npm-run-all --parallel build:web:watch serve\",\"build:node\":\"babel -d lib src\",\"build:node:watch\":\"babel -w -d lib src\",\"build:web\":\"webpack --env.production --env.target=web\",\"build:web:dev\":\"webpack --env.development --env.target=web\",\"build:web:watch\":\"webpack --env.development --env.target=web --watch\",\"dev\":\"webpack --env.development --progress --colors --watch\",\"watch\":\"npm-run-all build:web:watch build:node:watch\",\"test\":\"mocha --require @babel/register --colors 'test/**/*test.js'\",\"test:watch\":\"npm run test -- -w\",\"clean\":\"rimraf dist lib\",\"preversion\":\"npm-run-all clean build\",\"prepublishOnly\":\"npm-run-all clean build\",\"serve\":\"http-server -p 1234 -c-1 dist\",\"dev:serve\":\"run-p serve watch\",\"release:patch\":\"np patch --any-branch --yolo\"},\"devDependencies\":{\"@babel/cli\":\"^7.10.5\",\"@babel/core\":\"^7.11.4\",\"@babel/plugin-proposal-class-properties\":\"^7.10.4\",\"@babel/plugin-transform-runtime\":\"^7.11.0\",\"@babel/polyfill\":\"^7.10.4\",\"@babel/preset-env\":\"^7.11.0\",\"@babel/register\":\"^7.10.5\",\"@commitlint/cli\":\"^8.3.5\",\"@commitlint/config-conventional\":\"^8.3.4\",\"babel-eslint\":\"^8.2.6\",\"babel-loader\":\"^8.0.6\",\"babel-plugin-add-module-exports\":\"^1.0.2\",\"babel-plugin-date-fns\":\"^0.1.0\",\"chai\":\"^4.2.0\",\"chai-spies\":\"^1.0.0\",\"eslint\":\"5.0.0\",\"eslint-config-standard\":\"^12.0.0\",\"eslint-loader\":\"^2.2.1\",\"eslint-plugin-import\":\"^2.22.0\",\"eslint-plugin-node\":\"^8.0.1\",\"eslint-plugin-promise\":\"^4.2.1\",\"eslint-plugin-standard\":\"^4.0.1\",\"http-server\":\"^0.12.3\",\"mocha\":\"^5.2.0\",\"np\":\"^8.0.4\",\"npm-run-all\":\"^4.1.5\",\"rimraf\":\"^2.7.1\",\"serve\":\"^12.0.0\",\"webpack\":\"^4.44.1\",\"webpack-cli\":\"^3.3.12\"},\"dependencies\":{\"@babel/runtime\":\"^7.11.2\",\"date-fns\":\"^1.30.1\",\"is_js\":\"^0.9.0\",\"lodash.debounce\":\"^4.0.8\",\"lodash.throttle\":\"^4.1.1\",\"mitt\":\"^1.2.0\",\"mqtt\":\"~4.2.6\",\"superagent\":\"^3.8.3\"},\"babel\":{\"presets\":[[\"@babel/preset-env\",{\"modules\":\"auto\"}]],\"plugins\":[\"@babel/plugin-transform-runtime\",\"@babel/plugin-proposal-class-properties\",\"babel-plugin-add-module-exports\"]},\"prettier\":{\"semi\":false,\"singleQuote\":true,\"trailingComma\":\"es5\"},\"engines\":{\"node\":\"16.15.1\"},\"packageManager\":\"pnpm@8.15.9\"}");
|
|
29970
29970
|
|
|
29971
29971
|
/***/ }),
|
|
29972
29972
|
|
|
@@ -30067,6 +30067,9 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
30067
30067
|
function QiscusSDK() {
|
|
30068
30068
|
var _this = this;
|
|
30069
30069
|
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_2___default()(this, QiscusSDK);
|
|
30070
|
+
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_4___default()(this, "_pendingComments", []);
|
|
30071
|
+
// count of how much does a comment has been retried
|
|
30072
|
+
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_4___default()(this, "_pendingCommentsCount", {});
|
|
30070
30073
|
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_4___default()(this, "_readComment", function (roomId, commentId) {
|
|
30071
30074
|
return _this._updateStatus(roomId, commentId);
|
|
30072
30075
|
});
|
|
@@ -30478,9 +30481,14 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
30478
30481
|
_this2.events.emit('room-cleared', room);
|
|
30479
30482
|
});
|
|
30480
30483
|
});
|
|
30484
|
+
this.syncAdapter.on('synchronize', function () {
|
|
30485
|
+
_this2._pendingComments.forEach(function (m) {
|
|
30486
|
+
return _this2._retrySendComment(m);
|
|
30487
|
+
});
|
|
30488
|
+
});
|
|
30481
30489
|
this.customEventAdapter = Object(_lib_adapters_custom_event__WEBPACK_IMPORTED_MODULE_18__["default"])(this.realtimeAdapter, this.user_id);
|
|
30482
30490
|
this.setEventListeners();
|
|
30483
|
-
case
|
|
30491
|
+
case 56:
|
|
30484
30492
|
case "end":
|
|
30485
30493
|
return _context3.stop();
|
|
30486
30494
|
}
|
|
@@ -30657,6 +30665,9 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
30657
30665
|
version: _this3.version,
|
|
30658
30666
|
getCustomHeader: function getCustomHeader() {
|
|
30659
30667
|
return _this3._customHeader;
|
|
30668
|
+
},
|
|
30669
|
+
expiredTokenAdapterGetter: function expiredTokenAdapterGetter() {
|
|
30670
|
+
return _this3.expiredTokenAdapter;
|
|
30660
30671
|
}
|
|
30661
30672
|
});
|
|
30662
30673
|
_this3.HTTPAdapter.setToken(_this3.userData.token);
|
|
@@ -30666,15 +30677,18 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
30666
30677
|
refreshToken: user.refresh_token,
|
|
30667
30678
|
expiredAt: user.token_expires_at,
|
|
30668
30679
|
userId: _this3.user_id,
|
|
30669
|
-
onTokenRefreshed: function onTokenRefreshed(token, refreshToken, expiredAt) {
|
|
30680
|
+
onTokenRefreshed: function onTokenRefreshed(token, refreshToken, expiredAt, oldToken) {
|
|
30670
30681
|
_this3.userData.token = token;
|
|
30671
30682
|
_this3.userData.refresh_token = refreshToken;
|
|
30672
30683
|
_this3.userData.token_expires_at = expiredAt === null || expiredAt === void 0 ? void 0 : expiredAt.toJSON();
|
|
30673
30684
|
_this3.events.emit('token-refreshed', {
|
|
30674
30685
|
token: token,
|
|
30675
30686
|
refreshToken: refreshToken,
|
|
30676
|
-
expiredAt: expiredAt
|
|
30687
|
+
expiredAt: expiredAt,
|
|
30688
|
+
oldToken: oldToken
|
|
30677
30689
|
});
|
|
30690
|
+
_this3.realtimeAdapter.unsusbcribeUserChannelByToken(oldToken);
|
|
30691
|
+
_this3.realtimeAdapter.subscribeUserChannelByToken(token);
|
|
30678
30692
|
},
|
|
30679
30693
|
getAuthenticationStatus: function getAuthenticationStatus() {
|
|
30680
30694
|
return _this3.user_id != null && _this3.isLogin;
|
|
@@ -31621,7 +31635,7 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
31621
31635
|
}, {
|
|
31622
31636
|
key: "sendComment",
|
|
31623
31637
|
value: (function () {
|
|
31624
|
-
var _sendComment = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function
|
|
31638
|
+
var _sendComment = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function _callee15(topicId, commentMessage, uniqueId) {
|
|
31625
31639
|
var _this13 = this;
|
|
31626
31640
|
var type,
|
|
31627
31641
|
payload,
|
|
@@ -31633,13 +31647,23 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
31633
31647
|
repliedMessage,
|
|
31634
31648
|
extrasToBeSubmitted,
|
|
31635
31649
|
messageData,
|
|
31636
|
-
|
|
31637
|
-
|
|
31638
|
-
|
|
31650
|
+
sendComment,
|
|
31651
|
+
_this$options$comment,
|
|
31652
|
+
_this$options,
|
|
31653
|
+
res,
|
|
31654
|
+
commentIndex,
|
|
31655
|
+
_error$message$toLowe,
|
|
31656
|
+
_error$message,
|
|
31657
|
+
whitelistedErrorStatus,
|
|
31658
|
+
message,
|
|
31659
|
+
isOffline,
|
|
31660
|
+
_args15 = arguments;
|
|
31661
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function _callee15$(_context15) {
|
|
31662
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
31639
31663
|
case 0:
|
|
31640
|
-
type =
|
|
31641
|
-
payload =
|
|
31642
|
-
extras =
|
|
31664
|
+
type = _args15.length > 3 && _args15[3] !== undefined ? _args15[3] : 'text';
|
|
31665
|
+
payload = _args15.length > 4 ? _args15[4] : undefined;
|
|
31666
|
+
extras = _args15.length > 5 ? _args15[5] : undefined;
|
|
31643
31667
|
self = this; // set extra data, etc
|
|
31644
31668
|
if (self.options.prePostCommentCallback) {
|
|
31645
31669
|
self.options.prePostCommentCallback(commentMessage);
|
|
@@ -31655,6 +31679,7 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
31655
31679
|
}
|
|
31656
31680
|
self.pendingCommentId--;
|
|
31657
31681
|
commentData = {
|
|
31682
|
+
room_id: topicId,
|
|
31658
31683
|
message: commentMessage,
|
|
31659
31684
|
username_as: this.username,
|
|
31660
31685
|
username_real: this.user_id,
|
|
@@ -31683,64 +31708,169 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
31683
31708
|
pendingComment.payload = parsedPayload;
|
|
31684
31709
|
}
|
|
31685
31710
|
extrasToBeSubmitted = extras || self.extras;
|
|
31686
|
-
|
|
31711
|
+
_context15.next = 13;
|
|
31687
31712
|
return this._hookAdapter.trigger(_lib_adapters_hook__WEBPACK_IMPORTED_MODULE_23__["Hooks"].MESSAGE_BEFORE_SENT, _objectSpread(_objectSpread({}, pendingComment), {}, {
|
|
31688
31713
|
extras: extrasToBeSubmitted
|
|
31689
31714
|
}));
|
|
31690
31715
|
case 13:
|
|
31691
|
-
messageData =
|
|
31716
|
+
messageData = _context15.sent;
|
|
31692
31717
|
messageData = self.prepareCommentToBeSubmitted(messageData);
|
|
31693
31718
|
if (self.selected) self.selected.comments.push(messageData);
|
|
31694
|
-
|
|
31695
|
-
|
|
31696
|
-
|
|
31697
|
-
|
|
31719
|
+
sendComment = function sendComment() {
|
|
31720
|
+
return _this13.userAdapter.postComment('' + topicId, messageData.message, messageData.unique_id, messageData.type, messageData.payload, messageData.extras);
|
|
31721
|
+
};
|
|
31722
|
+
_context15.prev = 17;
|
|
31723
|
+
_context15.next = 20;
|
|
31724
|
+
return sendComment();
|
|
31725
|
+
case 20:
|
|
31726
|
+
res = _context15.sent;
|
|
31727
|
+
_context15.next = 23;
|
|
31728
|
+
return this._hookAdapter.trigger(_lib_adapters_hook__WEBPACK_IMPORTED_MODULE_23__["Hooks"].MESSAGE_BEFORE_RECEIVED, res);
|
|
31729
|
+
case 23:
|
|
31730
|
+
res = _context15.sent;
|
|
31731
|
+
Object.assign(messageData, res);
|
|
31732
|
+
if (self.selected) {
|
|
31733
|
+
_context15.next = 27;
|
|
31734
|
+
break;
|
|
31735
|
+
}
|
|
31736
|
+
return _context15.abrupt("return", Promise.resolve(messageData));
|
|
31737
|
+
case 27:
|
|
31738
|
+
// When the posting succeeded, we mark the Comment as sent,
|
|
31739
|
+
// so all the interested party can be notified.
|
|
31740
|
+
messageData.markAsSent();
|
|
31741
|
+
messageData.id = res.id;
|
|
31742
|
+
messageData.before_id = res.comment_before_id;
|
|
31743
|
+
// update the timestamp also then re-sort the comment list
|
|
31744
|
+
messageData.unix_timestamp = res.unix_timestamp;
|
|
31745
|
+
(_this$options$comment = (_this$options = this.options).commentSentCallback) === null || _this$options$comment === void 0 || _this$options$comment.call(_this$options, {
|
|
31746
|
+
comment: messageData
|
|
31747
|
+
});
|
|
31748
|
+
self.events.emit('comment-sent', messageData);
|
|
31749
|
+
self.sortComments();
|
|
31750
|
+
commentIndex = self._pendingComments.findIndex(function (c) {
|
|
31751
|
+
return c.unique_id === messageData.unique_id;
|
|
31752
|
+
});
|
|
31753
|
+
if (commentIndex > -1) {
|
|
31754
|
+
self._pendingComments.splice(commentIndex, 1);
|
|
31755
|
+
}
|
|
31756
|
+
return _context15.abrupt("return", messageData);
|
|
31757
|
+
case 39:
|
|
31758
|
+
_context15.prev = 39;
|
|
31759
|
+
_context15.t0 = _context15["catch"](17);
|
|
31760
|
+
messageData.markAsFailed();
|
|
31761
|
+
// From superagent: `https://forwardemail.github.io/superagent/#retrying-requests`
|
|
31762
|
+
whitelistedErrorStatus = [undefined, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524];
|
|
31763
|
+
message = (_error$message$toLowe = (_error$message = _context15.t0.message) === null || _error$message === void 0 ? void 0 : _error$message.toLowerCase()) !== null && _error$message$toLowe !== void 0 ? _error$message$toLowe : '';
|
|
31764
|
+
isOffline = message.includes('offline');
|
|
31765
|
+
if (whitelistedErrorStatus.includes(_context15.t0.status) || isOffline) {
|
|
31766
|
+
this._pendingComments.push(messageData);
|
|
31767
|
+
this.logger('Failed sending comment', _context15.t0);
|
|
31768
|
+
}
|
|
31769
|
+
return _context15.abrupt("return", Promise.reject(_context15.t0));
|
|
31770
|
+
case 47:
|
|
31771
|
+
case "end":
|
|
31772
|
+
return _context15.stop();
|
|
31773
|
+
}
|
|
31774
|
+
}, _callee15, this, [[17, 39]]);
|
|
31775
|
+
}));
|
|
31776
|
+
function sendComment(_x12, _x13, _x14) {
|
|
31777
|
+
return _sendComment.apply(this, arguments);
|
|
31778
|
+
}
|
|
31779
|
+
return sendComment;
|
|
31780
|
+
}())
|
|
31781
|
+
}, {
|
|
31782
|
+
key: "_retrySendComment",
|
|
31783
|
+
value: function () {
|
|
31784
|
+
var _retrySendComment2 = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function _callee17(comment) {
|
|
31785
|
+
var _this$_pendingComment,
|
|
31786
|
+
_this14 = this;
|
|
31787
|
+
var _this$options$comment2, _this$options2, index;
|
|
31788
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function _callee17$(_context17) {
|
|
31789
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
31790
|
+
case 0:
|
|
31791
|
+
this.logger('Retrying send comment', comment);
|
|
31792
|
+
this._pendingCommentsCount[comment.unique_id] = ((_this$_pendingComment = this._pendingCommentsCount[comment.unique_id]) !== null && _this$_pendingComment !== void 0 ? _this$_pendingComment : 0) + 1;
|
|
31793
|
+
|
|
31794
|
+
// If it is exceeding the maximum retry count (which is 10), we will not retry anymore
|
|
31795
|
+
if (!(this._pendingCommentsCount[comment.unique_id] > 10)) {
|
|
31796
|
+
_context17.next = 10;
|
|
31797
|
+
break;
|
|
31798
|
+
}
|
|
31799
|
+
this.logger("Exceeding maximum retry count for comment ".concat(comment.unique_id, ", not retrying anymore"));
|
|
31800
|
+
(_this$options$comment2 = (_this$options2 = this.options).commentRetryExceedCallback) === null || _this$options$comment2 === void 0 || _this$options$comment2.call(_this$options2, comment);
|
|
31801
|
+
// Remove the comment from pending comments
|
|
31802
|
+
index = this._pendingComments.findIndex(function (c) {
|
|
31803
|
+
return c.unique_id === comment.unique_id;
|
|
31804
|
+
});
|
|
31805
|
+
if (index > -1) {
|
|
31806
|
+
this._pendingComments.splice(index, 1);
|
|
31807
|
+
}
|
|
31808
|
+
// Mark the comment as failed
|
|
31809
|
+
comment.markAsFailed();
|
|
31810
|
+
// Emit the event
|
|
31811
|
+
this.events.emit('comment-retry-exceed', comment);
|
|
31812
|
+
return _context17.abrupt("return", Promise.reject(new Error('Exceeding maximum retry count')));
|
|
31813
|
+
case 10:
|
|
31814
|
+
return _context17.abrupt("return", this.userAdapter.postComment('' + comment.room_id, comment.message, comment.unique_id, comment.type, comment.payload, comment.extras).then(/*#__PURE__*/function () {
|
|
31815
|
+
var _ref12 = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function _callee16(res) {
|
|
31816
|
+
var _this14$selected, _this14$selected2, _this14$options$comme, _this14$options;
|
|
31817
|
+
var index, commentIndex;
|
|
31818
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function _callee16$(_context16) {
|
|
31819
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
31698
31820
|
case 0:
|
|
31699
|
-
|
|
31700
|
-
|
|
31701
|
-
case 2:
|
|
31702
|
-
res = _context15.sent;
|
|
31703
|
-
Object.assign(messageData, res);
|
|
31704
|
-
if (self.selected) {
|
|
31705
|
-
_context15.next = 6;
|
|
31821
|
+
if (!(((_this14$selected = _this14.selected) === null || _this14$selected === void 0 ? void 0 : _this14$selected.id) !== comment.room_id)) {
|
|
31822
|
+
_context16.next = 2;
|
|
31706
31823
|
break;
|
|
31707
31824
|
}
|
|
31708
|
-
return
|
|
31709
|
-
case
|
|
31710
|
-
|
|
31711
|
-
|
|
31712
|
-
|
|
31713
|
-
|
|
31714
|
-
|
|
31715
|
-
|
|
31716
|
-
|
|
31717
|
-
|
|
31718
|
-
|
|
31719
|
-
|
|
31825
|
+
return _context16.abrupt("return", res);
|
|
31826
|
+
case 2:
|
|
31827
|
+
Object.assign(comment, res);
|
|
31828
|
+
comment.markAsSent();
|
|
31829
|
+
comment.id = res.id;
|
|
31830
|
+
comment.before_id = res.comment_before_id;
|
|
31831
|
+
comment.unix_timestamp = res.unix_timestamp;
|
|
31832
|
+
index = (_this14$selected2 = _this14.selected) === null || _this14$selected2 === void 0 ? void 0 : _this14$selected2.comments.findIndex(function (c) {
|
|
31833
|
+
return c.unique_id === comment.unique_id;
|
|
31834
|
+
});
|
|
31835
|
+
if (index > -1) {
|
|
31836
|
+
_this14.selected.comments[index] = comment;
|
|
31837
|
+
}
|
|
31838
|
+
_this14.sortComments();
|
|
31839
|
+
(_this14$options$comme = (_this14$options = _this14.options).commentSentCallback) === null || _this14$options$comme === void 0 || _this14$options$comme.call(_this14$options, {
|
|
31840
|
+
comment: comment
|
|
31841
|
+
});
|
|
31842
|
+
_this14.events.emit('comment-sent', comment);
|
|
31843
|
+
commentIndex = _this14._pendingComments.findIndex(function (c) {
|
|
31844
|
+
return c.unique_id === comment.unique_id;
|
|
31845
|
+
});
|
|
31846
|
+
if (commentIndex > -1) {
|
|
31847
|
+
_this14._pendingComments.splice(commentIndex, 1);
|
|
31848
|
+
}
|
|
31849
|
+
return _context16.abrupt("return", comment);
|
|
31850
|
+
case 15:
|
|
31720
31851
|
case "end":
|
|
31721
|
-
return
|
|
31852
|
+
return _context16.stop();
|
|
31722
31853
|
}
|
|
31723
|
-
},
|
|
31854
|
+
}, _callee16);
|
|
31724
31855
|
}));
|
|
31725
|
-
return function (
|
|
31856
|
+
return function (_x16) {
|
|
31726
31857
|
return _ref12.apply(this, arguments);
|
|
31727
31858
|
};
|
|
31728
31859
|
}())["catch"](function (err) {
|
|
31729
|
-
|
|
31860
|
+
comment.markAsFailed();
|
|
31730
31861
|
return Promise.reject(err);
|
|
31731
31862
|
}));
|
|
31732
|
-
case
|
|
31863
|
+
case 11:
|
|
31733
31864
|
case "end":
|
|
31734
|
-
return
|
|
31865
|
+
return _context17.stop();
|
|
31735
31866
|
}
|
|
31736
|
-
},
|
|
31867
|
+
}, _callee17, this);
|
|
31737
31868
|
}));
|
|
31738
|
-
function
|
|
31739
|
-
return
|
|
31869
|
+
function _retrySendComment(_x15) {
|
|
31870
|
+
return _retrySendComment2.apply(this, arguments);
|
|
31740
31871
|
}
|
|
31741
|
-
return
|
|
31872
|
+
return _retrySendComment;
|
|
31742
31873
|
}() // #endregion
|
|
31743
|
-
)
|
|
31744
31874
|
}, {
|
|
31745
31875
|
key: "getUsers",
|
|
31746
31876
|
value: function getUsers() {
|
|
@@ -31918,12 +32048,12 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
31918
32048
|
}, {
|
|
31919
32049
|
key: "removeParticipantsFromGroup",
|
|
31920
32050
|
value: function removeParticipantsFromGroup(roomId, emails) {
|
|
31921
|
-
var
|
|
32051
|
+
var _this15 = this;
|
|
31922
32052
|
if (is_js__WEBPACK_IMPORTED_MODULE_8___default.a.not.array(emails)) {
|
|
31923
32053
|
return Promise.reject(new Error('`emails` must have type of array'));
|
|
31924
32054
|
}
|
|
31925
32055
|
return this.roomAdapter.removeParticipantsFromGroup(roomId, emails).then(function (res) {
|
|
31926
|
-
|
|
32056
|
+
_this15.events.emit('participants-removed', emails);
|
|
31927
32057
|
return Promise.resolve(res);
|
|
31928
32058
|
});
|
|
31929
32059
|
}
|
|
@@ -32086,12 +32216,12 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32086
32216
|
}, {
|
|
32087
32217
|
key: "deleteComment",
|
|
32088
32218
|
value: function deleteComment(roomId, commentUniqueIds, isForEveryone, isHard) {
|
|
32089
|
-
var
|
|
32219
|
+
var _this16 = this;
|
|
32090
32220
|
if (!Array.isArray(commentUniqueIds)) {
|
|
32091
32221
|
throw new Error("unique ids' must be type of Array");
|
|
32092
32222
|
}
|
|
32093
32223
|
return this.userAdapter.deleteComment(roomId, commentUniqueIds, isForEveryone, isHard).then(function (res) {
|
|
32094
|
-
|
|
32224
|
+
_this16.events.emit('comment-deleted', {
|
|
32095
32225
|
roomId: roomId,
|
|
32096
32226
|
commentUniqueIds: commentUniqueIds,
|
|
32097
32227
|
isForEveryone: isForEveryone,
|
|
@@ -32105,7 +32235,7 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32105
32235
|
}, {
|
|
32106
32236
|
key: "clearRoomsCache",
|
|
32107
32237
|
value: function clearRoomsCache() {
|
|
32108
|
-
var
|
|
32238
|
+
var _this17 = this;
|
|
32109
32239
|
// remove all room except currently selected
|
|
32110
32240
|
if (this.selected) {
|
|
32111
32241
|
// clear the map
|
|
@@ -32113,14 +32243,14 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32113
32243
|
// get current index and array length
|
|
32114
32244
|
var roomLength = this.rooms.length;
|
|
32115
32245
|
var curIndex = this.rooms.findIndex(function (room) {
|
|
32116
|
-
return room.id ===
|
|
32246
|
+
return room.id === _this17.selected.id;
|
|
32117
32247
|
});
|
|
32118
32248
|
if (!(curIndex + 1 === roomLength)) {
|
|
32119
32249
|
this.rooms.splice(curIndex + 1, roomLength - (curIndex + 1));
|
|
32120
32250
|
}
|
|
32121
32251
|
// ambil ulang cur index nya, klo udah di awal ga perlu lagi kode dibawah ini
|
|
32122
32252
|
curIndex = this.rooms.findIndex(function (room) {
|
|
32123
|
-
return room.id ===
|
|
32253
|
+
return room.id === _this17.selected.id;
|
|
32124
32254
|
});
|
|
32125
32255
|
if (curIndex > 0 && this.rooms.length > 1) {
|
|
32126
32256
|
this.rooms.splice(1, this.rooms.length - 1);
|
|
@@ -32130,18 +32260,18 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32130
32260
|
}, {
|
|
32131
32261
|
key: "exitChatRoom",
|
|
32132
32262
|
value: function exitChatRoom() {
|
|
32133
|
-
var
|
|
32263
|
+
var _this18 = this;
|
|
32134
32264
|
// remove all subscriber
|
|
32135
32265
|
this.realtimeAdapter.unsubscribeTyping();
|
|
32136
32266
|
Object(_lib_util__WEBPACK_IMPORTED_MODULE_21__["tryCatch"])(function () {
|
|
32137
|
-
return
|
|
32138
|
-
return it.email !==
|
|
32267
|
+
return _this18.selected.participants.filter(function (it) {
|
|
32268
|
+
return it.email !== _this18.user_id;
|
|
32139
32269
|
}).map(function (it) {
|
|
32140
32270
|
return it.email;
|
|
32141
32271
|
});
|
|
32142
32272
|
}, null, this.noop, function (userIds) {
|
|
32143
32273
|
return userIds.forEach(function (userId) {
|
|
32144
|
-
return
|
|
32274
|
+
return _this18.realtimeAdapter.unsubscribeRoomPresence(userId);
|
|
32145
32275
|
});
|
|
32146
32276
|
});
|
|
32147
32277
|
this.selected = null;
|
|
@@ -32339,7 +32469,7 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32339
32469
|
}, {
|
|
32340
32470
|
key: "searchMessage",
|
|
32341
32471
|
value: (function () {
|
|
32342
|
-
var _searchMessage = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function
|
|
32472
|
+
var _searchMessage = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function _callee18() {
|
|
32343
32473
|
var _ref13,
|
|
32344
32474
|
query,
|
|
32345
32475
|
_ref13$roomIds,
|
|
@@ -32352,20 +32482,20 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32352
32482
|
url,
|
|
32353
32483
|
isValidRoomType,
|
|
32354
32484
|
room,
|
|
32355
|
-
|
|
32356
|
-
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function
|
|
32357
|
-
while (1) switch (
|
|
32485
|
+
_args18 = arguments;
|
|
32486
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function _callee18$(_context18) {
|
|
32487
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
32358
32488
|
case 0:
|
|
32359
|
-
_ref13 =
|
|
32489
|
+
_ref13 = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {}, query = _ref13.query, _ref13$roomIds = _ref13.roomIds, roomIds = _ref13$roomIds === void 0 ? [] : _ref13$roomIds, userId = _ref13.userId, type = _ref13.type, roomType = _ref13.roomType, page = _ref13.page, limit = _ref13.limit;
|
|
32360
32490
|
url = 'api/v2/sdk/search';
|
|
32361
32491
|
isValidRoomType = ['group', 'single', 'channel'].some(function (it) {
|
|
32362
32492
|
return it === roomType;
|
|
32363
32493
|
});
|
|
32364
32494
|
if (!(roomType != null && !isValidRoomType)) {
|
|
32365
|
-
|
|
32495
|
+
_context18.next = 5;
|
|
32366
32496
|
break;
|
|
32367
32497
|
}
|
|
32368
|
-
return
|
|
32498
|
+
return _context18.abrupt("return", Promise.reject('Invalid room type, valid room type are: `group`, `single`, and `channel`'));
|
|
32369
32499
|
case 5:
|
|
32370
32500
|
room = function (roomType) {
|
|
32371
32501
|
var rType = roomType == null ? undefined : roomType === 'single' ? 'single' : 'group';
|
|
@@ -32375,7 +32505,7 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32375
32505
|
isPublic: isPublic
|
|
32376
32506
|
};
|
|
32377
32507
|
}(roomType);
|
|
32378
|
-
return
|
|
32508
|
+
return _context18.abrupt("return", this.HTTPAdapter.post_json(url, {
|
|
32379
32509
|
token: this.token,
|
|
32380
32510
|
query: query,
|
|
32381
32511
|
sender: userId,
|
|
@@ -32392,9 +32522,9 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32392
32522
|
}));
|
|
32393
32523
|
case 7:
|
|
32394
32524
|
case "end":
|
|
32395
|
-
return
|
|
32525
|
+
return _context18.stop();
|
|
32396
32526
|
}
|
|
32397
|
-
},
|
|
32527
|
+
}, _callee18, this);
|
|
32398
32528
|
}));
|
|
32399
32529
|
function searchMessage() {
|
|
32400
32530
|
return _searchMessage.apply(this, arguments);
|
|
@@ -32418,7 +32548,7 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32418
32548
|
}, {
|
|
32419
32549
|
key: "getFileList",
|
|
32420
32550
|
value: (function () {
|
|
32421
|
-
var _getFileList = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function
|
|
32551
|
+
var _getFileList = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function _callee19() {
|
|
32422
32552
|
var _ref14,
|
|
32423
32553
|
_ref14$roomIds,
|
|
32424
32554
|
roomIds,
|
|
@@ -32431,17 +32561,17 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32431
32561
|
excludeExtensions,
|
|
32432
32562
|
url,
|
|
32433
32563
|
opts,
|
|
32434
|
-
|
|
32435
|
-
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function
|
|
32436
|
-
while (1) switch (
|
|
32564
|
+
_args19 = arguments;
|
|
32565
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function _callee19$(_context19) {
|
|
32566
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
32437
32567
|
case 0:
|
|
32438
|
-
_ref14 =
|
|
32568
|
+
_ref14 = _args19.length > 0 && _args19[0] !== undefined ? _args19[0] : {}, _ref14$roomIds = _ref14.roomIds, roomIds = _ref14$roomIds === void 0 ? [] : _ref14$roomIds, fileType = _ref14.fileType, page = _ref14.page, limit = _ref14.limit, sender = _ref14.sender, userId = _ref14.userId, includeExtensions = _ref14.includeExtensions, excludeExtensions = _ref14.excludeExtensions;
|
|
32439
32569
|
url = 'api/v2/sdk/file_list';
|
|
32440
32570
|
if (this.isLogin) {
|
|
32441
|
-
|
|
32571
|
+
_context19.next = 4;
|
|
32442
32572
|
break;
|
|
32443
32573
|
}
|
|
32444
|
-
return
|
|
32574
|
+
return _context19.abrupt("return", Promise.reject('You need to login to use this method'));
|
|
32445
32575
|
case 4:
|
|
32446
32576
|
// intended to check for undefined, so user can provide user
|
|
32447
32577
|
// with null. If null, backend can determine that we want to
|
|
@@ -32463,14 +32593,14 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32463
32593
|
exclude_extensions: excludeExtensions
|
|
32464
32594
|
};
|
|
32465
32595
|
if (sender != null) opts['sender'] = sender;
|
|
32466
|
-
return
|
|
32596
|
+
return _context19.abrupt("return", this.HTTPAdapter.post_json(url, opts).then(function (res) {
|
|
32467
32597
|
return res.body;
|
|
32468
32598
|
}));
|
|
32469
32599
|
case 9:
|
|
32470
32600
|
case "end":
|
|
32471
|
-
return
|
|
32601
|
+
return _context19.stop();
|
|
32472
32602
|
}
|
|
32473
|
-
},
|
|
32603
|
+
}, _callee19, this);
|
|
32474
32604
|
}));
|
|
32475
32605
|
function getFileList() {
|
|
32476
32606
|
return _getFileList.apply(this, arguments);
|
|
@@ -32600,18 +32730,18 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32600
32730
|
}, {
|
|
32601
32731
|
key: "updateMessage",
|
|
32602
32732
|
value: function () {
|
|
32603
|
-
var _updateMessage = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function
|
|
32604
|
-
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function
|
|
32605
|
-
while (1) switch (
|
|
32733
|
+
var _updateMessage = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function _callee20(message) {
|
|
32734
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function _callee20$(_context20) {
|
|
32735
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
32606
32736
|
case 0:
|
|
32607
|
-
return
|
|
32737
|
+
return _context20.abrupt("return", this.userAdapter.updateMessage(message));
|
|
32608
32738
|
case 1:
|
|
32609
32739
|
case "end":
|
|
32610
|
-
return
|
|
32740
|
+
return _context20.stop();
|
|
32611
32741
|
}
|
|
32612
|
-
},
|
|
32742
|
+
}, _callee20, this);
|
|
32613
32743
|
}));
|
|
32614
|
-
function updateMessage(
|
|
32744
|
+
function updateMessage(_x17) {
|
|
32615
32745
|
return _updateMessage.apply(this, arguments);
|
|
32616
32746
|
}
|
|
32617
32747
|
return updateMessage;
|
|
@@ -32619,10 +32749,10 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32619
32749
|
}, {
|
|
32620
32750
|
key: "onMessageUpdated",
|
|
32621
32751
|
value: function onMessageUpdated(handler) {
|
|
32622
|
-
var
|
|
32752
|
+
var _this19 = this;
|
|
32623
32753
|
this.realtimeAdapter.on('message:updated', handler);
|
|
32624
32754
|
return function () {
|
|
32625
|
-
return
|
|
32755
|
+
return _this19.realtimeAdapter.off('message:updated', handler);
|
|
32626
32756
|
};
|
|
32627
32757
|
}
|
|
32628
32758
|
|
|
@@ -32633,16 +32763,16 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32633
32763
|
}, {
|
|
32634
32764
|
key: "closeRealtimeConnection",
|
|
32635
32765
|
value: (function () {
|
|
32636
|
-
var _closeRealtimeConnection = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function
|
|
32637
|
-
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function
|
|
32638
|
-
while (1) switch (
|
|
32766
|
+
var _closeRealtimeConnection = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function _callee21() {
|
|
32767
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function _callee21$(_context21) {
|
|
32768
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
32639
32769
|
case 0:
|
|
32640
|
-
return
|
|
32770
|
+
return _context21.abrupt("return", this.realtimeAdapter.closeConnection());
|
|
32641
32771
|
case 1:
|
|
32642
32772
|
case "end":
|
|
32643
|
-
return
|
|
32773
|
+
return _context21.stop();
|
|
32644
32774
|
}
|
|
32645
|
-
},
|
|
32775
|
+
}, _callee21, this);
|
|
32646
32776
|
}));
|
|
32647
32777
|
function closeRealtimeConnection() {
|
|
32648
32778
|
return _closeRealtimeConnection.apply(this, arguments);
|
|
@@ -32657,16 +32787,16 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32657
32787
|
}, {
|
|
32658
32788
|
key: "openRealtimeConnection",
|
|
32659
32789
|
value: (function () {
|
|
32660
|
-
var _openRealtimeConnection = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function
|
|
32661
|
-
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function
|
|
32662
|
-
while (1) switch (
|
|
32790
|
+
var _openRealtimeConnection = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function _callee22() {
|
|
32791
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function _callee22$(_context22) {
|
|
32792
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
32663
32793
|
case 0:
|
|
32664
|
-
return
|
|
32794
|
+
return _context22.abrupt("return", this.realtimeAdapter.openConnection());
|
|
32665
32795
|
case 1:
|
|
32666
32796
|
case "end":
|
|
32667
|
-
return
|
|
32797
|
+
return _context22.stop();
|
|
32668
32798
|
}
|
|
32669
|
-
},
|
|
32799
|
+
}, _callee22, this);
|
|
32670
32800
|
}));
|
|
32671
32801
|
function openRealtimeConnection() {
|
|
32672
32802
|
return _openRealtimeConnection.apply(this, arguments);
|
|
@@ -32676,16 +32806,16 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32676
32806
|
}, {
|
|
32677
32807
|
key: "startSync",
|
|
32678
32808
|
value: function () {
|
|
32679
|
-
var _startSync = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function
|
|
32680
|
-
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function
|
|
32681
|
-
while (1) switch (
|
|
32809
|
+
var _startSync = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function _callee23() {
|
|
32810
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function _callee23$(_context23) {
|
|
32811
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
32682
32812
|
case 0:
|
|
32683
32813
|
this._forceEnableSync = true;
|
|
32684
32814
|
case 1:
|
|
32685
32815
|
case "end":
|
|
32686
|
-
return
|
|
32816
|
+
return _context23.stop();
|
|
32687
32817
|
}
|
|
32688
|
-
},
|
|
32818
|
+
}, _callee23, this);
|
|
32689
32819
|
}));
|
|
32690
32820
|
function startSync() {
|
|
32691
32821
|
return _startSync.apply(this, arguments);
|
|
@@ -32695,16 +32825,16 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
32695
32825
|
}, {
|
|
32696
32826
|
key: "stopSync",
|
|
32697
32827
|
value: function () {
|
|
32698
|
-
var _stopSync = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function
|
|
32699
|
-
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function
|
|
32700
|
-
while (1) switch (
|
|
32828
|
+
var _stopSync = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.mark(function _callee24() {
|
|
32829
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_5___default.a.wrap(function _callee24$(_context24) {
|
|
32830
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
32701
32831
|
case 0:
|
|
32702
32832
|
this._forceEnableSync = false;
|
|
32703
32833
|
case 1:
|
|
32704
32834
|
case "end":
|
|
32705
|
-
return
|
|
32835
|
+
return _context24.stop();
|
|
32706
32836
|
}
|
|
32707
|
-
},
|
|
32837
|
+
}, _callee24, this);
|
|
32708
32838
|
}));
|
|
32709
32839
|
function stopSync() {
|
|
32710
32840
|
return _stopSync.apply(this, arguments);
|
|
@@ -33182,7 +33312,7 @@ function CustomEventAdapter(mqttAdapter, userId) {
|
|
|
33182
33312
|
// ?
|
|
33183
33313
|
data: payload
|
|
33184
33314
|
});
|
|
33185
|
-
mqttAdapter.
|
|
33315
|
+
mqttAdapter.publish(getTopic(roomId), _payload);
|
|
33186
33316
|
},
|
|
33187
33317
|
subscribeEvent: function subscribeEvent(roomId, callback) {
|
|
33188
33318
|
if (is_js__WEBPACK_IMPORTED_MODULE_0___default.a.undefined(roomId)) throw new Error('`roomId` required');
|
|
@@ -33192,7 +33322,7 @@ function CustomEventAdapter(mqttAdapter, userId) {
|
|
|
33192
33322
|
var topic = getTopic(roomId);
|
|
33193
33323
|
// Only allow 1 subcription for now
|
|
33194
33324
|
if (subscribedTopics[topic]) return;
|
|
33195
|
-
mqttAdapter.
|
|
33325
|
+
mqttAdapter.subscribe(topic);
|
|
33196
33326
|
var cb = function cb(payload) {
|
|
33197
33327
|
var parsedPayload = JSON.parse(payload);
|
|
33198
33328
|
callback(parsedPayload);
|
|
@@ -33205,7 +33335,7 @@ function CustomEventAdapter(mqttAdapter, userId) {
|
|
|
33205
33335
|
if (is_js__WEBPACK_IMPORTED_MODULE_0___default.a.not.string(roomId)) throw new TypeError('`roomId` must have type of string');
|
|
33206
33336
|
var topic = getTopic(roomId);
|
|
33207
33337
|
if (!subscribedTopics[topic]) return;
|
|
33208
|
-
mqttAdapter.
|
|
33338
|
+
mqttAdapter.unsubscribe(topic);
|
|
33209
33339
|
events.off(topic, subscribedTopics[topic]);
|
|
33210
33340
|
subscribedTopics[topic] = null;
|
|
33211
33341
|
delete subscribedTopics[topic];
|
|
@@ -33253,7 +33383,7 @@ var ExpiredTokenAdapter = /*#__PURE__*/function () {
|
|
|
33253
33383
|
* userId: string,
|
|
33254
33384
|
* refreshToken: string | null,
|
|
33255
33385
|
* expiredAt: string | null,
|
|
33256
|
-
* onTokenRefreshed: (token: string, refreshToken: string, expiredAt: Date) => void
|
|
33386
|
+
* onTokenRefreshed: (token: string, refreshToken: string, expiredAt: Date, oldToken: string) => void
|
|
33257
33387
|
* getAuthenticationStatus: () => boolean,
|
|
33258
33388
|
* }} param
|
|
33259
33389
|
*/
|
|
@@ -33273,7 +33403,7 @@ var ExpiredTokenAdapter = /*#__PURE__*/function () {
|
|
|
33273
33403
|
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_3___default()(this, "_expiredAt", null);
|
|
33274
33404
|
/** @type {import('./http').default} */
|
|
33275
33405
|
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_3___default()(this, "_http", void 0);
|
|
33276
|
-
/** @type {(token: string, refreshToken: string, expiredAt: Date) => void | undefined} */
|
|
33406
|
+
/** @type {(token: string, refreshToken: string, expiredAt: Date, oldToken: string) => void | undefined} */
|
|
33277
33407
|
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_3___default()(this, "_onTokenRefreshed", void 0);
|
|
33278
33408
|
/** @type {any} */
|
|
33279
33409
|
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_3___default()(this, "_timerId", void 0);
|
|
@@ -33339,13 +33469,12 @@ var ExpiredTokenAdapter = /*#__PURE__*/function () {
|
|
|
33339
33469
|
var res = r.body.results;
|
|
33340
33470
|
var token = res.token;
|
|
33341
33471
|
_this2._refreshToken = res.refresh_token;
|
|
33472
|
+
// @ts-ignore
|
|
33473
|
+
(_this2$_onTokenRefres = _this2._onTokenRefreshed) === null || _this2$_onTokenRefres === void 0 || _this2$_onTokenRefres.call(_this2, token, _this2._refreshToken, _this2._expiredAt, _this2._http.token);
|
|
33342
33474
|
_this2._http.setToken(res.token);
|
|
33343
33475
|
if (res.token_expires_at != null) {
|
|
33344
33476
|
_this2._expiredAt = new Date(res.token_expires_at);
|
|
33345
33477
|
}
|
|
33346
|
-
|
|
33347
|
-
// @ts-ignore
|
|
33348
|
-
(_this2$_onTokenRefres = _this2._onTokenRefreshed) === null || _this2$_onTokenRefres === void 0 || _this2$_onTokenRefres.call(_this2, token, _this2._refreshToken, _this2._expiredAt);
|
|
33349
33478
|
_this2._setTimer(_this2._expiredAt);
|
|
33350
33479
|
return res;
|
|
33351
33480
|
}));
|
|
@@ -33438,12 +33567,18 @@ function hookAdapterFactory() {
|
|
|
33438
33567
|
"use strict";
|
|
33439
33568
|
__webpack_require__.r(__webpack_exports__);
|
|
33440
33569
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return HttpAdapter; });
|
|
33441
|
-
/* harmony import */ var
|
|
33442
|
-
/* harmony import */ var
|
|
33443
|
-
/* harmony import */ var
|
|
33444
|
-
/* harmony import */ var
|
|
33445
|
-
/* harmony import */ var
|
|
33446
|
-
/* harmony import */ var
|
|
33570
|
+
/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/.pnpm/@babel+runtime@7.26.9/node_modules/@babel/runtime/helpers/asyncToGenerator.js");
|
|
33571
|
+
/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__);
|
|
33572
|
+
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/.pnpm/@babel+runtime@7.26.9/node_modules/@babel/runtime/helpers/classCallCheck.js");
|
|
33573
|
+
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1__);
|
|
33574
|
+
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/.pnpm/@babel+runtime@7.26.9/node_modules/@babel/runtime/helpers/createClass.js");
|
|
33575
|
+
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2__);
|
|
33576
|
+
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/.pnpm/@babel+runtime@7.26.9/node_modules/@babel/runtime/regenerator/index.js");
|
|
33577
|
+
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3__);
|
|
33578
|
+
/* harmony import */ var superagent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! superagent */ "./node_modules/.pnpm/superagent@3.8.3/node_modules/superagent/lib/client.js");
|
|
33579
|
+
/* harmony import */ var superagent__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(superagent__WEBPACK_IMPORTED_MODULE_4__);
|
|
33580
|
+
|
|
33581
|
+
|
|
33447
33582
|
|
|
33448
33583
|
|
|
33449
33584
|
|
|
@@ -33453,16 +33588,19 @@ var HttpAdapter = /*#__PURE__*/function () {
|
|
|
33453
33588
|
AppId = _ref.AppId,
|
|
33454
33589
|
userId = _ref.userId,
|
|
33455
33590
|
version = _ref.version,
|
|
33456
|
-
getCustomHeader = _ref.getCustomHeader
|
|
33457
|
-
|
|
33591
|
+
getCustomHeader = _ref.getCustomHeader,
|
|
33592
|
+
expiredTokenAdapterGetter = _ref.expiredTokenAdapterGetter;
|
|
33593
|
+
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_1___default()(this, HttpAdapter);
|
|
33458
33594
|
this.baseURL = baseURL;
|
|
33459
33595
|
this.token = null;
|
|
33460
33596
|
this.userId = userId;
|
|
33461
33597
|
this.AppId = AppId;
|
|
33462
33598
|
this.version = version;
|
|
33463
33599
|
this.getCustomHeader = getCustomHeader;
|
|
33600
|
+
/** @type {() => import('./expired-token.js').ExpiredTokenAdapter} */
|
|
33601
|
+
this._expiredTokenAdapterGetter = expiredTokenAdapterGetter;
|
|
33464
33602
|
}
|
|
33465
|
-
return
|
|
33603
|
+
return _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_2___default()(HttpAdapter, [{
|
|
33466
33604
|
key: "setToken",
|
|
33467
33605
|
value: function setToken(token) {
|
|
33468
33606
|
this.token = token;
|
|
@@ -33473,135 +33611,167 @@ var HttpAdapter = /*#__PURE__*/function () {
|
|
|
33473
33611
|
var _this = this;
|
|
33474
33612
|
var headers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33475
33613
|
var options = arguments.length > 2 ? arguments[2] : undefined;
|
|
33476
|
-
return
|
|
33477
|
-
var req
|
|
33478
|
-
|
|
33479
|
-
|
|
33480
|
-
|
|
33481
|
-
|
|
33482
|
-
|
|
33483
|
-
|
|
33614
|
+
return this._retryHelper(/*#__PURE__*/_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.mark(function _callee() {
|
|
33615
|
+
var req;
|
|
33616
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.wrap(function _callee$(_context) {
|
|
33617
|
+
while (1) switch (_context.prev = _context.next) {
|
|
33618
|
+
case 0:
|
|
33619
|
+
req = superagent__WEBPACK_IMPORTED_MODULE_4___default.a.get("".concat(_this.baseURL, "/").concat(path));
|
|
33620
|
+
if (options && options.baseURL) req = superagent__WEBPACK_IMPORTED_MODULE_4___default.a.get("".concat(options.baseURL, "/").concat(path));
|
|
33621
|
+
req = _this.setupHeaders(req, headers);
|
|
33622
|
+
return _context.abrupt("return", req);
|
|
33623
|
+
case 4:
|
|
33624
|
+
case "end":
|
|
33625
|
+
return _context.stop();
|
|
33484
33626
|
}
|
|
33485
|
-
|
|
33486
|
-
|
|
33487
|
-
});
|
|
33627
|
+
}, _callee);
|
|
33628
|
+
})));
|
|
33488
33629
|
}
|
|
33489
33630
|
// eslint-disable-next-line
|
|
33490
33631
|
}, {
|
|
33491
33632
|
key: "get_request",
|
|
33492
33633
|
value: function get_request(path) {
|
|
33493
|
-
var
|
|
33494
|
-
|
|
33495
|
-
|
|
33634
|
+
var _this2 = this;
|
|
33635
|
+
return this._retryHelper(/*#__PURE__*/_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.mark(function _callee2() {
|
|
33636
|
+
var req;
|
|
33637
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.wrap(function _callee2$(_context2) {
|
|
33638
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
33639
|
+
case 0:
|
|
33640
|
+
req = superagent__WEBPACK_IMPORTED_MODULE_4___default.a.get("".concat(_this2.baseURL, "/").concat(path));
|
|
33641
|
+
req = _this2.setupHeaders(req, {});
|
|
33642
|
+
return _context2.abrupt("return", req);
|
|
33643
|
+
case 3:
|
|
33644
|
+
case "end":
|
|
33645
|
+
return _context2.stop();
|
|
33646
|
+
}
|
|
33647
|
+
}, _callee2);
|
|
33648
|
+
})));
|
|
33496
33649
|
}
|
|
33497
33650
|
}, {
|
|
33498
33651
|
key: "post",
|
|
33499
33652
|
value: function post(path) {
|
|
33500
|
-
var
|
|
33653
|
+
var _this3 = this;
|
|
33501
33654
|
var body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33502
33655
|
var headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
33503
|
-
return
|
|
33504
|
-
var req
|
|
33505
|
-
|
|
33506
|
-
|
|
33507
|
-
|
|
33508
|
-
|
|
33509
|
-
|
|
33656
|
+
return this._retryHelper(/*#__PURE__*/_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.mark(function _callee3() {
|
|
33657
|
+
var req;
|
|
33658
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.wrap(function _callee3$(_context3) {
|
|
33659
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
33660
|
+
case 0:
|
|
33661
|
+
req = superagent__WEBPACK_IMPORTED_MODULE_4___default.a.post("".concat(_this3.baseURL, "/").concat(path));
|
|
33662
|
+
req = _this3.setupHeaders(req, headers);
|
|
33663
|
+
return _context3.abrupt("return", req.send(body).set('Content-Type', 'application/x-www-form-urlencoded'));
|
|
33664
|
+
case 3:
|
|
33665
|
+
case "end":
|
|
33666
|
+
return _context3.stop();
|
|
33510
33667
|
}
|
|
33511
|
-
|
|
33512
|
-
|
|
33513
|
-
});
|
|
33668
|
+
}, _callee3);
|
|
33669
|
+
})));
|
|
33514
33670
|
}
|
|
33515
33671
|
|
|
33516
33672
|
// eslint-disable-next-line
|
|
33517
33673
|
}, {
|
|
33518
33674
|
key: "post_json",
|
|
33519
33675
|
value: function post_json(path) {
|
|
33520
|
-
var
|
|
33676
|
+
var _this4 = this;
|
|
33521
33677
|
var body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33522
33678
|
var headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
33523
|
-
return
|
|
33524
|
-
var req
|
|
33525
|
-
|
|
33526
|
-
|
|
33527
|
-
|
|
33528
|
-
|
|
33529
|
-
|
|
33679
|
+
return this._retryHelper(/*#__PURE__*/_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.mark(function _callee4() {
|
|
33680
|
+
var req;
|
|
33681
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.wrap(function _callee4$(_context4) {
|
|
33682
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
33683
|
+
case 0:
|
|
33684
|
+
req = superagent__WEBPACK_IMPORTED_MODULE_4___default.a.post("".concat(_this4.baseURL, "/").concat(path));
|
|
33685
|
+
req = _this4.setupHeaders(req, headers);
|
|
33686
|
+
req.send(body);
|
|
33687
|
+
return _context4.abrupt("return", req);
|
|
33688
|
+
case 4:
|
|
33689
|
+
case "end":
|
|
33690
|
+
return _context4.stop();
|
|
33530
33691
|
}
|
|
33531
|
-
|
|
33532
|
-
|
|
33533
|
-
});
|
|
33692
|
+
}, _callee4);
|
|
33693
|
+
})));
|
|
33534
33694
|
}
|
|
33535
33695
|
}, {
|
|
33536
33696
|
key: "put",
|
|
33537
33697
|
value: function put(path) {
|
|
33538
|
-
var
|
|
33698
|
+
var _this5 = this;
|
|
33539
33699
|
var body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33540
33700
|
var headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
33541
|
-
return
|
|
33542
|
-
var req
|
|
33543
|
-
|
|
33544
|
-
|
|
33545
|
-
|
|
33546
|
-
|
|
33547
|
-
|
|
33701
|
+
return this._retryHelper(/*#__PURE__*/_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.mark(function _callee5() {
|
|
33702
|
+
var req;
|
|
33703
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.wrap(function _callee5$(_context5) {
|
|
33704
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
33705
|
+
case 0:
|
|
33706
|
+
req = superagent__WEBPACK_IMPORTED_MODULE_4___default.a.put("".concat(_this5.baseURL, "/").concat(path));
|
|
33707
|
+
req = _this5.setupHeaders(req, headers);
|
|
33708
|
+
return _context5.abrupt("return", req.send(body).set('Content-Type', 'application/x-www-form-urlencoded'));
|
|
33709
|
+
case 3:
|
|
33710
|
+
case "end":
|
|
33711
|
+
return _context5.stop();
|
|
33548
33712
|
}
|
|
33549
|
-
|
|
33550
|
-
|
|
33551
|
-
});
|
|
33713
|
+
}, _callee5);
|
|
33714
|
+
})));
|
|
33552
33715
|
}
|
|
33553
33716
|
}, {
|
|
33554
33717
|
key: "patch",
|
|
33555
33718
|
value: function patch(path) {
|
|
33556
|
-
var
|
|
33719
|
+
var _this6 = this;
|
|
33557
33720
|
var body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33558
33721
|
var headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
33559
|
-
return
|
|
33560
|
-
var req
|
|
33561
|
-
|
|
33562
|
-
|
|
33563
|
-
|
|
33564
|
-
|
|
33565
|
-
|
|
33722
|
+
return this._retryHelper(/*#__PURE__*/_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.mark(function _callee6() {
|
|
33723
|
+
var req;
|
|
33724
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.wrap(function _callee6$(_context6) {
|
|
33725
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
33726
|
+
case 0:
|
|
33727
|
+
req = superagent__WEBPACK_IMPORTED_MODULE_4___default.a.patch("".concat(_this6.baseURL, "/").concat(path));
|
|
33728
|
+
req = _this6.setupHeaders(req, headers);
|
|
33729
|
+
return _context6.abrupt("return", req.send(body).set('Content-Type', 'application/x-www-form-urlencoded'));
|
|
33730
|
+
case 3:
|
|
33731
|
+
case "end":
|
|
33732
|
+
return _context6.stop();
|
|
33566
33733
|
}
|
|
33567
|
-
|
|
33568
|
-
|
|
33569
|
-
});
|
|
33734
|
+
}, _callee6);
|
|
33735
|
+
})));
|
|
33570
33736
|
}
|
|
33571
33737
|
}, {
|
|
33572
33738
|
key: "del",
|
|
33573
33739
|
value: function del(path) {
|
|
33574
|
-
var
|
|
33740
|
+
var _this7 = this;
|
|
33575
33741
|
var body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33576
33742
|
var headers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
33577
|
-
return
|
|
33578
|
-
var req
|
|
33579
|
-
|
|
33580
|
-
|
|
33581
|
-
|
|
33582
|
-
|
|
33583
|
-
|
|
33743
|
+
return this._retryHelper(/*#__PURE__*/_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.mark(function _callee7() {
|
|
33744
|
+
var req;
|
|
33745
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.wrap(function _callee7$(_context7) {
|
|
33746
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
33747
|
+
case 0:
|
|
33748
|
+
req = superagent__WEBPACK_IMPORTED_MODULE_4___default.a.del("".concat(_this7.baseURL, "/").concat(path));
|
|
33749
|
+
req = _this7.setupHeaders(req, headers);
|
|
33750
|
+
return _context7.abrupt("return", req.send(body).set('Content-Type', 'application/json'));
|
|
33751
|
+
case 3:
|
|
33752
|
+
case "end":
|
|
33753
|
+
return _context7.stop();
|
|
33584
33754
|
}
|
|
33585
|
-
|
|
33586
|
-
|
|
33587
|
-
});
|
|
33755
|
+
}, _callee7);
|
|
33756
|
+
})));
|
|
33588
33757
|
}
|
|
33589
33758
|
}, {
|
|
33590
33759
|
key: "setupHeaders",
|
|
33591
33760
|
value: function setupHeaders(req) {
|
|
33592
33761
|
var headers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33762
|
+
req.set('QISCUS-SDK-PLATFORM', 'javascript');
|
|
33593
33763
|
// let's give this default Authorization Header
|
|
33594
33764
|
if (this.AppId != null) {
|
|
33595
|
-
req.set(
|
|
33765
|
+
req.set('QISCUS-SDK-APP-ID', "".concat(this.AppId));
|
|
33596
33766
|
}
|
|
33597
33767
|
if (this.userId != null) {
|
|
33598
|
-
req.set(
|
|
33768
|
+
req.set('QISCUS-SDK-USER-ID', "".concat(this.userId));
|
|
33599
33769
|
}
|
|
33600
33770
|
if (this.token != null) {
|
|
33601
|
-
req.set(
|
|
33771
|
+
req.set('QISCUS-SDK-TOKEN', "".concat(this.token));
|
|
33602
33772
|
}
|
|
33603
33773
|
if (this.version != null) {
|
|
33604
|
-
req.set(
|
|
33774
|
+
req.set('QISCUS-SDK-VERSION', "".concat(this.version));
|
|
33605
33775
|
}
|
|
33606
33776
|
if (this.getCustomHeader != null) {
|
|
33607
33777
|
var customHeaders = this.getCustomHeader();
|
|
@@ -33619,16 +33789,53 @@ var HttpAdapter = /*#__PURE__*/function () {
|
|
|
33619
33789
|
}
|
|
33620
33790
|
return req;
|
|
33621
33791
|
}
|
|
33792
|
+
|
|
33793
|
+
/**
|
|
33794
|
+
* @param {() => request.Request} fn
|
|
33795
|
+
* @returns {Promise<unknown>}
|
|
33796
|
+
*/
|
|
33622
33797
|
}, {
|
|
33623
|
-
key: "
|
|
33624
|
-
value: function
|
|
33625
|
-
var
|
|
33626
|
-
|
|
33627
|
-
|
|
33628
|
-
|
|
33629
|
-
|
|
33798
|
+
key: "_retryHelper",
|
|
33799
|
+
value: (function () {
|
|
33800
|
+
var _retryHelper2 = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.mark(function _callee8(fn) {
|
|
33801
|
+
var _err$response, _err$response2, _body$error, status, body;
|
|
33802
|
+
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_3___default.a.wrap(function _callee8$(_context8) {
|
|
33803
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
33804
|
+
case 0:
|
|
33805
|
+
_context8.prev = 0;
|
|
33806
|
+
_context8.next = 3;
|
|
33807
|
+
return fn();
|
|
33808
|
+
case 3:
|
|
33809
|
+
return _context8.abrupt("return", _context8.sent);
|
|
33810
|
+
case 6:
|
|
33811
|
+
_context8.prev = 6;
|
|
33812
|
+
_context8.t0 = _context8["catch"](0);
|
|
33813
|
+
status = _context8.t0 === null || _context8.t0 === void 0 || (_err$response = _context8.t0.response) === null || _err$response === void 0 ? void 0 : _err$response.status;
|
|
33814
|
+
body = _context8.t0 === null || _context8.t0 === void 0 || (_err$response2 = _context8.t0.response) === null || _err$response2 === void 0 ? void 0 : _err$response2.body;
|
|
33815
|
+
if (!(status === 403 && ((_body$error = body.error) === null || _body$error === void 0 || (_body$error = _body$error.message) === null || _body$error === void 0 ? void 0 : _body$error.toLowerCase()) === 'unauthorized. token is expired')) {
|
|
33816
|
+
_context8.next = 18;
|
|
33817
|
+
break;
|
|
33818
|
+
}
|
|
33819
|
+
_context8.next = 13;
|
|
33820
|
+
return this._expiredTokenAdapterGetter().refreshAuthToken();
|
|
33821
|
+
case 13:
|
|
33822
|
+
_context8.next = 15;
|
|
33823
|
+
return fn();
|
|
33824
|
+
case 15:
|
|
33825
|
+
return _context8.abrupt("return", _context8.sent);
|
|
33826
|
+
case 18:
|
|
33827
|
+
throw _context8.t0;
|
|
33828
|
+
case 19:
|
|
33829
|
+
case "end":
|
|
33830
|
+
return _context8.stop();
|
|
33831
|
+
}
|
|
33832
|
+
}, _callee8, this, [[0, 6]]);
|
|
33833
|
+
}));
|
|
33834
|
+
function _retryHelper(_x) {
|
|
33835
|
+
return _retryHelper2.apply(this, arguments);
|
|
33630
33836
|
}
|
|
33631
|
-
|
|
33837
|
+
return _retryHelper;
|
|
33838
|
+
}())
|
|
33632
33839
|
}]);
|
|
33633
33840
|
}();
|
|
33634
33841
|
|
|
@@ -33885,7 +34092,7 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
33885
34092
|
}
|
|
33886
34093
|
|
|
33887
34094
|
/**
|
|
33888
|
-
* @return {Promise<boolean}
|
|
34095
|
+
* @return {Promise<boolean>}
|
|
33889
34096
|
*/
|
|
33890
34097
|
}, {
|
|
33891
34098
|
key: "openConnection",
|
|
@@ -33895,7 +34102,7 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
33895
34102
|
while (1) switch (_context2.prev = _context2.next) {
|
|
33896
34103
|
case 0:
|
|
33897
34104
|
this.shouldConnect = true;
|
|
33898
|
-
this.__mqtt_conneck();
|
|
34105
|
+
this.mqtt = this.__mqtt_conneck();
|
|
33899
34106
|
case 2:
|
|
33900
34107
|
case "end":
|
|
33901
34108
|
return _context2.stop();
|
|
@@ -33915,12 +34122,18 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
33915
34122
|
key: "closeConnection",
|
|
33916
34123
|
value: (function () {
|
|
33917
34124
|
var _closeConnection = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_2___default()(/*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_6___default.a.mark(function _callee3() {
|
|
34125
|
+
var _this2 = this;
|
|
33918
34126
|
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_6___default.a.wrap(function _callee3$(_context3) {
|
|
33919
34127
|
while (1) switch (_context3.prev = _context3.next) {
|
|
33920
34128
|
case 0:
|
|
33921
34129
|
this.shouldConnect = false;
|
|
33922
|
-
this.mqtt.end(true)
|
|
33923
|
-
|
|
34130
|
+
this.mqtt.end(true, function (err) {
|
|
34131
|
+
if (err) {
|
|
34132
|
+
_this2.logger('error when close connection', err.message);
|
|
34133
|
+
}
|
|
34134
|
+
});
|
|
34135
|
+
this.mqtt = null;
|
|
34136
|
+
case 3:
|
|
33924
34137
|
case "end":
|
|
33925
34138
|
return _context3.stop();
|
|
33926
34139
|
}
|
|
@@ -33969,14 +34182,14 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
33969
34182
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
33970
34183
|
args[_key2] = arguments[_key2];
|
|
33971
34184
|
}
|
|
33972
|
-
this.logger('subscribe to', args);
|
|
33973
34185
|
this.subscribtionBuffer.push(args);
|
|
33974
|
-
|
|
33975
|
-
|
|
34186
|
+
while (this.mqtt != null && this.subscribtionBuffer.length > 0) {
|
|
34187
|
+
var subs = this.subscribtionBuffer.shift();
|
|
34188
|
+
if (subs != null) {
|
|
33976
34189
|
var _this$mqtt;
|
|
33977
|
-
|
|
33978
|
-
|
|
33979
|
-
}
|
|
34190
|
+
this.logger('subscribe topic', subs);
|
|
34191
|
+
(_this$mqtt = this.mqtt).subscribe.apply(_this$mqtt, _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(subs));
|
|
34192
|
+
}
|
|
33980
34193
|
}
|
|
33981
34194
|
}
|
|
33982
34195
|
}, {
|
|
@@ -33985,16 +34198,14 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
33985
34198
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
33986
34199
|
args[_key3] = arguments[_key3];
|
|
33987
34200
|
}
|
|
33988
|
-
this.logger('unsubscribe from', args);
|
|
33989
34201
|
this.unsubscribtionBuffer.push(args);
|
|
33990
|
-
|
|
33991
|
-
|
|
33992
|
-
|
|
33993
|
-
|
|
33994
|
-
|
|
33995
|
-
|
|
33996
|
-
|
|
33997
|
-
} while (this.unsubscribtionBuffer.length > 0);
|
|
34202
|
+
while (this.mqtt != null && this.unsubscribtionBuffer.length > 0) {
|
|
34203
|
+
var subs = this.unsubscribtionBuffer.shift();
|
|
34204
|
+
if (subs != null) {
|
|
34205
|
+
var _this$mqtt2;
|
|
34206
|
+
this.logger('unsubscribe topic', subs);
|
|
34207
|
+
(_this$mqtt2 = this.mqtt).unsubscribe.apply(_this$mqtt2, _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(subs));
|
|
34208
|
+
}
|
|
33998
34209
|
}
|
|
33999
34210
|
}
|
|
34000
34211
|
}, {
|
|
@@ -34006,12 +34217,13 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
34006
34217
|
payload: payload,
|
|
34007
34218
|
options: options
|
|
34008
34219
|
});
|
|
34009
|
-
|
|
34220
|
+
while (this.mqtt != null && this.publishBuffer.length > 0) {
|
|
34010
34221
|
var data = this.publishBuffer.shift();
|
|
34011
34222
|
if (data != null) {
|
|
34012
|
-
|
|
34223
|
+
this.logger('publish to', data.topic, data.payload, data.options);
|
|
34224
|
+
this.mqtt.publish(data.topic, data.payload.toString(), data.options);
|
|
34013
34225
|
}
|
|
34014
|
-
}
|
|
34226
|
+
}
|
|
34015
34227
|
}
|
|
34016
34228
|
}, {
|
|
34017
34229
|
key: "emit",
|
|
@@ -34103,13 +34315,13 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
34103
34315
|
}, {
|
|
34104
34316
|
key: "notificationHandler",
|
|
34105
34317
|
value: function notificationHandler(topic, message) {
|
|
34106
|
-
var
|
|
34318
|
+
var _this3 = this;
|
|
34107
34319
|
this.logger('on:notification', message);
|
|
34108
34320
|
message = JSON.parse(message);
|
|
34109
34321
|
var data = message.payload.data;
|
|
34110
34322
|
if ('deleted_messages' in data) {
|
|
34111
34323
|
data.deleted_messages.forEach(function (message) {
|
|
34112
|
-
|
|
34324
|
+
_this3.emit('comment-deleted', {
|
|
34113
34325
|
roomId: message.room_id,
|
|
34114
34326
|
commentUniqueIds: message.message_unique_ids,
|
|
34115
34327
|
isForEveryone: true,
|
|
@@ -34119,7 +34331,7 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
34119
34331
|
}
|
|
34120
34332
|
if ('deleted_rooms' in data) {
|
|
34121
34333
|
data.deleted_rooms.forEach(function (room) {
|
|
34122
|
-
|
|
34334
|
+
_this3.emit('room-cleared', room);
|
|
34123
34335
|
});
|
|
34124
34336
|
}
|
|
34125
34337
|
}
|
|
@@ -34290,6 +34502,27 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
34290
34502
|
this.subscribe("".concat(this.core.userData.token, "/n"));
|
|
34291
34503
|
this.subscribe("".concat(this.core.userData.token, "/update"));
|
|
34292
34504
|
}
|
|
34505
|
+
}, {
|
|
34506
|
+
key: "subscribeUserChannelByToken",
|
|
34507
|
+
value: function subscribeUserChannelByToken(token) {
|
|
34508
|
+
this.subscribe("".concat(token, "/c"));
|
|
34509
|
+
this.subscribe("".concat(token, "/n"));
|
|
34510
|
+
this.subscribe("".concat(token, "/update"));
|
|
34511
|
+
}
|
|
34512
|
+
}, {
|
|
34513
|
+
key: "unsubscribeUserChannel",
|
|
34514
|
+
value: function unsubscribeUserChannel() {
|
|
34515
|
+
this.unsubscribe("".concat(this.core.userData.token, "/c"));
|
|
34516
|
+
this.unsubscribe("".concat(this.core.userData.token, "/n"));
|
|
34517
|
+
this.unsubscribe("".concat(this.core.userData.token, "/update"));
|
|
34518
|
+
}
|
|
34519
|
+
}, {
|
|
34520
|
+
key: "unsusbcribeUserChannelByToken",
|
|
34521
|
+
value: function unsusbcribeUserChannelByToken(token) {
|
|
34522
|
+
this.unsubscribe("".concat(token, "/c"));
|
|
34523
|
+
this.unsubscribe("".concat(token, "/n"));
|
|
34524
|
+
this.unsubscribe("".concat(token, "/update"));
|
|
34525
|
+
}
|
|
34293
34526
|
}, {
|
|
34294
34527
|
key: "publishPresence",
|
|
34295
34528
|
value: function publishPresence(userId) {
|
|
@@ -34632,16 +34865,20 @@ function synchronizeFactory(getHttp, getInterval, getSync, getId, logger) {
|
|
|
34632
34865
|
}
|
|
34633
34866
|
result = _step.value;
|
|
34634
34867
|
try {
|
|
34635
|
-
|
|
34636
|
-
|
|
34637
|
-
|
|
34638
|
-
messages
|
|
34639
|
-
|
|
34640
|
-
|
|
34641
|
-
|
|
34868
|
+
emitter.emit('synchronize', Date.now());
|
|
34869
|
+
if ((result === null || result === void 0 ? void 0 : result.lastMessageId) != null && (result === null || result === void 0 ? void 0 : result.messages) != null) {
|
|
34870
|
+
messageId = result.lastMessageId;
|
|
34871
|
+
messages = result.messages;
|
|
34872
|
+
if (messageId > getId()) {
|
|
34873
|
+
messages.forEach(function (m) {
|
|
34874
|
+
return emitter.emit('message.new', m);
|
|
34875
|
+
});
|
|
34876
|
+
emitter.emit('last-message-id.new', messageId);
|
|
34877
|
+
}
|
|
34642
34878
|
}
|
|
34643
34879
|
} catch (e) {
|
|
34644
34880
|
logger('error when sync', e.message);
|
|
34881
|
+
console.log('error when sync', e);
|
|
34645
34882
|
}
|
|
34646
34883
|
case 9:
|
|
34647
34884
|
_iteratorAbruptCompletion = false;
|
|
@@ -34890,6 +35127,9 @@ function SyncAdapter(getHttpAdapter, _ref) {
|
|
|
34890
35127
|
syncFactory.on('message.new', function (m) {
|
|
34891
35128
|
return emitter.emit('message.new', m);
|
|
34892
35129
|
});
|
|
35130
|
+
syncFactory.on('synchronize', function (m) {
|
|
35131
|
+
return emitter.emit('synchronize', m);
|
|
35132
|
+
});
|
|
34893
35133
|
syncFactory.run()["catch"](function (err) {
|
|
34894
35134
|
return logger('got error when sync', err);
|
|
34895
35135
|
});
|
|
@@ -34924,6 +35164,12 @@ function SyncAdapter(getHttpAdapter, _ref) {
|
|
|
34924
35164
|
get off() {
|
|
34925
35165
|
return emitter.off;
|
|
34926
35166
|
},
|
|
35167
|
+
get interval() {
|
|
35168
|
+
return getInterval();
|
|
35169
|
+
},
|
|
35170
|
+
get enabled() {
|
|
35171
|
+
return enableSync();
|
|
35172
|
+
},
|
|
34927
35173
|
synchronize: function synchronize() {
|
|
34928
35174
|
syncFactory.synchronize();
|
|
34929
35175
|
},
|