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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@webpresso/forms

v0.1.1

Published

Webpresso drop-in form components: a provider-neutral contact-form handler for edge workers.

Readme

@webpresso/forms

Contact-form submission handling for Workers: field validation and sanitization, captcha gating, internal + confirmation email dispatch, and redirect responses with a status vocabulary. Provider-neutral root surface; the captcha vendor is confined to a single adapter subpath.

Install

vp add @webpresso/forms

The public package names and release policy are defined by .webpresso/package-surface.json in the framework repository.

Config shape

import type { ContactFormConfig } from '@webpresso/forms'

const config: ContactFormConfig = {
  siteName: 'Example',
  from: '[email protected]',
  internalRecipients: ['[email protected]'],
  fields: [
    { name: 'name', label: 'Name', type: 'text', required: true },
    { name: 'email', label: 'Email', type: 'email', required: true },
    { name: 'message', label: 'Message', type: 'textarea', required: true },
  ],
  customerEmailField: 'email',
  customerNameField: 'name',
  redirectPath: '/contact',
  subjects: { internal: 'New contact request', confirmation: 'We received your message' },
}

Field types are text | email | textarea | tel; values are control-character-stripped, whitespace-collapsed, length-capped (maxLength, default 2000), and email-typed fields are lowercased. Required fields and the customer email field are validated before any email is sent.

Usage

Mount the handler in a Worker with an email binding and a captcha verifier:

import { createContactFormHandler, type EmailBinding } from '@webpresso/forms'
import { createTurnstileVerifier } from '@webpresso/forms/adapters/turnstile'

type Env = { TURNSTILE_SECRET: string; SEND_EMAIL: EmailBinding }

export default {
  fetch: (request: Request, env: Env) => {
    const url = new URL(request.url)
    if (url.pathname === '/api/contact' && request.method === 'POST') {
      const contact = createContactFormHandler(config, {
        captcha: createTurnstileVerifier({ secret: env.TURNSTILE_SECRET }),
      })
      return contact(request, { email: env.SEND_EMAIL })
    }
    return new Response('Not found', { status: 404 })
  },
}

context.email is an EmailBinding (send(message)); when it is absent the handler redirects with the email status instead of sending. A custom CaptchaVerifier can replace the adapter at the neutral captcha option.

Redirect status vocabulary

The handler answers with a 303 redirect carrying a contact query parameter. A form's optional _redirect field is accepted only if its decoded value starts with /, does not start with //, and contains no backslashes or control characters (U+0000–U+001F or U+007F). Otherwise, or when the field is missing, the handler uses config.redirectPath. Wrong-method and unparsable-form requests also use config.redirectPath.

| Value | Meaning | | --------- | ------------------------------------------------------------ | | success | Validation and captcha passed; internal email send succeeded | | invalid | Wrong method, unparsable form, or bad fields | | captcha | Captcha failed or the verifier errored | | email | No email binding, or the internal send failed |

After the internal send succeeds, the handler attempts the confirmation email on a best-effort basis. A confirmation send failure still yields success unless the optional logger itself throws. Supply a logger, such as logger: console, in the handler options to receive a contact_confirmation_failed warning with the error code and site name; without a logger, no warning is emitted.

Adapter-confined naming

The root surface stays provider-neutral: vendor names appear only where the adapter subpath is documented. @webpresso/forms/adapters/turnstile is the single subpath naming the captcha vendor, its siteverify endpoint, and its form field name — mirroring how the runtime documents its auth adapter imports. Import the adapter explicitly; nothing vendor-specific is re-exported from the root.

Provenance

Logic ported from the in-org public ozby/cloudflare-utils repository, pinned at commit dd4cb995c8b786f30b5b2993cd40b05e2a73bb56. The source repository carries no LICENSE file and the module is authored in-org by the rights holder, so this port is licensed Elastic-2.0 as part of the framework inventory.

License

Elastic-2.0