@opengis/fastify-table 2.6.6 → 2.6.8

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":"config.d.ts","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,MAAM,KAA8D,CAAC;AAiD3E,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../config.ts"],"names":[],"mappings":"AAYA,QAAA,MAAM,MAAM,KAA8D,CAAC;AAsD3E,eAAe,MAAM,CAAC"}
package/dist/config.js CHANGED
@@ -3,6 +3,7 @@ import dotenv from "dotenv";
3
3
  dotenv.config(); // ! load .env (workaround for node)
4
4
  import { existsSync, readFileSync } from "node:fs";
5
5
  import unflattenObject from "./server/plugins/util/funcs/unflattenObject.js";
6
+ import { randomUUID } from "node:crypto";
6
7
  const fileName = ["config.json", "/data/local/config.json"].find((el) => existsSync(el) ? el : null);
7
8
  const config = fileName ? JSON.parse(readFileSync(fileName, "utf-8")) : {};
8
9
  const { skipKeys = ["windir"] } = config;
@@ -38,6 +39,11 @@ function loadEnvConfig() {
38
39
  (key.charAt(0) === key.charAt(0)?.toLowerCase?.() || key.includes(".")))
39
40
  .reduce((acc, curr) => ({ ...acc, [curr]: process.env[curr] }), {});
40
41
  Object.assign(config, unflattenObject(configKeys));
42
+ if (!config.auth?.secret) {
43
+ config.auth = config.auth || {};
44
+ config.auth.secret = randomUUID().replace(/-/g, "");
45
+ console.warn("environment variable auth.secret not set");
46
+ }
41
47
  }
42
48
  loadEnvConfig();
43
49
  export default config;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAYxD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAYtD,wBAAsB,SAAS,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,YAAY,iBAiIxE;AAED,iBAAS,MAAM,CAAC,OAAO,EAAE,eAAe,QAmCvC;AAED,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAYxD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAQtD,wBAAsB,SAAS,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,YAAY,iBAiIxE;AAED,iBAAS,MAAM,CAAC,OAAO,EAAE,eAAe,QAmCvC;AAED,eAAe,MAAM,CAAC"}
@@ -8,9 +8,6 @@ import getRedis from "../redis/funcs/getRedis.js";
8
8
  import { ForbiddenError } from "../../../errors.js";
9
9
  const { prefix = "/api" } = config;
10
10
  const { auth } = config || {};
11
- if (!auth?.secret && process.platform !== 'win32') {
12
- throw new Error("environment variable auth.secret not set");
13
- }
14
11
  const fastifyPassport = new Authenticator();
15
12
  export async function onRequest(req, reply) {
16
13
  const { hostname, headers, routeOptions } = req;
@@ -127,7 +124,7 @@ function plugin(fastify) {
127
124
  parseOptions: config?.auth?.cookieOptions || { secure: false },
128
125
  });
129
126
  fastify.register(session, {
130
- secret: auth?.secret || 'fastify-session-redis-store-secret',
127
+ secret: auth?.secret || "fastify-session-redis-store-secret",
131
128
  cookieName: "session_auth",
132
129
  cookie: config?.auth?.cookieOptions || { secure: false },
133
130
  store: new RedisStore({
@@ -1 +1 @@
1
- {"version":3,"file":"getAccess.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/crud/funcs/getAccess.ts"],"names":[],"mappings":"AA8BA;;;;;;;;;GASG;AAEH,wBAA8B,SAAS,CACrC,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,IAAS,EAAE,MAAc,EAAE,EAAE,GAAG,EACzD,EAAE,MAAmB,sBA4HtB"}
1
+ {"version":3,"file":"getAccess.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/crud/funcs/getAccess.ts"],"names":[],"mappings":"AA8BA;;;;;;;;;GASG;AAEH,wBAA8B,SAAS,CACrC,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,IAAS,EAAE,MAAc,EAAE,EAAE,GAAG,EACzD,EAAE,MAAmB,sBA8HtB"}
@@ -24,7 +24,7 @@ left join admin.user_roles d on
24
24
  then d.expiration > CURRENT_DATE
25
25
  else 1=1
26
26
  end )
27
- where $1 in (a.route_id, a.alias, a.table_name) and $2 in (b.user_uid, d.user_uid)`;
27
+ where ($1 in (a.route_id, a.table_name, a.alias) or $2 in (a.route_id, a.table_name, a.alias)) and $3 in (b.user_uid, d.user_uid)`;
28
28
  /**
29
29
  * @param {Array} user_roles.actions Actions - user actions <> group actions
30
30
  * @param {Array} role_access.actions Actions - user actions = group actions
@@ -112,7 +112,9 @@ export default async function getAccess({ resource, table, form, user = {}, meth
112
112
  pg.pk?.["admin.role_access"] &&
113
113
  pg.pk?.["admin.roles"] &&
114
114
  pg.pk?.["admin.user_roles"]
115
- ? await pg.query(q, [table, uid]).then((el) => ({
115
+ ? await pg
116
+ .query(q, [table.replace(/\.table$/, ""), table, uid])
117
+ .then((el) => ({
116
118
  ...(el.rows[0] || {}),
117
119
  roles: el.rows?.map?.((row) => row.role_id) || [],
118
120
  actions: el.rows?.map?.((row) => row.actions).flat() || [],
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/logger/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAgC,MAAM,SAAS,CAAC;AAqE7E,iBAAS,YAAY,CAAC,OAAO,EAAE,eAAe,QAmD7C;AACD,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/plugins/logger/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAgC,MAAM,SAAS,CAAC;AAqE7E,iBAAS,YAAY,CAAC,OAAO,EAAE,eAAe,QAsD7C;AACD,eAAe,YAAY,CAAC"}
@@ -89,7 +89,10 @@ function loggerPlugin(fastify) {
89
89
  });
90
90
  });
91
91
  fastify.addHook("onListen", async () => {
92
- logger.file("init", { db: pgClients.client?.options?.database });
92
+ logger.file("init", {
93
+ db: pgClients.client?.options?.database,
94
+ port: process.env.PORT || 3000,
95
+ });
93
96
  });
94
97
  }
95
98
  export default loggerPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "2.6.6",
3
+ "version": "2.6.8",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [