@opengis/fastify-table 2.5.40 → 2.5.42

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":"loginUser.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/auth/funcs/loginUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAWvC,wBAA8B,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,kBAuDpE"}
1
+ {"version":3,"file":"loginUser.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/auth/funcs/loginUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAuBvC,wBAA8B,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,kBA2DpE"}
@@ -4,9 +4,17 @@ import logger from "../../logger/getLogger.js";
4
4
  import verifyPassword from "./verifyPassword.js";
5
5
  import authorizeUser from "./authorizeUser.js";
6
6
  import { BadRequestError } from "../../../../errors.js";
7
+ const getIp = (req) => (req.headers?.["x-real-ip"] ||
8
+ req.headers?.["x-forwarded-for"] ||
9
+ req.ip ||
10
+ req.connection?.remoteAddress ||
11
+ "")
12
+ .split(":")
13
+ .pop();
7
14
  export default async function loginUser(req, reply) {
8
15
  const { username, password } = (req.method === "POST" ? req.body : req.query) || {};
9
16
  const { pg = pgClients.client } = req;
17
+ const ip = getIp(req);
10
18
  if (!config.pg) {
11
19
  if (req.method !== "GET") {
12
20
  throw Error("empty pg");
@@ -29,6 +37,7 @@ export default async function loginUser(req, reply) {
29
37
  password,
30
38
  })) || {};
31
39
  if (!user) {
40
+ logger.file("auth/warn", { error: message, username, ip });
32
41
  if (req.method !== "GET") {
33
42
  throw BadRequestError(message);
34
43
  }
@@ -1 +1 @@
1
- {"version":3,"file":"verifyPassword.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/auth/funcs/verifyPassword.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAWpD,wBAA8B,cAAc,CAAC,EAC3C,EAAE,EACF,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;;;;;;eA2CA"}
1
+ {"version":3,"file":"verifyPassword.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/auth/funcs/verifyPassword.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAYpD,wBAA8B,cAAc,CAAC,EAC3C,EAAE,EACF,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,EAAE,EAAE,UAAU,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;;;;;;eA6CA"}
@@ -15,8 +15,9 @@ export default async function verifyPassword({ pg, username, password, }) {
15
15
  const json = await pg
16
16
  .query(query, [username])
17
17
  .then((r) => r.rows?.[0] || {});
18
- if (!json)
18
+ if (!json) {
19
19
  return { message: "user not found" };
20
+ }
20
21
  if (json.password_new_hash_algorithm === true) {
21
22
  const hash = await pg
22
23
  .query(`SELECT public.crypt($1, $2)`, [password, json.salt])
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../server/routes/util/controllers/config.ts"],"names":[],"mappings":"AAyBA,wBAA8B,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,gBAWpD"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../server/routes/util/controllers/config.ts"],"names":[],"mappings":"AAyBA,wBAA8B,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,gBAUpD"}
@@ -25,9 +25,8 @@ function processObject(obj, substr) {
25
25
  : substringObject(obj, substr);
26
26
  }
27
27
  export default async function apiConfig({ user }) {
28
- if (process.platform === "win32" ||
29
- config.local ||
30
- (config.debug && user?.user_type?.includes?.("admin"))) {
28
+ const debug = (config.local || config.debug) && user?.user_type?.includes?.("admin");
29
+ if (process.platform === "win32" || debug) {
31
30
  return config;
32
31
  }
33
32
  const reductConfig = processObject(config, 3);
@@ -1,3 +1,3 @@
1
- declare function plugin(app: any, opt?: any): void;
1
+ declare function plugin(app: any): void;
2
2
  export default plugin;
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/util/index.ts"],"names":[],"mappings":"AAaA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QA4CtC;AAED,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/util/index.ts"],"names":[],"mappings":"AAaA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,QA4CvB;AAED,eAAe,MAAM,CAAC"}
@@ -7,7 +7,7 @@ import dependencies from "./controllers/dependencies.js";
7
7
  import apiCheck from "./controllers/api.check.js";
8
8
  const tags = ["core", "util"];
9
9
  const packageName = "fastify-table";
10
- function plugin(app, opt = {}) {
10
+ function plugin(app) {
11
11
  app.get("/next-id", { config: { tags, package: packageName, policy: "L0" } }, nextId);
12
12
  app.get("/check", { config: { tags, package: packageName, role: "admin" } }, apiCheck);
13
13
  app.get("/status-monitor", { config: { tags, package: packageName, role: "admin" } }, statusMonitor);
@@ -17,7 +17,7 @@ function plugin(app, opt = {}) {
17
17
  ...(req.headers || {}),
18
18
  sessionId: req.session?.sessionId,
19
19
  }));
20
- app.get("/config", { config: { tags, package: packageName, policy: "L0" /*role: "admin"*/ } }, apiConfig);
20
+ app.get("/config", { config: { tags, package: packageName, role: "admin" } }, apiConfig);
21
21
  app.get("/dependencies", { config: { tags, package: packageName, policy: "L1", role: "admin" } }, dependencies);
22
22
  }
23
23
  export default plugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "2.5.40",
3
+ "version": "2.5.42",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [