@nocobase/auth 1.7.0-beta.8 → 1.8.0-beta.1

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.
@@ -45,6 +45,7 @@ export declare class BaseAuth extends Auth {
45
45
  }>;
46
46
  check(): ReturnType<Auth['check']>;
47
47
  validate(): Promise<Model>;
48
+ signNewToken(userId: number): Promise<string>;
48
49
  signIn(): Promise<{
49
50
  user: Model<any, any>;
50
51
  token: string;
package/lib/base/auth.js CHANGED
@@ -240,6 +240,23 @@ const _BaseAuth = class _BaseAuth extends import_auth.Auth {
240
240
  async validate() {
241
241
  return null;
242
242
  }
243
+ async signNewToken(userId) {
244
+ const tokenInfo = await this.tokenController.add({ userId });
245
+ const expiresIn = Math.floor((await this.tokenController.getConfig()).tokenExpirationTime / 1e3);
246
+ const token = this.jwt.sign(
247
+ {
248
+ userId,
249
+ temp: true,
250
+ iat: Math.floor(tokenInfo.issuedTime / 1e3),
251
+ signInTime: tokenInfo.signInTime
252
+ },
253
+ {
254
+ jwtid: tokenInfo.jti,
255
+ expiresIn
256
+ }
257
+ );
258
+ return token;
259
+ }
243
260
  async signIn() {
244
261
  let user;
245
262
  try {
@@ -255,20 +272,7 @@ const _BaseAuth = class _BaseAuth extends import_auth.Auth {
255
272
  code: import_auth.AuthErrorCode.NOT_EXIST_USER
256
273
  });
257
274
  }
258
- const tokenInfo = await this.tokenController.add({ userId: user.id });
259
- const expiresIn = Math.floor((await this.tokenController.getConfig()).tokenExpirationTime / 1e3);
260
- const token = this.jwt.sign(
261
- {
262
- userId: user.id,
263
- temp: true,
264
- iat: Math.floor(tokenInfo.issuedTime / 1e3),
265
- signInTime: tokenInfo.signInTime
266
- },
267
- {
268
- jwtid: tokenInfo.jti,
269
- expiresIn
270
- }
271
- );
275
+ const token = await this.signNewToken(user.id);
272
276
  return {
273
277
  user,
274
278
  token
@@ -33,6 +33,6 @@ export interface ITokenControlService {
33
33
  add({ userId }: {
34
34
  userId: number;
35
35
  }): Promise<TokenInfo>;
36
- removeSessionExpiredTokens(userId: number): Promise<void>;
36
+ removeSessionExpiredTokens(userId: number): Promise<any>;
37
37
  }
38
38
  export {};
package/package.json CHANGED
@@ -1,23 +1,23 @@
1
1
  {
2
2
  "name": "@nocobase/auth",
3
- "version": "1.7.0-beta.8",
3
+ "version": "1.8.0-beta.1",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0",
6
6
  "main": "./lib/index.js",
7
7
  "types": "./lib/index.d.ts",
8
8
  "dependencies": {
9
- "@nocobase/actions": "1.7.0-beta.8",
10
- "@nocobase/cache": "1.7.0-beta.8",
11
- "@nocobase/database": "1.7.0-beta.8",
12
- "@nocobase/resourcer": "1.7.0-beta.8",
13
- "@nocobase/utils": "1.7.0-beta.8",
14
- "@types/jsonwebtoken": "^8.5.8",
15
- "jsonwebtoken": "^8.5.1"
9
+ "@nocobase/actions": "1.8.0-beta.1",
10
+ "@nocobase/cache": "1.8.0-beta.1",
11
+ "@nocobase/database": "1.8.0-beta.1",
12
+ "@nocobase/resourcer": "1.8.0-beta.1",
13
+ "@nocobase/utils": "1.8.0-beta.1",
14
+ "@types/jsonwebtoken": "^9.0.9",
15
+ "jsonwebtoken": "^9.0.2"
16
16
  },
17
17
  "repository": {
18
18
  "type": "git",
19
19
  "url": "git+https://github.com/nocobase/nocobase.git",
20
20
  "directory": "packages/auth"
21
21
  },
22
- "gitHead": "9ad35ee90db98d95dfa660645d155f4f4e81b47c"
22
+ "gitHead": "103935669123174f2942247202e3d9ff15f0d4ed"
23
23
  }