@adminforth/two-factors-auth 2.9.16 → 2.9.17
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/build.log +1 -1
- package/dist/index.js +6 -4
- package/index.ts +22 -13
- package/package.json +2 -2
package/build.log
CHANGED
package/dist/index.js
CHANGED
|
@@ -306,9 +306,9 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
306
306
|
}
|
|
307
307
|
const beforeLoginConfirmation = this.adminforth.config.auth.beforeLoginConfirmation;
|
|
308
308
|
const beforeLoginConfirmationArray = Array.isArray(beforeLoginConfirmation) ? beforeLoginConfirmation : [beforeLoginConfirmation];
|
|
309
|
-
beforeLoginConfirmationArray.push((_a) => __awaiter(this, [_a], void 0, function* ({ adminUser, response, extra }) {
|
|
309
|
+
beforeLoginConfirmationArray.push((_a) => __awaiter(this, [_a], void 0, function* ({ adminUser, response, adminforth, extra, rememberMeDays }) {
|
|
310
310
|
var _b, _c, _d, _e;
|
|
311
|
-
if (((_b = extra === null || extra === void 0 ? void 0 : extra.
|
|
311
|
+
if (((_b = extra === null || extra === void 0 ? void 0 : extra.meta) === null || _b === void 0 ? void 0 : _b.loginAllowedByPasskeyDirectSignIn) === true) {
|
|
312
312
|
return { body: { loginAllowed: true }, ok: true };
|
|
313
313
|
}
|
|
314
314
|
const secret = adminUser.dbUser[this.options.twoFaSecretFieldName];
|
|
@@ -322,7 +322,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
322
322
|
const authPk = authResource.columns.find((col) => col.primaryKey).name;
|
|
323
323
|
const userPk = adminUser.dbUser[authPk];
|
|
324
324
|
const rememberMe = ((_c = extra === null || extra === void 0 ? void 0 : extra.body) === null || _c === void 0 ? void 0 : _c.rememberMe) || false;
|
|
325
|
-
const rememberMeDays = rememberMe ? adminforth.config.auth.rememberMeDays || 30 : 1;
|
|
325
|
+
// const rememberMeDays = rememberMe ? adminforth.config.auth.rememberMeDays || 30 : 1;
|
|
326
326
|
let newSecret = null;
|
|
327
327
|
const userNeeds2FA = this.options.usersFilterToApply ? this.options.usersFilterToApply(adminUser) : true;
|
|
328
328
|
if (!userNeeds2FA) {
|
|
@@ -495,12 +495,14 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
495
495
|
username,
|
|
496
496
|
};
|
|
497
497
|
const toReturn = { allowedLogin: true, error: '' };
|
|
498
|
+
const rememberMe = (body === null || body === void 0 ? void 0 : body.rememberMe) || false;
|
|
498
499
|
yield this.adminforth.restApi.processLoginCallbacks(adminUser, toReturn, response, {
|
|
499
500
|
headers,
|
|
500
501
|
cookies,
|
|
501
502
|
requestUrl,
|
|
502
503
|
query,
|
|
503
|
-
body: {
|
|
504
|
+
body: {},
|
|
505
|
+
meta: {
|
|
504
506
|
loginAllowedByPasskeyDirectSignIn: true
|
|
505
507
|
},
|
|
506
508
|
});
|
package/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdminForthPlugin, Filters, suggestIfTypo } from "adminforth";
|
|
1
|
+
import { AdminForthPlugin, Filters, suggestIfTypo, HttpExtra } from "adminforth";
|
|
2
2
|
import type { AdminForthResource, AdminUser, IAdminForth, IHttpServer, IAdminForthAuth, BeforeLoginConfirmationFunction, IAdminForthHttpResponse } from "adminforth";
|
|
3
3
|
import twofactor from 'node-2fa';
|
|
4
4
|
import { PluginOptions } from "./types.js"
|
|
@@ -341,8 +341,8 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
341
341
|
const beforeLoginConfirmation = this.adminforth.config.auth.beforeLoginConfirmation;
|
|
342
342
|
const beforeLoginConfirmationArray = Array.isArray(beforeLoginConfirmation) ? beforeLoginConfirmation : [beforeLoginConfirmation];
|
|
343
343
|
beforeLoginConfirmationArray.push(
|
|
344
|
-
async({ adminUser, response, extra }: { adminUser: AdminUser, response: IAdminForthHttpResponse, extra?:
|
|
345
|
-
if (extra?.
|
|
344
|
+
async({ adminUser, response, adminforth, extra, rememberMeDays }: { adminUser: AdminUser, response: IAdminForthHttpResponse, adminforth: IAdminForth, extra?: HttpExtra, rememberMeDays?: number} )=> {
|
|
345
|
+
if ( extra?.meta?.loginAllowedByPasskeyDirectSignIn === true) {
|
|
346
346
|
return { body: { loginAllowed: true }, ok: true };
|
|
347
347
|
}
|
|
348
348
|
const secret = adminUser.dbUser[this.options.twoFaSecretFieldName]
|
|
@@ -356,7 +356,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
356
356
|
const authPk = authResource.columns.find((col)=>col.primaryKey).name
|
|
357
357
|
const userPk = adminUser.dbUser[authPk]
|
|
358
358
|
const rememberMe = extra?.body?.rememberMe || false;
|
|
359
|
-
const rememberMeDays = rememberMe ? adminforth.config.auth.rememberMeDays || 30 : 1;
|
|
359
|
+
// const rememberMeDays = rememberMe ? adminforth.config.auth.rememberMeDays || 30 : 1;
|
|
360
360
|
let newSecret = null;
|
|
361
361
|
|
|
362
362
|
const userNeeds2FA = this.options.usersFilterToApply ? this.options.usersFilterToApply(adminUser) : true;
|
|
@@ -543,16 +543,25 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
543
543
|
};
|
|
544
544
|
|
|
545
545
|
const toReturn = { allowedLogin: true, error: '' };
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
546
|
+
const rememberMe = body?.rememberMe || false;
|
|
547
|
+
|
|
548
|
+
await this.adminforth.restApi.processLoginCallbacks(
|
|
549
|
+
adminUser,
|
|
550
|
+
toReturn,
|
|
551
|
+
response,
|
|
552
|
+
{
|
|
553
|
+
headers,
|
|
554
|
+
cookies,
|
|
555
|
+
requestUrl,
|
|
556
|
+
query,
|
|
557
|
+
body: {},
|
|
558
|
+
meta: {
|
|
559
|
+
loginAllowedByPasskeyDirectSignIn: true
|
|
560
|
+
},
|
|
554
561
|
},
|
|
555
|
-
|
|
562
|
+
// rememberMeDays: rememberMe ? this.adminforth.config.auth.rememberMeDays || 30 : 1,
|
|
563
|
+
|
|
564
|
+
);
|
|
556
565
|
|
|
557
566
|
if ( toReturn.allowedLogin === true ) {
|
|
558
567
|
this.adminforth.auth.setAuthCookie({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminforth/two-factors-auth",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.17",
|
|
4
4
|
"description": "AdminForth plugin for two factors authentication",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"node-2fa": "^2.0.3"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"adminforth": "^2.13.0-next.
|
|
32
|
+
"adminforth": "^2.13.0-next.65"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "^22.10.7",
|