npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@adocasts.com/adonisjs-honeypot

v1.0.12

Published

Bot protection with Honeypot form fields in AdonisJS

Downloads

92

Readme

AdonisJS Honeypot

A simple way to keep pesky bots from submitting your forms.

npm-image license-image typescript-image

AdonisJS Honeypot allows you to easily add a honeypot system to your application to prevent bots from submitting your forms. AdonisJS Honeypot will add fields to your form that aren't visible to the user, but are to bots! Then, it validates that all fields have been left untouched. If any fields have been filled, we know a bot has submitted.

Installation

First install the package as a dependency on your project

npm i @adocasts.com/adonisjs-honeypot

Then configure it within your project

node ace configure @adocasts.com/adonisjs-honeypot

Lastly, add it as a middleware within your project.

// start/kernel.ts

Server.middleware.registerNamed({
  honeypot: () => import('@ioc:Adocasts/Honeypot') // 👈
})

Also, be sure to define custom honeypot fields within config/honeypot.ts. The more realistic the field names the more likely the honeypot is to work. However, be sure the field names won't conflict with any fields in your site.

// here are the default fields
fields: ['ohbother', 'ohpiglet', 'ohpoo', 'firstName', 'lastName'],

Usage

To add honeypot to a form submission, first apply the middleware to your route(s).

Route
  .post('/signup', 'AuthController.signup')
  .middleware(['honeypot']) // 👈

This will require the honeypot fields to be submitted within your request's body. So, last thing we need to do is add the fields to your form.

When you configured @adocasts/adonisjs-honeypot within your project, we registered a global component named honeypot. This single component will render all the configured honeypot fields and also hide them using CSS so they're visible to bots, but not to humans.

So, all you need to do is add this component within your form!

<form action="{{ route('auth.signup') }}" method="POST">
  @!component('honeypot') {{-- 👈 --}}

  {{-- ... other form fields ... --}}
</form>