@abtnode/core 1.16.0-beta-1d6c582e → 1.16.0-beta-62b42401
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/api/team.js +51 -0
- package/lib/blocklet/manager/disk.js +129 -28
- package/lib/blocklet/manager/helper/install-application-from-backup.js +101 -16
- package/lib/blocklet/manager/helper/install-application-from-dev.js +7 -1
- package/lib/blocklet/manager/helper/install-application-from-general.js +23 -17
- package/lib/blocklet/manager/helper/migrate-application-to-struct-v2.js +31 -6
- package/lib/blocklet/storage/backup/base.js +64 -10
- package/lib/blocklet/storage/backup/blocklet.js +1 -1
- package/lib/blocklet/storage/backup/disk.js +132 -0
- package/lib/blocklet/storage/backup/spaces.js +8 -36
- package/lib/blocklet/storage/restore/base.js +13 -6
- package/lib/blocklet/storage/restore/blocklet-extras.js +5 -3
- package/lib/blocklet/storage/restore/blocklet.js +1 -1
- package/lib/blocklet/storage/restore/disk.js +104 -0
- package/lib/blocklet/storage/restore/spaces.js +10 -6
- package/lib/blocklet/storage/utils/disk.js +61 -0
- package/lib/event.js +7 -1
- package/lib/index.js +4 -2
- package/lib/states/audit-log.js +3 -0
- package/lib/states/user.js +88 -1
- package/lib/util/blocklet.js +4 -0
- package/package.json +26 -26
package/lib/states/audit-log.js
CHANGED
|
@@ -127,6 +127,8 @@ const getLogContent = async (action, args, context, result, info, node) => {
|
|
|
127
127
|
return `updated following navigations for blocklet ${getBlockletInfo(result, info)}:\n${args.navigations.map(
|
|
128
128
|
(x) => `- ${x.title}: ${x.link}\n`
|
|
129
129
|
)}`;
|
|
130
|
+
case 'configOAuth':
|
|
131
|
+
return `updated following OAuth for blocklet ${getBlockletInfo(result, info)}:\n${args.oauth}`;
|
|
130
132
|
case 'updateComponentTitle':
|
|
131
133
|
return `update component title to **${args.title}** for blocklet ${getBlockletInfo(result, info)}`;
|
|
132
134
|
case 'updateComponentMountPoint':
|
|
@@ -271,6 +273,7 @@ const getLogCategory = (action) => {
|
|
|
271
273
|
case 'upgradeComponents':
|
|
272
274
|
case 'configPublicToStore':
|
|
273
275
|
case 'configNavigations':
|
|
276
|
+
case 'configOAuth':
|
|
274
277
|
case 'updateComponentTitle':
|
|
275
278
|
case 'updateComponentMountPoint':
|
|
276
279
|
return 'blocklet';
|
package/lib/states/user.js
CHANGED
|
@@ -9,6 +9,42 @@ const { validateOwner } = require('../util');
|
|
|
9
9
|
|
|
10
10
|
const isNullOrUndefined = (x) => x === undefined || x === null;
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* UserPassport
|
|
14
|
+
* @typedef {Object} UserPassport
|
|
15
|
+
* @property {string} id - id
|
|
16
|
+
* @property {string[]} [type] - passport's type
|
|
17
|
+
* @property {string[]} [issuer] - passport's issuer
|
|
18
|
+
* @property {Date} [issuanceDate] - passport's issuanceDate
|
|
19
|
+
* @property {string} [specVersion] - passport's specVersion
|
|
20
|
+
* @property {string} name - passport's name
|
|
21
|
+
* @property {string} [title] - passport's title
|
|
22
|
+
* @property {string} [endpoint] - passport's endpoint
|
|
23
|
+
* @property {string} [status] - passport's status
|
|
24
|
+
* @property {string} role - passport's role
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The Data structure of blocklet-service user
|
|
29
|
+
* @typedef {Object} BlockletUser - Blocklet Service User Table
|
|
30
|
+
* @property {string} _id - id
|
|
31
|
+
* @property {('profile')} type - type of user
|
|
32
|
+
* @property {string} fullName - user profile's name
|
|
33
|
+
* @property {string} avatar - url of user's avatar, eg: bn://avatar/7f8848569405f8cdf8b1b2788ebf7d0f.jpg
|
|
34
|
+
* @property {string} did - user's did
|
|
35
|
+
* @property {('owner'|'admin'|'member'|'guest'|string)} role - user's role
|
|
36
|
+
* @property {UserPassport[]} passports - user's passport list
|
|
37
|
+
* @property {string} pk - user's publicKey
|
|
38
|
+
* @property {boolean} approved - enable user to login
|
|
39
|
+
* @property {string} locale - locale
|
|
40
|
+
* @property {Object} extra - extra data of user
|
|
41
|
+
* @property {Date} firstLoginAt - firstLoginAt
|
|
42
|
+
* @property {Date} lastLoginAt - lastLoginAt
|
|
43
|
+
* @property {string} lastLoginIp - lastLoginIp
|
|
44
|
+
* @property {Date} createdAt - createdAt
|
|
45
|
+
* @property {Date} updatedAt - updatedAt
|
|
46
|
+
*/
|
|
47
|
+
|
|
12
48
|
class User extends BaseState {
|
|
13
49
|
constructor(baseDir, config = {}) {
|
|
14
50
|
super(baseDir, { filename: 'user.db', ...config });
|
|
@@ -22,6 +58,11 @@ class User extends BaseState {
|
|
|
22
58
|
});
|
|
23
59
|
}
|
|
24
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Add a new user
|
|
63
|
+
* @param {BlockletUser} user - user data
|
|
64
|
+
* @returns {Promise<number>}
|
|
65
|
+
*/
|
|
25
66
|
async add(user) {
|
|
26
67
|
if (!validateOwner(user)) {
|
|
27
68
|
throw new Error('user is invalid');
|
|
@@ -33,7 +74,14 @@ class User extends BaseState {
|
|
|
33
74
|
});
|
|
34
75
|
}
|
|
35
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Update a user
|
|
79
|
+
* @param {BlockletUser} user - user data
|
|
80
|
+
* @returns {BlockletUser}
|
|
81
|
+
*/
|
|
36
82
|
async update(user) {
|
|
83
|
+
// FIXME: @zhanghan 这里为什么要限制?
|
|
84
|
+
// 限制后也无法更新 lastLoginAt ?
|
|
37
85
|
if (!validateOwner(user)) {
|
|
38
86
|
throw new Error('user is invalid');
|
|
39
87
|
}
|
|
@@ -59,6 +107,11 @@ class User extends BaseState {
|
|
|
59
107
|
return this._setPassportStatusById({ did, id, status: PASSPORT_STATUS.VALID });
|
|
60
108
|
}
|
|
61
109
|
|
|
110
|
+
/**
|
|
111
|
+
* remove a user by user's did
|
|
112
|
+
* @param {string} did - the did of user
|
|
113
|
+
* @returns {number} deleted count
|
|
114
|
+
*/
|
|
62
115
|
async remove({ did }) {
|
|
63
116
|
const num = await super.remove({ did });
|
|
64
117
|
|
|
@@ -69,6 +122,12 @@ class User extends BaseState {
|
|
|
69
122
|
return num;
|
|
70
123
|
}
|
|
71
124
|
|
|
125
|
+
/**
|
|
126
|
+
* enable/disable user login
|
|
127
|
+
* @param {string} did user's did
|
|
128
|
+
* @param {boolean} approved enable/disable user login
|
|
129
|
+
* @returns {BlockletUser}
|
|
130
|
+
*/
|
|
72
131
|
async updateApproved({ did, approved }) {
|
|
73
132
|
const [num, doc] = await super.update({ did }, { $set: { approved } });
|
|
74
133
|
|
|
@@ -79,6 +138,12 @@ class User extends BaseState {
|
|
|
79
138
|
return doc;
|
|
80
139
|
}
|
|
81
140
|
|
|
141
|
+
/**
|
|
142
|
+
* update user's role
|
|
143
|
+
* @param {string} did user's did
|
|
144
|
+
* @param {BlockletUser.role} role user's rolel
|
|
145
|
+
* @returns {BlockletUser}
|
|
146
|
+
*/
|
|
82
147
|
async updateRole({ did, role }) {
|
|
83
148
|
const [num, doc] = await super.update({ did }, { $set: { role } });
|
|
84
149
|
|
|
@@ -89,8 +154,15 @@ class User extends BaseState {
|
|
|
89
154
|
return doc;
|
|
90
155
|
}
|
|
91
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Get blocklet service user list
|
|
159
|
+
* @param {Object} query query params
|
|
160
|
+
* @param {('asc'|'desc')} sort query sort
|
|
161
|
+
* @param {any} paging query paging
|
|
162
|
+
* @returns {{list: BlockletUser[]; paging: any;}}
|
|
163
|
+
*/
|
|
92
164
|
async getUsers({ query, sort, paging: inputPaging } = {}) {
|
|
93
|
-
const { approved, role, search } = query || {};
|
|
165
|
+
const { approved, role, search, derivedDid } = query || {};
|
|
94
166
|
|
|
95
167
|
// make query param
|
|
96
168
|
const queryParam = {};
|
|
@@ -121,6 +193,11 @@ class User extends BaseState {
|
|
|
121
193
|
}
|
|
122
194
|
}
|
|
123
195
|
|
|
196
|
+
// 根据 derivedDid 查询 user 信息(wallet 账户绑定 oauth 账户后,会有该字段)
|
|
197
|
+
if (derivedDid) {
|
|
198
|
+
queryParam['derivedAccount.did'] = derivedDid;
|
|
199
|
+
}
|
|
200
|
+
|
|
124
201
|
const sortParam = pickBy(sort, (x) => !isNullOrUndefined(x));
|
|
125
202
|
|
|
126
203
|
if (!Object.keys(sortParam).length) {
|
|
@@ -136,6 +213,11 @@ class User extends BaseState {
|
|
|
136
213
|
};
|
|
137
214
|
}
|
|
138
215
|
|
|
216
|
+
/**
|
|
217
|
+
* get user list by did list
|
|
218
|
+
* @param {string[]} dids user did list
|
|
219
|
+
* @returns {BlockletUser[]}
|
|
220
|
+
*/
|
|
139
221
|
async getUsersByDids({ dids, query } = {}) {
|
|
140
222
|
const { approved } = query || {};
|
|
141
223
|
const didList = dids || [];
|
|
@@ -152,6 +234,11 @@ class User extends BaseState {
|
|
|
152
234
|
return this.find(queryParam);
|
|
153
235
|
}
|
|
154
236
|
|
|
237
|
+
/**
|
|
238
|
+
* get user by did
|
|
239
|
+
* @param {string} did user's did
|
|
240
|
+
* @returns {BlockletUser}
|
|
241
|
+
*/
|
|
155
242
|
async getUser(did) {
|
|
156
243
|
const doc = await this.findOne({ did });
|
|
157
244
|
return doc;
|
package/lib/util/blocklet.js
CHANGED
|
@@ -72,6 +72,7 @@ const {
|
|
|
72
72
|
getSharedConfigObj,
|
|
73
73
|
getComponentName,
|
|
74
74
|
isEnvShareable,
|
|
75
|
+
getBlockletAppIdList,
|
|
75
76
|
} = require('@blocklet/meta/lib/util');
|
|
76
77
|
const toBlockletDid = require('@blocklet/meta/lib/did');
|
|
77
78
|
const { titleSchema, descriptionSchema, logoSchema } = require('@blocklet/meta/lib/schema');
|
|
@@ -429,6 +430,8 @@ const getRuntimeEnvironments = (blocklet, nodeEnvironments, ancestors) => {
|
|
|
429
430
|
? getBlockletWallet(blocklet.meta.did, nodeEnvironments.ABT_NODE_SK, undefined, 1)
|
|
430
431
|
: null;
|
|
431
432
|
|
|
433
|
+
const BLOCKLET_APP_IDS = getBlockletAppIdList(root).join(',');
|
|
434
|
+
|
|
432
435
|
const env = {
|
|
433
436
|
...blocklet.configObj,
|
|
434
437
|
...getSharedConfigObj(blocklet, ancestors),
|
|
@@ -439,6 +442,7 @@ const getRuntimeEnvironments = (blocklet, nodeEnvironments, ancestors) => {
|
|
|
439
442
|
BLOCKLET_MODE: blocklet.mode || BLOCKLET_MODES.PRODUCTION,
|
|
440
443
|
BLOCKLET_APP_EK: tmp?.secretKey,
|
|
441
444
|
BLOCKLET_APP_VERSION: root.meta.version,
|
|
445
|
+
BLOCKLET_APP_IDS,
|
|
442
446
|
...nodeEnvironments,
|
|
443
447
|
...safeNodeEnvironments,
|
|
444
448
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.0-beta-
|
|
6
|
+
"version": "1.16.0-beta-62b42401",
|
|
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.0-beta-
|
|
23
|
-
"@abtnode/certificate-manager": "1.16.0-beta-
|
|
24
|
-
"@abtnode/constant": "1.16.0-beta-
|
|
25
|
-
"@abtnode/cron": "1.16.0-beta-
|
|
26
|
-
"@abtnode/db": "1.16.0-beta-
|
|
27
|
-
"@abtnode/logger": "1.16.0-beta-
|
|
28
|
-
"@abtnode/queue": "1.16.0-beta-
|
|
29
|
-
"@abtnode/rbac": "1.16.0-beta-
|
|
30
|
-
"@abtnode/router-provider": "1.16.0-beta-
|
|
31
|
-
"@abtnode/static-server": "1.16.0-beta-
|
|
32
|
-
"@abtnode/timemachine": "1.16.0-beta-
|
|
33
|
-
"@abtnode/util": "1.16.0-beta-
|
|
34
|
-
"@arcblock/did": "1.18.
|
|
22
|
+
"@abtnode/auth": "1.16.0-beta-62b42401",
|
|
23
|
+
"@abtnode/certificate-manager": "1.16.0-beta-62b42401",
|
|
24
|
+
"@abtnode/constant": "1.16.0-beta-62b42401",
|
|
25
|
+
"@abtnode/cron": "1.16.0-beta-62b42401",
|
|
26
|
+
"@abtnode/db": "1.16.0-beta-62b42401",
|
|
27
|
+
"@abtnode/logger": "1.16.0-beta-62b42401",
|
|
28
|
+
"@abtnode/queue": "1.16.0-beta-62b42401",
|
|
29
|
+
"@abtnode/rbac": "1.16.0-beta-62b42401",
|
|
30
|
+
"@abtnode/router-provider": "1.16.0-beta-62b42401",
|
|
31
|
+
"@abtnode/static-server": "1.16.0-beta-62b42401",
|
|
32
|
+
"@abtnode/timemachine": "1.16.0-beta-62b42401",
|
|
33
|
+
"@abtnode/util": "1.16.0-beta-62b42401",
|
|
34
|
+
"@arcblock/did": "1.18.63",
|
|
35
35
|
"@arcblock/did-motif": "^1.1.10",
|
|
36
|
-
"@arcblock/did-util": "1.18.
|
|
37
|
-
"@arcblock/event-hub": "1.18.
|
|
38
|
-
"@arcblock/jwt": "^1.18.
|
|
36
|
+
"@arcblock/did-util": "1.18.63",
|
|
37
|
+
"@arcblock/event-hub": "1.18.63",
|
|
38
|
+
"@arcblock/jwt": "^1.18.63",
|
|
39
39
|
"@arcblock/pm2-events": "^0.0.5",
|
|
40
|
-
"@arcblock/vc": "1.18.
|
|
41
|
-
"@blocklet/constant": "1.16.0-beta-
|
|
42
|
-
"@blocklet/meta": "1.16.0-beta-
|
|
43
|
-
"@blocklet/sdk": "1.16.0-beta-
|
|
40
|
+
"@arcblock/vc": "1.18.63",
|
|
41
|
+
"@blocklet/constant": "1.16.0-beta-62b42401",
|
|
42
|
+
"@blocklet/meta": "1.16.0-beta-62b42401",
|
|
43
|
+
"@blocklet/sdk": "1.16.0-beta-62b42401",
|
|
44
44
|
"@did-space/client": "^0.2.40",
|
|
45
45
|
"@fidm/x509": "^1.2.1",
|
|
46
|
-
"@ocap/client": "1.18.
|
|
47
|
-
"@ocap/mcrypto": "1.18.
|
|
48
|
-
"@ocap/util": "1.18.
|
|
49
|
-
"@ocap/wallet": "1.18.
|
|
46
|
+
"@ocap/client": "1.18.63",
|
|
47
|
+
"@ocap/mcrypto": "1.18.63",
|
|
48
|
+
"@ocap/util": "1.18.63",
|
|
49
|
+
"@ocap/wallet": "1.18.63",
|
|
50
50
|
"@slack/webhook": "^5.0.4",
|
|
51
51
|
"archiver": "^5.3.1",
|
|
52
52
|
"axios": "^0.27.2",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"express": "^4.18.2",
|
|
92
92
|
"jest": "^27.5.1"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "6ef1c3601d0cfdcf5da0b55b4c54ef1fa9fce7d2"
|
|
95
95
|
}
|