@nocobase/auth 0.17.0-alpha.7 → 0.18.0-alpha.8

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.
@@ -1,11 +1,15 @@
1
1
  import { Context, Next } from '@nocobase/actions';
2
- import { Model } from '@nocobase/database';
3
2
  import { Registry } from '@nocobase/utils';
4
3
  import { Auth, AuthExtend } from './auth';
5
4
  import { JwtOptions, JwtService } from './base/jwt-service';
6
5
  import { ITokenBlacklistService } from './base/token-blacklist-service';
6
+ export interface Authenticator {
7
+ authType: string;
8
+ options: Record<string, any>;
9
+ [key: string]: any;
10
+ }
7
11
  export interface Storer {
8
- get: (name: string) => Promise<Model>;
12
+ get: (name: string) => Promise<Authenticator>;
9
13
  }
10
14
  export type AuthManagerOptions = {
11
15
  authKey: string;
@@ -96,7 +96,7 @@ const _AuthManager = class _AuthManager {
96
96
  ctx.auth = authenticator;
97
97
  } catch (err) {
98
98
  ctx.auth = {};
99
- ctx.app.logger.warn(`auth, ${err.message}`);
99
+ ctx.logger.warn(err.message, { method: "check", authenticator: name });
100
100
  return next();
101
101
  }
102
102
  if (authenticator) {
package/lib/auth.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Context } from '@nocobase/actions';
2
2
  import { Model } from '@nocobase/database';
3
+ import { Authenticator } from './auth-manager';
3
4
  export type AuthConfig = {
4
- authenticator: Model;
5
+ authenticator: Authenticator;
5
6
  options: {
6
7
  [key: string]: any;
7
8
  };
@@ -17,13 +18,13 @@ interface IAuth {
17
18
  }
18
19
  export declare abstract class Auth implements IAuth {
19
20
  abstract user: Model;
20
- protected authenticator: Model;
21
+ protected authenticator: Authenticator;
21
22
  protected options: {
22
23
  [key: string]: any;
23
24
  };
24
25
  protected ctx: Context;
25
26
  constructor(config: AuthConfig);
26
- abstract check(): any;
27
+ abstract check(): Promise<Model>;
27
28
  signIn(): Promise<any>;
28
29
  signUp(): Promise<any>;
29
30
  signOut(): Promise<any>;
package/lib/base/auth.js CHANGED
@@ -68,7 +68,7 @@ const _BaseAuth = class _BaseAuth extends import_auth.Auth {
68
68
  })
69
69
  );
70
70
  } catch (err) {
71
- this.ctx.logger.error(err);
71
+ this.ctx.logger.error(err, { method: "check" });
72
72
  return null;
73
73
  }
74
74
  }
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@nocobase/auth",
3
- "version": "0.17.0-alpha.7",
3
+ "version": "0.18.0-alpha.8",
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.17.0-alpha.7",
10
- "@nocobase/cache": "0.17.0-alpha.7",
11
- "@nocobase/database": "0.17.0-alpha.7",
12
- "@nocobase/resourcer": "0.17.0-alpha.7",
13
- "@nocobase/utils": "0.17.0-alpha.7",
9
+ "@nocobase/actions": "0.18.0-alpha.8",
10
+ "@nocobase/cache": "0.18.0-alpha.8",
11
+ "@nocobase/database": "0.18.0-alpha.8",
12
+ "@nocobase/resourcer": "0.18.0-alpha.8",
13
+ "@nocobase/utils": "0.18.0-alpha.8",
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": "91377a3abd1124f79fb3819f2d0e80905e091a32"
22
+ "gitHead": "727d42f6f14e5f863831da3dbf3255ba1165b567"
23
23
  }