Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Honeypot detection helper. A honeypot field is a hidden input that
|
||||
* legitimate users never see / fill — bots that scrape form fields and
|
||||
* submit blindly do.
|
||||
*
|
||||
* The renderer emits a field with key {@link HONEYPOT_FIELD_KEY} hidden
|
||||
* via CSS + aria-hidden + tabindex=-1. The submission endpoint passes the
|
||||
* raw payload through this helper. When a non-empty value is detected we
|
||||
* return `true` — the caller should silently accept the request (204) so
|
||||
* the bot gets no signal that it was rejected.
|
||||
*/
|
||||
|
||||
import { HONEYPOT_FIELD_KEY } from "./schema.js";
|
||||
|
||||
export function isHoneypotTriggered(values: Record<string, unknown> | null | undefined): boolean {
|
||||
if (!values) return false;
|
||||
const raw = values[HONEYPOT_FIELD_KEY];
|
||||
if (raw === undefined || raw === null) return false;
|
||||
if (typeof raw === "string") return raw.trim() !== "";
|
||||
if (typeof raw === "boolean") return raw === true;
|
||||
if (typeof raw === "number") return raw !== 0;
|
||||
return true;
|
||||
}
|
||||
Reference in new issue
Block a user