@opengis/fastify-table 2.5.14 → 2.5.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -4
- package/dist/server/plugins/file/uploadMultiPart.d.ts.map +1 -1
- package/dist/server/plugins/file/uploadMultiPart.js +4 -3
- package/dist/server/plugins/file/utils/allowedExtensions.d.ts.map +1 -1
- package/dist/server/plugins/file/utils/allowedExtensions.js +2 -0
- package/package.json +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AA8FA,iBAAe,MAAM,CAAC,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AA8FA,iBAAe,MAAM,CAAC,OAAO,EAAE,GAAG,iBA2OjC;;AACD,wBAEG"}
|
package/dist/index.js
CHANGED
|
@@ -164,13 +164,21 @@ async function plugin(fastify) {
|
|
|
164
164
|
if (config.dblist) {
|
|
165
165
|
fastify.register(dblistRoutes, opt);
|
|
166
166
|
}
|
|
167
|
-
fastify.addHook(
|
|
167
|
+
fastify.addHook("preValidation", async (request) => {
|
|
168
|
+
Object.keys(request.query || {})
|
|
169
|
+
.filter((key) => request.query[key] === "")
|
|
170
|
+
.forEach((key) => delete request.query[key]);
|
|
171
|
+
Object.keys(request.body || {})
|
|
172
|
+
.filter((key) => request.body[key] === "")
|
|
173
|
+
.forEach((key) => delete request.body[key]);
|
|
174
|
+
});
|
|
175
|
+
fastify.addHook("preHandler", async (request, reply) => {
|
|
168
176
|
const q = request.query;
|
|
169
177
|
if (q?.limit !== undefined) {
|
|
170
178
|
const limit = Number(q.limit);
|
|
171
179
|
if (!Number.isInteger(limit) || limit < 1 || limit > 1000) {
|
|
172
180
|
reply.code(400).send({
|
|
173
|
-
error:
|
|
181
|
+
error: "Invalid limit (1-100)",
|
|
174
182
|
});
|
|
175
183
|
}
|
|
176
184
|
}
|
|
@@ -178,7 +186,7 @@ async function plugin(fastify) {
|
|
|
178
186
|
const offset = Number(q.offset);
|
|
179
187
|
if (!Number.isInteger(offset) || offset < 0) {
|
|
180
188
|
reply.code(400).send({
|
|
181
|
-
error:
|
|
189
|
+
error: "Invalid offset (>=0)",
|
|
182
190
|
});
|
|
183
191
|
}
|
|
184
192
|
}
|
|
@@ -186,7 +194,7 @@ async function plugin(fastify) {
|
|
|
186
194
|
const page = Number(q.page);
|
|
187
195
|
if (!Number.isInteger(page) || page > 100000) {
|
|
188
196
|
reply.code(400).send({
|
|
189
|
-
error:
|
|
197
|
+
error: "Invalid page (<=100000)",
|
|
190
198
|
});
|
|
191
199
|
}
|
|
192
200
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadMultiPart.d.ts","sourceRoot":"","sources":["../../../../server/plugins/file/uploadMultiPart.ts"],"names":[],"mappings":"AA6BA,MAAM,WAAW,KAAK;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AA2CD,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,O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OAAO,EAAE,MAAM,mBAkBvE;AAED,wBAAsB,gBAAgB,CACpC,EACE,IAAI,EAAE,QAAQ,EACd,MAA2C,EAC3C,MAAM,GACP,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACpD,MAAM,MAAW,mBA+BlB;AAED,wBAAsB,eAAe,CACnC,GAAG,EAAE,GAAG,EACR,EACE,UAAU,EACV,GAAG,EACH,MAAM,EACN,gBAAwB,GACzB,GAAE;IACD,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CACvB,GACL,OAAO,CAAC,KAAK,CAAC,CAmHhB;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -105,9 +105,7 @@ export async function uploadMultiPart(req, { extensions, raw, subdir, originalFi
|
|
|
105
105
|
throw new BadRequestError("file buffer is empty");
|
|
106
106
|
}
|
|
107
107
|
const { ext: fileExtension } = (await fileTypeFromBuffer(fileBuffer)) || {};
|
|
108
|
-
|
|
109
|
-
throw new ConflictError("file type spoofing attempt detected");
|
|
110
|
-
}
|
|
108
|
+
const nameExt = ext.substring(1);
|
|
111
109
|
// return buffer for custom upload
|
|
112
110
|
if (raw) {
|
|
113
111
|
return {
|
|
@@ -118,6 +116,9 @@ export async function uploadMultiPart(req, { extensions, raw, subdir, originalFi
|
|
|
118
116
|
fields: value.fields,
|
|
119
117
|
};
|
|
120
118
|
}
|
|
119
|
+
if (fileExtension !== nameExt) {
|
|
120
|
+
throw new ConflictError("file type spoofing attempt detected");
|
|
121
|
+
}
|
|
121
122
|
const dir = subdir != null ? subdir : req.params?.["*"] || "uploads";
|
|
122
123
|
const yearMonthDay = subdir != null ? "" : new Date().toISOString().split("T")[0];
|
|
123
124
|
const dbname = req.pg?.options?.database || req.pg?.database || config.pg?.database; // request / config params / default config params
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"allowedExtensions.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/file/utils/allowedExtensions.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,GAAG,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"allowedExtensions.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/file/utils/allowedExtensions.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,GAAG,EAAE,MAAM,EAyBhB,CAAC;AAEF,QAAA,MAAM,MAAM,EAAE,MAAM,EAInB,CAAC;AAEF,QAAA,MAAM,MAAM,EAAE,MAAM,EAEnB,CAAC;AAEF,QAAA,MAAM,SAAS,EAAE,MAAM,EAetB,CAAC;AAEF,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;;;;;;;AAE1C,wBAKE"}
|
|
@@ -25,6 +25,7 @@ const all = envExtensions || [
|
|
|
25
25
|
"mp4",
|
|
26
26
|
"mov",
|
|
27
27
|
"xml",
|
|
28
|
+
"p7s"
|
|
28
29
|
];
|
|
29
30
|
const images = all.filter((ext) => ["jpg", "jpeg", "png", "tiff", "tif", "ico", "svg", "heic", "webp"].includes(ext));
|
|
30
31
|
const videos = all.filter((ext) => ["mp4", "mov", "avi"].includes(ext));
|
|
@@ -40,6 +41,7 @@ const documents = all.filter((ext) => [
|
|
|
40
41
|
"xml",
|
|
41
42
|
"ppt",
|
|
42
43
|
"pptx",
|
|
44
|
+
"p7s"
|
|
43
45
|
].includes(ext));
|
|
44
46
|
export { all, images, videos, documents };
|
|
45
47
|
export default {
|