@abtnode/auth 1.8.15 → 1.8.18
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/passport.js +9 -5
- package/package.json +13 -13
package/lib/passport.js
CHANGED
|
@@ -12,7 +12,7 @@ const passportSchema = Joi.object({
|
|
|
12
12
|
name: Joi.string().required(),
|
|
13
13
|
title: Joi.string(),
|
|
14
14
|
specVersion: Joi.string(),
|
|
15
|
-
endpoint: Joi.string().uri(),
|
|
15
|
+
endpoint: Joi.string().uri(), // deprecated
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
const validatePassport = (d) => {
|
|
@@ -23,17 +23,21 @@ const validatePassport = (d) => {
|
|
|
23
23
|
return value;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
const createPassport = async ({ name, node, locale = 'en', teamDid, endpoint } = {}) => {
|
|
26
|
+
const createPassport = async ({ name, node, locale = 'en', teamDid, endpoint, role: inputRole } = {}) => {
|
|
27
27
|
const passportNotFound = {
|
|
28
28
|
en: (x) => `The passport was not found: ${x}`,
|
|
29
29
|
zh: (x) => `未找到通行证: ${x}`,
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
const role = roles.find((x) => x.name === name);
|
|
32
|
+
let role = inputRole;
|
|
34
33
|
if (!role) {
|
|
35
|
-
|
|
34
|
+
const roles = await node.getRoles({ teamDid });
|
|
35
|
+
role = roles.find((x) => x.name === name);
|
|
36
|
+
if (!role) {
|
|
37
|
+
throw new Error(passportNotFound[locale](name));
|
|
38
|
+
}
|
|
36
39
|
}
|
|
40
|
+
|
|
37
41
|
const passport = {
|
|
38
42
|
specVersion: SPEC_VERSION,
|
|
39
43
|
name: role.name,
|
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.18",
|
|
7
7
|
"description": "Simple lib to manage auth in ABT Node",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
"author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@abtnode/constant": "1.8.
|
|
24
|
-
"@abtnode/logger": "1.8.
|
|
25
|
-
"@abtnode/util": "1.8.
|
|
26
|
-
"@arcblock/did": "1.17.
|
|
27
|
-
"@arcblock/jwt": "^1.17.
|
|
28
|
-
"@arcblock/vc": "1.17.
|
|
29
|
-
"@blocklet/meta": "1.8.
|
|
30
|
-
"@ocap/client": "1.17.
|
|
31
|
-
"@ocap/mcrypto": "1.17.
|
|
32
|
-
"@ocap/util": "1.17.
|
|
33
|
-
"@ocap/wallet": "1.17.
|
|
23
|
+
"@abtnode/constant": "1.8.18",
|
|
24
|
+
"@abtnode/logger": "1.8.18",
|
|
25
|
+
"@abtnode/util": "1.8.18",
|
|
26
|
+
"@arcblock/did": "1.17.19",
|
|
27
|
+
"@arcblock/jwt": "^1.17.19",
|
|
28
|
+
"@arcblock/vc": "1.17.19",
|
|
29
|
+
"@blocklet/meta": "1.8.18",
|
|
30
|
+
"@ocap/client": "1.17.19",
|
|
31
|
+
"@ocap/mcrypto": "1.17.19",
|
|
32
|
+
"@ocap/util": "1.17.19",
|
|
33
|
+
"@ocap/wallet": "1.17.19",
|
|
34
34
|
"axios": "^0.27.2",
|
|
35
35
|
"joi": "^17.6.0",
|
|
36
36
|
"jsonwebtoken": "^8.5.1",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"jest": "^27.5.1"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "7d82c570913bedf740afca15c27ef10d05aa85fc"
|
|
45
45
|
}
|