@abtnode/core 1.8.25 → 1.8.26

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/index.js CHANGED
@@ -208,8 +208,8 @@ function ABTNode(options) {
208
208
  upgradeBlocklet: blockletManager.upgrade.bind(blockletManager),
209
209
  configBlocklet: blockletManager.config.bind(blockletManager),
210
210
  devBlocklet: blockletManager.dev.bind(blockletManager),
211
- checkChildBlockletsForUpdates: blockletManager.checkChildrenForUpdates.bind(blockletManager),
212
- upgradeChildBlocklets: blockletManager.updateChildren.bind(blockletManager),
211
+ checkComponentsForUpdates: blockletManager.checkChildrenForUpdates.bind(blockletManager),
212
+ upgradeComponents: blockletManager.updateChildren.bind(blockletManager),
213
213
  getLatestBlockletVersion: blockletManager.getLatestBlockletVersion.bind(blockletManager),
214
214
  getBlockletMetaFromUrl: blockletManager.getMetaFromUrl.bind(blockletManager),
215
215
  resetBlocklet: blockletManager.reset.bind(blockletManager),
@@ -115,7 +115,7 @@ const getLogContent = async (action, args, context, result, info, node) => {
115
115
  return `upgrade blocklet failed: ${getBlockletInfo(result, info)}`;
116
116
  }
117
117
  return `upgraded blocklet ${getBlockletInfo(result, info)} to v${result.meta.version}`;
118
- case 'updateChildBlocklets':
118
+ case 'upgradeComponents':
119
119
  return `upgraded components for blocklet ${getBlockletInfo(result, info)}`;
120
120
  case 'configPublicToStore':
121
121
  if (args.publicToStore) {
@@ -259,7 +259,7 @@ const getLogCategory = (action) => {
259
259
  case 'deleteComponent':
260
260
  case 'configBlocklet':
261
261
  case 'upgradeBlocklet':
262
- case 'updateChildBlocklets':
262
+ case 'upgradeComponents':
263
263
  case 'configPublicToStore':
264
264
  case 'updateComponentTitle':
265
265
  case 'updateComponentMountPoint':
@@ -294,6 +294,7 @@ class NodeState extends BaseState {
294
294
  return this.read().then((info) => ({
295
295
  ABT_NODE: info.version,
296
296
  ABT_NODE_DID: info.did,
297
+ ABT_NODE_SK: info.sk,
297
298
  ABT_NODE_PK: info.pk,
298
299
  ABT_NODE_PORT: info.port,
299
300
  ABT_NODE_SERVICE_PORT: process.env.ABT_NODE_SERVICE_PORT,
@@ -41,6 +41,7 @@ const verifyMultiSig = require('@blocklet/meta/lib/verify-multi-sig');
41
41
  const validateBlockletEntry = require('@blocklet/meta/lib/entry');
42
42
  const getBlockletEngine = require('@blocklet/meta/lib/engine');
43
43
  const getBlockletInfo = require('@blocklet/meta/lib/info');
44
+ const getBlockletWallet = require('@blocklet/meta/lib/wallet');
44
45
  const { validateMeta, fixAndValidateService } = require('@blocklet/meta/lib/validate');
45
46
  const {
46
47
  forEachBlocklet,
@@ -68,6 +69,8 @@ const { getDidDomainForBlocklet } = require('./get-domain-for-blocklet');
68
69
  const { getBlockletDomainGroupName } = require('./router');
69
70
  const { isBeforeInstalled, expandBundle, findInterfacePortByName, validateBlockletMeta } = require('./index');
70
71
 
72
+ const getComponentConfig = (meta) => meta.components || meta.children;
73
+
71
74
  /**
72
75
  * get blocklet engine info, default is node
73
76
  * @param {object} blockletMeta blocklet meta
@@ -363,6 +366,11 @@ const getRuntimeEnvironments = (blocklet, nodeEnvironments, ancestors) => {
363
366
  mountPoints.push(mountPoint);
364
367
  }
365
368
 
369
+ // use index 1 as the path to derive deterministic encryption key for blocklet
370
+ const tmp = get(nodeEnvironments, 'ABT_NODE_SK')
371
+ ? getBlockletWallet(blocklet.meta.did, nodeEnvironments.ABT_NODE_SK, undefined, 1)
372
+ : null;
373
+
366
374
  return {
367
375
  ...blocklet.configObj,
368
376
  ...getSharedConfigObj(blocklet, ancestors),
@@ -371,6 +379,7 @@ const getRuntimeEnvironments = (blocklet, nodeEnvironments, ancestors) => {
371
379
  BLOCKLET_WEB_PORTS: JSON.stringify(ports),
372
380
  BLOCKLET_MOUNT_POINTS: JSON.stringify(mountPoints),
373
381
  BLOCKLET_MODE: blocklet.mode || BLOCKLET_MODES.PRODUCTION,
382
+ BLOCKLET_APP_EK: tmp?.secretKey,
374
383
  ...nodeEnvironments,
375
384
  ...safeNodeEnvironments,
376
385
  };
@@ -652,7 +661,7 @@ const reloadProcess = (processId) =>
652
661
  });
653
662
 
654
663
  const parseChildren = (children, parentMeta = {}, { dynamic } = {}) => {
655
- const configs = Array.isArray(parentMeta) ? parentMeta : parentMeta.children || [];
664
+ const configs = Array.isArray(parentMeta) ? parentMeta : getComponentConfig(parentMeta) || [];
656
665
 
657
666
  children.forEach((x) => {
658
667
  if (dynamic !== undefined) {
@@ -673,7 +682,7 @@ const parseChildrenFromMeta = async (src, context = {}) => {
673
682
  throw new Error('The depth of component should not exceed 40');
674
683
  }
675
684
 
676
- const configs = Array.isArray(src) ? src : src.children || [];
685
+ const configs = Array.isArray(src) ? src : getComponentConfig(src) || [];
677
686
 
678
687
  if (!configs || !configs.length) {
679
688
  return [];
@@ -1012,7 +1021,7 @@ const getRuntimeInfo = async (processId) => {
1012
1021
  const mergeMeta = (source, childrenMeta = []) => {
1013
1022
  // configMap
1014
1023
  const configMap = {};
1015
- (Array.isArray(source) ? source : source.children || []).forEach((x) => {
1024
+ (Array.isArray(source) ? source : getComponentConfig(source) || []).forEach((x) => {
1016
1025
  configMap[x.name] = x;
1017
1026
  });
1018
1027
 
@@ -1065,8 +1074,29 @@ const mergeMeta = (source, childrenMeta = []) => {
1065
1074
  };
1066
1075
 
1067
1076
  const fixAndVerifyMetaFromStore = (meta) => {
1077
+ // strip unknown properties
1078
+ // rename property alias
1079
+
1068
1080
  const sanitized = validateMeta(meta, { ensureDist: false, schemaOptions: { noDefaults: true, stripUnknown: true } });
1069
1081
 
1082
+ // rollback meta renamed by validateMeta
1083
+
1084
+ if (meta.children) {
1085
+ sanitized.children = meta.children;
1086
+ delete sanitized.components;
1087
+ }
1088
+
1089
+ if (meta.navigation) {
1090
+ meta.navigation.forEach((nav, index) => {
1091
+ if (nav.child) {
1092
+ sanitized.navigation[index].child = nav.child;
1093
+ delete sanitized.navigation[index].component;
1094
+ }
1095
+ });
1096
+ }
1097
+
1098
+ // verify
1099
+
1070
1100
  try {
1071
1101
  const result = verifyMultiSig(sanitized);
1072
1102
  if (!result) {
package/lib/util/index.js CHANGED
@@ -412,9 +412,10 @@ const getQueueConcurrencyByMem = () => {
412
412
 
413
413
  const getSafeEnv = (inputEnv, processEnv = process.env) => {
414
414
  const whiteList = ['ABT_NODE', 'ABT_NODE_DID', 'ABT_NODE_PK', 'ABT_NODE_PORT', 'ABT_NODE_SERVICE_PORT'];
415
+ const blackList = { ABT_NODE_SK: '' };
415
416
  // 此处需要保留 process.env 中的环境变量,只移除和 ABT_NODE 相关的环境变量(否则丢失了 process.env.SHELL 变量可能会造成无法使用 nodejs 的情况)
416
417
  const filterProcessEnv = pickBy(processEnv, (value, key) => !key.startsWith('ABT_NODE') || whiteList.includes(key));
417
- const mergedEnv = { ...filterProcessEnv, ...inputEnv };
418
+ const mergedEnv = { ...filterProcessEnv, ...inputEnv, ...blackList };
418
419
  return mergedEnv;
419
420
  };
420
421
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.25",
6
+ "version": "1.8.26",
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.25",
23
- "@abtnode/certificate-manager": "1.8.25",
24
- "@abtnode/constant": "1.8.25",
25
- "@abtnode/cron": "1.8.25",
26
- "@abtnode/db": "1.8.25",
27
- "@abtnode/logger": "1.8.25",
28
- "@abtnode/queue": "1.8.25",
29
- "@abtnode/rbac": "1.8.25",
30
- "@abtnode/router-provider": "1.8.25",
31
- "@abtnode/static-server": "1.8.25",
32
- "@abtnode/timemachine": "1.8.25",
33
- "@abtnode/util": "1.8.25",
22
+ "@abtnode/auth": "1.8.26",
23
+ "@abtnode/certificate-manager": "1.8.26",
24
+ "@abtnode/constant": "1.8.26",
25
+ "@abtnode/cron": "1.8.26",
26
+ "@abtnode/db": "1.8.26",
27
+ "@abtnode/logger": "1.8.26",
28
+ "@abtnode/queue": "1.8.26",
29
+ "@abtnode/rbac": "1.8.26",
30
+ "@abtnode/router-provider": "1.8.26",
31
+ "@abtnode/static-server": "1.8.26",
32
+ "@abtnode/timemachine": "1.8.26",
33
+ "@abtnode/util": "1.8.26",
34
34
  "@arcblock/did": "1.17.19",
35
35
  "@arcblock/did-motif": "^1.1.10",
36
36
  "@arcblock/did-util": "1.17.19",
@@ -38,8 +38,8 @@
38
38
  "@arcblock/jwt": "^1.17.19",
39
39
  "@arcblock/pm2-events": "^0.0.5",
40
40
  "@arcblock/vc": "1.17.19",
41
- "@blocklet/meta": "1.8.25",
42
- "@blocklet/sdk": "1.8.25",
41
+ "@blocklet/meta": "1.8.26",
42
+ "@blocklet/sdk": "1.8.26",
43
43
  "@fidm/x509": "^1.2.1",
44
44
  "@ocap/mcrypto": "1.17.19",
45
45
  "@ocap/util": "1.17.19",
@@ -80,5 +80,5 @@
80
80
  "express": "^4.18.1",
81
81
  "jest": "^27.5.1"
82
82
  },
83
- "gitHead": "ea34dcd0037c63cb63b31744efcf169edf8aa776"
83
+ "gitHead": "71937dabc196a98a1bb514789bc32aee44a1e8c4"
84
84
  }