{"id":22703954,"url":"https://github.com/hettiger/spa-honeypot","last_synced_at":"2026-04-30T10:39:16.156Z","repository":{"id":65145116,"uuid":"548285785","full_name":"hettiger/spa-honeypot","owner":"hettiger","description":"Honeypot package for Single Page Applications","archived":false,"fork":false,"pushed_at":"2022-12-30T14:22:04.000Z","size":106,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-06T19:47:12.625Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hettiger.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-09T08:56:54.000Z","updated_at":"2022-12-30T13:29:50.000Z","dependencies_parsed_at":"2023-01-01T00:29:24.072Z","dependency_job_id":null,"html_url":"https://github.com/hettiger/spa-honeypot","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":"spatie/package-skeleton-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hettiger%2Fspa-honeypot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hettiger%2Fspa-honeypot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hettiger%2Fspa-honeypot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hettiger%2Fspa-honeypot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hettiger","download_url":"https://codeload.github.com/hettiger/spa-honeypot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246237436,"owners_count":20745348,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-10T08:13:19.866Z","updated_at":"2026-04-30T10:39:11.102Z","avatar_url":"https://github.com/hettiger.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Honeypot package for Single Page Applications\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/hettiger/spa-honeypot.svg?style=flat-square)](https://packagist.org/packages/hettiger/spa-honeypot)\n[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/hettiger/spa-honeypot/run-tests?label=tests)](https://github.com/hettiger/spa-honeypot/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/hettiger/spa-honeypot/Fix%20PHP%20code%20style%20issues?label=code%20style)](https://github.com/hettiger/spa-honeypot/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/hettiger/spa-honeypot.svg?style=flat-square)](https://packagist.org/packages/hettiger/spa-honeypot)\n\nHelps to protect SPA's (Single Page Applications) against SPAM without using cookies or user input.\n\n## Installation\n\n```bash\ncomposer require hettiger/spa-honeypot\nphp artisan spa-honeypot:install\n```\n\n## Usage\n\n1. Add the `form.honeypot`, `form.token`  or `form` middleware to a forms target route\n\n```php\nRoute::post('form', fn () =\u003e 'OK')-\u003emiddleware('form');\n```\n\n\u003e The `form` middleware group simply combines `form.honeypot` and `form.token` so you don't have to.\n\u003e Using just `form.token` protection without the `form.honeypot` middleware or vise versa is supported. \n\n2. Use one of the corresponding [frontend libraries](#frontend-libraries) to make form token requests \n\n### Lighthouse GraphQL API\n\n1. Add the `form.token.handle` middleware to the `lighthouse.route.middleware` config\n\n```php\n// config/lighthouse.php — must be published\n\n'middleware' =\u003e [\n    // …\n\n    'form.token.handle',\n],\n```\n\n2. Register the honeypot scalar in your `graphql/schema.graphql` file\n\n```graphql\nscalar Honeypot @scalar(class: \"Hettiger\\\\Honeypot\\\\GraphQL\\\\Scalars\\\\HoneypotScalar\")\n\n# …\n```\n\n3. Add a honeypot field to any input that you want to protect against SPAM\n\n```graphql\ninput SendContactRequestInput {\n    # …\n    honey: Honeypot\n}\n```\n\n\u003e The `field` config is not being used in GraphQL context.\n\n4. Add the `@requireFormToken` directive to any field that you want to protect against SPAM\n\n```graphql\n# e.g. graphql/contact.graphql\n\nextend type Mutation {\n    sendContactRequest(input: SendContactRequestInput): SendContactRequestPayload @requireFormToken\n}\n```\n\n5. Use one of the corresponding [frontend libraries](#frontend-libraries) to make form token requests\n\n### Customizing Responses\n\nYou may provide custom error response factories using the config:\n\n```php\nreturn [\n    // …\n    \n    'honeypot_error_response_factory' =\u003e \\Hettiger\\Honeypot\\ErrorResponseFactory::class,\n    'form_token_error_response_factory' =\u003e \\Hettiger\\Honeypot\\ErrorResponseFactory::class,\n];\n```\n\nAlternatively you can provide a simple `Closure` anywhere in your application:\n\n```php\nuse Hettiger\\Honeypot\\Facades\\Honeypot;\nuse Illuminate\\Support\\ServiceProvider;\n\nclass AppServiceProvider extends ServiceProvider\n{\n    // …\n\n    public function boot()\n    {\n        $errorResponseFactory = fn (bool $isGraphQLRequest) =\u003e $isGraphQLRequest\n            ? ['errors' =\u003e [['message' =\u003e 'Whoops, something went wrong …']]]\n            : 'Whoops, something went wrong …';\n\n        Honeypot::respondToHoneypotErrorsUsing($errorResponseFactory);\n        Honeypot::respondToFormTokenErrorsUsing($errorResponseFactory);\n    }\n}\n```\n\n\u003e You don't have to worry about adding the form token header yourself. It'll be added for you automatically.\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Frontend Libraries\n\n- [Angular](https://www.npmjs.com/package/@hettiger/ngx-spa-honeypot)\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Credits\n\n- [Martin Hettiger](https://github.com/hettiger)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhettiger%2Fspa-honeypot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhettiger%2Fspa-honeypot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhettiger%2Fspa-honeypot/lists"}