@abtnode/core 1.8.7 → 1.8.10
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/lib/blocklet/manager/disk.js +6 -0
- package/lib/event.js +6 -0
- package/lib/index.js +1 -0
- package/lib/team/manager.js +31 -5
- package/lib/util/blocklet.js +2 -1
- package/lib/util/upgrade.js +1 -1
- package/package.json +25 -25
|
@@ -2211,6 +2211,9 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
2211
2211
|
} else {
|
|
2212
2212
|
newBlocklet.children.push(newChild);
|
|
2213
2213
|
}
|
|
2214
|
+
|
|
2215
|
+
checkDuplicateComponents(newBlocklet.children);
|
|
2216
|
+
|
|
2214
2217
|
await this._upsertDynamicNavigation(newBlocklet.meta.did, newChild);
|
|
2215
2218
|
|
|
2216
2219
|
await this._downloadBlocklet(newBlocklet, oldBlocklet);
|
|
@@ -2713,6 +2716,9 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
2713
2716
|
|
|
2714
2717
|
await fs.writeFile(path.join(blocklet.env.dataDir, 'logo.svg'), createDidLogo(blocklet.meta.did));
|
|
2715
2718
|
|
|
2719
|
+
// Init db
|
|
2720
|
+
await this.teamManager.initTeam(blocklet.meta.did);
|
|
2721
|
+
|
|
2716
2722
|
this.emit(BlockletEvents.installed, { blocklet, context });
|
|
2717
2723
|
|
|
2718
2724
|
// Update dynamic component meta in blocklet settings
|
package/lib/event.js
CHANGED
|
@@ -25,6 +25,7 @@ module.exports = ({
|
|
|
25
25
|
handleRouting,
|
|
26
26
|
domainStatus,
|
|
27
27
|
teamAPI,
|
|
28
|
+
teamManager,
|
|
28
29
|
certManager,
|
|
29
30
|
node,
|
|
30
31
|
}) => {
|
|
@@ -50,6 +51,11 @@ module.exports = ({
|
|
|
50
51
|
// Subscribe events from eventHub and proxy to eventHandler
|
|
51
52
|
[...Object.values(BlockletEvents), ...Object.values(EVENTS)].forEach((name) => {
|
|
52
53
|
eventHub.on(name, (data) => {
|
|
54
|
+
if (name === BlockletEvents.removed) {
|
|
55
|
+
// Cleanup cache in teamManager for every node instance
|
|
56
|
+
teamManager.deleteTeam(data?.meta?.did, { closeDatabase: false });
|
|
57
|
+
}
|
|
58
|
+
|
|
53
59
|
if (typeof eventHandler === 'function') {
|
|
54
60
|
eventHandler({ name, data });
|
|
55
61
|
}
|
package/lib/index.js
CHANGED
package/lib/team/manager.js
CHANGED
|
@@ -104,7 +104,7 @@ class TeamManager extends EventEmitter {
|
|
|
104
104
|
|
|
105
105
|
async getUserState(did) {
|
|
106
106
|
// validate exist
|
|
107
|
-
if (!this.isNodeTeam(did) && !(await this.states.blocklet.
|
|
107
|
+
if (!this.isNodeTeam(did) && !(await this.states.blocklet.hasBlocklet(did))) {
|
|
108
108
|
logger.error('Did does not exist', { action: 'getUserState', did });
|
|
109
109
|
throw new Error(`Did does not exist: ${did}`);
|
|
110
110
|
}
|
|
@@ -143,7 +143,7 @@ class TeamManager extends EventEmitter {
|
|
|
143
143
|
|
|
144
144
|
async getSessionState(did) {
|
|
145
145
|
// validate exist
|
|
146
|
-
if (!this.isNodeTeam(did) && !(await this.states.blocklet.
|
|
146
|
+
if (!this.isNodeTeam(did) && !(await this.states.blocklet.hasBlocklet(did))) {
|
|
147
147
|
logger.error('Did does not exist', { action: 'getSessionState', did });
|
|
148
148
|
throw new Error(`Did does not exist: ${did}`);
|
|
149
149
|
}
|
|
@@ -182,7 +182,7 @@ class TeamManager extends EventEmitter {
|
|
|
182
182
|
logger.info('get rbac', { did });
|
|
183
183
|
|
|
184
184
|
// validate exist
|
|
185
|
-
if (!this.isNodeTeam(did) && !(await this.states.blocklet.
|
|
185
|
+
if (!this.isNodeTeam(did) && !(await this.states.blocklet.hasBlocklet(did))) {
|
|
186
186
|
logger.error('Did does not exist', { action: 'getRBAC', did });
|
|
187
187
|
throw new Error(`Did does not exist: ${did}`);
|
|
188
188
|
}
|
|
@@ -288,8 +288,34 @@ class TeamManager extends EventEmitter {
|
|
|
288
288
|
return owner;
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
-
async
|
|
292
|
-
if (
|
|
291
|
+
async initTeam(did) {
|
|
292
|
+
if (!did) {
|
|
293
|
+
logger.error('initTeam: did does not exist');
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
logger.info('initTeam', { did });
|
|
298
|
+
|
|
299
|
+
const rbac = await this.getRBAC(did);
|
|
300
|
+
const user = await this.getUserState(did);
|
|
301
|
+
const session = await this.getSessionState(did);
|
|
302
|
+
|
|
303
|
+
this.cache[did] = {
|
|
304
|
+
rbac,
|
|
305
|
+
user,
|
|
306
|
+
session,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
async deleteTeam(did, { closeDatabase: closeDB = true } = {}) {
|
|
311
|
+
if (!did) {
|
|
312
|
+
logger.error('deleteTeam: did does not exist');
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
logger.info('deleteTeam', { did, closeDB });
|
|
317
|
+
|
|
318
|
+
if (closeDB && this.cache[did]) {
|
|
293
319
|
try {
|
|
294
320
|
if (this.cache[did].rbac) {
|
|
295
321
|
await closeDatabase(this.cache[did].rbac.storage.db);
|
package/lib/util/blocklet.js
CHANGED
|
@@ -21,6 +21,7 @@ const CustomError = require('@abtnode/util/lib/custom-error');
|
|
|
21
21
|
const getFolderSize = require('@abtnode/util/lib/get-folder-size');
|
|
22
22
|
const normalizePathPrefix = require('@abtnode/util/lib/normalize-path-prefix');
|
|
23
23
|
const hashFiles = require('@abtnode/util/lib/hash-files');
|
|
24
|
+
const isPathPrefixEqual = require('@abtnode/util/lib/is-path-prefix-equal');
|
|
24
25
|
const { BLOCKLET_MAX_MEM_LIMIT_IN_MB, BLOCKLET_STORE_API_BLOCKLET_PREFIX } = require('@abtnode/constant');
|
|
25
26
|
|
|
26
27
|
const {
|
|
@@ -1191,7 +1192,7 @@ const checkDuplicateComponents = (components = []) => {
|
|
|
1191
1192
|
}
|
|
1192
1193
|
|
|
1193
1194
|
const duplicateMountPoints = components.filter(
|
|
1194
|
-
(item, index) => components.findIndex((x) => x.mountPoint
|
|
1195
|
+
(item, index) => components.findIndex((x) => isPathPrefixEqual(x.mountPoint, item.mountPoint)) !== index
|
|
1195
1196
|
);
|
|
1196
1197
|
if (duplicateMountPoints.length) {
|
|
1197
1198
|
throw new Error(`mount point must be unique: ${duplicateMountPoints.map((x) => x.mountPoint).join(', ')}`);
|
package/lib/util/upgrade.js
CHANGED
|
@@ -128,7 +128,7 @@ const doUpgrade = async (session) => {
|
|
|
128
128
|
if (session.stage === NODE_UPGRADE_PROGRESS.CLEANUP) {
|
|
129
129
|
logger.info('cleanup for upgrading', { from, to, sessionId });
|
|
130
130
|
await goNextState(NODE_UPGRADE_PROGRESS.COMPLETE);
|
|
131
|
-
await sleep(
|
|
131
|
+
await sleep(8000);
|
|
132
132
|
await states.node.updateNodeInfo({ nextVersion: '', version: to, upgradeSessionId: '' });
|
|
133
133
|
try {
|
|
134
134
|
await states.node.exitMode(NODE_MODES.MAINTENANCE);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.8.
|
|
6
|
+
"version": "1.8.10",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,32 +19,32 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/certificate-manager": "1.8.
|
|
23
|
-
"@abtnode/constant": "1.8.
|
|
24
|
-
"@abtnode/cron": "1.8.
|
|
25
|
-
"@abtnode/db": "1.8.
|
|
26
|
-
"@abtnode/logger": "1.8.
|
|
27
|
-
"@abtnode/queue": "1.8.
|
|
28
|
-
"@abtnode/rbac": "1.8.
|
|
29
|
-
"@abtnode/router-provider": "1.8.
|
|
30
|
-
"@abtnode/static-server": "1.8.
|
|
31
|
-
"@abtnode/timemachine": "1.8.
|
|
32
|
-
"@abtnode/util": "1.8.
|
|
33
|
-
"@arcblock/did": "1.17.
|
|
22
|
+
"@abtnode/certificate-manager": "1.8.10",
|
|
23
|
+
"@abtnode/constant": "1.8.10",
|
|
24
|
+
"@abtnode/cron": "1.8.10",
|
|
25
|
+
"@abtnode/db": "1.8.10",
|
|
26
|
+
"@abtnode/logger": "1.8.10",
|
|
27
|
+
"@abtnode/queue": "1.8.10",
|
|
28
|
+
"@abtnode/rbac": "1.8.10",
|
|
29
|
+
"@abtnode/router-provider": "1.8.10",
|
|
30
|
+
"@abtnode/static-server": "1.8.10",
|
|
31
|
+
"@abtnode/timemachine": "1.8.10",
|
|
32
|
+
"@abtnode/util": "1.8.10",
|
|
33
|
+
"@arcblock/did": "1.17.11",
|
|
34
34
|
"@arcblock/did-motif": "^1.1.10",
|
|
35
|
-
"@arcblock/did-util": "1.17.
|
|
36
|
-
"@arcblock/event-hub": "1.17.
|
|
37
|
-
"@arcblock/jwt": "^1.17.
|
|
35
|
+
"@arcblock/did-util": "1.17.11",
|
|
36
|
+
"@arcblock/event-hub": "1.17.11",
|
|
37
|
+
"@arcblock/jwt": "^1.17.11",
|
|
38
38
|
"@arcblock/pm2-events": "^0.0.5",
|
|
39
|
-
"@arcblock/vc": "1.17.
|
|
40
|
-
"@blocklet/meta": "1.8.
|
|
41
|
-
"@blocklet/sdk": "1.8.
|
|
39
|
+
"@arcblock/vc": "1.17.11",
|
|
40
|
+
"@blocklet/meta": "1.8.10",
|
|
41
|
+
"@blocklet/sdk": "1.8.10",
|
|
42
42
|
"@fidm/x509": "^1.2.1",
|
|
43
|
-
"@nedb/core": "^1.3.
|
|
44
|
-
"@nedb/multi": "^1.3.
|
|
45
|
-
"@ocap/mcrypto": "1.17.
|
|
46
|
-
"@ocap/util": "1.17.
|
|
47
|
-
"@ocap/wallet": "1.17.
|
|
43
|
+
"@nedb/core": "^1.3.4",
|
|
44
|
+
"@nedb/multi": "^1.3.4",
|
|
45
|
+
"@ocap/mcrypto": "1.17.11",
|
|
46
|
+
"@ocap/util": "1.17.11",
|
|
47
|
+
"@ocap/wallet": "1.17.11",
|
|
48
48
|
"@slack/webhook": "^5.0.4",
|
|
49
49
|
"axios": "^0.27.2",
|
|
50
50
|
"axon": "^2.0.3",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"express": "^4.18.1",
|
|
83
83
|
"jest": "^27.5.1"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "84f655bd7b8d55fde2656fac8671faad3c3bde28"
|
|
86
86
|
}
|