@strapi/utils 4.11.3 → 4.12.0-beta.0
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.d.ts +10 -0
- package/dist/async.js +33 -0
- package/dist/async.js.map +1 -0
- package/dist/code-generator.d.ts +2 -0
- package/dist/code-generator.js +11 -0
- package/dist/code-generator.js.map +1 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.js +79 -0
- package/dist/config.js.map +1 -0
- package/dist/content-types.d.ts +60 -0
- package/dist/content-types.js +151 -0
- package/dist/content-types.js.map +1 -0
- package/dist/convert-query-params.d.ts +75 -0
- package/dist/convert-query-params.js +476 -0
- package/dist/convert-query-params.js.map +1 -0
- package/dist/env-helper.d.ts +18 -0
- package/dist/env-helper.js +84 -0
- package/dist/env-helper.js.map +1 -0
- package/dist/errors.d.ts +37 -0
- package/dist/errors.js +100 -0
- package/dist/errors.js.map +1 -0
- package/dist/file.d.ts +16 -0
- package/dist/file.js +54 -0
- package/dist/file.js.map +1 -0
- package/dist/format-yup-error.d.ts +10 -0
- package/dist/format-yup-error.js +17 -0
- package/dist/format-yup-error.js.map +1 -0
- package/dist/hooks.d.ts +63 -0
- package/dist/hooks.js +89 -0
- package/dist/hooks.js.map +1 -0
- package/dist/import-default.d.ts +1 -0
- package/dist/import-default.js +9 -0
- package/dist/import-default.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +99 -0
- package/dist/index.js.map +1 -0
- package/dist/object-formatting.d.ts +3 -0
- package/dist/object-formatting.js +14 -0
- package/dist/object-formatting.js.map +1 -0
- package/dist/operators.d.ts +2 -0
- package/dist/operators.js +70 -0
- package/dist/operators.js.map +1 -0
- package/dist/pagination.d.ts +14 -0
- package/dist/pagination.js +80 -0
- package/dist/pagination.js.map +1 -0
- package/dist/parse-multipart.d.ts +8 -0
- package/dist/parse-multipart.js +36 -0
- package/dist/parse-multipart.js.map +1 -0
- package/dist/parse-type.d.ts +21 -0
- package/dist/parse-type.js +108 -0
- package/dist/parse-type.js.map +1 -0
- package/dist/policy.d.ts +41 -0
- package/dist/policy.js +109 -0
- package/dist/policy.js.map +1 -0
- package/dist/print-value.d.ts +2 -0
- package/dist/print-value.js +50 -0
- package/dist/print-value.js.map +1 -0
- package/dist/provider-factory.d.ts +29 -0
- package/dist/provider-factory.js +80 -0
- package/dist/provider-factory.js.map +1 -0
- package/dist/relations.d.ts +10 -0
- package/dist/relations.js +23 -0
- package/dist/relations.js.map +1 -0
- package/dist/sanitize/index.d.ts +23 -0
- package/dist/sanitize/index.js +135 -0
- package/dist/sanitize/index.js.map +1 -0
- package/dist/sanitize/sanitizers.d.ts +10 -0
- package/dist/sanitize/sanitizers.js +114 -0
- package/dist/sanitize/sanitizers.js.map +1 -0
- package/dist/sanitize/visitors/allowed-fields.d.ts +3 -0
- package/{lib → dist}/sanitize/visitors/allowed-fields.js +17 -32
- package/dist/sanitize/visitors/allowed-fields.js.map +1 -0
- package/dist/sanitize/visitors/index.d.ts +7 -0
- package/dist/sanitize/visitors/index.js +21 -0
- package/dist/sanitize/visitors/index.js.map +1 -0
- package/dist/sanitize/visitors/remove-dynamic-zones.d.ts +3 -0
- package/dist/sanitize/visitors/remove-dynamic-zones.js +10 -0
- package/dist/sanitize/visitors/remove-dynamic-zones.js.map +1 -0
- package/dist/sanitize/visitors/remove-morph-to-relations.d.ts +3 -0
- package/dist/sanitize/visitors/remove-morph-to-relations.js +10 -0
- package/dist/sanitize/visitors/remove-morph-to-relations.js.map +1 -0
- package/dist/sanitize/visitors/remove-password.d.ts +3 -0
- package/dist/sanitize/visitors/remove-password.js +9 -0
- package/dist/sanitize/visitors/remove-password.js.map +1 -0
- package/dist/sanitize/visitors/remove-private.d.ts +3 -0
- package/dist/sanitize/visitors/remove-private.js +14 -0
- package/dist/sanitize/visitors/remove-private.js.map +1 -0
- package/dist/sanitize/visitors/remove-restricted-relations.d.ts +3 -0
- package/dist/sanitize/visitors/remove-restricted-relations.js +88 -0
- package/dist/sanitize/visitors/remove-restricted-relations.js.map +1 -0
- package/dist/sanitize/visitors/restricted-fields.d.ts +3 -0
- package/dist/sanitize/visitors/restricted-fields.js +25 -0
- package/dist/sanitize/visitors/restricted-fields.js.map +1 -0
- package/dist/set-creator-fields.d.ts +9 -0
- package/dist/set-creator-fields.js +39 -0
- package/dist/set-creator-fields.js.map +1 -0
- package/dist/string-formatting.d.ts +15 -0
- package/dist/string-formatting.js +85 -0
- package/dist/string-formatting.js.map +1 -0
- package/dist/template-configuration.d.ts +5 -0
- package/dist/template-configuration.js +30 -0
- package/dist/template-configuration.js.map +1 -0
- package/dist/template.d.ts +9 -0
- package/dist/template.js +20 -0
- package/dist/template.js.map +1 -0
- package/dist/traverse/factory.d.ts +78 -0
- package/dist/traverse/factory.js +127 -0
- package/dist/traverse/factory.js.map +1 -0
- package/dist/traverse/index.d.ts +5 -0
- package/dist/traverse/index.js +17 -0
- package/dist/traverse/index.js.map +1 -0
- package/dist/traverse/query-fields.d.ts +3 -0
- package/dist/traverse/query-fields.js +35 -0
- package/dist/traverse/query-fields.js.map +1 -0
- package/dist/traverse/query-filters.d.ts +3 -0
- package/dist/traverse/query-filters.js +75 -0
- package/dist/traverse/query-filters.js.map +1 -0
- package/dist/traverse/query-populate.d.ts +3 -0
- package/dist/traverse/query-populate.js +144 -0
- package/dist/traverse/query-populate.js.map +1 -0
- package/dist/traverse/query-sort.d.ts +3 -0
- package/dist/traverse/query-sort.js +116 -0
- package/dist/traverse/query-sort.js.map +1 -0
- package/dist/traverse-entity.d.ts +31 -0
- package/dist/traverse-entity.js +134 -0
- package/dist/traverse-entity.js.map +1 -0
- package/dist/types.d.ts +65 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/validators.d.ts +13 -0
- package/dist/validators.js +120 -0
- package/dist/validators.js.map +1 -0
- package/dist/webhook.d.ts +5 -0
- package/dist/webhook.js +27 -0
- package/dist/webhook.js.map +1 -0
- package/package.json +19 -4
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -4
- package/index.d.ts +0 -5
- package/lib/async.d.ts +0 -21
- package/lib/async.js +0 -45
- package/lib/build-query.js +0 -208
- package/lib/code-generator.js +0 -13
- package/lib/config.js +0 -88
- package/lib/content-types.js +0 -196
- package/lib/convert-query-params.js +0 -586
- package/lib/env-helper.js +0 -98
- package/lib/errors.js +0 -113
- package/lib/file.js +0 -60
- package/lib/format-yup-error.js +0 -20
- package/lib/hooks.js +0 -110
- package/lib/import-default.js +0 -10
- package/lib/index.js +0 -99
- package/lib/object-formatting.js +0 -15
- package/lib/operators.js +0 -74
- package/lib/pagination.js +0 -99
- package/lib/parse-multipart.js +0 -44
- package/lib/parse-type.js +0 -100
- package/lib/policy.js +0 -129
- package/lib/print-value.js +0 -52
- package/lib/provider-factory.js +0 -116
- package/lib/relations.js +0 -31
- package/lib/sanitize/index.js +0 -143
- package/lib/sanitize/sanitizers.js +0 -163
- package/lib/sanitize/visitors/index.js +0 -11
- package/lib/sanitize/visitors/remove-dynamic-zones.js +0 -9
- package/lib/sanitize/visitors/remove-morph-to-relations.js +0 -9
- package/lib/sanitize/visitors/remove-password.js +0 -7
- package/lib/sanitize/visitors/remove-private.js +0 -15
- package/lib/sanitize/visitors/remove-restricted-relations.js +0 -81
- package/lib/sanitize/visitors/restricted-fields.js +0 -32
- package/lib/set-creator-fields.js +0 -17
- package/lib/string-formatting.js +0 -79
- package/lib/template-configuration.js +0 -32
- package/lib/template.js +0 -28
- package/lib/traverse/factory.js +0 -157
- package/lib/traverse/index.js +0 -16
- package/lib/traverse/query-fields.js +0 -39
- package/lib/traverse/query-filters.js +0 -97
- package/lib/traverse/query-populate.js +0 -191
- package/lib/traverse/query-sort.js +0 -171
- package/lib/traverse-entity.js +0 -166
- package/lib/validators.js +0 -120
- package/lib/webhook.js +0 -30
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAnyToMany = exports.isAnyToOne = exports.isManyToAny = exports.isOneToAny = exports.getRelationalFields = exports.constants = void 0;
|
|
4
|
+
const content_types_1 = require("./content-types");
|
|
5
|
+
const MANY_RELATIONS = ['oneToMany', 'manyToMany'];
|
|
6
|
+
const getRelationalFields = (contentType) => {
|
|
7
|
+
return Object.keys(contentType.attributes).filter((attributeName) => {
|
|
8
|
+
return contentType.attributes[attributeName].type === 'relation';
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
exports.getRelationalFields = getRelationalFields;
|
|
12
|
+
const isOneToAny = (attribute) => (0, content_types_1.isRelationalAttribute)(attribute) && ['oneToOne', 'oneToMany'].includes(attribute.relation);
|
|
13
|
+
exports.isOneToAny = isOneToAny;
|
|
14
|
+
const isManyToAny = (attribute) => (0, content_types_1.isRelationalAttribute)(attribute) && ['manyToMany', 'manyToOne'].includes(attribute.relation);
|
|
15
|
+
exports.isManyToAny = isManyToAny;
|
|
16
|
+
const isAnyToOne = (attribute) => (0, content_types_1.isRelationalAttribute)(attribute) && ['oneToOne', 'manyToOne'].includes(attribute.relation);
|
|
17
|
+
exports.isAnyToOne = isAnyToOne;
|
|
18
|
+
const isAnyToMany = (attribute) => (0, content_types_1.isRelationalAttribute)(attribute) && ['oneToMany', 'manyToMany'].includes(attribute.relation);
|
|
19
|
+
exports.isAnyToMany = isAnyToMany;
|
|
20
|
+
exports.constants = {
|
|
21
|
+
MANY_RELATIONS,
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=relations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relations.js","sourceRoot":"","sources":["../src/relations.ts"],"names":[],"mappings":";;;AAEA,mDAAwD;AAExD,MAAM,cAAc,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;AAEnD,MAAM,mBAAmB,GAAG,CAAC,WAAkB,EAAE,EAAE;IACjD,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,EAAE;QAClE,OAAO,WAAW,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAeO,kDAAmB;AAb5B,MAAM,UAAU,GAAG,CAAC,SAAoB,EAAE,EAAE,CAC1C,IAAA,qCAAqB,EAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;AAY/D,gCAAU;AAXxC,MAAM,WAAW,GAAG,CAAC,SAAoB,EAAE,EAAE,CAC3C,IAAA,qCAAqB,EAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;AAUrD,kCAAW;AATrD,MAAM,UAAU,GAAG,CAAC,SAAoB,EAAE,EAAE,CAC1C,IAAA,qCAAqB,EAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;AAQtC,gCAAU;AAPjE,MAAM,WAAW,GAAG,CAAC,SAAoB,EAAE,EAAE,CAC3C,IAAA,qCAAqB,EAAC,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;AAM5B,kCAAW;AAJjE,QAAA,SAAS,GAAG;IACvB,cAAc;CACf,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as visitors from './visitors';
|
|
2
|
+
import * as sanitizers from './sanitizers';
|
|
3
|
+
import { Model } from '../types';
|
|
4
|
+
export interface Options {
|
|
5
|
+
auth?: unknown;
|
|
6
|
+
}
|
|
7
|
+
export interface SanitizeFunc {
|
|
8
|
+
(data: unknown, schema: Model, options?: Options): Promise<unknown>;
|
|
9
|
+
}
|
|
10
|
+
declare const _default: {
|
|
11
|
+
contentAPI: {
|
|
12
|
+
input: SanitizeFunc;
|
|
13
|
+
output: SanitizeFunc;
|
|
14
|
+
query: (query: Record<string, unknown>, schema: Model, { auth }?: Options) => Promise<Record<string, unknown>>;
|
|
15
|
+
filters: SanitizeFunc;
|
|
16
|
+
sort: SanitizeFunc;
|
|
17
|
+
fields: SanitizeFunc;
|
|
18
|
+
populate: SanitizeFunc;
|
|
19
|
+
};
|
|
20
|
+
sanitizers: typeof sanitizers;
|
|
21
|
+
visitors: typeof visitors;
|
|
22
|
+
};
|
|
23
|
+
export default _default;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const fp_1 = require("lodash/fp");
|
|
30
|
+
const content_types_1 = require("../content-types");
|
|
31
|
+
const async_1 = require("../async");
|
|
32
|
+
const visitors = __importStar(require("./visitors"));
|
|
33
|
+
const sanitizers = __importStar(require("./sanitizers"));
|
|
34
|
+
const traverse_entity_1 = __importDefault(require("../traverse-entity"));
|
|
35
|
+
const traverse_1 = require("../traverse");
|
|
36
|
+
const createContentAPISanitizers = () => {
|
|
37
|
+
const sanitizeInput = (data, schema, { auth } = {}) => {
|
|
38
|
+
if ((0, fp_1.isArray)(data)) {
|
|
39
|
+
return Promise.all(data.map((entry) => sanitizeInput(entry, schema, { auth })));
|
|
40
|
+
}
|
|
41
|
+
const nonWritableAttributes = (0, content_types_1.getNonWritableAttributes)(schema);
|
|
42
|
+
const transforms = [
|
|
43
|
+
// Remove non writable attributes
|
|
44
|
+
(0, traverse_entity_1.default)(visitors.restrictedFields(nonWritableAttributes), { schema }),
|
|
45
|
+
];
|
|
46
|
+
if (auth) {
|
|
47
|
+
// Remove restricted relations
|
|
48
|
+
transforms.push((0, traverse_entity_1.default)(visitors.removeRestrictedRelations(auth), { schema }));
|
|
49
|
+
}
|
|
50
|
+
// Apply sanitizers from registry if exists
|
|
51
|
+
strapi.sanitizers
|
|
52
|
+
.get('content-api.input')
|
|
53
|
+
.forEach((sanitizer) => transforms.push(sanitizer(schema)));
|
|
54
|
+
return (0, async_1.pipeAsync)(...transforms)(data);
|
|
55
|
+
};
|
|
56
|
+
const sanitizeOutput = async (data, schema, { auth } = {}) => {
|
|
57
|
+
if ((0, fp_1.isArray)(data)) {
|
|
58
|
+
const res = new Array(data.length);
|
|
59
|
+
for (let i = 0; i < data.length; i += 1) {
|
|
60
|
+
res[i] = await sanitizeOutput(data[i], schema, { auth });
|
|
61
|
+
}
|
|
62
|
+
return res;
|
|
63
|
+
}
|
|
64
|
+
const transforms = [(data) => sanitizers.defaultSanitizeOutput(schema, data)];
|
|
65
|
+
if (auth) {
|
|
66
|
+
transforms.push((0, traverse_entity_1.default)(visitors.removeRestrictedRelations(auth), { schema }));
|
|
67
|
+
}
|
|
68
|
+
// Apply sanitizers from registry if exists
|
|
69
|
+
strapi.sanitizers
|
|
70
|
+
.get('content-api.output')
|
|
71
|
+
.forEach((sanitizer) => transforms.push(sanitizer(schema)));
|
|
72
|
+
return (0, async_1.pipeAsync)(...transforms)(data);
|
|
73
|
+
};
|
|
74
|
+
const sanitizeQuery = async (query, schema, { auth } = {}) => {
|
|
75
|
+
const { filters, sort, fields, populate } = query;
|
|
76
|
+
const sanitizedQuery = (0, fp_1.cloneDeep)(query);
|
|
77
|
+
if (filters) {
|
|
78
|
+
Object.assign(sanitizedQuery, { filters: await sanitizeFilters(filters, schema, { auth }) });
|
|
79
|
+
}
|
|
80
|
+
if (sort) {
|
|
81
|
+
Object.assign(sanitizedQuery, { sort: await sanitizeSort(sort, schema, { auth }) });
|
|
82
|
+
}
|
|
83
|
+
if (fields) {
|
|
84
|
+
Object.assign(sanitizedQuery, { fields: await sanitizeFields(fields, schema) });
|
|
85
|
+
}
|
|
86
|
+
if (populate) {
|
|
87
|
+
Object.assign(sanitizedQuery, { populate: await sanitizePopulate(populate, schema) });
|
|
88
|
+
}
|
|
89
|
+
return sanitizedQuery;
|
|
90
|
+
};
|
|
91
|
+
const sanitizeFilters = (filters, schema, { auth } = {}) => {
|
|
92
|
+
if ((0, fp_1.isArray)(filters)) {
|
|
93
|
+
return Promise.all(filters.map((filter) => sanitizeFilters(filter, schema, { auth })));
|
|
94
|
+
}
|
|
95
|
+
const transforms = [sanitizers.defaultSanitizeFilters(schema)];
|
|
96
|
+
if (auth) {
|
|
97
|
+
transforms.push((0, traverse_1.traverseQueryFilters)(visitors.removeRestrictedRelations(auth), { schema }));
|
|
98
|
+
}
|
|
99
|
+
return (0, async_1.pipeAsync)(...transforms)(filters);
|
|
100
|
+
};
|
|
101
|
+
const sanitizeSort = (sort, schema, { auth } = {}) => {
|
|
102
|
+
const transforms = [sanitizers.defaultSanitizeSort(schema)];
|
|
103
|
+
if (auth) {
|
|
104
|
+
transforms.push((0, traverse_1.traverseQuerySort)(visitors.removeRestrictedRelations(auth), { schema }));
|
|
105
|
+
}
|
|
106
|
+
return (0, async_1.pipeAsync)(...transforms)(sort);
|
|
107
|
+
};
|
|
108
|
+
const sanitizeFields = (fields, schema) => {
|
|
109
|
+
const transforms = [sanitizers.defaultSanitizeFields(schema)];
|
|
110
|
+
return (0, async_1.pipeAsync)(...transforms)(fields);
|
|
111
|
+
};
|
|
112
|
+
const sanitizePopulate = (populate, schema, { auth } = {}) => {
|
|
113
|
+
const transforms = [sanitizers.defaultSanitizePopulate(schema)];
|
|
114
|
+
if (auth) {
|
|
115
|
+
transforms.push((0, traverse_1.traverseQueryPopulate)(visitors.removeRestrictedRelations(auth), { schema }));
|
|
116
|
+
}
|
|
117
|
+
return (0, async_1.pipeAsync)(...transforms)(populate);
|
|
118
|
+
};
|
|
119
|
+
return {
|
|
120
|
+
input: sanitizeInput,
|
|
121
|
+
output: sanitizeOutput,
|
|
122
|
+
query: sanitizeQuery,
|
|
123
|
+
filters: sanitizeFilters,
|
|
124
|
+
sort: sanitizeSort,
|
|
125
|
+
fields: sanitizeFields,
|
|
126
|
+
populate: sanitizePopulate,
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
const contentAPI = createContentAPISanitizers();
|
|
130
|
+
exports.default = {
|
|
131
|
+
contentAPI,
|
|
132
|
+
sanitizers,
|
|
133
|
+
visitors,
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sanitize/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;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M,EAAE,cAAc;QACtB,KAAK,EAAE,aAAa;QACpB,OAAO,EAAE,eAAe;QACxB,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,cAAc;QACtB,QAAQ,EAAE,gBAAgB;KAC3B,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,0BAA0B,EAAE,CAAC;AAEhD,kBAAe;IACb,UAAU;IACV,UAAU;IACV,QAAQ;CACT,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import { Data } from '../traverse-entity';
|
|
3
|
+
import type { Model } from '../types';
|
|
4
|
+
declare const sanitizePasswords: (schema: Model) => (entity: Data) => Promise<Data>;
|
|
5
|
+
declare const defaultSanitizeOutput: (schema: Model, entity: Data) => Promise<Data>;
|
|
6
|
+
declare const defaultSanitizeFilters: import("lodash").CurriedFunction2<Model, unknown, Promise<unknown>>;
|
|
7
|
+
declare const defaultSanitizeSort: import("lodash").CurriedFunction2<Model, unknown, Promise<unknown>>;
|
|
8
|
+
declare const defaultSanitizeFields: import("lodash").CurriedFunction2<Model, unknown, Promise<any>>;
|
|
9
|
+
declare const defaultSanitizePopulate: import("lodash").CurriedFunction2<Model, unknown, Promise<unknown>>;
|
|
10
|
+
export { sanitizePasswords, defaultSanitizeOutput, defaultSanitizeFilters, defaultSanitizeSort, defaultSanitizeFields, defaultSanitizePopulate, };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.defaultSanitizePopulate = exports.defaultSanitizeFields = exports.defaultSanitizeSort = exports.defaultSanitizeFilters = exports.defaultSanitizeOutput = exports.sanitizePasswords = void 0;
|
|
7
|
+
const fp_1 = require("lodash/fp");
|
|
8
|
+
const async_1 = require("../async");
|
|
9
|
+
const traverse_entity_1 = __importDefault(require("../traverse-entity"));
|
|
10
|
+
const content_types_1 = require("../content-types");
|
|
11
|
+
const traverse_1 = require("../traverse");
|
|
12
|
+
const visitors_1 = require("./visitors");
|
|
13
|
+
const operators_1 = require("../operators");
|
|
14
|
+
const sanitizePasswords = (schema) => async (entity) => {
|
|
15
|
+
return (0, traverse_entity_1.default)(visitors_1.removePassword, { schema }, entity);
|
|
16
|
+
};
|
|
17
|
+
exports.sanitizePasswords = sanitizePasswords;
|
|
18
|
+
const defaultSanitizeOutput = async (schema, entity) => {
|
|
19
|
+
return (0, traverse_entity_1.default)((...args) => {
|
|
20
|
+
(0, visitors_1.removePassword)(...args);
|
|
21
|
+
(0, visitors_1.removePrivate)(...args);
|
|
22
|
+
}, { schema }, entity);
|
|
23
|
+
};
|
|
24
|
+
exports.defaultSanitizeOutput = defaultSanitizeOutput;
|
|
25
|
+
const defaultSanitizeFilters = (0, fp_1.curry)((schema, filters) => {
|
|
26
|
+
return (0, async_1.pipeAsync)(
|
|
27
|
+
// Remove keys that are not attributes or valid operators
|
|
28
|
+
(0, traverse_1.traverseQueryFilters)(({ key, attribute }, { remove }) => {
|
|
29
|
+
const isAttribute = !!attribute;
|
|
30
|
+
if (!isAttribute && !(0, operators_1.isOperator)(key) && key !== 'id') {
|
|
31
|
+
remove(key);
|
|
32
|
+
}
|
|
33
|
+
}, { schema }),
|
|
34
|
+
// Remove dynamic zones from filters
|
|
35
|
+
(0, traverse_1.traverseQueryFilters)(visitors_1.removeDynamicZones, { schema }),
|
|
36
|
+
// Remove morpTo relations from filters
|
|
37
|
+
(0, traverse_1.traverseQueryFilters)(visitors_1.removeMorphToRelations, { schema }),
|
|
38
|
+
// Remove passwords from filters
|
|
39
|
+
(0, traverse_1.traverseQueryFilters)(visitors_1.removePassword, { schema }),
|
|
40
|
+
// Remove private from filters
|
|
41
|
+
(0, traverse_1.traverseQueryFilters)(visitors_1.removePrivate, { schema }),
|
|
42
|
+
// Remove empty objects
|
|
43
|
+
(0, traverse_1.traverseQueryFilters)(({ key, value }, { remove }) => {
|
|
44
|
+
if ((0, fp_1.isObject)(value) && (0, fp_1.isEmpty)(value)) {
|
|
45
|
+
remove(key);
|
|
46
|
+
}
|
|
47
|
+
}, { schema }))(filters);
|
|
48
|
+
});
|
|
49
|
+
exports.defaultSanitizeFilters = defaultSanitizeFilters;
|
|
50
|
+
const defaultSanitizeSort = (0, fp_1.curry)((schema, sort) => {
|
|
51
|
+
return (0, async_1.pipeAsync)(
|
|
52
|
+
// Remove non attribute keys
|
|
53
|
+
(0, traverse_1.traverseQuerySort)(({ key, attribute }, { remove }) => {
|
|
54
|
+
// ID is not an attribute per se, so we need to make
|
|
55
|
+
// an extra check to ensure we're not removing it
|
|
56
|
+
if (key === 'id') {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (!attribute) {
|
|
60
|
+
remove(key);
|
|
61
|
+
}
|
|
62
|
+
}, { schema }),
|
|
63
|
+
// Remove dynamic zones from sort
|
|
64
|
+
(0, traverse_1.traverseQuerySort)(visitors_1.removeDynamicZones, { schema }),
|
|
65
|
+
// Remove morpTo relations from sort
|
|
66
|
+
(0, traverse_1.traverseQuerySort)(visitors_1.removeMorphToRelations, { schema }),
|
|
67
|
+
// Remove private from sort
|
|
68
|
+
(0, traverse_1.traverseQuerySort)(visitors_1.removePrivate, { schema }),
|
|
69
|
+
// Remove passwords from filters
|
|
70
|
+
(0, traverse_1.traverseQuerySort)(visitors_1.removePassword, { schema }),
|
|
71
|
+
// Remove keys for empty non-scalar values
|
|
72
|
+
(0, traverse_1.traverseQuerySort)(({ key, attribute, value }, { remove }) => {
|
|
73
|
+
if (!(0, content_types_1.isScalarAttribute)(attribute) && (0, fp_1.isEmpty)(value)) {
|
|
74
|
+
remove(key);
|
|
75
|
+
}
|
|
76
|
+
}, { schema }))(sort);
|
|
77
|
+
});
|
|
78
|
+
exports.defaultSanitizeSort = defaultSanitizeSort;
|
|
79
|
+
const defaultSanitizeFields = (0, fp_1.curry)((schema, fields) => {
|
|
80
|
+
return (0, async_1.pipeAsync)(
|
|
81
|
+
// Only keep scalar attributes
|
|
82
|
+
(0, traverse_1.traverseQueryFields)(({ key, attribute }, { remove }) => {
|
|
83
|
+
if ((0, fp_1.isNil)(attribute) || !(0, content_types_1.isScalarAttribute)(attribute)) {
|
|
84
|
+
remove(key);
|
|
85
|
+
}
|
|
86
|
+
}, { schema }),
|
|
87
|
+
// Remove private fields
|
|
88
|
+
(0, traverse_1.traverseQueryFields)(visitors_1.removePrivate, { schema }),
|
|
89
|
+
// Remove password fields
|
|
90
|
+
(0, traverse_1.traverseQueryFields)(visitors_1.removePassword, { schema }),
|
|
91
|
+
// Remove nil values from fields array
|
|
92
|
+
(value) => ((0, fp_1.isArray)(value) ? value.filter((field) => !(0, fp_1.isNil)(field)) : value))(fields);
|
|
93
|
+
});
|
|
94
|
+
exports.defaultSanitizeFields = defaultSanitizeFields;
|
|
95
|
+
const defaultSanitizePopulate = (0, fp_1.curry)((schema, populate) => {
|
|
96
|
+
return (0, async_1.pipeAsync)((0, traverse_1.traverseQueryPopulate)(async ({ key, value, schema, attribute }, { set }) => {
|
|
97
|
+
if (attribute) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (key === 'sort') {
|
|
101
|
+
set(key, await defaultSanitizeSort(schema, value));
|
|
102
|
+
}
|
|
103
|
+
if (key === 'filters') {
|
|
104
|
+
set(key, await defaultSanitizeFilters(schema, value));
|
|
105
|
+
}
|
|
106
|
+
if (key === 'fields') {
|
|
107
|
+
set(key, await defaultSanitizeFields(schema, value));
|
|
108
|
+
}
|
|
109
|
+
}, { schema }),
|
|
110
|
+
// Remove private fields
|
|
111
|
+
(0, traverse_1.traverseQueryPopulate)(visitors_1.removePrivate, { schema }))(populate);
|
|
112
|
+
});
|
|
113
|
+
exports.defaultSanitizePopulate = defaultSanitizePopulate;
|
|
114
|
+
//# sourceMappingURL=sanitizers.js.map
|
|
@@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C,CAAC,CAAC,KAAK,CAAC,CAC7E,CAAC,MAAM,CAAC,CAAC;AACZ,CAAC,CAAC,CAAC;AAkCD,sDAAqB;AAhCvB,MAAM,uBAAuB,GAAG,IAAA,UAAK,EAAC,CAAC,MAAa,EAAE,QAAiB,EAAE,EAAE;IACzE,OAAO,IAAA,iBAAS,EACd,IAAA,gCAAqB,EACnB,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;QACnD,IAAI,SAAS,EAAE;YACb,OAAO;SACR;QAED,IAAI,GAAG,KAAK,MAAM,EAAE;YAClB,GAAG,CAAC,GAAG,EAAE,MAAM,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;SACpD;QAED,IAAI,GAAG,KAAK,SAAS,EAAE;YACrB,GAAG,CAAC,GAAG,EAAE,MAAM,sBAAsB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;SACvD;QAED,IAAI,GAAG,KAAK,QAAQ,EAAE;YACpB,GAAG,CAAC,GAAG,EAAE,MAAM,qBAAqB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;SACtD;IACH,CAAC,EACD,EAAE,MAAM,EAAE,CACX;IACD,wBAAwB;IACxB,IAAA,gCAAqB,EAAC,wBAAa,EAAE,EAAE,MAAM,EAAE,CAAC,CACjD,CAAC,QAAQ,CAAC,CAAC;AACd,CAAC,CAAC,CAAC;AAQD,0DAAuB"}
|
|
@@ -1,26 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
module.exports =
|
|
6
|
-
(allowedFields = null) =>
|
|
7
|
-
({ key, path: { attribute: path } }, { remove }) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fp_1 = require("lodash/fp");
|
|
4
|
+
exports.default = (allowedFields = null) => ({ key, path: { attribute: path } }, { remove }) => {
|
|
8
5
|
// All fields are allowed
|
|
9
6
|
if (allowedFields === null) {
|
|
10
|
-
|
|
7
|
+
return;
|
|
11
8
|
}
|
|
12
|
-
|
|
13
9
|
// Ignore invalid formats
|
|
14
|
-
if (!isArray(allowedFields)) {
|
|
15
|
-
|
|
10
|
+
if (!(0, fp_1.isArray)(allowedFields)) {
|
|
11
|
+
return;
|
|
16
12
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return;
|
|
13
|
+
if ((0, fp_1.isNil)(path)) {
|
|
14
|
+
return;
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
const containedPaths = getContainedPaths(path);
|
|
23
|
-
|
|
24
17
|
/**
|
|
25
18
|
* Tells if the current path should be kept or not based
|
|
26
19
|
* on the success of the check functions for any of the allowed paths.
|
|
@@ -59,24 +52,16 @@ module.exports =
|
|
|
59
52
|
* // it should match but isn't handled by this check
|
|
60
53
|
* ```
|
|
61
54
|
*/
|
|
62
|
-
const isPathAllowed = allowedFields.some(
|
|
63
|
-
(p) => containedPaths.includes(p) || p.startsWith(`${path}.`)
|
|
64
|
-
);
|
|
65
|
-
|
|
55
|
+
const isPathAllowed = allowedFields.some((p) => containedPaths.includes(p) || p.startsWith(`${path}.`));
|
|
66
56
|
if (isPathAllowed) {
|
|
67
|
-
|
|
57
|
+
return;
|
|
68
58
|
}
|
|
69
|
-
|
|
70
59
|
// Remove otherwise
|
|
71
60
|
remove(key);
|
|
72
|
-
|
|
73
|
-
|
|
61
|
+
};
|
|
74
62
|
/**
|
|
75
63
|
* Retrieve the list of allowed paths based on the given path
|
|
76
64
|
*
|
|
77
|
-
* @param {string} path
|
|
78
|
-
* @return {string[]}
|
|
79
|
-
*
|
|
80
65
|
* @example
|
|
81
66
|
* ```js
|
|
82
67
|
* const containedPaths = getContainedPaths('foo');
|
|
@@ -90,9 +75,9 @@ module.exports =
|
|
|
90
75
|
* ```
|
|
91
76
|
*/
|
|
92
77
|
const getContainedPaths = (path) => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}, []);
|
|
78
|
+
const parts = (0, fp_1.toPath)(path);
|
|
79
|
+
return parts.reduce((acc, value, index, list) => {
|
|
80
|
+
return [...acc, list.slice(0, index + 1).join('.')];
|
|
81
|
+
}, []);
|
|
98
82
|
};
|
|
83
|
+
//# sourceMappingURL=allowed-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allowed-fields.js","sourceRoot":"","sources":["../../../src/sanitize/visitors/allowed-fields.ts"],"names":[],"mappings":";;AAAA,kCAAmD;AAGnD,kBAAe,CAAC,gBAAiC,IAAI,EAAW,EAAE,CAChE,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IACjD,yBAAyB;IACzB,IAAI,aAAa,KAAK,IAAI,EAAE;QAC1B,OAAO;KACR;IAED,yBAAyB;IACzB,IAAI,CAAC,IAAA,YAAO,EAAC,aAAa,CAAC,EAAE;QAC3B,OAAO;KACR;IAED,IAAI,IAAA,UAAK,EAAC,IAAI,CAAC,EAAE;QACf,OAAO;KACR;IAED,MAAM,cAAc,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACH,MAAM,aAAa,GAAG,aAAa,CAAC,IAAI,CACtC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,CAC9D,CAAC;IAEF,IAAI,aAAa,EAAE;QACjB,OAAO;KACR;IAED,mBAAmB;IACnB,MAAM,CAAC,GAAG,CAAC,CAAC;AACd,CAAC,CAAC;AAEJ;;;;;;;;;;;;;;GAcG;AACH,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,EAAE;IACzC,MAAM,KAAK,GAAG,IAAA,WAAM,EAAC,IAAI,CAAC,CAAC;IAE3B,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAC9C,OAAO,CAAC,GAAG,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC,EAAE,EAAc,CAAC,CAAC;AACrB,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as removePassword } from './remove-password';
|
|
2
|
+
export { default as removePrivate } from './remove-private';
|
|
3
|
+
export { default as removeRestrictedRelations } from './remove-restricted-relations';
|
|
4
|
+
export { default as removeMorphToRelations } from './remove-morph-to-relations';
|
|
5
|
+
export { default as removeDynamicZones } from './remove-dynamic-zones';
|
|
6
|
+
export { default as allowedFields } from './allowed-fields';
|
|
7
|
+
export { default as restrictedFields } from './restricted-fields';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.restrictedFields = exports.allowedFields = exports.removeDynamicZones = exports.removeMorphToRelations = exports.removeRestrictedRelations = exports.removePrivate = exports.removePassword = void 0;
|
|
7
|
+
var remove_password_1 = require("./remove-password");
|
|
8
|
+
Object.defineProperty(exports, "removePassword", { enumerable: true, get: function () { return __importDefault(remove_password_1).default; } });
|
|
9
|
+
var remove_private_1 = require("./remove-private");
|
|
10
|
+
Object.defineProperty(exports, "removePrivate", { enumerable: true, get: function () { return __importDefault(remove_private_1).default; } });
|
|
11
|
+
var remove_restricted_relations_1 = require("./remove-restricted-relations");
|
|
12
|
+
Object.defineProperty(exports, "removeRestrictedRelations", { enumerable: true, get: function () { return __importDefault(remove_restricted_relations_1).default; } });
|
|
13
|
+
var remove_morph_to_relations_1 = require("./remove-morph-to-relations");
|
|
14
|
+
Object.defineProperty(exports, "removeMorphToRelations", { enumerable: true, get: function () { return __importDefault(remove_morph_to_relations_1).default; } });
|
|
15
|
+
var remove_dynamic_zones_1 = require("./remove-dynamic-zones");
|
|
16
|
+
Object.defineProperty(exports, "removeDynamicZones", { enumerable: true, get: function () { return __importDefault(remove_dynamic_zones_1).default; } });
|
|
17
|
+
var allowed_fields_1 = require("./allowed-fields");
|
|
18
|
+
Object.defineProperty(exports, "allowedFields", { enumerable: true, get: function () { return __importDefault(allowed_fields_1).default; } });
|
|
19
|
+
var restricted_fields_1 = require("./restricted-fields");
|
|
20
|
+
Object.defineProperty(exports, "restrictedFields", { enumerable: true, get: function () { return __importDefault(restricted_fields_1).default; } });
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sanitize/visitors/index.ts"],"names":[],"mappings":";;;;;;AAAA,qDAA8D;AAArD,kIAAA,OAAO,OAAkB;AAClC,mDAA4D;AAAnD,gIAAA,OAAO,OAAiB;AACjC,6EAAqF;AAA5E,yJAAA,OAAO,OAA6B;AAC7C,yEAAgF;AAAvE,oJAAA,OAAO,OAA0B;AAC1C,+DAAuE;AAA9D,2IAAA,OAAO,OAAsB;AACtC,mDAA4D;AAAnD,gIAAA,OAAO,OAAiB;AACjC,yDAAkE;AAAzD,sIAAA,OAAO,OAAoB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const content_types_1 = require("../../content-types");
|
|
4
|
+
const visitor = ({ key, attribute }, { remove }) => {
|
|
5
|
+
if ((0, content_types_1.isDynamicZoneAttribute)(attribute)) {
|
|
6
|
+
remove(key);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
exports.default = visitor;
|
|
10
|
+
//# sourceMappingURL=remove-dynamic-zones.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-dynamic-zones.js","sourceRoot":"","sources":["../../../src/sanitize/visitors/remove-dynamic-zones.ts"],"names":[],"mappings":";;AAAA,uDAA6D;AAG7D,MAAM,OAAO,GAAY,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IAC1D,IAAI,IAAA,sCAAsB,EAAC,SAAS,CAAC,EAAE;QACrC,MAAM,CAAC,GAAG,CAAC,CAAC;KACb;AACH,CAAC,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const content_types_1 = require("../../content-types");
|
|
4
|
+
const visitor = ({ key, attribute }, { remove }) => {
|
|
5
|
+
if ((0, content_types_1.isMorphToRelationalAttribute)(attribute)) {
|
|
6
|
+
remove(key);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
exports.default = visitor;
|
|
10
|
+
//# sourceMappingURL=remove-morph-to-relations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-morph-to-relations.js","sourceRoot":"","sources":["../../../src/sanitize/visitors/remove-morph-to-relations.ts"],"names":[],"mappings":";;AAAA,uDAAmE;AAGnE,MAAM,OAAO,GAAY,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IAC1D,IAAI,IAAA,4CAA4B,EAAC,SAAS,CAAC,EAAE;QAC3C,MAAM,CAAC,GAAG,CAAC,CAAC;KACb;AACH,CAAC,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const visitor = ({ key, attribute }, { remove }) => {
|
|
4
|
+
if (attribute?.type === 'password') {
|
|
5
|
+
remove(key);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
exports.default = visitor;
|
|
9
|
+
//# sourceMappingURL=remove-password.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-password.js","sourceRoot":"","sources":["../../../src/sanitize/visitors/remove-password.ts"],"names":[],"mappings":";;AAEA,MAAM,OAAO,GAAY,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IAC1D,IAAI,SAAS,EAAE,IAAI,KAAK,UAAU,EAAE;QAClC,MAAM,CAAC,GAAG,CAAC,CAAC;KACb;AACH,CAAC,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const content_types_1 = require("../../content-types");
|
|
4
|
+
const visitor = ({ schema, key, attribute }, { remove }) => {
|
|
5
|
+
if (!attribute) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const isPrivate = attribute.private === true || (0, content_types_1.isPrivateAttribute)(schema, key);
|
|
9
|
+
if (isPrivate) {
|
|
10
|
+
remove(key);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
exports.default = visitor;
|
|
14
|
+
//# sourceMappingURL=remove-private.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-private.js","sourceRoot":"","sources":["../../../src/sanitize/visitors/remove-private.ts"],"names":[],"mappings":";;AAAA,uDAAyD;AAGzD,MAAM,OAAO,GAAY,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IAClE,IAAI,CAAC,SAAS,EAAE;QACd,OAAO;KACR;IAED,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,KAAK,IAAI,IAAI,IAAA,kCAAkB,EAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEhF,IAAI,SAAS,EAAE;QACb,MAAM,CAAC,GAAG,CAAC,CAAC;KACb;AACH,CAAC,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const contentTypeUtils = __importStar(require("../../content-types"));
|
|
27
|
+
const ACTIONS_TO_VERIFY = ['find'];
|
|
28
|
+
const { CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE } = contentTypeUtils.constants;
|
|
29
|
+
exports.default = (auth) => async ({ data, key, attribute, schema }, { remove, set }) => {
|
|
30
|
+
if (!attribute) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const isRelation = attribute.type === 'relation';
|
|
34
|
+
if (!isRelation) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const handleMorphRelation = async () => {
|
|
38
|
+
const newMorphValue = [];
|
|
39
|
+
for (const element of data[key]) {
|
|
40
|
+
const scopes = ACTIONS_TO_VERIFY.map((action) => `${element.__type}.${action}`);
|
|
41
|
+
const isAllowed = await hasAccessToSomeScopes(scopes, auth);
|
|
42
|
+
if (isAllowed) {
|
|
43
|
+
newMorphValue.push(element);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// If the new value is empty, remove the relation completely
|
|
47
|
+
if (newMorphValue.length === 0) {
|
|
48
|
+
remove(key);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
set(key, newMorphValue);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const handleRegularRelation = async () => {
|
|
55
|
+
const scopes = ACTIONS_TO_VERIFY.map((action) => `${attribute.target}.${action}`);
|
|
56
|
+
const isAllowed = await hasAccessToSomeScopes(scopes, auth);
|
|
57
|
+
// If the authenticated user don't have access to any of the scopes, then remove the field
|
|
58
|
+
if (!isAllowed) {
|
|
59
|
+
remove(key);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const isCreatorRelation = [CREATED_BY_ATTRIBUTE, UPDATED_BY_ATTRIBUTE].includes(key);
|
|
63
|
+
// Polymorphic relations
|
|
64
|
+
if (contentTypeUtils.isMorphToRelationalAttribute(attribute)) {
|
|
65
|
+
await handleMorphRelation();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
// Creator relations
|
|
69
|
+
if (isCreatorRelation && schema.options.populateCreatorFields) {
|
|
70
|
+
// do nothing
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
// Regular relations
|
|
74
|
+
await handleRegularRelation();
|
|
75
|
+
};
|
|
76
|
+
const hasAccessToSomeScopes = async (scopes, auth) => {
|
|
77
|
+
for (const scope of scopes) {
|
|
78
|
+
try {
|
|
79
|
+
await strapi.auth.verify(auth, { scope });
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=remove-restricted-relations.js.map
|