@abtnode/core 1.8.35 → 1.8.36
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 +43 -35
- package/lib/index.js +1 -0
- package/lib/states/access-key.js +15 -2
- package/lib/validators/blocklet.js +2 -1
- package/package.json +17 -17
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const fs = require('fs-extra');
|
|
4
4
|
const { fileURLToPath } = require('url');
|
|
5
5
|
const path = require('path');
|
|
6
|
+
const flat = require('flat');
|
|
6
7
|
const urlHttp = require('url-http');
|
|
7
8
|
const get = require('lodash/get');
|
|
8
9
|
const pick = require('lodash/pick');
|
|
@@ -39,7 +40,6 @@ const {
|
|
|
39
40
|
forEachChild,
|
|
40
41
|
getComponentId,
|
|
41
42
|
getComponentBundleId,
|
|
42
|
-
isExternalBlocklet,
|
|
43
43
|
} = require('@blocklet/meta/lib/util');
|
|
44
44
|
const getComponentProcessId = require('@blocklet/meta/lib/get-component-process-id');
|
|
45
45
|
const validateBlockletEntry = require('@blocklet/meta/lib/entry');
|
|
@@ -860,46 +860,54 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
860
860
|
return this.attachRuntimeInfo({ did, nodeInfo, diskInfo: true, context });
|
|
861
861
|
}
|
|
862
862
|
|
|
863
|
-
async
|
|
864
|
-
const
|
|
865
|
-
|
|
863
|
+
async attachBlockletListRuntimeInfo({ blocklets, useCache }, context) {
|
|
864
|
+
const nodeInfo = await states.node.read();
|
|
865
|
+
const updated = (
|
|
866
|
+
await Promise.all(
|
|
867
|
+
blocklets.map((x) => {
|
|
868
|
+
if (isBeforeInstalled(x.status)) {
|
|
869
|
+
return x;
|
|
870
|
+
}
|
|
866
871
|
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
const updated = (
|
|
870
|
-
await Promise.all(
|
|
871
|
-
blocklets.map((x) => {
|
|
872
|
-
if (isBeforeInstalled(x.status)) {
|
|
873
|
-
return x;
|
|
874
|
-
}
|
|
872
|
+
const cachedBlocklet =
|
|
873
|
+
useCache && this.cachedBlocklets ? this.cachedBlocklets.find((y) => y.meta.did === x.meta.did) : null;
|
|
875
874
|
|
|
876
|
-
|
|
877
|
-
|
|
875
|
+
return this.attachRuntimeInfo({
|
|
876
|
+
did: x.meta.did,
|
|
877
|
+
nodeInfo,
|
|
878
|
+
diskInfo: false,
|
|
879
|
+
context,
|
|
880
|
+
cachedBlocklet,
|
|
881
|
+
});
|
|
882
|
+
})
|
|
883
|
+
)
|
|
884
|
+
).filter(Boolean);
|
|
878
885
|
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
diskInfo: false,
|
|
883
|
-
context,
|
|
884
|
-
cachedBlocklet,
|
|
885
|
-
});
|
|
886
|
-
})
|
|
887
|
-
)
|
|
888
|
-
).filter(Boolean);
|
|
886
|
+
this.cachedBlocklets = cloneDeep(updated);
|
|
887
|
+
return updated;
|
|
888
|
+
}
|
|
889
889
|
|
|
890
|
-
|
|
891
|
-
|
|
890
|
+
async list({ includeRuntimeInfo = true, useCache = true, query, filter } = {}, context) {
|
|
891
|
+
const condition = { ...flat(query || {}) };
|
|
892
|
+
if (filter === 'external-only') {
|
|
893
|
+
condition.controller = {
|
|
894
|
+
$exists: true,
|
|
895
|
+
};
|
|
892
896
|
}
|
|
893
897
|
|
|
894
898
|
if (filter === 'external-excluded') {
|
|
895
|
-
|
|
899
|
+
condition.controller = {
|
|
900
|
+
$exists: false,
|
|
901
|
+
};
|
|
896
902
|
}
|
|
897
903
|
|
|
898
|
-
|
|
899
|
-
|
|
904
|
+
const blocklets = await states.blocklet.getBlocklets(condition);
|
|
905
|
+
|
|
906
|
+
if (includeRuntimeInfo) {
|
|
907
|
+
return this.attachBlockletListRuntimeInfo({ blocklets, useCache }, context);
|
|
900
908
|
}
|
|
901
909
|
|
|
902
|
-
return
|
|
910
|
+
return blocklets;
|
|
903
911
|
}
|
|
904
912
|
|
|
905
913
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -1989,14 +1997,14 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
1989
1997
|
throw new Error('Can not install an already installed blocklet');
|
|
1990
1998
|
}
|
|
1991
1999
|
|
|
1992
|
-
if (controller?.
|
|
1993
|
-
// sometimes nedb will throw error if use states.blocklet.count({ ['controller.
|
|
2000
|
+
if (controller?.nftId) {
|
|
2001
|
+
// sometimes nedb will throw error if use states.blocklet.count({ ['controller.nftId']: controller.nftId })
|
|
1994
2002
|
const blocklets = await states.blocklet.find({}, { controller: 1 });
|
|
1995
|
-
const count = blocklets.filter((x) => x.controller?.
|
|
2003
|
+
const count = blocklets.filter((x) => x.controller?.nftId === controller.nftId).length;
|
|
1996
2004
|
|
|
1997
2005
|
if (count >= (controller.appMaxCount || 1)) {
|
|
1998
2006
|
throw new Error(
|
|
1999
|
-
`You can only install ${controller.appMaxCount} blocklet with this credential: ${controller.
|
|
2007
|
+
`You can only install ${controller.appMaxCount} blocklet with this credential: ${controller.nftId}`
|
|
2000
2008
|
);
|
|
2001
2009
|
}
|
|
2002
2010
|
}
|
|
@@ -2016,7 +2024,7 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
2016
2024
|
/**
|
|
2017
2025
|
* @type {{
|
|
2018
2026
|
* id: string;
|
|
2019
|
-
*
|
|
2027
|
+
* nftId: string;
|
|
2020
2028
|
* expireDate: Date;
|
|
2021
2029
|
* }} Controller
|
|
2022
2030
|
*
|
package/lib/index.js
CHANGED
|
@@ -355,6 +355,7 @@ function ABTNode(options) {
|
|
|
355
355
|
// Access Key
|
|
356
356
|
getAccessKeys: states.accessKey.list.bind(states.accessKey),
|
|
357
357
|
getAccessKey: states.accessKey.detail.bind(states.accessKey),
|
|
358
|
+
getAccessKeyByTag: states.accessKey.getAccessKeyByTag.bind(states.accessKey),
|
|
358
359
|
createAccessKey: states.accessKey.create.bind(states.accessKey),
|
|
359
360
|
updateAccessKey: states.accessKey.update.bind(states.accessKey),
|
|
360
361
|
deleteAccessKey: states.accessKey.remove.bind(states.accessKey),
|
package/lib/states/access-key.js
CHANGED
|
@@ -31,8 +31,8 @@ class AccessKeyState extends BaseState {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
async create(input
|
|
35
|
-
const { remark, passport } = input;
|
|
34
|
+
async create(input, context) {
|
|
35
|
+
const { remark, passport, tag } = input || {};
|
|
36
36
|
|
|
37
37
|
validateRemark(remark);
|
|
38
38
|
validatePassport(passport);
|
|
@@ -43,10 +43,15 @@ class AccessKeyState extends BaseState {
|
|
|
43
43
|
accessKeyPublic: wallet.publicKey,
|
|
44
44
|
passport,
|
|
45
45
|
};
|
|
46
|
+
|
|
46
47
|
if (remark) {
|
|
47
48
|
data.remark = remark;
|
|
48
49
|
}
|
|
49
50
|
|
|
51
|
+
if (tag) {
|
|
52
|
+
data.tag = tag;
|
|
53
|
+
}
|
|
54
|
+
|
|
50
55
|
data.createdBy = getUserName(context);
|
|
51
56
|
data.updatedBy = getUserName(context);
|
|
52
57
|
|
|
@@ -57,6 +62,14 @@ class AccessKeyState extends BaseState {
|
|
|
57
62
|
};
|
|
58
63
|
}
|
|
59
64
|
|
|
65
|
+
async getAccessKeyByTag({ tag } = {}) {
|
|
66
|
+
if (!tag) {
|
|
67
|
+
throw new Error('tag should not be empty');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return this.findOne({ tag });
|
|
71
|
+
}
|
|
72
|
+
|
|
60
73
|
// eslint-disable-next-line no-unused-vars
|
|
61
74
|
async list(params, context) {
|
|
62
75
|
const res = await this.paginate({}, { createdAt: -1 }, { pageSize: 100 });
|
|
@@ -5,7 +5,8 @@ const Joi = JOI.extend(didExtension);
|
|
|
5
5
|
|
|
6
6
|
const blockletController = Joi.object({
|
|
7
7
|
id: Joi.DID().required(), // userDid
|
|
8
|
-
|
|
8
|
+
nftId: Joi.DID().required(),
|
|
9
|
+
nftOwner: Joi.DID().required(),
|
|
9
10
|
appMaxCount: Joi.number().required().min(1),
|
|
10
11
|
expireDate: Joi.date(),
|
|
11
12
|
}).options({ stripUnknown: true });
|
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.36",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,18 +19,18 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/auth": "1.8.
|
|
23
|
-
"@abtnode/certificate-manager": "1.8.
|
|
24
|
-
"@abtnode/constant": "1.8.
|
|
25
|
-
"@abtnode/cron": "1.8.
|
|
26
|
-
"@abtnode/db": "1.8.
|
|
27
|
-
"@abtnode/logger": "1.8.
|
|
28
|
-
"@abtnode/queue": "1.8.
|
|
29
|
-
"@abtnode/rbac": "1.8.
|
|
30
|
-
"@abtnode/router-provider": "1.8.
|
|
31
|
-
"@abtnode/static-server": "1.8.
|
|
32
|
-
"@abtnode/timemachine": "1.8.
|
|
33
|
-
"@abtnode/util": "1.8.
|
|
22
|
+
"@abtnode/auth": "1.8.36",
|
|
23
|
+
"@abtnode/certificate-manager": "1.8.36",
|
|
24
|
+
"@abtnode/constant": "1.8.36",
|
|
25
|
+
"@abtnode/cron": "1.8.36",
|
|
26
|
+
"@abtnode/db": "1.8.36",
|
|
27
|
+
"@abtnode/logger": "1.8.36",
|
|
28
|
+
"@abtnode/queue": "1.8.36",
|
|
29
|
+
"@abtnode/rbac": "1.8.36",
|
|
30
|
+
"@abtnode/router-provider": "1.8.36",
|
|
31
|
+
"@abtnode/static-server": "1.8.36",
|
|
32
|
+
"@abtnode/timemachine": "1.8.36",
|
|
33
|
+
"@abtnode/util": "1.8.36",
|
|
34
34
|
"@arcblock/did": "1.18.15",
|
|
35
35
|
"@arcblock/did-motif": "^1.1.10",
|
|
36
36
|
"@arcblock/did-util": "1.18.15",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"@arcblock/jwt": "^1.18.15",
|
|
39
39
|
"@arcblock/pm2-events": "^0.0.5",
|
|
40
40
|
"@arcblock/vc": "1.18.15",
|
|
41
|
-
"@blocklet/constant": "1.8.
|
|
42
|
-
"@blocklet/meta": "1.8.
|
|
43
|
-
"@blocklet/sdk": "1.8.
|
|
41
|
+
"@blocklet/constant": "1.8.36",
|
|
42
|
+
"@blocklet/meta": "1.8.36",
|
|
43
|
+
"@blocklet/sdk": "1.8.36",
|
|
44
44
|
"@fidm/x509": "^1.2.1",
|
|
45
45
|
"@ocap/mcrypto": "1.18.15",
|
|
46
46
|
"@ocap/util": "1.18.15",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"express": "^4.18.2",
|
|
83
83
|
"jest": "^27.5.1"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "507e974ce88bad1aa002c593130b32982207f803"
|
|
86
86
|
}
|