@abtnode/core 1.16.3 → 1.16.4-beta-f058f4e8

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.
@@ -237,6 +237,7 @@ class BlockletManager extends BaseBlockletManager {
237
237
  * description: string;
238
238
  * storeUrl: string;
239
239
  * appSk: string;
240
+ * skSource: string;
240
241
  * sync: boolean = false; // download synchronously, not use queue
241
242
  * delay: number; // push download task to queue after a delay
242
243
  * downloadTokenList: Array<{did: string, token: string}>;
@@ -1839,7 +1840,7 @@ class BlockletManager extends BaseBlockletManager {
1839
1840
  return children;
1840
1841
  }
1841
1842
 
1842
- async _addBlocklet({ component, mode = BLOCKLET_MODES.PRODUCTION, name, did, title, description }) {
1843
+ async _addBlocklet({ component, mode = BLOCKLET_MODES.PRODUCTION, name, did, title, description, skSource = '' }) {
1843
1844
  const meta = {
1844
1845
  name,
1845
1846
  did,
@@ -1898,6 +1899,7 @@ class BlockletManager extends BaseBlockletManager {
1898
1899
  source: BlockletSource.custom,
1899
1900
  children,
1900
1901
  mode,
1902
+ externalSkSource: skSource,
1901
1903
  };
1902
1904
 
1903
1905
  if (containerSourceUrl) {
@@ -20,6 +20,7 @@ const { getBlockletMetaFromUrl, ensureMeta, validateStore, validateInServerless
20
20
  const installApplicationFromGeneral = async ({
21
21
  type,
22
22
  appSk,
23
+ skSource,
23
24
  sync,
24
25
  delay,
25
26
  controller,
@@ -104,7 +105,7 @@ const installApplicationFromGeneral = async ({
104
105
  }
105
106
 
106
107
  // create app
107
- const blocklet = await manager._addBlocklet({ component, name, did, title, description });
108
+ const blocklet = await manager._addBlocklet({ component, name, did, title, description, skSource });
108
109
  logger.info('blocklet added to database', { did: blocklet.meta.did });
109
110
 
110
111
  // create config
@@ -270,39 +270,50 @@ const ensureWellknownRule = async (sites) => {
270
270
  // 这里默认 pathPrefix 最短的是自己 ( 通常自己在 /, 其他 blocklet 在 /xxxx )
271
271
  // 挂载其他 blocklet 的使用方式不推荐, 将来可能会被废弃
272
272
  .sort((a, b) => (a.from.pathPrefix.length > b.from.pathPrefix.length ? 1 : -1));
273
- if (blockletRules.length) {
274
- // get pathPrefix for blocklet-service
275
- const rootBlockletRule = blockletRules.find((x) => x.to.did === x.to.componentId);
276
-
277
- const servicePathPrefix = joinUrl(
278
- // rootBlockletRule?.from?.pathPrefix is for backwards compatibility
279
- // rootBlockletRule?.from?.groupPathPrefix 在旧的场景中可能不为 '/' (blocklet 只能挂载在 relative prefix 下)
280
- rootBlockletRule?.from?.groupPathPrefix || rootBlockletRule?.from?.pathPrefix || '/',
281
- WELLKNOWN_SERVICE_PATH_PREFIX
282
- );
283
273
 
284
- // requests for /.well-known/service will stay in blocklet-service and never proxy back to blocklet
285
- // so any rule is ok to be cloned
286
- if (!site.rules.some((x) => x.from.pathPrefix === servicePathPrefix)) {
287
- const rule = cloneDeep(rootBlockletRule || blockletRules[0]);
288
- rule.from.pathPrefix = servicePathPrefix;
289
- rule.to.target = servicePathPrefix;
290
- rule.isProtected = true;
291
- rule.dynamic = true; // mark as dynamic to avoid redundant generated rules
292
- site.rules.push(rule);
293
- }
274
+ const rootRule = blockletRules[0];
294
275
 
295
- // Cache user avatar in nginx
296
- const avatarPathPrefix = joinUrl(servicePathPrefix, USER_AVATAR_PATH_PREFIX);
297
- if (!site.rules.some((x) => x.from.pathPrefix === avatarPathPrefix)) {
298
- const rule = cloneDeep(rootBlockletRule || blockletRules[0]);
299
- rule.from.pathPrefix = avatarPathPrefix;
300
- rule.to.cacheGroup = 'blockletProxy';
301
- rule.to.target = avatarPathPrefix;
302
- rule.isProtected = true;
303
- rule.dynamic = true; // mark as dynamic to avoid redundant generated rules
304
- site.rules.push(rule);
305
- }
276
+ // Serve blocklet service always
277
+ const servicePathPrefix = joinUrl(WELLKNOWN_SERVICE_PATH_PREFIX);
278
+ if (!site.rules.some((x) => x.from.pathPrefix === servicePathPrefix)) {
279
+ site.rules.push({
280
+ id: rootRule?.id || '',
281
+ groupId: rootRule?.groupId || '',
282
+ from: {
283
+ pathPrefix: servicePathPrefix,
284
+ groupPathPrefix: '/',
285
+ },
286
+ to: {
287
+ type: 'blocklet',
288
+ did: site.blockletDid,
289
+ componentId: site.blockletDid,
290
+ target: servicePathPrefix,
291
+ },
292
+ isProtected: true,
293
+ dynamic: true,
294
+ });
295
+ }
296
+
297
+ // Cache user avatar from gateway
298
+ const avatarPathPrefix = joinUrl(servicePathPrefix, USER_AVATAR_PATH_PREFIX);
299
+ if (!site.rules.some((x) => x.from.pathPrefix === avatarPathPrefix)) {
300
+ site.rules.push({
301
+ id: rootRule?.id || '',
302
+ groupId: rootRule?.groupId || '',
303
+ from: {
304
+ pathPrefix: avatarPathPrefix,
305
+ groupPathPrefix: '/',
306
+ },
307
+ to: {
308
+ type: 'blocklet',
309
+ did: site.blockletDid,
310
+ componentId: site.blockletDid,
311
+ cacheGroup: 'blockletProxy',
312
+ target: avatarPathPrefix,
313
+ },
314
+ isProtected: true,
315
+ dynamic: true,
316
+ });
306
317
  }
307
318
  }
308
319
  }
@@ -1,5 +1,6 @@
1
1
  const get = require('lodash/get');
2
2
  const pick = require('lodash/pick');
3
+ const isEqual = require('lodash/isEqual');
3
4
  const cloneDeep = require('lodash/cloneDeep');
4
5
  const {
5
6
  DOMAIN_FOR_DEFAULT_SITE,
@@ -188,9 +189,6 @@ Router.formatSites = (sites = []) => {
188
189
  if (Array.isArray(site.rules) && site.rules.length > 0) {
189
190
  const rules = cloneDeep(site.rules);
190
191
 
191
- let hasRootPathBlockletRule = false;
192
- let tmpBlockletRule;
193
-
194
192
  rules.forEach((rule) => {
195
193
  if ([ROUTING_RULE_TYPES.BLOCKLET].includes(rule.to.type) === false) {
196
194
  return;
@@ -205,11 +203,6 @@ Router.formatSites = (sites = []) => {
205
203
  }
206
204
 
207
205
  if (daemonRule) {
208
- if (rule.from.pathPrefix === '/') {
209
- hasRootPathBlockletRule = true;
210
- }
211
- tmpBlockletRule = rule;
212
-
213
206
  // Serve meta js: both prefix and suffix do not contain trailing slash
214
207
  // NOTICE: 这里隐含了一个约定
215
208
  // 如果安装的 blockletA 和 blockletB 都需要 __blocklet__.js
@@ -242,38 +235,43 @@ Router.formatSites = (sites = []) => {
242
235
  cacheGroup: site.mode === BLOCKLET_MODES.PRODUCTION ? 'blockletJs' : '',
243
236
  },
244
237
  });
238
+ }
239
+ });
245
240
 
241
+ if (daemonRule) {
242
+ const rootFrom = {
243
+ pathPrefix: '/',
244
+ groupPathPrefix: '/',
245
+ pathSuffix: '/__blocklet__.js',
246
+ };
247
+ // ensure /__blocklet__.js should be proxy to daemon
248
+ if (!site.rules.find((x) => isEqual(x.from, rootFrom))) {
249
+ site.rules.push({
250
+ from: rootFrom,
251
+ to: {
252
+ type: ROUTING_RULE_TYPES.DAEMON,
253
+ port: daemonRule.to.port,
254
+ cacheGroup: site.mode === BLOCKLET_MODES.PRODUCTION ? 'blockletJs' : '',
255
+ did: site.blockletDid,
256
+ },
257
+ });
258
+ }
259
+
260
+ // ensure /.blocklet/proxy should be proxy to daemon
261
+ if (!site.rules.find((x) => x.from.pathPrefix === BLOCKLET_PROXY_PATH_PREFIX)) {
246
262
  site.rules.push({
247
263
  from: {
248
264
  pathPrefix: BLOCKLET_PROXY_PATH_PREFIX,
249
265
  },
250
266
  to: {
251
267
  port: daemonRule.to.port,
252
- did: rule.to.did,
253
268
  type: ROUTING_RULE_TYPES.DAEMON,
254
269
  target: BLOCKLET_PROXY_PATH_PREFIX,
255
270
  cacheGroup: site.mode === BLOCKLET_MODES.PRODUCTION ? 'blockletProxy' : '',
271
+ did: site.blockletDid,
256
272
  },
257
273
  });
258
274
  }
259
- });
260
-
261
- // ensure /__blocklet__.js should be proxy to daemon
262
- if (daemonRule && !hasRootPathBlockletRule && tmpBlockletRule) {
263
- site.rules.push({
264
- from: {
265
- pathPrefix: '/',
266
- groupPathPrefix: '/',
267
- pathSuffix: '/__blocklet__.js',
268
- },
269
- to: {
270
- type: ROUTING_RULE_TYPES.DAEMON,
271
- port: daemonRule.to.port,
272
- did: tmpBlockletRule.to.did,
273
- componentId: tmpBlockletRule.to.did,
274
- cacheGroup: site.mode === BLOCKLET_MODES.PRODUCTION ? 'blockletJs' : '',
275
- },
276
- });
277
275
  }
278
276
  }
279
277
  });
@@ -259,6 +259,7 @@ class BlockletState extends BaseState {
259
259
  // whether sk is managed by some party beside server, such as did-wallet
260
260
  // externalSk is always true in struct V2 blocklet
261
261
  externalSk = true,
262
+ externalSkSource = '',
262
263
  } = {}) {
263
264
  return this.getBlocklet(meta.did).then(
264
265
  (exist) =>
@@ -300,6 +301,7 @@ class BlockletState extends BaseState {
300
301
  children,
301
302
  migratedFrom,
302
303
  externalSk,
304
+ externalSkSource,
303
305
  structVersion: APP_STRUCT_VERSION,
304
306
  };
305
307
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.3",
6
+ "version": "1.16.4-beta-f058f4e8",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,34 +19,34 @@
19
19
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@abtnode/auth": "1.16.3",
23
- "@abtnode/certificate-manager": "1.16.3",
24
- "@abtnode/constant": "1.16.3",
25
- "@abtnode/cron": "1.16.3",
26
- "@abtnode/db": "1.16.3",
27
- "@abtnode/logger": "1.16.3",
28
- "@abtnode/queue": "1.16.3",
29
- "@abtnode/rbac": "1.16.3",
30
- "@abtnode/router-provider": "1.16.3",
31
- "@abtnode/static-server": "1.16.3",
32
- "@abtnode/timemachine": "1.16.3",
33
- "@abtnode/util": "1.16.3",
34
- "@arcblock/did": "1.18.65",
22
+ "@abtnode/auth": "1.16.4-beta-f058f4e8",
23
+ "@abtnode/certificate-manager": "1.16.4-beta-f058f4e8",
24
+ "@abtnode/constant": "1.16.4-beta-f058f4e8",
25
+ "@abtnode/cron": "1.16.4-beta-f058f4e8",
26
+ "@abtnode/db": "1.16.4-beta-f058f4e8",
27
+ "@abtnode/logger": "1.16.4-beta-f058f4e8",
28
+ "@abtnode/queue": "1.16.4-beta-f058f4e8",
29
+ "@abtnode/rbac": "1.16.4-beta-f058f4e8",
30
+ "@abtnode/router-provider": "1.16.4-beta-f058f4e8",
31
+ "@abtnode/static-server": "1.16.4-beta-f058f4e8",
32
+ "@abtnode/timemachine": "1.16.4-beta-f058f4e8",
33
+ "@abtnode/util": "1.16.4-beta-f058f4e8",
34
+ "@arcblock/did": "1.18.67",
35
35
  "@arcblock/did-motif": "^1.1.10",
36
- "@arcblock/did-util": "1.18.65",
37
- "@arcblock/event-hub": "1.18.65",
38
- "@arcblock/jwt": "^1.18.65",
36
+ "@arcblock/did-util": "1.18.67",
37
+ "@arcblock/event-hub": "1.18.67",
38
+ "@arcblock/jwt": "^1.18.67",
39
39
  "@arcblock/pm2-events": "^0.0.5",
40
- "@arcblock/vc": "1.18.65",
41
- "@blocklet/constant": "1.16.3",
42
- "@blocklet/meta": "1.16.3",
43
- "@blocklet/sdk": "1.16.3",
44
- "@did-space/client": "^0.2.45",
40
+ "@arcblock/vc": "1.18.67",
41
+ "@blocklet/constant": "1.16.4-beta-f058f4e8",
42
+ "@blocklet/meta": "1.16.4-beta-f058f4e8",
43
+ "@blocklet/sdk": "1.16.4-beta-f058f4e8",
44
+ "@did-space/client": "^0.2.67",
45
45
  "@fidm/x509": "^1.2.1",
46
- "@ocap/client": "1.18.65",
47
- "@ocap/mcrypto": "1.18.65",
48
- "@ocap/util": "1.18.65",
49
- "@ocap/wallet": "1.18.65",
46
+ "@ocap/client": "1.18.67",
47
+ "@ocap/mcrypto": "1.18.67",
48
+ "@ocap/util": "1.18.67",
49
+ "@ocap/wallet": "1.18.67",
50
50
  "@slack/webhook": "^5.0.4",
51
51
  "archiver": "^5.3.1",
52
52
  "axios": "^0.27.2",
@@ -93,5 +93,5 @@
93
93
  "express": "^4.18.2",
94
94
  "jest": "^27.5.1"
95
95
  },
96
- "gitHead": "a21d48225c6f89963796871f404a2318a335701d"
96
+ "gitHead": "e15364f5d5125950c2a6fb8d964b12f1b8799ac0"
97
97
  }