@abtnode/core 1.16.25-beta-cfcab4af → 1.16.25-beta-023ec101

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
@@ -15,6 +15,7 @@ const {
15
15
  STORE_DETAIL_PAGE_PATH_PREFIX,
16
16
  MAIN_CHAIN_ENDPOINT,
17
17
  USER_AVATAR_URL_PREFIX,
18
+ SESSION_TTL,
18
19
  } = require('@abtnode/constant');
19
20
  const { isValid: isValidDid } = require('@arcblock/did');
20
21
  const { BlockletEvents, TeamEvents } = require('@blocklet/constant');
@@ -266,12 +267,18 @@ class TeamAPI extends EventEmitter {
266
267
  list = doc.list;
267
268
  paging = doc.paging;
268
269
  }
270
+ const now = Date.now();
271
+ let sessionTtl = SESSION_TTL;
272
+ if (teamDid !== nodeInfo.did) {
273
+ const blocklet = await getBlocklet({ did: teamDid, states: this.states, dataDirs: this.dataDirs });
274
+ sessionTtl = blocklet.settings?.session?.ttl || SESSION_TTL;
275
+ }
269
276
 
270
277
  return {
271
278
  // FIXME: @zhanghan 这里做字段过滤的目的是?gql 本身已经对字段做了过滤了
272
279
  users: list.map(
273
- (d) =>
274
- pick(d, [
280
+ (d) => {
281
+ const pickData = pick(d, [
275
282
  'did',
276
283
  'pk',
277
284
  'role',
@@ -293,7 +300,16 @@ class TeamAPI extends EventEmitter {
293
300
  'sourceProvider',
294
301
  'sourceAppPid',
295
302
  'connectedAccounts',
296
- ])
303
+ ]);
304
+ if (pickData?.userSessions) {
305
+ pickData.userSessions = pickData.userSessions.map((x) => {
306
+ const status = now - new Date(x.updatedAt).getTime() > sessionTtl * 1000 ? 'expired' : x.status;
307
+ return { ...x, status };
308
+ });
309
+ }
310
+ return pickData;
311
+ }
312
+
297
313
  // eslint-disable-next-line function-paren-newline
298
314
  ),
299
315
  paging,
@@ -1403,7 +1419,19 @@ class TeamAPI extends EventEmitter {
1403
1419
 
1404
1420
  const userSessions = await state.model.findAll({
1405
1421
  where,
1406
- attributes: ['id', 'appPid', 'userDid', 'visitorId', 'passportId', 'updatedAt', 'extra', 'ua', 'lastLoginIp'],
1422
+ attributes: [
1423
+ 'id',
1424
+ 'appPid',
1425
+ 'userDid',
1426
+ 'visitorId',
1427
+ 'passportId',
1428
+ 'createdAt',
1429
+ 'updatedAt',
1430
+ 'extra',
1431
+ 'ua',
1432
+ 'lastLoginIp',
1433
+ 'status',
1434
+ ],
1407
1435
  include: {
1408
1436
  model: userState.model,
1409
1437
  as: 'user',
@@ -31,6 +31,7 @@ const {
31
31
  DEFAULT_DID_DOMAIN,
32
32
  FEDERATED,
33
33
  CHECK_UPDATE,
34
+ SESSION_CACHE_TTL,
34
35
  } = require('@abtnode/constant');
35
36
 
36
37
  const getBlockletEngine = require('@blocklet/meta/lib/engine');
@@ -1807,7 +1808,7 @@ class DiskBlockletManager extends BaseBlockletManager {
1807
1808
  sessionConfig.cacheTtl = validateConfig.cacheTtl;
1808
1809
  } else {
1809
1810
  // NOTE: 将 cacheTtl 默认值设置为 3600s
1810
- sessionConfig.cacheTtl = 60 * 60; // seconds
1811
+ sessionConfig.cacheTtl = SESSION_CACHE_TTL; // seconds
1811
1812
  }
1812
1813
  if (validateConfig.ttl) {
1813
1814
  sessionConfig.ttl = validateConfig.ttl;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.25-beta-cfcab4af",
6
+ "version": "1.16.25-beta-023ec101",
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.25-beta-cfcab4af",
23
- "@abtnode/auth": "1.16.25-beta-cfcab4af",
24
- "@abtnode/certificate-manager": "1.16.25-beta-cfcab4af",
25
- "@abtnode/constant": "1.16.25-beta-cfcab4af",
26
- "@abtnode/cron": "1.16.25-beta-cfcab4af",
27
- "@abtnode/logger": "1.16.25-beta-cfcab4af",
28
- "@abtnode/models": "1.16.25-beta-cfcab4af",
29
- "@abtnode/queue": "1.16.25-beta-cfcab4af",
30
- "@abtnode/rbac": "1.16.25-beta-cfcab4af",
31
- "@abtnode/router-provider": "1.16.25-beta-cfcab4af",
32
- "@abtnode/static-server": "1.16.25-beta-cfcab4af",
33
- "@abtnode/timemachine": "1.16.25-beta-cfcab4af",
34
- "@abtnode/util": "1.16.25-beta-cfcab4af",
22
+ "@abtnode/analytics": "1.16.25-beta-023ec101",
23
+ "@abtnode/auth": "1.16.25-beta-023ec101",
24
+ "@abtnode/certificate-manager": "1.16.25-beta-023ec101",
25
+ "@abtnode/constant": "1.16.25-beta-023ec101",
26
+ "@abtnode/cron": "1.16.25-beta-023ec101",
27
+ "@abtnode/logger": "1.16.25-beta-023ec101",
28
+ "@abtnode/models": "1.16.25-beta-023ec101",
29
+ "@abtnode/queue": "1.16.25-beta-023ec101",
30
+ "@abtnode/rbac": "1.16.25-beta-023ec101",
31
+ "@abtnode/router-provider": "1.16.25-beta-023ec101",
32
+ "@abtnode/static-server": "1.16.25-beta-023ec101",
33
+ "@abtnode/timemachine": "1.16.25-beta-023ec101",
34
+ "@abtnode/util": "1.16.25-beta-023ec101",
35
35
  "@arcblock/did": "1.18.113",
36
36
  "@arcblock/did-auth": "1.18.113",
37
37
  "@arcblock/did-ext": "^1.18.113",
@@ -42,12 +42,12 @@
42
42
  "@arcblock/pm2-events": "^0.0.5",
43
43
  "@arcblock/validator": "^1.18.113",
44
44
  "@arcblock/vc": "1.18.113",
45
- "@blocklet/constant": "1.16.25-beta-cfcab4af",
46
- "@blocklet/env": "1.16.25-beta-cfcab4af",
47
- "@blocklet/meta": "1.16.25-beta-cfcab4af",
48
- "@blocklet/resolver": "1.16.25-beta-cfcab4af",
49
- "@blocklet/sdk": "1.16.25-beta-cfcab4af",
50
- "@did-space/client": "^0.3.70",
45
+ "@blocklet/constant": "1.16.25-beta-023ec101",
46
+ "@blocklet/env": "1.16.25-beta-023ec101",
47
+ "@blocklet/meta": "1.16.25-beta-023ec101",
48
+ "@blocklet/resolver": "1.16.25-beta-023ec101",
49
+ "@blocklet/sdk": "1.16.25-beta-023ec101",
50
+ "@did-space/client": "^0.3.71",
51
51
  "@fidm/x509": "^1.2.1",
52
52
  "@ocap/mcrypto": "1.18.113",
53
53
  "@ocap/util": "1.18.113",
@@ -102,5 +102,5 @@
102
102
  "jest": "^29.7.0",
103
103
  "unzipper": "^0.10.11"
104
104
  },
105
- "gitHead": "061cbc96f4e918e2186f3834960c0c2e14de9317"
105
+ "gitHead": "7e534f8dd1335f42897bf467e261f02bc7a59be0"
106
106
  }