@abtnode/core 1.8.49 → 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 +12 -0
- package/lib/router/helper.js +35 -27
- package/lib/util/blocklet.js +17 -1
- package/lib/util/get-domain-for-blocklet.js +3 -5
- package/package.json +17 -17
|
@@ -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');
|
|
@@ -3603,6 +3605,16 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
3603
3605
|
}
|
|
3604
3606
|
}
|
|
3605
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
|
+
|
|
3606
3618
|
const result = await states.blocklet.deleteBlocklet(did);
|
|
3607
3619
|
logger.info('blocklet removed successfully', { did });
|
|
3608
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,
|
|
@@ -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,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.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
34
|
"@arcblock/did": "1.18.32",
|
|
35
35
|
"@arcblock/did-motif": "^1.1.10",
|
|
36
36
|
"@arcblock/did-util": "1.18.32",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"@arcblock/jwt": "^1.18.32",
|
|
39
39
|
"@arcblock/pm2-events": "^0.0.5",
|
|
40
40
|
"@arcblock/vc": "1.18.32",
|
|
41
|
-
"@blocklet/constant": "1.8.
|
|
42
|
-
"@blocklet/meta": "1.8.
|
|
43
|
-
"@blocklet/sdk": "1.8.
|
|
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
45
|
"@ocap/mcrypto": "1.18.32",
|
|
46
46
|
"@ocap/util": "1.18.32",
|
|
@@ -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
|
}
|