@adminforth/two-factors-auth 4.2.1 → 4.2.3
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 +3 -4
- package/dist/types.d.ts +3 -3
- package/index.ts +3 -4
- package/package.json +3 -3
- package/pnpm-workspace.yaml +1 -1
- package/services/passkeyService.ts +2 -2
- package/types.ts +3 -3
package/build.log
CHANGED
package/dist/index.js
CHANGED
|
@@ -45,10 +45,9 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
45
45
|
//check if user has 2FA set up
|
|
46
46
|
const users2FASecret = this.userRepository.getSecret(userRecord);
|
|
47
47
|
//check if user has any passkeys registered
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
48
|
+
const userHasPasskeys = this.options.passkeys
|
|
49
|
+
? yield this.passkeyService.hasPasskeysForUser(adminUser.dbUser[userPkFieldName])
|
|
50
|
+
: false;
|
|
52
51
|
// If user has either 2FA secret or any passkeys, they cannot skip
|
|
53
52
|
if (users2FASecret || userHasPasskeys) {
|
|
54
53
|
return { skipAllowed: false };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AdminUser, KeyValueAdapter } from "adminforth";
|
|
2
|
-
import { type PluginsCommonOptions } from "adminforth";
|
|
2
|
+
import { type PluginsCommonOptions, PeriodString } from "adminforth";
|
|
3
3
|
export interface PluginOptions extends PluginsCommonOptions {
|
|
4
4
|
/**
|
|
5
5
|
* Name of the field in the auth resource which will store 2FA secret.
|
|
@@ -46,11 +46,11 @@ export interface PluginOptions extends PluginsCommonOptions {
|
|
|
46
46
|
/**
|
|
47
47
|
* Period between showing alert suggesting to set up Passkeys if not set up yet.
|
|
48
48
|
*/
|
|
49
|
-
suggestionPeriod?:
|
|
49
|
+
suggestionPeriod?: PeriodString;
|
|
50
50
|
/**
|
|
51
51
|
* Challenge period for Passkeys authentication.
|
|
52
52
|
*/
|
|
53
|
-
challengeValidityPeriod?:
|
|
53
|
+
challengeValidityPeriod?: PeriodString;
|
|
54
54
|
/**
|
|
55
55
|
* Passkeys settings for WebAuthn API.
|
|
56
56
|
*/
|
package/index.ts
CHANGED
|
@@ -54,10 +54,9 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
|
54
54
|
//check if user has 2FA set up
|
|
55
55
|
const users2FASecret = this.userRepository.getSecret(userRecord);
|
|
56
56
|
//check if user has any passkeys registered
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
57
|
+
const userHasPasskeys = this.options.passkeys
|
|
58
|
+
? await this.passkeyService.hasPasskeysForUser(adminUser.dbUser[userPkFieldName])
|
|
59
|
+
: false;
|
|
61
60
|
|
|
62
61
|
// If user has either 2FA secret or any passkeys, they cannot skip
|
|
63
62
|
if (users2FASecret || userHasPasskeys) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminforth/two-factors-auth",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.3",
|
|
4
4
|
"description": "AdminForth plugin for two factors authentication",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"node-2fa": "^2.0.3"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"adminforth": "^3.
|
|
31
|
+
"adminforth": "^3.6.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^22.10.7",
|
|
35
|
-
"adminforth": "^3.
|
|
35
|
+
"adminforth": "^3.6.2",
|
|
36
36
|
"semantic-release": "^24.2.1",
|
|
37
37
|
"semantic-release-slack-bot": "^4.0.2",
|
|
38
38
|
"typescript": "^5.7.3"
|
package/pnpm-workspace.yaml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { convertPeriodToSeconds } from "adminforth";
|
|
2
|
-
import type { AdminUser, IAdminForth, IAdminForthHttpResponse } from "adminforth";
|
|
2
|
+
import type { AdminUser, IAdminForth, IAdminForthHttpResponse, PeriodString } from "adminforth";
|
|
3
3
|
import {
|
|
4
4
|
generateRegistrationOptions,
|
|
5
5
|
verifyRegistrationResponse,
|
|
@@ -39,7 +39,7 @@ export class PasskeyService {
|
|
|
39
39
|
private readonly cookieService = new CookieService(adminforth, options),
|
|
40
40
|
) {}
|
|
41
41
|
|
|
42
|
-
private async markChallengeAsUsed(challenge: string, expiresIn?:
|
|
42
|
+
private async markChallengeAsUsed(challenge: string, expiresIn?: PeriodString): Promise<void> {
|
|
43
43
|
const expiresInSeconds = expiresIn ? convertPeriodToSeconds(expiresIn) : undefined;
|
|
44
44
|
await this.options.passkeys.keyValueAdapter.set(challenge, 'stub_value', expiresInSeconds);
|
|
45
45
|
}
|
package/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AdminUser, KeyValueAdapter } from "adminforth";
|
|
2
|
-
import {type PluginsCommonOptions } from "adminforth";
|
|
2
|
+
import {type PluginsCommonOptions, PeriodString } from "adminforth";
|
|
3
3
|
|
|
4
4
|
export interface PluginOptions extends PluginsCommonOptions {
|
|
5
5
|
|
|
@@ -58,11 +58,11 @@ export interface PluginOptions extends PluginsCommonOptions {
|
|
|
58
58
|
/**
|
|
59
59
|
* Period between showing alert suggesting to set up Passkeys if not set up yet.
|
|
60
60
|
*/
|
|
61
|
-
suggestionPeriod?:
|
|
61
|
+
suggestionPeriod?: PeriodString; // e.g. '30d', '12h', '15m'. Default is '5d'
|
|
62
62
|
/**
|
|
63
63
|
* Challenge period for Passkeys authentication.
|
|
64
64
|
*/
|
|
65
|
-
challengeValidityPeriod?:
|
|
65
|
+
challengeValidityPeriod?: PeriodString; // e.g. '5m', '10m', '15m'. Default is '1m'
|
|
66
66
|
/**
|
|
67
67
|
* Passkeys settings for WebAuthn API.
|
|
68
68
|
*/
|