@opengis/fastify-table 2.4.8 → 2.4.10

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":"validateData.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/crud/funcs/validateData.ts"],"names":[],"mappings":"AA+GA,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
+ {"version":3,"file":"validateData.d.ts","sourceRoot":"","sources":["../../../../../server/plugins/crud/funcs/validateData.ts"],"names":[],"mappings":"AAkIA,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"}
@@ -2,6 +2,11 @@ import config from "../../../../config.js";
2
2
  /* eslint-disable no-console */
3
3
  // eslint-disable-next-line no-control-regex
4
4
  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;
5
+ function isNumeric(value) {
6
+ if (value === null || value === "")
7
+ return false;
8
+ return Number.isFinite(Number(value));
9
+ }
5
10
  function checkField(key, val, options, idx, body) {
6
11
  const type = options?.type?.toLowerCase?.();
7
12
  const isrequired = options?.validators?.includes?.("required");
@@ -26,6 +31,20 @@ function checkField(key, val, options, idx, body) {
26
31
  };
27
32
  }
28
33
  }
34
+ else if (type === "number") {
35
+ // required + empty
36
+ if (isrequired && !isNumeric(val)) {
37
+ return { error: "invalid value", key, idx };
38
+ }
39
+ if (isNumeric(val)) {
40
+ if (isNumeric(options.min) && +val < +options.min) {
41
+ return { error: "Number out of range", key, idx };
42
+ }
43
+ if (isNumeric(options.max) && +val > +options.max) {
44
+ return { error: "Number out of range", key, idx };
45
+ }
46
+ }
47
+ }
29
48
  else if (isrequired && !val) {
30
49
  if (options?.conditions) {
31
50
  const allowed = typeof options?.conditions?.[2] === "string" &&
@@ -9,8 +9,12 @@ interface ICode {
9
9
  pg: ExtendedPG;
10
10
  enable?: boolean;
11
11
  }
12
- declare const enableSecret: ({ uid, pg }: ISecret) => Promise<void>;
13
- declare const deleteSecret: ({ uid, pg }: ISecret) => Promise<void>;
12
+ declare const enableSecret: ({ uid, pg }: ISecret) => Promise<{
13
+ rowCount: any;
14
+ }>;
15
+ declare const deleteSecret: ({ uid, pg }: ISecret) => Promise<{
16
+ rowCount: any;
17
+ }>;
14
18
  declare const getSecret: ({ uid, pg }: ISecret) => Promise<{
15
19
  secret: any;
16
20
  enabled: any;
@@ -1 +1 @@
1
- {"version":3,"file":"totp.d.ts","sourceRoot":"","sources":["../../../../../../../server/routes/auth/controllers/2factor/providers/totp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAW1D,UAAU,OAAO;I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Ac5C,CAAC;AAuBF,QAAA,MAAM,QAAQ,GAAU,aAAa,OAAO;;;;;;;;;;;;EA0D3C,CAAC;AAEF,QAAA,MAAM,MAAM,GAAU,0BAA0B,KAAK;;;EAmBpD,CAAC;AAKF,QAAA,MAAM,MAAM,GAAU,2BAA2B,KAAK,iBAqBrD,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;;AAE3E,wBAAoB"}
@@ -11,17 +11,23 @@ const getOTP = (id, secret) => {
11
11
  return `otpauth://totp/${issuer}:${encodeURIComponent(id.toString())}?secret=${secret}&period=30&digits=6&algorithm=SHA1&issuer=${encodeURIComponent(issuer)}`;
12
12
  };
13
13
  const enableSecret = async ({ uid, pg }) => {
14
- await pg.query("update admin.users_social_auth set enabled=true where uid = $1 and social_auth_type = $2", [uid, TYPE]);
14
+ const rowCount = await pg
15
+ .query("update admin.users_social_auth set enabled=true where uid = $1 and social_auth_type = $2", [uid, TYPE])
16
+ .then((r) => r.rowCount);
17
+ return { rowCount };
15
18
  };
16
19
  const deleteSecret = async ({ uid, pg }) => {
17
- await pg.query("delete from admin.users_social_auth where uid=$1 and social_auth_type = $2", [uid, TYPE]);
20
+ const rowCount = await pg
21
+ .query("delete from admin.users_social_auth where uid=$1 and social_auth_type = $2", [uid, TYPE])
22
+ .then((r) => r.rowCount);
23
+ return { rowCount };
18
24
  };
19
25
  const getSecret = async ({ uid, pg }) => {
20
26
  const { social_auth_code: secret, enabled, recoveryCodes, } = await pg
21
27
  .query(`select social_auth_code, enabled, social_auth_obj->'codesArray' as "recoveryCodes"
22
28
  from admin.users_social_auth
23
29
  where uid = $1 and social_auth_type = $2`, [uid, TYPE])
24
- .then((el) => el.rows?.[0] || {});
30
+ .then((r) => r.rows?.[0] || {});
25
31
  return { secret, enabled, recoveryCodes };
26
32
  };
27
33
  const addSecret = async ({ uid, secret, pg, recoveryCodes, otp }) => {
@@ -33,7 +39,7 @@ const updateSecret = async ({ uid, pg, secret, recoveryCodes, otp }) => {
33
39
  .query(`update admin.users_social_auth
34
40
  set social_auth_code=$3, social_auth_obj=$4::json, social_auth_url=$5
35
41
  where uid = $1 and social_auth_type = $2`, [uid, TYPE, secret, { codesArray: recoveryCodes }, otp])
36
- .then((el) => el.rows?.[0] || {});
42
+ .then((r) => r.rows?.[0] || {});
37
43
  return result;
38
44
  };
39
45
  // return a new secret until it's enabled
@@ -51,7 +57,7 @@ const generate = async ({ uid, pg }) => {
51
57
  ];
52
58
  const userData = await pg
53
59
  .query(`select social_auth_id as code, coalesce(login,email) as login, email from admin.users where uid=$1`, [uid])
54
- .then((el) => el.rows?.[0] || {});
60
+ .then((r) => r.rows?.[0] || {});
55
61
  const { sufix } = config.auth?.["2fa"] || {};
56
62
  if (sufix && !userData[sufix]) {
57
63
  console.warn("⚠️ 2fa prefix not found at userData");
@@ -90,7 +96,8 @@ const verify = async ({ uid, code: token, pg }) => {
90
96
  if (!secret) {
91
97
  throw new BadRequestError("Включіть двофакторну аутентифікацію");
92
98
  }
93
- const isValid = authenticator.verify({ token, secret }) ||
99
+ const { valid } = await authenticator.verify({ token, secret });
100
+ const isValid = valid ||
94
101
  recoveryCodes.reduce((result, recoveryCode) => result || recoveryCode === token, false);
95
102
  if (!isValid) {
96
103
  throw new ForbiddenError("Невірний код");
@@ -49,7 +49,7 @@ export default function apiListService({ includeTags: queryIncludeTags, excludeT
49
49
  const markdownStr = toMarkdownTable(filteredRoutes3, Array.isArray(columns) ? columns : columns.split("|"));
50
50
  return {
51
51
  headers: {
52
- "Content-Type": "text/markdown",
52
+ "Content-Type": "text/markdown; charset=utf-8",
53
53
  },
54
54
  data: markdownStr,
55
55
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "2.4.8",
3
+ "version": "2.4.10",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [