{"_id":"@alpineux/plugin-forms","_rev":"5-ae6afaa44c04509c435c846c6f07054e","name":"@alpineux/plugin-forms","dist-tags":{"latest":"0.1.4"},"versions":{"0.0.0-stage":{"name":"@alpineux/plugin-forms","version":"0.0.0-stage","_id":"@alpineux/plugin-forms@0.0.0-stage","stub":true,"maintainers":[{"name":"alpineux","email":"jason@alpineux.com"}],"dist":{"shasum":"70f4149afa3a9531597bf28e71fa1c57c9c9c3d3","tarball":"https://registry.npmjs.org/@alpineux/plugin-forms/-/plugin-forms-0.0.0-stage.tgz","fileCount":2,"integrity":"sha512-cyEBT/8G1FxivXr+cYRh/vMh2mnfYQIrV3IDtQoEK+mbDpIOgQqTU/PNc6ZBebRudagaiQBJIWN+oKoTIsPktg==","signatures":[{"sig":"MEUCIDatFjf3b2+lskHB+AYdr7JZivokwS/Td9c/wtievdZCAiEAvXk40qQFd9mBmCIomGo3HxYchBM2DBhwcxRGbNdDzaM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":344},"_npmUser":{"name":"alpineux","email":"jason@alpineux.com"},"description":"Temporary package placeholder for staged publishing","directories":{}},"0.1.0":{"name":"@alpineux/plugin-forms","version":"0.1.0","keywords":["emdash","emdash-plugin","forms"],"author":"AlpineUX (https://www.alpineux.com)","license":"MIT","_id":"@alpineux/plugin-forms@0.1.0","maintainers":[{"name":"alpineux","email":"jason@alpineux.com"}],"homepage":"https://www.alpineux.com","dist":{"shasum":"53fed0efb02744c53ec855b5b955841061383f59","tarball":"https://registry.npmjs.org/@alpineux/plugin-forms/-/plugin-forms-0.1.0.tgz","fileCount":8,"integrity":"sha512-iLNT0v0c3VDlQ86Q+E+PTFjPQTvLcCSFC4/8hXXZjUPW0HXs27/Gvud0QEQG7Zt9jStItuwLNee47Uk+JGXJUg==","signatures":[{"sig":"MEUCIBVoGzoWrtc6bbw5FKRYw1nZFNUUhfXL8d4GRcmNMtUbAiEA30vViw1i0CbbN7/y4OZSnyNVG3vH6QmlPlFum189rFM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIFtvTW6rrEtzo4+EBJ15omqE4QuGW+p8HsytVaeCpik7AiEAk8fVCTDjo6QBW5EBEYHnHZltG518SITqCgNE0IfcjUY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54185},"main":"dist/index.mjs","type":"module","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs"},"./sandbox":"./dist/plugin.mjs"},"scripts":{"dev":"emdash-plugin dev","test":"emdash-plugin validate && vitest run","build":"emdash-plugin build","login":"emdash-plugin login","bundle":"emdash-plugin bundle","validate":"emdash-plugin validate","typecheck":"tsc --noEmit","registry:publish":"emdash-plugin publish"},"_npmUser":{"name":"alpineux","email":"jason@alpineux.com"},"description":"Contact forms for your website, with email notifications and an inbox.","directories":{},"_nodeVersion":"22.23.4","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"zod":"4.5.4","emdash":"^1.4.0","vitest":"^4.1.0","typescript":"^6.0.3","@emdash-cms/blocks":"^1.4.0","@alpineux/plugin-kit":"0.1.0","@emdash-cms/plugin-cli":"0.13.5","@emdash-cms/plugin-test":"^0.2.6"},"peerDependencies":{"emdash":">=1.4.0"},"_npmOperationalInternal":{"tmp":"tmp/plugin-forms_0.1.0_1793582658847_0.45318663593975794","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@alpineux/plugin-forms","version":"0.1.2","keywords":["emdash","emdash-plugin","forms"],"author":{"url":"https://www.alpineux.com","name":"AlpineUX"},"license":"MIT","_id":"@alpineux/plugin-forms@0.1.2","maintainers":[{"name":"alpineux","email":"jason@alpineux.com"}],"homepage":"https://www.alpineux.com","dist":{"shasum":"3bcda09cbe315e0ac3e3dac768aaa0c3d20e0109","tarball":"https://registry.npmjs.org/@alpineux/plugin-forms/-/plugin-forms-0.1.2.tgz","fileCount":8,"integrity":"sha512-4ed2RVr7aMm4tcJUQZvOEnaE2ymL1vXy5Guvrwpj0C/F96FE+7aXKo139XVClyHNQs1CLxE3x6soTC/z60YYZA==","signatures":[{"sig":"MEUCIC01+I9uBkIrs/7pGSt7qSe2AwQsZ5BQF8KIS7ePIQ5EAiEAhN6ni9Bv7U+67BhK+JhsDrAD9R8wfYdI6EyFfuvbREQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIQDuJZ0IKXFuiyavm9/XKnCqekb84Zcik6GgWj3Y8DEAhQIgPVXO2sunmFvf82gDA6G/tgqyNnSFOC+48iL8mGyJ6u4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":57512},"main":"dist/index.mjs","type":"module","_from":"file:/private/tmp/claude-501/-Users-jasonleyser-Documents-alpineux-emdash-alpineux/71b8f305-732a-4d23-a961-a6c818f6032a/scratchpad/alpineux-plugin-forms-0.1.2.tgz","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs"},"./sandbox":"./dist/plugin.mjs"},"scripts":{"dev":"emdash-plugin dev","test":"emdash-plugin validate && vitest run","build":"emdash-plugin build","login":"emdash-plugin login","bundle":"emdash-plugin bundle","validate":"emdash-plugin validate","typecheck":"tsc --noEmit","registry:publish":"emdash-plugin publish"},"_npmUser":{"name":"alpineux","email":"jason@alpineux.com"},"_resolved":"/private/tmp/claude-501/-Users-jasonleyser-Documents-alpineux-emdash-alpineux/71b8f305-732a-4d23-a961-a6c818f6032a/scratchpad/alpineux-plugin-forms-0.1.2.tgz","_integrity":"sha512-4ed2RVr7aMm4tcJUQZvOEnaE2ymL1vXy5Guvrwpj0C/F96FE+7aXKo139XVClyHNQs1CLxE3x6soTC/z60YYZA==","_npmVersion":"10.9.9","description":"Contact forms for your website, with email notifications and an inbox.","directories":{},"_nodeVersion":"22.23.4","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"zod":"4.5.4","emdash":"^1.4.0","vitest":"^4.1.0","typescript":"^6.0.3","@emdash-cms/blocks":"^1.4.0","@alpineux/plugin-kit":"0.1.0","@emdash-cms/plugin-cli":"0.13.5","@emdash-cms/plugin-test":"^0.2.6"},"peerDependencies":{"emdash":">=1.4.0"},"_npmOperationalInternal":{"tmp":"tmp/plugin-forms_0.1.2_1793591204312_0.5906636145683807","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@alpineux/plugin-forms","version":"0.1.3","keywords":["emdash","emdash-plugin","forms"],"author":{"url":"https://www.alpineux.com","name":"AlpineUX"},"license":"MIT","_id":"@alpineux/plugin-forms@0.1.3","maintainers":[{"name":"alpineux","email":"jason@alpineux.com"}],"homepage":"https://www.alpineux.com","dist":{"shasum":"e5c05101ccba841f1c3dc74143e3730a036311a3","tarball":"https://registry.npmjs.org/@alpineux/plugin-forms/-/plugin-forms-0.1.3.tgz","fileCount":8,"integrity":"sha512-nFTwgckzQLwwdN/D1831BHnrCbFQgiH552SigX4Zh6Wc80m9sBzsDIC3BZaR5WfnhjzTP82r3+DJmA/w6/GA8A==","signatures":[{"sig":"MEUCIQD6sgeggJvzY4nwbAdEp8N7TH0xfujQoXZP2fZJZSOGOAIgXgY6hHoWgrMx2mtXin7wXtFDrSsyhJYOcMhE9Nml73c=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEYCIQCZBRmk6W8sP1Z5RSml0T21hKbu00jV9CquzLPD1D803wIhAJw2XENcPrK9LZs19EJvLdI9ErnO7idCop80irB9ncV2","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":56926},"main":"dist/index.mjs","type":"module","_from":"file:/private/tmp/claude-501/-Users-jasonleyser-Documents-alpineux-emdash-alpineux/71b8f305-732a-4d23-a961-a6c818f6032a/scratchpad/alpineux-plugin-forms-0.1.3.tgz","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs"},"./sandbox":"./dist/plugin.mjs"},"scripts":{"dev":"emdash-plugin dev","test":"emdash-plugin validate && vitest run","build":"emdash-plugin build","login":"emdash-plugin login","bundle":"emdash-plugin bundle","validate":"emdash-plugin validate","typecheck":"tsc --noEmit","registry:publish":"emdash-plugin publish"},"_npmUser":{"name":"alpineux","email":"jason@alpineux.com"},"_resolved":"/private/tmp/claude-501/-Users-jasonleyser-Documents-alpineux-emdash-alpineux/71b8f305-732a-4d23-a961-a6c818f6032a/scratchpad/alpineux-plugin-forms-0.1.3.tgz","_integrity":"sha512-nFTwgckzQLwwdN/D1831BHnrCbFQgiH552SigX4Zh6Wc80m9sBzsDIC3BZaR5WfnhjzTP82r3+DJmA/w6/GA8A==","_npmVersion":"10.9.9","description":"Contact forms for your website, with email notifications and an inbox.","directories":{},"_nodeVersion":"22.23.4","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"zod":"4.5.4","emdash":"^1.4.0","vitest":"^4.1.0","typescript":"^6.0.3","@emdash-cms/blocks":"^1.4.0","@alpineux/plugin-kit":"0.1.0","@emdash-cms/plugin-cli":"0.13.5","@emdash-cms/plugin-test":"^0.2.6"},"peerDependencies":{"emdash":">=1.4.0"},"_npmOperationalInternal":{"tmp":"tmp/plugin-forms_0.1.3_1793592139956_0.34700024500377535","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"_id":"@alpineux/plugin-forms@0.1.4","dist":{"shasum":"5d12b87ed1a6cada2cbbe6b4b1f8f1380014b546","tarball":"https://registry.npmjs.org/@alpineux/plugin-forms/-/plugin-forms-0.1.4.tgz","fileCount":8,"integrity":"sha512-NyJB+Dzm4OXCJDQT5NtxY4Kg+na6MSIGVvhzCW/pmah/0WcEgDl8Iw//a/szji6ud2dy9H5BMe3yyMWQBqTz4A==","signatures":[{"sig":"MEQCIE/HQ//14DudrEhx2V+jcgfHQ0dFRdman8+/aFC3EmEzAiBTddTWuFmXOWZqy3yK9HwDil8sxeHbpK3ZsiOuBhFhJQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCboDk+xhQLzTWkNBNS3fQxFZ1o7FwGgLAcf226zyYEPAIgG1Ug/Fj2UcOAXaKXUMWKeuaF4sGMQkZUXs4/J5Mfkes="}],"unpackedSize":56207},"main":"dist/index.mjs","name":"@alpineux/plugin-forms","type":"module","_from":"file:/private/tmp/claude-501/-Users-jasonleyser-Documents-alpineux-emdash-alpineux/71b8f305-732a-4d23-a961-a6c818f6032a/scratchpad/alpineux-plugin-forms-0.1.4.tgz","author":{"url":"https://www.alpineux.com","name":"AlpineUX"},"exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs"},"./sandbox":"./dist/plugin.mjs"},"license":"MIT","scripts":{"dev":"emdash-plugin dev","test":"emdash-plugin validate && vitest run","build":"emdash-plugin build","login":"emdash-plugin login","bundle":"emdash-plugin bundle","validate":"emdash-plugin validate","typecheck":"tsc --noEmit","registry:publish":"emdash-plugin publish"},"version":"0.1.4","_npmUser":{"name":"alpineux","email":"jason@alpineux.com"},"homepage":"https://www.alpineux.com","keywords":["emdash","emdash-plugin","forms"],"_resolved":"/private/tmp/claude-501/-Users-jasonleyser-Documents-alpineux-emdash-alpineux/71b8f305-732a-4d23-a961-a6c818f6032a/scratchpad/alpineux-plugin-forms-0.1.4.tgz","_integrity":"sha512-NyJB+Dzm4OXCJDQT5NtxY4Kg+na6MSIGVvhzCW/pmah/0WcEgDl8Iw//a/szji6ud2dy9H5BMe3yyMWQBqTz4A==","_npmVersion":"10.9.9","description":"Contact forms for your website, with email notifications and an inbox.","directories":{},"maintainers":[{"name":"alpineux","email":"jason@alpineux.com"}],"_nodeVersion":"22.23.4","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"zod":"4.5.4","emdash":"^1.4.0","vitest":"^4.1.0","typescript":"^6.0.3","@emdash-cms/blocks":"^1.4.0","@alpineux/plugin-kit":"0.1.0","@emdash-cms/plugin-cli":"0.13.5","@emdash-cms/plugin-test":"^0.2.6"},"peerDependencies":{"emdash":">=1.4.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/plugin-forms_0.1.4_1793593834331_0.28792547346082853"}}},"time":{"created":"2026-11-02T01:23:23.517Z","modified":"2026-11-02T04:30:34.590Z","0.0.0-stage":"2026-11-02T01:23:23.517Z","0.1.0":"2026-11-02T01:24:18.948Z","0.1.2":"2026-11-02T03:46:44.407Z","0.1.3":"2026-11-02T04:02:20.040Z","0.1.4":"2026-11-02T04:30:34.437Z"},"author":{"url":"https://www.alpineux.com","name":"AlpineUX"},"license":"MIT","homepage":"https://www.alpineux.com","keywords":["emdash","emdash-plugin","forms"],"description":"Contact forms for your website, with email notifications and an inbox.","maintainers":[{"name":"alpineux","email":"jason@alpineux.com"}],"readme":"# Forms (EmDash plugin)\n\nContact forms for the website, written for people who aren't technical: build a form in the admin or connect one built in code, get each message by email, and keep them all in one inbox (admin → Apps → Forms).\n\n## Two kinds of form\n\n- **Built here.** The owner picks fields (short text, email address, phone number, long text, drop-down list, tick box), renames them and puts them in order. The site renders it with its own look: `<Form id=\"contact\" />` (`src/components/Form.astro` in the AlpineUX site, which reads the fields from the public `form` route in-process with `getPublicPluginApiRouteHandler`).\n- **Your own code.** A developer builds any form and posts it to `POST /_emdash/api/plugins/forms/submit` as JSON: `{ \"form\": \"<id>\", ...answers, \"cf-turnstile-response\": \"<token>\" }`, i.e. `Object.fromEntries(new FormData(form))` plus the form ID. Any field names work (up to 30, 20,000 characters in all); a field whose name contains \"email\" holding an address becomes the reply-to. The form's page in the admin shows a copy-paste example. It doesn't contain the Turnstile Site Key: it fetches it from the public `form` route when the page loads and renders Turnstile explicitly, so the keys live only under Spam protection and changing them there updates every form (built-in `<Form>` and the site's `/start` page read it the same way, server-side).\n\nBoth go through the same intake: same checks, inbox and emails.\n\nThe response (inside EmDash's `{ success, data }` envelope) is `{ ok: true, message }` with the form's thank-you text, or `{ ok: false, error, fields? }` with a plain sentence and, for built forms, which fields to fix.\n\n## Emails\n\nEach form has a notification to the owner (one or more addresses: the first is To, the rest Cc; replies go to the visitor) and an optional thank-you to the visitor. Cloudflare Email Sending has no templates, so the owner writes subject and message with `{variables}` and the plugin fills them in and sends finished text plus escaped HTML through `ctx.email.send()`: whichever email provider the site has (our Emails plugin, in production).\n\n- Notification: `{<field key>}` for any answer, `{all_fields}`, `{form}`, `{site}`, `{date}`. Field keys are fixed when a field is added, so renaming its label keeps emails working.\n- Thank-you: only `{name}` (letters, spaces, hyphens and apostrophes, 40 characters), `{form}`, `{site}`, `{date}`, and at most one per inbox per day (a `+tag`, and dots in Gmail addresses, don't make a new one). It never repeats what was typed, so the form can't be used to send someone else your domain's email with an attacker's words or links in it.\n\nWithout an email provider, messages are still kept and the page says so.\n\n## Keeping robots out (on by default)\n\nIn the order the intake runs them:\n\n1. **Forms are off until Turnstile is set up.** Nothing is accepted without spam protection; the admin walks the owner through adding a Turnstile widget and checks the Secret Key with Cloudflare before saving it (encrypted, as the `turnstileSecret` secret setting).\n2. **Hidden trap field** `_hp`: filled in means a robot. It gets a fake \"thanks\" and nothing is kept or sent. It's only counted on the Forms page within the visitor's hourly limit, so a robot can't run up storage writes.\n3. **Answers are checked before Turnstile**, so a typo doesn't use up the visitor's one-time pass: required fields, email and phone format, drop-down values must be one of the choices, lengths (200 / 5,000 for long text), control and invisible direction characters stripped, unknown fields dropped.\n4. **Per-visitor limit**: 5 messages an hour by default (1 to 50 in the admin), counted by a salted hash of the IP address; IPv6 addresses count by their /64, since one connection usually gets the whole block. IPs are never stored. The IP comes from EmDash's request metadata: always there on Cloudflare; elsewhere only with `trustedProxyHeaders` set. Without one the limit is skipped rather than shared by every visitor (which would let anyone close the form for everyone), and Turnstile alone checks each message.\n5. **Turnstile** (`siteverify`, with the visitor's IP). If Cloudflare can't be reached, the message is refused, not let through. A pass done on another site that shares the widget is refused too (the hostname Cloudflare reports must be the site's, ignoring `www.`; `localhost` and Cloudflare's test keys are allowed for development).\n\nEmDash's middleware also rejects browser posts from other websites (a different `Origin` gets a 403) before they reach the plugin. Bodies over 64 KB are refused.\n\n## Trust contract\n\n- `email:send`: notifications and thank-yous through the site's email provider.\n- `network:request` to `challenges.cloudflare.com` only (Turnstile).\n- Public routes: `form` (GET, a form's fields, button text, thank-you text and the Turnstile site key; never the email settings) and `submit` (POST).\n- Storage: `forms`, `messages` (the answers, name, email, the page on this site it came from, email outcome), `limits` (hashed counters, cleared after two days, and the daily counts, kept 62 days). KV: Turnstile site key, per-hour limit, the hash salt (0.1.0 also kept the daily counts here as `stats:days`; they're still shown but no longer written).\n\n## Calls per request\n\nEmDash's Cloudflare sandbox allows a plugin 10 calls out per request: each KV, settings or storage call, fetch, email and log line counts, and going over fails the request even when the work is done. So each request reads KV and settings with one `kv.list()` (`load()` in `src/guard.ts`, which includes the decrypted Turnstile secret), and a visitor's counters and the day's counts are one `getMany()` and one `putMany()` on `limits`. A message with a notification and a thank-you makes 9 calls; opening the Forms page makes 6 (old counters are cleared then, not while a visitor waits). The forms list shows each form's messages over the last 30 days, from the daily counts, because counting every form's messages would be a call per form. `tests/calls.test.ts` counts calls on every path with a fake context, since the test host doesn't enforce the limit.\n\n## Testing locally\n\nTurnstile's [test keys](https://developers.cloudflare.com/turnstile/troubleshooting/testing/) work: site key `1x00000000000000000000AA` with secret `1x0000000000000000000000000000000AA` always passes. In `astro dev`, emails go to EmDash's console provider (the terminal) unless the email provider was switched (see `packages/plugin-emails/README.md`).\n\n## Files\n\n- `src/plugin.ts`: routes (`admin`, public `form` and `submit`) and the admin actions\n- `src/submit.ts`: the intake\n- `src/forms.ts`: the form model, defaults and checking answers\n- `src/emails.ts`: variables, the two emails, HTML\n- `src/guard.ts`: reading KV and settings (`load`), Turnstile, limits, daily counts\n- `src/screens.ts`: the screens and all user-facing wording, built from `@alpineux/plugin-kit` (the Help tab is hidden with `SHOW_HELP = false` until the guide pages under https://www.alpineux.com/docs/forms exist; its links come from `DOCS_URL` and `GUIDES` there)\n\n## Develop\n\n```sh\npnpm install\npnpm run typecheck\npnpm test        # validates the manifest, builds, runs tests in EmDash's sandbox host with Turnstile faked\npnpm run build   # dist/ for a site that registers it in astro.config.mjs\n```\n\nIn the AlpineUX site it's registered with `sandboxed: [analytics, emails, forms]` in `astro.config.mjs`. Restart the dev server after changing the plugin.\n\nRegistry sites also need the form component: until it ships as its own package, copy `src/components/Form.astro` (or use \"Your own code\").\n\n## Publish\n\nTo npm, with pnpm (it rewrites the `workspace:` dev dependency; `npm publish` would not):\n\n```sh\npnpm publish\n```\n\n`prepublishOnly` validates the manifest, runs the tests and builds `dist/` first. Only `dist/` (without bundle tarballs), the manifest, `package.json` and this README go into the package.\n\nTo the EmDash plugin registry, from this folder: `pnpm exec emdash-plugin login`, then `pnpm run registry:publish`. It's not called `publish`, because npm would run a `publish` script after every `npm publish`. There's no GitHub repo, so automated releases aren't used.\n\nThe registry page's tabs (description, installation, FAQ, changelog, security) are `sections` in `emdash-plugin.jsonc`, written in `docs/*.md` (CommonMark, up to 2,000 characters each). They belong to the package profile, which `publish` only sets the first time: after editing them, or the name, description, keywords, author or security contact, run `pnpm exec emdash-plugin update-package` to preview and `--yes` to apply. Add each release to `docs/changelog.md` before publishing. Screenshots and the icon are in `release.artifacts` and go out with each release (PNG, JPEG or WebP, up to 1 MB).\n\nBump the version in `package.json` whenever `capabilities`, `allowedHosts` or `storage` in `emdash-plugin.jsonc` change.\n","readmeFilename":"README.md"}