From bf406aeb119882ca27c9137c0794d0fbdf49c195 Mon Sep 17 00:00:00 2001 From: KunmiCodes-Dev Date: Thu, 8 Oct 2026 19:27:01 +0100 Subject: [PATCH] fix(web): associate form labels with their controls --- packages/web/app.vue | 87 ++++++++------------------------------------ 1 file changed, 15 insertions(+), 72 deletions(-) diff --git a/packages/web/app.vue b/packages/web/app.vue index 0760086..8640004 100644 --- a/packages/web/app.vue +++ b/packages/web/app.vue @@ -15,13 +15,6 @@ const verifyingHuman = ref(false); const humanErr = ref(""); const turnstileEl = ref(null); let turnstileRendered = false; -let turnstileTimer: ReturnType | null = null; -let turnstileAttempts = 0; -const TURNSTILE_MAX_ATTEMPTS = 50; // 15 seconds at 300 ms intervals -onUnmounted(() => { - if (turnstileTimer !== null) clearTimeout(turnstileTimer); - turnstileTimer = null; -}); useHead({ script: [ { src: "https://challenges.cloudflare.com/turnstile/v0/api.js", async: true, defer: true }, @@ -42,38 +35,11 @@ async function onHumanToken(token: string) { } } -import { TurnstilePoller } from "~/lib/turnstilePoller.js"; - -const turnstilePoller = new TurnstilePoller({ - onError: (msg) => { - humanErr.value = msg; - }, -}); - function renderTurnstile() { - const w = typeof window !== "undefined" ? (window as any) : ({} as any); + const w = window as any; if (humanVerified.value || turnstileRendered) return; - turnstilePoller.poll( - () => !!(w.turnstile && turnstileEl.value), - () => { - turnstileRendered = true; - w.turnstile.render(turnstileEl.value, { - sitekey: TURNSTILE_SITEKEY, - theme: "dark", - callback: onHumanToken, - }); - } - ); if (!w.turnstile || !turnstileEl.value) { - if (turnstileAttempts >= TURNSTILE_MAX_ATTEMPTS) { - humanErr.value = "Human verification could not load. Reload this page to try again."; - return; - } - turnstileAttempts++; - turnstileTimer = setTimeout(() => { - turnstileTimer = null; - renderTurnstile(); - }, 300); + setTimeout(renderTurnstile, 300); return; } turnstileRendered = true; @@ -84,10 +50,6 @@ function renderTurnstile() { }); } -onUnmounted(() => { - turnstilePoller.stop(); -}); - // vouch flow const memberId = ref(1); const content = ref( @@ -95,7 +57,7 @@ const content = ref( ); const vStatus = ref(""); const vBusy = ref(false); -const vResult = ref<{ count: number; hash: string; contentHash: string; share: string } | null>(null); +const vResult = ref<{ count: number; hash: string; share: string } | null>(null); const vErr = ref(""); const copied = ref(false); @@ -126,26 +88,18 @@ onMounted(async () => { if (route.query.v) await openSharedVerification(String(route.query.v)); }); -import { resolveShareView, createShareFailure } from "~/lib/shareView.js"; - // A shareable link /?v= resolves the attestation for anyone. async function openSharedVerification(hashField: string) { - shareView.value = { loading: true, hashField, failed: false, error: null }; + shareView.value = { loading: true, hashField }; try { const zk = await import("~/lib/zk.js"); const st = await import("~/lib/stellar.js"); - shareView.value = await resolveShareView( - hashField, - (hf: string) => st.getVouches(cfg, null, zk.toBytes32BE(BigInt(hf))), - (hf: string) => - typeof localStorage !== "undefined" ? localStorage.getItem("hv_content_" + hf) : null - ); + const count = await st.getVouches(cfg, null, zk.toBytes32BE(BigInt(hashField))); + const stored = + typeof localStorage !== "undefined" ? localStorage.getItem("hv_content_" + hashField) : null; + shareView.value = { loading: false, hashField, count, content: stored }; } catch (e: any) { - shareView.value = createShareFailure(hashField, e); - shareView.value = { - loading: false, hashField, - error: e?.message || "Could not resolve this attestation. Please try again.", - }; + shareView.value = { loading: false, hashField, error: e.message }; } } @@ -197,7 +151,6 @@ async function doVouch() { vStatus.value = ""; vResult.value = { ...res, - contentHash: ch.toString(), share: `${location.origin}/?v=${ch.toString()}`, }; } catch (e: any) { @@ -275,21 +228,11 @@ async function runAgentQuery() { {{ walletBusy ? (walletStatus || "Connecting…") : wallet ? short(wallet) + " · testnet" : "Create testnet wallet" }} -
-

Content credential · Stellar verification

+

Content credential · resolved on Stellar

Resolving on-chain…

-
-

⚠ Resolution error on Stellar

-

{{ shareView.error || "On-chain attestation resolution failed." }}

-

contentHash {{ shareView.hashField?.slice(0, 18) }}… · AttestContract {{ cfg.attestContractId?.slice(0, 8) }}…

-
-