@nocobase/auth 1.9.22 → 1.9.23

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.
@@ -71,6 +71,6 @@ export declare class AuthManager {
71
71
  middleware(): (ctx: Context & {
72
72
  auth: Auth;
73
73
  }, next: Next) => Promise<any>;
74
- private getDefaultAPIKey;
74
+ private getDefaultJWTSecret;
75
75
  }
76
76
  export {};
@@ -59,7 +59,7 @@ const _AuthManager = class _AuthManager {
59
59
  this.options = options;
60
60
  const jwtOptions = options.jwt || {};
61
61
  if (!jwtOptions.secret) {
62
- jwtOptions.secret = this.getDefaultAPIKey();
62
+ jwtOptions.secret = this.getDefaultJWTSecret();
63
63
  }
64
64
  this.jwt = new import_jwt_service.JwtService(jwtOptions);
65
65
  }
@@ -142,11 +142,11 @@ const _AuthManager = class _AuthManager {
142
142
  await next();
143
143
  }, "AuthManagerMiddleware");
144
144
  }
145
- getDefaultAPIKey() {
146
- const apiKeyPath = import_path.default.resolve(process.cwd(), "storage", "apps", "main", "api_key.dat");
147
- const appKeyExists = import_fs.default.existsSync(apiKeyPath);
148
- if (appKeyExists) {
149
- const key2 = import_fs.default.readFileSync(apiKeyPath);
145
+ getDefaultJWTSecret() {
146
+ const jwtSecretPath = import_path.default.resolve(process.cwd(), "storage", "apps", "main", "jwt_secret.dat");
147
+ const jwtSecretExists = import_fs.default.existsSync(jwtSecretPath);
148
+ if (jwtSecretExists) {
149
+ const key2 = import_fs.default.readFileSync(jwtSecretPath);
150
150
  if (key2.length !== 32) {
151
151
  throw new Error("Invalid api key length in file");
152
152
  }
@@ -157,8 +157,8 @@ const _AuthManager = class _AuthManager {
157
157
  return envKey;
158
158
  }
159
159
  const key = import_crypto.default.randomBytes(32);
160
- import_fs.default.mkdirSync(import_path.default.dirname(apiKeyPath), { recursive: true });
161
- import_fs.default.writeFileSync(apiKeyPath, key, { mode: 384 });
160
+ import_fs.default.mkdirSync(import_path.default.dirname(jwtSecretPath), { recursive: true });
161
+ import_fs.default.writeFileSync(jwtSecretPath, key, { mode: 384 });
162
162
  return key;
163
163
  }
164
164
  };
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@nocobase/auth",
3
- "version": "1.9.22",
3
+ "version": "1.9.23",
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.9.22",
10
- "@nocobase/cache": "1.9.22",
11
- "@nocobase/database": "1.9.22",
12
- "@nocobase/resourcer": "1.9.22",
13
- "@nocobase/utils": "1.9.22",
9
+ "@nocobase/actions": "1.9.23",
10
+ "@nocobase/cache": "1.9.23",
11
+ "@nocobase/database": "1.9.23",
12
+ "@nocobase/resourcer": "1.9.23",
13
+ "@nocobase/utils": "1.9.23",
14
14
  "@types/jsonwebtoken": "^9.0.9",
15
15
  "jsonwebtoken": "^9.0.2"
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": "8c563adec50841006fdda8f6055be127b174da76"
22
+ "gitHead": "da3bff5691d405115b843f4ad634da2cc70395d8"
23
23
  }