Hold Button
more-shadcn-noair/verify-humanFreeComponent
A self-contained heuristic bot protection component. It uses honeypots, velocity checks, and event trust analysis.
Live preview
live · rendered by the registry
Rendered by more-shadcn-noair on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://more-shadcn.noair.fun/r/verify-human.jsonSource
1<script lang="ts">2 import { cn } from '$UTILS$';3 import { Check, Loader2, ShieldCheck, X } from '@lucide/svelte';4 import { onMount } from 'svelte';56 let {7 class: className,8 onVerify,9 verified = $bindable(false)10 }: {11 class?: string;12 onVerify?: () => void;13 verified?: boolean;14 } = $props();1516 let status = $state<'idle' | 'verifying' | 'verified' | 'failed'>('idle');17 let mountTime = 0;18 let humanInteraction = false;19 let honeypot = $state(false);2021 onMount(() => {22 mountTime = Date.now();2324 const markHuman = () => {25 humanInteraction = true;26 };27 window.addEventListener('mousemove', markHuman, { once: true });28 window.addEventListener('touchstart', markHuman, { once: true });29 window.addEventListener('keydown', markHuman, { once: true });3031 return () => {32 window.removeEventListener('mousemove', markHuman);33 window.removeEventListener('touchstart', markHuman);34 window.removeEventListener('keydown', markHuman);35 };36 });3738 function runHeuristics(e: MouseEvent | TouchEvent | KeyboardEvent) {39 if (honeypot) return false;4041 if (Date.now() - mountTime < 500) return false;4243 if (!humanInteraction) return false;4445 if (!e.isTrusted) return false;4647 return true;48 }4950 async function handleClick(e: any) {51 if (status !== 'idle' && status !== 'failed') return;5253 status = 'verifying';5455 await new Promise((r) => setTimeout(r, 800));5657 if (runHeuristics(e)) {58 status = 'verified';59 verified = true;60 onVerify?.();61 } else {62 status = 'failed';63 verified = false;64 setTimeout(() => {65 status = 'idle';66 }, 2000);67 }68 }69</script>7071<input72 type="checkbox"73 class="absolute opacity-0 -z-10 w-0 h-0"74 tabindex="-1"75 bind:checked={honeypot}76 autocomplete="off"77/>7879<button80 onclick={handleClick}81 class={cn(82 'group flex items-center justify-between w-[300px] h-16 px-4 rounded-md border bg-card text-card-foreground shadow-sm transition-all select-none',83 status === 'idle' && 'hover:bg-accent/5 cursor-pointer',84 status === 'failed' && 'border-red-500/50 bg-red-500/5 cursor-not-allowed',85 (status === 'verifying' || status === 'verified') && 'cursor-default',86 className87 )}88 type="button"89>90 <div class="flex items-center gap-3">91 <div92 class={cn(93 'relative flex items-center justify-center w-7 h-7 rounded border-2 bg-background transition-all duration-300',94// … truncated
More from more-shadcn-noair
All 43 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Audioaudio | more-shadcn-noair | Components | Free | no deps | |
| Audio Waveaudio-wave | more-shadcn-noair | Components | Free | no deps | |
| Autocompleteautocomplete | more-shadcn-noair | Components | Free | no deps | |
| Bannerbanner | more-shadcn-noair | Components | Free | no deps | |
| Big Calendarbig-calendar | more-shadcn-noair | Components | Free | no deps | |
| Bottom Navigationbottom-nav | more-shadcn-noair | Components | Free | no deps | |
| Canvascanvas | more-shadcn-noair | Components | Free | no deps | |
| Chipchip | more-shadcn-noair | Components | Free | no deps |
