@opengis/fastify-table 2.5.69 → 2.5.71

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.
@@ -0,0 +1,3 @@
1
+ {
2
+ "public": true
3
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"getSelectMeta.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/table/funcs/getSelectMeta.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAWzD,wBAA8B,aAAa,CAAC,EAC1C,IAAI,EACJ,UAAU,EACV,GAAG,EACH,OAAO,EACP,MAAM,EACN,IAAI,EACJ,EAAqB,GACtB,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,UAAU,CAAC;CACjB,gBAmIA"}
1
+ {"version":3,"file":"getSelectMeta.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/table/funcs/getSelectMeta.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAWzD,wBAA8B,aAAa,CAAC,EAC1C,IAAI,EACJ,UAAU,EACV,GAAG,EACH,OAAO,EACP,MAAM,EACN,IAAI,EACJ,EAAqB,GACtB,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,UAAU,CAAC;CACjB,gBAoIA"}
@@ -94,6 +94,7 @@ export default async function getSelectMeta({ name, startsWith, key, nocache, pa
94
94
  searchQuery,
95
95
  table: tableNew.join(","),
96
96
  time: new Date().toISOString(),
97
+ access: cls.public === false ? "user" : "public",
97
98
  };
98
99
  selectMeta[name] = data;
99
100
  // on demand - search by "start with these characters"
@@ -26,7 +26,9 @@ export default async function authorize(req, reply) {
26
26
  }
27
27
  const ip = getIp(req);
28
28
  const q = `select * from oauth.clients where client_id=$1 and token_endpoint_auth_method=$2 and (allowed_ips is null or $3=any(allowed_ips)) and ${scope ? "$4=any(scopes)" : "1=1"} order by allowed_ips nulls last limit 1`;
29
- const { owner_user_id: userId, client_secret_hash: secret, redirect_uris = [], scopes, allowed_ips: allowedIPs = [], } = pg.pk?.["oauth.clients"]
29
+ const { owner_user_id: userId, client_secret_hash: secret, redirect_uris = [], scopes,
30
+ // allowed_ips: allowedIPs = [],
31
+ } = pg.pk?.["oauth.clients"]
30
32
  ? await pg
31
33
  .query(q, [client_id, "private_key_jwt", ip, scope].filter(Boolean))
32
34
  .then((el) => el.rows?.[0] || {})
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/auth/index.ts"],"names":[],"mappings":"AAgDA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QAuGtC;AAED,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../server/routes/auth/index.ts"],"names":[],"mappings":"AA6DA,iBAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,GAAE,GAAQ,QAsGtC;AAED,eAAe,MAAM,CAAC"}
@@ -23,6 +23,19 @@ import qrCode from "./controllers/2factor/qrcode.js";
23
23
  const tags = ["core", "auth"];
24
24
  const packageName = "fastify-table";
25
25
  const params = { config: { policy: "L0", tags, package: packageName } };
26
+ const loginApiParams = {
27
+ config: {
28
+ policy: "L0",
29
+ tags,
30
+ package: packageName,
31
+ rateLimit: config.rateLimit
32
+ ? {
33
+ max: +(config.rateLimit?.login?.max || 5),
34
+ timeWindow: config.rateLimit?.login?.timeWindow || "1 minute",
35
+ }
36
+ : undefined,
37
+ },
38
+ };
26
39
  const registrationSchema = {
27
40
  body: {
28
41
  type: "object",
@@ -44,13 +57,11 @@ function plugin(app, opt = {}) {
44
57
  app.get("/logout", params, logout);
45
58
  }
46
59
  if (!app.hasRoute({ method: "GET", url: "/api/login" }) &&
47
- process.env.DISABLE_GET_LOGIN !== "true"
48
- // && process.env.platform === "win32"
49
- ) {
50
- app.get("/api/login", params, login);
60
+ process.env.DISABLE_GET_LOGIN !== "true") {
61
+ app.get("/api/login", loginApiParams, login);
51
62
  }
52
63
  if (!app.hasRoute({ method: "POST", url: "/api/login" })) {
53
- app.post("/api/login", params, login);
64
+ app.post("/api/login", loginApiParams, login);
54
65
  }
55
66
  if (!app.hasRoute({ method: "POST", url: "/api/registration" })) {
56
67
  app.post("/api/registration", { ...params, schema: registrationSchema }, registration);
@@ -1 +1 @@
1
- {"version":3,"file":"suggest.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/suggest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AA+BpD,wBAAsB,kBAAkB,CAAC,EACvC,KAAK,EACL,QAAQ,EACR,MAAM,EACN,UAAU,EACV,QAAQ,EACR,UAAU,EACV,GAAG,EACH,EAAqB,GACtB,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,GAAG,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,UAAU,CAAC;CACjB;;;;;;UAyGA;AAED,wBAA8B,OAAO,CAAC,GAAG,EAAE,GAAG,gBA6d7C"}
1
+ {"version":3,"file":"suggest.d.ts","sourceRoot":"","sources":["../../../../../server/routes/table/controllers/suggest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAgCpD,wBAAsB,kBAAkB,CAAC,EACvC,KAAK,EACL,QAAQ,EACR,MAAM,EACN,UAAU,EACV,QAAQ,EACR,UAAU,EACV,GAAG,EACH,EAAqB,GACtB,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,GAAG,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,UAAU,CAAC;CACjB;;;;;;UAyGA;AAED,wBAA8B,OAAO,CAAC,GAAG,EAAE,GAAG,gBAqe7C"}
@@ -131,12 +131,11 @@ export default async function suggest(req) {
131
131
  const table2 = table1 || query.token;
132
132
  const table = resources[table2] || table2;
133
133
  const column = column1 || query.column;
134
- const { body: hookBody } = table
135
- ? (await applyHook("preSuggest", {
136
- pg: pg1,
137
- table,
138
- })) || {}
139
- : {};
134
+ const { body: hookBody } = (await applyHook("preSuggest", {
135
+ pg: pg1,
136
+ table, // old hook support
137
+ data: params.data, // in case of need for additional security checks
138
+ })) || {};
140
139
  if (params.data === "list" &&
141
140
  (user?.user_type === "admin" || process.platform === "win32")) {
142
141
  const cls = await getTemplate("cls", "list");
@@ -154,6 +153,9 @@ export default async function suggest(req) {
154
153
  };
155
154
  }
156
155
  const body = await getTemplate("table", table);
156
+ if (body && !user?.uid && body.public !== true) {
157
+ throw ForbiddenError("authorization required");
158
+ }
157
159
  if (table && !hookBody?.table && !body?.table) {
158
160
  throw ForbiddenError("invalid params: table");
159
161
  }
@@ -185,6 +187,9 @@ export default async function suggest(req) {
185
187
  lang: query.lang,
186
188
  parent,
187
189
  });
190
+ if (meta?.access === "user" && !user?.uid) {
191
+ throw ForbiddenError("authorization required");
192
+ }
188
193
  if (meta?.minLength && query.key && query.key.length < meta?.minLength) {
189
194
  throw BadRequestError(`min length: ${meta.minLength}`);
190
195
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "2.5.69",
3
+ "version": "2.5.71",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [