@strands.gg/accui 1.3.2 → 1.3.3

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.
@@ -370,7 +370,7 @@ const _sfc_main$o = /* @__PURE__ */ vue.defineComponent({
370
370
  placeholder: { type: String, required: false },
371
371
  disabled: { type: Boolean, required: false },
372
372
  required: { type: Boolean, required: false },
373
- error: { type: String, required: false },
373
+ error: { type: Object, required: false },
374
374
  helpText: { type: String, required: false },
375
375
  autocomplete: { type: String, required: false },
376
376
  size: { type: String, required: false, default: "md" }
@@ -539,7 +539,7 @@ function _sfc_render$o(_ctx, _cache, $props, $setup, $data, $options) {
539
539
  $props.error ? (vue.openBlock(), vue.createElementBlock(
540
540
  "p",
541
541
  _hoisted_9$b,
542
- vue.toDisplayString($props.error),
542
+ vue.toDisplayString($props.error.message),
543
543
  1
544
544
  /* TEXT */
545
545
  )) : $props.helpText ? (vue.openBlock(), vue.createElementBlock(
@@ -1392,14 +1392,33 @@ const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
1392
1392
  throw new Error("Hardware keys are not supported in this browser");
1393
1393
  }
1394
1394
  const challengeResponse = await getMfaWebAuthnChallenge(selectedMethod.value.id);
1395
- const challenge = challengeResponse.challenge;
1396
- console.log("Received WebAuthn challenge:", challenge);
1395
+ const challengeData = challengeResponse.challenge.publicKey || challengeResponse.challenge;
1396
+ const base64ToUint8Array = (base64) => {
1397
+ if (!base64 || typeof base64 !== "string") {
1398
+ return new Uint8Array(0);
1399
+ }
1400
+ const padding = "=".repeat((4 - base64.length % 4) % 4);
1401
+ const b64 = (base64 + padding).replace(/-/g, "+").replace(/_/g, "/");
1402
+ const rawData = window.atob(b64);
1403
+ const outputArray = new Uint8Array(rawData.length);
1404
+ for (let i = 0; i < rawData.length; ++i) {
1405
+ outputArray[i] = rawData.charCodeAt(i);
1406
+ }
1407
+ return outputArray;
1408
+ };
1397
1409
  const isPasskey = selectedMethod.value.device_type === "passkey";
1398
1410
  const publicKeyCredentialRequestOptions = {
1399
- ...challenge,
1400
- timeout: isPasskey ? 3e5 : challenge.timeout || 6e4,
1411
+ ...challengeData,
1412
+ challenge: challengeData.challenge ? base64ToUint8Array(challengeData.challenge) : new Uint8Array(32),
1413
+ timeout: isPasskey ? 3e5 : challengeData.timeout || 6e4,
1401
1414
  userVerification: isPasskey ? "required" : "discouraged"
1402
1415
  };
1416
+ if (challengeData.allowCredentials && Array.isArray(challengeData.allowCredentials)) {
1417
+ publicKeyCredentialRequestOptions.allowCredentials = challengeData.allowCredentials.map((cred) => ({
1418
+ ...cred,
1419
+ id: base64ToUint8Array(cred.id)
1420
+ }));
1421
+ }
1403
1422
  const credential = await navigator.credentials.get({
1404
1423
  publicKey: publicKeyCredentialRequestOptions
1405
1424
  });
@@ -1440,6 +1459,7 @@ const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
1440
1459
  await verifyMfa(selectedMethod.value.id, JSON.stringify(credentialData));
1441
1460
  emit("success");
1442
1461
  } catch (error) {
1462
+ console.error("Hardware key authentication error:", error);
1443
1463
  emit("error", error instanceof Error ? error.message : "Hardware key authentication failed");
1444
1464
  }
1445
1465
  };