Verena Presence

Prove a real person is there, without a CAPTCHA

Presence is a widget for your page and one API call for your server. The visitor taps once on their phone, with Face ID or a fingerprint.

Using a coding agent? Give it this prompt. More

Integrate Verena Presence. Follow https://verena.se/llms.txt.
Try itLive
Tick the box. The proof your onVerified callback receives shows up here.

Quickstart

Three pieces: a key pair from the dashboard, the widget on your page, and a check on your server before you act on the request.

  1. Create a key pair

    Sign in and create a key in the dashboard. You get a site key (site_…) for the page and a secret key (sk_…) for your server. The secret key is shown once, so store it right away.

  2. Add the widget

    Load the script, give it a container, and call init and mount. When the visitor has verified, onVerified receives a proof token.

  3. Check the token on your server

    Send the token along with the request you want to protect. Your server posts it to /v1/verify with the secret key and proceeds only if valid is true.

Always check on the server. The widget's callback runs in the visitor's browser, and a bot can skip it. Only the answer from /v1/verify counts.
index.html
<div id="verena" style="min-height: 88px"></div>
<script src="https://widget.verena.se/js/verena.min.js"></script>
<script>
  Verena.init({
    siteKey: "site_your_key",
    onVerified: (proof) => {
      // Send proof.token with the request you want to protect
      form.elements.verenaToken.value = proof.token;
    },
  });
  Verena.mount("#verena");
