0013 Secure the email links, and run the daily email per tester¶
- Status: Proposed
- Date: 2026-12-05
Context¶
Phase 2 of the demo adds sign-up with double opt-in, an unsubscribe link in every email, and a daily run that emails each tester. ADR 0012 decided what's stored. Building it raised questions the plan didn't answer:
- Confirmation links. Security tools in mail apps and company networks open every link in an email to scan it. If opening the link confirmed the address, a scanner could confirm a sign-up that its owner never made, and double opt-in would prove nothing.
- Unsubscribe links. ADR 0012 planned to store a hash of each tester's unsubscribe token. But the daily GitHub Actions run builds the link for every email, and a hash can't be turned back into the token. The run would have to make a new token each day, and the links in older emails would stop working.
- Tokens in addresses. Cloudflare's logs record the address of every request. A token in the address would sit in the logs.
- Which countries to query. ADR 0008 chose one Himalayas country query for one profile. With testers, the run needs a rule that finds every job open to every tester.
- The maintainer. The single-user run emailed the address in the
WFHEAVEN_TO_EMAILsecret, and kept its memory in the Actions cache. Thetest emailmode still needs to know whom to email.
Decision¶
Links in emails¶
- Confirming takes a button click. The confirmation link opens
/confirm, which shows a Confirm my email button. Only the button's POST request makes the tester active. A scanner that opens the link changes nothing. - Confirmation tokens are random and stored as hashes. 32 random bytes; D1 holds only the SHA-256 hash, valid for 24 hours, and cleared once used. The "Send it again" link on the inbox page uses a second random token, also stored as a hash, so the page can ask for a new link without sending the address again.
- Unsubscribe links are signed, not stored. The link carries the
tester's random ID and an HMAC-SHA256 of it, made with a secret,
UNSUBSCRIBE_KEY, that the Worker and the daily run share. Nothing is stored for it. The run can build the link for every email, and the link in an old email keeps working. This replaces the stored unsubscribe hash in ADR 0012. - Unsubscribing takes one click. The
/leavepage deletes the data as it opens, as the landing page promises. A scanner that opens the link would unsubscribe the tester. That's the smaller risk: they can sign up again, while a missed unsubscribe would keep emailing someone who asked to stop. Mail apps' own button sends the one-click POST request of RFC 8058 to/leave. - Tokens go in the fragment. Links look like
/confirm#TOKENand/leave#ID.SIGNATURE. Browsers never send the part after#to the server, so it stays out of request logs. The page's script reads it and sends it in the body of a POST request. Only theList-Unsubscribeheader must use/leave?t=..., because mail apps send it as it is.
Sign-up answers¶
- The same answer for every address. Signing up with an address that's already active answers as if it worked and sends nothing. So the form can't be used to find out who is a tester.
- At most 20 testers, pending and active together (
MAX_TESTERS). Resend's free plan sends 100 emails a day; 20 testers leave room for confirmations.
The daily run¶
- Country queries: first, every tester gets one of their countries, picking each time the country most testers still without one share. Then the rest of their countries are added, most shared first, up to 10 queries a day. One tester's countries are all queried: for the maintainer, Hungary, Japan, and Taiwan, so ADR 0008's Taiwan query stays.
- The log never names a country. Testers' countries are personal data,
and the log of a public repository is public. The collector and the run
summary number the queries instead:
country query 1,2,3. - The maintainer is a tester with the
maintainerrole. A script,daily/add_tester.py, addsprofiles/gergely.yamlto D1 as an active tester. The daily run emails the maintainer like anyone else, and thetest emailmode emails only rows with that role. TheWFHEAVEN_TO_EMAILsecret and the Actions cache memory are retired.
Consequences¶
- One new secret,
UNSUBSCRIBE_KEY, must hold the same value in the Worker and in GitHub. If they differ, every unsubscribe link fails, and the/leavepage tells the tester to emailprivacy@wfheaven.app. Changing the key breaks the links in every email sent before. - Anyone who has an email's unsubscribe link can unsubscribe that tester. That's the purpose of the link; it can't do anything else.
- Confirming needs two clicks: the link, then the button.
- Up to 10 Himalayas country queries of up to 10 pages each: at most about 110 requests a day, so the run uses a free Himalayas API key.
- The run summary no longer shows which country a query was for. To see it, run the collector on your computer.
- ADR 0006 is superseded: the memory moves to D1, as keyed hashes per tester.