@abtnode/core 1.8.48 → 1.8.50
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 +40 -5
- package/lib/router/helper.js +35 -27
- package/lib/util/blocklet.js +18 -1
- package/lib/util/get-domain-for-blocklet.js +3 -5
- package/package.json +25 -25
|
@@ -14,6 +14,7 @@ const { Throttle } = require('stream-throttle');
|
|
|
14
14
|
const LRU = require('lru-cache');
|
|
15
15
|
const joi = require('joi');
|
|
16
16
|
const { isNFTExpired } = require('@abtnode/util/lib/nft');
|
|
17
|
+
const { disableDNS } = require('@abtnode/util/lib/did-document');
|
|
17
18
|
const { sign } = require('@arcblock/jwt');
|
|
18
19
|
const { isValid: isValidDid } = require('@arcblock/did');
|
|
19
20
|
const { verifyPresentation } = require('@arcblock/vc');
|
|
@@ -21,6 +22,7 @@ const { toBase58, isHex } = require('@ocap/util');
|
|
|
21
22
|
const { fromSecretKey } = require('@ocap/wallet');
|
|
22
23
|
const { toSvg: createDidLogo } =
|
|
23
24
|
process.env.NODE_ENV !== 'test' ? require('@arcblock/did-motif') : require('@arcblock/did-motif/dist/did-motif.cjs');
|
|
25
|
+
const getBlockletInfo = require('@blocklet/meta/lib/info');
|
|
24
26
|
|
|
25
27
|
const logger = require('@abtnode/logger')('@abtnode/core:blocklet:manager');
|
|
26
28
|
const downloadFile = require('@abtnode/util/lib/download-file');
|
|
@@ -1000,9 +1002,12 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
1000
1002
|
}
|
|
1001
1003
|
|
|
1002
1004
|
if (
|
|
1003
|
-
[
|
|
1004
|
-
|
|
1005
|
-
|
|
1005
|
+
[
|
|
1006
|
+
BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_LOGO,
|
|
1007
|
+
BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_LOGO_RECT,
|
|
1008
|
+
BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_LOGO_SQUARE,
|
|
1009
|
+
BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_LOGO_FAVICON,
|
|
1010
|
+
].includes(x.key)
|
|
1006
1011
|
) {
|
|
1007
1012
|
x.value = await logoSchema.validateAsync(x.value);
|
|
1008
1013
|
}
|
|
@@ -1395,7 +1400,16 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
1395
1400
|
};
|
|
1396
1401
|
}
|
|
1397
1402
|
|
|
1398
|
-
async updateChildren(
|
|
1403
|
+
async updateChildren(
|
|
1404
|
+
{
|
|
1405
|
+
updateId,
|
|
1406
|
+
did: inputDid,
|
|
1407
|
+
children: inputChildren,
|
|
1408
|
+
oldBlocklet: inputOldBlocklet,
|
|
1409
|
+
selectedComponents: selectedComponentDids,
|
|
1410
|
+
},
|
|
1411
|
+
context
|
|
1412
|
+
) {
|
|
1399
1413
|
let did;
|
|
1400
1414
|
let children;
|
|
1401
1415
|
let oldBlocklet;
|
|
@@ -1406,8 +1420,19 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
1406
1420
|
} else {
|
|
1407
1421
|
const sessionData = await states.session.end(updateId);
|
|
1408
1422
|
did = sessionData.did;
|
|
1409
|
-
children = sessionData.children;
|
|
1410
1423
|
oldBlocklet = await this._getBlockletForInstallation(did);
|
|
1424
|
+
|
|
1425
|
+
if (selectedComponentDids && selectedComponentDids.length) {
|
|
1426
|
+
children = cloneDeep(oldBlocklet.children).map((oldComponent) => {
|
|
1427
|
+
const newComponent = sessionData.children.find((x) => x.meta.did === oldComponent.meta.did);
|
|
1428
|
+
if (newComponent && selectedComponentDids.includes(newComponent.meta.did)) {
|
|
1429
|
+
return newComponent;
|
|
1430
|
+
}
|
|
1431
|
+
return oldComponent;
|
|
1432
|
+
});
|
|
1433
|
+
} else {
|
|
1434
|
+
children = sessionData.children;
|
|
1435
|
+
}
|
|
1411
1436
|
}
|
|
1412
1437
|
|
|
1413
1438
|
// get old blocklet
|
|
@@ -3580,6 +3605,16 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
3580
3605
|
}
|
|
3581
3606
|
}
|
|
3582
3607
|
|
|
3608
|
+
const nodeInfo = await states.node.read();
|
|
3609
|
+
const { wallet } = getBlockletInfo(blocklet, nodeInfo.sk);
|
|
3610
|
+
disableDNS({ wallet, didRegistryUrl: nodeInfo.didRegistry })
|
|
3611
|
+
.then(() => {
|
|
3612
|
+
logger.info(`disabled blocklet ${blocklet.appDid} dns`);
|
|
3613
|
+
})
|
|
3614
|
+
.catch((err) => {
|
|
3615
|
+
logger.error(`disable blocklet ${blocklet.appDid} dns failed`, { error: err });
|
|
3616
|
+
});
|
|
3617
|
+
|
|
3583
3618
|
const result = await states.blocklet.deleteBlocklet(did);
|
|
3584
3619
|
logger.info('blocklet removed successfully', { did });
|
|
3585
3620
|
|
package/lib/router/helper.js
CHANGED
|
@@ -12,6 +12,9 @@ const { getProvider } = require('@abtnode/router-provider');
|
|
|
12
12
|
const normalizePathPrefix = require('@abtnode/util/lib/normalize-path-prefix');
|
|
13
13
|
const getTmpDir = require('@abtnode/util/lib/get-tmp-directory');
|
|
14
14
|
const downloadFile = require('@abtnode/util/lib/download-file');
|
|
15
|
+
const { encode: encodeBase32 } = require('@abtnode/util/lib/base32');
|
|
16
|
+
const { updateBlockletDocument } = require('@abtnode/util/lib/did-document');
|
|
17
|
+
const getBlockletInfo = require('@blocklet/meta/lib/info');
|
|
15
18
|
const {
|
|
16
19
|
DOMAIN_FOR_DEFAULT_SITE,
|
|
17
20
|
DOMAIN_FOR_IP_SITE_REGEXP,
|
|
@@ -564,35 +567,26 @@ module.exports = function getRouterHelpers({ dataDirs, routingSnapshot, routerMa
|
|
|
564
567
|
}
|
|
565
568
|
}
|
|
566
569
|
|
|
567
|
-
const isExistsInAlias = (domainAlias) =>
|
|
568
|
-
(dashboardSite.domainAliases || []).find((item) => {
|
|
569
|
-
if (typeof item === 'object') {
|
|
570
|
-
return domainAlias === item.value;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
return domainAlias === item;
|
|
574
|
-
});
|
|
575
|
-
|
|
576
570
|
const ipWildcardDomain = get(info, 'routing.ipWildcardDomain', '');
|
|
577
|
-
const didDomain = `${info.did.toLowerCase()}.${info.didDomain}`;
|
|
578
|
-
let dashboardAliasDomains = [ipWildcardDomain, didDomain];
|
|
579
571
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
572
|
+
const domainAliases = (dashboardSite.domainAliases || []).filter(
|
|
573
|
+
(item) => !item.value.endsWith(ipWildcardDomain) && !item.value.endsWith(info.didDomain)
|
|
574
|
+
);
|
|
583
575
|
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
576
|
+
const didDomain = `${encodeBase32(info.did)}.${info.didDomain}`;
|
|
577
|
+
const dashboardAliasDomains = [
|
|
578
|
+
{ value: ipWildcardDomain, isProtected: true },
|
|
579
|
+
{ value: didDomain, isProtected: true },
|
|
580
|
+
];
|
|
581
|
+
domainAliases.push(...dashboardAliasDomains);
|
|
590
582
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
583
|
+
try {
|
|
584
|
+
const result = await siteState.update({ _id: dashboardSite.id }, { $set: { domainAliases } });
|
|
585
|
+
|
|
586
|
+
updatedResult.push(result);
|
|
587
|
+
} catch (error) {
|
|
588
|
+
logger.error('add dashboard domain rule failed', { error });
|
|
589
|
+
console.error('Add dashboard domain rule failed:', error);
|
|
596
590
|
}
|
|
597
591
|
|
|
598
592
|
const defaultRule = sites.find((x) => x.domain === DOMAIN_FOR_DEFAULT_SITE);
|
|
@@ -666,11 +660,25 @@ module.exports = function getRouterHelpers({ dataDirs, routingSnapshot, routerMa
|
|
|
666
660
|
const domainAliases = [];
|
|
667
661
|
|
|
668
662
|
const didDomain = getDidDomainForBlocklet({
|
|
669
|
-
|
|
670
|
-
daemonDid: nodeInfo.did,
|
|
663
|
+
blockletAppDid: blocklet.appDid,
|
|
671
664
|
didDomain: nodeInfo.didDomain,
|
|
672
665
|
});
|
|
673
666
|
|
|
667
|
+
const { wallet } = getBlockletInfo(blocklet, nodeInfo.sk);
|
|
668
|
+
updateBlockletDocument({
|
|
669
|
+
wallet,
|
|
670
|
+
blockletAppDid: blocklet.appDid,
|
|
671
|
+
daemonDidDomain: `${encodeBase32(nodeInfo.did)}.${nodeInfo.didDomain}`,
|
|
672
|
+
didRegistryUrl: nodeInfo.didRegistry,
|
|
673
|
+
domain: nodeInfo.didDomain,
|
|
674
|
+
})
|
|
675
|
+
.then(() => {
|
|
676
|
+
logger.info(`updated blocklet ${blocklet.appDid} dns`);
|
|
677
|
+
})
|
|
678
|
+
.catch((err) => {
|
|
679
|
+
logger.error(`update blocklet ${blocklet.appDid} dns failed`, { error: err });
|
|
680
|
+
});
|
|
681
|
+
|
|
674
682
|
const ipEchoDnsDomain = getIpDnsDomainForBlocklet(blocklet, webInterface, nodeInfo.did);
|
|
675
683
|
|
|
676
684
|
// let didDomain in front of ipEchoDnsDomain
|
package/lib/util/blocklet.js
CHANGED
|
@@ -266,7 +266,23 @@ const getAppSystemEnvironments = (blocklet, nodeInfo) => {
|
|
|
266
266
|
const appName = title || name || result.name;
|
|
267
267
|
const appDescription = description || result.description;
|
|
268
268
|
|
|
269
|
-
|
|
269
|
+
/* 获取 did domain 方式:
|
|
270
|
+
* 1. 先从 site 里读
|
|
271
|
+
* 2. 如果没有,再拼接
|
|
272
|
+
*/
|
|
273
|
+
|
|
274
|
+
let appUrl = '';
|
|
275
|
+
|
|
276
|
+
const domainAliases = get(blocklet, 'site.domainAliases') || [];
|
|
277
|
+
const didDomainAlias = domainAliases.find((item) => item.value.endsWith(nodeInfo.didDomain));
|
|
278
|
+
if (didDomainAlias) {
|
|
279
|
+
appUrl = domainAliases.value;
|
|
280
|
+
} else {
|
|
281
|
+
appUrl = `https://${getDidDomainForBlocklet({
|
|
282
|
+
blockletAppDid: appId,
|
|
283
|
+
didDomain: nodeInfo.didDomain,
|
|
284
|
+
})}`;
|
|
285
|
+
}
|
|
270
286
|
|
|
271
287
|
return {
|
|
272
288
|
BLOCKLET_DID: did,
|
|
@@ -396,6 +412,7 @@ const getRuntimeEnvironments = (blocklet, nodeEnvironments, ancestors) => {
|
|
|
396
412
|
BLOCKLET_MOUNT_POINTS: JSON.stringify(mountPoints),
|
|
397
413
|
BLOCKLET_MODE: blocklet.mode || BLOCKLET_MODES.PRODUCTION,
|
|
398
414
|
BLOCKLET_APP_EK: tmp?.secretKey,
|
|
415
|
+
BLOCKLET_APP_VERSION: root.meta.version,
|
|
399
416
|
...nodeEnvironments,
|
|
400
417
|
...safeNodeEnvironments,
|
|
401
418
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const slugify = require('slugify');
|
|
2
2
|
const { DEFAULT_IP_DOMAIN_SUFFIX } = require('@abtnode/constant');
|
|
3
|
-
const
|
|
3
|
+
const { encode: encodeBase32 } = require('@abtnode/util/lib/base32');
|
|
4
4
|
|
|
5
5
|
const SLOT_FOR_IP_DNS_SITE = '888-888-888-888';
|
|
6
6
|
|
|
@@ -17,10 +17,8 @@ const getIpDnsDomainForBlocklet = (blocklet, blockletInterface) => {
|
|
|
17
17
|
}${iName}-${SLOT_FOR_IP_DNS_SITE}.${DEFAULT_IP_DOMAIN_SUFFIX}`;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
const getDidDomainForBlocklet = ({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return `${prefix}-${daemonDid.toLowerCase()}.${didDomain}`;
|
|
20
|
+
const getDidDomainForBlocklet = ({ blockletAppDid, didDomain }) => {
|
|
21
|
+
return `${encodeBase32(blockletAppDid)}.${didDomain}`;
|
|
24
22
|
};
|
|
25
23
|
|
|
26
24
|
module.exports = { getIpDnsDomainForBlocklet, getDidDomainForBlocklet, formatName };
|
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.50",
|
|
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/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.
|
|
34
|
-
"@arcblock/did": "1.18.
|
|
22
|
+
"@abtnode/auth": "1.8.50",
|
|
23
|
+
"@abtnode/certificate-manager": "1.8.50",
|
|
24
|
+
"@abtnode/constant": "1.8.50",
|
|
25
|
+
"@abtnode/cron": "1.8.50",
|
|
26
|
+
"@abtnode/db": "1.8.50",
|
|
27
|
+
"@abtnode/logger": "1.8.50",
|
|
28
|
+
"@abtnode/queue": "1.8.50",
|
|
29
|
+
"@abtnode/rbac": "1.8.50",
|
|
30
|
+
"@abtnode/router-provider": "1.8.50",
|
|
31
|
+
"@abtnode/static-server": "1.8.50",
|
|
32
|
+
"@abtnode/timemachine": "1.8.50",
|
|
33
|
+
"@abtnode/util": "1.8.50",
|
|
34
|
+
"@arcblock/did": "1.18.32",
|
|
35
35
|
"@arcblock/did-motif": "^1.1.10",
|
|
36
|
-
"@arcblock/did-util": "1.18.
|
|
37
|
-
"@arcblock/event-hub": "1.18.
|
|
38
|
-
"@arcblock/jwt": "^1.18.
|
|
36
|
+
"@arcblock/did-util": "1.18.32",
|
|
37
|
+
"@arcblock/event-hub": "1.18.32",
|
|
38
|
+
"@arcblock/jwt": "^1.18.32",
|
|
39
39
|
"@arcblock/pm2-events": "^0.0.5",
|
|
40
|
-
"@arcblock/vc": "1.18.
|
|
41
|
-
"@blocklet/constant": "1.8.
|
|
42
|
-
"@blocklet/meta": "1.8.
|
|
43
|
-
"@blocklet/sdk": "1.8.
|
|
40
|
+
"@arcblock/vc": "1.18.32",
|
|
41
|
+
"@blocklet/constant": "1.8.50",
|
|
42
|
+
"@blocklet/meta": "1.8.50",
|
|
43
|
+
"@blocklet/sdk": "1.8.50",
|
|
44
44
|
"@fidm/x509": "^1.2.1",
|
|
45
|
-
"@ocap/mcrypto": "1.18.
|
|
46
|
-
"@ocap/util": "1.18.
|
|
47
|
-
"@ocap/wallet": "1.18.
|
|
45
|
+
"@ocap/mcrypto": "1.18.32",
|
|
46
|
+
"@ocap/util": "1.18.32",
|
|
47
|
+
"@ocap/wallet": "1.18.32",
|
|
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.2",
|
|
83
83
|
"jest": "^27.5.1"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "7f3ccb957659a6791b93b6fc4fbcbbd2c42f1efd"
|
|
86
86
|
}
|