@abtnode/core 1.16.16-beta-740ea329 → 1.16.16-beta-d6c5ed65
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 +56 -5
- package/lib/index.js +1 -0
- package/lib/states/user.js +11 -1
- package/lib/validators/user.js +1 -0
- package/package.json +21 -21
package/lib/api/team.js
CHANGED
|
@@ -3890,28 +3890,79 @@ class FederatedBlockletManager extends DiskBlockletManager {
|
|
|
3890
3890
|
logger.error('Failed to post audit res to member-site', { error, did, url: postUrl });
|
|
3891
3891
|
throw error;
|
|
3892
3892
|
}
|
|
3893
|
+
await this.syncFederated({
|
|
3894
|
+
did,
|
|
3895
|
+
data: {
|
|
3896
|
+
sites: federated.sites,
|
|
3897
|
+
},
|
|
3898
|
+
});
|
|
3899
|
+
return newState;
|
|
3900
|
+
}
|
|
3901
|
+
|
|
3902
|
+
async syncFederated({ did, data = {} } = {}) {
|
|
3903
|
+
const blocklet = await this.getBlocklet(did);
|
|
3904
|
+
|
|
3905
|
+
const federated = defaults(cloneDeep(blocklet.settings.federated || {}), {
|
|
3906
|
+
config: {},
|
|
3907
|
+
sites: [],
|
|
3908
|
+
});
|
|
3909
|
+
|
|
3910
|
+
const safeData = {};
|
|
3911
|
+
const { users, sites } = data;
|
|
3912
|
+
if (users && Array.isArray(users)) {
|
|
3913
|
+
safeData.users = users.map((item) =>
|
|
3914
|
+
pick(item, ['did', 'pk', 'fullName', 'avatar', 'email', 'connectedAccount', 'action'])
|
|
3915
|
+
);
|
|
3916
|
+
}
|
|
3917
|
+
|
|
3918
|
+
if (sites && Array.isArray(sites)) {
|
|
3919
|
+
safeData.sites = sites.map((item) =>
|
|
3920
|
+
pick(item, [
|
|
3921
|
+
'appId',
|
|
3922
|
+
'appPid',
|
|
3923
|
+
'aliasDid',
|
|
3924
|
+
'appName',
|
|
3925
|
+
'appDescription',
|
|
3926
|
+
'appUrl',
|
|
3927
|
+
'aliasDomain',
|
|
3928
|
+
'appLogo',
|
|
3929
|
+
'appLogoRect',
|
|
3930
|
+
'appliedAt',
|
|
3931
|
+
'did',
|
|
3932
|
+
'pk',
|
|
3933
|
+
'serverId',
|
|
3934
|
+
'serverVersion',
|
|
3935
|
+
'version',
|
|
3936
|
+
'isMaster',
|
|
3937
|
+
'status',
|
|
3938
|
+
])
|
|
3939
|
+
);
|
|
3940
|
+
}
|
|
3941
|
+
|
|
3942
|
+
const nodeInfo = await states.node.read();
|
|
3943
|
+
const { permanentWallet } = getBlockletInfo(blocklet, nodeInfo.sk);
|
|
3944
|
+
|
|
3893
3945
|
const waitingList = federated.sites
|
|
3894
3946
|
.filter((item) => item.appId !== federated.config.appId)
|
|
3895
3947
|
.map((item) => {
|
|
3896
3948
|
return limitSync(async () => {
|
|
3897
|
-
const url = `${item.appUrl}
|
|
3949
|
+
const url = `${item.appUrl}${WELLKNOWN_SERVICE_PATH_PREFIX}/api/federated/sync`;
|
|
3898
3950
|
try {
|
|
3899
|
-
// NOTICE:
|
|
3951
|
+
// NOTICE: 即使通知某个站点失败了,也不影响其他站点接收同步结果
|
|
3900
3952
|
await pRetry(
|
|
3901
3953
|
() =>
|
|
3902
3954
|
request.post(url, {
|
|
3903
3955
|
signer: permanentWallet.address,
|
|
3904
|
-
data: signV2(permanentWallet.address, permanentWallet.secretKey,
|
|
3956
|
+
data: signV2(permanentWallet.address, permanentWallet.secretKey, safeData),
|
|
3905
3957
|
}),
|
|
3906
3958
|
{ retries: 3 }
|
|
3907
3959
|
);
|
|
3908
3960
|
} catch (error) {
|
|
3909
|
-
logger.warn('Failed to sync federated sites', { error, did, url, action: '
|
|
3961
|
+
logger.warn('Failed to sync federated sites', { error, did, url, action: 'sync' });
|
|
3910
3962
|
}
|
|
3911
3963
|
});
|
|
3912
3964
|
});
|
|
3913
3965
|
await Promise.all(waitingList);
|
|
3914
|
-
return newState;
|
|
3915
3966
|
}
|
|
3916
3967
|
}
|
|
3917
3968
|
|
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-d6c5ed65",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,19 +19,19 @@
|
|
|
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-
|
|
22
|
+
"@abtnode/analytics": "1.16.16-beta-d6c5ed65",
|
|
23
|
+
"@abtnode/auth": "1.16.16-beta-d6c5ed65",
|
|
24
|
+
"@abtnode/certificate-manager": "1.16.16-beta-d6c5ed65",
|
|
25
|
+
"@abtnode/constant": "1.16.16-beta-d6c5ed65",
|
|
26
|
+
"@abtnode/cron": "1.16.16-beta-d6c5ed65",
|
|
27
|
+
"@abtnode/logger": "1.16.16-beta-d6c5ed65",
|
|
28
|
+
"@abtnode/models": "1.16.16-beta-d6c5ed65",
|
|
29
|
+
"@abtnode/queue": "1.16.16-beta-d6c5ed65",
|
|
30
|
+
"@abtnode/rbac": "1.16.16-beta-d6c5ed65",
|
|
31
|
+
"@abtnode/router-provider": "1.16.16-beta-d6c5ed65",
|
|
32
|
+
"@abtnode/static-server": "1.16.16-beta-d6c5ed65",
|
|
33
|
+
"@abtnode/timemachine": "1.16.16-beta-d6c5ed65",
|
|
34
|
+
"@abtnode/util": "1.16.16-beta-d6c5ed65",
|
|
35
35
|
"@arcblock/did": "1.18.89",
|
|
36
36
|
"@arcblock/did-auth": "1.18.89",
|
|
37
37
|
"@arcblock/did-ext": "^1.18.89",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"@arcblock/pm2-events": "^0.0.5",
|
|
43
43
|
"@arcblock/validator": "^1.18.89",
|
|
44
44
|
"@arcblock/vc": "1.18.89",
|
|
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.2.
|
|
45
|
+
"@blocklet/constant": "1.16.16-beta-d6c5ed65",
|
|
46
|
+
"@blocklet/env": "1.16.16-beta-d6c5ed65",
|
|
47
|
+
"@blocklet/meta": "1.16.16-beta-d6c5ed65",
|
|
48
|
+
"@blocklet/resolver": "1.16.16-beta-d6c5ed65",
|
|
49
|
+
"@blocklet/sdk": "1.16.16-beta-d6c5ed65",
|
|
50
|
+
"@did-space/client": "^0.2.171",
|
|
51
51
|
"@fidm/x509": "^1.2.1",
|
|
52
52
|
"@ocap/mcrypto": "1.18.89",
|
|
53
53
|
"@ocap/util": "1.18.89",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"jest": "^27.5.1",
|
|
101
101
|
"unzipper": "^0.10.11"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "16f5632a7b86283381fa49acc4d2553c65cd2aa3"
|
|
104
104
|
}
|