@abtnode/core 1.17.8-beta-20260119-034126-467341b7 → 1.17.8-beta-20260121-102603-f9d0176f
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/event/index.js
CHANGED
|
@@ -159,6 +159,13 @@ module.exports = ({
|
|
|
159
159
|
safeData.blocklet = wipeSensitiveData(safeData.blocklet);
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
if (name === BlockletInternalEvents.appSettingChanged) {
|
|
163
|
+
handleBlockletRouting({
|
|
164
|
+
did: data.appDid,
|
|
165
|
+
message: 'App setting changed',
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
162
169
|
logger.debug('proxy event to event hub', { name });
|
|
163
170
|
eventHub.broadcast(name, safeData); // 广播到所有节点
|
|
164
171
|
if (!disabledNodeListener) {
|
package/lib/router/helper.js
CHANGED
|
@@ -749,6 +749,75 @@ const ensureBlockletStaticServing = async (sites = [], blocklets = [], teamManag
|
|
|
749
749
|
return result.filter(Boolean);
|
|
750
750
|
};
|
|
751
751
|
|
|
752
|
+
/**
|
|
753
|
+
* Generate sub-service sites for blocklets with subService configuration
|
|
754
|
+
* @param {Array} sites - Existing routing sites
|
|
755
|
+
* @param {Array} blocklets - All blocklets
|
|
756
|
+
* @returns {Promise<Array>} Sites with sub-service sites added
|
|
757
|
+
*/
|
|
758
|
+
const ensureSubServiceSites = async (sites = [], blocklets = []) => {
|
|
759
|
+
const settingsPromises = blocklets.map((blocklet) => {
|
|
760
|
+
return states.blockletExtras.getSettings(blocklet.meta.did).then((settings) => ({
|
|
761
|
+
did: blocklet.meta.did,
|
|
762
|
+
dataDir: blocklet.environments?.find((e) => e.key === 'BLOCKLET_DATA_DIR')?.value ?? '',
|
|
763
|
+
config: settings?.subService,
|
|
764
|
+
}));
|
|
765
|
+
});
|
|
766
|
+
|
|
767
|
+
const settingsResults = await Promise.all(settingsPromises);
|
|
768
|
+
|
|
769
|
+
// Generate sub-service sites
|
|
770
|
+
const subServiceSites = settingsResults
|
|
771
|
+
.filter(({ config }) => {
|
|
772
|
+
const domain = config?.domain;
|
|
773
|
+
// Validate configuration is complete and enabled
|
|
774
|
+
return config?.enabled && domain && config.staticRoot;
|
|
775
|
+
})
|
|
776
|
+
.map(({ did, dataDir, config }) => {
|
|
777
|
+
const domain = config.domain;
|
|
778
|
+
|
|
779
|
+
// Security: Normalize and validate path to prevent directory traversal
|
|
780
|
+
const normalizedDataDir = path.resolve(dataDir);
|
|
781
|
+
const absoluteStaticRoot = path.resolve(dataDir, config.staticRoot);
|
|
782
|
+
|
|
783
|
+
// Ensure the resolved path is still within dataDir
|
|
784
|
+
if (!absoluteStaticRoot.startsWith(normalizedDataDir + path.sep)) {
|
|
785
|
+
logger.error('ensureSubServiceSites.pathTraversalAttempt', {
|
|
786
|
+
did,
|
|
787
|
+
dataDir: normalizedDataDir,
|
|
788
|
+
staticRoot: config.staticRoot,
|
|
789
|
+
resolved: absoluteStaticRoot,
|
|
790
|
+
});
|
|
791
|
+
throw new Error(`Invalid staticRoot path: ${config.staticRoot} - path traversal detected`);
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
logger.info('ensureSubServiceSites.created', {
|
|
795
|
+
did,
|
|
796
|
+
domain,
|
|
797
|
+
staticRoot: config.staticRoot,
|
|
798
|
+
absoluteStaticRoot,
|
|
799
|
+
});
|
|
800
|
+
|
|
801
|
+
return {
|
|
802
|
+
domain,
|
|
803
|
+
type: ROUTING_RULE_TYPES.SUB_SERVICE,
|
|
804
|
+
blockletDid: did,
|
|
805
|
+
serviceType: 'blocklet',
|
|
806
|
+
rules: [
|
|
807
|
+
{
|
|
808
|
+
from: { pathPrefix: '/' },
|
|
809
|
+
to: {
|
|
810
|
+
type: ROUTING_RULE_TYPES.SUB_SERVICE,
|
|
811
|
+
staticRoot: absoluteStaticRoot,
|
|
812
|
+
},
|
|
813
|
+
},
|
|
814
|
+
],
|
|
815
|
+
};
|
|
816
|
+
});
|
|
817
|
+
|
|
818
|
+
return [...sites, ...subServiceSites];
|
|
819
|
+
};
|
|
820
|
+
|
|
752
821
|
const ensureLatestInfo = async (sites = [], blocklets = [], teamManager = null, { nodeInfo = null } = {}) => {
|
|
753
822
|
const info = nodeInfo ?? (await states.node.read());
|
|
754
823
|
// CAUTION: following steps are very important, please do not change the order
|
|
@@ -762,6 +831,7 @@ const ensureLatestInfo = async (sites = [], blocklets = [], teamManager = null,
|
|
|
762
831
|
result = ensureBlockletWellknownRules(result, blocklets);
|
|
763
832
|
result = expandComponentRules(result, blocklets);
|
|
764
833
|
result = await ensureBlockletStaticServing(result, blocklets, teamManager);
|
|
834
|
+
result = await ensureSubServiceSites(result, blocklets);
|
|
765
835
|
|
|
766
836
|
return result;
|
|
767
837
|
};
|
|
@@ -2150,6 +2220,7 @@ module.exports = function getRouterHelpers({
|
|
|
2150
2220
|
const getSitesFromState = async (scope = 'all') => {
|
|
2151
2221
|
const sites = scope === 'all' ? await siteState.getSites() : await siteState.getSystemSites();
|
|
2152
2222
|
const blocklets = scope === 'all' ? await states.blocklet.getBlocklets() : [];
|
|
2223
|
+
|
|
2153
2224
|
return ensureLatestInfo(sites, blocklets, teamManager);
|
|
2154
2225
|
};
|
|
2155
2226
|
|
|
@@ -2353,6 +2424,7 @@ module.exports.ensureWellknownRule = ensureWellknownRule;
|
|
|
2353
2424
|
module.exports.ensureBlockletWellknownRules = ensureBlockletWellknownRules;
|
|
2354
2425
|
module.exports.ensureBlockletProxyBehavior = ensureBlockletProxyBehavior;
|
|
2355
2426
|
module.exports.ensureBlockletStaticServing = ensureBlockletStaticServing;
|
|
2427
|
+
module.exports.ensureSubServiceSites = ensureSubServiceSites;
|
|
2356
2428
|
module.exports.expandComponentRules = expandComponentRules;
|
|
2357
2429
|
module.exports.getDomainsByDid = getDomainsByDid;
|
|
2358
2430
|
module.exports.ensureBlockletHasMultipleInterfaces = ensureBlockletHasMultipleInterfaces;
|
package/lib/router/index.js
CHANGED
|
@@ -35,7 +35,9 @@ const expandSites = (sites = []) => {
|
|
|
35
35
|
const domain = typeof domainAlias === 'object' ? domainAlias.value : domainAlias;
|
|
36
36
|
const tmpSite = cloneDeep(site);
|
|
37
37
|
delete tmpSite.domainAliases;
|
|
38
|
+
|
|
38
39
|
tmpSite.serviceType = isBlockletSite(site.domain) ? 'blocklet' : 'daemon';
|
|
40
|
+
|
|
39
41
|
tmpSite.domain = domain;
|
|
40
42
|
result.push(tmpSite);
|
|
41
43
|
});
|
|
@@ -44,7 +46,10 @@ const expandSites = (sites = []) => {
|
|
|
44
46
|
|
|
45
47
|
// skip site if domain is BLOCKLET_SITE_GROUP
|
|
46
48
|
if (!site.domain.endsWith(BLOCKLET_SITE_GROUP_SUFFIX)) {
|
|
47
|
-
site.serviceType
|
|
49
|
+
if (!site.serviceType) {
|
|
50
|
+
site.serviceType = 'daemon';
|
|
51
|
+
}
|
|
52
|
+
|
|
48
53
|
result.push(site);
|
|
49
54
|
}
|
|
50
55
|
});
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.17.8-beta-
|
|
6
|
+
"version": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -17,19 +17,19 @@
|
|
|
17
17
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
18
18
|
"license": "Apache-2.0",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@abtnode/analytics": "1.17.8-beta-
|
|
21
|
-
"@abtnode/auth": "1.17.8-beta-
|
|
22
|
-
"@abtnode/certificate-manager": "1.17.8-beta-
|
|
23
|
-
"@abtnode/constant": "1.17.8-beta-
|
|
24
|
-
"@abtnode/cron": "1.17.8-beta-
|
|
25
|
-
"@abtnode/db-cache": "1.17.8-beta-
|
|
26
|
-
"@abtnode/docker-utils": "1.17.8-beta-
|
|
27
|
-
"@abtnode/logger": "1.17.8-beta-
|
|
28
|
-
"@abtnode/models": "1.17.8-beta-
|
|
29
|
-
"@abtnode/queue": "1.17.8-beta-
|
|
30
|
-
"@abtnode/rbac": "1.17.8-beta-
|
|
31
|
-
"@abtnode/router-provider": "1.17.8-beta-
|
|
32
|
-
"@abtnode/util": "1.17.8-beta-
|
|
20
|
+
"@abtnode/analytics": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
21
|
+
"@abtnode/auth": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
22
|
+
"@abtnode/certificate-manager": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
23
|
+
"@abtnode/constant": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
24
|
+
"@abtnode/cron": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
25
|
+
"@abtnode/db-cache": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
26
|
+
"@abtnode/docker-utils": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
27
|
+
"@abtnode/logger": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
28
|
+
"@abtnode/models": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
29
|
+
"@abtnode/queue": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
30
|
+
"@abtnode/rbac": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
31
|
+
"@abtnode/router-provider": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
32
|
+
"@abtnode/util": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
33
33
|
"@arcblock/did": "^1.28.5",
|
|
34
34
|
"@arcblock/did-connect-js": "^1.28.5",
|
|
35
35
|
"@arcblock/did-ext": "^1.28.5",
|
|
@@ -40,15 +40,15 @@
|
|
|
40
40
|
"@arcblock/pm2-events": "^0.0.5",
|
|
41
41
|
"@arcblock/validator": "^1.28.5",
|
|
42
42
|
"@arcblock/vc": "^1.28.5",
|
|
43
|
-
"@blocklet/constant": "1.17.8-beta-
|
|
43
|
+
"@blocklet/constant": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
44
44
|
"@blocklet/did-space-js": "^1.2.15",
|
|
45
|
-
"@blocklet/env": "1.17.8-beta-
|
|
45
|
+
"@blocklet/env": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
46
46
|
"@blocklet/error": "^0.3.5",
|
|
47
|
-
"@blocklet/meta": "1.17.8-beta-
|
|
48
|
-
"@blocklet/resolver": "1.17.8-beta-
|
|
49
|
-
"@blocklet/sdk": "1.17.8-beta-
|
|
50
|
-
"@blocklet/server-js": "1.17.8-beta-
|
|
51
|
-
"@blocklet/store": "1.17.8-beta-
|
|
47
|
+
"@blocklet/meta": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
48
|
+
"@blocklet/resolver": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
49
|
+
"@blocklet/sdk": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
50
|
+
"@blocklet/server-js": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
51
|
+
"@blocklet/store": "1.17.8-beta-20260121-102603-f9d0176f",
|
|
52
52
|
"@blocklet/theme": "^3.4.8",
|
|
53
53
|
"@fidm/x509": "^1.2.1",
|
|
54
54
|
"@ocap/mcrypto": "^1.28.5",
|
|
@@ -113,5 +113,5 @@
|
|
|
113
113
|
"express": "^4.18.2",
|
|
114
114
|
"unzipper": "^0.10.11"
|
|
115
115
|
},
|
|
116
|
-
"gitHead": "
|
|
116
|
+
"gitHead": "7ae816f51ed511037e5b7ac0008012ebf4afc987"
|
|
117
117
|
}
|