@adminforth/two-factors-auth 2.1.2 → 2.1.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
@@ -13,5 +13,5 @@ custom/package.json
13
13
  custom/tsconfig.json
14
14
  custom/utils.js
15
15
 
16
- sent 74,931 bytes received 172 bytes 150,206.00 bytes/sec
17
- total size is 74,291 speedup is 0.99
16
+ sent 77,390 bytes received 172 bytes 155,124.00 bytes/sec
17
+ total size is 76,750 speedup is 0.99
@@ -204,13 +204,25 @@
204
204
  });
205
205
 
206
206
  async function isCMAAvailable() {
207
+ let isCMA_supported = false;
208
+ let isParsingSupported = false;
207
209
  if (window.PublicKeyCredential &&
208
210
  PublicKeyCredential.isConditionalMediationAvailable) {
209
211
  const isCMA = await PublicKeyCredential.isConditionalMediationAvailable();
210
- if (isCMA) {
211
- isPasskeysSupported.value = true;
212
- }
212
+ if (isCMA) {
213
+ isCMA_supported = true;
214
+ }
215
+ }
216
+ try {
217
+ const temp = PublicKeyCredential.parseRequestOptionsFromJSON({challenge: 'test123', timeout: 60000, userVerification: 'required'});
218
+ if (temp && typeof temp === 'object') {
219
+ isParsingSupported = true;
220
+ }
221
+ } catch (e) {
222
+ adminforth.alert({message: 'Please ensure your browser supports passkeys.', variant: 'warning'});
223
+ isParsingSupported = false;
213
224
  }
225
+ isPasskeysSupported.value = (isCMA_supported && isParsingSupported);
214
226
  }
215
227
 
216
228
  onBeforeUnmount(() => {
@@ -365,14 +377,19 @@
365
377
  if (name === 'AbortError') {
366
378
  // Aborted intentionally; no user-facing error needed
367
379
  return null;
368
- }
369
- if (name === 'InvalidStateError' || name === 'OperationError' || /pending/i.test(message)) {
380
+ } else if (name === 'InvalidStateError' || name === 'OperationError' || /pending/i.test(message)) {
370
381
  adminforth.alert({ message: t('Another security prompt is already open. Please try again.'), variant: 'warning' });
371
382
  codeError.value = t('A previous passkey attempt was still pending. Please try again.');
372
383
  return null;
384
+ } else if (name === 'NotAllowedError') {
385
+ adminforth.alert({ message: `The operation either timed out or was not allowed`, variant: 'warning' });
386
+ codeError.value = 'The operation either timed out or was not allowed.';
387
+ return null;
388
+ } else {
389
+ adminforth.alert({message: `Error during authentication: ${error}`, variant: 'warning'});
390
+ codeError.value = 'Error during authentication.';
391
+ return null;
373
392
  }
374
- adminforth.alert({message: `Error during authentication: ${error}`, variant: 'warning'});
375
- codeError.value = 'Error during authentication.';
376
393
  }
377
394
  finally {
378
395
  // Clear in-flight state regardless of outcome
@@ -327,6 +327,8 @@
327
327
  }
328
328
 
329
329
  function checkForCompatibility() {
330
+ let isCMA_supported = false;
331
+ let isParsingSupported = false;
330
332
  if (window.PublicKeyCredential &&
331
333
  PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable &&
332
334
  PublicKeyCredential.isConditionalMediationAvailable) {
@@ -335,13 +337,23 @@
335
337
  PublicKeyCredential.isConditionalMediationAvailable(),
336
338
  ]).then(results => {
337
339
  if (results.every(r => r === true)) {
338
- isPasskeySupported.value = true;
340
+ isCMA_supported = true;
339
341
  } else {
340
- isPasskeySupported.value = false;
342
+ isCMA_supported = false;
341
343
  addPasskeyMode.value = 'cross-platform';
342
344
  }
343
345
  });
344
- }
346
+ }
347
+ try {
348
+ const temp = PublicKeyCredential.parseRequestOptionsFromJSON({challenge: 'test123', timeout: 60000, userVerification: 'required'});
349
+ if (temp && typeof temp === 'object') {
350
+ isParsingSupported = true;
351
+ }
352
+ } catch (e) {
353
+ adminforth.alert({message: 'Please ensure your browser supports passkeys.', variant: 'warning'});
354
+ isParsingSupported = false;
355
+ }
356
+ isPasskeySupported.value = (isCMA_supported && isParsingSupported);
345
357
  }
346
358
 
347
359
  async function fetchInformationFromTheBackend(confirmationResult) {
package/custom/utils.js CHANGED
@@ -100,7 +100,25 @@
100
100
  });
101
101
  return credential;
102
102
  } catch (error) {
103
- adminforth.alert({message: 'Error during authentication', variant: 'warning'});
104
- codeError.value = 'Error during authentication.';
103
+ console.error('Error during authentication:', error);
104
+ // Handle specific concurrent/pending request error cases gracefully
105
+ const name = (error && (error.name || error.constructor?.name)) || '';
106
+ const message = (error && error.message) || '';
107
+ if (name === 'AbortError') {
108
+ // Aborted intentionally; no user-facing error needed
109
+ return null;
110
+ } else if (name === 'InvalidStateError' || name === 'OperationError' || /pending/i.test(message)) {
111
+ adminforth.alert({ message: t('Another security prompt is already open. Please try again.'), variant: 'warning' });
112
+ codeError.value = t('A previous passkey attempt was still pending. Please try again.');
113
+ return null;
114
+ } else if (name === 'NotAllowedError') {
115
+ adminforth.alert({ message: `The operation either timed out or was not allowed`, variant: 'warning' });
116
+ codeError.value = 'The operation either timed out or was not allowed.';
117
+ return null;
118
+ } else {
119
+ adminforth.alert({message: `Error during authentication: ${error}`, variant: 'warning'});
120
+ codeError.value = 'Error during authentication.';
121
+ return null;
122
+ }
105
123
  }
