@opengis/fastify-table 2.4.9 → 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.
- package/dist/server/routes/auth/controllers/2factor/providers/totp.d.ts +6 -2
- package/dist/server/routes/auth/controllers/2factor/providers/totp.d.ts.map +1 -1
- package/dist/server/routes/auth/controllers/2factor/providers/totp.js +13 -6
- package/dist/server/routes/util/controllers/api.list.js +1 -1
- package/package.json +1 -1
|
@@ -9,8 +9,12 @@ interface ICode {
|
|
|
9
9
|
pg: ExtendedPG;
|
|
10
10
|
enable?: boolean;
|
|
11
11
|
}
|
|
12
|
-
declare const enableSecret: ({ uid, pg }: ISecret) => Promise<
|
|
13
|
-
|
|
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;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,UAAU,CAAC;CAChB;AAED,UAAU,KAAK;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,UAAU,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAuBD,QAAA,MAAM,YAAY,GAAU,aAAa,OAAO
|
|
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;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,UAAU,CAAC;CAChB;AAED,UAAU,KAAK;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,UAAU,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAuBD,QAAA,MAAM,YAAY,GAAU,aAAa,OAAO;;EAQ/C,CAAC;AAEF,QAAA,MAAM,YAAY,GAAU,aAAa,OAAO;;EAQ/C,CAAC;AAEF,QAAA,MAAM,SAAS,GAAU,aAAa,OAAO;;;;EAc5C,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
|
-
|
|
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
|
-
|
|
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((
|
|
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((
|
|
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((
|
|
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
|
|
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
|
};
|