@abtnode/core 1.16.11-next-f74663ac → 1.16.11

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.
@@ -140,7 +140,7 @@ const UpgradeComponents = require('./helper/upgrade-components');
140
140
  const BlockletDownloader = require('../downloader/blocklet-downloader');
141
141
  const RollbackCache = require('./helper/rollback-cache');
142
142
  const { migrateApplicationToStructV2 } = require('./helper/migrate-application-to-struct-v2');
143
- const { getBackupFilesUrlFromEndpoint, getBackupEndpoint } = require('../../util/spaces');
143
+ const { getBackupFilesUrlFromEndpoint, getBackupEndpoint, getSpaceNameByEndpoint } = require('../../util/spaces');
144
144
  const { validateAddSpaceGateway, validateUpdateSpaceGateway } = require('../../validators/space-gateway');
145
145
 
146
146
  const { formatEnvironments, getBlockletMeta, validateOwner } = util;
@@ -1684,7 +1684,7 @@ class BlockletManager extends BaseBlockletManager {
1684
1684
  const spaceGateways = await this.getBlockletSpaceGateways({ did });
1685
1685
 
1686
1686
  for (const s of spaceGateways) {
1687
- if (s.url === where?.url) {
1687
+ if (s.did === where?.did) {
1688
1688
  Object.assign(s, value);
1689
1689
  break;
1690
1690
  }
@@ -3132,32 +3132,39 @@ class BlockletManager extends BaseBlockletManager {
3132
3132
  */
3133
3133
  // eslint-disable-next-line no-unused-vars
3134
3134
  async _backupToSpaces({ blocklet, context }) {
3135
- const {
3136
- user: { did: userDid },
3137
- } = context;
3138
- const {
3139
- appDid,
3140
- meta: { did: appPid },
3141
- } = blocklet;
3142
-
3143
- const backup = await states.backup.start({
3144
- appPid,
3145
- userDid,
3146
- strategy: 1,
3147
- sourceUrl: path.join(this.dataDirs.tmp, 'backup', appDid),
3148
- });
3135
+ try {
3136
+ const {
3137
+ user: { did: userDid },
3138
+ } = context;
3139
+ const {
3140
+ appDid,
3141
+ meta: { did: appPid },
3142
+ } = blocklet;
3143
+ const endpoint = getBackupEndpoint(blocklet.environments);
3144
+
3145
+ const backup = await states.backup.start({
3146
+ appPid,
3147
+ userDid,
3148
+ strategy: 1,
3149
+ sourceUrl: path.join(this.dataDirs.tmp, 'backup', appDid),
3150
+ targetName: await getSpaceNameByEndpoint(endpoint, 'DID Space'),
3151
+ });
3149
3152
 
3150
- this.backupQueue.push(
3151
- {
3152
- entity: 'blocklet',
3153
- action: 'backupToSpaces',
3154
- id: appDid,
3155
- blocklet,
3156
- context,
3157
- backup,
3158
- },
3159
- appDid
3160
- );
3153
+ this.backupQueue.push(
3154
+ {
3155
+ entity: 'blocklet',
3156
+ action: 'backupToSpaces',
3157
+ id: appDid,
3158
+ blocklet,
3159
+ context,
3160
+ backup,
3161
+ },
3162
+ appDid
3163
+ );
3164
+ } catch (error) {
3165
+ logger.error(error);
3166
+ throw error;
3167
+ }
3161
3168
  }
3162
3169
 
3163
3170
  /**
@@ -15,6 +15,7 @@ const validateBackup = Joi.object({
15
15
  // 如果存储在 Spaces, 形如: https://bbqaw5mgxc6fnihrwqcejcxvukkdgkk4anwxwk5msvm.did.abtnet.io/app/space/zNKhe8jwgNZX2z7ZUfwNddNECxSe3wyg7VtS
16
16
  // 如果存储在 Local,形如: /User/allen/discuss-kit
17
17
  target: Joi.string().valid('Spaces', 'Local').optional().default('Spaces'),
18
+ targetName: Joi.string().required(),
18
19
  targetUrl: Joi.string().optional().allow('').default(''),
19
20
 
20
21
  createdAt: Joi.string()
@@ -1,4 +1,5 @@
1
1
  const { BLOCKLET_CONFIGURABLE_KEY } = require('@blocklet/constant');
2
+ const { default: axios } = require('axios');
2
3
  const isUrl = require('is-url');
3
4
  const isArray = require('lodash/isArray');
4
5
  const isEmpty = require('lodash/isEmpty');
@@ -45,8 +46,33 @@ function getDIDSpacesUrlFromEndpoint(endpoint) {
45
46
  return endpoint.replace(/\/api\/space\/.+/, '');
46
47
  }
47
48
 
49
+ /**
50
+ * @description
51
+ * @export
52
+ * @param {string} endpoint
53
+ * @param {string} [defaultValue='DID Space']
54
+ * @return {Promise<string >}
55
+ */
56
+ async function getSpaceNameByEndpoint(endpoint, defaultValue = '') {
57
+ try {
58
+ if (!isUrl(endpoint)) {
59
+ return '';
60
+ }
61
+
62
+ const { headers } = await axios.head(endpoint, {
63
+ timeout: 3000,
64
+ });
65
+
66
+ return headers['x-space-name'] ?? defaultValue;
67
+ } catch (error) {
68
+ console.error(error);
69
+ return defaultValue;
70
+ }
71
+ }
72
+
48
73
  module.exports = {
49
74
  getBackupEndpoint,
50
75
  getBackupFilesUrlFromEndpoint,
51
76
  getDIDSpacesUrlFromEndpoint,
77
+ getSpaceNameByEndpoint,
52
78
  };
@@ -7,6 +7,7 @@ const validateBackupStart = Joi.object({
7
7
 
8
8
  sourceUrl: Joi.string().required(),
9
9
  target: Joi.string().valid('Spaces', 'Local').optional().default('Spaces'),
10
+ targetName: Joi.string().required(),
10
11
  });
11
12
 
12
13
  const validateBackupSuccess = Joi.object({
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.11-next-f74663ac",
6
+ "version": "1.16.11",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,36 +19,36 @@
19
19
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
20
20
  "license": "Apache-2.0",
21
21
  "dependencies": {
22
- "@abtnode/auth": "1.16.11-next-f74663ac",
23
- "@abtnode/certificate-manager": "1.16.11-next-f74663ac",
24
- "@abtnode/constant": "1.16.11-next-f74663ac",
25
- "@abtnode/cron": "1.16.11-next-f74663ac",
26
- "@abtnode/logger": "1.16.11-next-f74663ac",
27
- "@abtnode/models": "1.16.11-next-f74663ac",
28
- "@abtnode/queue": "1.16.11-next-f74663ac",
29
- "@abtnode/rbac": "1.16.11-next-f74663ac",
30
- "@abtnode/router-provider": "1.16.11-next-f74663ac",
31
- "@abtnode/static-server": "1.16.11-next-f74663ac",
32
- "@abtnode/timemachine": "1.16.11-next-f74663ac",
33
- "@abtnode/util": "1.16.11-next-f74663ac",
34
- "@arcblock/did": "1.18.80",
35
- "@arcblock/did-auth": "1.18.80",
36
- "@arcblock/did-ext": "^1.18.80",
22
+ "@abtnode/auth": "1.16.11",
23
+ "@abtnode/certificate-manager": "1.16.11",
24
+ "@abtnode/constant": "1.16.11",
25
+ "@abtnode/cron": "1.16.11",
26
+ "@abtnode/logger": "1.16.11",
27
+ "@abtnode/models": "1.16.11",
28
+ "@abtnode/queue": "1.16.11",
29
+ "@abtnode/rbac": "1.16.11",
30
+ "@abtnode/router-provider": "1.16.11",
31
+ "@abtnode/static-server": "1.16.11",
32
+ "@abtnode/timemachine": "1.16.11",
33
+ "@abtnode/util": "1.16.11",
34
+ "@arcblock/did": "1.18.84",
35
+ "@arcblock/did-auth": "1.18.84",
36
+ "@arcblock/did-ext": "^1.18.84",
37
37
  "@arcblock/did-motif": "^1.1.10",
38
- "@arcblock/did-util": "1.18.80",
39
- "@arcblock/event-hub": "1.18.80",
40
- "@arcblock/jwt": "^1.18.80",
38
+ "@arcblock/did-util": "1.18.84",
39
+ "@arcblock/event-hub": "1.18.84",
40
+ "@arcblock/jwt": "^1.18.84",
41
41
  "@arcblock/pm2-events": "^0.0.5",
42
- "@arcblock/validator": "^1.18.80",
43
- "@arcblock/vc": "1.18.80",
44
- "@blocklet/constant": "1.16.11-next-f74663ac",
45
- "@blocklet/meta": "1.16.11-next-f74663ac",
46
- "@blocklet/sdk": "1.16.11-next-f74663ac",
47
- "@did-space/client": "^0.2.113",
42
+ "@arcblock/validator": "^1.18.84",
43
+ "@arcblock/vc": "1.18.84",
44
+ "@blocklet/constant": "1.16.11",
45
+ "@blocklet/meta": "1.16.11",
46
+ "@blocklet/sdk": "1.16.11",
47
+ "@did-space/client": "^0.2.117",
48
48
  "@fidm/x509": "^1.2.1",
49
- "@ocap/mcrypto": "1.18.80",
50
- "@ocap/util": "1.18.80",
51
- "@ocap/wallet": "1.18.80",
49
+ "@ocap/mcrypto": "1.18.84",
50
+ "@ocap/util": "1.18.84",
51
+ "@ocap/wallet": "1.18.84",
52
52
  "@slack/webhook": "^5.0.4",
53
53
  "archiver": "^5.3.1",
54
54
  "axios": "^0.27.2",
@@ -96,5 +96,5 @@
96
96
  "express": "^4.18.2",
97
97
  "jest": "^27.5.1"
98
98
  },
99
- "gitHead": "805327b6c7544c6d2328558434835253e2d741ec"
99
+ "gitHead": "bf1a5bd70ed2ee7cd044c6b629c18bbc900f1598"
100
100
  }