@adminforth/two-factors-auth 2.1.4 → 2.2.0

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.
@@ -204,25 +204,13 @@
204
204
  });
205
205
 
206
206
  async function isCMAAvailable() {
207
- let isCMA_supported = false;
208
- let isParsingSupported = false;
209
207
  if (window.PublicKeyCredential &&
210
208
  PublicKeyCredential.isConditionalMediationAvailable) {
211
209
  const isCMA = await PublicKeyCredential.isConditionalMediationAvailable();
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;
210
+ if (isCMA) {
211
+ isPasskeysSupported.value = true;
212
+ }
224
213
  }
225
- isPasskeysSupported.value = (isCMA_supported && isParsingSupported);
226
214
  }
227
215
 
228
216
  onBeforeUnmount(() => {
@@ -311,7 +299,14 @@
311
299
  return;
312
300
  }
313
301
  const { _options, challengeId } = signIn;
314
- const options = PublicKeyCredential.parseRequestOptionsFromJSON(_options);
302
+ let options;
303
+ try {
304
+ options = PublicKeyCredential.parseRequestOptionsFromJSON(_options);
305
+ } catch (e) {
306
+ console.error('Error parsing request options:', e);
307
+ adminforth.alert({message: 'Error initiating passkey authentication.', variant: 'warning'});
308
+ return;
309
+ }
315
310
  const credential = await authenticate(options);
316
311
  if (!credential) {
317
312
  isFetchingPasskey.value = false;
@@ -349,8 +344,11 @@
349
344
  }
350
345
  }
351
346
 
347
+ let controller = new AbortController();
348
+
352
349
  async function authenticate(options) {
353
350
  console.log("Authenticating with options:", options);
351
+ controller.abort();
354
352
  try {
355
353
  // Guard: prevent concurrent navigator.credentials.get calls
356
354
  if (webAuthn.inFlight) {
@@ -11,6 +11,12 @@
11
11
  ]"
12
12
  :data="passkeys"
13
13
  >
14
+ <template #cell:name="{item}">
15
+ <div class="flex items-center justify-start space-x-2">
16
+ <img class="max-h-6" :src="coreStore.theme === 'light' ? item.light_icon : item.dark_icon" />
17
+ <p>{{ item.name }}</p>
18
+ </div>
19
+ </template>
14
20
  <template #cell:actions="{item}">
15
21
  <div class="flex items-center justify-start space-x-2">
16
22
  <Dialog
@@ -327,8 +333,6 @@
327
333
  }
328
334
 
329
335
  function checkForCompatibility() {
330
- let isCMA_supported = false;
331
- let isParsingSupported = false;
332
336
  if (window.PublicKeyCredential &&
333
337
  PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable &&
334
338
  PublicKeyCredential.isConditionalMediationAvailable) {
@@ -337,23 +341,13 @@
337
341
  PublicKeyCredential.isConditionalMediationAvailable(),
338
342
  ]).then(results => {
339
343
  if (results.every(r => r === true)) {
340
- isCMA_supported = true;
344
+ isPasskeySupported.value = true;
341
345
  } else {
342
- isCMA_supported = false;
346
+ isPasskeySupported.value = false;
343
347
  addPasskeyMode.value = 'cross-platform';
344
348
  }
345
349
  });
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);
350
+ }
357
351
  }
358
352
 
359
353
  async function fetchInformationFromTheBackend(confirmationResult) {