@abtnode/auth 1.16.45-beta-20250701-122807-92b03aba → 1.16.45-beta-20250702-072658-6f6c82be
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/bind-wallet.js +4 -4
- package/lib/util/bind-wallet.js +15 -4
- package/package.json +8 -8
package/lib/bind-wallet.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { onConnect, onApprove, authPrincipal } = require('./util/bind-wallet');
|
|
2
2
|
const logger = require('./logger');
|
|
3
3
|
|
|
4
|
-
const createBindWalletRoute = ({ node }) => ({
|
|
4
|
+
const createBindWalletRoute = ({ node, isService = true }) => ({
|
|
5
5
|
action: 'bind-wallet',
|
|
6
6
|
authPrincipal: false,
|
|
7
7
|
claims: {
|
|
@@ -9,7 +9,7 @@ const createBindWalletRoute = ({ node }) => ({
|
|
|
9
9
|
return authPrincipal({ locale, previousUserDid, email });
|
|
10
10
|
},
|
|
11
11
|
},
|
|
12
|
-
onConnect: ({ req, userDid, extraParams: { locale, passportId = '', componentId, previousUserDid
|
|
12
|
+
onConnect: ({ req, userDid, extraParams: { locale, passportId = '', componentId, previousUserDid } }) => {
|
|
13
13
|
return onConnect({
|
|
14
14
|
node,
|
|
15
15
|
request: req,
|
|
@@ -26,7 +26,7 @@ const createBindWalletRoute = ({ node }) => ({
|
|
|
26
26
|
claims,
|
|
27
27
|
userDid,
|
|
28
28
|
userPk,
|
|
29
|
-
extraParams: { locale, previousUserDid, skipMigrateAccount
|
|
29
|
+
extraParams: { locale, previousUserDid, skipMigrateAccount },
|
|
30
30
|
req,
|
|
31
31
|
baseUrl,
|
|
32
32
|
}) => {
|
|
@@ -42,7 +42,7 @@ const createBindWalletRoute = ({ node }) => ({
|
|
|
42
42
|
previousUserDid,
|
|
43
43
|
skipMigrateAccount:
|
|
44
44
|
typeof skipMigrateAccount === 'boolean' ? skipMigrateAccount : skipMigrateAccount === 'true',
|
|
45
|
-
isService
|
|
45
|
+
isService,
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
if (result.nextWorkflowData && skipMigrateAccount) {
|
package/lib/util/bind-wallet.js
CHANGED
|
@@ -25,7 +25,7 @@ module.exports = {
|
|
|
25
25
|
supervised: true,
|
|
26
26
|
};
|
|
27
27
|
},
|
|
28
|
-
onConnect: async ({ node, request, userDid, locale, previousUserDid, isService }) => {
|
|
28
|
+
onConnect: async ({ node, request, userDid, locale, previousUserDid, isService = true }) => {
|
|
29
29
|
const translations = {
|
|
30
30
|
en: {
|
|
31
31
|
notFound: "Couldn't find account information.",
|
|
@@ -42,6 +42,8 @@ module.exports = {
|
|
|
42
42
|
},
|
|
43
43
|
};
|
|
44
44
|
const t = createTranslator({ translations });
|
|
45
|
+
const blockletInfo = await request.getBlockletInfo();
|
|
46
|
+
const nodeInfo = await node.getNodeInfo();
|
|
45
47
|
const { did: teamDid } = isService ? await request.getBlockletInfo() : await node.getNodeInfo();
|
|
46
48
|
|
|
47
49
|
const walletUser = await node.getUser({ teamDid, user: { did: userDid } });
|
|
@@ -59,7 +61,16 @@ module.exports = {
|
|
|
59
61
|
},
|
|
60
62
|
});
|
|
61
63
|
if (!oauthUser) {
|
|
62
|
-
|
|
64
|
+
logger.error('bind-wallet failed: oauthUser not found', {
|
|
65
|
+
bindToUser: userDid,
|
|
66
|
+
currentUser: previousUserDid,
|
|
67
|
+
isService,
|
|
68
|
+
locale,
|
|
69
|
+
teamDid,
|
|
70
|
+
blocklet: blockletInfo.did,
|
|
71
|
+
node: nodeInfo.did,
|
|
72
|
+
});
|
|
73
|
+
throw new Error(t('notFound', locale));
|
|
63
74
|
}
|
|
64
75
|
|
|
65
76
|
const sourceProvider = oauthUser.sourceProvider || LOGIN_PROVIDER.WALLET;
|
|
@@ -82,7 +93,7 @@ module.exports = {
|
|
|
82
93
|
if (bindUser) {
|
|
83
94
|
const bindConnectedAccounts = bindUser.connectedAccounts || [];
|
|
84
95
|
if (bindConnectedAccounts.find((item) => item.provider === sourceProvider)) {
|
|
85
|
-
throw new Error(t('alreadyBindOAuth', locale, {
|
|
96
|
+
throw new Error(t('alreadyBindOAuth', locale, { did: userDid }));
|
|
86
97
|
}
|
|
87
98
|
}
|
|
88
99
|
|
|
@@ -114,7 +125,7 @@ module.exports = {
|
|
|
114
125
|
previousUserDid,
|
|
115
126
|
baseUrl,
|
|
116
127
|
skipMigrateAccount = false,
|
|
117
|
-
isService =
|
|
128
|
+
isService = true,
|
|
118
129
|
}) => {
|
|
119
130
|
// 在这里要对 server 还是 service 进行区分
|
|
120
131
|
const nodeInfo = await node.getNodeInfo();
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.45-beta-
|
|
6
|
+
"version": "1.16.45-beta-20250702-072658-6f6c82be",
|
|
7
7
|
"description": "Simple lib to manage auth in ABT Node",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -20,9 +20,9 @@
|
|
|
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.45-beta-
|
|
24
|
-
"@abtnode/logger": "1.16.45-beta-
|
|
25
|
-
"@abtnode/util": "1.16.45-beta-
|
|
23
|
+
"@abtnode/constant": "1.16.45-beta-20250702-072658-6f6c82be",
|
|
24
|
+
"@abtnode/logger": "1.16.45-beta-20250702-072658-6f6c82be",
|
|
25
|
+
"@abtnode/util": "1.16.45-beta-20250702-072658-6f6c82be",
|
|
26
26
|
"@arcblock/did": "1.20.14",
|
|
27
27
|
"@arcblock/did-auth": "1.20.14",
|
|
28
28
|
"@arcblock/did-ext": "1.20.14",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"@arcblock/nft-display": "^2.13.70",
|
|
32
32
|
"@arcblock/validator": "1.20.14",
|
|
33
33
|
"@arcblock/vc": "1.20.14",
|
|
34
|
-
"@blocklet/constant": "1.16.45-beta-
|
|
34
|
+
"@blocklet/constant": "1.16.45-beta-20250702-072658-6f6c82be",
|
|
35
35
|
"@blocklet/error": "^0.2.5",
|
|
36
|
-
"@blocklet/meta": "1.16.45-beta-
|
|
37
|
-
"@blocklet/sdk": "1.16.45-beta-
|
|
36
|
+
"@blocklet/meta": "1.16.45-beta-20250702-072658-6f6c82be",
|
|
37
|
+
"@blocklet/sdk": "1.16.45-beta-20250702-072658-6f6c82be",
|
|
38
38
|
"@ocap/client": "1.20.14",
|
|
39
39
|
"@ocap/mcrypto": "1.20.14",
|
|
40
40
|
"@ocap/util": "1.20.14",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"jest": "^29.7.0"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "e2b7203766cce76f547833530ac0eb463752162c"
|
|
60
60
|
}
|