snakeia-server 1.1.4 → 1.1.5

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/README.md CHANGED
@@ -8,7 +8,7 @@ A server for my [SnakeIA](https://github.com/Eliastik/snakeia) game, written in
8
8
 
9
9
  ## About this server
10
10
 
11
- * Version 1.1.4 (11/23/2024)
11
+ * Version 1.1.5 (6/18/2025)
12
12
  * Made in France by Eliastik - [eliastiksofts.com](http://eliastiksofts.com) - Contact : [eliastiksofts.com/contact](http://eliastiksofts.com/contact)
13
13
  * License: GNU GPLv3 (see LICENCE.txt file)
14
14
 
@@ -74,7 +74,7 @@ You can create another configuration file in the **config** directory named **lo
74
74
  ````
75
75
  {
76
76
  "ServerConfig": {
77
- "version": "1.1.4", // The server version
77
+ "version": "1.1.5", // The server version
78
78
  "port": 3000, // The port where the server runs
79
79
  "proxyMode": false, // Sets this value to true if your server is behind a proxy - defaults to false
80
80
  "numberOfProxies": 1, // Sets the number of reverse proxies in front of the server. Default to 1. See: https://expressjs.com/en/guide/behind-proxies.html / https://express-rate-limit.mintlify.app/guides/troubleshooting-proxy-issues
@@ -120,6 +120,15 @@ You can create another configuration file in the **config** directory named **lo
120
120
 
121
121
  ## Changelog
122
122
 
123
+ * Version 1.1.5 (6/18/2025):
124
+ - Fixed "Error: invalid CSRF token" occurring during certain actions in the administrator panel
125
+
126
+ * Version 1.1.4.2 (6/18/2025):
127
+ - Updated dependencies
128
+
129
+ * Version 1.1.4.1 (1/1/2025):
130
+ - Updated dependencies
131
+
123
132
  * Version 1.1.4 (11/23/2024):
124
133
  - Switched to csrf-csrf library instead of csurf (no longer maintained) for CSRF protection
125
134
  - Added "numberOfProxies" parameter (default 1) to server configuration file
@@ -179,7 +188,7 @@ Un serveur pour mon jeu [SnakeIA](https://github.com/Eliastik/snakeia), écrit e
179
188
 
180
189
  ## À propos de ce serveur
181
190
 
182
- * Version 1.1.4 (23/11/2024)
191
+ * Version 1.1.5 (18/06/2025)
183
192
  * Made in France by Eliastik - [eliastiksofts.com](http://eliastiksofts.com) - Contact : [eliastiksofts.com/contact](http://eliastiksofts.com/contact)
184
193
  * Licence : GNU GPLv3 (voir le fichier LICENCE.txt)
185
194
 
@@ -245,7 +254,7 @@ Vous pouvez créer un fichier de configuration **local.json** dans le dossier **
245
254
  ````
246
255
  {
247
256
  "ServerConfig": {
248
- "version": "1.1.4", // La version du serveur
257
+ "version": "1.1.5", // La version du serveur
249
258
  "port": 3000, // Le port sur lequel lancer le server
250
259
  "proxyMode": false, // Mettez à true si votre serveur est derrière un proxy - par défaut false
251
260
  "numberOfProxies": 1, // Configure le nombre de proxies devant votre serveur. Par défaut 1. Voir : https://expressjs.com/en/guide/behind-proxies.html / https://express-rate-limit.mintlify.app/guides/troubleshooting-proxy-issues
@@ -291,6 +300,15 @@ Vous pouvez créer un fichier de configuration **local.json** dans le dossier **
291
300
 
292
301
  ## Journal des changements
293
302
 
303
+ * Version 1.1.5 (18/06/2025) :
304
+ - Correction de l’erreur "Error: invalid CSRF token" lors de certaines actions dans le panneau d’administration
305
+
306
+ * Version 1.1.4.2 (18/06/2025) :
307
+ - Mise à jour des dépendences
308
+
309
+ * Version 1.1.4.1 (1/1/2025) :
310
+ - Mise à jour des dépendences
311
+
294
312
  * Version 1.1.4 (23/11/2024) :
295
313
  - Passage à la bibliothèque logicielle csrf-csrf au lieu de csurf (qui n'était plus maintenue) pour la protection CSRF
296
314
  - Ajout du paramètre "numberOfProxies" (par défaut à 1) dans le fichier de configuration du serveur
@@ -353,7 +371,7 @@ Vous pouvez créer un fichier de configuration **local.json** dans le dossier **
353
371
 
354
372
  ## Déclaration de licence
355
373
 
356
- Copyright (C) 2020-2024 Eliastik (eliastiksofts.com)
374
+ Copyright (C) 2020-2025 Eliastik (eliastiksofts.com)
357
375
 
358
376
  Ce programme est un logiciel libre ; vous pouvez le redistribuer ou le modifier suivant les termes de la GNU General Public License telle que publiée par la Free Software Foundation ; soit la version 3 de la licence, soit (à votre gré) toute version ultérieure.
359
377
 
@@ -363,7 +381,7 @@ Vous devez avoir reçu une copie de la GNU General Public License en même temps
363
381
 
364
382
  ----
365
383
 
366
- Copyright (C) 2020-2024 Eliastik (eliastiksofts.com)
384
+ Copyright (C) 2020-2025 Eliastik (eliastiksofts.com)
367
385
 
368
386
  This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
369
387
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "ServerConfig": {
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "port": 3000,
5
5
  "proxyMode": false,
6
6
  "numberOfProxies": 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "snakeia-server",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "Server for multiplaying in SnakeIA (https://github.com/Eliastik/snakeia)",
5
5
  "main": "server.js",
6
6
  "scripts": {
@@ -18,14 +18,14 @@
18
18
  },
19
19
  "homepage": "https://github.com/Eliastik/snakeia-server#readme",
20
20
  "dependencies": {
21
- "body-parser": "^1.20.3",
22
- "config": "^3.3.12",
21
+ "body-parser": "^2.2.0",
22
+ "config": "^4.0.0",
23
23
  "cookie-parser": "^1.4.7",
24
- "csrf-csrf": "^3.0.8",
24
+ "csrf-csrf": "^4.0.3",
25
25
  "ejs": "^3.1.10",
26
- "express": "^4.21.1",
27
- "express-rate-limit": "^7.4.1",
28
- "html-entities": "^2.5.2",
26
+ "express": "^5.1.0",
27
+ "express-rate-limit": "^7.5.0",
28
+ "html-entities": "^2.6.0",
29
29
  "i18n": "^0.15.1",
30
30
  "jsonwebtoken": "^9.0.2",
31
31
  "node-fetch": "^3.3.2",
package/server.js CHANGED
@@ -96,6 +96,7 @@ i18n.configure({
96
96
 
97
97
  // Game modules
98
98
  const snakeia = require("snakeia");
99
+ const { randomUUID } = require("crypto");
99
100
  const Snake = snakeia.Snake;
100
101
  const Grid = snakeia.Grid;
101
102
  const GameConstants = snakeia.GameConstants;
@@ -908,7 +909,8 @@ app.use(i18n.init);
908
909
  // Rate limiter
909
910
  app.use("/authentication", rateLimit({
910
911
  windowMs: config.authentWindowMs,
911
- max: config.authentMaxRequest
912
+ max: config.authentMaxRequest,
913
+ validate: { trustProxy: false }
912
914
  }));
913
915
 
914
916
  // IP ban
@@ -1168,8 +1170,16 @@ function verifyFormAuthenticationAdmin(body) {
1168
1170
  }
1169
1171
 
1170
1172
  const csrfSecret = generateRandomJsonWebTokenSecretKey(jsonWebTokenSecretKeyAdmin);
1171
- const { doubleCsrfProtection, generateToken } = doubleCsrf({
1173
+ const { doubleCsrfProtection, generateCsrfToken } = doubleCsrf({
1172
1174
  getSecret: () => csrfSecret,
1175
+ getSessionIdentifier: (req) => req.cookies.tokenAdmin || randomUUID(),
1176
+ getCsrfTokenFromRequest: (req) => {
1177
+ return (
1178
+ req.headers["x-csrf-token"] ||
1179
+ req.body?._csrf ||
1180
+ req.query?._csrf
1181
+ );
1182
+ },
1173
1183
  cookieName: productionMode ? "__Host-snakeia-server.x-csrf-token" : "snakeia-server.x-csrf-token",
1174
1184
  cookieOptions: {
1175
1185
  sameSite: productionMode ? "strict" : "lax",
@@ -1206,7 +1216,7 @@ app.get("/admin", doubleCsrfProtection, function(req, res) {
1206
1216
  games: games,
1207
1217
  io: io,
1208
1218
  config: config,
1209
- csrfToken: generateToken(req, res, true),
1219
+ csrfToken: generateCsrfToken(req, res, { overwrite: true, validateOnReuse: true }),
1210
1220
  serverLog: logFile,
1211
1221
  errorLog: errorLogFile,
1212
1222
  getIPSocketIO: getIPSocketIO
@@ -1311,7 +1321,8 @@ app.use(function (err, req, res, next) {
1311
1321
 
1312
1322
  const adminRateLimiter = rateLimit({
1313
1323
  windowMs: config.authentWindowMs,
1314
- max: config.authentMaxRequest
1324
+ max: config.authentMaxRequest,
1325
+ validate: { trustProxy: false }
1315
1326
  });
1316
1327
 
1317
1328
  app.post("/admin", adminRateLimiter, function(req, res) {