@abtnode/core 1.8.63 → 1.8.64-beta-0b5ede51

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.
@@ -23,7 +23,6 @@ const logger = require('@abtnode/logger')('state-blocklet');
23
23
  const BaseState = require('./base');
24
24
  const { checkDuplicateComponents, ensureMeta } = require('../util/blocklet');
25
25
  const { validateBlockletMeta } = require('../util');
26
- const { validateBlockletController } = require('../validators/blocklet');
27
26
 
28
27
  const lock = new Lock('blocklet-port-assign-lock');
29
28
 
@@ -122,21 +121,6 @@ class BlockletState extends BaseState {
122
121
  });
123
122
  }
124
123
 
125
- async isExternalBlocklet(did) {
126
- if (!did) {
127
- return false;
128
- }
129
-
130
- const exist = await this.findOne({
131
- $or: [{ 'meta.did': did }, { appDid: did }],
132
- controller: {
133
- $exists: true,
134
- },
135
- });
136
-
137
- return !!exist;
138
- }
139
-
140
124
  async getBlockletStatus(did) {
141
125
  return new Promise((resolve, reject) => {
142
126
  if (!did) {
@@ -212,7 +196,6 @@ class BlockletState extends BaseState {
212
196
  deployedFrom = '',
213
197
  mode = BLOCKLET_MODES.PRODUCTION,
214
198
  children: rawChildren = [],
215
- controller,
216
199
  } = {}) {
217
200
  return this.getBlocklet(meta.did).then(
218
201
  (exist) =>
@@ -251,13 +234,8 @@ class BlockletState extends BaseState {
251
234
  ports,
252
235
  environments: [],
253
236
  children,
254
- controller,
255
237
  };
256
238
 
257
- if (controller) {
258
- data.controller = await validateBlockletController(controller);
259
- }
260
-
261
239
  // add to db
262
240
  this.insert(data, (err, doc) => {
263
241
  lock.release();
@@ -88,6 +88,7 @@ const {
88
88
  findInterfacePortByName,
89
89
  validateBlockletMeta,
90
90
  prettyURL,
91
+ getNFTState,
91
92
  } = require('./index');
92
93
 
93
94
  const getComponentConfig = (meta) => meta.components || meta.children;
@@ -1392,6 +1393,11 @@ const getBlocklet = async ({
1392
1393
  blocklet.enablePassportIssuance = get(settings, 'enablePassportIssuance', true);
1393
1394
  blocklet.settings = settings || {};
1394
1395
 
1396
+ const extrasMeta = await states.blockletExtras.getMeta(blocklet.meta.did);
1397
+ if (extrasMeta) {
1398
+ blocklet.controller = extrasMeta.controller;
1399
+ }
1400
+
1395
1401
  blocklet.settings.storeList = blocklet.settings.storeList || [];
1396
1402
 
1397
1403
  if (!blocklet.settings.storeList.find((x) => x.url === BLOCKLET_STORE.url)) {
@@ -1491,7 +1497,11 @@ const getConfigFromPreferences = (blocklet) => {
1491
1497
 
1492
1498
  const consumeServerlessNFT = async ({ nftId, nodeInfo, blocklet }) => {
1493
1499
  try {
1494
- const { url } = nodeInfo.launcher;
1500
+ const state = await getNFTState(blocklet.controller.chainHost, nftId);
1501
+ if (!state) {
1502
+ throw new Error(`get nft state failed, chainHost: ${blocklet.controller.chainHost}, nftId: ${nftId}`);
1503
+ }
1504
+
1495
1505
  const type = WalletType({
1496
1506
  role: types.RoleType.ROLE_APPLICATION,
1497
1507
  pk: types.KeyType.ED25519,
@@ -1502,7 +1512,8 @@ const consumeServerlessNFT = async ({ nftId, nodeInfo, blocklet }) => {
1502
1512
 
1503
1513
  const body = { nftId, appURL };
1504
1514
 
1505
- const { data } = await axios.post(joinURL(url, '/api/serverless/consume'), body, {
1515
+ const { launcherUrl } = state.data.value;
1516
+ const { data } = await axios.post(joinURL(launcherUrl, '/api/serverless/consume'), body, {
1506
1517
  headers: {
1507
1518
  'x-sig': toBase58(wallet.sign(stableStringify(body))),
1508
1519
  },
@@ -1618,6 +1629,16 @@ const validateAppConfig = async (config, blockletDid, states) => {
1618
1629
  throw new Error(`${x.key}(${x.value}) is not a valid http address`);
1619
1630
  }
1620
1631
  }
1632
+
1633
+ if (x.key === BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_SPACES_URL) {
1634
+ if (isEmpty(x.value)) {
1635
+ throw new Error(`${x.key} can not be empty`);
1636
+ }
1637
+
1638
+ if (!isUrl(x.value)) {
1639
+ throw new Error(`${x.key}(${x.value}) is not a valid http address`);
1640
+ }
1641
+ }
1621
1642
  };
1622
1643
 
1623
1644
  const checkDuplicateAppSk = async ({ sk, did, states }) => {
@@ -13,6 +13,7 @@ const getMultipleLangParams = (context) => ({
13
13
  const blockletController = Joi.object({
14
14
  nftId: Joi.DID().required(),
15
15
  nftOwner: Joi.DID().required(),
16
+ chainHost: Joi.string().uri().required(),
16
17
  appMaxCount: Joi.number().required().min(1),
17
18
  }).options({ stripUnknown: true });
18
19
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.63",
6
+ "version": "1.8.64-beta-0b5ede51",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,32 +19,33 @@
19
19
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@abtnode/auth": "1.8.63",
23
- "@abtnode/certificate-manager": "1.8.63",
24
- "@abtnode/constant": "1.8.63",
25
- "@abtnode/cron": "1.8.63",
26
- "@abtnode/db": "1.8.63",
27
- "@abtnode/logger": "1.8.63",
28
- "@abtnode/queue": "1.8.63",
29
- "@abtnode/rbac": "1.8.63",
30
- "@abtnode/router-provider": "1.8.63",
31
- "@abtnode/static-server": "1.8.63",
32
- "@abtnode/timemachine": "1.8.63",
33
- "@abtnode/util": "1.8.63",
34
- "@arcblock/did": "1.18.36",
22
+ "@abtnode/auth": "1.8.64-beta-0b5ede51",
23
+ "@abtnode/certificate-manager": "1.8.64-beta-0b5ede51",
24
+ "@abtnode/constant": "1.8.64-beta-0b5ede51",
25
+ "@abtnode/cron": "1.8.64-beta-0b5ede51",
26
+ "@abtnode/db": "1.8.64-beta-0b5ede51",
27
+ "@abtnode/logger": "1.8.64-beta-0b5ede51",
28
+ "@abtnode/queue": "1.8.64-beta-0b5ede51",
29
+ "@abtnode/rbac": "1.8.64-beta-0b5ede51",
30
+ "@abtnode/router-provider": "1.8.64-beta-0b5ede51",
31
+ "@abtnode/static-server": "1.8.64-beta-0b5ede51",
32
+ "@abtnode/timemachine": "1.8.64-beta-0b5ede51",
33
+ "@abtnode/util": "1.8.64-beta-0b5ede51",
34
+ "@arcblock/did": "1.18.37",
35
35
  "@arcblock/did-motif": "^1.1.10",
36
- "@arcblock/did-util": "1.18.36",
37
- "@arcblock/event-hub": "1.18.36",
38
- "@arcblock/jwt": "^1.18.36",
36
+ "@arcblock/did-util": "1.18.37",
37
+ "@arcblock/event-hub": "1.18.37",
38
+ "@arcblock/jwt": "^1.18.37",
39
39
  "@arcblock/pm2-events": "^0.0.5",
40
- "@arcblock/vc": "1.18.36",
41
- "@blocklet/constant": "1.8.63",
42
- "@blocklet/meta": "1.8.63",
43
- "@blocklet/sdk": "1.8.63",
40
+ "@arcblock/vc": "1.18.37",
41
+ "@blocklet/constant": "1.8.64-beta-0b5ede51",
42
+ "@blocklet/meta": "1.8.64-beta-0b5ede51",
43
+ "@blocklet/sdk": "1.8.64-beta-0b5ede51",
44
+ "@did-space/client": "^0.1.66",
44
45
  "@fidm/x509": "^1.2.1",
45
- "@ocap/mcrypto": "1.18.36",
46
- "@ocap/util": "1.18.36",
47
- "@ocap/wallet": "1.18.36",
46
+ "@ocap/mcrypto": "1.18.37",
47
+ "@ocap/util": "1.18.37",
48
+ "@ocap/wallet": "1.18.37",
48
49
  "@slack/webhook": "^5.0.4",
49
50
  "archiver": "^5.3.1",
50
51
  "axios": "^0.27.2",
@@ -55,7 +56,7 @@
55
56
  "detect-port": "^1.5.1",
56
57
  "escape-string-regexp": "^4.0.0",
57
58
  "flat": "^5.0.2",
58
- "fs-extra": "^10.1.0",
59
+ "fs-extra": "^11.1.0",
59
60
  "get-port": "^5.1.1",
60
61
  "is-base64": "^1.1.0",
61
62
  "is-ip": "^3.1.0",
@@ -64,6 +65,7 @@
64
65
  "js-yaml": "^4.1.0",
65
66
  "lodash": "^4.17.21",
66
67
  "lru-cache": "^6.0.0",
68
+ "node-stream-zip": "^1.15.0",
67
69
  "p-limit": "^3.1.0",
68
70
  "pm2": "^5.2.0",
69
71
  "semver": "^7.3.8",
@@ -77,7 +79,8 @@
77
79
  "ua-parser-js": "^1.0.2",
78
80
  "unzipper": "^0.10.11",
79
81
  "url-join": "^4.0.1",
80
- "uuid": "7.0.3"
82
+ "uuid": "7.0.3",
83
+ "valid-url": "^1.0.9"
81
84
  },
82
85
  "devDependencies": {
83
86
  "compression": "^1.7.4",
@@ -85,5 +88,5 @@
85
88
  "express": "^4.18.2",
86
89
  "jest": "^27.5.1"
87
90
  },
88
- "gitHead": "69c7bf7f79fbabc8718d8ec0c6fb36ce9477cfd8"
91
+ "gitHead": "fbb72fdf88ea44c949ea951b84ab0506805bda7d"
89
92
  }
@@ -1,5 +0,0 @@
1
- const { blockletController } = require('./util');
2
-
3
- module.exports = {
4
- validateBlockletController: (entity) => blockletController.validateAsync(entity),
5
- };