@opengis/fastify-table 2.0.85 → 2.0.87

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":"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"}
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;AA0BvC;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAA8B,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,kBAmEzE"}
@@ -1,6 +1,6 @@
1
1
  import path from "node:path";
2
2
  import { fileURLToPath } from "url";
3
- import { readFile } from "node:fs/promises";
3
+ import { existsSync, readFileSync } from "node:fs";
4
4
  import config from "../../../../../config.js";
5
5
  import getTemplate from "../../../../plugins/table/funcs/getTemplate.js";
6
6
  import pgClients from "../../../../plugins/pg/pgClients.js";
@@ -9,6 +9,9 @@ import { verify, enableSecret } from "./providers/totp.js";
9
9
  import sendNotification from "../../../../plugins/auth/funcs/sendNotification.js";
10
10
  const template = "recovery-codes-email-template";
11
11
  const dirname = path.dirname(fileURLToPath(import.meta.url));
12
+ const defaultPt = existsSync(path.join(dirname, `../../../../templates/pt/${template}.hbs`))
13
+ ? readFileSync(path.join(dirname, `../../../../templates/pt/${template}.hbs`), "utf8")
14
+ : "Recovery codes: {{{code}}}";
12
15
  /**
13
16
  * Перевірка двохфакторної авторизації для користувача
14
17
  *
@@ -48,16 +51,16 @@ export default async function verifyFunction(req, reply) {
48
51
  uid,
49
52
  });
50
53
  req.session.secondFactorPassed = true;
51
- if (!enabled) {
54
+ if (!enabled && email) {
52
55
  const { recoveryCodes } = await pg
53
56
  .query(`select social_auth_obj->'codesArray' as "recoveryCodes"
54
57
  from admin.users_social_auth where uid=$1 and social_auth_type='TOTP'`, [uid])
55
58
  ?.then((el) => el.rows?.[0] || {});
56
59
  const customPt = await getTemplate("pt", template);
57
- const pt = customPt ||
58
- (await readFile(path.join(dirname, `../../../../../templates/pt/${template}.hbs`), "utf8"));
60
+ const pt = customPt || defaultPt;
59
61
  const html = await handlebars.compile(pt)({
60
62
  recoveryCodes,
63
+ code: recoveryCodes,
61
64
  domain: `${req.protocol || "https"}://${req.hostname}`,
62
65
  });
63
66
  await sendNotification({
@@ -0,0 +1,13 @@
1
+ <div style="background:#eee;padding:30px;">
2
+ <div
3
+ style="background:#fff;padding: 15px 20px;width: 550px;border: 1px solid #e3e3e5;border-radius:3px;margin: 0 auto;font: normal 13px/19px Verdana;box-shadow: 0 3px 7px rgba(0,0,0,.1);">
4
+ <h2 style="font:normal 21px/48px Arial;color: #222;text-align:center">
5
+ Коди відновлення на випадок втрати доступу до застосунку для двофакторної аутентифікації порталу {{domain}}
6
+ </h2>
7
+ {{#each recoveryCodes}}
8
+ <p style="width: 400px;margin:0 auto;display: block;background: #4CAF50;color: #fff;font-weight:bold; line-height: 44px;text-align: center;text-decoration: none;border-radius: 3px;text-shadow: 0 1px 3px rgba(0,0,0,.35);border: 1px solid #388E3C;box-shadow: inset 0 1px rgba(255,255,255,.4);">
9
+ {{this}}<hr>
10
+ </p>
11
+ {{/each}}
12
+ </div>
13
+ </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/fastify-table",
3
- "version": "2.0.85",
3
+ "version": "2.0.87",
4
4
  "type": "module",
5
5
  "description": "core-plugins",
6
6
  "keywords": [
@@ -23,7 +23,7 @@
23
23
  "scripts": {
24
24
  "prepublishOnly": "npm run build",
25
25
  "clean": "tsc -b --clean",
26
- "build": "tsc -b --clean && tsc && copyfiles server/plugins/grpc/utils/*.proto dist && copyfiles server/migrations/*.sql dist && copyfiles server/templates/**/*.html dist",
26
+ "build": "tsc -b --clean && tsc && copyfiles server/plugins/grpc/utils/*.proto dist && copyfiles server/migrations/*.sql dist && copyfiles server/templates/**/*.html dist && copyfiles server/templates/**/*.hbs dist",
27
27
  "prod": "NODE_ENV=production bun dist/server",
28
28
  "patch": "npm version patch && git push && npm publish",
29
29
  "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",