not-node 6.2.12 → 6.2.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-node",
3
- "version": "6.2.12",
3
+ "version": "6.2.14",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -35,6 +35,7 @@
35
35
  "url": "https://github.com/interrupter/not-node/issues"
36
36
  },
37
37
  "dependencies": {
38
+ "xss": "*",
38
39
  "body-parser": "^1.20.1",
39
40
  "commander": "^9.5.0",
40
41
  "compression": "^1.7.4",
package/src/form/form.js CHANGED
@@ -327,9 +327,10 @@ class Form {
327
327
  }
328
328
 
329
329
  #extractByInstructionPipe({ results, instructions, fieldName, req }) {
330
- if (instructions.length === 0) {
330
+ if (!instructions || instructions.length === 0) {
331
331
  throw new FormExceptionExtractorForFieldIsUndefined(fieldName);
332
332
  }
333
+ //
333
334
  this.#extractByInstruction({
334
335
  results,
335
336
  instruction: instructions[0],
@@ -380,7 +381,7 @@ class Form {
380
381
 
381
382
  createInstructionFromRouteActionFields(
382
383
  req,
383
- mainInstruction = "fromBody",
384
+ mainInstruction = ["fromBody", "xss"],
384
385
  exceptions = {}
385
386
  ) {
386
387
  const result = {};
@@ -397,7 +398,7 @@ class Form {
397
398
 
398
399
  extractByInstructionsFromRouteActionFields(
399
400
  req,
400
- mainInstruction = "fromBody",
401
+ mainInstruction = ["fromBody", "xss"],
401
402
  exceptions = {}
402
403
  ) {
403
404
  const instructions = this.createInstructionFromRouteActionFields(
@@ -4,4 +4,5 @@
4
4
 
5
5
  module.exports = {
6
6
  stringToJSON: require("./stringToJSON.js"),
7
+ xss: require("./xss.js"),
7
8
  };
@@ -0,0 +1,2 @@
1
+ const xss = require("xss");
2
+ module.exports = (val) => xss(val);
@@ -0,0 +1,28 @@
1
+ //DB related validation tools
2
+ const Form = require("../form/form");
3
+ const { firstLetterToUpper } = require("../common");
4
+ //not-node
5
+ const { getIP } = require("../auth");
6
+ //form
7
+ const FIELDS = [
8
+ ["activeUserId", { required: true }, "not-node//objectId"],
9
+ ["activeUser", "not-node//requiredObject"],
10
+ ["ip", "not-node//ip"],
11
+ ];
12
+
13
+ module.exports = ({ MODULE_NAME, actionName }) => {
14
+ const FORM_NAME = `${MODULE_NAME}:${firstLetterToUpper(actionName)}Form`;
15
+ return class extends Form {
16
+ constructor({ app }) {
17
+ super({ FIELDS, FORM_NAME, app });
18
+ }
19
+
20
+ extract(req) {
21
+ return {
22
+ activeUser: req?.user,
23
+ activeUserId: req?.user._id,
24
+ ip: getIP(req),
25
+ };
26
+ }
27
+ };
28
+ };
@@ -2,6 +2,7 @@ module.exports.GenericLogic = require("./logic.js");
2
2
  module.exports.GenericRoute = require("./route.js");
3
3
  module.exports.GenericGetByIdForm = require("./form.getById.js");
4
4
  module.exports.GenericGetByIDForm = require("./form.getByID.js");
5
+ module.exports.GenericAuthorizedActionForm = require("./form.authorizedAction.js");
5
6
  module.exports.GenericListAndCountForm = require("./form.listAndCount.js");
6
7
 
7
8
  const FORMS = {};