@abtnode/core 1.16.10 → 1.16.11-beta-069c3537
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.
|
@@ -104,6 +104,7 @@ const {
|
|
|
104
104
|
updateBlockletFallbackLogo,
|
|
105
105
|
ensureAppLogo,
|
|
106
106
|
getBlockletDidDomainList,
|
|
107
|
+
shouldCleanExpiredBlocklet,
|
|
107
108
|
} = require('../../util/blocklet');
|
|
108
109
|
const states = require('../../states');
|
|
109
110
|
const BaseBlockletManager = require('./base');
|
|
@@ -2850,13 +2851,22 @@ class BlockletManager extends BaseBlockletManager {
|
|
|
2850
2851
|
return;
|
|
2851
2852
|
}
|
|
2852
2853
|
|
|
2853
|
-
const tasks = blockletExtras.map(async ({ appDid, did, meta }) => {
|
|
2854
|
+
const tasks = blockletExtras.map(async ({ appDid, did, meta, controller }) => {
|
|
2854
2855
|
const blocklet = await this.getBlocklet(did);
|
|
2855
2856
|
if (blocklet) {
|
|
2856
2857
|
logger.error('skip cleaning the blocklet which is not deleted', { blockletDid: did });
|
|
2857
2858
|
return;
|
|
2858
2859
|
}
|
|
2859
2860
|
|
|
2861
|
+
const assetState = await util.getNFTState(controller.chainHost, controller.nftId);
|
|
2862
|
+
const expirationDate = getNftExpirationDate(assetState);
|
|
2863
|
+
|
|
2864
|
+
if (!shouldCleanExpiredBlocklet(expirationDate)) {
|
|
2865
|
+
logger.error('skip cleaning the blocklet which is not expired', { blockletDid: did, expirationDate });
|
|
2866
|
+
await blockletExtras.updateExpireInfo({ did, expiredAt: expirationDate });
|
|
2867
|
+
return;
|
|
2868
|
+
}
|
|
2869
|
+
|
|
2860
2870
|
let blockletMeta = meta;
|
|
2861
2871
|
if (isEmpty(blockletMeta)) {
|
|
2862
2872
|
// 旧版本的 blocklet 没有 meta 信息,这里补充一下
|
package/lib/util/blocklet.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('fs-extra');
|
|
4
4
|
const path = require('path');
|
|
5
|
+
const dayjs = require('dayjs');
|
|
5
6
|
const joinURL = require('url-join');
|
|
6
7
|
const shelljs = require('shelljs');
|
|
7
8
|
const os = require('os');
|
|
@@ -43,6 +44,7 @@ const {
|
|
|
43
44
|
BLOCKLET_INSTALL_TYPE,
|
|
44
45
|
BLOCKLET_STORE_DEV,
|
|
45
46
|
APP_STRUCT_VERSION,
|
|
47
|
+
EXPIRED_BLOCKLET_DATA_RETENTION_DAYS,
|
|
46
48
|
} = require('@abtnode/constant');
|
|
47
49
|
const formatBackSlash = require('@abtnode/util/lib/format-back-slash');
|
|
48
50
|
const { toSvg: createDidLogo } =
|
|
@@ -99,6 +101,9 @@ const { validate: validateEngine, get: getEngine } = require('../blocklet/manage
|
|
|
99
101
|
const isRequirementsSatisfied = require('./requirement');
|
|
100
102
|
const { getDidDomainForBlocklet } = require('./get-domain-for-blocklet');
|
|
101
103
|
const { expandBundle, findInterfacePortByName, prettyURL, getNFTState, templateReplace } = require('./index');
|
|
104
|
+
const externalIpUtil = require('./get-accessible-external-node-ip');
|
|
105
|
+
const { getIpDnsDomainForBlocklet } = require('./get-domain-for-blocklet');
|
|
106
|
+
const { replaceDomainSlot } = require('./index');
|
|
102
107
|
|
|
103
108
|
const getComponentConfig = (meta) => {
|
|
104
109
|
const components = meta.components || meta.children || [];
|
|
@@ -1518,6 +1523,22 @@ const getConfigFromPreferences = (blocklet) => {
|
|
|
1518
1523
|
return result;
|
|
1519
1524
|
};
|
|
1520
1525
|
|
|
1526
|
+
const getBlockletURLForLauncher = async ({ blocklet, nodeInfo }) => {
|
|
1527
|
+
let nodeIp = await externalIpUtil.getFromCache();
|
|
1528
|
+
if (process.env.ABT_NODE_HOST) {
|
|
1529
|
+
// 开发调试用
|
|
1530
|
+
nodeIp = process.env.ABT_NODE_HOST;
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
if (nodeIp) {
|
|
1534
|
+
const ipEchoDomain = getIpDnsDomainForBlocklet(blocklet);
|
|
1535
|
+
return `https://${replaceDomainSlot({ domain: ipEchoDomain, nodeIp })}`;
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
const didDomain = getDidDomainForBlocklet({ appPid: blocklet.appPid, didDomain: nodeInfo.didDomain });
|
|
1539
|
+
return `https://${didDomain}`;
|
|
1540
|
+
};
|
|
1541
|
+
|
|
1521
1542
|
const consumeServerlessNFT = async ({ nftId, nodeInfo, blocklet }) => {
|
|
1522
1543
|
try {
|
|
1523
1544
|
const state = await getNFTState(blocklet.controller.chainHost, nftId);
|
|
@@ -1525,13 +1546,15 @@ const consumeServerlessNFT = async ({ nftId, nodeInfo, blocklet }) => {
|
|
|
1525
1546
|
throw new Error(`get nft state failed, chainHost: ${blocklet.controller.chainHost}, nftId: ${nftId}`);
|
|
1526
1547
|
}
|
|
1527
1548
|
|
|
1528
|
-
const
|
|
1529
|
-
|
|
1549
|
+
const appURL = await getBlockletURLForLauncher({ blocklet, nodeInfo });
|
|
1550
|
+
|
|
1551
|
+
logger.info('app url when consuming nft', { appURL, nftId });
|
|
1530
1552
|
|
|
1531
1553
|
const body = { nftId, appURL };
|
|
1532
1554
|
|
|
1533
1555
|
const { launcherUrl } = state.data.value;
|
|
1534
1556
|
|
|
1557
|
+
const wallet = getNodeWallet(nodeInfo.sk);
|
|
1535
1558
|
const func = async () => {
|
|
1536
1559
|
const { data } = await axios.post(joinURL(launcherUrl, '/api/serverless/consume'), body, {
|
|
1537
1560
|
headers: {
|
|
@@ -1929,6 +1952,10 @@ const getBlockletDidDomainList = (blocklet, nodeInfo) => {
|
|
|
1929
1952
|
return domainAliases;
|
|
1930
1953
|
};
|
|
1931
1954
|
|
|
1955
|
+
const shouldCleanExpiredBlocklet = (expirationDate) => {
|
|
1956
|
+
return dayjs().diff(dayjs(expirationDate), 'day') > EXPIRED_BLOCKLET_DATA_RETENTION_DAYS;
|
|
1957
|
+
};
|
|
1958
|
+
|
|
1932
1959
|
module.exports = {
|
|
1933
1960
|
updateBlockletFallbackLogo,
|
|
1934
1961
|
consumeServerlessNFT,
|
|
@@ -1987,4 +2014,6 @@ module.exports = {
|
|
|
1987
2014
|
getFixedBundleSource,
|
|
1988
2015
|
ensureAppLogo,
|
|
1989
2016
|
getBlockletDidDomainList,
|
|
2017
|
+
shouldCleanExpiredBlocklet,
|
|
2018
|
+
getBlockletURLForLauncher,
|
|
1990
2019
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.
|
|
6
|
+
"version": "1.16.11-beta-069c3537",
|
|
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": "Apache-2.0",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/auth": "1.16.
|
|
23
|
-
"@abtnode/certificate-manager": "1.16.
|
|
24
|
-
"@abtnode/constant": "1.16.
|
|
25
|
-
"@abtnode/cron": "1.16.
|
|
26
|
-
"@abtnode/logger": "1.16.
|
|
27
|
-
"@abtnode/models": "1.16.
|
|
28
|
-
"@abtnode/queue": "1.16.
|
|
29
|
-
"@abtnode/rbac": "1.16.
|
|
30
|
-
"@abtnode/router-provider": "1.16.
|
|
31
|
-
"@abtnode/static-server": "1.16.
|
|
32
|
-
"@abtnode/timemachine": "1.16.
|
|
33
|
-
"@abtnode/util": "1.16.
|
|
22
|
+
"@abtnode/auth": "1.16.11-beta-069c3537",
|
|
23
|
+
"@abtnode/certificate-manager": "1.16.11-beta-069c3537",
|
|
24
|
+
"@abtnode/constant": "1.16.11-beta-069c3537",
|
|
25
|
+
"@abtnode/cron": "1.16.11-beta-069c3537",
|
|
26
|
+
"@abtnode/logger": "1.16.11-beta-069c3537",
|
|
27
|
+
"@abtnode/models": "1.16.11-beta-069c3537",
|
|
28
|
+
"@abtnode/queue": "1.16.11-beta-069c3537",
|
|
29
|
+
"@abtnode/rbac": "1.16.11-beta-069c3537",
|
|
30
|
+
"@abtnode/router-provider": "1.16.11-beta-069c3537",
|
|
31
|
+
"@abtnode/static-server": "1.16.11-beta-069c3537",
|
|
32
|
+
"@abtnode/timemachine": "1.16.11-beta-069c3537",
|
|
33
|
+
"@abtnode/util": "1.16.11-beta-069c3537",
|
|
34
34
|
"@arcblock/did": "1.18.80",
|
|
35
35
|
"@arcblock/did-auth": "1.18.80",
|
|
36
36
|
"@arcblock/did-ext": "^1.18.80",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"@arcblock/pm2-events": "^0.0.5",
|
|
42
42
|
"@arcblock/validator": "^1.18.80",
|
|
43
43
|
"@arcblock/vc": "1.18.80",
|
|
44
|
-
"@blocklet/constant": "1.16.
|
|
45
|
-
"@blocklet/meta": "1.16.
|
|
46
|
-
"@blocklet/sdk": "1.16.
|
|
44
|
+
"@blocklet/constant": "1.16.11-beta-069c3537",
|
|
45
|
+
"@blocklet/meta": "1.16.11-beta-069c3537",
|
|
46
|
+
"@blocklet/sdk": "1.16.11-beta-069c3537",
|
|
47
47
|
"@did-space/client": "^0.2.99",
|
|
48
48
|
"@fidm/x509": "^1.2.1",
|
|
49
49
|
"@ocap/mcrypto": "1.18.80",
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"express": "^4.18.2",
|
|
97
97
|
"jest": "^27.5.1"
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "a89c7f13901d2c2d50b09d68d6088ca705648ff6"
|
|
100
100
|
}
|