@blocklet/sdk 1.8.31 → 1.8.32
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/service/auth.js +19 -10
- package/package.json +13 -13
package/lib/service/auth.js
CHANGED
|
@@ -26,6 +26,18 @@ const type =
|
|
|
26
26
|
? WalletType({ role: types.RoleType.ROLE_APPLICATION, pk: types.KeyType.ED25519, hash: types.HashType.SHA3 })
|
|
27
27
|
: 'eth';
|
|
28
28
|
|
|
29
|
+
const fixAvatar = (user) => {
|
|
30
|
+
const avatar = user?.avatar;
|
|
31
|
+
if (avatar && avatar.startsWith(USER_AVATAR_URL_PREFIX)) {
|
|
32
|
+
user.avatar = joinUrl(
|
|
33
|
+
WELLKNOWN_SERVICE_PATH_PREFIX,
|
|
34
|
+
USER_AVATAR_PATH_PREFIX,
|
|
35
|
+
avatar.replace(USER_AVATAR_URL_PREFIX, '')
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
return user;
|
|
39
|
+
};
|
|
40
|
+
|
|
29
41
|
class AuthService extends Client {
|
|
30
42
|
constructor(httpEndpoint) {
|
|
31
43
|
checkBlockletEnv();
|
|
@@ -95,19 +107,16 @@ class AuthService extends Client {
|
|
|
95
107
|
const apiFnMap = {
|
|
96
108
|
getUser: (fn) => async (did) => {
|
|
97
109
|
const res = await fn({ input: { user: { did }, teamDid } });
|
|
110
|
+
fixAvatar(res.user);
|
|
111
|
+
return res;
|
|
112
|
+
},
|
|
98
113
|
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
res.user.avatar = joinUrl(
|
|
103
|
-
WELLKNOWN_SERVICE_PATH_PREFIX,
|
|
104
|
-
USER_AVATAR_PATH_PREFIX,
|
|
105
|
-
avatar.replace(USER_AVATAR_URL_PREFIX, '')
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
114
|
+
getUsers: (fn) => async (args) => {
|
|
115
|
+
const res = await fn({ input: { teamDid, ...args } });
|
|
116
|
+
(res.users || []).forEach(fixAvatar);
|
|
109
117
|
return res;
|
|
110
118
|
},
|
|
119
|
+
|
|
111
120
|
removeUser: apiConvertDid,
|
|
112
121
|
updateUserRole: (fn) => (did, role) => fn({ input: { user: { did, role }, teamDid } }),
|
|
113
122
|
updateUserApproval: (fn) => (did, approved) => fn({ input: { user: { did, approved }, teamDid } }),
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.8.
|
|
6
|
+
"version": "1.8.32",
|
|
7
7
|
"description": "graphql client to read/write data on abt node",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,18 +19,18 @@
|
|
|
19
19
|
"author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/client": "1.8.
|
|
23
|
-
"@abtnode/constant": "1.8.
|
|
24
|
-
"@arcblock/did-auth": "1.
|
|
25
|
-
"@arcblock/jwt": "1.
|
|
26
|
-
"@arcblock/ws": "1.
|
|
27
|
-
"@blocklet/constant": "1.8.
|
|
28
|
-
"@blocklet/meta": "1.8.
|
|
29
|
-
"@did-connect/authenticator": "^2.1.
|
|
30
|
-
"@did-connect/handler": "^2.1.
|
|
22
|
+
"@abtnode/client": "1.8.32",
|
|
23
|
+
"@abtnode/constant": "1.8.32",
|
|
24
|
+
"@arcblock/did-auth": "1.18.1",
|
|
25
|
+
"@arcblock/jwt": "1.18.1",
|
|
26
|
+
"@arcblock/ws": "1.18.1",
|
|
27
|
+
"@blocklet/constant": "1.8.32",
|
|
28
|
+
"@blocklet/meta": "1.8.32",
|
|
29
|
+
"@did-connect/authenticator": "^2.1.24",
|
|
30
|
+
"@did-connect/handler": "^2.1.24",
|
|
31
31
|
"@nedb/core": "^2.0.5",
|
|
32
|
-
"@ocap/mcrypto": "1.
|
|
33
|
-
"@ocap/wallet": "1.
|
|
32
|
+
"@ocap/mcrypto": "1.18.1",
|
|
33
|
+
"@ocap/wallet": "1.18.1",
|
|
34
34
|
"axios": "^0.27.2",
|
|
35
35
|
"fs-extra": "^10.1.0",
|
|
36
36
|
"joi": "17.6.3",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"detect-port": "^1.5.1",
|
|
47
47
|
"jest": "^27.5.1"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "8502244aeda5926b3433c1dd9142e63233e3c23c"
|
|
50
50
|
}
|