@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.
- package/lib/auth-manager.d.ts +1 -1
- package/lib/auth-manager.js +8 -8
- package/package.json +7 -7
package/lib/auth-manager.d.ts
CHANGED
package/lib/auth-manager.js
CHANGED
|
@@ -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.
|
|
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
|
-
|
|
146
|
-
const
|
|
147
|
-
const
|
|
148
|
-
if (
|
|
149
|
-
const key2 = import_fs.default.readFileSync(
|
|
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(
|
|
161
|
-
import_fs.default.writeFileSync(
|
|
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.
|
|
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.
|
|
10
|
-
"@nocobase/cache": "1.9.
|
|
11
|
-
"@nocobase/database": "1.9.
|
|
12
|
-
"@nocobase/resourcer": "1.9.
|
|
13
|
-
"@nocobase/utils": "1.9.
|
|
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": "
|
|
22
|
+
"gitHead": "da3bff5691d405115b843f4ad634da2cc70395d8"
|
|
23
23
|
}
|