@opengis/fastify-table 2.4.15 → 2.4.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/module/core/select/core.user_mentioned.sql +1 -1
- package/dist/server/plugins/crud/funcs/validateData.d.ts.map +1 -1
- package/dist/server/plugins/crud/funcs/validateData.js +24 -18
- package/dist/server/plugins/pg/funcs/getMeta.js +1 -1
- package/dist/server/routes/auth/controllers/2factor/recovery.d.ts.map +1 -1
- package/dist/server/routes/auth/controllers/2factor/recovery.js +1 -1
- package/package.json +1 -1
- package/dist/server.js +0 -97
|
@@ -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,'')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateData.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/crud/funcs/validateData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validateData.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/crud/funcs/validateData.ts"],"names":[],"mappings":"AAuIA,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,IAAS,EACT,MAAW,GACZ,EAAE;IACD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B,OAMA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import config from "../../../../config.js";
|
|
2
1
|
/* eslint-disable no-console */
|
|
3
2
|
// eslint-disable-next-line no-control-regex
|
|
4
3
|
const emailReg = /(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/g;
|
|
@@ -10,8 +9,30 @@ function isNumeric(value) {
|
|
|
10
9
|
function checkField(key, val, options, idx, body) {
|
|
11
10
|
const type = options?.type?.toLowerCase?.();
|
|
12
11
|
const isrequired = options?.validators?.includes?.("required");
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
if (isrequired && !val && options.conditions) {
|
|
13
|
+
const allowed = typeof options?.conditions?.[2] === "string" &&
|
|
14
|
+
options?.conditions?.[2]?.startsWith("[")
|
|
15
|
+
? JSON.parse(options?.conditions?.[2])
|
|
16
|
+
: options?.conditions?.[2];
|
|
17
|
+
const check = Array.isArray(allowed)
|
|
18
|
+
? allowed.includes(body[options?.conditions?.[0] || ""])
|
|
19
|
+
: body[options?.conditions?.[0] || ""] === allowed;
|
|
20
|
+
if (options?.conditions?.[1] === "in" && !check) {
|
|
21
|
+
return {
|
|
22
|
+
error: "conditions not met: not allowed",
|
|
23
|
+
key,
|
|
24
|
+
val,
|
|
25
|
+
idx,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if (isrequired &&
|
|
29
|
+
options?.conditions?.[1] === "==" &&
|
|
30
|
+
body[options?.conditions?.[0] || ""] === options?.conditions?.[2]) {
|
|
31
|
+
return { error: "conditions not met: empty required", key, val, idx };
|
|
32
|
+
}
|
|
33
|
+
return null; // conditions met, is valid
|
|
34
|
+
}
|
|
35
|
+
else if (type === "switcher") {
|
|
15
36
|
// skip nulls at non-required switchers, restrict invalid values
|
|
16
37
|
if (val && typeof val !== "boolean" && !["true", "false"].includes(val)) {
|
|
17
38
|
return {
|
|
@@ -46,21 +67,6 @@ function checkField(key, val, options, idx, body) {
|
|
|
46
67
|
}
|
|
47
68
|
}
|
|
48
69
|
else if (isrequired && !val) {
|
|
49
|
-
if (options?.conditions) {
|
|
50
|
-
const allowed = typeof options?.conditions?.[2] === "string" &&
|
|
51
|
-
options?.conditions?.[2]?.startsWith("[")
|
|
52
|
-
? JSON.parse(options?.conditions?.[2])
|
|
53
|
-
: options?.conditions?.[2];
|
|
54
|
-
const check = options?.conditions?.[1] === "in" && Array.isArray(allowed)
|
|
55
|
-
? allowed.includes(body[options?.conditions?.[0] || ""])
|
|
56
|
-
: body[options?.conditions?.[0] || ""] === allowed;
|
|
57
|
-
if (!check) {
|
|
58
|
-
if (config.trace)
|
|
59
|
-
console.log("validateData", "skip conditions", key, body[options?.conditions?.[0] || ""], allowed);
|
|
60
|
-
return { key, val, idx };
|
|
61
|
-
}
|
|
62
|
-
return null; // conditions met, is valid
|
|
63
|
-
}
|
|
64
70
|
return {
|
|
65
71
|
error: "empty required",
|
|
66
72
|
key,
|
|
@@ -28,7 +28,7 @@ export default async function getMeta(opt, nocache) {
|
|
|
28
28
|
.then((el) => el.rows[0].pks1 || {});
|
|
29
29
|
const pk = table.startsWith("public.")
|
|
30
30
|
? pks1[table.replace("public.", "")]
|
|
31
|
-
: pks1[table];
|
|
31
|
+
: pks1[table] || pg.pk[table];
|
|
32
32
|
const geomColumns = fields.filter((el) => pg.pgType?.[el.dataTypeID] === "geometry");
|
|
33
33
|
const geomAttr = geomColumns.find((el) => el.name === "geom_4326") || geomColumns[0];
|
|
34
34
|
const dbColumns = await pg
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recovery.d.ts","sourceRoot":"","sources":["../../../../../../server/routes/auth/controllers/2factor/recovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAsBvC;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAA8B,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"recovery.d.ts","sourceRoot":"","sources":["../../../../../../server/routes/auth/controllers/2factor/recovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAsBvC;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAA8B,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,kBA+EnE"}
|
|
@@ -46,7 +46,7 @@ export default async function recovery(req, reply) {
|
|
|
46
46
|
}
|
|
47
47
|
const customPt = await getTemplate("pt", template);
|
|
48
48
|
const pt = customPt ||
|
|
49
|
-
(await readFile(path.join(dirname, `../../../../../templates/pt/${template}.
|
|
49
|
+
(await readFile(path.join(dirname, `../../../../../dist/server/templates/pt/${template}.hbs`), "utf8"));
|
|
50
50
|
const recoveryCodes = await pg
|
|
51
51
|
.query(`select social_auth_obj->'codesArray' as "recoveryCodes" from admin.users_social_auth
|
|
52
52
|
where uid = $1 and social_auth_type = $2`, [uid, "TOTP"])
|
package/package.json
CHANGED
package/dist/server.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-return-assign */
|
|
2
|
-
// This file contains code that we reuse
|
|
3
|
-
// between our tests.
|
|
4
|
-
import Fastify from 'fastify';
|
|
5
|
-
|
|
6
|
-
import config from './config.js';
|
|
7
|
-
import plugin from './index.js';
|
|
8
|
-
import loginEuSign from './server/routes/auth/controllers/page/loginEuSign.js';
|
|
9
|
-
|
|
10
|
-
import loggerTest from './server/routes/logger/controllers/logger.test.api.js';
|
|
11
|
-
import { addHook, logger, addTemplateDir, pgClients } from './utils.js';
|
|
12
|
-
import { BadRequestError } from './errors.js';
|
|
13
|
-
|
|
14
|
-
addHook('afterChunkedUpload', async ({ id, meta }) => {
|
|
15
|
-
console.log('chunked upload finished', id, meta);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
const cwd = process.cwd();
|
|
19
|
-
|
|
20
|
-
const app = Fastify({ loggerInstance: logger });
|
|
21
|
-
function contentParser(req, body, done) {
|
|
22
|
-
const parseBody = decodeURIComponent(body.toString()).split('&').reduce((acc, el) => {
|
|
23
|
-
const [key, val] = el.split('=');
|
|
24
|
-
return { ...acc, [key]: val };
|
|
25
|
-
}, {});
|
|
26
|
-
done(null, parseBody);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
app.addContentTypeParser('application/x-www-form-urlencoded', { parseAs: 'buffer' }, contentParser);
|
|
30
|
-
|
|
31
|
-
await app.register(plugin, config);
|
|
32
|
-
|
|
33
|
-
// debug only
|
|
34
|
-
app.get('/login1', { config: { policy: 'L0' } }, loginEuSign);
|
|
35
|
-
addHook("afterAuth", async () => {
|
|
36
|
-
if (config.auth?.redirectAfter) return; // let config decide
|
|
37
|
-
return { href: "/user" }; // force redirect to specific page after login
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
addTemplateDir(`${cwd}/module/test`);
|
|
41
|
-
|
|
42
|
-
app.get('/logger-test', { config: { policy: 'L0' } }, loggerTest);
|
|
43
|
-
app.get('/err', { config: { policy: 'L0' } }, ({ query }) => {
|
|
44
|
-
if (query.custom) {
|
|
45
|
-
throw BadRequestError('this is message');
|
|
46
|
-
}
|
|
47
|
-
if (query.custom1) {
|
|
48
|
-
throw new BadRequestError('this is stil same message');
|
|
49
|
-
}
|
|
50
|
-
throw new Error('test error code 500');
|
|
51
|
-
});
|
|
52
|
-
app.get('/test-permissions', { config: { permission: 'orders.read' } }, async () => {
|
|
53
|
-
return 'allowed';
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
app.get('/health', {
|
|
57
|
-
// preHandler: userJwt,
|
|
58
|
-
config: {
|
|
59
|
-
tags: ['server.js'],
|
|
60
|
-
policy: 'L1', // L0, L1, L2
|
|
61
|
-
auth: 'user-jwt', // none, user-jwt, creds
|
|
62
|
-
role: 'admin', // role
|
|
63
|
-
scope: 'logger', // logger, admin, gis, bi
|
|
64
|
-
rateLimit: { max: 100, timeWindow: '1 minute', hook: 'preHandler' },
|
|
65
|
-
cors: { origins: ['https://app.example.com'] },
|
|
66
|
-
rbac: { resource: 'id', action: 'add' },
|
|
67
|
-
}
|
|
68
|
-
}, async () => {
|
|
69
|
-
const clients = await Promise.all(Object.keys(pgClients || {}).map(async key => {
|
|
70
|
-
const connected = await pgClients[key]?.query('select 1').catch(err => { err }).then(el => el?.rowCount);
|
|
71
|
-
const keys = Object.keys(pgClients[key] || {});
|
|
72
|
-
return {
|
|
73
|
-
name: key,
|
|
74
|
-
init: !!pgClients[key]?.tlist
|
|
75
|
-
&& !!pgClients[key]?.pk
|
|
76
|
-
&& !!pgClients[key]?.pgType
|
|
77
|
-
&& !!pgClients[key]?.relkinds
|
|
78
|
-
&& !!pgClients[key]?.queryCache,
|
|
79
|
-
connected: !!connected,
|
|
80
|
-
keys,
|
|
81
|
-
};
|
|
82
|
-
}));
|
|
83
|
-
return { ok: true, pgClients: clients };
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
/* addCron(async function testCron() {
|
|
87
|
-
return (config.local || true) ? null : { message: 'Done', status: 200 };
|
|
88
|
-
}, 60 * 1); */
|
|
89
|
-
|
|
90
|
-
app.listen({ host: config.host || '0.0.0.0', port: config.port || process.env.PORT || 3000 }, (err) => {
|
|
91
|
-
console.log(`Server started via port: ${config.port || process.env.PORT || 3000}`);
|
|
92
|
-
if (err) {
|
|
93
|
-
console.error(err.toString());
|
|
94
|
-
logger.error(err);
|
|
95
|
-
process.exit(1);
|
|
96
|
-
}
|
|
97
|
-
});
|