@abtnode/auth 1.16.41 → 1.16.42-beta-20250403-230303-c167c6a1

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.
@@ -25,6 +25,8 @@ const { getWalletDid } = require('@blocklet/meta/lib/did-utils');
25
25
  const { Hasher } = require('@ocap/mcrypto');
26
26
  const { getSourceAppPid, getLoginProvider } = require('@blocklet/sdk/lib/util/login');
27
27
  const isArray = require('lodash/isArray');
28
+ const { getDeviceData } = require('@abtnode/util/lib/device');
29
+
28
30
  const {
29
31
  getFederatedMaster,
30
32
  shouldSyncFederated,
@@ -394,8 +396,7 @@ const createLostPassportIssueRoute = ({ node, type, authServicePrefix, createTok
394
396
  if (oldPassport.scope === 'passport' && purpose === 'login' && isFunction(createToken)) {
395
397
  if (type === TEAM_TYPES.BLOCKLET) {
396
398
  const lastLoginIp = getRequestIP(request);
397
- const walletDeviceMessageToken = request.get('wallet-device-message-token');
398
- const walletDeviceId = request.get('wallet-device-id');
399
+ const deviceData = getDeviceData({ request });
399
400
  const ua = request.get('user-agent');
400
401
  const walletOS = request.context.didwallet.os;
401
402
  const sourceAppPid = getSourceAppPid(request);
@@ -430,8 +431,7 @@ const createLostPassportIssueRoute = ({ node, type, authServicePrefix, createTok
430
431
  lastLoginIp,
431
432
  extra: {
432
433
  walletOS,
433
- walletDeviceMessageToken,
434
- walletDeviceId,
434
+ device: deviceData,
435
435
  },
436
436
  });
437
437
 
@@ -466,8 +466,7 @@ const createLostPassportIssueRoute = ({ node, type, authServicePrefix, createTok
466
466
  lastLoginIp,
467
467
  extra: {
468
468
  walletOS,
469
- walletDeviceMessageToken,
470
- walletDeviceId,
469
+ device: deviceData,
471
470
  },
472
471
  });
473
472
  });
package/lib/oauth.js CHANGED
@@ -1,15 +1,12 @@
1
1
  /* eslint-disable max-len */
2
- const pick = require('lodash/pick');
3
2
  const uniq = require('lodash/uniq');
4
3
  const { getActivePassports } = require('@abtnode/util/lib/passport');
5
- const { getAppAvatarUrl } = require('@abtnode/util/lib/user');
4
+ const { getAppAvatarUrl, getUserAvatarUrl } = require('@abtnode/util/lib/user');
6
5
  const { ROLES } = require('@abtnode/constant');
7
6
  const formatContext = require('@abtnode/util/lib/format-context');
8
7
  const { getBlockletAppIdList } = require('@blocklet/meta/lib/util');
9
8
  const { LOGIN_PROVIDER } = require('@blocklet/constant');
10
9
 
11
- const createPassportSvg = require('./util/create-passport-svg');
12
- const { getUserAvatarUrl } = require('./util/federated');
13
10
  const { getApplicationInfo } = require('./auth');
14
11
 
15
12
  const getSessionConfig = async (req) => {
@@ -56,23 +53,20 @@ function createPassportList(node, mode = 'server') {
56
53
  const { passports = [] } = user || {};
57
54
  const passportTypes = getActivePassports({ passports }, issuers).map((x) => {
58
55
  return {
59
- ...pick(x, ['id', 'name', 'title', 'role', 'scope', 'role']),
60
- display:
61
- x.scope === 'custom'
62
- ? x.display
63
- : createPassportSvg({
64
- scope: x.scope,
65
- role: x.role,
66
- title: x.scope === 'kyc' ? x.name : x.title,
67
- issuer: x.issuer.name,
68
- issuerDid: x.issuer.id,
69
- issuerAvatarUrl,
70
- ownerName: user?.fullName,
71
- ownerDid: userDid,
72
- ownerAvatarUrl,
73
- isDataUrl: true,
74
- preferredColor: passportColor || 'auto',
75
- }),
56
+ display: x.scope === 'custom' ? x.display : null,
57
+ id: x.id,
58
+ name: x.name,
59
+ scope: x.scope,
60
+ role: x.role,
61
+ title: x.scope === 'kyc' ? x.name : x.title,
62
+ issuer: x.issuer.name,
63
+ issuerDid: x.issuer.id,
64
+ issuerAvatarUrl,
65
+ ownerName: user?.fullName,
66
+ ownerDid: userDid,
67
+ ownerAvatarUrl,
68
+ isDataUrl: false,
69
+ preferredColor: passportColor || 'auto',
76
70
  };
77
71
  });
78
72
  res.send(passportTypes);
@@ -91,11 +85,22 @@ function createPassportSwitcher(node, createToken, mode = 'server') {
91
85
  // NOTICE: 这里获取的 did 是当前登录用户的永久 did,无需查询 connectedAccount
92
86
  const user = await node.getUser({ teamDid, user: { did: userDid } });
93
87
  const { passports = [] } = user || {};
88
+ const visitorId = req.get('x-blocklet-visitor-id');
94
89
 
95
90
  const passport = passportId
96
91
  ? passports.find((item) => item.id === passportId)
97
92
  : { name: 'Guest', role: 'guest', scope: 'passport' };
98
93
 
94
+ // 需要更新用户会话中记录的 passportId
95
+ await node.upsertUserSession({
96
+ teamDid,
97
+ userDid: user.did,
98
+ visitorId,
99
+ appPid: teamDid,
100
+ passportId: passport?.id ?? null,
101
+ status: 'online',
102
+ });
103
+
99
104
  await node.createAuditLog(
100
105
  {
101
106
  action: 'switchPassport',
package/lib/passkey.js CHANGED
@@ -549,8 +549,6 @@ function createPasskeyHandlers(node, mode, createToken) {
549
549
  lastLoginIp: getRequestIP(req),
550
550
  extra: {
551
551
  walletOS: 'passkey',
552
- walletDeviceMessageToken: null,
553
- walletDeviceId: null,
554
552
  },
555
553
  });
556
554
 
package/lib/server.js CHANGED
@@ -40,6 +40,8 @@ const {
40
40
  PASSPORT_ISSUE_ACTION,
41
41
  } = require('@abtnode/constant');
42
42
  const parseBooleanString = require('@abtnode/util/lib/parse-boolean-string');
43
+ const { getDeviceData } = require('@abtnode/util/lib/device');
44
+
43
45
  const {
44
46
  messages,
45
47
  getVCFromClaims,
@@ -390,7 +392,7 @@ const getAuthPrincipalForMigrateAppToV2 = (node) => async (param) => {
390
392
  }
391
393
 
392
394
  return {
393
- description: 'Please select account to continue',
395
+ description: 'Please continue with your account',
394
396
  chainInfo,
395
397
  };
396
398
  };
@@ -846,6 +848,8 @@ const createLaunchBlockletHandler =
846
848
  context || formatContext(Object.assign(req, { user: { ...pick(user, ['did', 'fullName']), role } }))
847
849
  );
848
850
 
851
+ const deviceData = getDeviceData({ req });
852
+
849
853
  const result = await node.setupAppOwner({
850
854
  node,
851
855
  sessionId,
@@ -856,9 +860,8 @@ const createLaunchBlockletHandler =
856
860
  ua: context?.ua || req?.get('user-agent'),
857
861
  lastLoginIp: context?.ip || getRequestIP(req),
858
862
  walletOS: didwallet?.os,
859
- walletDeviceMessageToken: context ? '' : req?.get('wallet-device-message-token'),
860
- walletDeviceId: context ? '' : req?.get('wallet-device-id'),
861
863
  userDid,
864
+ device: context ? deviceData : null,
862
865
  },
863
866
  });
864
867
  await updateSession({ setupToken: result.setupToken, visitorId: result.visitorId });
@@ -7,7 +7,7 @@ const { normalizePathPrefix } = require('@blocklet/meta/lib/normalize-path-prefi
7
7
  const getBlockletInfo = require('@blocklet/meta/lib/info');
8
8
  const { getSignData } = require('@blocklet/sdk/lib/util/verify-sign');
9
9
  const { SIG_VERSION } = require('@blocklet/constant');
10
- const cloneDeep = require('lodash/cloneDeep');
10
+ const cloneDeep = require('@abtnode/util/lib/deep-clone');
11
11
  const defaults = require('lodash/defaults');
12
12
 
13
13
  const request = require('./request');
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.41",
6
+ "version": "1.16.42-beta-20250403-230303-c167c6a1",
7
7
  "description": "Simple lib to manage auth in ABT Node",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -20,19 +20,19 @@
20
20
  "author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
21
21
  "license": "Apache-2.0",
22
22
  "dependencies": {
23
- "@abtnode/constant": "1.16.41",
24
- "@abtnode/logger": "1.16.41",
25
- "@abtnode/util": "1.16.41",
23
+ "@abtnode/constant": "1.16.42-beta-20250403-230303-c167c6a1",
24
+ "@abtnode/logger": "1.16.42-beta-20250403-230303-c167c6a1",
25
+ "@abtnode/util": "1.16.42-beta-20250403-230303-c167c6a1",
26
26
  "@arcblock/did": "1.19.15",
27
27
  "@arcblock/did-auth": "1.19.15",
28
- "@arcblock/jwt": "^1.19.15",
29
- "@arcblock/nft-display": "^2.12.51",
30
- "@arcblock/validator": "^1.19.15",
28
+ "@arcblock/jwt": "^1.19.17",
29
+ "@arcblock/nft-display": "^2.12.58",
30
+ "@arcblock/validator": "^1.19.17",
31
31
  "@arcblock/vc": "1.19.15",
32
- "@blocklet/constant": "1.16.41",
33
- "@blocklet/meta": "1.16.41",
34
- "@blocklet/sdk": "1.16.41",
35
- "@ocap/client": "^1.19.15",
32
+ "@blocklet/constant": "1.16.42-beta-20250403-230303-c167c6a1",
33
+ "@blocklet/meta": "1.16.42-beta-20250403-230303-c167c6a1",
34
+ "@blocklet/sdk": "1.16.42-beta-20250403-230303-c167c6a1",
35
+ "@ocap/client": "^1.19.17",
36
36
  "@ocap/mcrypto": "1.19.15",
37
37
  "@ocap/util": "1.19.15",
38
38
  "@ocap/wallet": "1.19.15",
@@ -52,5 +52,5 @@
52
52
  "devDependencies": {
53
53
  "jest": "^29.7.0"
54
54
  },
55
- "gitHead": "54be9488459ae9a3544648d495e6204f9fad493a"
55
+ "gitHead": "34d6d981bb270af1d0ca59704715bfa82949a9fe"
56
56
  }