not-node 6.3.13 → 6.3.15

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.3.13",
3
+ "version": "6.3.15",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,5 +1,13 @@
1
+ const { HttpExceptionForbidden } = require("../exceptions/http");
2
+
1
3
  module.exports = ({ getLogic, before, after }) => {
2
4
  class notGenericRoute {
5
+ static restrictRootAccess = false;
6
+ static exceptionOnRootAccess = HttpExceptionForbidden;
7
+ static exceptionParamsPacker = (prepared) => {
8
+ return [{ params: prepared }];
9
+ };
10
+
3
11
  static before() {
4
12
  return before(...arguments);
5
13
  }
@@ -9,6 +17,11 @@ module.exports = ({ getLogic, before, after }) => {
9
17
  }
10
18
 
11
19
  static async _create(req, res, next, prepared) {
20
+ if (this.restrictRootAccess) {
21
+ throw new this.exceptionOnRootAccess(
22
+ ...this.exceptionParamsPacker(prepared)
23
+ );
24
+ }
12
25
  prepared.root = true;
13
26
  return await getLogic().create(prepared);
14
27
  }
@@ -18,6 +31,11 @@ module.exports = ({ getLogic, before, after }) => {
18
31
  }
19
32
 
20
33
  static async _get(req, res, next, prepared) {
34
+ if (this.restrictRootAccess) {
35
+ throw new this.exceptionOnRootAccess(
36
+ ...this.exceptionParamsPacker(prepared)
37
+ );
38
+ }
21
39
  prepared.root = true;
22
40
  return await getLogic().get(prepared);
23
41
  }
@@ -27,6 +45,11 @@ module.exports = ({ getLogic, before, after }) => {
27
45
  }
28
46
 
29
47
  static async _getByID(req, res, next, prepared) {
48
+ if (this.restrictRootAccess) {
49
+ throw new this.exceptionOnRootAccess(
50
+ ...this.exceptionParamsPacker(prepared)
51
+ );
52
+ }
30
53
  prepared.root = true;
31
54
  return await getLogic().getByID(prepared);
32
55
  }
@@ -36,6 +59,11 @@ module.exports = ({ getLogic, before, after }) => {
36
59
  }
37
60
 
38
61
  static async _getRaw(req, res, next, prepared) {
62
+ if (this.restrictRootAccess) {
63
+ throw new this.exceptionOnRootAccess(
64
+ ...this.exceptionParamsPacker(prepared)
65
+ );
66
+ }
39
67
  prepared.root = true;
40
68
  return await getLogic().getRaw(prepared);
41
69
  }
@@ -45,6 +73,11 @@ module.exports = ({ getLogic, before, after }) => {
45
73
  }
46
74
 
47
75
  static async _update(req, res, next, prepared) {
76
+ if (this.restrictRootAccess) {
77
+ throw new this.exceptionOnRootAccess(
78
+ ...this.exceptionParamsPacker(prepared)
79
+ );
80
+ }
48
81
  prepared.root = true;
49
82
  return await getLogic().update(prepared);
50
83
  }
@@ -54,6 +87,11 @@ module.exports = ({ getLogic, before, after }) => {
54
87
  }
55
88
 
56
89
  static async _listAll(req, res, next, prepared) {
90
+ if (this.restrictRootAccess) {
91
+ throw new this.exceptionOnRootAccess(
92
+ ...this.exceptionParamsPacker(prepared)
93
+ );
94
+ }
57
95
  prepared.root = true;
58
96
  return await getLogic().listAll(prepared);
59
97
  }
@@ -63,6 +101,11 @@ module.exports = ({ getLogic, before, after }) => {
63
101
  }
64
102
 
65
103
  static async _listAndCount(req, res, next, prepared) {
104
+ if (this.restrictRootAccess) {
105
+ throw new this.exceptionOnRootAccess(
106
+ ...this.exceptionParamsPacker(prepared)
107
+ );
108
+ }
66
109
  prepared.root = true;
67
110
  return await getLogic().listAndCount(prepared);
68
111
  }
@@ -72,6 +115,11 @@ module.exports = ({ getLogic, before, after }) => {
72
115
  }
73
116
 
74
117
  static async _list(req, res, next, prepared) {
118
+ if (this.restrictRootAccess) {
119
+ throw new this.exceptionOnRootAccess(
120
+ ...this.exceptionParamsPacker(prepared)
121
+ );
122
+ }
75
123
  prepared.root = true;
76
124
  return await getLogic().list(prepared);
77
125
  }
@@ -81,6 +129,11 @@ module.exports = ({ getLogic, before, after }) => {
81
129
  }
82
130
 
83
131
  static async _count(req, res, next, prepared) {
132
+ if (this.restrictRootAccess) {
133
+ throw new this.exceptionOnRootAccess(
134
+ ...this.exceptionParamsPacker(prepared)
135
+ );
136
+ }
84
137
  prepared.root = true;
85
138
  return await getLogic().count(prepared);
86
139
  }
@@ -90,6 +143,11 @@ module.exports = ({ getLogic, before, after }) => {
90
143
  }
91
144
 
92
145
  static async _delete(req, res, next, prepared) {
146
+ if (this.restrictRootAccess) {
147
+ throw new this.exceptionOnRootAccess(
148
+ ...this.exceptionParamsPacker(prepared)
149
+ );
150
+ }
93
151
  prepared.root = true;
94
152
  return await getLogic().delete(prepared);
95
153
  }
@@ -28,6 +28,7 @@ module.exports = class notAppIdentity {
28
28
  uid: identity.getUserId(),
29
29
  sid: identity.getSessionId(),
30
30
  ip: getIP(req),
31
+ provider: identity.constructor.name,
31
32
  };
32
33
  }
33
34
 
package/src/types.js CHANGED
@@ -92,6 +92,7 @@
92
92
  * @property {string} uid //user identificator
93
93
  * @property {string} sid //user session identificator
94
94
  * @property {string} ip //request source ip
95
+ * @property {string} provider //provider class name
95
96
  */
96
97
 
97
98
  module.exports = {};
@@ -4,6 +4,7 @@ const {
4
4
  } = require("../../src/exceptions/http");
5
5
 
6
6
  const notAppIdentity = require("../../src/identity/index");
7
+ const IdentityProviderSession = require("../../src/identity/providers/session");
7
8
 
8
9
  module.exports = ({ Auth, expect }) => {
9
10
  describe("Routes", () => {
@@ -71,6 +72,7 @@ module.exports = ({ Auth, expect }) => {
71
72
  auth: false,
72
73
  role: [Auth.DEFAULT_USER_ROLE_FOR_GUEST],
73
74
  primaryRole: Auth.DEFAULT_USER_ROLE_FOR_GUEST,
75
+ provider: IdentityProviderSession.name,
74
76
  uid: null,
75
77
  sid: undefined,
76
78
  ip: "127.0.0.1",