Repository navigation
Releases
Releases · Particle-Academy/fancy-captcha-ui
v0.2.1
Fixed
- README: the re-arm after a submit needs
processing. A hand-builtform={{ data, setData }}
has noprocessing, soresetAfterSubmitsilently does nothing. The README now says to pass the
form itself, or to includeprocessing. Documentation only; no code changed. Reported by
GuardCard. Consumer action: if you pass a hand-built form object, addprocessing.
v0.2.0
Added
resetAfterSubmit(defaulttrue): the captcha re-arms itself after every submit.
fancy-captcha'scaptcha:<action>middleware verifies before the controller validates, so
a submit refused by your own validation ("email taken") has already spent its provider token
(sent to siteverify) or its proof-of-work (ProofOfWork::redeem()marks it spent first).
Until now only clearing the field re-armed the widget, whichform.reset()does on success
and nothing does on an error, so resubmitting the same form was refused. Now, when
form.processinggoes true and then false, the component resets the widget, re-executes
reCAPTCHA v3, or solves a fresh challenge for whatever that submit posted. An unsolved widget
or a first proof-of-work still running is left alone, a hostform.reset()that already
cleared the field does not cause a second reset, and the signed timestamp (not single-use) is
never touched.
Consumer action: none with Inertia'suseForm()or fancy-inertia'suseFancyForm(); it
is on by default. If you worked around this by clearing_captcha_token/_captcha_powin
onErrororonFinish, you can remove that (it is harmless if kept). Pass
resetAfterSubmit={false}only if you reset the captcha yourself.CaptchaForm.processing?: boolean, the in-flight flag the re-arm watches. Optional, so a
form adapter without it still type-checks and works as before.
Consumer action: none. A custom form adapter can addprocessingto get the re-arm.
Changed
- README: per-form
action. The Inertia example now passesaction="signup", and says it
must equal the route'scaptcha:<action>. The sharedfancyCaptchaprop carries
action: null; a mismatch refuses every submit under Turnstile and reCAPTCHA v3 (logged as
reason: action_mismatch) and is not checked at all in built-in mode, hCaptcha or reCAPTCHA
v2, so it stays hidden until the driver changes. No code changed:actionwas already a
prop.
Consumer action: if you spread the action into the config ({...fancyCaptcha, action}),
switch to<Captcha config={fancyCaptcha} form={form} action="signup" />, and check every
form'sactionagainst its route's middleware before moving to a provider.
v0.1.0
Added
<Captcha>, one component for every provider:builtin(the default),turnstile,
recaptcha-v2,recaptcha-v3andhcaptcha. Takes fancy-captcha's server props
(config), orprovider/siteKey/action/namedirectly. Exposes the token through
onTokenand a hidden form field.useCaptcha()for headless use: values, status, progress,widgetRef,reset(),
cancel().- Works with Inertia's
useForm()and fancy-inertia'suseFancyForm()throughform
(anything withdataandsetData(key, value)), and with a plain<form>.
captchaData(config)seeds a form's data. - Reset when consumed. Clearing the token or solution (as
form.reset()does after a
submit) resets the widget, re-executes reCAPTCHA v3 or solves a fresh challenge. Expiry and
errors clear the token. - Lazy, SSR-safe script loading: in an effect, once per URL for any number of widgets,
reusing an API already on the page.scriptUrlfor a self-hosted copy. - Built-in mode: an off-screen honeypot hidden from assistive tech and the keyboard, the
signed timestamp, and proof-of-work solved in a Web Worker built from a Blob (main-thread
slices when a Worker cannot be made), with a progress bar, a polite live region and
cancellation. Challenges outside 8..32 bits are refused. - Optional consent gating with fancy-compliance-ui, structurally typed so it is not a
dependency: a gated provider renders only after its category is granted, with the built-in
check (and proof-of-work) as the fallback. - RTL through
diror inheritance; AAA where we control it. Read-only
data-fancy-captcha-*handles andonStatusChangefor agents, which must never solve a
captcha. CAPTCHA_FIELDS, the same field names as the server'sFancyCaptcha\Fields.
Consumer action: new package. Install it with particle-academy/fancy-captcha on the
server, add the @source line for Tailwind, and add worker-src blob: if you run a strict CSP
and want proof-of-work off the main thread.