@abtnode/core 1.8.14 → 1.8.17
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/api/team.js +124 -2
- package/lib/blocklet/manager/base.js +2 -0
- package/lib/blocklet/manager/disk.js +27 -72
- package/lib/index.js +5 -4
- package/lib/states/access-key.js +16 -14
- package/lib/states/audit-log.js +16 -6
- package/lib/states/base.js +2 -2
- package/lib/states/blocklet-extras.js +10 -10
- package/lib/states/blocklet.js +20 -19
- package/lib/states/cache.js +8 -6
- package/lib/states/challenge.js +5 -5
- package/lib/states/index.js +13 -13
- package/lib/states/migration.js +4 -4
- package/lib/states/node.js +12 -12
- package/lib/states/notification.js +8 -8
- package/lib/states/session.js +16 -14
- package/lib/states/site.js +10 -22
- package/lib/states/user.js +11 -21
- package/lib/states/webhook.js +5 -5
- package/lib/util/blocklet.js +72 -1
- package/package.json +24 -25
package/lib/util/blocklet.js
CHANGED
|
@@ -11,6 +11,7 @@ const ssri = require('ssri');
|
|
|
11
11
|
const diff = require('deep-diff');
|
|
12
12
|
|
|
13
13
|
const { toHex } = require('@ocap/util');
|
|
14
|
+
const { isValid: isValidDid } = require('@arcblock/did');
|
|
14
15
|
const logger = require('@abtnode/logger')('@abtnode/core:util:blocklet');
|
|
15
16
|
const pm2 = require('@abtnode/util/lib/async-pm2');
|
|
16
17
|
const sleep = require('@abtnode/util/lib/sleep');
|
|
@@ -58,11 +59,13 @@ const {
|
|
|
58
59
|
getBlockletMetaFromUrls,
|
|
59
60
|
getBlockletMetaFromUrl,
|
|
60
61
|
} = require('@blocklet/meta/lib/util-meta');
|
|
62
|
+
const getComponentProcessId = require('@blocklet/meta/lib/get-component-process-id');
|
|
61
63
|
|
|
62
64
|
const { validate: validateEngine, get: getEngine } = require('../blocklet/manager/engine');
|
|
63
65
|
|
|
64
66
|
const isRequirementsSatisfied = require('./requirement');
|
|
65
67
|
const { getDidDomainForBlocklet } = require('./get-domain-for-blocklet');
|
|
68
|
+
const { getBlockletDomainGroupName } = require('./router');
|
|
66
69
|
const { isBeforeInstalled, expandBundle, findInterfacePortByName, validateBlockletMeta } = require('./index');
|
|
67
70
|
|
|
68
71
|
/**
|
|
@@ -208,7 +211,8 @@ const fillBlockletConfigs = (blocklet, configs) => {
|
|
|
208
211
|
acc[x.key] = x.value;
|
|
209
212
|
return acc;
|
|
210
213
|
}, {});
|
|
211
|
-
blocklet.
|
|
214
|
+
blocklet.environments = blocklet.environments || [];
|
|
215
|
+
blocklet.environmentObj = blocklet.environments.reduce((acc, x) => {
|
|
212
216
|
acc[x.key] = x.value;
|
|
213
217
|
return acc;
|
|
214
218
|
}, {});
|
|
@@ -1223,6 +1227,72 @@ const ensureMeta = (meta, { name, did } = {}) => {
|
|
|
1223
1227
|
return newMeta;
|
|
1224
1228
|
};
|
|
1225
1229
|
|
|
1230
|
+
const getBlocklet = async ({
|
|
1231
|
+
did,
|
|
1232
|
+
dataDirs,
|
|
1233
|
+
states,
|
|
1234
|
+
e2eMode = false,
|
|
1235
|
+
validateEnv = true,
|
|
1236
|
+
throwOnNotExist = true,
|
|
1237
|
+
ensureDirs = true,
|
|
1238
|
+
} = {}) => {
|
|
1239
|
+
if (!did) {
|
|
1240
|
+
throw new Error('Blocklet did does not exist');
|
|
1241
|
+
}
|
|
1242
|
+
if (!isValidDid(did)) {
|
|
1243
|
+
throw new Error(`Blocklet did is invalid: ${did}`);
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
if (!dataDirs) {
|
|
1247
|
+
throw new Error('dataDirs does not exist');
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
if (!states) {
|
|
1251
|
+
throw new Error('states does not exist');
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
const blocklet = await states.blocklet.getBlocklet(did);
|
|
1255
|
+
if (!blocklet) {
|
|
1256
|
+
if (throwOnNotExist) {
|
|
1257
|
+
throw new Error(`can not find blocklet in database by did ${did}`);
|
|
1258
|
+
}
|
|
1259
|
+
return null;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
// app settings
|
|
1263
|
+
const settings = await states.blockletExtras.getSettings(blocklet.meta.did);
|
|
1264
|
+
blocklet.trustedPassports = get(settings, 'trustedPassports') || [];
|
|
1265
|
+
blocklet.enablePassportIssuance = get(settings, 'enablePassportIssuance', true);
|
|
1266
|
+
blocklet.settings = settings || {};
|
|
1267
|
+
|
|
1268
|
+
// app site
|
|
1269
|
+
const sites = await states.site.getSites();
|
|
1270
|
+
const domain = getBlockletDomainGroupName(blocklet.meta.did);
|
|
1271
|
+
blocklet.site = (sites || []).find((x) => x.domain === domain);
|
|
1272
|
+
|
|
1273
|
+
await forEachBlocklet(blocklet, async (component, { id, level, ancestors }) => {
|
|
1274
|
+
// component env
|
|
1275
|
+
component.env = {
|
|
1276
|
+
id,
|
|
1277
|
+
name: getComponentName(component, ancestors),
|
|
1278
|
+
processId: getComponentProcessId(component, ancestors),
|
|
1279
|
+
...getComponentDirs(component, {
|
|
1280
|
+
dataDirs,
|
|
1281
|
+
ensure: ensureDirs,
|
|
1282
|
+
validate: validateEnv,
|
|
1283
|
+
ancestors,
|
|
1284
|
+
e2eMode: level === 0 ? e2eMode : false,
|
|
1285
|
+
}),
|
|
1286
|
+
};
|
|
1287
|
+
|
|
1288
|
+
// component config
|
|
1289
|
+
const configs = await states.blockletExtras.getConfigs([...ancestors.map((x) => x.meta.did), component.meta.did]);
|
|
1290
|
+
fillBlockletConfigs(component, configs);
|
|
1291
|
+
});
|
|
1292
|
+
|
|
1293
|
+
return blocklet;
|
|
1294
|
+
};
|
|
1295
|
+
|
|
1226
1296
|
module.exports = {
|
|
1227
1297
|
forEachBlocklet,
|
|
1228
1298
|
getBlockletMetaFromUrl: (url) => getBlockletMetaFromUrl(url, { logger }),
|
|
@@ -1261,4 +1331,5 @@ module.exports = {
|
|
|
1261
1331
|
needBlockletDownload,
|
|
1262
1332
|
findAvailableDid,
|
|
1263
1333
|
ensureMeta,
|
|
1334
|
+
getBlocklet,
|
|
1264
1335
|
};
|
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.17",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,32 +19,31 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/
|
|
23
|
-
"@abtnode/
|
|
24
|
-
"@abtnode/
|
|
25
|
-
"@abtnode/
|
|
26
|
-
"@abtnode/
|
|
27
|
-
"@abtnode/
|
|
28
|
-
"@abtnode/
|
|
29
|
-
"@abtnode/
|
|
30
|
-
"@abtnode/
|
|
31
|
-
"@abtnode/
|
|
32
|
-
"@abtnode/
|
|
33
|
-
"@
|
|
22
|
+
"@abtnode/auth": "1.8.17",
|
|
23
|
+
"@abtnode/certificate-manager": "1.8.17",
|
|
24
|
+
"@abtnode/constant": "1.8.17",
|
|
25
|
+
"@abtnode/cron": "1.8.17",
|
|
26
|
+
"@abtnode/db": "1.8.17",
|
|
27
|
+
"@abtnode/logger": "1.8.17",
|
|
28
|
+
"@abtnode/queue": "1.8.17",
|
|
29
|
+
"@abtnode/rbac": "1.8.17",
|
|
30
|
+
"@abtnode/router-provider": "1.8.17",
|
|
31
|
+
"@abtnode/static-server": "1.8.17",
|
|
32
|
+
"@abtnode/timemachine": "1.8.17",
|
|
33
|
+
"@abtnode/util": "1.8.17",
|
|
34
|
+
"@arcblock/did": "1.17.19",
|
|
34
35
|
"@arcblock/did-motif": "^1.1.10",
|
|
35
|
-
"@arcblock/did-util": "1.17.
|
|
36
|
-
"@arcblock/event-hub": "1.17.
|
|
37
|
-
"@arcblock/jwt": "^1.17.
|
|
36
|
+
"@arcblock/did-util": "1.17.19",
|
|
37
|
+
"@arcblock/event-hub": "1.17.19",
|
|
38
|
+
"@arcblock/jwt": "^1.17.19",
|
|
38
39
|
"@arcblock/pm2-events": "^0.0.5",
|
|
39
|
-
"@arcblock/vc": "1.17.
|
|
40
|
-
"@blocklet/meta": "1.8.
|
|
41
|
-
"@blocklet/sdk": "1.8.
|
|
40
|
+
"@arcblock/vc": "1.17.19",
|
|
41
|
+
"@blocklet/meta": "1.8.17",
|
|
42
|
+
"@blocklet/sdk": "1.8.17",
|
|
42
43
|
"@fidm/x509": "^1.2.1",
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"@ocap/
|
|
46
|
-
"@ocap/util": "1.17.17",
|
|
47
|
-
"@ocap/wallet": "1.17.17",
|
|
44
|
+
"@ocap/mcrypto": "1.17.19",
|
|
45
|
+
"@ocap/util": "1.17.19",
|
|
46
|
+
"@ocap/wallet": "1.17.19",
|
|
48
47
|
"@slack/webhook": "^5.0.4",
|
|
49
48
|
"axios": "^0.27.2",
|
|
50
49
|
"axon": "^2.0.3",
|
|
@@ -81,5 +80,5 @@
|
|
|
81
80
|
"express": "^4.18.1",
|
|
82
81
|
"jest": "^27.5.1"
|
|
83
82
|
},
|
|
84
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "aa1854b3b71a6250182bfcad794235099f38a514"
|
|
85
84
|
}
|