@strapi/utils 5.12.1 → 5.12.2
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/dist/async.js +28 -0
- package/dist/async.js.map +1 -0
- package/dist/async.mjs +24 -0
- package/dist/async.mjs.map +1 -0
- package/dist/content-types.js +201 -0
- package/dist/content-types.js.map +1 -0
- package/dist/content-types.mjs +167 -0
- package/dist/content-types.mjs.map +1 -0
- package/dist/convert-query-params.js +512 -0
- package/dist/convert-query-params.js.map +1 -0
- package/dist/convert-query-params.mjs +510 -0
- package/dist/convert-query-params.mjs.map +1 -0
- package/dist/env-helper.js +81 -0
- package/dist/env-helper.js.map +1 -0
- package/dist/env-helper.mjs +79 -0
- package/dist/env-helper.mjs.map +1 -0
- package/dist/errors.js +104 -0
- package/dist/errors.js.map +1 -0
- package/dist/errors.mjs +88 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/file.js +57 -0
- package/dist/file.js.map +1 -0
- package/dist/file.mjs +50 -0
- package/dist/file.mjs.map +1 -0
- package/dist/format-yup-error.js +19 -0
- package/dist/format-yup-error.js.map +1 -0
- package/dist/format-yup-error.mjs +17 -0
- package/dist/format-yup-error.mjs.map +1 -0
- package/dist/hooks.js +86 -0
- package/dist/hooks.js.map +1 -0
- package/dist/hooks.mjs +80 -0
- package/dist/hooks.mjs.map +1 -0
- package/dist/import-default.js +9 -0
- package/dist/import-default.js.map +1 -0
- package/dist/import-default.mjs +7 -0
- package/dist/import-default.mjs.map +1 -0
- package/dist/index.js +54 -4358
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -4317
- package/dist/index.mjs.map +1 -1
- package/dist/machine-id.js +17 -0
- package/dist/machine-id.js.map +1 -0
- package/dist/machine-id.mjs +15 -0
- package/dist/machine-id.mjs.map +1 -0
- package/dist/operators.js +79 -0
- package/dist/operators.js.map +1 -0
- package/dist/operators.mjs +76 -0
- package/dist/operators.mjs.map +1 -0
- package/dist/package-manager.js +36 -0
- package/dist/package-manager.js.map +1 -0
- package/dist/package-manager.mjs +33 -0
- package/dist/package-manager.mjs.map +1 -0
- package/dist/pagination.js +163 -0
- package/dist/pagination.js.map +1 -0
- package/dist/pagination.mjs +159 -0
- package/dist/pagination.mjs.map +1 -0
- package/dist/parse-type.js +140 -0
- package/dist/parse-type.js.map +1 -0
- package/dist/parse-type.mjs +118 -0
- package/dist/parse-type.mjs.map +1 -0
- package/dist/policy.js +33 -0
- package/dist/policy.js.map +1 -0
- package/dist/policy.mjs +30 -0
- package/dist/policy.mjs.map +1 -0
- package/dist/primitives/arrays.js +7 -0
- package/dist/primitives/arrays.js.map +1 -0
- package/dist/primitives/arrays.mjs +5 -0
- package/dist/primitives/arrays.mjs.map +1 -0
- package/dist/primitives/dates.js +11 -0
- package/dist/primitives/dates.js.map +1 -0
- package/dist/primitives/dates.mjs +9 -0
- package/dist/primitives/dates.mjs.map +1 -0
- package/dist/primitives/objects.js +13 -0
- package/dist/primitives/objects.js.map +1 -0
- package/dist/primitives/objects.mjs +11 -0
- package/dist/primitives/objects.mjs.map +1 -0
- package/dist/primitives/strings.js +49 -0
- package/dist/primitives/strings.js.map +1 -0
- package/dist/primitives/strings.mjs +38 -0
- package/dist/primitives/strings.mjs.map +1 -0
- package/dist/print-value.js +42 -0
- package/dist/print-value.js.map +1 -0
- package/dist/print-value.mjs +40 -0
- package/dist/print-value.mjs.map +1 -0
- package/dist/provider-factory.js +82 -0
- package/dist/provider-factory.js.map +1 -0
- package/dist/provider-factory.mjs +80 -0
- package/dist/provider-factory.mjs.map +1 -0
- package/dist/relations.js +54 -0
- package/dist/relations.js.map +1 -0
- package/dist/relations.mjs +45 -0
- package/dist/relations.mjs.map +1 -0
- package/dist/sanitize/index.js +195 -0
- package/dist/sanitize/index.js.map +1 -0
- package/dist/sanitize/index.mjs +194 -0
- package/dist/sanitize/index.mjs.map +1 -0
- package/dist/sanitize/sanitizers.js +173 -0
- package/dist/sanitize/sanitizers.js.map +1 -0
- package/dist/sanitize/sanitizers.mjs +166 -0
- package/dist/sanitize/sanitizers.mjs.map +1 -0
- package/dist/sanitize/visitors/expand-wildcard-populate.js +20 -0
- package/dist/sanitize/visitors/expand-wildcard-populate.js.map +1 -0
- package/dist/sanitize/visitors/expand-wildcard-populate.mjs +18 -0
- package/dist/sanitize/visitors/expand-wildcard-populate.mjs.map +1 -0
- package/dist/sanitize/visitors/index.js +22 -0
- package/dist/sanitize/visitors/index.js.map +1 -0
- package/dist/sanitize/visitors/index.mjs +9 -0
- package/dist/sanitize/visitors/index.mjs.map +1 -0
- package/dist/sanitize/visitors/remove-disallowed-fields.js +87 -0
- package/dist/sanitize/visitors/remove-disallowed-fields.js.map +1 -0
- package/dist/sanitize/visitors/remove-disallowed-fields.mjs +85 -0
- package/dist/sanitize/visitors/remove-disallowed-fields.mjs.map +1 -0
- package/dist/sanitize/visitors/remove-dynamic-zones.js +12 -0
- package/dist/sanitize/visitors/remove-dynamic-zones.js.map +1 -0
- package/dist/sanitize/visitors/remove-dynamic-zones.mjs +10 -0
- package/dist/sanitize/visitors/remove-dynamic-zones.mjs.map +1 -0
- package/dist/sanitize/visitors/remove-morph-to-relations.js +12 -0
- package/dist/sanitize/visitors/remove-morph-to-relations.js.map +1 -0
- package/dist/sanitize/visitors/remove-morph-to-relations.mjs +10 -0
- package/dist/sanitize/visitors/remove-morph-to-relations.mjs.map +1 -0
- package/dist/sanitize/visitors/remove-password.js +10 -0
- package/dist/sanitize/visitors/remove-password.js.map +1 -0
- package/dist/sanitize/visitors/remove-password.mjs +8 -0
- package/dist/sanitize/visitors/remove-password.mjs.map +1 -0
- package/dist/sanitize/visitors/remove-private.js +16 -0
- package/dist/sanitize/visitors/remove-private.js.map +1 -0
- package/dist/sanitize/visitors/remove-private.mjs +14 -0
- package/dist/sanitize/visitors/remove-private.mjs.map +1 -0
- package/dist/sanitize/visitors/remove-restricted-fields.js +28 -0
- package/dist/sanitize/visitors/remove-restricted-fields.js.map +1 -0
- package/dist/sanitize/visitors/remove-restricted-fields.mjs +26 -0
- package/dist/sanitize/visitors/remove-restricted-fields.mjs.map +1 -0
- package/dist/sanitize/visitors/remove-restricted-relations.js +116 -0
- package/dist/sanitize/visitors/remove-restricted-relations.js.map +1 -0
- package/dist/sanitize/visitors/remove-restricted-relations.mjs +114 -0
- package/dist/sanitize/visitors/remove-restricted-relations.mjs.map +1 -0
- package/dist/set-creator-fields.js +18 -0
- package/dist/set-creator-fields.js.map +1 -0
- package/dist/set-creator-fields.mjs +16 -0
- package/dist/set-creator-fields.mjs.map +1 -0
- package/dist/template.js +18 -0
- package/dist/template.js.map +1 -0
- package/dist/template.mjs +15 -0
- package/dist/template.mjs.map +1 -0
- package/dist/traverse/factory.js +158 -0
- package/dist/traverse/factory.js.map +1 -0
- package/dist/traverse/factory.mjs +156 -0
- package/dist/traverse/factory.mjs.map +1 -0
- package/dist/traverse/index.js +14 -0
- package/dist/traverse/index.js.map +1 -0
- package/dist/traverse/index.mjs +5 -0
- package/dist/traverse/index.mjs.map +1 -0
- package/dist/traverse/query-fields.js +41 -0
- package/dist/traverse/query-fields.js.map +1 -0
- package/dist/traverse/query-fields.mjs +39 -0
- package/dist/traverse/query-fields.mjs.map +1 -0
- package/dist/traverse/query-filters.js +114 -0
- package/dist/traverse/query-filters.js.map +1 -0
- package/dist/traverse/query-filters.mjs +112 -0
- package/dist/traverse/query-filters.mjs.map +1 -0
- package/dist/traverse/query-populate.js +280 -0
- package/dist/traverse/query-populate.js.map +1 -0
- package/dist/traverse/query-populate.mjs +278 -0
- package/dist/traverse/query-populate.mjs.map +1 -0
- package/dist/traverse/query-sort.js +144 -0
- package/dist/traverse/query-sort.js.map +1 -0
- package/dist/traverse/query-sort.mjs +142 -0
- package/dist/traverse/query-sort.mjs.map +1 -0
- package/dist/traverse-entity.js +170 -0
- package/dist/traverse-entity.js.map +1 -0
- package/dist/traverse-entity.mjs +168 -0
- package/dist/traverse-entity.mjs.map +1 -0
- package/dist/validate/index.js +218 -0
- package/dist/validate/index.js.map +1 -0
- package/dist/validate/index.mjs +217 -0
- package/dist/validate/index.mjs.map +1 -0
- package/dist/validate/utils.js +27 -0
- package/dist/validate/utils.js.map +1 -0
- package/dist/validate/utils.mjs +24 -0
- package/dist/validate/utils.mjs.map +1 -0
- package/dist/validate/validators.js +369 -0
- package/dist/validate/validators.js.map +1 -0
- package/dist/validate/validators.mjs +356 -0
- package/dist/validate/validators.mjs.map +1 -0
- package/dist/validate/visitors/index.js +22 -0
- package/dist/validate/visitors/index.js.map +1 -0
- package/dist/validate/visitors/index.mjs +9 -0
- package/dist/validate/visitors/index.mjs.map +1 -0
- package/dist/validate/visitors/throw-disallowed-fields.js +91 -0
- package/dist/validate/visitors/throw-disallowed-fields.js.map +1 -0
- package/dist/validate/visitors/throw-disallowed-fields.mjs +89 -0
- package/dist/validate/visitors/throw-disallowed-fields.mjs.map +1 -0
- package/dist/validate/visitors/throw-dynamic-zones.js +16 -0
- package/dist/validate/visitors/throw-dynamic-zones.js.map +1 -0
- package/dist/validate/visitors/throw-dynamic-zones.mjs +14 -0
- package/dist/validate/visitors/throw-dynamic-zones.mjs.map +1 -0
- package/dist/validate/visitors/throw-morph-to-relations.js +16 -0
- package/dist/validate/visitors/throw-morph-to-relations.js.map +1 -0
- package/dist/validate/visitors/throw-morph-to-relations.mjs +14 -0
- package/dist/validate/visitors/throw-morph-to-relations.mjs.map +1 -0
- package/dist/validate/visitors/throw-password.js +15 -0
- package/dist/validate/visitors/throw-password.js.map +1 -0
- package/dist/validate/visitors/throw-password.mjs +13 -0
- package/dist/validate/visitors/throw-password.mjs.map +1 -0
- package/dist/validate/visitors/throw-private.js +20 -0
- package/dist/validate/visitors/throw-private.js.map +1 -0
- package/dist/validate/visitors/throw-private.mjs +18 -0
- package/dist/validate/visitors/throw-private.mjs.map +1 -0
- package/dist/validate/visitors/throw-restricted-fields.js +36 -0
- package/dist/validate/visitors/throw-restricted-fields.js.map +1 -0
- package/dist/validate/visitors/throw-restricted-fields.mjs +34 -0
- package/dist/validate/visitors/throw-restricted-fields.mjs.map +1 -0
- package/dist/validate/visitors/throw-restricted-relations.js +125 -0
- package/dist/validate/visitors/throw-restricted-relations.js.map +1 -0
- package/dist/validate/visitors/throw-restricted-relations.mjs +123 -0
- package/dist/validate/visitors/throw-restricted-relations.mjs.map +1 -0
- package/dist/validate/visitors/throw-unrecognized-fields.js +66 -0
- package/dist/validate/visitors/throw-unrecognized-fields.js.map +1 -0
- package/dist/validate/visitors/throw-unrecognized-fields.mjs +64 -0
- package/dist/validate/visitors/throw-unrecognized-fields.mjs.map +1 -0
- package/dist/validators.js +60 -0
- package/dist/validators.js.map +1 -0
- package/dist/validators.mjs +37 -0
- package/dist/validators.mjs.map +1 -0
- package/dist/yup.js +101 -0
- package/dist/yup.js.map +1 -0
- package/dist/yup.mjs +74 -0
- package/dist/yup.mjs.map +1 -0
- package/dist/zod.js +31 -0
- package/dist/zod.js.map +1 -0
- package/dist/zod.mjs +29 -0
- package/dist/zod.mjs.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expand-wildcard-populate.mjs","sources":["../../../src/sanitize/visitors/expand-wildcard-populate.ts"],"sourcesContent":["import type { Visitor } from '../../traverse/factory';\n\nconst visitor: Visitor = ({ schema, key, value }, { set }) => {\n if (key === '' && value === '*') {\n const { attributes } = schema;\n\n const newPopulateQuery = Object.entries(attributes)\n .filter(([, attribute]) =>\n ['relation', 'component', 'media', 'dynamiczone'].includes(attribute.type)\n )\n .reduce<Record<string, true>>((acc, [key]) => ({ ...acc, [key]: true }), {});\n\n set('', newPopulateQuery);\n }\n};\n\nexport default visitor;\n"],"names":["visitor","schema","key","value","set","attributes","newPopulateQuery","Object","entries","filter","attribute","includes","type","reduce","acc"],"mappings":"AAEA,MAAMA,OAAmB,GAAA,CAAC,EAAEC,MAAM,EAAEC,GAAG,EAAEC,KAAK,EAAE,EAAE,EAAEC,GAAG,EAAE,GAAA;IACvD,IAAIF,GAAAA,KAAQ,EAAMC,IAAAA,KAAAA,KAAU,GAAK,EAAA;QAC/B,MAAM,EAAEE,UAAU,EAAE,GAAGJ,MAAAA;QAEvB,MAAMK,gBAAAA,GAAmBC,MAAOC,CAAAA,OAAO,CAACH,UAAAA,CAAAA,CACrCI,MAAM,CAAC,CAAC,GAAGC,SAAAA,CAAU,GACpB;AAAC,gBAAA,UAAA;AAAY,gBAAA,WAAA;AAAa,gBAAA,OAAA;AAAS,gBAAA;AAAc,aAAA,CAACC,QAAQ,CAACD,SAAUE,CAAAA,IAAI,CAE1EC,CAAAA,CAAAA,MAAM,CAAuB,CAACC,GAAK,EAAA,CAACZ,GAAI,CAAA,IAAM;AAAE,gBAAA,GAAGY,GAAG;AAAE,gBAAA,CAACZ,MAAM;AAAK,aAAA,GAAI,EAAC,CAAA;AAE5EE,QAAAA,GAAAA,CAAI,EAAIE,EAAAA,gBAAAA,CAAAA;AACV;AACF;;;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var removePassword = require('./remove-password.js');
|
|
4
|
+
var removePrivate = require('./remove-private.js');
|
|
5
|
+
var removeRestrictedRelations = require('./remove-restricted-relations.js');
|
|
6
|
+
var removeMorphToRelations = require('./remove-morph-to-relations.js');
|
|
7
|
+
var removeDynamicZones = require('./remove-dynamic-zones.js');
|
|
8
|
+
var removeDisallowedFields = require('./remove-disallowed-fields.js');
|
|
9
|
+
var removeRestrictedFields = require('./remove-restricted-fields.js');
|
|
10
|
+
var expandWildcardPopulate = require('./expand-wildcard-populate.js');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
exports.removePassword = removePassword;
|
|
15
|
+
exports.removePrivate = removePrivate;
|
|
16
|
+
exports.removeRestrictedRelations = removeRestrictedRelations;
|
|
17
|
+
exports.removeMorphToRelations = removeMorphToRelations;
|
|
18
|
+
exports.removeDynamicZones = removeDynamicZones;
|
|
19
|
+
exports.removeDisallowedFields = removeDisallowedFields;
|
|
20
|
+
exports.removeRestrictedFields = removeRestrictedFields;
|
|
21
|
+
exports.expandWildcardPopulate = expandWildcardPopulate;
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as removePassword } from './remove-password.mjs';
|
|
2
|
+
export { default as removePrivate } from './remove-private.mjs';
|
|
3
|
+
export { default as removeRestrictedRelations } from './remove-restricted-relations.mjs';
|
|
4
|
+
export { default as removeMorphToRelations } from './remove-morph-to-relations.mjs';
|
|
5
|
+
export { default as removeDynamicZones } from './remove-dynamic-zones.mjs';
|
|
6
|
+
export { default as removeDisallowedFields } from './remove-disallowed-fields.mjs';
|
|
7
|
+
export { default as removeRestrictedFields } from './remove-restricted-fields.mjs';
|
|
8
|
+
export { default as expandWildcardPopulate } from './expand-wildcard-populate.mjs';
|
|
9
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fp = require('lodash/fp');
|
|
4
|
+
|
|
5
|
+
var removeDisallowedFields = ((allowedFields = null)=>({ key, path: { attribute: path } }, { remove })=>{
|
|
6
|
+
// All fields are allowed
|
|
7
|
+
if (allowedFields === null) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
// Throw on invalid formats
|
|
11
|
+
if (!(fp.isArray(allowedFields) && allowedFields.every(fp.isString))) {
|
|
12
|
+
throw new TypeError(`Expected array of strings for allowedFields but got "${typeof allowedFields}"`);
|
|
13
|
+
}
|
|
14
|
+
if (fp.isNil(path)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const containedPaths = getContainedPaths(path);
|
|
18
|
+
/**
|
|
19
|
+
* Tells if the current path should be kept or not based
|
|
20
|
+
* on the success of the check functions for any of the allowed paths.
|
|
21
|
+
*
|
|
22
|
+
* The check functions are defined as follow:
|
|
23
|
+
*
|
|
24
|
+
* `containedPaths.includes(p)`
|
|
25
|
+
* @example
|
|
26
|
+
* ```js
|
|
27
|
+
* const path = 'foo.bar.field';
|
|
28
|
+
* const p = 'foo.bar';
|
|
29
|
+
* // it should match
|
|
30
|
+
*
|
|
31
|
+
* const path = 'foo.bar.field';
|
|
32
|
+
* const p = 'bar.foo';
|
|
33
|
+
* // it shouldn't match
|
|
34
|
+
*
|
|
35
|
+
* const path = 'foo.bar';
|
|
36
|
+
* const p = 'foo.bar.field';
|
|
37
|
+
* // it should match but isn't handled by this check
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* `p.startsWith(`${path}.`)`
|
|
41
|
+
* @example
|
|
42
|
+
* ```js
|
|
43
|
+
* const path = 'foo.bar';
|
|
44
|
+
* const p = 'foo.bar.field';
|
|
45
|
+
* // it should match
|
|
46
|
+
*
|
|
47
|
+
* const path = 'foo.bar.field';
|
|
48
|
+
* const p = 'bar.foo';
|
|
49
|
+
* // it shouldn't match
|
|
50
|
+
*
|
|
51
|
+
* const path = 'foo.bar.field';
|
|
52
|
+
* const p = 'foo.bar';
|
|
53
|
+
* // it should match but isn't handled by this check
|
|
54
|
+
* ```
|
|
55
|
+
*/ const isPathAllowed = allowedFields.some((p)=>containedPaths.includes(p) || p.startsWith(`${path}.`));
|
|
56
|
+
if (isPathAllowed) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
// Remove otherwise
|
|
60
|
+
remove(key);
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* Retrieve the list of allowed paths based on the given path
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```js
|
|
67
|
+
* const containedPaths = getContainedPaths('foo');
|
|
68
|
+
* // ['foo']
|
|
69
|
+
*
|
|
70
|
+
* * const containedPaths = getContainedPaths('foo.bar');
|
|
71
|
+
* // ['foo', 'foo.bar']
|
|
72
|
+
*
|
|
73
|
+
* * const containedPaths = getContainedPaths('foo.bar.field');
|
|
74
|
+
* // ['foo', 'foo.bar', 'foo.bar.field']
|
|
75
|
+
* ```
|
|
76
|
+
*/ const getContainedPaths = (path)=>{
|
|
77
|
+
const parts = fp.toPath(path);
|
|
78
|
+
return parts.reduce((acc, value, index, list)=>{
|
|
79
|
+
return [
|
|
80
|
+
...acc,
|
|
81
|
+
list.slice(0, index + 1).join('.')
|
|
82
|
+
];
|
|
83
|
+
}, []);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
module.exports = removeDisallowedFields;
|
|
87
|
+
//# sourceMappingURL=remove-disallowed-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-disallowed-fields.js","sources":["../../../src/sanitize/visitors/remove-disallowed-fields.ts"],"sourcesContent":["import { isArray, isNil, isString, toPath } from 'lodash/fp';\nimport type { Visitor } from '../../traverse/factory';\n\nexport default (allowedFields: string[] | null = null): Visitor =>\n ({ key, path: { attribute: path } }, { remove }) => {\n // All fields are allowed\n if (allowedFields === null) {\n return;\n }\n\n // Throw on invalid formats\n if (!(isArray(allowedFields) && allowedFields.every(isString))) {\n throw new TypeError(\n `Expected array of strings for allowedFields but got \"${typeof allowedFields}\"`\n );\n }\n\n if (isNil(path)) {\n return;\n }\n\n const containedPaths = getContainedPaths(path);\n\n /**\n * Tells if the current path should be kept or not based\n * on the success of the check functions for any of the allowed paths.\n *\n * The check functions are defined as follow:\n *\n * `containedPaths.includes(p)`\n * @example\n * ```js\n * const path = 'foo.bar.field';\n * const p = 'foo.bar';\n * // it should match\n *\n * const path = 'foo.bar.field';\n * const p = 'bar.foo';\n * // it shouldn't match\n *\n * const path = 'foo.bar';\n * const p = 'foo.bar.field';\n * // it should match but isn't handled by this check\n * ```\n *\n * `p.startsWith(`${path}.`)`\n * @example\n * ```js\n * const path = 'foo.bar';\n * const p = 'foo.bar.field';\n * // it should match\n *\n * const path = 'foo.bar.field';\n * const p = 'bar.foo';\n * // it shouldn't match\n *\n * const path = 'foo.bar.field';\n * const p = 'foo.bar';\n * // it should match but isn't handled by this check\n * ```\n */\n const isPathAllowed = allowedFields.some(\n (p) => containedPaths.includes(p) || p.startsWith(`${path}.`)\n );\n\n if (isPathAllowed) {\n return;\n }\n\n // Remove otherwise\n remove(key);\n };\n\n/**\n * Retrieve the list of allowed paths based on the given path\n *\n * @example\n * ```js\n * const containedPaths = getContainedPaths('foo');\n * // ['foo']\n *\n * * const containedPaths = getContainedPaths('foo.bar');\n * // ['foo', 'foo.bar']\n *\n * * const containedPaths = getContainedPaths('foo.bar.field');\n * // ['foo', 'foo.bar', 'foo.bar.field']\n * ```\n */\nconst getContainedPaths = (path: string) => {\n const parts = toPath(path);\n\n return parts.reduce((acc, value, index, list) => {\n return [...acc, list.slice(0, index + 1).join('.')];\n }, [] as string[]);\n};\n"],"names":["allowedFields","key","path","attribute","remove","isArray","every","isString","TypeError","isNil","containedPaths","getContainedPaths","isPathAllowed","some","p","includes","startsWith","parts","toPath","reduce","acc","value","index","list","slice","join"],"mappings":";;;;AAGA,6BAAe,CAAA,CAACA,aAAAA,GAAiC,IAAI,GACnD,CAAC,EAAEC,GAAG,EAAEC,IAAM,EAAA,EAAEC,WAAWD,IAAI,EAAE,EAAE,EAAE,EAAEE,MAAM,EAAE,GAAA;;AAE7C,QAAA,IAAIJ,kBAAkB,IAAM,EAAA;AAC1B,YAAA;AACF;;QAGA,IAAI,EAAEK,UAAQL,CAAAA,aAAAA,CAAAA,IAAkBA,cAAcM,KAAK,CAACC,YAAQ,CAAI,EAAA;YAC9D,MAAM,IAAIC,UACR,CAAC,qDAAqD,EAAE,OAAOR,aAAAA,CAAc,CAAC,CAAC,CAAA;AAEnF;AAEA,QAAA,IAAIS,SAAMP,IAAO,CAAA,EAAA;AACf,YAAA;AACF;AAEA,QAAA,MAAMQ,iBAAiBC,iBAAkBT,CAAAA,IAAAA,CAAAA;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCC,QACD,MAAMU,aAAgBZ,GAAAA,aAAAA,CAAca,IAAI,CACtC,CAACC,IAAMJ,cAAeK,CAAAA,QAAQ,CAACD,CAAAA,CAAAA,IAAMA,EAAEE,UAAU,CAAC,CAAC,EAAEd,IAAAA,CAAK,CAAC,CAAC,CAAA,CAAA;AAG9D,QAAA,IAAIU,aAAe,EAAA;AACjB,YAAA;AACF;;QAGAR,MAAOH,CAAAA,GAAAA,CAAAA;AACT,KAAA;AAEF;;;;;;;;;;;;;;IAeA,MAAMU,oBAAoB,CAACT,IAAAA,GAAAA;AACzB,IAAA,MAAMe,QAAQC,SAAOhB,CAAAA,IAAAA,CAAAA;AAErB,IAAA,OAAOe,MAAME,MAAM,CAAC,CAACC,GAAAA,EAAKC,OAAOC,KAAOC,EAAAA,IAAAA,GAAAA;QACtC,OAAO;AAAIH,YAAAA,GAAAA,GAAAA;AAAKG,YAAAA,IAAAA,CAAKC,KAAK,CAAC,CAAA,EAAGF,KAAQ,GAAA,CAAA,CAAA,CAAGG,IAAI,CAAC,GAAA;AAAK,SAAA;AACrD,KAAA,EAAG,EAAE,CAAA;AACP,CAAA;;;;"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { isArray, isString, isNil, toPath } from 'lodash/fp';
|
|
2
|
+
|
|
3
|
+
var removeDisallowedFields = ((allowedFields = null)=>({ key, path: { attribute: path } }, { remove })=>{
|
|
4
|
+
// All fields are allowed
|
|
5
|
+
if (allowedFields === null) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
// Throw on invalid formats
|
|
9
|
+
if (!(isArray(allowedFields) && allowedFields.every(isString))) {
|
|
10
|
+
throw new TypeError(`Expected array of strings for allowedFields but got "${typeof allowedFields}"`);
|
|
11
|
+
}
|
|
12
|
+
if (isNil(path)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const containedPaths = getContainedPaths(path);
|
|
16
|
+
/**
|
|
17
|
+
* Tells if the current path should be kept or not based
|
|
18
|
+
* on the success of the check functions for any of the allowed paths.
|
|
19
|
+
*
|
|
20
|
+
* The check functions are defined as follow:
|
|
21
|
+
*
|
|
22
|
+
* `containedPaths.includes(p)`
|
|
23
|
+
* @example
|
|
24
|
+
* ```js
|
|
25
|
+
* const path = 'foo.bar.field';
|
|
26
|
+
* const p = 'foo.bar';
|
|
27
|
+
* // it should match
|
|
28
|
+
*
|
|
29
|
+
* const path = 'foo.bar.field';
|
|
30
|
+
* const p = 'bar.foo';
|
|
31
|
+
* // it shouldn't match
|
|
32
|
+
*
|
|
33
|
+
* const path = 'foo.bar';
|
|
34
|
+
* const p = 'foo.bar.field';
|
|
35
|
+
* // it should match but isn't handled by this check
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* `p.startsWith(`${path}.`)`
|
|
39
|
+
* @example
|
|
40
|
+
* ```js
|
|
41
|
+
* const path = 'foo.bar';
|
|
42
|
+
* const p = 'foo.bar.field';
|
|
43
|
+
* // it should match
|
|
44
|
+
*
|
|
45
|
+
* const path = 'foo.bar.field';
|
|
46
|
+
* const p = 'bar.foo';
|
|
47
|
+
* // it shouldn't match
|
|
48
|
+
*
|
|
49
|
+
* const path = 'foo.bar.field';
|
|
50
|
+
* const p = 'foo.bar';
|
|
51
|
+
* // it should match but isn't handled by this check
|
|
52
|
+
* ```
|
|
53
|
+
*/ const isPathAllowed = allowedFields.some((p)=>containedPaths.includes(p) || p.startsWith(`${path}.`));
|
|
54
|
+
if (isPathAllowed) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
// Remove otherwise
|
|
58
|
+
remove(key);
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* Retrieve the list of allowed paths based on the given path
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```js
|
|
65
|
+
* const containedPaths = getContainedPaths('foo');
|
|
66
|
+
* // ['foo']
|
|
67
|
+
*
|
|
68
|
+
* * const containedPaths = getContainedPaths('foo.bar');
|
|
69
|
+
* // ['foo', 'foo.bar']
|
|
70
|
+
*
|
|
71
|
+
* * const containedPaths = getContainedPaths('foo.bar.field');
|
|
72
|
+
* // ['foo', 'foo.bar', 'foo.bar.field']
|
|
73
|
+
* ```
|
|
74
|
+
*/ const getContainedPaths = (path)=>{
|
|
75
|
+
const parts = toPath(path);
|
|
76
|
+
return parts.reduce((acc, value, index, list)=>{
|
|
77
|
+
return [
|
|
78
|
+
...acc,
|
|
79
|
+
list.slice(0, index + 1).join('.')
|
|
80
|
+
];
|
|
81
|
+
}, []);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export { removeDisallowedFields as default };
|
|
85
|
+
//# sourceMappingURL=remove-disallowed-fields.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-disallowed-fields.mjs","sources":["../../../src/sanitize/visitors/remove-disallowed-fields.ts"],"sourcesContent":["import { isArray, isNil, isString, toPath } from 'lodash/fp';\nimport type { Visitor } from '../../traverse/factory';\n\nexport default (allowedFields: string[] | null = null): Visitor =>\n ({ key, path: { attribute: path } }, { remove }) => {\n // All fields are allowed\n if (allowedFields === null) {\n return;\n }\n\n // Throw on invalid formats\n if (!(isArray(allowedFields) && allowedFields.every(isString))) {\n throw new TypeError(\n `Expected array of strings for allowedFields but got \"${typeof allowedFields}\"`\n );\n }\n\n if (isNil(path)) {\n return;\n }\n\n const containedPaths = getContainedPaths(path);\n\n /**\n * Tells if the current path should be kept or not based\n * on the success of the check functions for any of the allowed paths.\n *\n * The check functions are defined as follow:\n *\n * `containedPaths.includes(p)`\n * @example\n * ```js\n * const path = 'foo.bar.field';\n * const p = 'foo.bar';\n * // it should match\n *\n * const path = 'foo.bar.field';\n * const p = 'bar.foo';\n * // it shouldn't match\n *\n * const path = 'foo.bar';\n * const p = 'foo.bar.field';\n * // it should match but isn't handled by this check\n * ```\n *\n * `p.startsWith(`${path}.`)`\n * @example\n * ```js\n * const path = 'foo.bar';\n * const p = 'foo.bar.field';\n * // it should match\n *\n * const path = 'foo.bar.field';\n * const p = 'bar.foo';\n * // it shouldn't match\n *\n * const path = 'foo.bar.field';\n * const p = 'foo.bar';\n * // it should match but isn't handled by this check\n * ```\n */\n const isPathAllowed = allowedFields.some(\n (p) => containedPaths.includes(p) || p.startsWith(`${path}.`)\n );\n\n if (isPathAllowed) {\n return;\n }\n\n // Remove otherwise\n remove(key);\n };\n\n/**\n * Retrieve the list of allowed paths based on the given path\n *\n * @example\n * ```js\n * const containedPaths = getContainedPaths('foo');\n * // ['foo']\n *\n * * const containedPaths = getContainedPaths('foo.bar');\n * // ['foo', 'foo.bar']\n *\n * * const containedPaths = getContainedPaths('foo.bar.field');\n * // ['foo', 'foo.bar', 'foo.bar.field']\n * ```\n */\nconst getContainedPaths = (path: string) => {\n const parts = toPath(path);\n\n return parts.reduce((acc, value, index, list) => {\n return [...acc, list.slice(0, index + 1).join('.')];\n }, [] as string[]);\n};\n"],"names":["allowedFields","key","path","attribute","remove","isArray","every","isString","TypeError","isNil","containedPaths","getContainedPaths","isPathAllowed","some","p","includes","startsWith","parts","toPath","reduce","acc","value","index","list","slice","join"],"mappings":";;AAGA,6BAAe,CAAA,CAACA,aAAAA,GAAiC,IAAI,GACnD,CAAC,EAAEC,GAAG,EAAEC,IAAM,EAAA,EAAEC,WAAWD,IAAI,EAAE,EAAE,EAAE,EAAEE,MAAM,EAAE,GAAA;;AAE7C,QAAA,IAAIJ,kBAAkB,IAAM,EAAA;AAC1B,YAAA;AACF;;QAGA,IAAI,EAAEK,OAAQL,CAAAA,aAAAA,CAAAA,IAAkBA,cAAcM,KAAK,CAACC,SAAQ,CAAI,EAAA;YAC9D,MAAM,IAAIC,UACR,CAAC,qDAAqD,EAAE,OAAOR,aAAAA,CAAc,CAAC,CAAC,CAAA;AAEnF;AAEA,QAAA,IAAIS,MAAMP,IAAO,CAAA,EAAA;AACf,YAAA;AACF;AAEA,QAAA,MAAMQ,iBAAiBC,iBAAkBT,CAAAA,IAAAA,CAAAA;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCC,QACD,MAAMU,aAAgBZ,GAAAA,aAAAA,CAAca,IAAI,CACtC,CAACC,IAAMJ,cAAeK,CAAAA,QAAQ,CAACD,CAAAA,CAAAA,IAAMA,EAAEE,UAAU,CAAC,CAAC,EAAEd,IAAAA,CAAK,CAAC,CAAC,CAAA,CAAA;AAG9D,QAAA,IAAIU,aAAe,EAAA;AACjB,YAAA;AACF;;QAGAR,MAAOH,CAAAA,GAAAA,CAAAA;AACT,KAAA;AAEF;;;;;;;;;;;;;;IAeA,MAAMU,oBAAoB,CAACT,IAAAA,GAAAA;AACzB,IAAA,MAAMe,QAAQC,MAAOhB,CAAAA,IAAAA,CAAAA;AAErB,IAAA,OAAOe,MAAME,MAAM,CAAC,CAACC,GAAAA,EAAKC,OAAOC,KAAOC,EAAAA,IAAAA,GAAAA;QACtC,OAAO;AAAIH,YAAAA,GAAAA,GAAAA;AAAKG,YAAAA,IAAAA,CAAKC,KAAK,CAAC,CAAA,EAAGF,KAAQ,GAAA,CAAA,CAAA,CAAGG,IAAI,CAAC,GAAA;AAAK,SAAA;AACrD,KAAA,EAAG,EAAE,CAAA;AACP,CAAA;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var contentTypes = require('../../content-types.js');
|
|
4
|
+
|
|
5
|
+
const visitor = ({ key, attribute }, { remove })=>{
|
|
6
|
+
if (contentTypes.isDynamicZoneAttribute(attribute)) {
|
|
7
|
+
remove(key);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
module.exports = visitor;
|
|
12
|
+
//# sourceMappingURL=remove-dynamic-zones.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-dynamic-zones.js","sources":["../../../src/sanitize/visitors/remove-dynamic-zones.ts"],"sourcesContent":["import { isDynamicZoneAttribute } from '../../content-types';\nimport type { Visitor } from '../../traverse/factory';\n\nconst visitor: Visitor = ({ key, attribute }, { remove }) => {\n if (isDynamicZoneAttribute(attribute)) {\n remove(key);\n }\n};\n\nexport default visitor;\n"],"names":["visitor","key","attribute","remove","isDynamicZoneAttribute"],"mappings":";;;;AAGMA,MAAAA,OAAAA,GAAmB,CAAC,EAAEC,GAAG,EAAEC,SAAS,EAAE,EAAE,EAAEC,MAAM,EAAE,GAAA;AACtD,IAAA,IAAIC,oCAAuBF,SAAY,CAAA,EAAA;QACrCC,MAAOF,CAAAA,GAAAA,CAAAA;AACT;AACF;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isDynamicZoneAttribute } from '../../content-types.mjs';
|
|
2
|
+
|
|
3
|
+
const visitor = ({ key, attribute }, { remove })=>{
|
|
4
|
+
if (isDynamicZoneAttribute(attribute)) {
|
|
5
|
+
remove(key);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { visitor as default };
|
|
10
|
+
//# sourceMappingURL=remove-dynamic-zones.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-dynamic-zones.mjs","sources":["../../../src/sanitize/visitors/remove-dynamic-zones.ts"],"sourcesContent":["import { isDynamicZoneAttribute } from '../../content-types';\nimport type { Visitor } from '../../traverse/factory';\n\nconst visitor: Visitor = ({ key, attribute }, { remove }) => {\n if (isDynamicZoneAttribute(attribute)) {\n remove(key);\n }\n};\n\nexport default visitor;\n"],"names":["visitor","key","attribute","remove","isDynamicZoneAttribute"],"mappings":";;AAGMA,MAAAA,OAAAA,GAAmB,CAAC,EAAEC,GAAG,EAAEC,SAAS,EAAE,EAAE,EAAEC,MAAM,EAAE,GAAA;AACtD,IAAA,IAAIC,uBAAuBF,SAAY,CAAA,EAAA;QACrCC,MAAOF,CAAAA,GAAAA,CAAAA;AACT;AACF;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var contentTypes = require('../../content-types.js');
|
|
4
|
+
|
|
5
|
+
const visitor = ({ key, attribute }, { remove })=>{
|
|
6
|
+
if (contentTypes.isMorphToRelationalAttribute(attribute)) {
|
|
7
|
+
remove(key);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
module.exports = visitor;
|
|
12
|
+
//# sourceMappingURL=remove-morph-to-relations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-morph-to-relations.js","sources":["../../../src/sanitize/visitors/remove-morph-to-relations.ts"],"sourcesContent":["import { isMorphToRelationalAttribute } from '../../content-types';\nimport type { Visitor } from '../../traverse/factory';\n\nconst visitor: Visitor = ({ key, attribute }, { remove }) => {\n if (isMorphToRelationalAttribute(attribute)) {\n remove(key);\n }\n};\n\nexport default visitor;\n"],"names":["visitor","key","attribute","remove","isMorphToRelationalAttribute"],"mappings":";;;;AAGMA,MAAAA,OAAAA,GAAmB,CAAC,EAAEC,GAAG,EAAEC,SAAS,EAAE,EAAE,EAAEC,MAAM,EAAE,GAAA;AACtD,IAAA,IAAIC,0CAA6BF,SAAY,CAAA,EAAA;QAC3CC,MAAOF,CAAAA,GAAAA,CAAAA;AACT;AACF;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isMorphToRelationalAttribute } from '../../content-types.mjs';
|
|
2
|
+
|
|
3
|
+
const visitor = ({ key, attribute }, { remove })=>{
|
|
4
|
+
if (isMorphToRelationalAttribute(attribute)) {
|
|
5
|
+
remove(key);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { visitor as default };
|
|
10
|
+
//# sourceMappingURL=remove-morph-to-relations.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-morph-to-relations.mjs","sources":["../../../src/sanitize/visitors/remove-morph-to-relations.ts"],"sourcesContent":["import { isMorphToRelationalAttribute } from '../../content-types';\nimport type { Visitor } from '../../traverse/factory';\n\nconst visitor: Visitor = ({ key, attribute }, { remove }) => {\n if (isMorphToRelationalAttribute(attribute)) {\n remove(key);\n }\n};\n\nexport default visitor;\n"],"names":["visitor","key","attribute","remove","isMorphToRelationalAttribute"],"mappings":";;AAGMA,MAAAA,OAAAA,GAAmB,CAAC,EAAEC,GAAG,EAAEC,SAAS,EAAE,EAAE,EAAEC,MAAM,EAAE,GAAA;AACtD,IAAA,IAAIC,6BAA6BF,SAAY,CAAA,EAAA;QAC3CC,MAAOF,CAAAA,GAAAA,CAAAA;AACT;AACF;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-password.js","sources":["../../../src/sanitize/visitors/remove-password.ts"],"sourcesContent":["import type { Visitor } from '../../traverse/factory';\n\nconst visitor: Visitor = ({ key, attribute }, { remove }) => {\n if (attribute?.type === 'password') {\n remove(key);\n }\n};\n\nexport default visitor;\n"],"names":["visitor","key","attribute","remove","type"],"mappings":";;AAEMA,MAAAA,OAAAA,GAAmB,CAAC,EAAEC,GAAG,EAAEC,SAAS,EAAE,EAAE,EAAEC,MAAM,EAAE,GAAA;IACtD,IAAID,SAAAA,EAAWE,SAAS,UAAY,EAAA;QAClCD,MAAOF,CAAAA,GAAAA,CAAAA;AACT;AACF;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-password.mjs","sources":["../../../src/sanitize/visitors/remove-password.ts"],"sourcesContent":["import type { Visitor } from '../../traverse/factory';\n\nconst visitor: Visitor = ({ key, attribute }, { remove }) => {\n if (attribute?.type === 'password') {\n remove(key);\n }\n};\n\nexport default visitor;\n"],"names":["visitor","key","attribute","remove","type"],"mappings":"AAEMA,MAAAA,OAAAA,GAAmB,CAAC,EAAEC,GAAG,EAAEC,SAAS,EAAE,EAAE,EAAEC,MAAM,EAAE,GAAA;IACtD,IAAID,SAAAA,EAAWE,SAAS,UAAY,EAAA;QAClCD,MAAOF,CAAAA,GAAAA,CAAAA;AACT;AACF;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var contentTypes = require('../../content-types.js');
|
|
4
|
+
|
|
5
|
+
const visitor = ({ schema, key, attribute }, { remove })=>{
|
|
6
|
+
if (!attribute) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const isPrivate = attribute.private === true || contentTypes.isPrivateAttribute(schema, key);
|
|
10
|
+
if (isPrivate) {
|
|
11
|
+
remove(key);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
module.exports = visitor;
|
|
16
|
+
//# sourceMappingURL=remove-private.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-private.js","sources":["../../../src/sanitize/visitors/remove-private.ts"],"sourcesContent":["import { isPrivateAttribute } from '../../content-types';\nimport type { Visitor } from '../../traverse/factory';\n\nconst visitor: Visitor = ({ schema, key, attribute }, { remove }) => {\n if (!attribute) {\n return;\n }\n\n const isPrivate = attribute.private === true || isPrivateAttribute(schema, key);\n\n if (isPrivate) {\n remove(key);\n }\n};\n\nexport default visitor;\n"],"names":["visitor","schema","key","attribute","remove","isPrivate","private","isPrivateAttribute"],"mappings":";;;;AAGA,MAAMA,OAAmB,GAAA,CAAC,EAAEC,MAAM,EAAEC,GAAG,EAAEC,SAAS,EAAE,EAAE,EAAEC,MAAM,EAAE,GAAA;AAC9D,IAAA,IAAI,CAACD,SAAW,EAAA;AACd,QAAA;AACF;AAEA,IAAA,MAAME,YAAYF,SAAUG,CAAAA,OAAO,KAAK,IAAA,IAAQC,gCAAmBN,MAAQC,EAAAA,GAAAA,CAAAA;AAE3E,IAAA,IAAIG,SAAW,EAAA;QACbD,MAAOF,CAAAA,GAAAA,CAAAA;AACT;AACF;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { isPrivateAttribute } from '../../content-types.mjs';
|
|
2
|
+
|
|
3
|
+
const visitor = ({ schema, key, attribute }, { remove })=>{
|
|
4
|
+
if (!attribute) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const isPrivate = attribute.private === true || isPrivateAttribute(schema, key);
|
|
8
|
+
if (isPrivate) {
|
|
9
|
+
remove(key);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { visitor as default };
|
|
14
|
+
//# sourceMappingURL=remove-private.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-private.mjs","sources":["../../../src/sanitize/visitors/remove-private.ts"],"sourcesContent":["import { isPrivateAttribute } from '../../content-types';\nimport type { Visitor } from '../../traverse/factory';\n\nconst visitor: Visitor = ({ schema, key, attribute }, { remove }) => {\n if (!attribute) {\n return;\n }\n\n const isPrivate = attribute.private === true || isPrivateAttribute(schema, key);\n\n if (isPrivate) {\n remove(key);\n }\n};\n\nexport default visitor;\n"],"names":["visitor","schema","key","attribute","remove","isPrivate","private","isPrivateAttribute"],"mappings":";;AAGA,MAAMA,OAAmB,GAAA,CAAC,EAAEC,MAAM,EAAEC,GAAG,EAAEC,SAAS,EAAE,EAAE,EAAEC,MAAM,EAAE,GAAA;AAC9D,IAAA,IAAI,CAACD,SAAW,EAAA;AACd,QAAA;AACF;AAEA,IAAA,MAAME,YAAYF,SAAUG,CAAAA,OAAO,KAAK,IAAA,IAAQC,mBAAmBN,MAAQC,EAAAA,GAAAA,CAAAA;AAE3E,IAAA,IAAIG,SAAW,EAAA;QACbD,MAAOF,CAAAA,GAAAA,CAAAA;AACT;AACF;;;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fp = require('lodash/fp');
|
|
4
|
+
|
|
5
|
+
var removeRestrictedFields = ((restrictedFields = null)=>({ key, path: { attribute: path } }, { remove })=>{
|
|
6
|
+
// Remove all fields
|
|
7
|
+
if (restrictedFields === null) {
|
|
8
|
+
remove(key);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
// Throw on invalid formats
|
|
12
|
+
if (!(fp.isArray(restrictedFields) && restrictedFields.every(fp.isString))) {
|
|
13
|
+
throw new TypeError(`Expected array of strings for restrictedFields but got "${typeof restrictedFields}"`);
|
|
14
|
+
}
|
|
15
|
+
// Remove if an exact match was found
|
|
16
|
+
if (restrictedFields.includes(path)) {
|
|
17
|
+
remove(key);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
// Remove nested matches
|
|
21
|
+
const isRestrictedNested = restrictedFields.some((allowedPath)=>path?.toString().startsWith(`${allowedPath}.`));
|
|
22
|
+
if (isRestrictedNested) {
|
|
23
|
+
remove(key);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
module.exports = removeRestrictedFields;
|
|
28
|
+
//# sourceMappingURL=remove-restricted-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-restricted-fields.js","sources":["../../../src/sanitize/visitors/remove-restricted-fields.ts"],"sourcesContent":["import { isArray, isString } from 'lodash/fp';\nimport type { Visitor } from '../../traverse/factory';\n\nexport default (restrictedFields: string[] | null = null): Visitor =>\n ({ key, path: { attribute: path } }, { remove }) => {\n // Remove all fields\n if (restrictedFields === null) {\n remove(key);\n return;\n }\n\n // Throw on invalid formats\n if (!(isArray(restrictedFields) && restrictedFields.every(isString))) {\n throw new TypeError(\n `Expected array of strings for restrictedFields but got \"${typeof restrictedFields}\"`\n );\n }\n\n // Remove if an exact match was found\n if (restrictedFields.includes(path as string)) {\n remove(key);\n return;\n }\n\n // Remove nested matches\n const isRestrictedNested = restrictedFields.some((allowedPath) =>\n path?.toString().startsWith(`${allowedPath}.`)\n );\n if (isRestrictedNested) {\n remove(key);\n }\n };\n"],"names":["restrictedFields","key","path","attribute","remove","isArray","every","isString","TypeError","includes","isRestrictedNested","some","allowedPath","toString","startsWith"],"mappings":";;;;AAGA,6BAAe,CAAA,CAACA,gBAAAA,GAAoC,IAAI,GACtD,CAAC,EAAEC,GAAG,EAAEC,IAAM,EAAA,EAAEC,WAAWD,IAAI,EAAE,EAAE,EAAE,EAAEE,MAAM,EAAE,GAAA;;AAE7C,QAAA,IAAIJ,qBAAqB,IAAM,EAAA;YAC7BI,MAAOH,CAAAA,GAAAA,CAAAA;AACP,YAAA;AACF;;QAGA,IAAI,EAAEI,UAAQL,CAAAA,gBAAAA,CAAAA,IAAqBA,iBAAiBM,KAAK,CAACC,YAAQ,CAAI,EAAA;YACpE,MAAM,IAAIC,UACR,CAAC,wDAAwD,EAAE,OAAOR,gBAAAA,CAAiB,CAAC,CAAC,CAAA;AAEzF;;QAGA,IAAIA,gBAAAA,CAAiBS,QAAQ,CAACP,IAAiB,CAAA,EAAA;YAC7CE,MAAOH,CAAAA,GAAAA,CAAAA;AACP,YAAA;AACF;;AAGA,QAAA,MAAMS,kBAAqBV,GAAAA,gBAAAA,CAAiBW,IAAI,CAAC,CAACC,WAAAA,GAChDV,IAAMW,EAAAA,QAAAA,EAAAA,CAAWC,UAAW,CAAA,CAAC,EAAEF,WAAAA,CAAY,CAAC,CAAC,CAAA,CAAA;AAE/C,QAAA,IAAIF,kBAAoB,EAAA;YACtBN,MAAOH,CAAAA,GAAAA,CAAAA;AACT;AACF,KAAA;;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { isArray, isString } from 'lodash/fp';
|
|
2
|
+
|
|
3
|
+
var removeRestrictedFields = ((restrictedFields = null)=>({ key, path: { attribute: path } }, { remove })=>{
|
|
4
|
+
// Remove all fields
|
|
5
|
+
if (restrictedFields === null) {
|
|
6
|
+
remove(key);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
// Throw on invalid formats
|
|
10
|
+
if (!(isArray(restrictedFields) && restrictedFields.every(isString))) {
|
|
11
|
+
throw new TypeError(`Expected array of strings for restrictedFields but got "${typeof restrictedFields}"`);
|
|
12
|
+
}
|
|
13
|
+
// Remove if an exact match was found
|
|
14
|
+
if (restrictedFields.includes(path)) {
|
|
15
|
+
remove(key);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
// Remove nested matches
|
|
19
|
+
const isRestrictedNested = restrictedFields.some((allowedPath)=>path?.toString().startsWith(`${allowedPath}.`));
|
|
20
|
+
if (isRestrictedNested) {
|
|
21
|
+
remove(key);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export { removeRestrictedFields as default };
|
|
26
|
+
//# sourceMappingURL=remove-restricted-fields.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-restricted-fields.mjs","sources":["../../../src/sanitize/visitors/remove-restricted-fields.ts"],"sourcesContent":["import { isArray, isString } from 'lodash/fp';\nimport type { Visitor } from '../../traverse/factory';\n\nexport default (restrictedFields: string[] | null = null): Visitor =>\n ({ key, path: { attribute: path } }, { remove }) => {\n // Remove all fields\n if (restrictedFields === null) {\n remove(key);\n return;\n }\n\n // Throw on invalid formats\n if (!(isArray(restrictedFields) && restrictedFields.every(isString))) {\n throw new TypeError(\n `Expected array of strings for restrictedFields but got \"${typeof restrictedFields}\"`\n );\n }\n\n // Remove if an exact match was found\n if (restrictedFields.includes(path as string)) {\n remove(key);\n return;\n }\n\n // Remove nested matches\n const isRestrictedNested = restrictedFields.some((allowedPath) =>\n path?.toString().startsWith(`${allowedPath}.`)\n );\n if (isRestrictedNested) {\n remove(key);\n }\n };\n"],"names":["restrictedFields","key","path","attribute","remove","isArray","every","isString","TypeError","includes","isRestrictedNested","some","allowedPath","toString","startsWith"],"mappings":";;AAGA,6BAAe,CAAA,CAACA,gBAAAA,GAAoC,IAAI,GACtD,CAAC,EAAEC,GAAG,EAAEC,IAAM,EAAA,EAAEC,WAAWD,IAAI,EAAE,EAAE,EAAE,EAAEE,MAAM,EAAE,GAAA;;AAE7C,QAAA,IAAIJ,qBAAqB,IAAM,EAAA;YAC7BI,MAAOH,CAAAA,GAAAA,CAAAA;AACP,YAAA;AACF;;QAGA,IAAI,EAAEI,OAAQL,CAAAA,gBAAAA,CAAAA,IAAqBA,iBAAiBM,KAAK,CAACC,SAAQ,CAAI,EAAA;YACpE,MAAM,IAAIC,UACR,CAAC,wDAAwD,EAAE,OAAOR,gBAAAA,CAAiB,CAAC,CAAC,CAAA;AAEzF;;QAGA,IAAIA,gBAAAA,CAAiBS,QAAQ,CAACP,IAAiB,CAAA,EAAA;YAC7CE,MAAOH,CAAAA,GAAAA,CAAAA;AACP,YAAA;AACF;;AAGA,QAAA,MAAMS,kBAAqBV,GAAAA,gBAAAA,CAAiBW,IAAI,CAAC,CAACC,WAAAA,GAChDV,IAAMW,EAAAA,QAAAA,EAAAA,CAAWC,UAAW,CAAA,CAAC,EAAEF,WAAAA,CAAY,CAAC,CAAC,CAAA,CAAA;AAE/C,QAAA,IAAIF,kBAAoB,EAAA;YACtBN,MAAOH,CAAAA,GAAAA,CAAAA;AACT;AACF,KAAA;;;;"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fp = require('lodash/fp');
|
|
4
|
+
var contentTypes = require('../../content-types.js');
|
|
5
|
+
var relations = require('../../relations.js');
|
|
6
|
+
|
|
7
|
+
const ACTIONS_TO_VERIFY = [
|
|
8
|
+
'find'
|
|
9
|
+
];
|
|
10
|
+
const { CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE } = contentTypes.constants;
|
|
11
|
+
var removeRestrictedRelations = ((auth)=>async ({ data, key, attribute, schema }, { remove, set })=>{
|
|
12
|
+
if (!attribute) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const isRelation = attribute.type === 'relation';
|
|
16
|
+
if (!isRelation) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const handleMorphRelation = async ()=>{
|
|
20
|
+
const elements = data[key];
|
|
21
|
+
if ('connect' in elements || 'set' in elements || 'disconnect' in elements) {
|
|
22
|
+
const newValue = {};
|
|
23
|
+
const connect = await handleMorphElements(elements.connect || []);
|
|
24
|
+
const relSet = await handleMorphElements(elements.set || []);
|
|
25
|
+
const disconnect = await handleMorphElements(elements.disconnect || []);
|
|
26
|
+
if (connect.length > 0) {
|
|
27
|
+
newValue.connect = connect;
|
|
28
|
+
}
|
|
29
|
+
if (relSet.length > 0) {
|
|
30
|
+
newValue.set = relSet;
|
|
31
|
+
}
|
|
32
|
+
if (disconnect.length > 0) {
|
|
33
|
+
newValue.disconnect = disconnect;
|
|
34
|
+
}
|
|
35
|
+
// TODO: this should technically be in its own visitor to check morph options, but for now we'll handle it here
|
|
36
|
+
if ('options' in elements && typeof elements.options === 'object' && elements.options !== null) {
|
|
37
|
+
const filteredOptions = {};
|
|
38
|
+
// Iterate through the keys of elements.options
|
|
39
|
+
Object.keys(elements.options).forEach((key)=>{
|
|
40
|
+
const validator = relations.VALID_RELATION_ORDERING_KEYS[key];
|
|
41
|
+
// Ensure the key exists in VALID_RELATION_ORDERING_KEYS and the validator is defined before calling it
|
|
42
|
+
if (validator && validator(elements.options[key])) {
|
|
43
|
+
filteredOptions[key] = elements.options[key];
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
// Assign the filtered options back to newValue
|
|
47
|
+
newValue.options = filteredOptions;
|
|
48
|
+
} else {
|
|
49
|
+
newValue.options = {};
|
|
50
|
+
}
|
|
51
|
+
set(key, newValue);
|
|
52
|
+
} else {
|
|
53
|
+
const newMorphValue = await handleMorphElements(elements);
|
|
54
|
+
if (newMorphValue.length) {
|
|
55
|
+
set(key, newMorphValue);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const handleMorphElements = async (elements)=>{
|
|
60
|
+
const allowedElements = [];
|
|
61
|
+
if (!fp.isArray(elements)) {
|
|
62
|
+
return allowedElements;
|
|
63
|
+
}
|
|
64
|
+
for (const element of elements){
|
|
65
|
+
if (!fp.isObject(element) || !('__type' in element)) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const scopes = ACTIONS_TO_VERIFY.map((action)=>`${element.__type}.${action}`);
|
|
69
|
+
const isAllowed = await hasAccessToSomeScopes(scopes, auth);
|
|
70
|
+
if (isAllowed) {
|
|
71
|
+
allowedElements.push(element);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return allowedElements;
|
|
75
|
+
};
|
|
76
|
+
const handleRegularRelation = async ()=>{
|
|
77
|
+
const scopes = ACTIONS_TO_VERIFY.map((action)=>`${attribute.target}.${action}`);
|
|
78
|
+
const isAllowed = await hasAccessToSomeScopes(scopes, auth);
|
|
79
|
+
// If the authenticated user don't have access to any of the scopes, then remove the field
|
|
80
|
+
if (!isAllowed) {
|
|
81
|
+
remove(key);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const isCreatorRelation = [
|
|
85
|
+
CREATED_BY_ATTRIBUTE,
|
|
86
|
+
UPDATED_BY_ATTRIBUTE
|
|
87
|
+
].includes(key);
|
|
88
|
+
// Polymorphic relations
|
|
89
|
+
if (contentTypes.isMorphToRelationalAttribute(attribute)) {
|
|
90
|
+
await handleMorphRelation();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
// Creator relations
|
|
94
|
+
if (isCreatorRelation && schema.options?.populateCreatorFields) {
|
|
95
|
+
// do nothing
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
// Regular relations
|
|
99
|
+
await handleRegularRelation();
|
|
100
|
+
});
|
|
101
|
+
const hasAccessToSomeScopes = async (scopes, auth)=>{
|
|
102
|
+
for (const scope of scopes){
|
|
103
|
+
try {
|
|
104
|
+
await strapi.auth.verify(auth, {
|
|
105
|
+
scope
|
|
106
|
+
});
|
|
107
|
+
return true;
|
|
108
|
+
} catch {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
module.exports = removeRestrictedRelations;
|
|
116
|
+
//# sourceMappingURL=remove-restricted-relations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-restricted-relations.js","sources":["../../../src/sanitize/visitors/remove-restricted-relations.ts"],"sourcesContent":["import { isArray, isObject } from 'lodash/fp';\nimport * as contentTypeUtils from '../../content-types';\nimport type { Visitor } from '../../traverse/factory';\nimport { RelationOrderingOptions } from '../../types';\nimport { VALID_RELATION_ORDERING_KEYS } from '../../relations';\n\nconst ACTIONS_TO_VERIFY = ['find'];\nconst { CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE } = contentTypeUtils.constants;\n\ntype MorphArray = Array<{ __type: string }>;\n\nexport default (auth: unknown): Visitor =>\n async ({ data, key, attribute, schema }, { remove, set }) => {\n if (!attribute) {\n return;\n }\n\n const isRelation = attribute.type === 'relation';\n\n if (!isRelation) {\n return;\n }\n\n const handleMorphRelation = async () => {\n const elements: any = (data as Record<string, MorphArray>)[key];\n\n if ('connect' in elements || 'set' in elements || 'disconnect' in elements) {\n const newValue: Record<string, unknown> = {};\n\n const connect = await handleMorphElements(elements.connect || []);\n const relSet = await handleMorphElements(elements.set || []);\n const disconnect = await handleMorphElements(elements.disconnect || []);\n\n if (connect.length > 0) {\n newValue.connect = connect;\n }\n\n if (relSet.length > 0) {\n newValue.set = relSet;\n }\n\n if (disconnect.length > 0) {\n newValue.disconnect = disconnect;\n }\n\n // TODO: this should technically be in its own visitor to check morph options, but for now we'll handle it here\n if (\n 'options' in elements &&\n typeof elements.options === 'object' &&\n elements.options !== null\n ) {\n const filteredOptions: RelationOrderingOptions = {};\n\n // Iterate through the keys of elements.options\n Object.keys(elements.options).forEach((key) => {\n const validator = VALID_RELATION_ORDERING_KEYS[key as keyof RelationOrderingOptions];\n\n // Ensure the key exists in VALID_RELATION_ORDERING_KEYS and the validator is defined before calling it\n if (validator && validator(elements.options[key])) {\n filteredOptions[key as keyof RelationOrderingOptions] = elements.options[key];\n }\n });\n\n // Assign the filtered options back to newValue\n newValue.options = filteredOptions;\n } else {\n newValue.options = {};\n }\n\n set(key, newValue);\n } else {\n const newMorphValue = await handleMorphElements(elements);\n\n if (newMorphValue.length) {\n set(key, newMorphValue);\n }\n }\n };\n\n const handleMorphElements = async (elements: any[]) => {\n const allowedElements: Record<string, unknown>[] = [];\n\n if (!isArray(elements)) {\n return allowedElements;\n }\n\n for (const element of elements) {\n if (!isObject(element) || !('__type' in element)) {\n continue;\n }\n\n const scopes = ACTIONS_TO_VERIFY.map((action) => `${element.__type}.${action}`);\n const isAllowed = await hasAccessToSomeScopes(scopes, auth);\n\n if (isAllowed) {\n allowedElements.push(element);\n }\n }\n\n return allowedElements;\n };\n\n const handleRegularRelation = async () => {\n const scopes = ACTIONS_TO_VERIFY.map((action) => `${attribute.target}.${action}`);\n\n const isAllowed = await hasAccessToSomeScopes(scopes, auth);\n\n // If the authenticated user don't have access to any of the scopes, then remove the field\n if (!isAllowed) {\n remove(key);\n }\n };\n\n const isCreatorRelation = [CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE].includes(key);\n\n // Polymorphic relations\n if (contentTypeUtils.isMorphToRelationalAttribute(attribute)) {\n await handleMorphRelation();\n return;\n }\n\n // Creator relations\n if (isCreatorRelation && schema.options?.populateCreatorFields) {\n // do nothing\n return;\n }\n\n // Regular relations\n await handleRegularRelation();\n };\n\nconst hasAccessToSomeScopes = async (scopes: string[], auth: unknown) => {\n for (const scope of scopes) {\n try {\n await strapi.auth.verify(auth, { scope });\n return true;\n } catch {\n continue;\n }\n }\n\n return false;\n};\n"],"names":["ACTIONS_TO_VERIFY","CREATED_BY_ATTRIBUTE","UPDATED_BY_ATTRIBUTE","contentTypeUtils","auth","data","key","attribute","schema","remove","set","isRelation","type","handleMorphRelation","elements","newValue","connect","handleMorphElements","relSet","disconnect","length","options","filteredOptions","Object","keys","forEach","validator","VALID_RELATION_ORDERING_KEYS","newMorphValue","allowedElements","isArray","element","isObject","scopes","map","action","__type","isAllowed","hasAccessToSomeScopes","push","handleRegularRelation","target","isCreatorRelation","includes","populateCreatorFields","scope","strapi","verify"],"mappings":"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"}
|