@abtnode/core 1.6.15 → 1.6.16
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 +11 -4
- package/lib/event.js +1 -1
- package/lib/index.js +1 -0
- package/lib/router/helper.js +7 -3
- package/lib/states/blocklet.js +14 -12
- package/lib/util/blocklet.js +5 -0
- package/lib/util/default-node-config.js +1 -1
- package/lib/validators/node.js +11 -12
- package/package.json +20 -20
|
@@ -12,7 +12,7 @@ const LRU = require('lru-cache');
|
|
|
12
12
|
|
|
13
13
|
const { isValid: isValidDid } = require('@arcblock/did');
|
|
14
14
|
const { verifyPresentation } = require('@arcblock/vc');
|
|
15
|
-
const { toBase58 } = require('@ocap/util');
|
|
15
|
+
const { toBase58, isHex } = require('@ocap/util');
|
|
16
16
|
const { fromSecretKey } = require('@ocap/wallet');
|
|
17
17
|
|
|
18
18
|
const logger = require('@abtnode/logger')('@abtnode/core:blocklet:manager');
|
|
@@ -189,9 +189,9 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
|
|
192
|
+
const blocklet = await states.blocklet.getBlocklet(meta.did);
|
|
193
193
|
|
|
194
|
-
return meta;
|
|
194
|
+
return { meta, isFree, isInstalled: !!blocklet };
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
async installBlockletFromVc({ vcPresentation, challenge }, context) {
|
|
@@ -549,6 +549,14 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
549
549
|
}
|
|
550
550
|
}
|
|
551
551
|
|
|
552
|
+
if (x.key === 'BLOCKLET_PASSPORT_COLOR') {
|
|
553
|
+
if (x.value && x.value !== 'auto') {
|
|
554
|
+
if (x.value.length !== 7 || !isHex(x.value.slice(-6))) {
|
|
555
|
+
throw new Error('BLOCKLET_PASSPORT_COLOR must be a hex encoded color, eg. #ffeeaa');
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
552
560
|
blocklet.configObj[x.key] = x.value;
|
|
553
561
|
}
|
|
554
562
|
|
|
@@ -558,7 +566,6 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
558
566
|
hooks: Object.assign(blocklet.meta.hooks || {}, blocklet.meta.scripts || {}),
|
|
559
567
|
exitOnError: true,
|
|
560
568
|
env: { ...getRuntimeEnvironments(blocklet, nodeEnvironments), ...blocklet.configObj },
|
|
561
|
-
notification: states.notification,
|
|
562
569
|
did,
|
|
563
570
|
context,
|
|
564
571
|
progress: blocklet.mode === BLOCKLET_MODES.DEVELOPMENT,
|
package/lib/event.js
CHANGED
|
@@ -182,7 +182,7 @@ module.exports = ({
|
|
|
182
182
|
.catch((error) => logger.error('refresh blocklets failed on initialize the registry', { error }));
|
|
183
183
|
|
|
184
184
|
// We need update router on some fields change
|
|
185
|
-
const fields = ['enableWelcomePage', 'webWalletUrl'];
|
|
185
|
+
const fields = ['enableWelcomePage', 'webWalletUrl', 'registerUrl'];
|
|
186
186
|
const shouldUpdateRouter = fields.some((x) => nodeInfo[x] !== oldInfo[x]);
|
|
187
187
|
if (shouldUpdateRouter) {
|
|
188
188
|
handleRouting(nodeInfo).catch((err) => {
|
package/lib/index.js
CHANGED
package/lib/router/helper.js
CHANGED
|
@@ -244,6 +244,9 @@ const ensureLatestNodeInfo = async (sites = [], { withDefaultCors = true } = {})
|
|
|
244
244
|
site.domain = DOMAIN_FOR_IP_SITE_REGEXP;
|
|
245
245
|
|
|
246
246
|
if (withDefaultCors) {
|
|
247
|
+
// Allow CORS from "Install on ABT Node"
|
|
248
|
+
addCorsToSite(site, info.registerUrl);
|
|
249
|
+
|
|
247
250
|
// Allow CORS from "Web Wallet"
|
|
248
251
|
addCorsToSite(site, info.webWalletUrl);
|
|
249
252
|
}
|
|
@@ -434,7 +437,8 @@ module.exports = function getRouterHelpers({ dataDirs, routingSnapshot, routerMa
|
|
|
434
437
|
|
|
435
438
|
const https = get(info, 'routing.https', true);
|
|
436
439
|
const dashboardDomain = get(info, 'routing.dashboardDomain', '');
|
|
437
|
-
const certDownloadAddress =
|
|
440
|
+
const certDownloadAddress =
|
|
441
|
+
process.env.ABT_NODE_DASHBOARD_CERT_DOWN_URL || get(info, 'routing.dashboardCertDownloadAddress', '');
|
|
438
442
|
if (!https || !dashboardDomain || !certDownloadAddress) {
|
|
439
443
|
return;
|
|
440
444
|
}
|
|
@@ -508,9 +512,9 @@ module.exports = function getRouterHelpers({ dataDirs, routingSnapshot, routerMa
|
|
|
508
512
|
return { status: 'existed' };
|
|
509
513
|
}
|
|
510
514
|
|
|
511
|
-
logger.debug('downloading certificate', { url: downloadUrl, dashboardDomain });
|
|
515
|
+
logger.debug('downloading dashboard ip-domain certificate', { url: downloadUrl, dashboardDomain });
|
|
512
516
|
await updateDashboardCertificate({ checkExpire: false });
|
|
513
|
-
logger.debug('
|
|
517
|
+
logger.debug('downloaded dashboard ip-domain certificate', { url: downloadUrl, dashboardDomain });
|
|
514
518
|
return { status: 'downloaded' };
|
|
515
519
|
};
|
|
516
520
|
|
package/lib/states/blocklet.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
/* eslint-disable no-underscore-dangle */
|
|
5
5
|
const omit = require('lodash/omit');
|
|
6
6
|
const uniq = require('lodash/uniq');
|
|
7
|
+
const cloneDeep = require('lodash/cloneDeep');
|
|
7
8
|
const detectPort = require('detect-port');
|
|
8
9
|
const Lock = require('@abtnode/util/lib/lock');
|
|
9
10
|
const security = require('@abtnode/util/lib/security');
|
|
@@ -119,7 +120,7 @@ class BlockletState extends BaseState {
|
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
this.emit('remove', doc);
|
|
122
|
-
return resolve(doc);
|
|
123
|
+
return resolve(formatBlocklet(doc, 'onRead', this.options.dek));
|
|
123
124
|
});
|
|
124
125
|
})
|
|
125
126
|
);
|
|
@@ -196,7 +197,7 @@ class BlockletState extends BaseState {
|
|
|
196
197
|
}
|
|
197
198
|
|
|
198
199
|
try {
|
|
199
|
-
const formatted = formatBlocklet(updates, 'onUpdate', this.options.dek);
|
|
200
|
+
const formatted = formatBlocklet(cloneDeep(updates), 'onUpdate', this.options.dek);
|
|
200
201
|
const newDoc = await this.updateById(doc._id, { $set: formatted });
|
|
201
202
|
resolve(newDoc);
|
|
202
203
|
} catch (err) {
|
|
@@ -247,8 +248,10 @@ class BlockletState extends BaseState {
|
|
|
247
248
|
},
|
|
248
249
|
});
|
|
249
250
|
lock.release();
|
|
250
|
-
|
|
251
|
-
|
|
251
|
+
|
|
252
|
+
const formatted = formatBlocklet(newDoc, 'onRead', this.options.dek);
|
|
253
|
+
this.emit('upgrade', formatted);
|
|
254
|
+
resolve(formatted);
|
|
252
255
|
} catch (err) {
|
|
253
256
|
lock.release();
|
|
254
257
|
reject(err);
|
|
@@ -392,11 +395,12 @@ class BlockletState extends BaseState {
|
|
|
392
395
|
if (typeof status === 'undefined') {
|
|
393
396
|
throw new Error('Unsupported blocklet status');
|
|
394
397
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
if (
|
|
398
|
-
return
|
|
398
|
+
|
|
399
|
+
const doc = await this.getBlocklet(did);
|
|
400
|
+
if (doc.status === status) {
|
|
401
|
+
return formatBlocklet(doc, 'onRead', this.options.dek);
|
|
399
402
|
}
|
|
403
|
+
|
|
400
404
|
const updates = { status, startedAt: undefined, stoppedAt: undefined };
|
|
401
405
|
if (status === BlockletStatus.running) {
|
|
402
406
|
updates.startedAt = new Date();
|
|
@@ -408,10 +412,8 @@ class BlockletState extends BaseState {
|
|
|
408
412
|
updates.stoppedAt = new Date();
|
|
409
413
|
}
|
|
410
414
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
});
|
|
414
|
-
return res;
|
|
415
|
+
await this.update(doc._id, { $set: updates });
|
|
416
|
+
return formatBlocklet({ ...doc, ...updates }, 'onRead', this.options.dek);
|
|
415
417
|
}
|
|
416
418
|
|
|
417
419
|
getChildrenFromMetas(childrenMeta) {
|
package/lib/util/blocklet.js
CHANGED
|
@@ -41,6 +41,7 @@ const { forEachBlocklet } = require('@blocklet/meta/lib/util');
|
|
|
41
41
|
const { validate: validateEngine, get: getEngine } = require('../blocklet/manager/engine');
|
|
42
42
|
|
|
43
43
|
const isRequirementsSatisfied = require('./requirement');
|
|
44
|
+
const { getDidDomainForBlocklet } = require('./get-domain-for-blocklet');
|
|
44
45
|
const { getServices } = require('./service');
|
|
45
46
|
const {
|
|
46
47
|
isBeforeInstalled,
|
|
@@ -247,12 +248,16 @@ const getRootSystemEnvironments = (blocklet, nodeInfo) => {
|
|
|
247
248
|
const appName = title || name || result.name;
|
|
248
249
|
const appDescription = description || result.description;
|
|
249
250
|
|
|
251
|
+
// FIXME: we should use https here when possible, eg, when did-gateway is available
|
|
252
|
+
const appUrl = `http://${getDidDomainForBlocklet({ appId, didDomain: nodeInfo.didDomain })}`;
|
|
253
|
+
|
|
250
254
|
return {
|
|
251
255
|
BLOCKLET_DID: did,
|
|
252
256
|
BLOCKLET_APP_SK: appSk,
|
|
253
257
|
BLOCKLET_APP_ID: appId,
|
|
254
258
|
BLOCKLET_APP_NAME: appName,
|
|
255
259
|
BLOCKLET_APP_DESCRIPTION: appDescription,
|
|
260
|
+
BLOCKLET_APP_URL: appUrl,
|
|
256
261
|
};
|
|
257
262
|
};
|
|
258
263
|
|
package/lib/validators/node.js
CHANGED
|
@@ -9,14 +9,23 @@ const nodeInfoSchema = Joi.object({
|
|
|
9
9
|
description: Joi.string()
|
|
10
10
|
.required()
|
|
11
11
|
.messages({ zh: { 'string.empty': '描述不能为空' }, en: { 'string.empty': 'Description cannot be empty' } }),
|
|
12
|
+
registerUrl: Joi.string()
|
|
13
|
+
.uri({ scheme: [/https?/] })
|
|
14
|
+
.label('register url')
|
|
15
|
+
.allow('')
|
|
16
|
+
.optional()
|
|
17
|
+
.messages({
|
|
18
|
+
zh: { 'string.uriCustomScheme': '应用启动器必须是合法的 URL' },
|
|
19
|
+
en: { 'string.uriCustomScheme': 'Blocklet Launcher must be a valid URL' },
|
|
20
|
+
}),
|
|
12
21
|
webWalletUrl: Joi.string()
|
|
13
22
|
.uri({ scheme: [/https?/] })
|
|
14
23
|
.label('web wallet url')
|
|
15
24
|
.allow('')
|
|
16
25
|
.optional()
|
|
17
26
|
.messages({
|
|
18
|
-
zh: { 'string.uriCustomScheme': 'Web
|
|
19
|
-
en: { 'string.uriCustomScheme': 'Web
|
|
27
|
+
zh: { 'string.uriCustomScheme': 'Web Wallet 必须是合法的 URL' },
|
|
28
|
+
en: { 'string.uriCustomScheme': 'Web Wallet must be a valid URL' },
|
|
20
29
|
}),
|
|
21
30
|
autoUpgrade: Joi.boolean(),
|
|
22
31
|
enableWelcomePage: Joi.boolean(),
|
|
@@ -31,16 +40,6 @@ const nodeInfoSchema = Joi.object({
|
|
|
31
40
|
'number.max': 'Disk usage alert threshold cannot be higher than 99%',
|
|
32
41
|
},
|
|
33
42
|
}),
|
|
34
|
-
// removed in 1.5.1
|
|
35
|
-
registerUrl: Joi.string()
|
|
36
|
-
.uri({ scheme: [/https?/] })
|
|
37
|
-
.label('register url')
|
|
38
|
-
.allow('')
|
|
39
|
-
.optional()
|
|
40
|
-
.messages({
|
|
41
|
-
zh: { 'string.uriCustomScheme': '注册地址必须是合法的 URL' },
|
|
42
|
-
en: { 'string.uriCustomScheme': 'Registry URL must be a valid URL' },
|
|
43
|
-
}),
|
|
44
43
|
}).options({ stripUnknown: true });
|
|
45
44
|
|
|
46
45
|
module.exports = {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.6.
|
|
6
|
+
"version": "1.6.16",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,28 +19,28 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/certificate-manager": "1.6.
|
|
23
|
-
"@abtnode/constant": "1.6.
|
|
24
|
-
"@abtnode/cron": "1.6.
|
|
25
|
-
"@abtnode/db": "1.6.
|
|
26
|
-
"@abtnode/logger": "1.6.
|
|
27
|
-
"@abtnode/queue": "1.6.
|
|
28
|
-
"@abtnode/rbac": "1.6.
|
|
29
|
-
"@abtnode/router-provider": "1.6.
|
|
30
|
-
"@abtnode/static-server": "1.6.
|
|
31
|
-
"@abtnode/timemachine": "1.6.
|
|
32
|
-
"@abtnode/util": "1.6.
|
|
33
|
-
"@arcblock/did": "^1.
|
|
34
|
-
"@arcblock/event-hub": "1.
|
|
22
|
+
"@abtnode/certificate-manager": "1.6.16",
|
|
23
|
+
"@abtnode/constant": "1.6.16",
|
|
24
|
+
"@abtnode/cron": "1.6.16",
|
|
25
|
+
"@abtnode/db": "1.6.16",
|
|
26
|
+
"@abtnode/logger": "1.6.16",
|
|
27
|
+
"@abtnode/queue": "1.6.16",
|
|
28
|
+
"@abtnode/rbac": "1.6.16",
|
|
29
|
+
"@abtnode/router-provider": "1.6.16",
|
|
30
|
+
"@abtnode/static-server": "1.6.16",
|
|
31
|
+
"@abtnode/timemachine": "1.6.16",
|
|
32
|
+
"@abtnode/util": "1.6.16",
|
|
33
|
+
"@arcblock/did": "^1.14.3",
|
|
34
|
+
"@arcblock/event-hub": "1.14.3",
|
|
35
35
|
"@arcblock/pm2-events": "^0.0.5",
|
|
36
|
-
"@arcblock/vc": "^1.
|
|
37
|
-
"@blocklet/meta": "1.6.
|
|
36
|
+
"@arcblock/vc": "^1.14.3",
|
|
37
|
+
"@blocklet/meta": "1.6.16",
|
|
38
38
|
"@fidm/x509": "^1.2.1",
|
|
39
39
|
"@nedb/core": "^1.2.2",
|
|
40
40
|
"@nedb/multi": "^1.2.2",
|
|
41
|
-
"@ocap/mcrypto": "^1.
|
|
42
|
-
"@ocap/util": "^1.
|
|
43
|
-
"@ocap/wallet": "^1.
|
|
41
|
+
"@ocap/mcrypto": "^1.14.3",
|
|
42
|
+
"@ocap/util": "^1.14.3",
|
|
43
|
+
"@ocap/wallet": "^1.14.3",
|
|
44
44
|
"@slack/webhook": "^5.0.3",
|
|
45
45
|
"axios": "^0.21.4",
|
|
46
46
|
"axon": "^2.0.3",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"express": "^4.17.1",
|
|
76
76
|
"jest": "^27.4.5"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "69b08db16aeb75ce23b0e6bb5b9fa396adba2d4b"
|
|
79
79
|
}
|