@opengis/fastify-table 2.1.15 → 2.1.17
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/routes/auth/controllers/jwt/authorize.d.ts.map +1 -1
- package/dist/server/routes/auth/controllers/jwt/authorize.js +11 -5
- package/dist/server/routes/auth/index.d.ts.map +1 -1
- package/dist/server/routes/auth/index.js +3 -0
- package/dist/server/routes/file/controllers/files.d.ts.map +1 -1
- package/dist/server/routes/file/controllers/files.js +5 -7
- package/dist/server/routes/file/controllers/resize.d.ts.map +1 -1
- package/dist/server/routes/file/controllers/resize.js +4 -3
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorize.d.ts","sourceRoot":"","sources":["../../../../../../server/routes/auth/controllers/jwt/authorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAyBvC,wBAA8B,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"authorize.d.ts","sourceRoot":"","sources":["../../../../../../server/routes/auth/controllers/jwt/authorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAyBvC,wBAA8B,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,kBAkHpE"}
|
|
@@ -51,7 +51,9 @@ export default async function authorize(req, reply) {
|
|
|
51
51
|
if (!user) {
|
|
52
52
|
return reply.code(404).send({ error: "user not found", code: 404 });
|
|
53
53
|
}
|
|
54
|
-
const href1 =
|
|
54
|
+
const href1 = req.method === "POST"
|
|
55
|
+
? null
|
|
56
|
+
: await authorizeUser(user, req, "jwt", expireMsec);
|
|
55
57
|
const ip = getIp(req);
|
|
56
58
|
// Generate authorization code
|
|
57
59
|
const code = sign(userId, secret, expireMsec, ip);
|
|
@@ -85,10 +87,14 @@ export default async function authorize(req, reply) {
|
|
|
85
87
|
const href = redirect_uri && !redirect_uri.includes("?")
|
|
86
88
|
? backUrl
|
|
87
89
|
: backUrl?.replace?.(/\?code=/, "&code=") || href1;
|
|
88
|
-
if (req.method === "POST"
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
if (req.method === "POST") {
|
|
91
|
+
return reply.status(200).send({
|
|
92
|
+
code,
|
|
93
|
+
redirect_uri: href,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
if (payload.noredirect || process.env.NODE_ENV === "test") {
|
|
97
|
+
return reply.status(200).send(code);
|
|
92
98
|
}
|
|
93
99
|
return reply.redirect(href);
|
|
94
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAkD1C,iBAAS,MAAM,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,GAAE,GAAQ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAkD1C,iBAAS,MAAM,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,GAAE,GAAQ,QAwFlD;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -77,6 +77,9 @@ function plugin(app, opt = {}) {
|
|
|
77
77
|
if (!app.hasRoute({ method: "GET", url: "/oauth/authorize" })) {
|
|
78
78
|
app.get("/oauth/authorize", params, oauthAuthorize);
|
|
79
79
|
}
|
|
80
|
+
if (!app.hasRoute({ method: "POST", url: "/oauth/authorize" })) {
|
|
81
|
+
app.post("/oauth/authorize", params, oauthAuthorize);
|
|
82
|
+
}
|
|
80
83
|
if (!app.hasRoute({ method: "GET", url: "/oauth/token" })) {
|
|
81
84
|
app.get("/oauth/token", params, oauthToken);
|
|
82
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../../../server/routes/file/controllers/files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../../../server/routes/file/controllers/files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAgB5C;;;;;;;;;;;;;;;;;GAiBG;AAEH,wBAA8B,OAAO,CACnC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;IAAE,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,EACzE,KAAK,EAAE,YAAY,gBAgDpB"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import mime from "../../../plugins/file/providers/mime/index.js";
|
|
3
|
-
import isFileExists from "../../../plugins/file/isFileExists.js";
|
|
3
|
+
// import isFileExists from "../../../plugins/file/isFileExists.js";
|
|
4
4
|
import downloadFile from "../../../plugins/file/downloadFile.js";
|
|
5
5
|
import logger from "../../../plugins/logger/getLogger.js";
|
|
6
6
|
import applyHook from "../../../plugins/hook/applyHook.js";
|
|
7
|
+
const grayGif = Buffer.from("R0lGODdhAwADAIEAAICAgAAAAAAAAAAAACwAAAAAAwADAAAIBwABCBw4MCAAOw==", "base64");
|
|
7
8
|
/**
|
|
8
9
|
* Апі використовується для отримання різних файлів і можливістю змінювати їх
|
|
9
10
|
*
|
|
@@ -42,13 +43,10 @@ export default async function getFile({ params, user }, reply) {
|
|
|
42
43
|
if (hookData)
|
|
43
44
|
return hookData;
|
|
44
45
|
const filepath = path.join("files", relpath);
|
|
45
|
-
const
|
|
46
|
-
if (!exists) {
|
|
47
|
-
return reply.status(404).send({ error: "Файл не знайдено", code: 404 });
|
|
48
|
-
}
|
|
49
|
-
const fileStream = await downloadFile(filepath);
|
|
46
|
+
const fileStream = await downloadFile(filepath).catch();
|
|
50
47
|
if (!fileStream) {
|
|
51
|
-
return reply.status(404).send({ error: "Файл не знайдено", code: 404 });
|
|
48
|
+
// return reply.status(404).send({ error: "Файл не знайдено", code: 404 });
|
|
49
|
+
return reply.headers({ "Content-Type": "image/gif" }).send(grayGif);
|
|
52
50
|
}
|
|
53
51
|
const headers = {
|
|
54
52
|
"Content-Disposition": `inline; filename=${path.basename(filepath)}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resize.d.ts","sourceRoot":"","sources":["../../../../../server/routes/file/controllers/resize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAoC5C;;GAEG;AAEH,wBAA8B,MAAM,CAClC,EACE,KAAK,GACN,EAAE;IACD,KAAK,EAAE;QACL,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAC1B,IAAI,EAAE,MAAM,CAAC;QACb,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,OAAO,CAAC,EAAE,GAAG,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,GAAG,CAAC;KACf,CAAC;CACH,EACD,KAAK,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"resize.d.ts","sourceRoot":"","sources":["../../../../../server/routes/file/controllers/resize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAoC5C;;GAEG;AAEH,wBAA8B,MAAM,CAClC,EACE,KAAK,GACN,EAAE;IACD,KAAK,EAAE;QACL,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAC1B,IAAI,EAAE,MAAM,CAAC;QACb,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,CAAC,CAAC,EAAE,MAAM,CAAC;QACX,OAAO,CAAC,EAAE,GAAG,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,GAAG,CAAC;KACf,CAAC;CACH,EACD,KAAK,EAAE,YAAY,kBAyIpB"}
|
|
@@ -65,9 +65,10 @@ export default async function resize({ query, }, reply) {
|
|
|
65
65
|
// get File Data
|
|
66
66
|
const fileData = await downloadFile(filepath, { buffer: true });
|
|
67
67
|
if (!fileData?.length) {
|
|
68
|
-
return reply
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
// return reply
|
|
69
|
+
// .status(404)
|
|
70
|
+
// .send({ error: `Файл не знайдено - ${filepath}`, code: 400 });
|
|
71
|
+
return reply.headers({ "Content-Type": "image/gif" }).send(transparentGif);
|
|
71
72
|
}
|
|
72
73
|
const resizeQuality = Math.min(+(quality || 75), 100);
|
|
73
74
|
const { width = defaultWidth, height = defaultHeight } = imageSize(fileData) || {};
|