@riocrypto/common-server 1.0.1906 → 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 sanitizedData = (0, xss_1.default)(data);
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;
@@ -27,9 +27,9 @@ const verifyCsrfToken = (req, res, next) => __awaiter(void 0, void 0, void 0, fu
27
27
  if (hasAccessToken &&
28
28
  ["POST", "PUT", "PATCH", "DELETE"].includes(req.method.toUpperCase())) {
29
29
  // Retrieve CSRF token from the header
30
- const csrfToken = Array.isArray(req.headers["X-CSRF-TOKEN"])
31
- ? req.headers["X-CSRF-TOKEN"][0]
32
- : req.headers["X-CSRF-TOKEN"];
30
+ const csrfToken = Array.isArray(req.headers["x-csrf-token"])
31
+ ? req.headers["x-csrf-token"][0]
32
+ : req.headers["x-csrf-token"];
33
33
  if (!csrfToken) {
34
34
  return res.status(403).json({ error: "CSRF token missing" });
35
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1906",
3
+ "version": "1.0.1908",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",