@adminforth/two-factors-auth 2.1.3 → 2.1.5

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
@@ -13,5 +13,5 @@ custom/package.json
13
13
  custom/tsconfig.json
14
14
  custom/utils.js
15
15
 
16
- sent 76,042 bytes received 172 bytes 152,428.00 bytes/sec
17
- total size is 75,402 speedup is 0.99
16
+ sent 77,515 bytes received 172 bytes 155,374.00 bytes/sec
17
+ total size is 76,884 speedup is 0.99
@@ -349,8 +349,11 @@
349
349
  }
350
350
  }
351
351
 
352
+ let controller = new AbortController();
353
+
352
354
  async function authenticate(options) {
353
355
  console.log("Authenticating with options:", options);
356
+ controller.abort();
354
357
  try {
355
358
  // Guard: prevent concurrent navigator.credentials.get calls
356
359
  if (webAuthn.inFlight) {
@@ -377,14 +380,19 @@
377
380
  if (name === 'AbortError') {
378
381
  // Aborted intentionally; no user-facing error needed
379
382
  return null;
380
- }
381
- if (name === 'InvalidStateError' || name === 'OperationError' || /pending/i.test(message)) {
383
+ } else if (name === 'InvalidStateError' || name === 'OperationError' || /pending/i.test(message)) {
382
384
  adminforth.alert({ message: t('Another security prompt is already open. Please try again.'), variant: 'warning' });
383
385
  codeError.value = t('A previous passkey attempt was still pending. Please try again.');
384
386
  return null;
387
+ } else if (name === 'NotAllowedError') {
388
+ adminforth.alert({ message: `The operation either timed out or was not allowed`, variant: 'warning' });
389
+ codeError.value = 'The operation either timed out or was not allowed.';
390
+ return null;
391
+ } else {
392
+ adminforth.alert({message: `Error during authentication: ${error}`, variant: 'warning'});
393
+ codeError.value = 'Error during authentication.';
394
+ return null;
385
395
  }
386
- adminforth.alert({message: `Error during authentication: ${error}`, variant: 'warning'});
387
- codeError.value = 'Error during authentication.';
388
396
  }
389
397
  finally {
390
398
  // Clear in-flight state regardless of outcome
package/custom/utils.js CHANGED
@@ -91,7 +91,10 @@
91
91
  }
92
92
  }
93
93
 
94
+ let controller = new AbortController();
95
+
94
96
  async function authenticate(options) {
97
+ controller.abort();
95
98
  try {
96
99
  const abortController = new AbortController();
97
100
  const credential = await navigator.credentials.get({
@@ -100,7 +103,25 @@
100
103
  });
101
104
  return credential;
102
105
  } catch (error) {
103
- adminforth.alert({message: 'Error during authentication', variant: 'warning'});
104
- codeError.value = 'Error during authentication.';
106
+ console.error('Error during authentication:', error);
107
+ // Handle specific concurrent/pending request error cases gracefully
108
+ const name = (error && (error.name || error.constructor?.name)) || '';
109
+ const message = (error && error.message) || '';
110
+ if (name === 'AbortError') {
111
+ // Aborted intentionally; no user-facing error needed
112
+ return null;
113
+ } else if (name === 'InvalidStateError' || name === 'OperationError' || /pending/i.test(message)) {
114
+ adminforth.alert({ message: t('Another security prompt is already open. Please try again.'), variant: 'warning' });
115
+ codeError.value = t('A previous passkey attempt was still pending. Please try again.');
116
+ return null;
117
+ } else if (name === 'NotAllowedError') {
118
+ adminforth.alert({ message: `The operation either timed out or was not allowed`, variant: 'warning' });
119
+ codeError.value = 'The operation either timed out or was not allowed.';
120
+ return null;
121
+ } else {
122
+ adminforth.alert({message: `Error during authentication: ${error}`, variant: 'warning'});
123
+ codeError.value = 'Error during authentication.';
124
+ return null;
125
+ }
105
126
  }
106
127
  }
@@ -349,8 +349,11 @@
349
349
  }
350
350
  }
351
351
 
352
+ let controller = new AbortController();
353
+
352
354
  async function authenticate(options) {
353
355
  console.log("Authenticating with options:", options);
356
+ controller.abort();
354
357
  try {
355
358
  // Guard: prevent concurrent navigator.credentials.get calls
356
359
  if (webAuthn.inFlight) {
@@ -377,14 +380,19 @@
377
380
  if (name === 'AbortError') {
378
381
  // Aborted intentionally; no user-facing error needed
379
382
  return null;
380
- }
381
- if (name === 'InvalidStateError' || name === 'OperationError' || /pending/i.test(message)) {
383
+ } else if (name === 'InvalidStateError' || name === 'OperationError' || /pending/i.test(message)) {
382
384
  adminforth.alert({ message: t('Another security prompt is already open. Please try again.'), variant: 'warning' });
383
385
  codeError.value = t('A previous passkey attempt was still pending. Please try again.');
384
386
  return null;
387
+ } else if (name === 'NotAllowedError') {
388
+ adminforth.alert({ message: `The operation either timed out or was not allowed`, variant: 'warning' });
389
+ codeError.value = 'The operation either timed out or was not allowed.';
390
+ return null;
391
+ } else {
392
+ adminforth.alert({message: `Error during authentication: ${error}`, variant: 'warning'});
393
+ codeError.value = 'Error during authentication.';
394
+ return null;
385
395
  }
386
- adminforth.alert({message: `Error during authentication: ${error}`, variant: 'warning'});
387
- codeError.value = 'Error during authentication.';
388
396
  }
389
397
  finally {
390
398
  // Clear in-flight state regardless of outcome
@@ -91,7 +91,10 @@
91
91
  }
92
92
  }
93
93
 
94
+ let controller = new AbortController();
95
+
94
96
  async function authenticate(options) {
97
+ controller.abort();
95
98
  try {
96
99
  const abortController = new AbortController();
97
100
  const credential = await navigator.credentials.get({
@@ -100,7 +103,25 @@
100
103
  });
101
104
  return credential;
102
105
  } catch (error) {
103
- adminforth.alert({message: 'Error during authentication', variant: 'warning'});
104
- codeError.value = 'Error during authentication.';
106
+ console.error('Error during authentication:', error);
107
+ // Handle specific concurrent/pending request error cases gracefully
108
+ const name = (error && (error.name || error.constructor?.name)) || '';
109
+ const message = (error && error.message) || '';
110
+ if (name === 'AbortError') {
111
+ // Aborted intentionally; no user-facing error needed
112
+ return null;
113
+ } else if (name === 'InvalidStateError' || name === 'OperationError' || /pending/i.test(message)) {
114
+ adminforth.alert({ message: t('Another security prompt is already open. Please try again.'), variant: 'warning' });
115
+ codeError.value = t('A previous passkey attempt was still pending. Please try again.');
116
+ return null;
117
+ } else if (name === 'NotAllowedError') {
118
+ adminforth.alert({ message: `The operation either timed out or was not allowed`, variant: 'warning' });
119
+ codeError.value = 'The operation either timed out or was not allowed.';
120
+ return null;
121
+ } else {
122
+ adminforth.alert({message: `Error during authentication: ${error}`, variant: 'warning'});
123
+ codeError.value = 'Error during authentication.';
124
+ return null;
125
+ }
105
126
  }
106
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/two-factors-auth",
3
- "version": "2.1.3",
3
+ "version": "2.1.5",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",