@abtnode/core 1.16.24 → 1.16.25-beta-fe54d1bc
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 +1 -1
- package/lib/blocklet/manager/disk.js +6 -6
- package/lib/states/user.js +6 -2
- package/lib/util/blocklet.js +7 -2
- package/package.json +31 -31
- package/lib/util/federated.js +0 -43
package/lib/api/team.js
CHANGED
|
@@ -26,6 +26,7 @@ const {
|
|
|
26
26
|
createUserPassport,
|
|
27
27
|
} = require('@abtnode/auth/lib/passport');
|
|
28
28
|
const { getPassportStatusEndpoint } = require('@abtnode/auth/lib/auth');
|
|
29
|
+
const { callFederated, getFederatedMaster, findFederatedSite } = require('@abtnode/auth/lib/util/federated');
|
|
29
30
|
const { hasActiveOwnerPassport } = require('@abtnode/util/lib/passport');
|
|
30
31
|
const getBlockletInfo = require('@blocklet/meta/lib/info');
|
|
31
32
|
const { getUserAvatarUrl, getAppAvatarUrl, extractUserAvatar, getAvatarByUrl } = require('@abtnode/util/lib/user');
|
|
@@ -41,7 +42,6 @@ const { validateCreatePermission, validateUpdatePermission } = require('../valid
|
|
|
41
42
|
const { getBlocklet } = require('../util/blocklet');
|
|
42
43
|
const StoreUtil = require('../util/store');
|
|
43
44
|
const { profileSchema } = require('../validators/user');
|
|
44
|
-
const { callFederated, getFederatedMaster, findFederatedSite } = require('../util/federated');
|
|
45
45
|
|
|
46
46
|
const sanitizeUrl = (url) => {
|
|
47
47
|
if (!url) {
|
|
@@ -99,6 +99,7 @@ const isFunction = require('lodash/isFunction');
|
|
|
99
99
|
const { encode } = require('@abtnode/util/lib/base32');
|
|
100
100
|
const formatContext = require('@abtnode/util/lib/format-context');
|
|
101
101
|
const md5 = require('@abtnode/util/lib/md5');
|
|
102
|
+
const { callFederated } = require('@abtnode/auth/lib/util/federated');
|
|
102
103
|
const { consumeServerlessNFT, consumeLauncherSession } = require('../../util/launcher');
|
|
103
104
|
const util = require('../../util');
|
|
104
105
|
const {
|
|
@@ -197,7 +198,6 @@ const {
|
|
|
197
198
|
getSelectedResources,
|
|
198
199
|
updateSelectedResources,
|
|
199
200
|
} = require('../project');
|
|
200
|
-
const { callFederated } = require('../../util/federated');
|
|
201
201
|
|
|
202
202
|
const { formatEnvironments, getBlockletMeta, validateOwner, isCLI } = util;
|
|
203
203
|
|
|
@@ -1257,7 +1257,7 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
1257
1257
|
}
|
|
1258
1258
|
|
|
1259
1259
|
// Get blocklet by blockletDid or appDid
|
|
1260
|
-
async detail({ did, attachConfig = true, attachRuntimeInfo, useCache }, context) {
|
|
1260
|
+
async detail({ did, attachConfig = true, attachRuntimeInfo, useCache, getOptionalComponents }, context) {
|
|
1261
1261
|
if (!did) {
|
|
1262
1262
|
throw new Error('did should not be empty');
|
|
1263
1263
|
}
|
|
@@ -1267,7 +1267,7 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
1267
1267
|
}
|
|
1268
1268
|
|
|
1269
1269
|
if (attachRuntimeInfo) {
|
|
1270
|
-
return this._attachRuntimeInfo({ did, diskInfo: true, context });
|
|
1270
|
+
return this._attachRuntimeInfo({ did, diskInfo: true, context, getOptionalComponents });
|
|
1271
1271
|
}
|
|
1272
1272
|
|
|
1273
1273
|
if (useCache && this.cachedBlocklets.has(did)) {
|
|
@@ -1275,7 +1275,7 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
1275
1275
|
}
|
|
1276
1276
|
|
|
1277
1277
|
try {
|
|
1278
|
-
const blocklet = await this.getBlocklet(did, { throwOnNotExist: false });
|
|
1278
|
+
const blocklet = await this.getBlocklet(did, { throwOnNotExist: false, getOptionalComponents });
|
|
1279
1279
|
|
|
1280
1280
|
if (blocklet) {
|
|
1281
1281
|
if (blocklet.appDid) {
|
|
@@ -3026,13 +3026,13 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
3026
3026
|
return [];
|
|
3027
3027
|
}
|
|
3028
3028
|
|
|
3029
|
-
async _attachRuntimeInfo({ did, diskInfo = true, context }) {
|
|
3029
|
+
async _attachRuntimeInfo({ did, diskInfo = true, context, getOptionalComponents }) {
|
|
3030
3030
|
if (!did) {
|
|
3031
3031
|
throw new Error('did should not be empty');
|
|
3032
3032
|
}
|
|
3033
3033
|
|
|
3034
3034
|
try {
|
|
3035
|
-
const blocklet = await this.getBlocklet(did, { throwOnNotExist: false });
|
|
3035
|
+
const blocklet = await this.getBlocklet(did, { throwOnNotExist: false, getOptionalComponents });
|
|
3036
3036
|
|
|
3037
3037
|
if (!blocklet) {
|
|
3038
3038
|
return null;
|
package/lib/states/user.js
CHANGED
|
@@ -209,7 +209,9 @@ class User extends ExtendBase {
|
|
|
209
209
|
if (role && role !== '$all' && !where.did) {
|
|
210
210
|
if (role === '$none') {
|
|
211
211
|
where.did = {
|
|
212
|
-
[Op.notIn]: Sequelize.literal(
|
|
212
|
+
[Op.notIn]: Sequelize.literal(
|
|
213
|
+
`(SELECT DISTINCT userDid FROM passports WHERE status = '${PASSPORT_STATUS.VALID}')`
|
|
214
|
+
),
|
|
213
215
|
};
|
|
214
216
|
} else {
|
|
215
217
|
where.did = {
|
|
@@ -265,7 +267,9 @@ class User extends ExtendBase {
|
|
|
265
267
|
return this.count({
|
|
266
268
|
where: {
|
|
267
269
|
did: {
|
|
268
|
-
[Op.notIn]: Sequelize.literal(
|
|
270
|
+
[Op.notIn]: Sequelize.literal(
|
|
271
|
+
`(SELECT DISTINCT userDid FROM passports WHERE status = '${PASSPORT_STATUS.VALID}')`
|
|
272
|
+
),
|
|
269
273
|
},
|
|
270
274
|
},
|
|
271
275
|
});
|
package/lib/util/blocklet.js
CHANGED
|
@@ -1255,6 +1255,7 @@ const getBlocklet = async ({
|
|
|
1255
1255
|
e2eMode = false,
|
|
1256
1256
|
throwOnNotExist = true,
|
|
1257
1257
|
ensureIntegrity = false,
|
|
1258
|
+
getOptionalComponents = false,
|
|
1258
1259
|
} = {}) => {
|
|
1259
1260
|
if (!did) {
|
|
1260
1261
|
throw new Error('Blocklet did does not exist');
|
|
@@ -1333,8 +1334,12 @@ const getBlocklet = async ({
|
|
|
1333
1334
|
fillBlockletConfigs(component, configs);
|
|
1334
1335
|
});
|
|
1335
1336
|
|
|
1336
|
-
|
|
1337
|
-
|
|
1337
|
+
if (getOptionalComponents) {
|
|
1338
|
+
const optionalComponents = await parseOptionalComponents(blocklet);
|
|
1339
|
+
blocklet.optionalComponents = optionalComponents;
|
|
1340
|
+
} else {
|
|
1341
|
+
blocklet.optionalComponents = [];
|
|
1342
|
+
}
|
|
1338
1343
|
|
|
1339
1344
|
return blocklet;
|
|
1340
1345
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.
|
|
6
|
+
"version": "1.16.25-beta-fe54d1bc",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,39 +19,39 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/analytics": "1.16.
|
|
23
|
-
"@abtnode/auth": "1.16.
|
|
24
|
-
"@abtnode/certificate-manager": "1.16.
|
|
25
|
-
"@abtnode/constant": "1.16.
|
|
26
|
-
"@abtnode/cron": "1.16.
|
|
27
|
-
"@abtnode/logger": "1.16.
|
|
28
|
-
"@abtnode/models": "1.16.
|
|
29
|
-
"@abtnode/queue": "1.16.
|
|
30
|
-
"@abtnode/rbac": "1.16.
|
|
31
|
-
"@abtnode/router-provider": "1.16.
|
|
32
|
-
"@abtnode/static-server": "1.16.
|
|
33
|
-
"@abtnode/timemachine": "1.16.
|
|
34
|
-
"@abtnode/util": "1.16.
|
|
35
|
-
"@arcblock/did": "1.18.
|
|
36
|
-
"@arcblock/did-auth": "1.18.
|
|
37
|
-
"@arcblock/did-ext": "^1.18.
|
|
22
|
+
"@abtnode/analytics": "1.16.25-beta-fe54d1bc",
|
|
23
|
+
"@abtnode/auth": "1.16.25-beta-fe54d1bc",
|
|
24
|
+
"@abtnode/certificate-manager": "1.16.25-beta-fe54d1bc",
|
|
25
|
+
"@abtnode/constant": "1.16.25-beta-fe54d1bc",
|
|
26
|
+
"@abtnode/cron": "1.16.25-beta-fe54d1bc",
|
|
27
|
+
"@abtnode/logger": "1.16.25-beta-fe54d1bc",
|
|
28
|
+
"@abtnode/models": "1.16.25-beta-fe54d1bc",
|
|
29
|
+
"@abtnode/queue": "1.16.25-beta-fe54d1bc",
|
|
30
|
+
"@abtnode/rbac": "1.16.25-beta-fe54d1bc",
|
|
31
|
+
"@abtnode/router-provider": "1.16.25-beta-fe54d1bc",
|
|
32
|
+
"@abtnode/static-server": "1.16.25-beta-fe54d1bc",
|
|
33
|
+
"@abtnode/timemachine": "1.16.25-beta-fe54d1bc",
|
|
34
|
+
"@abtnode/util": "1.16.25-beta-fe54d1bc",
|
|
35
|
+
"@arcblock/did": "1.18.113",
|
|
36
|
+
"@arcblock/did-auth": "1.18.113",
|
|
37
|
+
"@arcblock/did-ext": "^1.18.113",
|
|
38
38
|
"@arcblock/did-motif": "^1.1.13",
|
|
39
|
-
"@arcblock/did-util": "1.18.
|
|
40
|
-
"@arcblock/event-hub": "1.18.
|
|
41
|
-
"@arcblock/jwt": "^1.18.
|
|
39
|
+
"@arcblock/did-util": "1.18.113",
|
|
40
|
+
"@arcblock/event-hub": "1.18.113",
|
|
41
|
+
"@arcblock/jwt": "^1.18.113",
|
|
42
42
|
"@arcblock/pm2-events": "^0.0.5",
|
|
43
|
-
"@arcblock/validator": "^1.18.
|
|
44
|
-
"@arcblock/vc": "1.18.
|
|
45
|
-
"@blocklet/constant": "1.16.
|
|
46
|
-
"@blocklet/env": "1.16.
|
|
47
|
-
"@blocklet/meta": "1.16.
|
|
48
|
-
"@blocklet/resolver": "1.16.
|
|
49
|
-
"@blocklet/sdk": "1.16.
|
|
43
|
+
"@arcblock/validator": "^1.18.113",
|
|
44
|
+
"@arcblock/vc": "1.18.113",
|
|
45
|
+
"@blocklet/constant": "1.16.25-beta-fe54d1bc",
|
|
46
|
+
"@blocklet/env": "1.16.25-beta-fe54d1bc",
|
|
47
|
+
"@blocklet/meta": "1.16.25-beta-fe54d1bc",
|
|
48
|
+
"@blocklet/resolver": "1.16.25-beta-fe54d1bc",
|
|
49
|
+
"@blocklet/sdk": "1.16.25-beta-fe54d1bc",
|
|
50
50
|
"@did-space/client": "^0.3.67",
|
|
51
51
|
"@fidm/x509": "^1.2.1",
|
|
52
|
-
"@ocap/mcrypto": "1.18.
|
|
53
|
-
"@ocap/util": "1.18.
|
|
54
|
-
"@ocap/wallet": "1.18.
|
|
52
|
+
"@ocap/mcrypto": "1.18.113",
|
|
53
|
+
"@ocap/util": "1.18.113",
|
|
54
|
+
"@ocap/wallet": "1.18.113",
|
|
55
55
|
"@slack/webhook": "^5.0.4",
|
|
56
56
|
"archiver": "^5.3.1",
|
|
57
57
|
"axios": "^0.27.2",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"jest": "^29.7.0",
|
|
103
103
|
"unzipper": "^0.10.11"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "e9411b6ee3c482554c76fe91796560abeb0e56ad"
|
|
106
106
|
}
|
package/lib/util/federated.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
const { WELLKNOWN_SERVICE_PATH_PREFIX } = require('@abtnode/constant');
|
|
2
|
-
const pRetry = require('p-retry');
|
|
3
|
-
const { signV2 } = require('@arcblock/jwt');
|
|
4
|
-
const joinUrl = require('url-join');
|
|
5
|
-
|
|
6
|
-
const request = require('./request');
|
|
7
|
-
|
|
8
|
-
function isMaster(site) {
|
|
9
|
-
return site?.isMaster !== false;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function getFederatedMaster(blocklet) {
|
|
13
|
-
const { sites } = blocklet?.settings?.federated || {};
|
|
14
|
-
const masterSite = (sites || []).find((item) => isMaster(item));
|
|
15
|
-
return masterSite || null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function findFederatedSite(blocklet, targetAppPid) {
|
|
19
|
-
const { sites } = blocklet?.settings?.federated || {};
|
|
20
|
-
const targetSite = (sites || []).find((item) => item.appPid === targetAppPid);
|
|
21
|
-
return targetSite || null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async function callFederated({ site, permanentWallet, data, action }) {
|
|
25
|
-
const url = new URL(site.appUrl);
|
|
26
|
-
url.pathname = joinUrl(WELLKNOWN_SERVICE_PATH_PREFIX, `/api/federated/${action}`);
|
|
27
|
-
const result = await pRetry(
|
|
28
|
-
() =>
|
|
29
|
-
request.post(url.href, {
|
|
30
|
-
signer: permanentWallet.address,
|
|
31
|
-
data: signV2(permanentWallet.address, permanentWallet.secretKey, data),
|
|
32
|
-
}),
|
|
33
|
-
{ retries: 3 }
|
|
34
|
-
);
|
|
35
|
-
return result.data;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
module.exports = {
|
|
39
|
-
callFederated,
|
|
40
|
-
getFederatedMaster,
|
|
41
|
-
findFederatedSite,
|
|
42
|
-
isMaster,
|
|
43
|
-
};
|