@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.
- package/lib/blocklet/manager/disk.js +34 -27
- package/lib/states/backup.js +1 -0
- package/lib/util/spaces.js +26 -0
- package/lib/validators/backup.js +1 -0
- package/package.json +29 -29
|
@@ -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.
|
|
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
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
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
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
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
|
/**
|
package/lib/states/backup.js
CHANGED
|
@@ -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()
|
package/lib/util/spaces.js
CHANGED
|
@@ -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
|
};
|
package/lib/validators/backup.js
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.11
|
|
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
|
|
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.
|
|
35
|
-
"@arcblock/did-auth": "1.18.
|
|
36
|
-
"@arcblock/did-ext": "^1.18.
|
|
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.
|
|
39
|
-
"@arcblock/event-hub": "1.18.
|
|
40
|
-
"@arcblock/jwt": "^1.18.
|
|
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.
|
|
43
|
-
"@arcblock/vc": "1.18.
|
|
44
|
-
"@blocklet/constant": "1.16.11
|
|
45
|
-
"@blocklet/meta": "1.16.11
|
|
46
|
-
"@blocklet/sdk": "1.16.11
|
|
47
|
-
"@did-space/client": "^0.2.
|
|
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.
|
|
50
|
-
"@ocap/util": "1.18.
|
|
51
|
-
"@ocap/wallet": "1.18.
|
|
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": "
|
|
99
|
+
"gitHead": "bf1a5bd70ed2ee7cd044c6b629c18bbc900f1598"
|
|
100
100
|
}
|