Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Honeypot instructions in README #276

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1863,7 +1863,7 @@ This means that the `respondTo` helper will prioritize any handler that match `t
> **Note**
> This depends on `react` and `crypto-js`.

Honeypot is a simple technic to prevent spam bots from submitting forms, it works by adding a hidden field to the form that bots will fill, but humans won't.
Honeypot is a simple technique to prevent spam bots from submitting forms. It works by adding a hidden field to the form that bots will fill, but humans won't.

There's a pair of utils in Remix Utils to help you implement this.

Expand All @@ -1890,7 +1890,7 @@ import { honeypot } from "~/honeypot.server";

export async function loader() {
// more code here
return json({ honeypot: honeypot.getInputProps() });
return json({ honeypotInputProps: honeypot.getInputProps() });
}
```

Expand All @@ -1903,7 +1903,7 @@ export default function Component() {
// more code here
return (
// some JSX
<HoneypotProvider>
<HoneypotProvider {...honeypotInputProps}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took me way too long to realize I was missing this and crucially the honeypot works halfway without it! It'd be wise to help the developer be completely explicit about the context here.

<Outlet />
</HoneypotProvider>
// end that JSX
Expand Down
4 changes: 2 additions & 2 deletions src/server/honeypot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface HoneypotInputProps {
encryptedValidFrom: string;
}

export interface HonetpotConfig {
export interface HoneypotConfig {
randomizeNameFieldName?: boolean;
nameFieldName?: string;
validFromFieldName?: string | null;
Expand All @@ -21,7 +21,7 @@ const DEFAULT_VALID_FROM_FIELD_NAME = "from__confirm";
export class Honeypot {
private generatedEncryptionSeed = this.randomValue();

constructor(protected config: HonetpotConfig = {}) {}
constructor(protected config: HoneypotConfig = {}) {}

public getInputProps({
validFromTimestamp = Date.now(),
Expand Down