@adminforth/two-factors-auth 2.9.13 → 2.9.15

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 CHANGED
@@ -15,5 +15,5 @@ custom/package.json
15
15
  custom/tsconfig.json
16
16
  custom/utils.js
17
17
 
18
- sent 273,800 bytes received 210 bytes 548,020.00 bytes/sec
19
- total size is 272,973 speedup is 1.00
18
+ sent 273,582 bytes received 210 bytes 547,584.00 bytes/sec
19
+ total size is 272,766 speedup is 1.00
@@ -1,17 +1,14 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "baseUrl": ".", // This should point to your project root
3
+ "baseUrl": ".",
4
4
  "paths": {
5
5
  "@/*": [
6
- // "node_modules/adminforth/dist/spa/src/*"
7
6
  "../../../adminforth/spa/src/*"
8
7
  ],
9
8
  "*": [
10
- // "node_modules/adminforth/dist/spa/node_modules/*"
11
9
  "../../../adminforth/spa/node_modules/*"
12
10
  ],
13
11
  "@@/*": [
14
- // "node_modules/adminforth/dist/spa/src/*"
15
12
  "."
16
13
  ]
17
14
  }
@@ -1,17 +1,14 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "baseUrl": ".", // This should point to your project root
3
+ "baseUrl": ".",
4
4
  "paths": {
5
5
  "@/*": [
6
- // "node_modules/adminforth/dist/spa/src/*"
7
6
  "../../../adminforth/spa/src/*"
8
7
  ],
9
8
  "*": [
10
- // "node_modules/adminforth/dist/spa/node_modules/*"
11
9
  "../../../adminforth/spa/node_modules/*"
12
10
  ],
13
11
  "@@/*": [
14
- // "node_modules/adminforth/dist/spa/src/*"
15
12
  "."
16
13
  ]
17
14
  }
package/dist/index.js CHANGED
@@ -207,6 +207,13 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
207
207
  pageLabel: 'Passkeys',
208
208
  slug: 'passkeys',
209
209
  component: this.componentPath('TwoFactorsPasskeysSettings.vue'),
210
+ isVisible: (adminUser) => {
211
+ const secret = adminUser.dbUser[this.options.twoFaSecretFieldName];
212
+ if (!secret || secret.length === 0) {
213
+ return false;
214
+ }
215
+ return true;
216
+ }
210
217
  });
211
218
  if (this.options.passkeys.allowLoginWithPasskeys !== false) {
212
219
  this.options.passkeys.allowLoginWithPasskeys = true;
@@ -648,6 +655,10 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
648
655
  if (decodedPasskeysCookies.user_id !== adminUser.pk) {
649
656
  return { error: 'Invalid user' };
650
657
  }
658
+ const secret = adminUser.dbUser[this.options.twoFaSecretFieldName];
659
+ if (!secret || secret.length === 0) {
660
+ return { error: 'TOTP must be set up before registering a passkey' };
661
+ }
651
662
  const settingsOrigin = (_b = this.options.passkeys) === null || _b === void 0 ? void 0 : _b.settings.expectedOrigin;
652
663
  const expectedOrigin = body.origin;
653
664
  const expectedChallenge = decodedPasskeysCookies.challenge;
package/index.ts CHANGED
@@ -219,6 +219,13 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
219
219
  pageLabel: 'Passkeys',
220
220
  slug: 'passkeys',
221
221
  component: this.componentPath('TwoFactorsPasskeysSettings.vue'),
222
+ isVisible: (adminUser: AdminUser) => {
223
+ const secret = adminUser.dbUser[this.options.twoFaSecretFieldName]
224
+ if (!secret || secret.length === 0) {
225
+ return false;
226
+ }
227
+ return true;
228
+ }
222
229
  });
223
230
 
224
231
  if ( this.options.passkeys.allowLoginWithPasskeys !== false ) {
@@ -701,6 +708,10 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
701
708
  if (decodedPasskeysCookies.user_id !== adminUser.pk) {
702
709
  return { error: 'Invalid user' };
703
710
  }
711
+ const secret = adminUser.dbUser[this.options.twoFaSecretFieldName]
712
+ if (!secret || secret.length === 0) {
713
+ return { error: 'TOTP must be set up before registering a passkey' };
714
+ }
704
715
  const settingsOrigin = this.options.passkeys?.settings.expectedOrigin;
705
716
  const expectedOrigin = body.origin;
706
717
  const expectedChallenge = decodedPasskeysCookies.challenge;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/two-factors-auth",
3
- "version": "2.9.13",
3
+ "version": "2.9.15",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -26,9 +26,11 @@
26
26
  "license": "ISC",
27
27
  "dependencies": {
28
28
  "@simplewebauthn/server": "^13.2.1",
29
- "adminforth": "^2.4.0-next.221",
30
29
  "node-2fa": "^2.0.3"
31
30
  },
31
+ "peerDependencies": {
32
+ "adminforth": "^2.4.0-next.321"
33
+ },
32
34
  "devDependencies": {
33
35
  "@types/node": "^22.10.7",
34
36
  "semantic-release": "^24.2.1",