@riocrypto/common-server 1.0.1907 → 1.0.1908
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.
|
@@ -6,7 +6,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.sendWithXSSGuard = void 0;
|
|
7
7
|
const xss_1 = __importDefault(require("xss"));
|
|
8
8
|
function sendWithXSSGuard(res, data, statusCode) {
|
|
9
|
-
const
|
|
9
|
+
const sanitize = (input) => {
|
|
10
|
+
if (typeof input === "string") {
|
|
11
|
+
return (0, xss_1.default)(input);
|
|
12
|
+
}
|
|
13
|
+
else if (typeof input === "object" && input !== null) {
|
|
14
|
+
const sanitizedObject = {};
|
|
15
|
+
for (const key in input) {
|
|
16
|
+
if (input.hasOwnProperty(key)) {
|
|
17
|
+
sanitizedObject[key] = sanitize(input[key]);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return sanitizedObject;
|
|
21
|
+
}
|
|
22
|
+
return input;
|
|
23
|
+
};
|
|
24
|
+
const sanitizedData = sanitize(data);
|
|
10
25
|
res.status(statusCode).send(sanitizedData);
|
|
11
26
|
}
|
|
12
27
|
exports.sendWithXSSGuard = sendWithXSSGuard;
|