@abtnode/core 1.16.20-beta-9c254d14 → 1.16.20-beta-e6e3b017

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.
@@ -2483,31 +2483,38 @@ class DiskBlockletManager extends BaseBlockletManager {
2483
2483
  }
2484
2484
  }
2485
2485
 
2486
- async _updateBlockletEnvironment(did) {
2486
+ async getBlockletEnvironments(did) {
2487
2487
  const blockletWithEnv = await this.getBlocklet(did);
2488
- const blocklet = await states.blocklet.getBlocklet(did);
2489
2488
  const nodeInfo = await states.node.read();
2490
-
2491
2489
  const appSystemEnvironments = {
2492
2490
  ...getAppSystemEnvironments(blockletWithEnv, nodeInfo, this.dataDirs),
2493
2491
  ...getAppOverwrittenEnvironments(blockletWithEnv, nodeInfo),
2494
2492
  };
2495
2493
 
2496
2494
  // fill environments to blocklet and components
2497
- blocklet.environments = formatEnvironments({
2498
- ...getComponentSystemEnvironments(blockletWithEnv),
2499
- ...appSystemEnvironments,
2500
- });
2495
+ return {
2496
+ all: formatEnvironments({
2497
+ ...getComponentSystemEnvironments(blockletWithEnv),
2498
+ ...appSystemEnvironments,
2499
+ }),
2500
+ appSystemEnvironments,
2501
+ };
2502
+ }
2503
+
2504
+ async _updateBlockletEnvironment(did) {
2505
+ const blockletWithEnv = await this.getBlocklet(did);
2506
+ const blocklet = await states.blocklet.getBlocklet(did);
2507
+
2508
+ const { all, appSystemEnvironments } = await this.getBlockletEnvironments(did);
2509
+ blocklet.environments = all;
2501
2510
 
2502
2511
  const envMap = {};
2503
2512
  forEachBlockletSync(blockletWithEnv, (child, { ancestors }) => {
2504
2513
  const id = getComponentId(child, ancestors);
2505
2514
  envMap[id] = child;
2506
2515
  });
2507
-
2508
2516
  forEachChildSync(blocklet, (child, { ancestors }) => {
2509
2517
  const id = getComponentId(child, ancestors);
2510
-
2511
2518
  const childWithEnv = envMap[id];
2512
2519
  if (childWithEnv) {
2513
2520
  child.environments = formatEnvironments({
@@ -2516,10 +2523,8 @@ class DiskBlockletManager extends BaseBlockletManager {
2516
2523
  });
2517
2524
  }
2518
2525
  });
2519
-
2520
2526
  // put BLOCKLET_APP_ID at root level for indexing
2521
2527
  blocklet.appDid = appSystemEnvironments.BLOCKLET_APP_ID;
2522
-
2523
2528
  if (!Array.isArray(blocklet.migratedFrom)) {
2524
2529
  blocklet.migratedFrom = [];
2525
2530
  }
@@ -2527,7 +2532,6 @@ class DiskBlockletManager extends BaseBlockletManager {
2527
2532
  if (!blocklet.appPid) {
2528
2533
  blocklet.appPid = appSystemEnvironments.BLOCKLET_APP_PID;
2529
2534
  }
2530
-
2531
2535
  // update state to db
2532
2536
  await states.blockletExtras.updateByDid(did, { appDid: blocklet.appDid });
2533
2537
  return states.blocklet.updateBlocklet(did, blocklet);
package/lib/index.js CHANGED
@@ -309,6 +309,7 @@ function ABTNode(options) {
309
309
  getBlocklet: blockletManager.detail.bind(blockletManager),
310
310
  getBlockletDiff: blockletManager.diff.bind(blockletManager),
311
311
  hasBlocklet: blockletManager.hasBlocklet.bind(blockletManager),
312
+ getBlockletEnvironments: blockletManager.getBlockletEnvironments.bind(blockletManager),
312
313
  updateAllBlockletEnvironment: blockletManager.updateAllBlockletEnvironment.bind(blockletManager),
313
314
  setBlockletInitialized: blockletManager.setInitialized.bind(blockletManager),
314
315
  setBlockletOwner: blockletManager.updateOwner.bind(blockletManager),
@@ -426,7 +426,6 @@ const getRuntimeEnvironments = (blocklet, nodeEnvironments, ancestors) => {
426
426
  ...getSharedConfigObj((ancestors || [])[0], blocklet),
427
427
  ...blocklet.environmentObj,
428
428
  ...devEnvironments,
429
- BLOCKLET_WEB_PORTS: JSON.stringify(ports),
430
429
  BLOCKLET_MOUNT_POINTS: JSON.stringify(componentsInternalInfo),
431
430
  BLOCKLET_MODE: blocklet.mode || BLOCKLET_MODES.PRODUCTION,
432
431
  BLOCKLET_APP_EK: tmp?.secretKey,
@@ -2,6 +2,7 @@ const path = require('path');
2
2
  const fs = require('fs-extra');
3
3
  const joinUrl = require('url-join');
4
4
  const pick = require('lodash/pick');
5
+ const isEmpty = require('lodash/isEmpty');
5
6
  const {
6
7
  getUserAvatarUrl,
7
8
  extractUserAvatar,
@@ -17,7 +18,7 @@ const { getLauncherUser, getLauncherSession: getLauncherSessionRaw, doRequest }
17
18
  const { createAuthToken, getPassportStatusEndpoint } = require('@abtnode/auth/lib/auth');
18
19
  const { createPassportVC, createPassport, createUserPassport } = require('@abtnode/auth/lib/passport');
19
20
 
20
- const { BlockletStatus, LOGIN_PROVIDER } = require('@blocklet/constant');
21
+ const { LOGIN_PROVIDER } = require('@blocklet/constant');
21
22
  const {
22
23
  WELLKNOWN_SERVICE_PATH_PREFIX,
23
24
  NODE_DATA_DIR_NAME,
@@ -88,8 +89,12 @@ const setupAppOwner = async (node, sessionId) => {
88
89
  if (!blocklet) {
89
90
  throw new Error(`Blocklet not found in server: ${appDid}`);
90
91
  }
91
- if (blocklet.status !== BlockletStatus.installed) {
92
- throw new Error(`Blocklet status not expected: ${appDid}`);
92
+
93
+ // 安装后 blocklet.environments 可能不会立即有值,可以从 node.getBlockletEnvironments 获取
94
+ if (isEmpty(blocklet.environments)) {
95
+ const { all } = await node.getBlockletEnvironments(appDid);
96
+
97
+ blocklet.environments = all;
93
98
  }
94
99
 
95
100
  const { wallet } = getBlockletInfo(blocklet, info.sk);
@@ -193,8 +198,6 @@ const setupAppOwner = async (node, sessionId) => {
193
198
  });
194
199
 
195
200
  await node.setBlockletOwner({ did: appDid, owner: { did: ownerDid, pk: ownerPk } });
196
- await node.endSession({ id: sessionId });
197
- logger.info('Complete install for blocklet', { appDid, ownerDid, sessionId });
198
201
 
199
202
  return {
200
203
  session,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.20-beta-9c254d14",
6
+ "version": "1.16.20-beta-e6e3b017",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,19 +19,19 @@
19
19
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
20
20
  "license": "Apache-2.0",
21
21
  "dependencies": {
22
- "@abtnode/analytics": "1.16.20-beta-9c254d14",
23
- "@abtnode/auth": "1.16.20-beta-9c254d14",
24
- "@abtnode/certificate-manager": "1.16.20-beta-9c254d14",
25
- "@abtnode/constant": "1.16.20-beta-9c254d14",
26
- "@abtnode/cron": "1.16.20-beta-9c254d14",
27
- "@abtnode/logger": "1.16.20-beta-9c254d14",
28
- "@abtnode/models": "1.16.20-beta-9c254d14",
29
- "@abtnode/queue": "1.16.20-beta-9c254d14",
30
- "@abtnode/rbac": "1.16.20-beta-9c254d14",
31
- "@abtnode/router-provider": "1.16.20-beta-9c254d14",
32
- "@abtnode/static-server": "1.16.20-beta-9c254d14",
33
- "@abtnode/timemachine": "1.16.20-beta-9c254d14",
34
- "@abtnode/util": "1.16.20-beta-9c254d14",
22
+ "@abtnode/analytics": "1.16.20-beta-e6e3b017",
23
+ "@abtnode/auth": "1.16.20-beta-e6e3b017",
24
+ "@abtnode/certificate-manager": "1.16.20-beta-e6e3b017",
25
+ "@abtnode/constant": "1.16.20-beta-e6e3b017",
26
+ "@abtnode/cron": "1.16.20-beta-e6e3b017",
27
+ "@abtnode/logger": "1.16.20-beta-e6e3b017",
28
+ "@abtnode/models": "1.16.20-beta-e6e3b017",
29
+ "@abtnode/queue": "1.16.20-beta-e6e3b017",
30
+ "@abtnode/rbac": "1.16.20-beta-e6e3b017",
31
+ "@abtnode/router-provider": "1.16.20-beta-e6e3b017",
32
+ "@abtnode/static-server": "1.16.20-beta-e6e3b017",
33
+ "@abtnode/timemachine": "1.16.20-beta-e6e3b017",
34
+ "@abtnode/util": "1.16.20-beta-e6e3b017",
35
35
  "@arcblock/did": "1.18.103",
36
36
  "@arcblock/did-auth": "1.18.103",
37
37
  "@arcblock/did-ext": "^1.18.103",
@@ -42,11 +42,11 @@
42
42
  "@arcblock/pm2-events": "^0.0.5",
43
43
  "@arcblock/validator": "^1.18.103",
44
44
  "@arcblock/vc": "1.18.103",
45
- "@blocklet/constant": "1.16.20-beta-9c254d14",
46
- "@blocklet/env": "1.16.20-beta-9c254d14",
47
- "@blocklet/meta": "1.16.20-beta-9c254d14",
48
- "@blocklet/resolver": "1.16.20-beta-9c254d14",
49
- "@blocklet/sdk": "1.16.20-beta-9c254d14",
45
+ "@blocklet/constant": "1.16.20-beta-e6e3b017",
46
+ "@blocklet/env": "1.16.20-beta-e6e3b017",
47
+ "@blocklet/meta": "1.16.20-beta-e6e3b017",
48
+ "@blocklet/resolver": "1.16.20-beta-e6e3b017",
49
+ "@blocklet/sdk": "1.16.20-beta-e6e3b017",
50
50
  "@did-space/client": "^0.3.41",
51
51
  "@fidm/x509": "^1.2.1",
52
52
  "@ocap/mcrypto": "1.18.103",
@@ -101,5 +101,5 @@
101
101
  "jest": "^27.5.1",
102
102
  "unzipper": "^0.10.11"
103
103
  },
104
- "gitHead": "2f74601e9a8f2e07e872a629b6abc8d4bc1fd371"
104
+ "gitHead": "764869cd8c889713e56416f4e60385cc70b9482e"
105
105
  }