@abtnode/auth 1.8.15 → 1.8.16

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.
Files changed (2) hide show
  1. package/lib/passport.js +9 -5
  2. package/package.json +6 -6
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
- const roles = await node.getRoles({ teamDid });
33
- const role = roles.find((x) => x.name === name);
32
+ let role = inputRole;
34
33
  if (!role) {
35
- throw new Error(passportNotFound[locale](name));
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.15",
6
+ "version": "1.8.16",
7
7
  "description": "Simple lib to manage auth in ABT Node",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -20,13 +20,13 @@
20
20
  "author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
- "@abtnode/constant": "1.8.15",
24
- "@abtnode/logger": "1.8.15",
25
- "@abtnode/util": "1.8.15",
23
+ "@abtnode/constant": "1.8.16",
24
+ "@abtnode/logger": "1.8.16",
25
+ "@abtnode/util": "1.8.16",
26
26
  "@arcblock/did": "1.17.17",
27
27
  "@arcblock/jwt": "^1.17.17",
28
28
  "@arcblock/vc": "1.17.17",
29
- "@blocklet/meta": "1.8.15",
29
+ "@blocklet/meta": "1.8.16",
30
30
  "@ocap/client": "1.17.17",
31
31
  "@ocap/mcrypto": "1.17.17",
32
32
  "@ocap/util": "1.17.17",
@@ -41,5 +41,5 @@
41
41
  "devDependencies": {
42
42
  "jest": "^27.5.1"
43
43
  },
44
- "gitHead": "57106db1b559b906734df5b8eac7ce87cae72980"
44
+ "gitHead": "2605cf6ebf2a0c3bb5524cb0f1385ad565fd85d6"
45
45
  }