@abtnode/auth 1.16.47-beta-20250805-140707-3a4df7fd → 1.16.47-beta-20250807-110715-19ad6b43
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/passkey.js +1 -1
- package/lib/util/bind-wallet.js +17 -11
- package/package.json +20 -20
package/lib/passkey.js
CHANGED
|
@@ -6,7 +6,7 @@ const { ROLES, PASSPORT_STATUS } = require('@abtnode/constant');
|
|
|
6
6
|
const { LOGIN_PROVIDER } = require('@blocklet/constant');
|
|
7
7
|
const { WELLKNOWN_SERVICE_PATH_PREFIX, SECURITY_RULE_DEFAULT_ID } = require('@abtnode/constant');
|
|
8
8
|
const { fromBase64, toBase64, toBuffer, toUint8Array, toHex } = require('@ocap/util');
|
|
9
|
-
const { prepareBaseUrl } = require('@arcblock/did-
|
|
9
|
+
const { prepareBaseUrl } = require('@arcblock/did-connect-js/lib/handlers/util');
|
|
10
10
|
const logger = require('@abtnode/logger')('@abtnode/auth:passkey');
|
|
11
11
|
const formatContext = require('@abtnode/util/lib/format-context');
|
|
12
12
|
const getRequestIP = require('@abtnode/util/lib/get-request-ip');
|
package/lib/util/bind-wallet.js
CHANGED
|
@@ -25,7 +25,19 @@ module.exports = {
|
|
|
25
25
|
supervised: true,
|
|
26
26
|
};
|
|
27
27
|
},
|
|
28
|
-
onConnect: async ({
|
|
28
|
+
onConnect: async ({
|
|
29
|
+
node,
|
|
30
|
+
request,
|
|
31
|
+
userDid,
|
|
32
|
+
locale,
|
|
33
|
+
previousUserDid, // FIXME: @zhanghan 这个数据目前只能从前端传递,可能会存在篡改的风险
|
|
34
|
+
isService = true,
|
|
35
|
+
}) => {
|
|
36
|
+
// 检查逻辑
|
|
37
|
+
// 1. 如果查询的账户,没有对应的 user 信息,则提示 notFound
|
|
38
|
+
// 2. 如果查询的账户已存在,并且已绑定 wallet 账户,则提示 alreadyBindWallet
|
|
39
|
+
// 3. 如果 wallet 账户已存在(主账户),则提示 alreadyMainAccount
|
|
40
|
+
// 4. 如果 wallet 账户已被其他账户绑定,则提示 alreadyBindOAuth
|
|
29
41
|
const translations = {
|
|
30
42
|
en: {
|
|
31
43
|
notFound: "Couldn't find account information.",
|
|
@@ -46,11 +58,6 @@ module.exports = {
|
|
|
46
58
|
const nodeInfo = await node.getNodeInfo();
|
|
47
59
|
const { did: teamDid } = isService ? await request.getBlockletInfo() : await node.getNodeInfo();
|
|
48
60
|
|
|
49
|
-
const walletUser = await node.getUser({ teamDid, user: { did: userDid } });
|
|
50
|
-
if (walletUser) {
|
|
51
|
-
throw new Error(t('alreadyMainAccount', locale, { did: userDid }));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
61
|
const oauthUser = await node.getUser({
|
|
55
62
|
teamDid,
|
|
56
63
|
user: {
|
|
@@ -73,7 +80,6 @@ module.exports = {
|
|
|
73
80
|
throw new Error(t('notFound', locale));
|
|
74
81
|
}
|
|
75
82
|
|
|
76
|
-
const sourceProvider = oauthUser.sourceProvider || LOGIN_PROVIDER.WALLET;
|
|
77
83
|
const oauthConnectedAccounts = oauthUser.connectedAccounts || [];
|
|
78
84
|
const exist = oauthConnectedAccounts.find((item) => item.provider === LOGIN_PROVIDER.WALLET);
|
|
79
85
|
if (exist) {
|
|
@@ -89,12 +95,12 @@ module.exports = {
|
|
|
89
95
|
enableConnectedAccount: true,
|
|
90
96
|
},
|
|
91
97
|
});
|
|
92
|
-
|
|
93
98
|
if (bindUser) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
throw new Error(t('alreadyBindOAuth', locale, { did: userDid }));
|
|
99
|
+
if (bindUser.sourceProvider === LOGIN_PROVIDER.WALLET) {
|
|
100
|
+
throw new Error(t('alreadyMainAccount', locale, { did: userDid }));
|
|
97
101
|
}
|
|
102
|
+
|
|
103
|
+
throw new Error(t('alreadyBindOAuth', locale, { did: userDid }));
|
|
98
104
|
}
|
|
99
105
|
|
|
100
106
|
const claims = {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.47-beta-
|
|
6
|
+
"version": "1.16.47-beta-20250807-110715-19ad6b43",
|
|
7
7
|
"description": "Simple lib to manage auth in ABT Node",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -20,25 +20,25 @@
|
|
|
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.47-beta-
|
|
24
|
-
"@abtnode/logger": "1.16.47-beta-
|
|
25
|
-
"@abtnode/util": "1.16.47-beta-
|
|
26
|
-
"@arcblock/did": "1.21.
|
|
27
|
-
"@arcblock/did-
|
|
28
|
-
"@arcblock/did-ext": "1.21.
|
|
29
|
-
"@arcblock/did-util": "1.21.
|
|
30
|
-
"@arcblock/jwt": "1.21.
|
|
31
|
-
"@arcblock/nft-display": "^3.0.
|
|
32
|
-
"@arcblock/validator": "1.21.
|
|
33
|
-
"@arcblock/vc": "1.21.
|
|
34
|
-
"@blocklet/constant": "1.16.47-beta-
|
|
23
|
+
"@abtnode/constant": "1.16.47-beta-20250807-110715-19ad6b43",
|
|
24
|
+
"@abtnode/logger": "1.16.47-beta-20250807-110715-19ad6b43",
|
|
25
|
+
"@abtnode/util": "1.16.47-beta-20250807-110715-19ad6b43",
|
|
26
|
+
"@arcblock/did": "1.21.2",
|
|
27
|
+
"@arcblock/did-connect-js": "1.21.2",
|
|
28
|
+
"@arcblock/did-ext": "1.21.2",
|
|
29
|
+
"@arcblock/did-util": "1.21.2",
|
|
30
|
+
"@arcblock/jwt": "1.21.2",
|
|
31
|
+
"@arcblock/nft-display": "^3.0.42",
|
|
32
|
+
"@arcblock/validator": "1.21.2",
|
|
33
|
+
"@arcblock/vc": "1.21.2",
|
|
34
|
+
"@blocklet/constant": "1.16.47-beta-20250807-110715-19ad6b43",
|
|
35
35
|
"@blocklet/error": "^0.2.5",
|
|
36
|
-
"@blocklet/meta": "1.16.47-beta-
|
|
37
|
-
"@blocklet/sdk": "1.16.47-beta-
|
|
38
|
-
"@ocap/client": "1.21.
|
|
39
|
-
"@ocap/mcrypto": "1.21.
|
|
40
|
-
"@ocap/util": "1.21.
|
|
41
|
-
"@ocap/wallet": "1.21.
|
|
36
|
+
"@blocklet/meta": "1.16.47-beta-20250807-110715-19ad6b43",
|
|
37
|
+
"@blocklet/sdk": "1.16.47-beta-20250807-110715-19ad6b43",
|
|
38
|
+
"@ocap/client": "1.21.2",
|
|
39
|
+
"@ocap/mcrypto": "1.21.2",
|
|
40
|
+
"@ocap/util": "1.21.2",
|
|
41
|
+
"@ocap/wallet": "1.21.2",
|
|
42
42
|
"@simplewebauthn/server": "^13.1.1",
|
|
43
43
|
"axios": "^1.7.9",
|
|
44
44
|
"flat": "^5.0.2",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"jest": "^29.7.0"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "639aa367b25d6885e38cba99f73d753b2831393d"
|
|
60
60
|
}
|