@abtnode/core 1.6.9 → 1.6.13
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 +19 -1
- package/lib/router/helper.js +46 -25
- package/lib/router/manager.js +1 -1
- package/lib/util/ready.js +1 -1
- package/lib/webhook/index.js +2 -2
- package/package.json +14 -14
|
@@ -24,7 +24,7 @@ const { updateBlocklet: updateDidDocument } = require('@abtnode/util/lib/did-doc
|
|
|
24
24
|
const { BLOCKLET_PURCHASE_NFT_TYPE } = require('@abtnode/constant');
|
|
25
25
|
|
|
26
26
|
const getBlockletEngine = require('@blocklet/meta/lib/engine');
|
|
27
|
-
const { isFreeBlocklet, getRequiredMissingConfigs } = require('@blocklet/meta/lib/util');
|
|
27
|
+
const { isFreeBlocklet, isDeletableBlocklet, getRequiredMissingConfigs } = require('@blocklet/meta/lib/util');
|
|
28
28
|
const validateBlockletEntry = require('@blocklet/meta/lib/entry');
|
|
29
29
|
const { getBlockletInfo } = require('@blocklet/meta/lib');
|
|
30
30
|
|
|
@@ -381,6 +381,9 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
381
381
|
|
|
382
382
|
try {
|
|
383
383
|
const blocklet = await this.ensureBlocklet(did);
|
|
384
|
+
if (isDeletableBlocklet(blocklet) === false) {
|
|
385
|
+
throw new Error('Blocklet is protected from accidental deletion');
|
|
386
|
+
}
|
|
384
387
|
|
|
385
388
|
const nodeEnvironments = await states.node.getEnvironments();
|
|
386
389
|
|
|
@@ -540,6 +543,12 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
540
543
|
}
|
|
541
544
|
}
|
|
542
545
|
|
|
546
|
+
if (x.key === 'BLOCKLET_DELETABLE') {
|
|
547
|
+
if (['yes', 'no'].includes(x.value) === false) {
|
|
548
|
+
throw new Error('BLOCKLET_DELETABLE must be either "yes" or "no"');
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
543
552
|
blocklet.configObj[x.key] = x.value;
|
|
544
553
|
}
|
|
545
554
|
|
|
@@ -1506,6 +1515,15 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
1506
1515
|
return null;
|
|
1507
1516
|
}
|
|
1508
1517
|
|
|
1518
|
+
// When new version found from the store where the blocklet was installed from, we should use that store first
|
|
1519
|
+
if (blocklet.source === BlockletSource.registry && blocklet.deployedFrom) {
|
|
1520
|
+
const latestFromSameRegistry = versions.find((x) => x.registryUrl === blocklet.deployedFrom);
|
|
1521
|
+
if (latestFromSameRegistry) {
|
|
1522
|
+
return latestFromSameRegistry;
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
// Otherwise try upgrading from other store
|
|
1509
1527
|
let latestBlockletVersion = versions[0];
|
|
1510
1528
|
versions.forEach((item) => {
|
|
1511
1529
|
if (semver.lt(latestBlockletVersion.version, item.version)) {
|
package/lib/router/helper.js
CHANGED
|
@@ -5,6 +5,7 @@ const path = require('path');
|
|
|
5
5
|
const tar = require('tar');
|
|
6
6
|
const get = require('lodash/get');
|
|
7
7
|
const cloneDeep = require('lodash/cloneDeep');
|
|
8
|
+
const isEqual = require('lodash/isEqual');
|
|
8
9
|
const joinUrl = require('url-join');
|
|
9
10
|
const { getProvider } = require('@abtnode/router-provider');
|
|
10
11
|
const normalizePathPrefix = require('@abtnode/util/lib/normalize-path-prefix');
|
|
@@ -28,6 +29,7 @@ const {
|
|
|
28
29
|
SLOT_FOR_IP_DNS_SITE,
|
|
29
30
|
BLOCKLET_SITE_GROUP_SUFFIX,
|
|
30
31
|
WELLKNOWN_ACME_CHALLENGE_PREFIX,
|
|
32
|
+
WELLKNOWN_DID_RESOLVER_PREFIX,
|
|
31
33
|
} = require('@abtnode/constant');
|
|
32
34
|
const {
|
|
33
35
|
BLOCKLET_DYNAMIC_PATH_PREFIX,
|
|
@@ -499,6 +501,30 @@ module.exports = function getRouterHelpers({ dataDirs, routingSnapshot, routerMa
|
|
|
499
501
|
return { status: 'downloaded' };
|
|
500
502
|
};
|
|
501
503
|
|
|
504
|
+
const upsertSiteRule = async ({ site, rule }, context) => {
|
|
505
|
+
const findExistingRule = (prefix) => site.rules.find((r) => r.from.pathPrefix === normalizePathPrefix(prefix));
|
|
506
|
+
|
|
507
|
+
const newSiteRule = {
|
|
508
|
+
id: site.id,
|
|
509
|
+
rule,
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
const existingRule = findExistingRule(get(rule, 'from.pathPrefix'));
|
|
513
|
+
if (!existingRule) {
|
|
514
|
+
await routerManager.addRoutingRule(newSiteRule, context);
|
|
515
|
+
return true;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
if (!isEqual(existingRule.to, rule.to)) {
|
|
519
|
+
newSiteRule.rule.id = existingRule.id;
|
|
520
|
+
newSiteRule.skipProtectedRuleChecking = true;
|
|
521
|
+
await routerManager.updateRoutingRule(newSiteRule, context);
|
|
522
|
+
return true;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
return false;
|
|
526
|
+
};
|
|
527
|
+
|
|
502
528
|
const addWellknownSite = async (sites, context) => {
|
|
503
529
|
const site = (sites || []).find((x) => x.name === NAME_FOR_WELLKNOWN_SITE);
|
|
504
530
|
|
|
@@ -511,42 +537,35 @@ module.exports = function getRouterHelpers({ dataDirs, routingSnapshot, routerMa
|
|
|
511
537
|
};
|
|
512
538
|
|
|
513
539
|
const didResolverWellknownRule = {
|
|
514
|
-
|
|
540
|
+
isProtected: true,
|
|
541
|
+
from: { pathPrefix: WELLKNOWN_DID_RESOLVER_PREFIX },
|
|
515
542
|
to: proxyTarget,
|
|
516
543
|
};
|
|
517
544
|
|
|
518
545
|
const acmeChallengeWellknownRule = {
|
|
546
|
+
isProtected: true,
|
|
519
547
|
from: { pathPrefix: WELLKNOWN_ACME_CHALLENGE_PREFIX },
|
|
520
548
|
to: proxyTarget,
|
|
521
549
|
};
|
|
522
550
|
|
|
523
551
|
if (site) {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
rule: didResolverWellknownRule,
|
|
532
|
-
},
|
|
533
|
-
context
|
|
534
|
-
);
|
|
535
|
-
changed = true;
|
|
536
|
-
}
|
|
552
|
+
const didResolverRuleUpdateRes = await upsertSiteRule(
|
|
553
|
+
{
|
|
554
|
+
site,
|
|
555
|
+
rule: didResolverWellknownRule,
|
|
556
|
+
},
|
|
557
|
+
context
|
|
558
|
+
);
|
|
537
559
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
);
|
|
546
|
-
changed = true;
|
|
547
|
-
}
|
|
560
|
+
const acmeRuleUpdateRes = await upsertSiteRule(
|
|
561
|
+
{
|
|
562
|
+
site,
|
|
563
|
+
rule: acmeChallengeWellknownRule,
|
|
564
|
+
},
|
|
565
|
+
context
|
|
566
|
+
);
|
|
548
567
|
|
|
549
|
-
return
|
|
568
|
+
return didResolverRuleUpdateRes || acmeRuleUpdateRes;
|
|
550
569
|
}
|
|
551
570
|
|
|
552
571
|
await routerManager.addRoutingSite(
|
|
@@ -1354,6 +1373,8 @@ module.exports = function getRouterHelpers({ dataDirs, routingSnapshot, routerMa
|
|
|
1354
1373
|
getCertificates,
|
|
1355
1374
|
checkDomain,
|
|
1356
1375
|
ensureDashboardCertificate,
|
|
1376
|
+
addWellknownSite,
|
|
1377
|
+
upsertSiteRule,
|
|
1357
1378
|
|
|
1358
1379
|
getRoutingCrons: () => [
|
|
1359
1380
|
{
|
package/lib/router/manager.js
CHANGED
|
@@ -302,7 +302,7 @@ class RouterManager extends EventEmitter {
|
|
|
302
302
|
|
|
303
303
|
// update rules
|
|
304
304
|
const newRules = [
|
|
305
|
-
...dbSite.rules.filter((x) => x.groupId !== rule.id || x.id !== rule.id), // 有些路由没有 rule.groupId
|
|
305
|
+
...dbSite.rules.filter((x) => (x.groupId && x.groupId !== rule.id) || x.id !== rule.id), // 有些路由没有 rule.groupId
|
|
306
306
|
...(await this.getRules(rule)),
|
|
307
307
|
];
|
|
308
308
|
|
package/lib/util/ready.js
CHANGED
|
@@ -33,7 +33,7 @@ const createStateReadyHandler =
|
|
|
33
33
|
console.error('Sharing data dir between Blocklet Server instances may break things!');
|
|
34
34
|
console.error('======================================================\x1b[0m');
|
|
35
35
|
console.log('\nIf you intend to use this dir:');
|
|
36
|
-
console.log(` 1. Stop Blocklet Server by ${chalk.cyan('
|
|
36
|
+
console.log(` 1. Stop Blocklet Server by ${chalk.cyan('blocklet server stop --force')}`);
|
|
37
37
|
console.log(` 2. Clear data dir by ${chalk.cyan(`rm -r ${options.dataDir}`)}`);
|
|
38
38
|
console.log(' 3. Reinitialize and start Blocklet Server');
|
|
39
39
|
process.exit(1);
|
package/lib/webhook/index.js
CHANGED
|
@@ -76,8 +76,8 @@ module.exports = ({ events, dataDirs, instance }) => {
|
|
|
76
76
|
const senderInstance = WebHookSender.getMessageSender(item.type);
|
|
77
77
|
senderFns[item.type] = senderInstance.send.bind(senderInstance);
|
|
78
78
|
}
|
|
79
|
-
const {
|
|
80
|
-
const options = { ...message, nodeInfo: `*${
|
|
79
|
+
const { name } = nodeInfo;
|
|
80
|
+
const options = { ...message, nodeInfo: `*${name}*` };
|
|
81
81
|
if (item.type === 'slack') {
|
|
82
82
|
options.urlInfo = getSlackUrlInfo(message.action, baseUrls);
|
|
83
83
|
}
|
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.13",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,22 +19,22 @@
|
|
|
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.
|
|
22
|
+
"@abtnode/certificate-manager": "1.6.13",
|
|
23
|
+
"@abtnode/constant": "1.6.13",
|
|
24
|
+
"@abtnode/cron": "1.6.13",
|
|
25
|
+
"@abtnode/db": "1.6.13",
|
|
26
|
+
"@abtnode/logger": "1.6.13",
|
|
27
|
+
"@abtnode/queue": "1.6.13",
|
|
28
|
+
"@abtnode/rbac": "1.6.13",
|
|
29
|
+
"@abtnode/router-provider": "1.6.13",
|
|
30
|
+
"@abtnode/static-server": "1.6.13",
|
|
31
|
+
"@abtnode/timemachine": "1.6.13",
|
|
32
|
+
"@abtnode/util": "1.6.13",
|
|
33
33
|
"@arcblock/did": "^1.13.79",
|
|
34
34
|
"@arcblock/event-hub": "1.13.79",
|
|
35
35
|
"@arcblock/pm2-events": "^0.0.5",
|
|
36
36
|
"@arcblock/vc": "^1.13.79",
|
|
37
|
-
"@blocklet/meta": "1.6.
|
|
37
|
+
"@blocklet/meta": "1.6.13",
|
|
38
38
|
"@fidm/x509": "^1.2.1",
|
|
39
39
|
"@nedb/core": "^1.2.2",
|
|
40
40
|
"@nedb/multi": "^1.2.2",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"express": "^4.17.1",
|
|
76
76
|
"jest": "^27.4.5"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "4fff3e4867db54e55b11bb0188bbbf703505dea9"
|
|
79
79
|
}
|