@abtnode/core 1.16.16-beta-740ea329 → 1.16.16-beta-301539f6
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 -0
- package/lib/blocklet/manager/disk.js +64 -12
- package/lib/index.js +1 -0
- package/lib/states/user.js +11 -1
- package/lib/validators/user.js +1 -0
- package/package.json +32 -32
package/lib/api/team.js
CHANGED
|
@@ -15,6 +15,7 @@ const { isNFTExpired, getNftExpirationDate } = require('@abtnode/util/lib/nft');
|
|
|
15
15
|
const { sign } = require('@arcblock/jwt');
|
|
16
16
|
const sleep = require('@abtnode/util/lib/sleep');
|
|
17
17
|
const getBlockletInfo = require('@blocklet/meta/lib/info');
|
|
18
|
+
const joinUrl = require('url-join');
|
|
18
19
|
|
|
19
20
|
const logger = require('@abtnode/logger')('@abtnode/core:blocklet:manager');
|
|
20
21
|
const {
|
|
@@ -3031,7 +3032,7 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
3031
3032
|
await states.blockletExtras.setConfigs([app.meta.did, component?.meta?.did].filter(Boolean), environments);
|
|
3032
3033
|
|
|
3033
3034
|
if (component) {
|
|
3034
|
-
const envsInApp = await states.blockletExtras.getConfigs([
|
|
3035
|
+
const envsInApp = await states.blockletExtras.getConfigs([blocklet.meta.did]);
|
|
3035
3036
|
const envsInComponent = await states.blockletExtras.getConfigs([app.meta.did, component.meta.did]);
|
|
3036
3037
|
|
|
3037
3038
|
const configs = getAppConfigsFromComponent({ environments }, envsInApp, envsInComponent);
|
|
@@ -3042,7 +3043,7 @@ class DiskBlockletManager extends BaseBlockletManager {
|
|
|
3042
3043
|
|
|
3043
3044
|
// chain config
|
|
3044
3045
|
await this._ensureAppChainConfig(
|
|
3045
|
-
blocklet.
|
|
3046
|
+
blocklet.meta.did,
|
|
3046
3047
|
environments.map((x) => ({ key: x.name, value: x.default })),
|
|
3047
3048
|
{ force: false }
|
|
3048
3049
|
);
|
|
@@ -3594,7 +3595,7 @@ class FederatedBlockletManager extends DiskBlockletManager {
|
|
|
3594
3595
|
async joinFederatedLogin({ appUrl, did }) {
|
|
3595
3596
|
const url = new URL(appUrl);
|
|
3596
3597
|
// master service api 的地址
|
|
3597
|
-
url.pathname =
|
|
3598
|
+
url.pathname = joinUrl(WELLKNOWN_SERVICE_PATH_PREFIX, '/api/federated/join');
|
|
3598
3599
|
|
|
3599
3600
|
const blocklet = await this.getBlocklet(did);
|
|
3600
3601
|
const nodeInfo = await states.node.read();
|
|
@@ -3611,7 +3612,7 @@ class FederatedBlockletManager extends DiskBlockletManager {
|
|
|
3611
3612
|
aliasDomain: domainAliases.map((x) => x.value),
|
|
3612
3613
|
appLogo:
|
|
3613
3614
|
blocklet.environmentObj.BLOCKLET_APP_LOGO ||
|
|
3614
|
-
normalizePathPrefix(
|
|
3615
|
+
normalizePathPrefix(joinUrl(WELLKNOWN_SERVICE_PATH_PREFIX, '/blocklet/logo')) ||
|
|
3615
3616
|
'/',
|
|
3616
3617
|
appLogoRect: blocklet.environmentObj.BLOCKLET_APP_LOGO_RECT,
|
|
3617
3618
|
did: permanentWallet.address,
|
|
@@ -3681,7 +3682,7 @@ class FederatedBlockletManager extends DiskBlockletManager {
|
|
|
3681
3682
|
masterAppUrl: masterSite.appUrl,
|
|
3682
3683
|
});
|
|
3683
3684
|
const url = new URL(masterSite.appUrl);
|
|
3684
|
-
url.pathname =
|
|
3685
|
+
url.pathname = joinUrl(WELLKNOWN_SERVICE_PATH_PREFIX, '/api/federated/quit');
|
|
3685
3686
|
try {
|
|
3686
3687
|
await pRetry(
|
|
3687
3688
|
() =>
|
|
@@ -3735,7 +3736,7 @@ class FederatedBlockletManager extends DiskBlockletManager {
|
|
|
3735
3736
|
.map((item) => {
|
|
3736
3737
|
return limitSync(async () => {
|
|
3737
3738
|
const url = new URL(item.appUrl);
|
|
3738
|
-
url.pathname =
|
|
3739
|
+
url.pathname = joinUrl(WELLKNOWN_SERVICE_PATH_PREFIX, '/api/federated/disband');
|
|
3739
3740
|
try {
|
|
3740
3741
|
await pRetry(
|
|
3741
3742
|
() =>
|
|
@@ -3863,7 +3864,7 @@ class FederatedBlockletManager extends DiskBlockletManager {
|
|
|
3863
3864
|
roles = await this.teamManager.getRoles(blocklet.appPid);
|
|
3864
3865
|
}
|
|
3865
3866
|
|
|
3866
|
-
const postUrl =
|
|
3867
|
+
const postUrl = joinUrl(memberSite.appUrl, WELLKNOWN_SERVICE_PATH_PREFIX, '/api/federated/audit-res');
|
|
3867
3868
|
|
|
3868
3869
|
logger.info('Audit member join federated login', {
|
|
3869
3870
|
status,
|
|
@@ -3890,28 +3891,79 @@ class FederatedBlockletManager extends DiskBlockletManager {
|
|
|
3890
3891
|
logger.error('Failed to post audit res to member-site', { error, did, url: postUrl });
|
|
3891
3892
|
throw error;
|
|
3892
3893
|
}
|
|
3894
|
+
await this.syncFederated({
|
|
3895
|
+
did,
|
|
3896
|
+
data: {
|
|
3897
|
+
sites: federated.sites,
|
|
3898
|
+
},
|
|
3899
|
+
});
|
|
3900
|
+
return newState;
|
|
3901
|
+
}
|
|
3902
|
+
|
|
3903
|
+
async syncFederated({ did, data = {} } = {}) {
|
|
3904
|
+
const blocklet = await this.getBlocklet(did);
|
|
3905
|
+
|
|
3906
|
+
const federated = defaults(cloneDeep(blocklet.settings.federated || {}), {
|
|
3907
|
+
config: {},
|
|
3908
|
+
sites: [],
|
|
3909
|
+
});
|
|
3910
|
+
|
|
3911
|
+
const safeData = {};
|
|
3912
|
+
const { users, sites } = data;
|
|
3913
|
+
if (users && Array.isArray(users)) {
|
|
3914
|
+
safeData.users = users.map((item) =>
|
|
3915
|
+
pick(item, ['did', 'pk', 'fullName', 'avatar', 'email', 'connectedAccount', 'action', 'sourceAppPid'])
|
|
3916
|
+
);
|
|
3917
|
+
}
|
|
3918
|
+
|
|
3919
|
+
if (sites && Array.isArray(sites)) {
|
|
3920
|
+
safeData.sites = sites.map((item) =>
|
|
3921
|
+
pick(item, [
|
|
3922
|
+
'appId',
|
|
3923
|
+
'appPid',
|
|
3924
|
+
'aliasDid',
|
|
3925
|
+
'appName',
|
|
3926
|
+
'appDescription',
|
|
3927
|
+
'appUrl',
|
|
3928
|
+
'aliasDomain',
|
|
3929
|
+
'appLogo',
|
|
3930
|
+
'appLogoRect',
|
|
3931
|
+
'appliedAt',
|
|
3932
|
+
'did',
|
|
3933
|
+
'pk',
|
|
3934
|
+
'serverId',
|
|
3935
|
+
'serverVersion',
|
|
3936
|
+
'version',
|
|
3937
|
+
'isMaster',
|
|
3938
|
+
'status',
|
|
3939
|
+
])
|
|
3940
|
+
);
|
|
3941
|
+
}
|
|
3942
|
+
|
|
3943
|
+
const nodeInfo = await states.node.read();
|
|
3944
|
+
const { permanentWallet } = getBlockletInfo(blocklet, nodeInfo.sk);
|
|
3945
|
+
|
|
3893
3946
|
const waitingList = federated.sites
|
|
3894
3947
|
.filter((item) => item.appId !== federated.config.appId)
|
|
3895
3948
|
.map((item) => {
|
|
3896
3949
|
return limitSync(async () => {
|
|
3897
|
-
const url =
|
|
3950
|
+
const url = joinUrl(item.appUrl, WELLKNOWN_SERVICE_PATH_PREFIX, '/api/federated/sync');
|
|
3898
3951
|
try {
|
|
3899
|
-
// NOTICE:
|
|
3952
|
+
// NOTICE: 即使通知某个站点失败了,也不影响其他站点接收同步结果
|
|
3900
3953
|
await pRetry(
|
|
3901
3954
|
() =>
|
|
3902
3955
|
request.post(url, {
|
|
3903
3956
|
signer: permanentWallet.address,
|
|
3904
|
-
data: signV2(permanentWallet.address, permanentWallet.secretKey,
|
|
3957
|
+
data: signV2(permanentWallet.address, permanentWallet.secretKey, safeData),
|
|
3905
3958
|
}),
|
|
3906
3959
|
{ retries: 3 }
|
|
3907
3960
|
);
|
|
3908
3961
|
} catch (error) {
|
|
3909
|
-
logger.warn('Failed to sync federated sites', { error, did, url, action: '
|
|
3962
|
+
logger.warn('Failed to sync federated sites', { error, did, url, action: 'sync' });
|
|
3910
3963
|
}
|
|
3911
3964
|
});
|
|
3912
3965
|
});
|
|
3913
3966
|
await Promise.all(waitingList);
|
|
3914
|
-
return newState;
|
|
3915
3967
|
}
|
|
3916
3968
|
}
|
|
3917
3969
|
|
package/lib/index.js
CHANGED
|
@@ -267,6 +267,7 @@ function ABTNode(options) {
|
|
|
267
267
|
auditFederatedLogin: blockletManager.auditFederatedLogin.bind(blockletManager),
|
|
268
268
|
configFederated: blockletManager.configFederated.bind(blockletManager),
|
|
269
269
|
setFederated: blockletManager.setFederated.bind(blockletManager),
|
|
270
|
+
syncFederated: blockletManager.syncFederated.bind(blockletManager),
|
|
270
271
|
configNotification: blockletManager.configNotification.bind(blockletManager),
|
|
271
272
|
updateWhoCanAccess: blockletManager.updateWhoCanAccess.bind(blockletManager),
|
|
272
273
|
updateAppSessionConfig: blockletManager.updateAppSessionConfig.bind(blockletManager),
|
package/lib/states/user.js
CHANGED
|
@@ -344,7 +344,17 @@ class User extends ExtendBase {
|
|
|
344
344
|
const exist = await this.getUser(user.did, { enableConnectedAccount: true });
|
|
345
345
|
|
|
346
346
|
const updates = {
|
|
347
|
-
...pick(user, [
|
|
347
|
+
...pick(user, [
|
|
348
|
+
'fullName',
|
|
349
|
+
'email',
|
|
350
|
+
'avatar',
|
|
351
|
+
'role',
|
|
352
|
+
'locale',
|
|
353
|
+
'extra',
|
|
354
|
+
'lastLoginIp',
|
|
355
|
+
'remark',
|
|
356
|
+
'sourceAppPid',
|
|
357
|
+
]),
|
|
348
358
|
lastLoginAt: now,
|
|
349
359
|
passports: user.passport ? [{ ...user.passport, lastLoginAt: now }] : [],
|
|
350
360
|
};
|
package/lib/validators/user.js
CHANGED
|
@@ -35,6 +35,7 @@ const loginSchema = Joi.object({
|
|
|
35
35
|
remark: Joi.string().empty(''),
|
|
36
36
|
lastLoginIp: Joi.string().empty(''),
|
|
37
37
|
passport: passportSchema.optional(),
|
|
38
|
+
sourceAppPid: Joi.string().empty(null),
|
|
38
39
|
connectedAccount: Joi.alternatives()
|
|
39
40
|
.try(connectedAccountSchema.required(), Joi.array().items(connectedAccountSchema).min(1).sparse(true))
|
|
40
41
|
.required(),
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.16-beta-
|
|
6
|
+
"version": "1.16.16-beta-301539f6",
|
|
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.16-beta-
|
|
23
|
-
"@abtnode/auth": "1.16.16-beta-
|
|
24
|
-
"@abtnode/certificate-manager": "1.16.16-beta-
|
|
25
|
-
"@abtnode/constant": "1.16.16-beta-
|
|
26
|
-
"@abtnode/cron": "1.16.16-beta-
|
|
27
|
-
"@abtnode/logger": "1.16.16-beta-
|
|
28
|
-
"@abtnode/models": "1.16.16-beta-
|
|
29
|
-
"@abtnode/queue": "1.16.16-beta-
|
|
30
|
-
"@abtnode/rbac": "1.16.16-beta-
|
|
31
|
-
"@abtnode/router-provider": "1.16.16-beta-
|
|
32
|
-
"@abtnode/static-server": "1.16.16-beta-
|
|
33
|
-
"@abtnode/timemachine": "1.16.16-beta-
|
|
34
|
-
"@abtnode/util": "1.16.16-beta-
|
|
35
|
-
"@arcblock/did": "1.18.
|
|
36
|
-
"@arcblock/did-auth": "1.18.
|
|
37
|
-
"@arcblock/did-ext": "^1.18.
|
|
22
|
+
"@abtnode/analytics": "1.16.16-beta-301539f6",
|
|
23
|
+
"@abtnode/auth": "1.16.16-beta-301539f6",
|
|
24
|
+
"@abtnode/certificate-manager": "1.16.16-beta-301539f6",
|
|
25
|
+
"@abtnode/constant": "1.16.16-beta-301539f6",
|
|
26
|
+
"@abtnode/cron": "1.16.16-beta-301539f6",
|
|
27
|
+
"@abtnode/logger": "1.16.16-beta-301539f6",
|
|
28
|
+
"@abtnode/models": "1.16.16-beta-301539f6",
|
|
29
|
+
"@abtnode/queue": "1.16.16-beta-301539f6",
|
|
30
|
+
"@abtnode/rbac": "1.16.16-beta-301539f6",
|
|
31
|
+
"@abtnode/router-provider": "1.16.16-beta-301539f6",
|
|
32
|
+
"@abtnode/static-server": "1.16.16-beta-301539f6",
|
|
33
|
+
"@abtnode/timemachine": "1.16.16-beta-301539f6",
|
|
34
|
+
"@abtnode/util": "1.16.16-beta-301539f6",
|
|
35
|
+
"@arcblock/did": "1.18.90",
|
|
36
|
+
"@arcblock/did-auth": "1.18.90",
|
|
37
|
+
"@arcblock/did-ext": "^1.18.90",
|
|
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.90",
|
|
40
|
+
"@arcblock/event-hub": "1.18.90",
|
|
41
|
+
"@arcblock/jwt": "^1.18.90",
|
|
42
42
|
"@arcblock/pm2-events": "^0.0.5",
|
|
43
|
-
"@arcblock/validator": "^1.18.
|
|
44
|
-
"@arcblock/vc": "1.18.
|
|
45
|
-
"@blocklet/constant": "1.16.16-beta-
|
|
46
|
-
"@blocklet/env": "1.16.16-beta-
|
|
47
|
-
"@blocklet/meta": "1.16.16-beta-
|
|
48
|
-
"@blocklet/resolver": "1.16.16-beta-
|
|
49
|
-
"@blocklet/sdk": "1.16.16-beta-
|
|
50
|
-
"@did-space/client": "^0.
|
|
43
|
+
"@arcblock/validator": "^1.18.90",
|
|
44
|
+
"@arcblock/vc": "1.18.90",
|
|
45
|
+
"@blocklet/constant": "1.16.16-beta-301539f6",
|
|
46
|
+
"@blocklet/env": "1.16.16-beta-301539f6",
|
|
47
|
+
"@blocklet/meta": "1.16.16-beta-301539f6",
|
|
48
|
+
"@blocklet/resolver": "1.16.16-beta-301539f6",
|
|
49
|
+
"@blocklet/sdk": "1.16.16-beta-301539f6",
|
|
50
|
+
"@did-space/client": "^0.3.0",
|
|
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.90",
|
|
53
|
+
"@ocap/util": "1.18.90",
|
|
54
|
+
"@ocap/wallet": "1.18.90",
|
|
55
55
|
"@slack/webhook": "^5.0.4",
|
|
56
56
|
"archiver": "^5.3.1",
|
|
57
57
|
"axios": "^0.27.2",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"jest": "^27.5.1",
|
|
101
101
|
"unzipper": "^0.10.11"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "4abf42f8b8cc859b76a85ab083414654dea10fcb"
|
|
104
104
|
}
|