@opengis/fastify-table 2.5.6 → 2.5.7
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/server/plugins/crud/funcs/utils/logChanges.js +1 -1
- package/dist/server/plugins/file/uploadMultiPart.d.ts.map +1 -1
- package/dist/server/plugins/file/uploadMultiPart.js +7 -2
- package/dist/server/plugins/file/utils/allowedExtensions.d.ts.map +1 -1
- package/dist/server/plugins/file/utils/allowedExtensions.js +13 -28
- package/package.json +99 -98
|
@@ -178,7 +178,7 @@ export default async function logChanges({ pg, table: table1, tokenData, referer
|
|
|
178
178
|
.then((el) => el.rows?.[0] || {});
|
|
179
179
|
return row1;
|
|
180
180
|
});
|
|
181
|
-
const newData = (Array.isArray(res) ? res : [res]).reduce((acc, curr) => Object.assign(acc, { [curr.entity_key]: curr.value_new }), {});
|
|
181
|
+
const newData = (Array.isArray(res) ? res : [res].filter(Boolean)).reduce((acc, curr) => Object.assign(acc, { [curr.entity_key]: curr.value_new }), {});
|
|
182
182
|
// console.log('logChanges OK', type);
|
|
183
183
|
return {
|
|
184
184
|
change_id: changeId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadMultiPart.d.ts","sourceRoot":"","sources":["../../../../server/plugins/file/uploadMultiPart.ts"],"names":[],"mappings":"
|
|
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,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,CAiHhB;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -4,6 +4,7 @@ import { existsSync } from "node:fs";
|
|
|
4
4
|
import { mkdir, writeFile, readdir } from "node:fs/promises";
|
|
5
5
|
import { randomUUID } from "node:crypto";
|
|
6
6
|
import { imageSize } from "image-size";
|
|
7
|
+
import { fileTypeFromBuffer } from "file-type";
|
|
7
8
|
import { ListObjectsV2Command } from "@aws-sdk/client-s3";
|
|
8
9
|
import config from "../../../config.js";
|
|
9
10
|
import s3Client from "./providers/s3/client.js";
|
|
@@ -11,7 +12,7 @@ import providers from "./providers/index.js";
|
|
|
11
12
|
import { all, images } from "./utils/allowedExtensions.js";
|
|
12
13
|
import grpc from "../grpc/grpc.js";
|
|
13
14
|
import getFileType from "./utils/getFileType.js";
|
|
14
|
-
import { BadRequestError, PayloadTooLargeError } from "../../../errors.js";
|
|
15
|
+
import { BadRequestError, ConflictError, PayloadTooLargeError, } from "../../../errors.js";
|
|
15
16
|
const { resizeImage } = grpc();
|
|
16
17
|
const { resizeImageMinSize = 5 } = config; // resize images >= 5 MB by default
|
|
17
18
|
async function writeFileToDisk(file, buffer) {
|
|
@@ -89,7 +90,7 @@ export async function uploadMultiPart(req, { extensions, raw, subdir, originalFi
|
|
|
89
90
|
if (extensions && !extensions.includes(ext)) {
|
|
90
91
|
throw new BadRequestError("file extension is not allowed");
|
|
91
92
|
}
|
|
92
|
-
// check extension by core list if custom not provided
|
|
93
|
+
// ! check extension by core list if custom not provided - from filename
|
|
93
94
|
if (!extensions && !allowedExtensions.includes(ext.substring(1))) {
|
|
94
95
|
throw new BadRequestError("file extension is not allowed");
|
|
95
96
|
}
|
|
@@ -103,6 +104,10 @@ export async function uploadMultiPart(req, { extensions, raw, subdir, originalFi
|
|
|
103
104
|
if (!fileBuffer?.length) {
|
|
104
105
|
throw new BadRequestError("file buffer is empty");
|
|
105
106
|
}
|
|
107
|
+
const { ext: fileExtension } = (await fileTypeFromBuffer(fileBuffer)) || {};
|
|
108
|
+
if (fileExtension !== ext.substring(1)) {
|
|
109
|
+
throw new ConflictError("file type spoofing attempt detected");
|
|
110
|
+
}
|
|
106
111
|
// return buffer for custom upload
|
|
107
112
|
if (raw) {
|
|
108
113
|
return {
|
|
@@ -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,EAwBhB,CAAC;AAEF,QAAA,MAAM,MAAM,EAAE,MAAM,EAInB,CAAC;AAEF,QAAA,MAAM,MAAM,EAAE,MAAM,EAEnB,CAAC;AAEF,QAAA,MAAM,SAAS,EAAE,MAAM,EActB,CAAC;AAEF,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;;;;;;;AAE1C,wBAKE"}
|
|
@@ -5,40 +5,26 @@ const all = envExtensions || [
|
|
|
5
5
|
"jpg",
|
|
6
6
|
"jpeg",
|
|
7
7
|
"png",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
8
|
+
"webp",
|
|
9
|
+
"heic",
|
|
10
10
|
"pdf",
|
|
11
|
-
"doc",
|
|
12
11
|
"docx",
|
|
13
|
-
"xks",
|
|
14
|
-
"csv",
|
|
15
|
-
"xls",
|
|
16
12
|
"xlsx",
|
|
13
|
+
"pptx",
|
|
14
|
+
"doc",
|
|
15
|
+
"xls",
|
|
16
|
+
"ppt",
|
|
17
|
+
"csv",
|
|
17
18
|
"txt",
|
|
18
|
-
"
|
|
19
|
+
"json",
|
|
20
|
+
"geojson",
|
|
21
|
+
"gpkg",
|
|
22
|
+
"tif",
|
|
23
|
+
"tiff",
|
|
24
|
+
"zip",
|
|
19
25
|
"mp4",
|
|
20
26
|
"mov",
|
|
21
|
-
"avi",
|
|
22
|
-
"zip",
|
|
23
|
-
"rar",
|
|
24
|
-
"7z",
|
|
25
|
-
"gz",
|
|
26
|
-
"geotiff",
|
|
27
|
-
"tiff",
|
|
28
|
-
"tif",
|
|
29
|
-
"svg",
|
|
30
|
-
"p7s",
|
|
31
|
-
"asice",
|
|
32
|
-
"shp",
|
|
33
27
|
"xml",
|
|
34
|
-
"gpkg",
|
|
35
|
-
"dmf",
|
|
36
|
-
"dwg",
|
|
37
|
-
"ico",
|
|
38
|
-
"ppt",
|
|
39
|
-
"pptx",
|
|
40
|
-
"heic",
|
|
41
|
-
"webp",
|
|
42
28
|
];
|
|
43
29
|
const images = all.filter((ext) => ["jpg", "jpeg", "png", "tiff", "tif", "ico", "svg", "heic", "webp"].includes(ext));
|
|
44
30
|
const videos = all.filter((ext) => ["mp4", "mov", "avi"].includes(ext));
|
|
@@ -51,7 +37,6 @@ const documents = all.filter((ext) => [
|
|
|
51
37
|
"xls",
|
|
52
38
|
"xlsx",
|
|
53
39
|
"txt",
|
|
54
|
-
"log",
|
|
55
40
|
"xml",
|
|
56
41
|
"ppt",
|
|
57
42
|
"pptx",
|
package/package.json
CHANGED
|
@@ -1,98 +1,99 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@opengis/fastify-table",
|
|
3
|
-
"version": "2.5.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "core-plugins",
|
|
6
|
-
"keywords": [
|
|
7
|
-
"fastify",
|
|
8
|
-
"table",
|
|
9
|
-
"crud",
|
|
10
|
-
"auth",
|
|
11
|
-
"pg",
|
|
12
|
-
"backend"
|
|
13
|
-
],
|
|
14
|
-
"main": "dist/index.js",
|
|
15
|
-
"exports": {
|
|
16
|
-
".": "./dist/index.js",
|
|
17
|
-
"./index.js": "./dist/index.js",
|
|
18
|
-
"./errors.js": "./dist/errors.js",
|
|
19
|
-
"./utils.js": "./dist/utils.js",
|
|
20
|
-
"./package.json": "./package.json"
|
|
21
|
-
},
|
|
22
|
-
"files": [
|
|
23
|
-
"dist/*"
|
|
24
|
-
],
|
|
25
|
-
"scripts": {
|
|
26
|
-
"dump": "bun ./script/dump.ts",
|
|
27
|
-
"migrate": "bun ./script/migrate.ts",
|
|
28
|
-
"dump1": "bun ./dist/script/dump.js",
|
|
29
|
-
"migrate1": "bun ./dist/script/migrate.js",
|
|
30
|
-
"prepublishOnly": "npm run build",
|
|
31
|
-
"clean": "tsc -b --clean",
|
|
32
|
-
"build": "tsc -b --clean && tsc && copyfiles server/plugins/grpc/utils/*.proto dist && copyfiles server/migrations/*.sql dist && copyfiles server/templates/**/*.html dist && copyfiles server/templates/**/*.hbs dist && copyfiles script/* dist && copyfiles -u 2 module/core/*/* dist/module/core",
|
|
33
|
-
"prod": "NODE_ENV=production bun dist/server",
|
|
34
|
-
"patch": "npm version patch && git push && npm publish",
|
|
35
|
-
"minor": "npm version minor && git push && npm publish",
|
|
36
|
-
"major": "npm version major && git push && npm publish",
|
|
37
|
-
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
|
|
38
|
-
"test": "npx vitest run",
|
|
39
|
-
"compress": "node compress.js",
|
|
40
|
-
"dev1": "bun --hot dist/server",
|
|
41
|
-
"dev": "NODE_ENV=development bun start",
|
|
42
|
-
"start": "LOG_LEVEL=trace bun server",
|
|
43
|
-
"start1": "npx tsx server"
|
|
44
|
-
},
|
|
45
|
-
"dependencies": {
|
|
46
|
-
"@aws-sdk/client-s3": "3.1079.0",
|
|
47
|
-
"@aws-sdk/lib-storage": "3.1079.0",
|
|
48
|
-
"@fastify/cookie": "11.0.2",
|
|
49
|
-
"@fastify/http-proxy": "11.5.0",
|
|
50
|
-
"@fastify/multipart": "10.0.0",
|
|
51
|
-
"@fastify/passport": "3.0.2",
|
|
52
|
-
"@fastify/rate-limit": "11.1.0",
|
|
53
|
-
"@fastify/session": "11.1.1",
|
|
54
|
-
"@grpc/grpc-js": "1.14.4",
|
|
55
|
-
"@grpc/proto-loader": "0.8.1",
|
|
56
|
-
"apache-crypt": "1.2.6",
|
|
57
|
-
"dotenv": "17.4.2",
|
|
58
|
-
"fastify": "5.9.0",
|
|
59
|
-
"fastify-plugin": "6.0.0",
|
|
60
|
-
"fastify-session-redis-store": "7.1.2",
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"pino
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"@
|
|
81
|
-
"@types/
|
|
82
|
-
"@types/
|
|
83
|
-
"@types/
|
|
84
|
-
"@types/
|
|
85
|
-
"@types/
|
|
86
|
-
"@types/passport
|
|
87
|
-
"@types/
|
|
88
|
-
"@types/
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"eslint
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
"
|
|
98
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@opengis/fastify-table",
|
|
3
|
+
"version": "2.5.7",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "core-plugins",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"fastify",
|
|
8
|
+
"table",
|
|
9
|
+
"crud",
|
|
10
|
+
"auth",
|
|
11
|
+
"pg",
|
|
12
|
+
"backend"
|
|
13
|
+
],
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": "./dist/index.js",
|
|
17
|
+
"./index.js": "./dist/index.js",
|
|
18
|
+
"./errors.js": "./dist/errors.js",
|
|
19
|
+
"./utils.js": "./dist/utils.js",
|
|
20
|
+
"./package.json": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist/*"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"dump": "bun ./script/dump.ts",
|
|
27
|
+
"migrate": "bun ./script/migrate.ts",
|
|
28
|
+
"dump1": "bun ./dist/script/dump.js",
|
|
29
|
+
"migrate1": "bun ./dist/script/migrate.js",
|
|
30
|
+
"prepublishOnly": "npm run build",
|
|
31
|
+
"clean": "tsc -b --clean",
|
|
32
|
+
"build": "tsc -b --clean && tsc && copyfiles server/plugins/grpc/utils/*.proto dist && copyfiles server/migrations/*.sql dist && copyfiles server/templates/**/*.html dist && copyfiles server/templates/**/*.hbs dist && copyfiles script/* dist && copyfiles -u 2 module/core/*/* dist/module/core",
|
|
33
|
+
"prod": "NODE_ENV=production bun dist/server",
|
|
34
|
+
"patch": "npm version patch && git push && npm publish",
|
|
35
|
+
"minor": "npm version minor && git push && npm publish",
|
|
36
|
+
"major": "npm version major && git push && npm publish",
|
|
37
|
+
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
|
|
38
|
+
"test": "npx vitest run",
|
|
39
|
+
"compress": "node compress.js",
|
|
40
|
+
"dev1": "bun --hot dist/server",
|
|
41
|
+
"dev": "NODE_ENV=development bun start",
|
|
42
|
+
"start": "LOG_LEVEL=trace bun server",
|
|
43
|
+
"start1": "npx tsx server"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@aws-sdk/client-s3": "3.1079.0",
|
|
47
|
+
"@aws-sdk/lib-storage": "3.1079.0",
|
|
48
|
+
"@fastify/cookie": "11.0.2",
|
|
49
|
+
"@fastify/http-proxy": "11.5.0",
|
|
50
|
+
"@fastify/multipart": "10.0.0",
|
|
51
|
+
"@fastify/passport": "3.0.2",
|
|
52
|
+
"@fastify/rate-limit": "11.1.0",
|
|
53
|
+
"@fastify/session": "11.1.1",
|
|
54
|
+
"@grpc/grpc-js": "1.14.4",
|
|
55
|
+
"@grpc/proto-loader": "0.8.1",
|
|
56
|
+
"apache-crypt": "1.2.6",
|
|
57
|
+
"dotenv": "17.4.2",
|
|
58
|
+
"fastify": "5.9.0",
|
|
59
|
+
"fastify-plugin": "6.0.0",
|
|
60
|
+
"fastify-session-redis-store": "7.1.2",
|
|
61
|
+
"file-type": "^22.0.1",
|
|
62
|
+
"handlebars": "4.7.9",
|
|
63
|
+
"image-size": "2.0.2",
|
|
64
|
+
"ioredis": "5.11.1",
|
|
65
|
+
"js-yaml": "5.2.1",
|
|
66
|
+
"markdown-it": "14.3.0",
|
|
67
|
+
"minio": "^8.0.7",
|
|
68
|
+
"nodemailer": "9.0.3",
|
|
69
|
+
"otplib": "13.4.1",
|
|
70
|
+
"pg": "8.22.0",
|
|
71
|
+
"pino": "10.3.1",
|
|
72
|
+
"pino-abstract-transport": "3.0.0",
|
|
73
|
+
"promised-handlebars": "2.0.1",
|
|
74
|
+
"qrcode": "1.5.4",
|
|
75
|
+
"sharp": "0.35.3",
|
|
76
|
+
"uglify-js": "3.19.3",
|
|
77
|
+
"undici": "8.6.0"
|
|
78
|
+
},
|
|
79
|
+
"devDependencies": {
|
|
80
|
+
"@stylistic/eslint-plugin": "^5.10.0",
|
|
81
|
+
"@types/bun": "^1.3.5",
|
|
82
|
+
"@types/js-yaml": "^4.0.9",
|
|
83
|
+
"@types/markdown-it": "^14.1.2",
|
|
84
|
+
"@types/node": "^26.1.0",
|
|
85
|
+
"@types/nodemailer": "^8.0.1",
|
|
86
|
+
"@types/passport": "^1.0.17",
|
|
87
|
+
"@types/passport-local": "^1.0.38",
|
|
88
|
+
"@types/pg": "^8.20.0",
|
|
89
|
+
"@types/qrcode": "^1.5.6",
|
|
90
|
+
"copyfiles": "^2.4.1",
|
|
91
|
+
"eslint": "^10.6.0",
|
|
92
|
+
"eslint-stylistic-airbnb": "^3.2.0",
|
|
93
|
+
"ts-migrate": "^0.1.35",
|
|
94
|
+
"typescript": "^6.0.2",
|
|
95
|
+
"vitest": "^4.1.2"
|
|
96
|
+
},
|
|
97
|
+
"author": "Softpro",
|
|
98
|
+
"license": "ISC"
|
|
99
|
+
}
|