@adminforth/two-factors-auth 3.3.3 → 3.3.4

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
@@ -16,5 +16,5 @@ custom/pnpm-lock.yaml
16
16
  custom/tsconfig.json
17
17
  custom/utils.js
18
18
 
19
- sent 285,623 bytes received 229 bytes 571,704.00 bytes/sec
20
- total size is 284,729 speedup is 1.00
19
+ sent 286,099 bytes received 229 bytes 572,656.00 bytes/sec
20
+ total size is 285,205 speedup is 1.00
@@ -241,7 +241,23 @@
241
241
  return JSON.stringify((credential as PublicKeyCredential).toJSON());
242
242
  } catch (error) {
243
243
  console.error(t('Error creating WebAuthn credential:', error));
244
- adminforth.alert({ message: t('Error creating passkey.'), variant: 'warning' });
244
+
245
+ let message = t('Failed to create passkey.');
246
+
247
+ if (error?.name === 'InvalidStateError') {
248
+ message = t('A passkey for this account already exists on this device.');
249
+ }
250
+
251
+ if (error?.name === 'NotAllowedError') {
252
+ message = t('Passkey creation was cancelled.');
253
+ }
254
+
255
+ if (error?.name === 'NotSupportedError') {
256
+ message = t('Passkeys are not supported on this device or browser.');
257
+ }
258
+
259
+ adminforth.alert({ message, variant: 'danger'});
260
+
245
261
  return null;
246
262
  }
247
263
  }
package/custom/utils.js CHANGED
@@ -122,7 +122,7 @@
122
122
  codeError.value = t('A previous passkey attempt was still pending. Please try again.');
123
123
  return null;
124
124
  } else if (name === 'NotAllowedError') {
125
- adminforth.alert({ message: `The operation either timed out or was not allowed`, variant: 'warning' });
125
+ adminforth.alert({ message: `The operation either timed out or was not allowed`, variant: 'danger' });
126
126
  codeError.value = 'The operation either timed out or was not allowed.';
127
127
  return null;
128
128
  } else {
@@ -241,7 +241,23 @@
241
241
  return JSON.stringify((credential as PublicKeyCredential).toJSON());
242
242
  } catch (error) {
243
243
  console.error(t('Error creating WebAuthn credential:', error));
244
- adminforth.alert({ message: t('Error creating passkey.'), variant: 'warning' });
244
+
245
+ let message = t('Failed to create passkey.');
246
+
247
+ if (error?.name === 'InvalidStateError') {
248
+ message = t('A passkey for this account already exists on this device.');
249
+ }
250
+
251
+ if (error?.name === 'NotAllowedError') {
252
+ message = t('Passkey creation was cancelled.');
253
+ }
254
+
255
+ if (error?.name === 'NotSupportedError') {
256
+ message = t('Passkeys are not supported on this device or browser.');
257
+ }
258
+
259
+ adminforth.alert({ message, variant: 'danger'});
260
+
245
261
  return null;
246
262
  }
247
263
  }
@@ -122,7 +122,7 @@
122
122
  codeError.value = t('A previous passkey attempt was still pending. Please try again.');
123
123
  return null;
124
124
  } else if (name === 'NotAllowedError') {
125
- adminforth.alert({ message: `The operation either timed out or was not allowed`, variant: 'warning' });
125
+ adminforth.alert({ message: `The operation either timed out or was not allowed`, variant: 'danger' });
126
126
  codeError.value = 'The operation either timed out or was not allowed.';
127
127
  return null;
128
128
  } else {
package/dist/index.js CHANGED
@@ -575,7 +575,8 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
575
575
  return { status: 'ok', allowedLogin: true };
576
576
  }
577
577
  else {
578
- return { error: 'Verification failed' };
578
+ response.setStatus(403);
579
+ return { error: 'Wrong or expired TOTP code', };
579
580
  }
580
581
  }
581
582
  })
package/index.ts CHANGED
@@ -617,7 +617,8 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
617
617
  this.adminforth.auth.setAuthCookie({expireInDuration: decoded.sessionDuration, response, username:decoded.userName, pk:decoded.pk})
618
618
  return { status: 'ok', allowedLogin: true }
619
619
  } else {
620
- return {error: 'Verification failed'}
620
+ response.setStatus(403);
621
+ return {error: 'Wrong or expired TOTP code', }
621
622
  }
622
623
  }
623
624
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/two-factors-auth",
3
- "version": "3.3.3",
3
+ "version": "3.3.4",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "^22.10.7",
35
- "adminforth": "^2.50.1",
35
+ "adminforth": "^2.66.0",
36
36
  "semantic-release": "^24.2.1",
37
37
  "semantic-release-slack-bot": "^4.0.2",
38
38
  "typescript": "^5.7.3"