@abtnode/core 1.16.30-beta-5d9c2c41 → 1.16.30-beta-e7a90fb2
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
CHANGED
|
@@ -465,14 +465,23 @@ class TeamAPI extends EventEmitter {
|
|
|
465
465
|
throw new Error('Cannot update owner\'s approval'); // prettier-ignore
|
|
466
466
|
}
|
|
467
467
|
|
|
468
|
-
const
|
|
468
|
+
const changeData = pick(user, ['did', 'approved']);
|
|
469
|
+
|
|
470
|
+
const result = await state.updateApproved(changeData);
|
|
469
471
|
|
|
470
472
|
logger.info('user approval updated successfully', { teamDid, userDid: user.did, approved: user.approved });
|
|
471
473
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
+
if (changeData?.approved === false) {
|
|
475
|
+
// 需要注销指定 userDid 在当前 member 和 master 中的所有 userSession
|
|
476
|
+
await this.logoutUser({
|
|
477
|
+
teamDid,
|
|
478
|
+
userDid: user.did,
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
this.emit(TeamEvents.userUpdated, { teamDid, user: result });
|
|
482
|
+
this.emit(TeamEvents.userPermissionUpdated, { teamDid, user: result });
|
|
474
483
|
|
|
475
|
-
return
|
|
484
|
+
return result;
|
|
476
485
|
}
|
|
477
486
|
|
|
478
487
|
async issuePassportToUser({ teamDid, userDid, role: roleName, notify = true }, context = {}) {
|
|
@@ -1479,7 +1488,17 @@ class TeamAPI extends EventEmitter {
|
|
|
1479
1488
|
include: {
|
|
1480
1489
|
model: userState.model,
|
|
1481
1490
|
as: 'user',
|
|
1482
|
-
attributes: [
|
|
1491
|
+
attributes: [
|
|
1492
|
+
'did',
|
|
1493
|
+
'pk',
|
|
1494
|
+
'sourceProvider',
|
|
1495
|
+
'fullName',
|
|
1496
|
+
'email',
|
|
1497
|
+
'avatar',
|
|
1498
|
+
'remark',
|
|
1499
|
+
'sourceAppPid',
|
|
1500
|
+
'approved',
|
|
1501
|
+
],
|
|
1483
1502
|
},
|
|
1484
1503
|
});
|
|
1485
1504
|
return userSessions.map((x) => x.toJSON());
|
|
@@ -1524,7 +1543,7 @@ class TeamAPI extends EventEmitter {
|
|
|
1524
1543
|
|
|
1525
1544
|
async upsertUserSession({ teamDid, appPid, userDid, visitorId, ua, lastLoginIp, passportId, status, extra }) {
|
|
1526
1545
|
if (!userDid) {
|
|
1527
|
-
throw new Error('userDid
|
|
1546
|
+
throw new Error('userDid is required');
|
|
1528
1547
|
}
|
|
1529
1548
|
|
|
1530
1549
|
const state = await this.getUserSessionState(teamDid);
|
|
@@ -1663,9 +1682,26 @@ class TeamAPI extends EventEmitter {
|
|
|
1663
1682
|
}
|
|
1664
1683
|
|
|
1665
1684
|
async logoutUser({ teamDid, userDid, visitorId, appPid }) {
|
|
1666
|
-
|
|
1667
|
-
|
|
1685
|
+
if (!userDid) {
|
|
1686
|
+
throw new Error('userDid is required');
|
|
1687
|
+
}
|
|
1688
|
+
if (!teamDid) {
|
|
1689
|
+
throw new Error('teamDid is required');
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1668
1692
|
const nodeInfo = await this.node.read();
|
|
1693
|
+
if (nodeInfo.did === teamDid) {
|
|
1694
|
+
return 0;
|
|
1695
|
+
}
|
|
1696
|
+
const state = await this.getUserSessionState(teamDid);
|
|
1697
|
+
const userSessionParams = { userDid };
|
|
1698
|
+
if (visitorId) {
|
|
1699
|
+
userSessionParams.visitorId = visitorId;
|
|
1700
|
+
}
|
|
1701
|
+
if (appPid) {
|
|
1702
|
+
userSessionParams.appPid = appPid;
|
|
1703
|
+
}
|
|
1704
|
+
const result = await state.remove(userSessionParams);
|
|
1669
1705
|
const blocklet = await getBlocklet({ did: teamDid, states: this.states, dataDirs: this.dataDirs });
|
|
1670
1706
|
const { permanentWallet } = getBlockletInfo(blocklet, nodeInfo.sk);
|
|
1671
1707
|
const federated = defaults(cloneDeep(blocklet.settings.federated || {}), {
|
|
@@ -1677,6 +1713,7 @@ class TeamAPI extends EventEmitter {
|
|
|
1677
1713
|
callFederated({
|
|
1678
1714
|
action: 'sync',
|
|
1679
1715
|
permanentWallet,
|
|
1716
|
+
// FIXME: @zhanghan 是否还需要通知其他 Member 站点,执行退出登录的操作
|
|
1680
1717
|
site: masterSite,
|
|
1681
1718
|
data: {
|
|
1682
1719
|
userSessions: [
|
|
@@ -1684,13 +1721,14 @@ class TeamAPI extends EventEmitter {
|
|
|
1684
1721
|
action: 'logout',
|
|
1685
1722
|
userDid,
|
|
1686
1723
|
visitorId,
|
|
1687
|
-
|
|
1724
|
+
// HACK: 如果未传入 appPid,代表要注销当前用户在 master 中所有登录状态,所以传入 undefined;否则就只注销 master 中记录的当前 member 的登录状态
|
|
1725
|
+
appPid: appPid ? teamDid : undefined,
|
|
1688
1726
|
},
|
|
1689
1727
|
],
|
|
1690
1728
|
},
|
|
1691
1729
|
});
|
|
1692
1730
|
}
|
|
1693
|
-
return
|
|
1731
|
+
return result;
|
|
1694
1732
|
}
|
|
1695
1733
|
}
|
|
1696
1734
|
|
|
@@ -14,7 +14,8 @@ const timeout = process.env.NODE_ENV === 'test' ? 500 : 5000;
|
|
|
14
14
|
// FIXME: check connected by wellknown endpoint
|
|
15
15
|
const checkConnected = async ({ ip, info }) => {
|
|
16
16
|
const { adminPath = WELLKNOWN_SERVER_ADMIN_PATH } = info.routing || {};
|
|
17
|
-
|
|
17
|
+
// dev 模式下,检查的地址不一样
|
|
18
|
+
const origin = process.env.NODE_ENV === 'development' ? `http://${ip}:3000` : `https://${getNodeDomain(ip)}`;
|
|
18
19
|
const endpoint = joinURL(origin, adminPath);
|
|
19
20
|
await axios.get(endpoint, { timeout });
|
|
20
21
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const request = require('./request');
|
|
2
2
|
const { filterDuplicateComponents, parseComponents } = require('./blocklet');
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -6,7 +6,7 @@ const { filterDuplicateComponents, parseComponents } = require('./blocklet');
|
|
|
6
6
|
* @returns {Promise<import('@abtnode/types').TComponentState[]>}
|
|
7
7
|
*/
|
|
8
8
|
async function getDynamicComponents({ url }) {
|
|
9
|
-
const rawMeta = await
|
|
9
|
+
const rawMeta = await request.get(url).then((res) => res.data);
|
|
10
10
|
const { dynamicComponents } = await parseComponents({ meta: rawMeta });
|
|
11
11
|
|
|
12
12
|
const components = filterDuplicateComponents(dynamicComponents);
|
package/lib/util/launcher.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
+
const os = require('os');
|
|
2
3
|
const fs = require('fs-extra');
|
|
3
4
|
const { joinURL } = require('ufo');
|
|
4
5
|
const dayjs = require('@abtnode/util/lib/dayjs');
|
|
5
6
|
const pick = require('lodash/pick');
|
|
6
7
|
const uniq = require('lodash/uniq');
|
|
8
|
+
const trim = require('lodash/trim');
|
|
7
9
|
const isEmpty = require('lodash/isEmpty');
|
|
8
10
|
const {
|
|
9
11
|
getUserAvatarUrl,
|
|
@@ -415,7 +417,25 @@ const getLaunchSessionStatus = async (blockletDid, controller) => {
|
|
|
415
417
|
return launcherSession.status;
|
|
416
418
|
};
|
|
417
419
|
|
|
420
|
+
const isBlockletProtected = (blockletDid) => {
|
|
421
|
+
if (!process.env.ABT_NODE_DATA_DIR) {
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
const configFile = path.join(process.env.ABT_NODE_DATA_DIR, '.protected-serverless-apps');
|
|
426
|
+
if (fs.existsSync(configFile)) {
|
|
427
|
+
const protectedAppIds = fs.readFileSync(configFile, 'utf8').split(os.EOL).map(trim).filter(Boolean);
|
|
428
|
+
return protectedAppIds.includes(blockletDid);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
return false;
|
|
432
|
+
};
|
|
433
|
+
|
|
418
434
|
const isBlockletExpired = async (blockletDid, controller) => {
|
|
435
|
+
if (isBlockletProtected(blockletDid)) {
|
|
436
|
+
logger.info('skip expire protected serverless app', { blockletDid, controller });
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
419
439
|
const status = await getLaunchSessionStatus(blockletDid, controller);
|
|
420
440
|
return [LAUNCH_SESSION_STATUS.overdue, LAUNCH_SESSION_STATUS.canceled, LAUNCH_SESSION_STATUS.terminated].includes(
|
|
421
441
|
status
|
|
@@ -425,6 +445,10 @@ const isBlockletExpired = async (blockletDid, controller) => {
|
|
|
425
445
|
const isLaunchSessionTerminated = (session) => session.status === LAUNCH_SESSION_STATUS.terminated;
|
|
426
446
|
|
|
427
447
|
const isBlockletTerminated = async (blockletDid, controller) => {
|
|
448
|
+
if (isBlockletProtected(blockletDid)) {
|
|
449
|
+
logger.info('skip terminate protected serverless app', { blockletDid, controller });
|
|
450
|
+
return false;
|
|
451
|
+
}
|
|
428
452
|
const status = await getLaunchSessionStatus(blockletDid, controller);
|
|
429
453
|
return status === LAUNCH_SESSION_STATUS.terminated;
|
|
430
454
|
};
|
package/lib/util/store.js
CHANGED
|
@@ -49,11 +49,8 @@ const fixAndVerifyMetaFromStore = (meta) => {
|
|
|
49
49
|
// Note: registry should contain the store endpoint
|
|
50
50
|
const getStoreMeta = async (registry) => {
|
|
51
51
|
try {
|
|
52
|
-
const url = withQuery(joinURL(registry, BLOCKLET_STORE_META_PATH), {
|
|
53
|
-
__t__: Date.now(),
|
|
54
|
-
});
|
|
52
|
+
const url = withQuery(joinURL(registry, BLOCKLET_STORE_META_PATH), { t: Date.now() });
|
|
55
53
|
const { data } = await request.get(url);
|
|
56
|
-
|
|
57
54
|
if (!data) {
|
|
58
55
|
return {};
|
|
59
56
|
}
|
|
@@ -78,6 +75,7 @@ const getStoreMeta = async (registry) => {
|
|
|
78
75
|
|
|
79
76
|
return result;
|
|
80
77
|
} catch (err) {
|
|
78
|
+
logger.error('Failed to getStoreMeta', err);
|
|
81
79
|
throw new Error(`Can not get meta info for store [${registry}]: ${err.message}`);
|
|
82
80
|
}
|
|
83
81
|
};
|
|
@@ -88,12 +86,11 @@ async function getStoreUrl(url) {
|
|
|
88
86
|
try {
|
|
89
87
|
const { data: meta } = await request.get(joinURL(origin, '__blocklet__.js?type=json&nocache=1'));
|
|
90
88
|
const component = meta.componentMountPoints?.find((item) => item.did === BLOCKLET_STORE_DID);
|
|
91
|
-
|
|
92
89
|
if (component) {
|
|
93
90
|
mountPoint = component.mountPoint;
|
|
94
91
|
}
|
|
95
|
-
} catch {
|
|
96
|
-
|
|
92
|
+
} catch (err) {
|
|
93
|
+
logger.error('Failed to getStoreUrl', err);
|
|
97
94
|
}
|
|
98
95
|
|
|
99
96
|
return joinURL(origin, mountPoint);
|
|
@@ -115,8 +112,8 @@ async function getStoreInfo(url) {
|
|
|
115
112
|
registryMeta: meta,
|
|
116
113
|
};
|
|
117
114
|
}
|
|
118
|
-
} catch {
|
|
119
|
-
|
|
115
|
+
} catch (err) {
|
|
116
|
+
logger.error('Failed to getStoreInfo', err);
|
|
120
117
|
}
|
|
121
118
|
}
|
|
122
119
|
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.30-beta-
|
|
6
|
+
"version": "1.16.30-beta-e7a90fb2",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,40 +19,40 @@
|
|
|
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.30-beta-
|
|
23
|
-
"@abtnode/auth": "1.16.30-beta-
|
|
24
|
-
"@abtnode/certificate-manager": "1.16.30-beta-
|
|
25
|
-
"@abtnode/constant": "1.16.30-beta-
|
|
26
|
-
"@abtnode/cron": "1.16.30-beta-
|
|
27
|
-
"@abtnode/logger": "1.16.30-beta-
|
|
28
|
-
"@abtnode/models": "1.16.30-beta-
|
|
29
|
-
"@abtnode/queue": "1.16.30-beta-
|
|
30
|
-
"@abtnode/rbac": "1.16.30-beta-
|
|
31
|
-
"@abtnode/router-provider": "1.16.30-beta-
|
|
32
|
-
"@abtnode/static-server": "1.16.30-beta-
|
|
33
|
-
"@abtnode/timemachine": "1.16.30-beta-
|
|
34
|
-
"@abtnode/util": "1.16.30-beta-
|
|
35
|
-
"@arcblock/did": "1.18.
|
|
36
|
-
"@arcblock/did-auth": "1.18.
|
|
37
|
-
"@arcblock/did-ext": "^1.18.
|
|
22
|
+
"@abtnode/analytics": "1.16.30-beta-e7a90fb2",
|
|
23
|
+
"@abtnode/auth": "1.16.30-beta-e7a90fb2",
|
|
24
|
+
"@abtnode/certificate-manager": "1.16.30-beta-e7a90fb2",
|
|
25
|
+
"@abtnode/constant": "1.16.30-beta-e7a90fb2",
|
|
26
|
+
"@abtnode/cron": "1.16.30-beta-e7a90fb2",
|
|
27
|
+
"@abtnode/logger": "1.16.30-beta-e7a90fb2",
|
|
28
|
+
"@abtnode/models": "1.16.30-beta-e7a90fb2",
|
|
29
|
+
"@abtnode/queue": "1.16.30-beta-e7a90fb2",
|
|
30
|
+
"@abtnode/rbac": "1.16.30-beta-e7a90fb2",
|
|
31
|
+
"@abtnode/router-provider": "1.16.30-beta-e7a90fb2",
|
|
32
|
+
"@abtnode/static-server": "1.16.30-beta-e7a90fb2",
|
|
33
|
+
"@abtnode/timemachine": "1.16.30-beta-e7a90fb2",
|
|
34
|
+
"@abtnode/util": "1.16.30-beta-e7a90fb2",
|
|
35
|
+
"@arcblock/did": "1.18.132",
|
|
36
|
+
"@arcblock/did-auth": "1.18.132",
|
|
37
|
+
"@arcblock/did-ext": "^1.18.132",
|
|
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.132",
|
|
40
|
+
"@arcblock/event-hub": "1.18.132",
|
|
41
|
+
"@arcblock/jwt": "^1.18.132",
|
|
42
42
|
"@arcblock/pm2-events": "^0.0.5",
|
|
43
|
-
"@arcblock/validator": "^1.18.
|
|
44
|
-
"@arcblock/vc": "1.18.
|
|
45
|
-
"@blocklet/constant": "1.16.30-beta-
|
|
46
|
-
"@blocklet/env": "1.16.30-beta-
|
|
47
|
-
"@blocklet/meta": "1.16.30-beta-
|
|
48
|
-
"@blocklet/resolver": "1.16.30-beta-
|
|
49
|
-
"@blocklet/sdk": "1.16.30-beta-
|
|
50
|
-
"@blocklet/store": "1.16.30-beta-
|
|
51
|
-
"@did-space/client": "^0.5.
|
|
43
|
+
"@arcblock/validator": "^1.18.132",
|
|
44
|
+
"@arcblock/vc": "1.18.132",
|
|
45
|
+
"@blocklet/constant": "1.16.30-beta-e7a90fb2",
|
|
46
|
+
"@blocklet/env": "1.16.30-beta-e7a90fb2",
|
|
47
|
+
"@blocklet/meta": "1.16.30-beta-e7a90fb2",
|
|
48
|
+
"@blocklet/resolver": "1.16.30-beta-e7a90fb2",
|
|
49
|
+
"@blocklet/sdk": "1.16.30-beta-e7a90fb2",
|
|
50
|
+
"@blocklet/store": "1.16.30-beta-e7a90fb2",
|
|
51
|
+
"@did-space/client": "^0.5.28",
|
|
52
52
|
"@fidm/x509": "^1.2.1",
|
|
53
|
-
"@ocap/mcrypto": "1.18.
|
|
54
|
-
"@ocap/util": "1.18.
|
|
55
|
-
"@ocap/wallet": "1.18.
|
|
53
|
+
"@ocap/mcrypto": "1.18.132",
|
|
54
|
+
"@ocap/util": "1.18.132",
|
|
55
|
+
"@ocap/wallet": "1.18.132",
|
|
56
56
|
"@slack/webhook": "^5.0.4",
|
|
57
57
|
"archiver": "^7.0.1",
|
|
58
58
|
"axios": "^1.7.2",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"jest": "^29.7.0",
|
|
104
104
|
"unzipper": "^0.10.11"
|
|
105
105
|
},
|
|
106
|
-
"gitHead": "
|
|
106
|
+
"gitHead": "c97ba97d694f553afc9f5336c9f3ddfae73cf955"
|
|
107
107
|
}
|