@opengis/fastify-table 2.0.83 → 2.0.85

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.
@@ -1 +1 @@
1
- {"version":3,"file":"authorizeUser.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/auth/funcs/authorizeUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AA4BtD,wBAA8B,aAAa,CACzC,IAAI,EAAE,YAAY,EAClB,GAAG,EAAE,GAAG,EACR,QAAQ,SAAe,EACvB,MAAM,CAAC,EAAE,MAAM,gBA+HhB"}
1
+ {"version":3,"file":"authorizeUser.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/auth/funcs/authorizeUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AA4BtD,wBAA8B,aAAa,CACzC,IAAI,EAAE,YAAY,EAClB,GAAG,EAAE,GAAG,EACR,QAAQ,SAAe,EACvB,MAAM,CAAC,EAAE,MAAM,gBA8HhB"}
@@ -57,7 +57,7 @@ export default async function authorizeUser(user, req, authType = "creds-user",
57
57
  {};
58
58
  await req.session?.save?.();
59
59
  const redirectUrl = req.headers?.referer?.match?.(/[?&]redirect=([^&]+)/)?.[1] || "/";
60
- const twofaEnabled = config.auth?.["2factor"] && user?.twofa && user.uid && pg;
60
+ const twofaEnabled = user?.twofa && user.uid && pg;
61
61
  const registered = false; // ? check by created/updated date?
62
62
  if (req.method === "POST" &&
63
63
  (!twofaEnabled || req.session?.secondFactorPassed)) {
@@ -91,7 +91,7 @@ export default async function authorizeUser(user, req, authType = "creds-user",
91
91
  }
92
92
  // by default, disable 2factor for id.gov.ua auth
93
93
  const check = authType === "govid" ? config.auth?.["2factor"]?.govid : true;
94
- if (config.auth?.["2factor"] && user?.twofa && check) {
94
+ if (user?.twofa && check) {
95
95
  return ("/2factor?redirect=" +
96
96
  (href ||
97
97
  config.auth?.redirectAfter ||
@@ -56,7 +56,7 @@ export async function onRequest(req, reply) {
56
56
  !config.auth?.disableRedirect &&
57
57
  !req.url.startsWith(prefix) &&
58
58
  !req.url.startsWith("/api") &&
59
- !req.url.startsWith(loginPageUrl) &&
59
+ !req.url.includes(loginPageUrl) &&
60
60
  !req.url.includes(".") &&
61
61
  !req.url.includes("@")) {
62
62
  return reply.redirect(`${loginPageUrl}` + `?redirect=${req.url}`);
@@ -1 +1 @@
1
- {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../../../../server/routes/auth/controllers/2factor/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAiBvC;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAA8B,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,kBAkEzE"}
1
+ {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../../../../server/routes/auth/controllers/2factor/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAiBvC;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAA8B,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,kBAuEzE"}
@@ -28,10 +28,10 @@ const dirname = path.dirname(fileURLToPath(import.meta.url));
28
28
  */
29
29
  export default async function verifyFunction(req, reply) {
30
30
  const { pg = pgClients.client, session = {}, body = {} } = req;
31
- const { uid, email } = session?.passport?.user || {};
31
+ const { uid, twofa, email } = session?.passport?.user || {};
32
32
  // const { nocache = config.local } = query;
33
33
  const { code } = body;
34
- if (!config?.auth?.["2factor"]) {
34
+ if (!twofa) {
35
35
  return reply.status(400).send("2fa not enabled");
36
36
  }
37
37
  if (!config.pg) {
@@ -55,7 +55,7 @@ export default async function verifyFunction(req, reply) {
55
55
  ?.then((el) => el.rows?.[0] || {});
56
56
  const customPt = await getTemplate("pt", template);
57
57
  const pt = customPt ||
58
- (await readFile(path.join(dirname, `../../../../../templates/pt/${template}.html`), "utf8"));
58
+ (await readFile(path.join(dirname, `../../../../../templates/pt/${template}.hbs`), "utf8"));
59
59
  const html = await handlebars.compile(pt)({
60
60
  recoveryCodes,
61
61
  domain: `${req.protocol || "https"}://${req.hostname}`,
@@ -69,9 +69,15 @@ export default async function verifyFunction(req, reply) {
69
69
  });
70
70
  }
71
71
  const redirectUrl = req.headers?.referer?.match?.(/[?&]redirect=([^&]+)/)?.[1] || "/";
72
- return reply.redirect(redirectUrl.startsWith("/") ? redirectUrl : "/");
72
+ // return reply.redirect(redirectUrl.startsWith("/") ? redirectUrl : "/");
73
+ return reply
74
+ .status(200)
75
+ .send({ redirectUrl: redirectUrl.startsWith("/") ? redirectUrl : "/" });
73
76
  }
74
77
  catch (err) {
78
+ if (err.message === "Невірний код") {
79
+ return reply.status(401).send({ error: err.message, code: 401 });
80
+ }
75
81
  return reply.status(500).send(err.toString());
76
82
  }
77
83
  }
@@ -1,6 +1,6 @@
1
1
  import type { FastifyReply } from "fastify";
2
2
  import type { ExtendedPG } from "../../../types/core.js";
3
- export default function dataAPI({ pg, params, table, id, headers, query, user, contextQuery, sufix, filterList, actions: actionsParam, }: {
3
+ export default function dataAPI({ pg, params, table, id, headers, query, user, contextQuery, sufix, filterList, actions: actionsParam, columns: columnsParam, }: {
4
4
  pg: ExtendedPG;
5
5
  params?: {
6
6
  id?: string;
@@ -16,5 +16,6 @@ export default function dataAPI({ pg, params, table, id, headers, query, user, c
16
16
  sufix?: boolean;
17
17
  filterList?: any[];
18
18
  actions?: string[];
19
+ columns?: string[];
19
20
  }, reply: FastifyReply, called?: any): Promise<any>;
20
21
  //# sourceMappingURL=getData.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getData.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/functions/getData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AA4DzD,wBAA8B,OAAO,CACnC,EACE,EAAqB,EACrB,MAAM,EACN,KAAK,EACL,EAAE,EACF,OAAY,EACZ,KAAU,EACV,IAAS,EACT,YAAY,EACZ,KAAY,EACZ,UAAU,EACV,OAAO,EAAE,YAAY,GACtB,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,MAAM,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,EACD,KAAK,EAAE,YAAY,EACnB,MAAM,CAAC,EAAE,GAAG,gBAgzBb"}
1
+ {"version":3,"file":"getData.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/functions/getData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AA4DzD,wBAA8B,OAAO,CACnC,EACE,EAAqB,EACrB,MAAM,EACN,KAAK,EACL,EAAE,EACF,OAAY,EACZ,KAAU,EACV,IAAS,EACT,YAAY,EACZ,KAAY,EACZ,UAAU,EACV,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,YAAY,GACtB,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,MAAM,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,EACD,KAAK,EAAE,YAAY,EACnB,MAAM,CAAC,EAAE,GAAG,gBA4zBb"}
@@ -39,7 +39,7 @@ function getOrder(queryOrder, queryDesc, defaultOrder, columnList, iscalled = fa
39
39
  const checkInline = {};
40
40
  const maxLimit = 100;
41
41
  const defaultLimit = 20;
42
- export default async function dataAPI({ pg = pgClients.client, params, table, id, headers = {}, query = {}, user = {}, contextQuery, sufix = true, filterList, actions: actionsParam, }, reply, called) {
42
+ export default async function dataAPI({ pg = pgClients.client, params, table, id, headers = {}, query = {}, user = {}, contextQuery, sufix = true, filterList, actions: actionsParam, columns: columnsParam, }, reply, called) {
43
43
  const time = Date.now();
44
44
  const timeArr = [Date.now()];
45
45
  const { uid } = user;
@@ -286,10 +286,11 @@ export default async function dataAPI({ pg = pgClients.client, params, table, id
286
286
  .filter(Boolean)
287
287
  .filter((el) => checkQuery(el));
288
288
  const q = `select ${pk ? `"${pk}" as id,` : ""}
289
- ${objectId || query.key ? "*" : sqlColumns || cols || "*"}
290
- ${metaCols}
291
-
292
- ${dbColumns.filter((el) => pg.pgType?.[el.dataTypeID] === "geometry").length
289
+ ${objectId || query.key
290
+ ? "*"
291
+ : columnsParam || sqlColumns || cols || "*"}
292
+ ${metaCols}
293
+ ${dbColumns.filter((el) => pg.pgType?.[el.dataTypeID] === "geometry").length && !columnsParam
293
294
  ? `,${dbColumns
294
295
  .filter((el) => pg.pgType?.[el.dataTypeID] === "geometry")
295
296
  .map((el) => `st_asgeojson("${el.name.replace(/'/g, "''")}")::json as "${el.name.replace(/'/g, "''")}"`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "2.0.83",
3
+ "version": "2.0.85",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [