The mock notify service stands in for the hosted notify service in tests. It verifies the same signed CBOR requests the app sends, keeps a per account inbox in memory, and sends no email and makes no remote writes.
File and mounting
One file: tools/mock-notify/routes.ts. It exports handle(req), which returns a Response, a promise of one, or null when the path is not its own. The local test server mounts it on 127.0.0.1:4790; everything lives under /activity/. Bun tests call handle in process or serve it on port 0.
Endpoints
Method and path | Purpose |
|---|---|
|
|
| The signed request endpoint, see below |
| Body |
| Body |
| Body |
| Marks every configured email verified, as if the person clicked the link |
other |
|
What a signed request must satisfy
request(req) (routes.ts L58-L123) decodes the CBOR body and checks, in order:
Check | Failure |
|---|---|
Body is CBOR | 400 |
Only the fields | 400 |
| 400 |
| 401 |
| 401 |
| 400 |
| 400 |
The signature convention differs from the agents protocol, which signs with a zero filled sig field. A Bun test sends an agents style signature and expects 401 (activity.test.ts L112-L130); it also checks that exactly 20000 ms passes and 20001 ms fails. See Crypto: signed envelopes.
Mutations handled: mark-event-read, mark-all-read, set-config (email is trimmed and lower cased; a new address resets verification), resend-config-verification (only when expired), remove-config. Anything else is 400 Unknown mutation. Every successful request returns the full snapshot.
Initial inbox
The first request from an account creates its state (routes.ts L15-L56): three NewDocument events on the hyper.media home account, today (1 hour ago, Ana, reply), earlier (2 hours ago, Ben, mention) and yesterday (24 hours ago, Mina, site-doc-update), with earlier already read. That is why tests expect "2 unread".
Scenarios
Set through /activity/reset:
Scenario | Effect |
|---|---|
| The three events, no email |
| No notifications |
| Email |
| Same, with |
| Same, with |
| Every signed request answers 503 |
| The snapshot's |
| The |
The POST counter
posts counts signed POSTs since the last reset. The Contract test "a minute on the inbox signs one request" uses /activity/posts with {"min":1,"max":1} and {"max":0} to bound how often the app signs: one refresh per minute on the tab, none while another tab is shown (activity.test.contract L224-L277).
Who uses it
activity.test.ts: serves handle on a random port and resets before each test.
routes.test.ts: config discovery and CORS.
activity.test.contract: all scenarios except thread, pending, verified and wrong-account.
open-site-activity.test.contract: the thread scenario, proving a thread opened from Activity is fetched from and replied to on the configured server.
me.test.contract: the saved servers test relies on /hm/api/config.
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime