@abtnode/core 1.16.25-next-1e779575 → 1.16.25-next-3d78a4cb

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',
@@ -30,6 +30,7 @@ const {
30
30
  DEFAULT_DID_DOMAIN,
31
31
  FEDERATED,
32
32
  CHECK_UPDATE,
33
+ SESSION_CACHE_TTL,
33
34
  } = require('@abtnode/constant');
34
35
 
35
36
  const getBlockletEngine = require('@blocklet/meta/lib/engine');
@@ -1828,7 +1829,7 @@ class DiskBlockletManager extends BaseBlockletManager {
1828
1829
  sessionConfig.cacheTtl = validateConfig.cacheTtl;
1829
1830
  } else {
1830
1831
  // NOTE: 将 cacheTtl 默认值设置为 3600s
1831
- sessionConfig.cacheTtl = 60 * 60; // seconds
1832
+ sessionConfig.cacheTtl = SESSION_CACHE_TTL; // seconds
1832
1833
  }
1833
1834
  if (validateConfig.ttl) {
1834
1835
  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-next-1e779575",
6
+ "version": "1.16.25-next-3d78a4cb",
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-next-1e779575",
23
- "@abtnode/auth": "1.16.25-next-1e779575",
24
- "@abtnode/certificate-manager": "1.16.25-next-1e779575",
25
- "@abtnode/constant": "1.16.25-next-1e779575",
26
- "@abtnode/cron": "1.16.25-next-1e779575",
27
- "@abtnode/logger": "1.16.25-next-1e779575",
28
- "@abtnode/models": "1.16.25-next-1e779575",
29
- "@abtnode/queue": "1.16.25-next-1e779575",
30
- "@abtnode/rbac": "1.16.25-next-1e779575",
31
- "@abtnode/router-provider": "1.16.25-next-1e779575",
32
- "@abtnode/static-server": "1.16.25-next-1e779575",
33
- "@abtnode/timemachine": "1.16.25-next-1e779575",
34
- "@abtnode/util": "1.16.25-next-1e779575",
22
+ "@abtnode/analytics": "1.16.25-next-3d78a4cb",
23
+ "@abtnode/auth": "1.16.25-next-3d78a4cb",
24
+ "@abtnode/certificate-manager": "1.16.25-next-3d78a4cb",
25
+ "@abtnode/constant": "1.16.25-next-3d78a4cb",
26
+ "@abtnode/cron": "1.16.25-next-3d78a4cb",
27
+ "@abtnode/logger": "1.16.25-next-3d78a4cb",
28
+ "@abtnode/models": "1.16.25-next-3d78a4cb",
29
+ "@abtnode/queue": "1.16.25-next-3d78a4cb",
30
+ "@abtnode/rbac": "1.16.25-next-3d78a4cb",
31
+ "@abtnode/router-provider": "1.16.25-next-3d78a4cb",
32
+ "@abtnode/static-server": "1.16.25-next-3d78a4cb",
33
+ "@abtnode/timemachine": "1.16.25-next-3d78a4cb",
34
+ "@abtnode/util": "1.16.25-next-3d78a4cb",
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-next-1e779575",
46
- "@blocklet/env": "1.16.25-next-1e779575",
47
- "@blocklet/meta": "1.16.25-next-1e779575",
48
- "@blocklet/resolver": "1.16.25-next-1e779575",
49
- "@blocklet/sdk": "1.16.25-next-1e779575",
50
- "@did-space/client": "^0.3.69",
45
+ "@blocklet/constant": "1.16.25-next-3d78a4cb",
46
+ "@blocklet/env": "1.16.25-next-3d78a4cb",
47
+ "@blocklet/meta": "1.16.25-next-3d78a4cb",
48
+ "@blocklet/resolver": "1.16.25-next-3d78a4cb",
49
+ "@blocklet/sdk": "1.16.25-next-3d78a4cb",
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": "a850cb40b003798c7bf6dbbf7546e2feabd85243"
105
+ "gitHead": "26b43891e46756b142bcd6b62c57357c7c23cf2f"
106
106
  }