@nocobase/auth 1.6.0-alpha.21 → 1.6.0-alpha.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/base/auth.js +5 -5
- package/package.json +7 -7
package/lib/base/auth.js
CHANGED
|
@@ -81,7 +81,7 @@ const _BaseAuth = class _BaseAuth extends import_auth.Auth {
|
|
|
81
81
|
return /^[^@.<>"'/]{1,50}$/.test(username);
|
|
82
82
|
}
|
|
83
83
|
async check() {
|
|
84
|
-
var _a, _b, _c, _d, _e, _f;
|
|
84
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
85
85
|
const token = this.ctx.getBearerToken();
|
|
86
86
|
if (!token) {
|
|
87
87
|
this.ctx.throw(401, {
|
|
@@ -108,7 +108,7 @@ const _BaseAuth = class _BaseAuth extends import_auth.Auth {
|
|
|
108
108
|
}
|
|
109
109
|
const { userId, roleName, iat, temp, jti, exp, signInTime } = payload ?? {};
|
|
110
110
|
const tokenPolicy = await this.tokenController.getConfig();
|
|
111
|
-
if (
|
|
111
|
+
if (signInTime && Date.now() - signInTime > tokenPolicy.sessionExpirationTime) {
|
|
112
112
|
this.ctx.throw(401, {
|
|
113
113
|
message: this.ctx.t("Your session has expired. Please sign in again.", { ns: localeNamespace }),
|
|
114
114
|
code: import_auth.AuthErrorCode.EXPIRED_SESSION
|
|
@@ -162,7 +162,7 @@ const _BaseAuth = class _BaseAuth extends import_auth.Auth {
|
|
|
162
162
|
url: this.ctx.originalUrl,
|
|
163
163
|
headers: JSON.stringify((_b = (_a = this.ctx) == null ? void 0 : _a.req) == null ? void 0 : _b.headers)
|
|
164
164
|
});
|
|
165
|
-
const isStreamRequest = this.ctx.req.headers
|
|
165
|
+
const isStreamRequest = ((_e = (_d = (_c = this.ctx) == null ? void 0 : _c.req) == null ? void 0 : _d.headers) == null ? void 0 : _e.accept) === "text/event-stream";
|
|
166
166
|
if (isStreamRequest) {
|
|
167
167
|
this.ctx.throw(401, {
|
|
168
168
|
message: "Stream api not allow renew token.",
|
|
@@ -173,7 +173,7 @@ const _BaseAuth = class _BaseAuth extends import_auth.Auth {
|
|
|
173
173
|
this.ctx.logger.info("token renewed", {
|
|
174
174
|
method: "auth.check",
|
|
175
175
|
url: this.ctx.originalUrl,
|
|
176
|
-
headers: JSON.stringify((
|
|
176
|
+
headers: JSON.stringify((_g = (_f = this.ctx) == null ? void 0 : _f.req) == null ? void 0 : _g.headers)
|
|
177
177
|
});
|
|
178
178
|
const expiresIn = Math.floor(tokenPolicy.tokenExpirationTime / 1e3);
|
|
179
179
|
const newToken = this.jwt.sign({ userId, roleName, temp, signInTime }, { jwtid: renewedResult.jti, expiresIn });
|
|
@@ -184,7 +184,7 @@ const _BaseAuth = class _BaseAuth extends import_auth.Auth {
|
|
|
184
184
|
method: "auth.check",
|
|
185
185
|
url: this.ctx.originalUrl,
|
|
186
186
|
err,
|
|
187
|
-
headers: JSON.stringify((
|
|
187
|
+
headers: JSON.stringify((_i = (_h = this.ctx) == null ? void 0 : _h.req) == null ? void 0 : _i.headers)
|
|
188
188
|
});
|
|
189
189
|
const options = err instanceof import_auth.AuthError ? { code: err.code, message: err.message } : { message: err.message, code: err.code ?? import_auth.AuthErrorCode.INVALID_TOKEN };
|
|
190
190
|
this.ctx.throw(401, {
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/auth",
|
|
3
|
-
"version": "1.6.0-alpha.
|
|
3
|
+
"version": "1.6.0-alpha.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.6.0-alpha.
|
|
10
|
-
"@nocobase/cache": "1.6.0-alpha.
|
|
11
|
-
"@nocobase/database": "1.6.0-alpha.
|
|
12
|
-
"@nocobase/resourcer": "1.6.0-alpha.
|
|
13
|
-
"@nocobase/utils": "1.6.0-alpha.
|
|
9
|
+
"@nocobase/actions": "1.6.0-alpha.23",
|
|
10
|
+
"@nocobase/cache": "1.6.0-alpha.23",
|
|
11
|
+
"@nocobase/database": "1.6.0-alpha.23",
|
|
12
|
+
"@nocobase/resourcer": "1.6.0-alpha.23",
|
|
13
|
+
"@nocobase/utils": "1.6.0-alpha.23",
|
|
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": "
|
|
22
|
+
"gitHead": "34e9bab601ea8364f10730f6da9f132e906b1908"
|
|
23
23
|
}
|