@abtnode/core 1.16.54-beta-20251027-105624-dfa978f8 → 1.16.54-beta-20251028-073105-3ed10cef
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.
|
@@ -10,17 +10,17 @@ const logger = require('@abtnode/logger')('@abtnode/core:blocklet:security');
|
|
|
10
10
|
const { _convertResponseHeaderPolicy, _formatResponseHeaderPolicy } = require('./utils');
|
|
11
11
|
const { responseHeaderPolicySchema } = require('./validator');
|
|
12
12
|
|
|
13
|
-
const getBlockletResponseHeaderPolicy = async ({ teamManager }, { did, id,
|
|
13
|
+
const getBlockletResponseHeaderPolicy = async ({ teamManager }, { did, id, formatted = false }) => {
|
|
14
14
|
const { responseHeaderPolicyState } = await teamManager.getSecurityState(did);
|
|
15
15
|
const result = await responseHeaderPolicyState.getResponseHeaderPolicy(id);
|
|
16
|
-
return
|
|
16
|
+
return formatted ? result : _convertResponseHeaderPolicy(result);
|
|
17
17
|
};
|
|
18
|
-
const getBlockletResponseHeaderPolicies = async ({ teamManager }, { did,
|
|
18
|
+
const getBlockletResponseHeaderPolicies = async ({ teamManager }, { did, formatted = false }) => {
|
|
19
19
|
const { responseHeaderPolicyState } = await teamManager.getSecurityState(did);
|
|
20
20
|
const result = await responseHeaderPolicyState.getResponseHeaderPolicies(undefined, undefined, {
|
|
21
21
|
createdAt: -1,
|
|
22
22
|
});
|
|
23
|
-
const responseHeaderPolicies = result.map((item) => (
|
|
23
|
+
const responseHeaderPolicies = result.map((item) => (formatted ? item : _convertResponseHeaderPolicy(item)));
|
|
24
24
|
return {
|
|
25
25
|
responseHeaderPolicies,
|
|
26
26
|
paging: null,
|
|
@@ -42,7 +42,7 @@ async function addBlockletResponseHeaderPolicy({ teamManager }, { did, data }) {
|
|
|
42
42
|
return _convertResponseHeaderPolicy(result);
|
|
43
43
|
}
|
|
44
44
|
// HACK: 由于需要使用 this.emit,所以这里不能使用箭头函数(尝试过传入 emit,会报错,目前只能这样)
|
|
45
|
-
async function updateBlockletResponseHeaderPolicy({ teamManager }, { did, data,
|
|
45
|
+
async function updateBlockletResponseHeaderPolicy({ teamManager }, { did, data, formatted = false }) {
|
|
46
46
|
const { responseHeaderPolicyState } = await teamManager.getSecurityState(did);
|
|
47
47
|
const { value, error } = responseHeaderPolicySchema
|
|
48
48
|
.concat(
|
|
@@ -60,7 +60,7 @@ async function updateBlockletResponseHeaderPolicy({ teamManager }, { did, data,
|
|
|
60
60
|
}
|
|
61
61
|
const result = await responseHeaderPolicyState.updateResponseHeaderPolicy(_formatResponseHeaderPolicy(value));
|
|
62
62
|
this.emit(BlockletEvents.securityConfigUpdated, { did });
|
|
63
|
-
return
|
|
63
|
+
return formatted ? result : _convertResponseHeaderPolicy(result);
|
|
64
64
|
}
|
|
65
65
|
// HACK: 由于需要使用 this.emit,所以这里不能使用箭头函数(尝试过传入 emit,会报错,目前只能这样)
|
|
66
66
|
async function deleteBlockletResponseHeaderPolicy({ teamManager }, { did, id }) {
|
|
@@ -17,7 +17,7 @@ const getBlockletSecurityRule = async ({ teamManager }, { did, id }) => {
|
|
|
17
17
|
const result = await securityRuleState.getSecurityRule(id);
|
|
18
18
|
return result;
|
|
19
19
|
};
|
|
20
|
-
const getBlockletSecurityRules = async ({ teamManager }, { did, includeDisabled = false,
|
|
20
|
+
const getBlockletSecurityRules = async ({ teamManager }, { did, includeDisabled = false, formatted = false }) => {
|
|
21
21
|
const { securityRuleState, accessPolicyState, responseHeaderPolicyState } = await teamManager.getSecurityState(did);
|
|
22
22
|
const include = [
|
|
23
23
|
{
|
|
@@ -36,7 +36,7 @@ const getBlockletSecurityRules = async ({ teamManager }, { did, includeDisabled
|
|
|
36
36
|
const result = await securityRuleState.model.findAll({ include, where });
|
|
37
37
|
const securityRules = result.map((item) => {
|
|
38
38
|
const resultItem = item.toJSON();
|
|
39
|
-
if (resultItem.responseHeaderPolicy && !
|
|
39
|
+
if (resultItem.responseHeaderPolicy && !formatted) {
|
|
40
40
|
resultItem.responseHeaderPolicy = _convertResponseHeaderPolicy(resultItem.responseHeaderPolicy);
|
|
41
41
|
}
|
|
42
42
|
return resultItem;
|
package/lib/util/blocklet.js
CHANGED
|
@@ -368,16 +368,22 @@ const getAppSystemEnvironments = (blocklet, nodeInfo, dataDirs) => {
|
|
|
368
368
|
const { wallet } = result;
|
|
369
369
|
const appSk = toHex(wallet.secretKey);
|
|
370
370
|
const appPk = toHex(wallet.publicKey);
|
|
371
|
+
|
|
372
|
+
const ethWallet = fromSecretKey(appSk.slice(0, 66), 'ethereum');
|
|
373
|
+
const ethPk = toHex(ethWallet.publicKey);
|
|
374
|
+
|
|
371
375
|
const appId = wallet.address;
|
|
372
376
|
const appName = title || name || result.name;
|
|
373
377
|
const appDescription = description || result.description;
|
|
374
378
|
|
|
375
379
|
const isMigrated = Array.isArray(blocklet.migratedFrom) && blocklet.migratedFrom.length > 0;
|
|
376
380
|
const appPid = blocklet.appPid || appId;
|
|
377
|
-
const appPsk = isMigrated ? blocklet.migratedFrom[0].appSk : appSk;
|
|
381
|
+
const appPsk = toHex(isMigrated ? blocklet.migratedFrom[0].appSk : appSk);
|
|
378
382
|
|
|
379
383
|
// Calculate permanent public key (PPK)
|
|
380
384
|
const appPpk = isMigrated ? toHex(fromSecretKey(appPsk, wallet.type).publicKey) : appPk;
|
|
385
|
+
const ethPermanentWallet = fromSecretKey(appPsk.slice(0, 66), 'ethereum');
|
|
386
|
+
const appPpkEth = toHex(ethPermanentWallet.publicKey);
|
|
381
387
|
|
|
382
388
|
/* 获取 did domain 方式:
|
|
383
389
|
* 1. 先从 site 里读
|
|
@@ -400,10 +406,12 @@ const getAppSystemEnvironments = (blocklet, nodeInfo, dataDirs) => {
|
|
|
400
406
|
return {
|
|
401
407
|
BLOCKLET_DID: did, // BLOCKLET_DID is always same as BLOCKLET_APP_PID in structV2 application
|
|
402
408
|
BLOCKLET_APP_PK: appPk,
|
|
409
|
+
BLOCKLET_APP_PK_ETH: ethPk,
|
|
403
410
|
BLOCKLET_APP_SK: appSk,
|
|
404
411
|
BLOCKLET_APP_ID: appId,
|
|
405
412
|
BLOCKLET_APP_PSK: appPsk, // permanent sk even the blocklet has been migrated
|
|
406
413
|
BLOCKLET_APP_PPK: appPpk, // permanent pk corresponding to PSK
|
|
414
|
+
BLOCKLET_APP_PPK_ETH: appPpkEth, // permanent pk corresponding to PSK for ethereum
|
|
407
415
|
BLOCKLET_APP_PID: appPid, // permanent did even the blocklet has been migrated
|
|
408
416
|
BLOCKLET_APP_NAME: appName,
|
|
409
417
|
BLOCKLET_APP_NAME_SLUG: urlPathFriendly(slugify(appName)),
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.54-beta-
|
|
6
|
+
"version": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,21 +19,21 @@
|
|
|
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.54-beta-
|
|
23
|
-
"@abtnode/auth": "1.16.54-beta-
|
|
24
|
-
"@abtnode/certificate-manager": "1.16.54-beta-
|
|
25
|
-
"@abtnode/constant": "1.16.54-beta-
|
|
26
|
-
"@abtnode/cron": "1.16.54-beta-
|
|
27
|
-
"@abtnode/db-cache": "1.16.54-beta-
|
|
28
|
-
"@abtnode/docker-utils": "1.16.54-beta-
|
|
29
|
-
"@abtnode/logger": "1.16.54-beta-
|
|
30
|
-
"@abtnode/models": "1.16.54-beta-
|
|
31
|
-
"@abtnode/queue": "1.16.54-beta-
|
|
32
|
-
"@abtnode/rbac": "1.16.54-beta-
|
|
33
|
-
"@abtnode/router-provider": "1.16.54-beta-
|
|
34
|
-
"@abtnode/static-server": "1.16.54-beta-
|
|
35
|
-
"@abtnode/timemachine": "1.16.54-beta-
|
|
36
|
-
"@abtnode/util": "1.16.54-beta-
|
|
22
|
+
"@abtnode/analytics": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
23
|
+
"@abtnode/auth": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
24
|
+
"@abtnode/certificate-manager": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
25
|
+
"@abtnode/constant": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
26
|
+
"@abtnode/cron": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
27
|
+
"@abtnode/db-cache": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
28
|
+
"@abtnode/docker-utils": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
29
|
+
"@abtnode/logger": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
30
|
+
"@abtnode/models": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
31
|
+
"@abtnode/queue": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
32
|
+
"@abtnode/rbac": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
33
|
+
"@abtnode/router-provider": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
34
|
+
"@abtnode/static-server": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
35
|
+
"@abtnode/timemachine": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
36
|
+
"@abtnode/util": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
37
37
|
"@aigne/aigne-hub": "^0.10.3",
|
|
38
38
|
"@arcblock/did": "^1.26.3",
|
|
39
39
|
"@arcblock/did-connect-js": "^1.26.3",
|
|
@@ -45,15 +45,15 @@
|
|
|
45
45
|
"@arcblock/pm2-events": "^0.0.5",
|
|
46
46
|
"@arcblock/validator": "^1.26.3",
|
|
47
47
|
"@arcblock/vc": "^1.26.3",
|
|
48
|
-
"@blocklet/constant": "1.16.54-beta-
|
|
48
|
+
"@blocklet/constant": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
49
49
|
"@blocklet/did-space-js": "^1.1.34",
|
|
50
|
-
"@blocklet/env": "1.16.54-beta-
|
|
50
|
+
"@blocklet/env": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
51
51
|
"@blocklet/error": "^0.2.5",
|
|
52
|
-
"@blocklet/meta": "1.16.54-beta-
|
|
53
|
-
"@blocklet/resolver": "1.16.54-beta-
|
|
54
|
-
"@blocklet/sdk": "1.16.54-beta-
|
|
55
|
-
"@blocklet/server-js": "1.16.54-beta-
|
|
56
|
-
"@blocklet/store": "1.16.54-beta-
|
|
52
|
+
"@blocklet/meta": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
53
|
+
"@blocklet/resolver": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
54
|
+
"@blocklet/sdk": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
55
|
+
"@blocklet/server-js": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
56
|
+
"@blocklet/store": "1.16.54-beta-20251028-073105-3ed10cef",
|
|
57
57
|
"@blocklet/theme": "^3.1.51",
|
|
58
58
|
"@fidm/x509": "^1.2.1",
|
|
59
59
|
"@ocap/mcrypto": "^1.26.3",
|
|
@@ -118,5 +118,5 @@
|
|
|
118
118
|
"express": "^4.18.2",
|
|
119
119
|
"unzipper": "^0.10.11"
|
|
120
120
|
},
|
|
121
|
-
"gitHead": "
|
|
121
|
+
"gitHead": "3002dd309759dd23c921b098b9edbef08838b734"
|
|
122
122
|
}
|