archetecture security fix

This commit is contained in:
root
2026-06-11 03:22:12 -04:00
parent 6def9993da
commit 9483750161
3126 changed files with 177194 additions and 37211 deletions
+21
View File
@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRawBodyString = getRawBodyString;
exports.parseRawJsonBody = parseRawJsonBody;
const errors_1 = require("./errors");
function getRawBodyString(req) {
if (!Buffer.isBuffer(req.body)) {
throw new errors_1.ValidationError('Webhook route must be mounted with express.raw before JSON parsing');
}
return req.body.toString('utf8');
}
function parseRawJsonBody(req) {
const rawBody = getRawBodyString(req);
try {
return JSON.parse(rawBody);
}
catch {
throw new errors_1.ValidationError('Malformed webhook JSON');
}
}
//# sourceMappingURL=webhooks.js.map