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