vanta-api 1.0.0 → 1.0.1
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 +1 -1
- package/src/config.js +20 -30
- package/src/security-default-config.js +31 -0
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -1,31 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
],
|
|
7
|
-
|
|
8
|
-
forbiddenFields: [
|
|
9
|
-
"password",
|
|
10
|
-
],
|
|
11
|
-
|
|
12
|
-
accessLevels: {
|
|
13
|
-
guest: {
|
|
14
|
-
maxLimit: 50,
|
|
15
|
-
allowedPopulate: ["*"]
|
|
16
|
-
},
|
|
17
|
-
user: {
|
|
18
|
-
maxLimit: 100,
|
|
19
|
-
allowedPopulate: ["*"]
|
|
20
|
-
},
|
|
21
|
-
admin: {
|
|
22
|
-
maxLimit: 1000,
|
|
23
|
-
allowedPopulate: ["*"]
|
|
24
|
-
},
|
|
25
|
-
superAdmin: {
|
|
26
|
-
maxLimit: 1000,
|
|
27
|
-
allowedPopulate: ["*"]
|
|
28
|
-
},
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
import { securityConfig as defaultConfig } from "./security-default-config.js";
|
|
4
|
+
|
|
5
|
+
let userConfig = {};
|
|
29
6
|
|
|
30
|
-
|
|
31
|
-
|
|
7
|
+
try {
|
|
8
|
+
const userPath = path.resolve(process.cwd(), "security-config.js");
|
|
9
|
+
userConfig = (await import(userPath))?.securityConfig || {};
|
|
10
|
+
} catch (err) {
|
|
11
|
+
// کاربر security-config نداشت، مشکلی نیست
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const securityConfig = {
|
|
15
|
+
...defaultConfig,
|
|
16
|
+
...userConfig,
|
|
17
|
+
accessLevels: {
|
|
18
|
+
...defaultConfig.accessLevels,
|
|
19
|
+
...(userConfig.accessLevels || {}),
|
|
20
|
+
},
|
|
21
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const securityConfig = {
|
|
2
|
+
allowedOperators: [
|
|
3
|
+
"eq", "ne", "gt", "gte",
|
|
4
|
+
"lt", "lte", "in", "nin",
|
|
5
|
+
"regex", "exists", "size", "or", "and"
|
|
6
|
+
],
|
|
7
|
+
|
|
8
|
+
forbiddenFields: [
|
|
9
|
+
"password",
|
|
10
|
+
],
|
|
11
|
+
|
|
12
|
+
accessLevels: {
|
|
13
|
+
guest: {
|
|
14
|
+
maxLimit: 50,
|
|
15
|
+
allowedPopulate: ["*"]
|
|
16
|
+
},
|
|
17
|
+
user: {
|
|
18
|
+
maxLimit: 100,
|
|
19
|
+
allowedPopulate: ["*"]
|
|
20
|
+
},
|
|
21
|
+
admin: {
|
|
22
|
+
maxLimit: 1000,
|
|
23
|
+
allowedPopulate: ["*"]
|
|
24
|
+
},
|
|
25
|
+
superAdmin: {
|
|
26
|
+
maxLimit: 1000,
|
|
27
|
+
allowedPopulate: ["*"]
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|