@wbce-d9/api 11.1.1 → 11.1.2
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/dist/database/migrations/20250910A-add-session-tracking.d.ts +3 -0
- package/dist/database/migrations/20250910A-add-session-tracking.js +16 -0
- package/dist/env.js +1 -0
- package/dist/middleware/authenticate.js +2 -0
- package/dist/request/response-interceptor.d.ts +1 -1
- package/dist/services/authentication.js +6 -0
- package/dist/services/items.js +3 -0
- package/dist/services/shares.js +2 -0
- package/package.json +9 -9
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export async function up(knex) {
|
|
2
|
+
await knex.schema.alterTable('directus_activity', (table) => {
|
|
3
|
+
table.string('session_id', 64).nullable();
|
|
4
|
+
});
|
|
5
|
+
await knex.schema.alterTable('directus_sessions', (table) => {
|
|
6
|
+
table.string('session_id', 64).nullable();
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
export async function down(knex) {
|
|
10
|
+
await knex.schema.alterTable('directus_activity', (table) => {
|
|
11
|
+
table.dropColumn('session_id');
|
|
12
|
+
});
|
|
13
|
+
await knex.schema.alterTable('directus_sessions', (table) => {
|
|
14
|
+
table.dropColumn('session_id');
|
|
15
|
+
});
|
|
16
|
+
}
|
package/dist/env.js
CHANGED
|
@@ -43,6 +43,7 @@ const allowedEnvironmentVars = [
|
|
|
43
43
|
'REFRESH_TOKEN_COOKIE_SECURE',
|
|
44
44
|
'REFRESH_TOKEN_COOKIE_SAME_SITE',
|
|
45
45
|
'REFRESH_TOKEN_COOKIE_NAME',
|
|
46
|
+
'REFRESH_TOKEN_OVERLAP_DURATION',
|
|
46
47
|
'LOGIN_STALL_TIME',
|
|
47
48
|
'PASSWORD_RESET_URL_ALLOW_LIST',
|
|
48
49
|
'USER_INVITE_URL_ALLOW_LIST',
|
|
@@ -47,6 +47,7 @@ export const handler = async (req, _res, next) => {
|
|
|
47
47
|
.select({
|
|
48
48
|
session_expires: 's.expires',
|
|
49
49
|
user_id: 'u.id',
|
|
50
|
+
session_id: 's.session_id',
|
|
50
51
|
})
|
|
51
52
|
.from('directus_sessions AS s')
|
|
52
53
|
.leftJoin('directus_users AS u', 's.user', 'u.id')
|
|
@@ -59,6 +60,7 @@ export const handler = async (req, _res, next) => {
|
|
|
59
60
|
req.accountability.role = payload.role;
|
|
60
61
|
req.accountability.admin = payload.admin_access === true || payload.admin_access == 1;
|
|
61
62
|
req.accountability.app = payload.app_access === true || payload.app_access == 1;
|
|
63
|
+
req.accountability.session_id = user.session_id;
|
|
62
64
|
if (payload.share)
|
|
63
65
|
req.accountability.share = payload.share;
|
|
64
66
|
if (payload.share_scope)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { AxiosResponse } from 'axios';
|
|
2
|
-
export declare const responseInterceptor: (config: AxiosResponse<any, any>) => Promise<AxiosResponse<any, any>>;
|
|
2
|
+
export declare const responseInterceptor: (config: AxiosResponse<any, any>) => Promise<AxiosResponse<any, any, {}>>;
|
|
@@ -120,6 +120,7 @@ export class AuthenticationService {
|
|
|
120
120
|
}
|
|
121
121
|
const refreshToken = nanoid(64);
|
|
122
122
|
const refreshTokenExpiration = new Date(Date.now() + getMilliseconds(env['REFRESH_TOKEN_TTL'], 0));
|
|
123
|
+
const sessionId = nanoid(64);
|
|
123
124
|
await this.knex('directus_sessions').insert({
|
|
124
125
|
token: refreshToken,
|
|
125
126
|
user: user.id,
|
|
@@ -127,6 +128,7 @@ export class AuthenticationService {
|
|
|
127
128
|
ip: this.accountability?.ip,
|
|
128
129
|
user_agent: this.accountability?.userAgent,
|
|
129
130
|
origin: this.accountability?.origin,
|
|
131
|
+
session_id: sessionId,
|
|
130
132
|
});
|
|
131
133
|
const tokenPayload = {
|
|
132
134
|
id: user.id,
|
|
@@ -159,6 +161,7 @@ export class AuthenticationService {
|
|
|
159
161
|
origin: this.accountability.origin,
|
|
160
162
|
collection: 'directus_users',
|
|
161
163
|
item: user.id,
|
|
164
|
+
session_id: sessionId,
|
|
162
165
|
});
|
|
163
166
|
}
|
|
164
167
|
await this.knex('directus_users').update({ last_access: new Date() }).where({ id: user.id });
|
|
@@ -185,6 +188,7 @@ export class AuthenticationService {
|
|
|
185
188
|
.select({
|
|
186
189
|
session_expires: 's.expires',
|
|
187
190
|
session_fallback_token: 's.fallback_token',
|
|
191
|
+
session_id: 's.session_id',
|
|
188
192
|
user_id: 'u.id',
|
|
189
193
|
user_first_name: 'u.first_name',
|
|
190
194
|
user_last_name: 'u.last_name',
|
|
@@ -259,6 +263,7 @@ export class AuthenticationService {
|
|
|
259
263
|
.andWhere('expires', '<', new Date());
|
|
260
264
|
let newRefreshToken = record.session_fallback_token ?? nanoid(64);
|
|
261
265
|
const refreshTokenExpiration = new Date(Date.now() + getMilliseconds(env['REFRESH_TOKEN_TTL'], 0));
|
|
266
|
+
const sessionId = record.session_id ?? nanoid(64);
|
|
262
267
|
// If a fallback session already exists, just update its expiration
|
|
263
268
|
if (record.session_fallback_token) {
|
|
264
269
|
await this.knex('directus_sessions')
|
|
@@ -295,6 +300,7 @@ export class AuthenticationService {
|
|
|
295
300
|
ip: this.accountability?.ip,
|
|
296
301
|
user_agent: this.accountability?.userAgent,
|
|
297
302
|
origin: this.accountability?.origin,
|
|
303
|
+
session_id: sessionId,
|
|
298
304
|
});
|
|
299
305
|
}
|
|
300
306
|
}
|
package/dist/services/items.js
CHANGED
|
@@ -162,6 +162,7 @@ export class ItemsService {
|
|
|
162
162
|
user_agent: this.accountability.userAgent,
|
|
163
163
|
origin: this.accountability.origin,
|
|
164
164
|
item: primaryKey,
|
|
165
|
+
session_id: this.accountability.session_id,
|
|
165
166
|
});
|
|
166
167
|
// If revisions are tracked, create revisions record
|
|
167
168
|
if (this.schema.collections[this.collection].accountability === 'all') {
|
|
@@ -496,6 +497,7 @@ export class ItemsService {
|
|
|
496
497
|
user_agent: this.accountability.userAgent,
|
|
497
498
|
origin: this.accountability.origin,
|
|
498
499
|
item: key,
|
|
500
|
+
session_id: this.accountability?.session_id,
|
|
499
501
|
})), { bypassLimits: true });
|
|
500
502
|
if (this.schema.collections[this.collection].accountability === 'all') {
|
|
501
503
|
const itemsService = new ItemsService(this.collection, {
|
|
@@ -680,6 +682,7 @@ export class ItemsService {
|
|
|
680
682
|
user_agent: this.accountability.userAgent,
|
|
681
683
|
origin: this.accountability.origin,
|
|
682
684
|
item: key,
|
|
685
|
+
session_id: this.accountability.session_id,
|
|
683
686
|
})), { bypassLimits: true });
|
|
684
687
|
}
|
|
685
688
|
});
|
package/dist/services/shares.js
CHANGED
|
@@ -61,6 +61,7 @@ export class SharesService extends ItemsService {
|
|
|
61
61
|
.where('id', record.share_id);
|
|
62
62
|
const refreshToken = nanoid(64);
|
|
63
63
|
const refreshTokenExpiration = new Date(Date.now() + getMilliseconds(env['REFRESH_TOKEN_TTL'], 0));
|
|
64
|
+
const sessionId = nanoid(64);
|
|
64
65
|
await this.knex('directus_sessions').insert({
|
|
65
66
|
token: refreshToken,
|
|
66
67
|
expires: refreshTokenExpiration,
|
|
@@ -68,6 +69,7 @@ export class SharesService extends ItemsService {
|
|
|
68
69
|
user_agent: this.accountability?.userAgent,
|
|
69
70
|
origin: this.accountability?.origin,
|
|
70
71
|
share: record.share_id,
|
|
72
|
+
session_id: sessionId,
|
|
71
73
|
});
|
|
72
74
|
await this.knex('directus_sessions').delete().where('expires', '<', new Date());
|
|
73
75
|
const tokenPayload = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wbce-d9/api",
|
|
3
|
-
"version": "11.1.
|
|
3
|
+
"version": "11.1.2",
|
|
4
4
|
"description": "Directus is a real-time API and App dashboard for managing SQL database content",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@wbce-d9/format-title": "10.0.0",
|
|
73
73
|
"argon2": "0.30.3",
|
|
74
74
|
"async": "3.2.4",
|
|
75
|
-
"axios": "^1.
|
|
75
|
+
"axios": "^1.12.0",
|
|
76
76
|
"busboy": "1.6.0",
|
|
77
77
|
"bytes": "3.1.2",
|
|
78
78
|
"camelcase": "7.0.1",
|
|
@@ -143,20 +143,20 @@
|
|
|
143
143
|
"uuid": "9.0.0",
|
|
144
144
|
"uuid-validate": "0.0.3",
|
|
145
145
|
"wellknown": "0.5.0",
|
|
146
|
+
"@wbce-d9/app": "9.33.3",
|
|
147
|
+
"@wbce-d9/exceptions": "9.26.4",
|
|
148
|
+
"@wbce-d9/extensions-sdk": "9.27.3",
|
|
146
149
|
"@wbce-d9/constants": "9.28.0",
|
|
147
|
-
"@wbce-d9/app": "9.33.2",
|
|
148
|
-
"@wbce-d9/extensions-sdk": "9.27.2",
|
|
149
|
-
"@wbce-d9/schema": "9.26.4",
|
|
150
150
|
"@wbce-d9/specs": "9.26.5",
|
|
151
151
|
"@wbce-d9/storage": "9.26.4",
|
|
152
152
|
"@wbce-d9/storage-driver-azure": "9.26.9",
|
|
153
153
|
"@wbce-d9/storage-driver-cloudinary": "9.27.2",
|
|
154
154
|
"@wbce-d9/storage-driver-gcs": "9.26.9",
|
|
155
|
+
"@wbce-d9/storage-driver-s3": "9.26.11",
|
|
155
156
|
"@wbce-d9/storage-driver-local": "9.26.9",
|
|
156
157
|
"@wbce-d9/update-check": "9.28.0",
|
|
157
|
-
"@wbce-d9/
|
|
158
|
-
"@wbce-d9/utils": "9.29.2"
|
|
159
|
-
"@wbce-d9/exceptions": "9.26.4"
|
|
158
|
+
"@wbce-d9/schema": "9.26.4",
|
|
159
|
+
"@wbce-d9/utils": "9.29.2"
|
|
160
160
|
},
|
|
161
161
|
"devDependencies": {
|
|
162
162
|
"@ngneat/falso": "6.4.0",
|
|
@@ -204,7 +204,7 @@
|
|
|
204
204
|
"supertest": "6.3.3",
|
|
205
205
|
"typescript": "5.0.4",
|
|
206
206
|
"vitest": "0.30.1",
|
|
207
|
-
"@wbce-d9/types": "9.28.
|
|
207
|
+
"@wbce-d9/types": "9.28.1"
|
|
208
208
|
},
|
|
209
209
|
"optionalDependencies": {
|
|
210
210
|
"@keyv/redis": "2.5.7",
|