@riocrypto/common-server 1.0.2303 → 1.0.2305

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.
@@ -133,9 +133,20 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
133
133
  }
134
134
  const payload = jsonwebtoken_1.default.verify(accessToken, ACCESS_TOKEN_SECRET);
135
135
  const auth = yield Auth.findById(payload.id);
136
- if (auth) {
137
- req.auth = auth;
138
- authId = auth.id;
136
+ if (auth && !auth.isDisabled) {
137
+ // Check if token version matches (for server-side invalidation)
138
+ if (payload.tokenVersion !== undefined &&
139
+ auth.tokenVersion !== undefined) {
140
+ if (payload.tokenVersion >= auth.tokenVersion) {
141
+ req.auth = auth;
142
+ authId = auth.id;
143
+ }
144
+ }
145
+ else {
146
+ // Backward compatibility for tokens without version
147
+ req.auth = auth;
148
+ authId = auth.id;
149
+ }
139
150
  }
140
151
  }
141
152
  catch (err) { }
@@ -10,10 +10,6 @@ interface AuthAttrs {
10
10
  apiKeys?: APIKey[];
11
11
  isDisabled?: boolean;
12
12
  tokenVersion?: number;
13
- blacklistedTokens?: Array<{
14
- jti: string;
15
- exp: Date;
16
- }>;
17
13
  authenticator?: {
18
14
  secret?: string;
19
15
  verified?: boolean;
@@ -38,10 +34,6 @@ interface AuthDoc extends Document {
38
34
  apiKeys?: APIKey[];
39
35
  isDisabled?: boolean;
40
36
  tokenVersion?: number;
41
- blacklistedTokens?: Array<{
42
- jti: string;
43
- exp: Date;
44
- }>;
45
37
  authenticator?: {
46
38
  secret?: string;
47
39
  verified?: boolean;
@@ -91,18 +91,6 @@ const buildAuth = (mongoose) => {
91
91
  },
92
92
  },
93
93
  ],
94
- blacklistedTokens: [
95
- {
96
- jti: {
97
- type: String,
98
- required: true,
99
- },
100
- exp: {
101
- type: Date,
102
- required: true,
103
- },
104
- },
105
- ],
106
94
  }, {
107
95
  toJSON: {
108
96
  transform(doc, ret) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2303",
3
+ "version": "1.0.2305",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",