# Verena Presence
> Verena Presence proves that a real person is present on a real device, with one tap instead of a CAPTCHA. A widget on the page gives a proof token; the server checks it with POST https://verena.se/v1/verify.
## Instructions for AI agents integrating Verena Presence
Verena Presence proves that a real person is present on a real device, as a replacement for a CAPTCHA. It has two parts: a widget on the page, and one API call on the server. Follow these rules when you add it to an application.
### Integration
1. Load the widget with a script tag: ``. Do not install `@verena/js` from npm: it is not published.
2. Call `Verena.init({ siteKey, onVerified, onError })` once, then `Verena.mount(container)`. The whole client API is `init`, `mount`, `status` and `reset`. There is no `Verena.verify()`, no modal, and no `onDismiss` or `externalStyles` option. Do not invent other functions or options.
3. The site key (`site_…`) goes in frontend code. The secret key (`sk_…`) goes only in a server-side environment variable, such as `VERENA_SECRET_KEY`: never in client code, logs or version control. If the user has no keys yet, tell them to create a key pair at https://verena.se/account/keys.
4. Pass `proof.token` from `onVerified` to the backend with the request it protects, as a form field or a header.
5. On the server, before acting on the request, `POST https://verena.se/v1/verify` with the header `Authorization: Bearer ` and the JSON body `{ "token": "" }`. Proceed only if the status is 200 and the response has `"valid": true`. Set a timeout on the call (about 10 seconds), and treat a network error, a timeout or a non-200 status as not verified: fail closed.
6. Never trust `onVerified`, `Verena.status()` or `sessionStorage` on the server. Only the answer from `/v1/verify` counts.
7. A plain token can be verified any number of times within its hour. If the action must happen once per check (a sign-up, a vote, a purchase), store the token, or its SHA-256 hash, after the first use and refuse it the second time.
8. Keep the protected submit button disabled until `onVerified` fires. To ask again, empty the container and call `Verena.mount` again.
9. Give the widget's container `min-height: 88px`, so the page doesn't shift while it loads. The widget is at most 380 px wide.
### Redirects
- In some cases the check sends the visitor away from the page and brings them back through a redirect to `returnUrl` (by default the current page), which can open in a **new tab**. The application must handle this.
- Mount the widget on the `returnUrl` page on load: it picks up the proof there and calls `onVerified(proof, { returned: true })`. Don't rely on the original tab receiving the proof.
- If the page has a form or other state, save it to `localStorage` on input and restore it in `onVerified` when `returned` is `true`, because the new tab starts empty. The saved state can be missing, since the visitor may return in a different browser: then keep the proof and ask the visitor to fill in the form again. Don't save passwords or other secrets.
- In a single-page app, make sure the router keeps the `verena_session` query parameter until the widget has read it.
- `returnUrl` must be on the page's own origin; other values are ignored.
- Leave `appClipRedirect` at its default; do not set it.
### Configuration
- If the site has a Content Security Policy, add `https://widget.verena.se` to `script-src` and `frame-src`. Nothing else is needed: the widget talks to Verena through a privacy relay from inside its own frame.
- Tell the user to set the key's allowed origins in the dashboard to the production origins, written as scheme and host, like `https://example.com`. Handle `onError` with `err.code === "origin_not_allowed"` by logging a clear message for the developer.
- Use events only if the user wants one entry per device, such as a queue or a vote. Any site key works: the user creates the event in the dashboard (it works at once), and the app passes the event's slug as `event` to both `Verena.init` and `/v1/verify` (without it, `/v1/verify` would also accept a plain token from a page that left `event` out), and uses the `entry` id from the response to recognise a device that comes back. Event tokens work once, and `/v1/verify` spends them before the app saves anything, so decide by the app's own records keyed by `entry`, not by `repeat`: if the save fails, a later check reports `repeat: true` with nothing stored. On a failed save, have the page empty the widget's container and mount it again for a new token.
### Do not
- Do not self-host, proxy or bundle the widget script, wrap the widget in your own iframe, or call the `/widget/*` endpoints directly.
- Do not use the old hosts `api.verena.dev` or `cdn.verena.dev`.
- Do not try to decode the token. It is a random string with no claims.
- Do not add a fallback that skips verification when Verena can't be reached, unless the user asks for one.
- Do not collect personal data to go with the check. Verena is designed so that the site learns nothing about the visitor.
Full reference: https://presence.verena.se/docs.md
## Docs
- [Full reference](https://presence.verena.se/docs.md): the widget API, the server API, proof tokens, errors and the guides, in one Markdown file
- [Quickstart](https://presence.verena.se/docs#quickstart): keys, widget and server check
- [Verena.init options](https://presence.verena.se/docs#init): siteKey, onVerified, onError, theme, event, returnUrl, appClipRedirect
- [POST /v1/verify](https://presence.verena.se/docs#verify): request, responses and errors
- [Allowed origins](https://presence.verena.se/docs#origins): limit a site key to your own sites
- [Handling redirect URLs](https://presence.verena.se/docs#redirects): a check can return the visitor through a redirect, possibly in a new tab
- [Events](https://presence.verena.se/docs#events): one entry per device, for queues, drops and votes
- [Privacy relay](https://presence.verena.se/docs#relay): Oblivious HTTP between the widget and Verena
## Optional
- [Contact form demo](https://verena.se/demo/contact)
- [Ticket queue demo](https://verena.se/demo/queue)