106
124
  }
@@ -204,13 +204,25 @@
204
204
  });
205
205
 
206
206
  async function isCMAAvailable() {
207
+ let isCMA_supported = false;
208
+ let isParsingSupported = false;
207
209
  if (window.PublicKeyCredential &&
208
210
  PublicKeyCredential.isConditionalMediationAvailable) {
209
211
  const isCMA = await PublicKeyCredential.isConditionalMediationAvailable();
210
- if (isCMA) {
211
- isPasskeysSupported.value = true;
212
- }
212
+ if (isCMA) {
213
+ isCMA_supported = true;
214
+ }
215
+ }
216
+ try {
217
+ const temp = PublicKeyCredential.parseRequestOptionsFromJSON({challenge: 'test123', timeout: 60000, userVerification: 'required'});
218
+ if (temp && typeof temp === 'object') {
219
+ isParsingSupported = true;
220
+ }
221
+ } catch (e) {
222
+ adminforth.alert({message: 'Please ensure your browser supports passkeys.', variant: 'warning'});
223
+ isParsingSupported = false;
213
224
  }
225
+ isPasskeysSupported.value = (isCMA_supported && isParsingSupported);
214
226
  }
215
227
 
216
228
  onBeforeUnmount(() => {
@@ -365,14 +377,19 @@
365
377
  if (name === 'AbortError') {
366
378
  // Aborted intentionally; no user-facing error needed
367
379
  return null;
368
- }
369
- if (name === 'InvalidStateError' || name === 'OperationError' || /pending/i.test(message)) {
380
+ } else if (name === 'InvalidStateError' || name === 'OperationError' || /pending/i.test(message)) {
370
381
  adminforth.alert({ message: t('Another security prompt is already open. Please try again.'), variant: 'warning' });
371
382
  codeError.value = t('A previous passkey attempt was still pending. Please try again.');
372
383
  return null;
384
+ } else if (name === 'NotAllowedError') {
385
+ adminforth.alert({ message: `The operation either timed out or was not allowed`, variant: 'warning' });
386
+ codeError.value = 'The operation either timed out or was not allowed.';
387
+ return null;
388
+ } else {
389
+ adminforth.alert({message: `Error during authentication: ${error}`, variant: 'warning'});
390
+ codeError.value = 'Error during authentication.';
391
+ return null;
373
392
  }
374
- adminforth.alert({message: `Error during authentication: ${error}`, variant: 'warning'});
375
- codeError.value = 'Error during authentication.';
376
393
  }
377
394
  finally {
378
395
  // Clear in-flight state regardless of outcome
@@ -327,6 +327,8 @@
327
327
  }
328
328
 
329
329
  function checkForCompatibility() {
330
+ let isCMA_supported = false;
331
+ let isParsingSupported = false;
330
332
  if (window.PublicKeyCredential &&
331
333
  PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable &&
332
334
  PublicKeyCredential.isConditionalMediationAvailable) {
@@ -335,13 +337,23 @@
335
337
  PublicKeyCredential.isConditionalMediationAvailable(),
336
338
  ]).then(results => {
337
339
  if (results.every(r => r === true)) {
338
- isPasskeySupported.value = true;
340
+ isCMA_supported = true;
339
341
  } else {
340
- isPasskeySupported.value = false;
342
+ isCMA_supported = false;
341
343
  addPasskeyMode.value = 'cross-platform';
342
344
  }
343
345
  });
344
- }
346
+ }
347
+ try {
348
+ const temp = PublicKeyCredential.parseRequestOptionsFromJSON({challenge: 'test123', timeout: 60000, userVerification: 'required'});
349
+ if (temp && typeof temp === 'object') {
350
+ isParsingSupported = true;
351
+ }
352
+ } catch (e) {
353
+ adminforth.alert({message: 'Please ensure your browser supports passkeys.', variant: 'warning'});
354
+ isParsingSupported = false;
355
+ }
356
+ isPasskeySupported.value = (isCMA_supported && isParsingSupported);
345
357
  }
346
358
 
347
359
  async function fetchInformationFromTheBackend(confirmationResult) {
@@ -100,7 +100,25 @@
100
100
  });
101
101
  return credential;
102
102
  } catch (error) {
103
- adminforth.alert({message: 'Error during authentication', variant: 'warning'});
104
- codeError.value = 'Error during authentication.';
103
+ console.error('Error during authentication:', error);
104
+ // Handle specific concurrent/pending request error cases gracefully
105
+ const name = (error && (error.name || error.constructor?.name)) || '';
106
+ const message = (error && error.message) || '';
107
+ if (name === 'AbortError') {
108
+ // Aborted intentionally; no user-facing error needed
109
+ return null;
110
+ } else if (name === 'InvalidStateError' || name === 'OperationError' || /pending/i.test(message)) {
111
+ adminforth.alert({ message: t('Another security prompt is already open. Please try again.'), variant: 'warning' });
112
+ codeError.value = t('A previous passkey attempt was still pending. Please try again.');
113
+ return null;
114
+ } else if (name === 'NotAllowedError') {
115
+ adminforth.alert({ message: `The operation either timed out or was not allowed`, variant: 'warning' });
116
+ codeError.value = 'The operation either timed out or was not allowed.';
117
+ return null;
118
+ } else {
119
+ adminforth.alert({message: `Error during authentication: ${error}`, variant: 'warning'});
120
+ codeError.value = 'Error during authentication.';
121
+ return null;
122
+ }
105
123
  }
106
124
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/two-factors-auth",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "description": "AdminForth plugin for two factors authentication",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",