@opengis/fastify-table 2.0.132 → 2.0.133
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/module/core/cls/constraint_type.json +14 -0
- package/dist/module/core/cls/constraint_type_table.json +18 -0
- package/dist/module/core/select/core.user_mentioned.sql +1 -1
- package/dist/server/routes/file/controllers/export.js +4 -4
- package/package.json +1 -1
- package/dist/server/plugins/hook/index.js +0 -39
- package/dist/server/routes/auth/controllers/2factor/generate.js +0 -38
- package/dist/server/routes/auth/controllers/2factor/toggle.js +0 -39
- package/dist/server/routes/logger/controllers/utils/checkUserAccess.js +0 -22
- package/dist/server/routes/logger/controllers/utils/getRootDir.js +0 -25
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
select uid, coalesce(sur_name,'')||coalesce(' '||user_name,'') as text, email from admin.users
|
|
1
|
+
select uid, coalesce(sur_name,'')||coalesce(' '||user_name,'') as text, email from admin.users
|
|
2
2
|
where enabled order by coalesce(sur_name,'')||coalesce(' '||user_name,'')
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
/* eslint-disable no-await-in-loop */
|
|
5
5
|
/* eslint-disable no-nested-ternary */
|
|
6
6
|
import path from "node:path";
|
|
7
|
-
import { createHash } from "node:crypto";
|
|
7
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
8
8
|
import { existsSync } from "node:fs";
|
|
9
9
|
import { appendFile, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
10
10
|
import config from "../../../../config.js";
|
|
@@ -59,7 +59,7 @@ export default async function exportTable({ pg = pgClients.client, headers, user
|
|
|
59
59
|
date.getFullYear(),
|
|
60
60
|
date.getMonth(),
|
|
61
61
|
date.getDate(),
|
|
62
|
-
date.getHours(),
|
|
62
|
+
// date.getHours(),
|
|
63
63
|
].join("-");
|
|
64
64
|
const objInfo = createHash("md5")
|
|
65
65
|
.update([sufixName, sufixDate].join("-"))
|
|
@@ -179,8 +179,8 @@ export default async function exportTable({ pg = pgClients.client, headers, user
|
|
|
179
179
|
// export xlsx / csv / json
|
|
180
180
|
const source = loadTable?.title || loadTable?.ua || table || sourceName;
|
|
181
181
|
const interval = setInterval(async () => {
|
|
182
|
-
send("process query...");
|
|
183
|
-
},
|
|
182
|
+
send("process query..." + randomUUID().split('-')[0]);
|
|
183
|
+
}, 10000);
|
|
184
184
|
// start stream only if total exceed limit, but use while anyway
|
|
185
185
|
const res = {};
|
|
186
186
|
let offset = 0;
|
package/package.json
CHANGED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import config from "../../../config.js";
|
|
2
|
-
export const hookList = {};
|
|
3
|
-
export async function applyHook(name, data) {
|
|
4
|
-
if (config.trace)
|
|
5
|
-
console.log("applyHook", name);
|
|
6
|
-
if (!hookList[name]?.length)
|
|
7
|
-
return null;
|
|
8
|
-
const result = {};
|
|
9
|
-
await Promise.all(hookList[name].map(async (hook) => {
|
|
10
|
-
const hookData = await hook({ ...data, config });
|
|
11
|
-
if (hookData) {
|
|
12
|
-
if (config.trace)
|
|
13
|
-
console.log("applyHook", name, hookData);
|
|
14
|
-
Object.assign(result, hookData);
|
|
15
|
-
}
|
|
16
|
-
})).catch((err) => {
|
|
17
|
-
console.error("applyHook", name, err.toString());
|
|
18
|
-
});
|
|
19
|
-
if (Object.keys(result).length) {
|
|
20
|
-
return result;
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
export function addHook(name, fn) {
|
|
25
|
-
if (!hookList[name]) {
|
|
26
|
-
hookList[name] = [];
|
|
27
|
-
}
|
|
28
|
-
if (config.trace)
|
|
29
|
-
console.log("addHook", name);
|
|
30
|
-
hookList[name].push(fn);
|
|
31
|
-
}
|
|
32
|
-
export function applyHookSync(name, data) {
|
|
33
|
-
if (!hookList[name]?.length)
|
|
34
|
-
return null;
|
|
35
|
-
if (config.trace)
|
|
36
|
-
console.log("applyHookSync", name);
|
|
37
|
-
const hookData = hookList[name].map((hook) => hook(data))[0];
|
|
38
|
-
return hookData;
|
|
39
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import config from "../../../../../config.js";
|
|
2
|
-
import pgClients from "../../../../plugins/pg/pgClients.js";
|
|
3
|
-
import { generate } from "./providers/totp.js";
|
|
4
|
-
/**
|
|
5
|
-
* Генерація secret для двохфакторної авторизації користувача
|
|
6
|
-
*
|
|
7
|
-
* @method GET
|
|
8
|
-
* @summary Генерація user secret для двохфакторної авторизації
|
|
9
|
-
* @priority 3
|
|
10
|
-
* @alias generate
|
|
11
|
-
* @type api
|
|
12
|
-
* @tag auth
|
|
13
|
-
* @requires 2fa
|
|
14
|
-
* @errors 500
|
|
15
|
-
* @returns {Number} status Номер помилки
|
|
16
|
-
* @returns {String|Object} error Опис помилки
|
|
17
|
-
* @returns {String|Object} message Повідомлення про успішне виконання або об'єкт з параметрами
|
|
18
|
-
*/
|
|
19
|
-
export default async function generateFunction({ pg = pgClients.client, user = {} }, reply) {
|
|
20
|
-
if (!user?.uid) {
|
|
21
|
-
return reply.status(401).send("unauthorized");
|
|
22
|
-
}
|
|
23
|
-
const { uid } = user;
|
|
24
|
-
if (!config?.auth?.["2factor"]) {
|
|
25
|
-
return reply.status(400).send("2fa not enabled");
|
|
26
|
-
}
|
|
27
|
-
if (!config.pg) {
|
|
28
|
-
return reply.status(400).send("empty pg");
|
|
29
|
-
}
|
|
30
|
-
if (!uid) {
|
|
31
|
-
return reply.status(401).send("access restricted: unauthorized");
|
|
32
|
-
}
|
|
33
|
-
const res = await generate({ pg, uid });
|
|
34
|
-
if (res?.enabled) {
|
|
35
|
-
return reply.status(400).send("already created 2fa");
|
|
36
|
-
}
|
|
37
|
-
return reply.status(200).send(res);
|
|
38
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import config from '../../../../../config.js';
|
|
2
|
-
import pgClients from '../../../../plugins/pg/pgClients.js';
|
|
3
|
-
import { toggle } from './providers/totp.js';
|
|
4
|
-
/**
|
|
5
|
-
* Включення/виключення двохфакторної авторизації для користувача
|
|
6
|
-
*
|
|
7
|
-
* @method GET
|
|
8
|
-
* @summary Включення/виключення двохфакторної авторизації
|
|
9
|
-
* @priority 2
|
|
10
|
-
* @alias toggle
|
|
11
|
-
* @type api
|
|
12
|
-
* @tag auth
|
|
13
|
-
* @requires 2fa
|
|
14
|
-
* @errors 500
|
|
15
|
-
* @returns {Number} status Номер помилки
|
|
16
|
-
* @returns {String|Object} error Опис помилки
|
|
17
|
-
* @returns {String|Object} message Повідомлення про успішне виконання або об'єкт з параметрами
|
|
18
|
-
*/
|
|
19
|
-
export default async function toggleFunction(req, reply) {
|
|
20
|
-
const { pg = pgClients.client, session = {}, query = {}, } = req;
|
|
21
|
-
const { uid } = session?.passport?.user || {};
|
|
22
|
-
const { code, enable } = query;
|
|
23
|
-
if (!config.pg) {
|
|
24
|
-
return reply.status(400).send('empty pg');
|
|
25
|
-
}
|
|
26
|
-
if (!uid) {
|
|
27
|
-
return reply.status(401).send('access restricted: unauthorized');
|
|
28
|
-
}
|
|
29
|
-
if (!code) {
|
|
30
|
-
return reply.status(400).send('param "code" is required');
|
|
31
|
-
}
|
|
32
|
-
if (!Object.hasOwn(query, 'enable')) {
|
|
33
|
-
return reply.status(400).send('param "enable" is required');
|
|
34
|
-
}
|
|
35
|
-
const data = await toggle({
|
|
36
|
-
pg, code, enable: enable === 'true', uid,
|
|
37
|
-
});
|
|
38
|
-
return reply.status(200).send(data);
|
|
39
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import config from "../../../../../config.js";
|
|
2
|
-
const { accessToken = "0NWcGQxKRP8AsRxD" } = config.auth || {};
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @summary check user access to logger interface - per admin user type or user group
|
|
6
|
-
* @returns {Object} message, status
|
|
7
|
-
*/
|
|
8
|
-
export default function checkUserAccess({ user = {}, token, }) {
|
|
9
|
-
if (token && token === accessToken) {
|
|
10
|
-
return { message: "access granted", status: 200 };
|
|
11
|
-
}
|
|
12
|
-
// console.log(user);
|
|
13
|
-
if (!user.user_type?.includes?.("admin") &&
|
|
14
|
-
!config?.local &&
|
|
15
|
-
!config.auth?.disable) {
|
|
16
|
-
return { message: "access restricted", status: 403 };
|
|
17
|
-
}
|
|
18
|
-
/* if (!['admin', 'superadmin']?.includes(user.user_type) && count === '0') {
|
|
19
|
-
return { message: 'access restricted', status: 403 };
|
|
20
|
-
} */
|
|
21
|
-
return { message: "access granted", status: 200 };
|
|
22
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import config from "../../../../../config.js";
|
|
5
|
-
// import { existsSync } from 'fs';
|
|
6
|
-
let logDir = null;
|
|
7
|
-
export default function getRootDir() {
|
|
8
|
-
// absolute / relative path
|
|
9
|
-
if (logDir)
|
|
10
|
-
return logDir;
|
|
11
|
-
const file = ["config.json", "/data/local/config.json"].find((el) => fs.existsSync(el) ? el : null);
|
|
12
|
-
const root = file === "config.json" ? process.cwd() : "/data/local";
|
|
13
|
-
logDir = config.logDir || path.join(root, config.log?.dir || "log");
|
|
14
|
-
console.log({ logDir });
|
|
15
|
-
return logDir;
|
|
16
|
-
// windows debug support
|
|
17
|
-
/* const customLogDir = process.cwd().includes(':') ? 'c:/data/local' : '/data/local';
|
|
18
|
-
// docker default path
|
|
19
|
-
if (existsSync(customLogDir)) {
|
|
20
|
-
return path.join(customLogDir, config.folder || '', 'log');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// non-docker default path
|
|
24
|
-
return path.join(config.root || '/data/local', config.folder || '', 'log'); */
|
|
25
|
-
}
|