@nocobase/auth 0.21.0-alpha.8 → 0.21.0-alpha.9

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/actions.js CHANGED
@@ -20,6 +20,7 @@ __export(actions_exports, {
20
20
  actions: () => actions
21
21
  });
22
22
  module.exports = __toCommonJS(actions_exports);
23
+ /* istanbul ignore file -- @preserve */
23
24
  const actions = {
24
25
  signIn: async (ctx, next) => {
25
26
  ctx.body = await ctx.auth.signIn();
@@ -76,9 +76,9 @@ const _AuthManager = class _AuthManager {
76
76
  if (!authenticator) {
77
77
  throw new Error(`Authenticator [${name}] is not found.`);
78
78
  }
79
- const { auth } = this.authTypes.get(authenticator.authType);
79
+ const { auth } = this.authTypes.get(authenticator.authType) || {};
80
80
  if (!auth) {
81
- throw new Error(`AuthType [${name}] is not found.`);
81
+ throw new Error(`AuthType [${authenticator.authType}] is not found.`);
82
82
  }
83
83
  return new auth({ authenticator, options: authenticator.options, ctx });
84
84
  }
package/lib/base/auth.js CHANGED
@@ -89,7 +89,7 @@ const _BaseAuth = class _BaseAuth extends import_auth.Auth {
89
89
  try {
90
90
  user = await this.validate();
91
91
  } catch (err) {
92
- this.ctx.throw(401, err.message);
92
+ this.ctx.throw(err.status || 401, err.message);
93
93
  }
94
94
  if (!user) {
95
95
  this.ctx.throw(401, "Unauthorized");
@@ -50,6 +50,7 @@ const _JwtService = class _JwtService {
50
50
  secret() {
51
51
  return this.options.secret;
52
52
  }
53
+ /* istanbul ignore next -- @preserve */
53
54
  sign(payload, options) {
54
55
  const opt = { expiresIn: this.expiresIn(), ...options };
55
56
  if (opt.expiresIn === "never") {
@@ -57,6 +58,7 @@ const _JwtService = class _JwtService {
57
58
  }
58
59
  return import_jsonwebtoken.default.sign(payload, this.secret(), opt);
59
60
  }
61
+ /* istanbul ignore next -- @preserve */
60
62
  decode(token) {
61
63
  return new Promise((resolve, reject) => {
62
64
  import_jsonwebtoken.default.verify(token, this.secret(), (err, decoded) => {
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@nocobase/auth",
3
- "version": "0.21.0-alpha.8",
3
+ "version": "0.21.0-alpha.9",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./lib/index.js",
7
7
  "types": "./lib/index.d.ts",
8
8
  "dependencies": {
9
- "@nocobase/actions": "0.21.0-alpha.8",
10
- "@nocobase/cache": "0.21.0-alpha.8",
11
- "@nocobase/database": "0.21.0-alpha.8",
12
- "@nocobase/resourcer": "0.21.0-alpha.8",
13
- "@nocobase/utils": "0.21.0-alpha.8",
9
+ "@nocobase/actions": "0.21.0-alpha.9",
10
+ "@nocobase/cache": "0.21.0-alpha.9",
11
+ "@nocobase/database": "0.21.0-alpha.9",
12
+ "@nocobase/resourcer": "0.21.0-alpha.9",
13
+ "@nocobase/utils": "0.21.0-alpha.9",
14
14
  "@types/jsonwebtoken": "^8.5.8",
15
15
  "jsonwebtoken": "^8.5.1"
16
16
  },
@@ -19,5 +19,5 @@
19
19
  "url": "git+https://github.com/nocobase/nocobase.git",
20
20
  "directory": "packages/auth"
21
21
  },
22
- "gitHead": "bed69485709bc8e268285b50debfc1ebfd7a30c7"
22
+ "gitHead": "a6fe6c4ee532c04e5a50ec777bf76436ca624cbd"
23
23
  }