</script>
app.post("/signup", async (req, res) => {
  let valid = false;
  try {
    const check = await fetch("https://verena.se/v1/verify", {
      method: "POST",
      headers: {
        "Authorization": `Bearer ${process.env.VERENA_SECRET_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ token: req.body.verenaToken }),
      signal: AbortSignal.timeout(10_000),
    });
    valid = check.ok && (await check.json()).valid === true;
  } catch {
    // Network error or timeout: fail closed
  }
  if (!valid) return res.status(403).send("Verify you're human first.");

  // A real person is here: go ahead
});

How a check works

The widget runs in a frame on Verena's domain, so your page never handles keys, biometrics or proofs. Your page only passes an opaque token to your server, and your server asks Verena whether it is good.

In step 2, the visitor confirms with their device, and Verena checks that interaction with local device attestation: the device's own secure hardware vouches that a real person used it, in a way a script can't fake. How that runs differs per platform and device, and can change over time; nothing in your integration depends on it.

What you can rely on is the outside: onVerified gives you a token, and /v1/verify answers the same whichever way the visitor verified.

Entering again

At a gate, Verena counts entries per device. Each gate has a number of entries per device: 1 unless you set another, up to 100 (maxUses).

  • Entries left: the device enters again, with a new entry id and repeat: false.
  • None left: the device isn't turned away. It gets a token for its last entry again: the same entry id, with repeat: true. Look that id up in your records and give the visitor their place back. With 1 entry per device, that is every return.
  • Another device is another entry. Verena can't tell that two devices belong to one person.
  • Clear entries on the gate's page starts the count over: every device can enter again, and keeps its entry ids.

Treat entry, not repeat, as the truth: if an earlier save on your side failed, the retry says repeat: true though you have nothing stored (see Gates).

Build with AI

Using a coding agent like Claude Code, Cursor or Codex? Give it these docs and the rules on the right, and it can add Verena to your app with the details right: the secret key stays on the server, the token is checked before anything happens, and the iPhone return is handled.

Agent instructions

Rules for adding Verena, written for an agent. Paste them into your prompt, or into a file your agent reads, like AGENTS.md or CLAUDE.md.

This whole reference as one Markdown file, with the instructions included.

The instructions and an index of the docs, in the llms.txt format that agents look for.

Example prompt

Integrate Verena Presence. Follow https://verena.se/llms.txt.
Agent instructions
## 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: `<script src="https://widget.verena.se/js/verena.min.js"></script>`. 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`. The only options are `siteKey`, `onVerified`, `onError`, `theme`, `gate`, `returnUrl` and `appClipRedirect`. 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 <secret key>` and the JSON body `{ "token": "<token>" }`. Proceed only if the status is 200 and the response has `"valid": true`. The response also has `scope`: `"personhood"` for a plain token, `"device-entry"` at a gate (see Gates below). When it isn't valid, `code` says why, such as `token_invalid` or `wrong_key`. 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`. That is all the widget needs: it talks to Verena through a privacy relay from inside its own frame. Also add `https://verena.se` to `connect-src` and `frame-src`, so the widget keeps working when the relay can't be reached: it then falls back to a direct connection, which a stricter policy blocks.
- Every key needs at least one allowed origin, written as scheme and host, like `https://example.com`. For development, use a separate key with the dev origin, such as `http://localhost:3000`, or add that origin to the key. Tell the user to list the production origins on the key in the dashboard. Handle `onError` with `err.code === "origin_not_allowed"` by logging a clear message for the developer.

### Gates

- Use a gate only if the user wants to limit entries per device, such as a queue or a vote: one entry per device, unless the gate sets more (`maxUses`, up to 100). Any site key works. The user creates the gate under Gates in the dashboard (it works at once), or the app's setup does it with `POST /v1/gates` (see the reference).
- Pass the gate's slug as `gate` to both `Verena.init` and `/v1/verify`. Without it, `/v1/verify` would also accept a plain token from a page that left `gate` out; with it, such a token is refused with `not_gate_token`.
- A valid gate token answers `{ "valid": true, "scope": "device-entry", "gate": "<slug>", "entry": "<32 hex characters>", "repeat": <boolean> }`. `entry` is the id of one entry. With one entry per device it is the same every time the device comes back: use it to recognise that device. With more, each entry has its own id, and a device with none left gets its last one again. `repeat` is `true` when the token is for an entry made before.
- Gate tokens work once, and `/v1/verify` spends them before the app saves anything. So decide by the app's own records keyed by `entry` (with a unique index), not by `repeat`: if the save fails, a later check reports `repeat: true` with nothing stored. On a failed save, answer an error and have the page empty the widget's container and mount it again for a new token.
- In `onError`, `unknown_gate` means no gate with that slug is on this site key, and `bad_gate` means `gate` isn't a string. `/v1/verify` answers `unknown_gate` too, when the slug the server passed isn't on the key: the token stays unused.
- Gates were called events until December 2026. Don't use the old names (`event`, `/v1/events`, `unknown_event` and the like) in new code.

### 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: it doesn't need any.

Full reference: https://verena.se/docs.md

Install

Load the script from Verena. It defines a global Verena with four functions: init, mount, status and reset.

The widget is a 380 × 88 frame that fills its container's width up to 380 px. It works on any page served over HTTPS, and on localhost.

npm package. @verena/js is not on npm yet. Until it is, load the script tag; it is versioned and cached by the CDN.
HTML
<script src="https://widget.verena.se/js/verena.min.js"></script>

Verena.init(config)

Configures the widget. Call it once, before mount. It throws if siteKey is missing.

Parameters

siteKeystringRequired

Your public site key, site_…. Safe to put in page source.

onVerified(proof, context) => void

Called when the visitor has verified.

proof.tokenstring

The proof token. Send it to your server.

proof.expiresAtnumber

Unix time in seconds when the token expires, one hour after it was issued.

proof.repeatboolean?

Only at a gate: this device had entered before and gets its same entry back.

context.returnedboolean

true when the visitor came back through a redirect, on a new tab. Anything they had in the original tab, like a half-filled form, isn't here. See Handling redirect URLs.

onError(error) => void

Called with an Error when the widget can't start or the check fails. It may carry a code: see Errors.

theme"light" | "dark" | "auto"Default "light"

"auto" follows the visitor's system setting.

gatestring

The slug of one of your gates, made on this site key. With it, the check is an entry to that gate; without it, plain verification. Any site key does both.

returnUrlstringDefault: the current page

Where the visitor returns after verifying, when the check sends them away from your page, as on iPhone or in an in-app browser. Must be on your page's origin; any other value is ignored. See Handling redirect URLs.

appClipRedirectbooleanDefault true

Set to false to keep iPhones in Safari instead of the Verena App Clip. A new iPhone can't verify there, so use it for testing only. Ignored at gates.

JavaScript
Verena.init({
  siteKey: "site_your_key",
  theme: "auto",
  onVerified(proof, { returned }) {
    tokenInput.value = proof.token;
    submitButton.disabled = false;
    if (returned) restoreDraft();
  },
  onError(err) {
    errorText.textContent = err.message;
  },
});
proof
{
  "token": "3f9a2c7d1e…",
  "expiresAt": 1796342400
}

Verena.mount(container)

Renders the widget into container, a CSS selector or an element. The widget runs the whole check: the checkbox, the tap, the phone hand-off and the result.

It throws if init hasn't been called or the container doesn't exist. To start over, for example after the token was used, empty the container and mount again.

Parameters

containerstring | ElementRequired

Where to put the widget. Give it a min-height of 88 px to avoid a layout shift while it loads.

JavaScript
Verena.mount("#verena");

// Later, to ask again
const box = document.querySelector("#verena");
box.innerHTML = "";
Verena.mount(box);

Verena.status()

Whether this tab holds an unexpired proof. The widget keeps the last proof in sessionStorage, so it lasts across page loads in the tab and is gone when the tab closes.

Use it to skip the widget for a visitor who just verified. It doesn't return the token: keep the one from onVerified if a later request needs it. It says nothing your server can rely on: check the token there as usual.

Returns

verifiedboolean

true if an unexpired proof is stored.

expiresAtnumber?

Unix time in seconds. Only when verified is true.

JavaScript
const { verified } = Verena.status();
if (!verified) Verena.mount("#verena");

Verena.reset()

Forgets the stored proof, so status() reports verified: false. Call it on sign-out, or whenever you want the visitor to verify again. Tokens already issued stay valid on the server until they expire.

JavaScript
signOutButton.addEventListener("click", () => {
  Verena.reset();
  location.href = "/";
});

Errors

onError receives an Error whose message is readable as is. When the cause is in your setup, it also has a code. Setup errors are logged to the console too, prefixed with [verena].

codeMeaningFix
invalid_keyThe site key doesn't exist.Check siteKey; it may have been deleted.
origin_not_allowedThe page's origin isn't in the key's allowed origins.Add it in the dashboard.
unknown_gateNo gate with that slug on this key.Check the slug, and that the gate is on the key in siteKey, in Gates.
bad_gategate isn't a string.Pass the slug as a string, or leave gate out.

Errors without a code come from the check itself, such as a cancelled fingerprint prompt. The widget shows them and lets the visitor try again, so you usually don't need to do anything.

Content Security Policy

If your site sends a Content Security Policy, allow the script and the frame from widget.verena.se.

That is all. The widget talks to Verena from inside its frame, through an independent privacy relay, so your page makes no requests to Verena and needs no connect-src entry. Only if the relay is unavailable does the widget fall back to https://verena.se; to allow that fallback, add it to connect-src and frame-src.

HTTP header
Content-Security-Policy:
  script-src 'self' https://widget.verena.se;
  frame-src https://widget.verena.se

Authentication

The server API takes your secret key as a bearer token. Keep it on your server, out of page source and out of version control.

Each secret key belongs to one site key. A token issued for one key pair can only be verified with that pair's secret key.

Base URL

https://verena.se

Header
Authorization: Bearer sk_your_secret_key
401 · wrong key
{
  "valid": false,
  "code": "invalid_secret",
  "error": "Invalid secret key."
}

Verify a token

POST/v1/verify

Checks a proof token. Call it before you act on the request it came with. A token that isn't valid always returns 200 with valid: false and an error; 401 and 400 mean the call itself was wrong. 503 means Verena couldn't answer: don't let the request through, and try again.

Body parameters

tokenstringRequired

The token from onVerified.

gatestring

For gate tokens: the slug you expect. Always pass it when you expect an entry: a site key gives plain tokens too, and with gate those are refused (not_gate_token). A token for another gate of the same key is refused, and stays unused.

Response

validboolean

Whether to let the request through.

scope"personhood" | "device-entry"

"device-entry" for gate tokens, "personhood" for all others.

errorstring

Why the token isn't valid, in words.

codestring

The same, for code: token_invalid (unknown, expired, or a gate token already spent), wrong_key (issued for another site key), not_gate_token (you passed gate; the page didn't), other_gate (the token is for another gate of this key, and stays unused), unknown_gate (the gate you passed isn't a gate of this key: check the slug; the token stays unused), or token_used (another call spent the token at the same moment). Your gate's page in the dashboard counts each of these.

gatestring

Gate tokens: the gate's slug.

entrystring

Gate tokens: the id of this entry, 32 hex characters. The same every time the device comes back to it; at a gate with more than one entry per device, each entry has its own (see Entering again). Use it to give a returning visitor back their place. Its page in the dashboard is https://verena.se/account/entries/<entry>.

repeatboolean

Gate tokens: true when the token is for an entry the device made before, false for a new entry.

const res = await fetch("https://verena.se/v1/verify", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.VERENA_SECRET_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ token }),
  signal: AbortSignal.timeout(10_000),
});
// Not 200, a network error or a timeout: not verified
const result = res.ok ? await res.json() : { valid: false };
{
  "valid": true,
  "scope": "personhood"
}

Proof tokens

A token is a random 64-character hex string. It carries no claims and can't be decoded: /v1/verify is the only way to check one. Verena stores only its hash.

PropertyBehaviour
LifetimeOne hour from issue (expiresAt).
ScopeValid only with the secret key of the site key it was issued for.
ReuseA plain token can be verified any number of times until it expires. If an action should happen once per check, mark the token as used on your side.
Single useGate tokens are spent by the first successful /v1/verify. Verifying again returns valid: false.
RevocationNone. Tokens are short-lived; let them expire.
Same token, every flow. Whether the visitor verified on an iPhone, an Android phone, or handed off from a computer to their phone, the token looks the same and /v1/verify answers the same. You can't tell flows apart, and don't need to.

Keys

What the dashboard does with keys and gates, for your server or a coding agent. It answers in JSON; an error has an error message and, for a missing or wrong credential, 401.

  • An access token (pat_…, made under Access tokens in the dashboard) acts as you: all your keys and their gates. Keep it on your server or in your agent's secrets.
  • A key's secret key (sk_…) reaches that key's gates only, not /v1/keys.

Send it in the Authorization header: Authorization: Bearer pat_… for an access token, Authorization: Bearer sk_… for a secret key.

RequestDoes
GET /v1/keysYour keys: label, allowed origins, how many gates, when last used.
POST /v1/keysCreate a key: { "label", "allowed_origins" }, with at least one origin. Returns the site key and the secret key, shown only this once.
PATCH /v1/keys/:idChange label or allowed_origins (comma-separated; example.com is saved as https://example.com).
DELETE /v1/keys/:idDelete a key. A key with gates can't be deleted: remove them first.
Create a key
curl https://verena.se/v1/keys \
  -H "Authorization: Bearer $VERENA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"label": "Shop", "allowed_origins": "shop.example.com"}'
# {"id": "8a1d…", "key": "site_…", "secret_key": "sk_…", …}

Gates

Everything you do with gates in the dashboard, you can also do through the API: create a gate with a name, give it an image shown as people enter, read its counts and entries, clear it or remove it. That lets your server or a coding agent set up a gate without opening the dashboard.

Use the same credentials as for keys. With an access token, POST /v1/gates takes the keyId to make the gate on; with a secret key, the gate goes on that key.

RequestDoes
GET /v1/gatesThe keys and their gates, with counts. With a secret key: that key only.
POST /v1/gatesCreate a gate: { "slug", "name", "keyId"?, "maxUses"? }. maxUses is the entries per device, 1 to 100 (default 1). Returns { "id" }.
GET /v1/gates/:idOne gate: counts by day, week and month, by phone and over time, and how its checks went.
GET /v1/gates/:id/entriesThe gate's entries, newest first, at most 500, with their total. Each has its id (the entry from /v1/verify), enteredAt and platform.
GET /v1/gates/entries/:entryOne entry by the entry id from /v1/verify, with its gate.
PATCH /v1/gates/:idChange name or maxUses. The slug can't change.
PUT /v1/gates/:id/imageSet the image shown as people enter. The body is the file: PNG, JPEG or WebP, at most 512 KB.
DELETE /v1/gates/:id/imageRemove the image.
POST /v1/gates/:id/clearClear its entries: every device can enter again.
DELETE /v1/gates/:idRemove the gate. Pages that name it stop working at once.
A gate with a name and an image
curl https://verena.se/v1/gates \
  -H "Authorization: Bearer $VERENA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"keyId": "8a1d…", "slug": "spring-drop", "name": "Spring drop"}'
# {"id": "3f9c…"}

curl -X PUT https://verena.se/v1/gates/3f9c…/image \
  -H "Authorization: Bearer $VERENA_TOKEN" \
  -H "Content-Type: image/png" \
  --data-binary @poster.png

Guide

Allowed origins

A site key is public: anyone can copy it from your page. Allowed origins make sure it only works on your sites. Set them per key in the dashboard, as a comma-separated list.

EntryAllowsDoesn't allow
https://example.comhttps://example.com, and the same host on another porthttps://www.example.com, http://example.com
http://localhost:3000Your dev server on that portOther ports
  • Write scheme and host, plus a port if it isn't the default. No path, no trailing slash.
  • Subdomains are separate origins: list https://www.example.com too if you use it.
  • Anywhere else, the widget doesn't start and onError gets origin_not_allowed, with the origin it saw. The message is logged to the console too.
  • The list is required: a key names at least one origin. An empty list is refused with origins_required. While you build, use a separate key for your dev origin, such as http://localhost:3000.

Keep separate keys for production and for development or staging, so their origins and traffic stay apart. Every key does plain verification and any of its gates. The first key's origin defaults to the website you gave at sign-up; change it any time with Edit on the key.

Allowed origins
https://example.com, https://www.example.com

Guide

Handling redirect URLs

Most checks finish inside the widget, on your page. In some cases, depending on the device and on how the visitor moves through the check, Verena sends them back to your site through a redirect instead, and that can land in a new tab. Your site must handle it.

The two common cases:

  • iOS. The check runs in the Verena App Clip, and when it's done, iOS opens your page again in a new Safari tab rather than returning to the one the visitor left.
  • In-app browsers, the browser views inside apps like Instagram, TikTok or Gmail. The check can't finish there, so it continues in the device's regular browser, and the visitor comes back to your page in a new tab there, not in the app they started in.
  1. The visitor leaves your page

    For example, the App Clip opens over Safari, or an in-app browser hands over to the regular browser.

  2. They verify

    Verena issues the token for the session.

  3. Back to returnUrl

    The visitor lands on returnUrl (by default the page they came from), possibly in a new tab, with a verena_session query parameter.

  4. The widget picks it up

    It removes the parameter from the address bar, scrolls back to where the visitor was, shows as verified and calls onVerified(proof, { returned: true }).

What your site must do:

  • Mount the widget on the returnUrl page, on load. Without it, the proof isn't picked up and the visitor would have to verify again.
  • Save what the visitor filled in before they verify, and restore it when returned is true: they come back in a new tab that starts empty. Save it in localStorage or on your server. localStorage stays in one browser, so it's gone when an in-app browser (Instagram, TikTok, Gmail) hands the visitor over to their regular browser. Only a copy on your server, such as under their account, survives that.
  • Single-page apps: point returnUrl at a route that mounts the widget, and don't let your router drop the verena_session parameter before the widget reads it.
  • Don't rely on the original tab. It may still be open, but it won't receive the proof.

returnUrl must be on your page's origin. Other values are ignored, so a session can't be turned into an open redirect.

Keep a form across the redirect
const KEY = "signup-draft";
form.addEventListener("input", () => {
  const draft = Object.fromEntries(new FormData(form));
  delete draft.password; // never store secrets
  try {
    localStorage.setItem(KEY, JSON.stringify(draft));
  } catch {} // private mode or full: the fallback below covers it
});
form.addEventListener("submit", () => {
  localStorage.removeItem(KEY);
});

Verena.init({
  siteKey: "site_your_key",
  returnUrl: "/signup",
  onVerified(proof, { returned }) {
    form.elements.verenaToken.value = proof.token;
    if (!returned) return;
    let draft = null;
    try {
      draft = JSON.parse(localStorage.getItem(KEY));
    } catch {} // storage blocked, or not valid JSON
    if (draft) {
      for (const [k, v] of Object.entries(draft)) {
        if (form.elements[k]) form.elements[k].value = v;
      }
    } else {
      // Back in another browser, without the draft.
      // The proof still counts: ask for the form again.
      notice.textContent =
        "You're verified. Please fill in the form again.";
    }
  },
});
Verena.mount("#verena");

Guide

Gates

A gate lets each device in a set number of times, once unless you choose more: a ticket queue, a drop, a vote, a sign-up. A device that comes back after that gets its same entry, so a visitor who reloads keeps their place instead of being turned away (see Entering again).

  1. Create the gate

    Under Gates, give it a name; the dashboard suggests a slug from it. Put it on any of your keys, which keep working for plain verification, or let the dashboard make a new one. Optionally an image (PNG, JPEG or WebP, up to 512 KB) that the App Clip shows as the visitor enters.

  2. Pass the slug

    Give gate to Verena.init and to /v1/verify. Store the entry from the response, and look it up in your own records to give a returning device its place back; repeat: true says the device got an earlier entry back.

  • Gates were called events until December 2026. The old names (event, /v1/events, codes such as unknown_event) still work for now, and will be removed.
  • Gate tokens work once. A token for another gate of the same key is refused and stays unused.
  • A failed save. /v1/verify spends the token before your app saves anything. If the save then fails, the visitor needs a new token, and that check reports repeat: true though you never recorded the sign-up. So look the entry up in your own records: none there means accept the retry, one there means they already signed up. Put a unique index on entry, so two retries at once save one row.
  • Timeouts and errors. A timeout, a network error or a non-200 from /v1/verify is never a pass. Answer 503 and let the page ask for a new check.
  • When nothing comes in, the gate's page shows each stage as Verena saw it, as counts only: checks your page started, refusals (origin_not_allowed, unknown_gate), QR handoffs no phone finished, phones turned away, and /v1/verify answers by code. It shows by platform and over time, never which device.
Page
Verena.init({
  siteKey: "site_your_key",
  gate: "spring-sale",
  async onVerified(proof) {
    const res = await fetch("/signup", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({
        token: proof.token,
        ...Object.fromEntries(new FormData(form)),
      }),
      signal: AbortSignal.timeout(15_000),
    }).catch(() => null); // network error or timeout
    if (res?.ok) return showDone(await res.json());

    // Not saved. The token may be spent, so get a new one.
    // The server accepts the retry: it has no record of
    // this entry yet, whatever `repeat` says.
    notice.textContent = "That didn't go through. Verify again.";
    const box = document.querySelector("#verena");
    box.innerHTML = "";
    Verena.mount(box);
  },
});
Verena.mount("#verena");
Server
// The /v1/verify call, failing closed. `unavailable`:
// Verena couldn't answer, so ask for a new check later.
async function verify(body) {
  try {
    const res = await fetch("https://verena.se/v1/verify", {
      method: "POST",
      headers: {
        "Authorization": `Bearer ${process.env.VERENA_SECRET_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify(body),
      signal: AbortSignal.timeout(10_000),
    });
    if (!res.ok) return { valid: false, unavailable: res.status >= 500 };
    return await res.json();
  } catch {
    return { valid: false, unavailable: true }; // network error, timeout
  }
}

app.post("/signup", async (req, res) => {
  const result = await verify({ token: req.body.token, gate: "spring-sale" });
  if (result.unavailable) return res.status(503).end();
  if (!result.valid) return res.status(403).end();

  // The token is now spent. Decide by your own record of
  // this entry, never by `repeat`: if an earlier save failed,
  // this retry says repeat: true and you have nothing stored.
  // signups.entry has a unique index.
  const saved = await signups.findByEntry(result.entry);
  if (saved) return res.json({ id: saved.id, already: true });
  try {
    const { id } = await signups.insert({ entry: result.entry, email: req.body.email });
    res.json({ id });
  } catch (e) {
    if (isUniqueViolation(e)) return res.json({ already: true }); // a parallel retry won
    console.error("signup not saved", e);
    res.status(503).end(); // the page asks for a new check, and we accept it
  }
});

Guide

Privacy relay

We use a private relay to mask visitors' IP addresses from our servers. As a result, the widget never talks to Verena's servers directly. Its requests are encrypted with Oblivious HTTP (RFC 9458) and sent through an independent relay run by Oblivious Network (relay.oblivious.network).

WhoSeesDoesn't see
The relayThe visitor's IP addressThe content: it's encrypted for Verena
VerenaThe contentThe visitor's IP address, only the relay's
Your siteThe tokenAnything from the check itself
  • The widget's page and script load from widget.verena.se, a static host, so loading it doesn't reach Verena's servers either.
  • Your page makes no requests to Verena. That's why a Content Security Policy needs only script-src and frame-src.
  • If the relay can't be reached, or Verena switches it off, the widget falls back to a direct connection: your page creates the session with https://verena.se and loads the widget from there. Under a CSP that doesn't allow that host in connect-src and frame-src, the fallback is blocked and the widget shows an error instead.
  • It's on by default; there's nothing to set up. To debug, add ?verena_ohttp=0 to your page's address to turn it off for that page load.

Privacy and security

What your site learns

That a person verified on a real device: valid: true. No name, no email, no device id, no biometrics. At gates, an entry id that is only meaningful within that gate.

What Verena learns

For a standard check, that one of the registered devices proved itself, not which one: the proof is zero-knowledge, over a set of all registered keys. The device fetches its place in that set with private information retrieval (PIR), so even that lookup doesn't single it out. Biometrics never leave the device.

The widget sends its requests through an independent privacy relay: the relay sees the visitor's IP address but not the content, and Verena sees the content but not the IP address.

Security

  • Every check answers a fresh, single-use challenge, so a captured proof can't be replayed.
  • The widget runs in a cross-origin frame. Scripts on your page can't read it or click it on the visitor's behalf.
  • Tokens are bound to your key pair, expire after an hour, and are stored only as hashes.

More in the privacy policy.

Testing

  • The widget works on http://localhost. Add your dev origin, such as http://localhost:3000, to the key's allowed origins, or use a separate key for development.
  • Use a real phone: an iPhone, or an Android phone with Chrome. From a computer, scan the QR code with your phone.
  • Check your server path with a real token from onVerified; anything else returns valid: false. Remember that tokens expire after an hour.
  • See the live demos at verena.se/presence.

Questions or something missing here? info@verena.se