qiscus-sdk-core 2.14.0 → 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 +35 -10
- package/dist/qiscus-sdk-core.js.map +1 -1
- package/dist/qiscus-sdk-core.min.js +2 -2
- package/dist/qiscus-sdk-core.min.js.map +1 -1
- package/lib/index.js +5 -2
- package/lib/lib/adapters/expired-token.js +4 -5
- package/lib/lib/adapters/mqtt.js +25 -2
- 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.14.
|
|
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
|
|
|
@@ -30677,15 +30677,18 @@ var QiscusSDK = /*#__PURE__*/function () {
|
|
|
30677
30677
|
refreshToken: user.refresh_token,
|
|
30678
30678
|
expiredAt: user.token_expires_at,
|
|
30679
30679
|
userId: _this3.user_id,
|
|
30680
|
-
onTokenRefreshed: function onTokenRefreshed(token, refreshToken, expiredAt) {
|
|
30680
|
+
onTokenRefreshed: function onTokenRefreshed(token, refreshToken, expiredAt, oldToken) {
|
|
30681
30681
|
_this3.userData.token = token;
|
|
30682
30682
|
_this3.userData.refresh_token = refreshToken;
|
|
30683
30683
|
_this3.userData.token_expires_at = expiredAt === null || expiredAt === void 0 ? void 0 : expiredAt.toJSON();
|
|
30684
30684
|
_this3.events.emit('token-refreshed', {
|
|
30685
30685
|
token: token,
|
|
30686
30686
|
refreshToken: refreshToken,
|
|
30687
|
-
expiredAt: expiredAt
|
|
30687
|
+
expiredAt: expiredAt,
|
|
30688
|
+
oldToken: oldToken
|
|
30688
30689
|
});
|
|
30690
|
+
_this3.realtimeAdapter.unsusbcribeUserChannelByToken(oldToken);
|
|
30691
|
+
_this3.realtimeAdapter.subscribeUserChannelByToken(token);
|
|
30689
30692
|
},
|
|
30690
30693
|
getAuthenticationStatus: function getAuthenticationStatus() {
|
|
30691
30694
|
return _this3.user_id != null && _this3.isLogin;
|
|
@@ -33380,7 +33383,7 @@ var ExpiredTokenAdapter = /*#__PURE__*/function () {
|
|
|
33380
33383
|
* userId: string,
|
|
33381
33384
|
* refreshToken: string | null,
|
|
33382
33385
|
* expiredAt: string | null,
|
|
33383
|
-
* onTokenRefreshed: (token: string, refreshToken: string, expiredAt: Date) => void
|
|
33386
|
+
* onTokenRefreshed: (token: string, refreshToken: string, expiredAt: Date, oldToken: string) => void
|
|
33384
33387
|
* getAuthenticationStatus: () => boolean,
|
|
33385
33388
|
* }} param
|
|
33386
33389
|
*/
|
|
@@ -33400,7 +33403,7 @@ var ExpiredTokenAdapter = /*#__PURE__*/function () {
|
|
|
33400
33403
|
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_3___default()(this, "_expiredAt", null);
|
|
33401
33404
|
/** @type {import('./http').default} */
|
|
33402
33405
|
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_3___default()(this, "_http", void 0);
|
|
33403
|
-
/** @type {(token: string, refreshToken: string, expiredAt: Date) => void | undefined} */
|
|
33406
|
+
/** @type {(token: string, refreshToken: string, expiredAt: Date, oldToken: string) => void | undefined} */
|
|
33404
33407
|
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_3___default()(this, "_onTokenRefreshed", void 0);
|
|
33405
33408
|
/** @type {any} */
|
|
33406
33409
|
_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_3___default()(this, "_timerId", void 0);
|
|
@@ -33466,13 +33469,12 @@ var ExpiredTokenAdapter = /*#__PURE__*/function () {
|
|
|
33466
33469
|
var res = r.body.results;
|
|
33467
33470
|
var token = res.token;
|
|
33468
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);
|
|
33469
33474
|
_this2._http.setToken(res.token);
|
|
33470
33475
|
if (res.token_expires_at != null) {
|
|
33471
33476
|
_this2._expiredAt = new Date(res.token_expires_at);
|
|
33472
33477
|
}
|
|
33473
|
-
|
|
33474
|
-
// @ts-ignore
|
|
33475
|
-
(_this2$_onTokenRefres = _this2._onTokenRefreshed) === null || _this2$_onTokenRefres === void 0 || _this2$_onTokenRefres.call(_this2, token, _this2._refreshToken, _this2._expiredAt);
|
|
33476
33478
|
_this2._setTimer(_this2._expiredAt);
|
|
33477
33479
|
return res;
|
|
33478
33480
|
}));
|
|
@@ -34090,7 +34092,7 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
34090
34092
|
}
|
|
34091
34093
|
|
|
34092
34094
|
/**
|
|
34093
|
-
* @return {Promise<boolean}
|
|
34095
|
+
* @return {Promise<boolean>}
|
|
34094
34096
|
*/
|
|
34095
34097
|
}, {
|
|
34096
34098
|
key: "openConnection",
|
|
@@ -34180,12 +34182,12 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
34180
34182
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
34181
34183
|
args[_key2] = arguments[_key2];
|
|
34182
34184
|
}
|
|
34183
|
-
this.logger('subscribe to', args);
|
|
34184
34185
|
this.subscribtionBuffer.push(args);
|
|
34185
34186
|
while (this.mqtt != null && this.subscribtionBuffer.length > 0) {
|
|
34186
34187
|
var subs = this.subscribtionBuffer.shift();
|
|
34187
34188
|
if (subs != null) {
|
|
34188
34189
|
var _this$mqtt;
|
|
34190
|
+
this.logger('subscribe topic', subs);
|
|
34189
34191
|
(_this$mqtt = this.mqtt).subscribe.apply(_this$mqtt, _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(subs));
|
|
34190
34192
|
}
|
|
34191
34193
|
}
|
|
@@ -34201,6 +34203,7 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
34201
34203
|
var subs = this.unsubscribtionBuffer.shift();
|
|
34202
34204
|
if (subs != null) {
|
|
34203
34205
|
var _this$mqtt2;
|
|
34206
|
+
this.logger('unsubscribe topic', subs);
|
|
34204
34207
|
(_this$mqtt2 = this.mqtt).unsubscribe.apply(_this$mqtt2, _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(subs));
|
|
34205
34208
|
}
|
|
34206
34209
|
}
|
|
@@ -34217,6 +34220,7 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
34217
34220
|
while (this.mqtt != null && this.publishBuffer.length > 0) {
|
|
34218
34221
|
var data = this.publishBuffer.shift();
|
|
34219
34222
|
if (data != null) {
|
|
34223
|
+
this.logger('publish to', data.topic, data.payload, data.options);
|
|
34220
34224
|
this.mqtt.publish(data.topic, data.payload.toString(), data.options);
|
|
34221
34225
|
}
|
|
34222
34226
|
}
|
|
@@ -34498,6 +34502,27 @@ var MqttAdapter = /*#__PURE__*/function () {
|
|
|
34498
34502
|
this.subscribe("".concat(this.core.userData.token, "/n"));
|
|
34499
34503
|
this.subscribe("".concat(this.core.userData.token, "/update"));
|
|
34500
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
|
+
}
|
|
34501
34526
|
}, {
|
|
34502
34527
|
key: "publishPresence",
|
|
34503
34528
|
value: function publishPresence(userId) {
|