feat(repair-uidhmac): add ratelimit

This commit is contained in:
Daniel López Guimaraes
2026-10-04 01:34:10 +01:00
parent a896f0b14b
commit 533bf42ce2
2 changed files with 12 additions and 1 deletions

View File

@@ -63,3 +63,13 @@ export const nascRatelimit = ratelimit({
},
message: nascError('null')
});
export const repairUIDHMACRatelimit = ratelimit({
windowMs: 5 * 60 * 1000, // 5mins
max: 30,
keyGenerator: (request: express.Request): string => {
const pid = request.body.pid?.trim();
return String(pid);
}
});

View File

@@ -1,6 +1,7 @@
import express from 'express';
import { LOG_ERROR } from '@/logger';
import { NEXAccount } from '@/models/nex-account';
import { repairUIDHMACRatelimit } from '@/middleware/ratelimit';
const router = express.Router();
@@ -9,7 +10,7 @@ const router = express.Router();
* Implementation of: https://api.pretendo.cc/v1/repair-uidhmac
* Description: Creates a new user PNID
*/
router.post('/', async (request: express.Request, response: express.Response): Promise<void> => {
router.post('/', repairUIDHMACRatelimit, async (request: express.Request, response: express.Response): Promise<void> => {
const pid = request.body.pid?.trim(); // * This has to be forwarded since this request comes from the websites server
const nexPassword = request.body.password?.trim();