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.
init, mount, callbacks and errors.
Server APIPOST /v1/verify and what it returns.
Using a coding agent? Give it this prompt. More
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.
-
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. -
Add the widget
Load the script, give it a container, and call
initandmount. When the visitor has verified,onVerifiedreceives a proof token. -
Check the token on your server
Send the token along with the request you want to protect. Your server posts it to
/v1/verifywith the secret key and proceeds only ifvalidistrue.
/v1/verify counts.<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
});
@app.post("/signup")
def signup():
try:
check = requests.post(
"https://verena.se/v1/verify",
headers={"Authorization": f"Bearer {VERENA_SECRET_KEY}"},
json={"token": request.form.get("verenaToken", "")},
timeout=10,
)
valid = (check.status_code == 200
and check.json().get("valid") is True)
except (requests.RequestException, ValueError):
valid = False # error or timeout: fail closed
if not valid:
return "Verify you're human first.", 403
# A real person is here: go ahead
curl https://verena.se/v1/verify \
-H "Authorization: Bearer sk_your_secret_key" \
-H "Content-Type: application/json" \
-d '{ "token": "3f9a2c…" }'
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
entryid andrepeat: false. - None left: the device isn't turned away. It gets a token for its last entry again: the same
entryid, withrepeat: 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
entryids.
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.
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.
Example prompt
## 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.
@verena/js is not on npm yet. Until it is, load the script tag; it is versioned and cached by the CDN.<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
Your public site key, site_…. Safe to put in page source.
Called when the visitor has verified.
The proof token. Send it to your server.
Unix time in seconds when the token expires, one hour after it was issued.
Only at a gate: this device had entered before and gets its same entry back.
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.
Called with an Error when the widget can't start or the check fails. It may carry a code: see Errors.
"auto" follows the visitor's system setting.
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.
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.
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.
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;
},
});
{
"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
Where to put the widget. Give it a min-height of 88 px to avoid a layout shift while it loads.
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
true if an unexpired proof is stored.
Unix time in seconds. Only when verified is true.
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.
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].
| code | Meaning | Fix |
|---|---|---|
| invalid_key | The site key doesn't exist. | Check siteKey; it may have been deleted. |
| origin_not_allowed | The page's origin isn't in the key's allowed origins. | Add it in the dashboard. |
| unknown_gate | No gate with that slug on this key. | Check the slug, and that the gate is on the key in siteKey, in Gates. |
| bad_gate | gate 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.
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
Authorization: Bearer sk_your_secret_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
The token from onVerified.
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
Whether to let the request through.
"device-entry" for gate tokens, "personhood" for all others.
Why the token isn't valid, in words.
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.
Gate tokens: the gate's slug.
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>.
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 };
res = requests.post(
"https://verena.se/v1/verify",
headers={"Authorization": f"Bearer {VERENA_SECRET_KEY}"},
json={"token": token},
timeout=10,
)
# Not 200, a network error or a timeout: not verified
ok = res.status_code == 200
result = res.json() if ok else {"valid": False}
curl https://verena.se/v1/verify \
-H "Authorization: Bearer sk_your_secret_key" \
-H "Content-Type: application/json" \
-d '{ "token": "3f9a2c…" }'
{
"valid": true,
"scope": "personhood"
}
{
"valid": true,
"scope": "device-entry",
"gate": "spring-sale",
"entry": "9b2e41c07d5fa3e8c16b0f42d97a5e13",
"repeat": false
}
{
"valid": false,
"code": "token_invalid",
"error": "Token is invalid or expired."
}
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.
| Property | Behaviour |
|---|---|
| Lifetime | One hour from issue (expiresAt). |
| Scope | Valid only with the secret key of the site key it was issued for. |
| Reuse | A 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 use | Gate tokens are spent by the first successful /v1/verify. Verifying again returns valid: false. |
| Revocation | None. Tokens are short-lived; let them expire. |
/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.
| Request | Does |
|---|---|
GET /v1/keys | Your keys: label, allowed origins, how many gates, when last used. |
POST /v1/keys | Create 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/:id | Change label or allowed_origins (comma-separated; example.com is saved as https://example.com). |
DELETE /v1/keys/:id | Delete a key. A key with gates can't be deleted: remove them first. |
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.
| Request | Does |
|---|---|
GET /v1/gates | The keys and their gates, with counts. With a secret key: that key only. |
POST /v1/gates | Create a gate: { "slug", "name", "keyId"?, "maxUses"? }. maxUses is the entries per device, 1 to 100 (default 1). Returns { "id" }. |
GET /v1/gates/:id | One gate: counts by day, week and month, by phone and over time, and how its checks went. |
GET /v1/gates/:id/entries | The 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/:entry | One entry by the entry id from /v1/verify, with its gate. |
PATCH /v1/gates/:id | Change name or maxUses. The slug can't change. |
PUT /v1/gates/:id/image | Set the image shown as people enter. The body is the file: PNG, JPEG or WebP, at most 512 KB. |
DELETE /v1/gates/:id/image | Remove the image. |
POST /v1/gates/:id/clear | Clear its entries: every device can enter again. |
DELETE /v1/gates/:id | Remove the gate. Pages that name it stop working at once. |
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.
| Entry | Allows | Doesn't allow |
|---|---|---|
| https://example.com | https://example.com, and the same host on another port | https://www.example.com, http://example.com |
| http://localhost:3000 | Your dev server on that port | Other 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.comtoo if you use it. - Anywhere else, the widget doesn't start and
onErrorgetsorigin_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 ashttp://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.
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.
The visitor leaves your page
For example, the App Clip opens over Safari, or an in-app browser hands over to the regular browser.
They verify
Verena issues the token for the session.
Back to
returnUrlThe visitor lands on
returnUrl(by default the page they came from), possibly in a new tab, with averena_sessionquery parameter.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
returnUrlpage, 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
returnedistrue: they come back in a new tab that starts empty. Save it inlocalStorageor on your server.localStoragestays 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
returnUrlat a route that mounts the widget, and don't let your router drop theverena_sessionparameter 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.
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).
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.
Pass the slug
Give
gatetoVerena.initand to/v1/verify. Store theentryfrom the response, and look it up in your own records to give a returning device its place back;repeat: truesays the device got an earlier entry back.
- Gates were called events until December 2026. The old names (
event,/v1/events, codes such asunknown_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/verifyspends the token before your app saves anything. If the save then fails, the visitor needs a new token, and that check reportsrepeat: truethough you never recorded the sign-up. So look theentryup in your own records: none there means accept the retry, one there means they already signed up. Put a unique index onentry, so two retries at once save one row. - Timeouts and errors. A timeout, a network error or a non-200 from
/v1/verifyis never a pass. Answer503and 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/verifyanswers bycode. It shows by platform and over time, never which device.
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");
// 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).
| Who | Sees | Doesn't see |
|---|---|---|
| The relay | The visitor's IP address | The content: it's encrypted for Verena |
| Verena | The content | The visitor's IP address, only the relay's |
| Your site | The token | Anything 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-srcandframe-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.seand loads the widget from there. Under a CSP that doesn't allow that host inconnect-srcandframe-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=0to 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 ashttp://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 returnsvalid: false. Remember that tokens expire after an hour. - See the live demos at verena.se/presence.
Questions or something missing here? info@verena.se