@abtnode/core 1.8.66-beta-b56e3b54 → 1.8.67-beta-f8b4c9ec

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.
@@ -47,7 +47,7 @@ const getComponentProcessId = require('@blocklet/meta/lib/get-component-process-
47
47
  const toBlockletDid = require('@blocklet/meta/lib/did');
48
48
  const { validateMeta } = require('@blocklet/meta/lib/validate');
49
49
  const { update: updateMetaFile } = require('@blocklet/meta/lib/file');
50
- const { titleSchema, mountPointSchema, environmentNameSchema } = require('@blocklet/meta/lib/schema');
50
+ const { titleSchema, updateMountPointSchema, environmentNameSchema } = require('@blocklet/meta/lib/schema');
51
51
  const hasReservedKey = require('@blocklet/meta/lib/has-reserved-key');
52
52
  const Lock = require('@abtnode/util/lib/lock');
53
53
 
@@ -334,7 +334,7 @@ class BlockletManager extends BaseBlockletManager {
334
334
  async installComponent(
335
335
  {
336
336
  rootDid,
337
- mountPoint,
337
+ mountPoint: tmpMountPoint,
338
338
  url,
339
339
  file,
340
340
  did,
@@ -348,6 +348,7 @@ class BlockletManager extends BaseBlockletManager {
348
348
  },
349
349
  context = {}
350
350
  ) {
351
+ const mountPoint = await updateMountPointSchema.validateAsync(tmpMountPoint);
351
352
  logger.debug('start install component', { rootDid, mountPoint, url });
352
353
 
353
354
  if (file) {
@@ -1193,8 +1194,8 @@ class BlockletManager extends BaseBlockletManager {
1193
1194
  return this.getBlocklet(rootDid);
1194
1195
  }
1195
1196
 
1196
- async updateComponentMountPoint({ did, rootDid: inputRootDid, mountPoint }, context) {
1197
- await mountPointSchema.validateAsync(mountPoint);
1197
+ async updateComponentMountPoint({ did, rootDid: inputRootDid, mountPoint: tmpMountPoint }, context) {
1198
+ const mountPoint = await updateMountPointSchema.validateAsync(tmpMountPoint);
1198
1199
 
1199
1200
  const blocklet = await states.blocklet.getBlocklet(inputRootDid);
1200
1201
 
@@ -183,6 +183,10 @@ Router.formatSites = (sites = []) => {
183
183
  result.forEach((site) => {
184
184
  if (Array.isArray(site.rules) && site.rules.length > 0) {
185
185
  const rules = cloneDeep(site.rules);
186
+
187
+ let hasRootPathBlockletRule = false;
188
+ let tmpBlockletRule;
189
+
186
190
  rules.forEach((rule) => {
187
191
  if ([ROUTING_RULE_TYPES.BLOCKLET].includes(rule.to.type) === false) {
188
192
  return;
@@ -197,6 +201,11 @@ Router.formatSites = (sites = []) => {
197
201
  }
198
202
 
199
203
  if (daemonRule) {
204
+ if (rule.from.pathPrefix === '/') {
205
+ hasRootPathBlockletRule = true;
206
+ }
207
+ tmpBlockletRule = rule;
208
+
200
209
  // Serve meta js: both prefix and suffix do not contain trailing slash
201
210
  // NOTICE: 这里隐含了一个约定
202
211
  // 如果安装的 blockletA 和 blockletB 都需要 __blocklet__.js
@@ -244,6 +253,24 @@ Router.formatSites = (sites = []) => {
244
253
  });
245
254
  }
246
255
  });
256
+
257
+ // ensure /__blocklet__.js should be proxy to daemon
258
+ if (daemonRule && !hasRootPathBlockletRule && tmpBlockletRule) {
259
+ site.rules.push({
260
+ from: {
261
+ pathPrefix: '/',
262
+ groupPathPrefix: '/',
263
+ pathSuffix: '/__blocklet__.js',
264
+ },
265
+ to: {
266
+ type: ROUTING_RULE_TYPES.DAEMON,
267
+ port: daemonRule.to.port,
268
+ did: tmpBlockletRule.to.did,
269
+ componentId: tmpBlockletRule.to.did,
270
+ cacheGroup: site.mode === BLOCKLET_MODES.PRODUCTION ? 'blockletJs' : '',
271
+ },
272
+ });
273
+ }
247
274
  }
248
275
  });
249
276
 
@@ -258,8 +258,8 @@ class RouterManager extends EventEmitter {
258
258
  return dbSite;
259
259
  }
260
260
 
261
- async addRoutingRule({ id, rule, skipCheckDynamicBlacklist = false }, context = {}) {
262
- await validateAddRule({ id, rule }, context);
261
+ async addRoutingRule({ id, rule: tempRule, skipCheckDynamicBlacklist = false }, context = {}) {
262
+ const { rule } = await validateAddRule({ id, rule: tempRule }, context);
263
263
  const dbSite = await states.site.findOne({ _id: id });
264
264
  if (!dbSite) {
265
265
  throw new Error(`site ${id} does not exist`);
@@ -294,8 +294,8 @@ class RouterManager extends EventEmitter {
294
294
  return newSite;
295
295
  }
296
296
 
297
- async updateRoutingRule({ id, rule, skipProtectedRuleChecking = false }, context = {}) {
298
- await validateEditRule({ id, rule }, context);
297
+ async updateRoutingRule({ id, rule: tmpRule, skipProtectedRuleChecking = false }, context = {}) {
298
+ const { rule } = await validateEditRule({ id, rule: tmpRule }, context);
299
299
  const dbSite = await states.site.findOne({ _id: id, 'rules.id': rule.id });
300
300
  if (!dbSite) {
301
301
  throw new Error(`site ${id}, rule ${rule.id} does not exist`);
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable newline-per-chained-call */
2
2
  const Joi = require('joi');
3
3
  const { DOMAIN_FOR_DEFAULT_SITE, ROUTING_RULE_TYPES, ROUTER_CACHE_GROUPS } = require('@abtnode/constant');
4
+ const urlFriendly = require('@blocklet/meta/lib/url-friendly').default;
4
5
  const { getMultipleLangParams } = require('./util');
5
6
 
6
7
  const WILDCARD_DOMAIN_REGEX = /^\*.(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/;
@@ -27,7 +28,8 @@ const ruleSchema = {
27
28
  .messages({
28
29
  zh: { 'string.empty': 'URL 前缀不能为空', 'string.max': 'URL 前缀的最大长度是 150' },
29
30
  en: { 'string.empty': 'URL prefix cannot be empty', 'string.max': 'The maximum length of URL prefix is 150' },
30
- }),
31
+ })
32
+ .custom((value) => urlFriendly(value)),
31
33
  groupPathPrefix: Joi.string().trim().min(1).max(150), // path prefix of interface of root blocklet
32
34
  header: Joi.any(), // TODO: header does not take effect
33
35
  }),
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.66-beta-b56e3b54",
6
+ "version": "1.8.67-beta-f8b4c9ec",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,33 +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.66-beta-b56e3b54",
23
- "@abtnode/certificate-manager": "1.8.66-beta-b56e3b54",
24
- "@abtnode/constant": "1.8.66-beta-b56e3b54",
25
- "@abtnode/cron": "1.8.66-beta-b56e3b54",
26
- "@abtnode/db": "1.8.66-beta-b56e3b54",
27
- "@abtnode/logger": "1.8.66-beta-b56e3b54",
28
- "@abtnode/queue": "1.8.66-beta-b56e3b54",
29
- "@abtnode/rbac": "1.8.66-beta-b56e3b54",
30
- "@abtnode/router-provider": "1.8.66-beta-b56e3b54",
31
- "@abtnode/static-server": "1.8.66-beta-b56e3b54",
32
- "@abtnode/timemachine": "1.8.66-beta-b56e3b54",
33
- "@abtnode/util": "1.8.66-beta-b56e3b54",
34
- "@arcblock/did": "1.18.52",
22
+ "@abtnode/auth": "1.8.67-beta-f8b4c9ec",
23
+ "@abtnode/certificate-manager": "1.8.67-beta-f8b4c9ec",
24
+ "@abtnode/constant": "1.8.67-beta-f8b4c9ec",
25
+ "@abtnode/cron": "1.8.67-beta-f8b4c9ec",
26
+ "@abtnode/db": "1.8.67-beta-f8b4c9ec",
27
+ "@abtnode/logger": "1.8.67-beta-f8b4c9ec",
28
+ "@abtnode/queue": "1.8.67-beta-f8b4c9ec",
29
+ "@abtnode/rbac": "1.8.67-beta-f8b4c9ec",
30
+ "@abtnode/router-provider": "1.8.67-beta-f8b4c9ec",
31
+ "@abtnode/static-server": "1.8.67-beta-f8b4c9ec",
32
+ "@abtnode/timemachine": "1.8.67-beta-f8b4c9ec",
33
+ "@abtnode/util": "1.8.67-beta-f8b4c9ec",
34
+ "@arcblock/did": "1.18.54",
35
35
  "@arcblock/did-motif": "^1.1.10",
36
- "@arcblock/did-util": "1.18.52",
37
- "@arcblock/event-hub": "1.18.52",
38
- "@arcblock/jwt": "^1.18.52",
36
+ "@arcblock/did-util": "1.18.54",
37
+ "@arcblock/event-hub": "1.18.54",
38
+ "@arcblock/jwt": "^1.18.54",
39
39
  "@arcblock/pm2-events": "^0.0.5",
40
- "@arcblock/vc": "1.18.52",
41
- "@blocklet/constant": "1.8.66-beta-b56e3b54",
42
- "@blocklet/meta": "1.8.66-beta-b56e3b54",
43
- "@blocklet/sdk": "1.8.66-beta-b56e3b54",
40
+ "@arcblock/vc": "1.18.54",
41
+ "@blocklet/constant": "1.8.67-beta-f8b4c9ec",
42
+ "@blocklet/meta": "1.8.67-beta-f8b4c9ec",
43
+ "@blocklet/sdk": "1.8.67-beta-f8b4c9ec",
44
44
  "@did-space/client": "^0.1.76",
45
45
  "@fidm/x509": "^1.2.1",
46
- "@ocap/mcrypto": "1.18.52",
47
- "@ocap/util": "1.18.52",
48
- "@ocap/wallet": "1.18.52",
46
+ "@ocap/mcrypto": "1.18.54",
47
+ "@ocap/util": "1.18.54",
48
+ "@ocap/wallet": "1.18.54",
49
49
  "@slack/webhook": "^5.0.4",
50
50
  "archiver": "^5.3.1",
51
51
  "axios": "^0.27.2",
@@ -89,5 +89,5 @@
89
89
  "express": "^4.18.2",
90
90
  "jest": "^27.5.1"
91
91
  },
92
- "gitHead": "4d95b431526128c14cd04c0741cac423afce8f48"
92
+ "gitHead": "ebf19fcbc6d99fff0d214dc0680c4df81aa94d6d"
93
93
  }