@abtnode/core 1.17.8-beta-20260119-102944-6ba93a16 → 1.17.8-beta-20260125-093329-64b43854

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.
@@ -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) {
@@ -822,9 +829,6 @@ module.exports = ({
822
829
  listen(teamAPI, BlockletEvents.updated, onEvent);
823
830
 
824
831
  listen(teamManager, BlockletEvents.storeChange, onEvent);
825
- listen(teamManager, EVENTS.NOTIFICATION_BLOCKLET_CREATE, (name, data) => {
826
- onEvent(name, data, true);
827
- });
828
832
 
829
833
  [EVENTS.NOTIFICATION_BLOCKLET_READ, EVENTS.NOTIFICATION_READ].forEach((eventName) => {
830
834
  listen(teamManager, eventName, onEvent);
@@ -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;
@@ -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 = 'daemon';
49
+ if (!site.serviceType) {
50
+ site.serviceType = 'daemon';
51
+ }
52
+
48
53
  result.push(site);
49
54
  }
50
55
  });
@@ -553,12 +553,13 @@ SELECT did,inviter,generation FROM UserTree`.trim();
553
553
  }
554
554
 
555
555
  /**
556
- * get user by did
556
+ * get user by did or name
557
557
  * @param {string} did user's did
558
558
  */
559
559
  async getUser(
560
560
  did,
561
561
  {
562
+ name,
562
563
  enableConnectedAccount = false,
563
564
  includeTags = false,
564
565
  includePassports = true,
@@ -566,10 +567,17 @@ SELECT did,inviter,generation FROM UserTree`.trim();
566
567
  selection = {},
567
568
  } = {}
568
569
  ) {
569
- let user = await this.findOne({ where: { did }, include: includeTags ? [this.getTagInclude()] : [] }, selection);
570
+ const where = {};
571
+ if (did) {
572
+ where.did = did;
573
+ } else if (name) {
574
+ where.name = name;
575
+ }
576
+ let user = await this.findOne({ where, include: includeTags ? [this.getTagInclude()] : [] }, selection);
570
577
 
571
578
  // search in connected accounts
572
579
  if (!user && enableConnectedAccount) {
580
+ // connectedAccounts don't have name field, so we can only search by did
573
581
  const connectedAccount = await this.connectedAccount.findOne({ did });
574
582
  if (connectedAccount) {
575
583
  user = await this.findOne({ did: connectedAccount.userDid }, selection);
@@ -4,6 +4,7 @@ const createOrgInputSchema = Joi.object({
4
4
  name: Joi.string().required().trim().min(1).max(64),
5
5
  description: Joi.string().optional().allow('').trim().min(1).max(255),
6
6
  ownerDid: Joi.DID().optional().allow('').allow(null),
7
+ avatar: Joi.string().optional().allow('').trim().min(1).max(255),
7
8
  });
8
9
 
9
10
  /**
@@ -13,6 +14,7 @@ const updateOrgInputSchema = Joi.object({
13
14
  id: Joi.string().required(),
14
15
  name: Joi.string().required().trim().min(1).max(20),
15
16
  description: Joi.string().optional().allow('').trim().min(1).max(255),
17
+ avatar: Joi.string().optional().allow('').trim().min(1).max(255),
16
18
  });
17
19
 
18
20
  exports.createOrgInputSchema = createOrgInputSchema;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.17.8-beta-20260119-102944-6ba93a16",
6
+ "version": "1.17.8-beta-20260125-093329-64b43854",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -17,43 +17,43 @@
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-20260119-102944-6ba93a16",
21
- "@abtnode/auth": "1.17.8-beta-20260119-102944-6ba93a16",
22
- "@abtnode/certificate-manager": "1.17.8-beta-20260119-102944-6ba93a16",
23
- "@abtnode/constant": "1.17.8-beta-20260119-102944-6ba93a16",
24
- "@abtnode/cron": "1.17.8-beta-20260119-102944-6ba93a16",
25
- "@abtnode/db-cache": "1.17.8-beta-20260119-102944-6ba93a16",
26
- "@abtnode/docker-utils": "1.17.8-beta-20260119-102944-6ba93a16",
27
- "@abtnode/logger": "1.17.8-beta-20260119-102944-6ba93a16",
28
- "@abtnode/models": "1.17.8-beta-20260119-102944-6ba93a16",
29
- "@abtnode/queue": "1.17.8-beta-20260119-102944-6ba93a16",
30
- "@abtnode/rbac": "1.17.8-beta-20260119-102944-6ba93a16",
31
- "@abtnode/router-provider": "1.17.8-beta-20260119-102944-6ba93a16",
32
- "@abtnode/util": "1.17.8-beta-20260119-102944-6ba93a16",
33
- "@arcblock/did": "^1.28.5",
34
- "@arcblock/did-connect-js": "^1.28.5",
35
- "@arcblock/did-ext": "^1.28.5",
20
+ "@abtnode/analytics": "1.17.8-beta-20260125-093329-64b43854",
21
+ "@abtnode/auth": "1.17.8-beta-20260125-093329-64b43854",
22
+ "@abtnode/certificate-manager": "1.17.8-beta-20260125-093329-64b43854",
23
+ "@abtnode/constant": "1.17.8-beta-20260125-093329-64b43854",
24
+ "@abtnode/cron": "1.17.8-beta-20260125-093329-64b43854",
25
+ "@abtnode/db-cache": "1.17.8-beta-20260125-093329-64b43854",
26
+ "@abtnode/docker-utils": "1.17.8-beta-20260125-093329-64b43854",
27
+ "@abtnode/logger": "1.17.8-beta-20260125-093329-64b43854",
28
+ "@abtnode/models": "1.17.8-beta-20260125-093329-64b43854",
29
+ "@abtnode/queue": "1.17.8-beta-20260125-093329-64b43854",
30
+ "@abtnode/rbac": "1.17.8-beta-20260125-093329-64b43854",
31
+ "@abtnode/router-provider": "1.17.8-beta-20260125-093329-64b43854",
32
+ "@abtnode/util": "1.17.8-beta-20260125-093329-64b43854",
33
+ "@arcblock/did": "^1.28.6",
34
+ "@arcblock/did-connect-js": "^1.28.6",
35
+ "@arcblock/did-ext": "^1.28.6",
36
36
  "@arcblock/did-motif": "^1.1.14",
37
- "@arcblock/did-util": "^1.28.5",
38
- "@arcblock/event-hub": "^1.28.5",
39
- "@arcblock/jwt": "^1.28.5",
37
+ "@arcblock/did-util": "^1.28.6",
38
+ "@arcblock/event-hub": "^1.28.6",
39
+ "@arcblock/jwt": "^1.28.6",
40
40
  "@arcblock/pm2-events": "^0.0.5",
41
- "@arcblock/validator": "^1.28.5",
42
- "@arcblock/vc": "^1.28.5",
43
- "@blocklet/constant": "1.17.8-beta-20260119-102944-6ba93a16",
41
+ "@arcblock/validator": "^1.28.6",
42
+ "@arcblock/vc": "^1.28.6",
43
+ "@blocklet/constant": "1.17.8-beta-20260125-093329-64b43854",
44
44
  "@blocklet/did-space-js": "^1.2.15",
45
- "@blocklet/env": "1.17.8-beta-20260119-102944-6ba93a16",
45
+ "@blocklet/env": "1.17.8-beta-20260125-093329-64b43854",
46
46
  "@blocklet/error": "^0.3.5",
47
- "@blocklet/meta": "1.17.8-beta-20260119-102944-6ba93a16",
48
- "@blocklet/resolver": "1.17.8-beta-20260119-102944-6ba93a16",
49
- "@blocklet/sdk": "1.17.8-beta-20260119-102944-6ba93a16",
50
- "@blocklet/server-js": "1.17.8-beta-20260119-102944-6ba93a16",
51
- "@blocklet/store": "1.17.8-beta-20260119-102944-6ba93a16",
52
- "@blocklet/theme": "^3.4.8",
47
+ "@blocklet/meta": "1.17.8-beta-20260125-093329-64b43854",
48
+ "@blocklet/resolver": "1.17.8-beta-20260125-093329-64b43854",
49
+ "@blocklet/sdk": "1.17.8-beta-20260125-093329-64b43854",
50
+ "@blocklet/server-js": "1.17.8-beta-20260125-093329-64b43854",
51
+ "@blocklet/store": "1.17.8-beta-20260125-093329-64b43854",
52
+ "@blocklet/theme": "^3.4.10",
53
53
  "@fidm/x509": "^1.2.1",
54
- "@ocap/mcrypto": "^1.28.5",
55
- "@ocap/util": "^1.28.5",
56
- "@ocap/wallet": "^1.28.5",
54
+ "@ocap/mcrypto": "^1.28.6",
55
+ "@ocap/util": "^1.28.6",
56
+ "@ocap/wallet": "^1.28.6",
57
57
  "@slack/webhook": "^7.0.6",
58
58
  "archiver": "^7.0.1",
59
59
  "axios": "^1.7.9",
@@ -113,5 +113,5 @@
113
113
  "express": "^4.18.2",
114
114
  "unzipper": "^0.10.11"
115
115
  },
116
- "gitHead": "52d0430ade8bad2dbc91251b6183d152116fee0f"
116
+ "gitHead": "241254785bda907be2296228869b4fc9c1679a6b"
117
117
  }