Mail relay: contract 1.6.0, the token tied to its host, IWSN in the panel
- contracts/mail-relay refreshed from IWDL 83af8c6 (1.6.0) - an answer that is not the service's JSON is 'not confirmed' unless its status is 400 to 499 - a site with a token issued by hand does not enrol to heal: it stops and says what to ask Intecion for - a store made on another host (a database copied to staging) is not used: the copy enrols as itself, nothing is revoked - the panel calls the service IWSN (RELAY_SHORT_NAME); docs, logs and the doctor keep the full name Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
7d766b6d58
commit
0ee74ab2a4
@@ -1,6 +1,22 @@
|
||||
# Changelog of the wire contract
|
||||
|
||||
## 1.5.0 — 2026-11-25 (not released; no tag yet)
|
||||
## 1.6.0 — 2026-11-25 (not released; no tag yet)
|
||||
|
||||
From the first client built against the contract (IAPL's). **The service did not change**; these are the
|
||||
contract's words. What a client built against 1.5.0 has to change is marked.
|
||||
|
||||
- **An answer that is not the service's JSON** is no longer "like `503 unavailable`" for the report: with a
|
||||
status from 400 to 499 it is *not sent*, with any other status (200 included) *not confirmed*.
|
||||
**Client: change the report for that case.** Retrying it is as before.
|
||||
- **A client that cannot keep key and bytes** (§1): no retry by itself after the report; a repeat by a person
|
||||
is a new message; keys derived from the message's record are described, and for such a key
|
||||
`idempotency-conflict` means "already handled". **Client: nothing must change; derived keys are an option.**
|
||||
- **A site with a hand-issued token** does not enrol on `reverify` / `invalid-token`; it reports
|
||||
`relay-refused` and what to ask Intecion for. **Client: nothing, if it already does this.**
|
||||
- **`Origin` / `Sec-Fetch-Site`:** a client sends neither; said in §1. **Client: nothing for Node.**
|
||||
- A stand-in need not reproduce the service's lists; said in §10.
|
||||
|
||||
## 1.5.0 — 2026-11-25 (never released)
|
||||
|
||||
After the third review.
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
8573bc968031c595b4e06f6694dd50e1d8e813255023b0397922352dcbc0a758 README.md
|
||||
fc5bd405549ceffe38e47de8e30ce4041556559fd65fb7aa4097c26fb494e9e5 CHANGELOG.md
|
||||
acb57a7135b2d7d6e665f67f056e21353023b93835f54def1ae523bf76f1bfb3 VERSION
|
||||
a5cc857363323400a6d24b45804c8fd964392cd0e61e99a8b120b354ac803e33 README.md
|
||||
05d026ddc45ee9824534ce13f5b8f14bd1475688fe98949e3297f90548e3abb0 CHANGELOG.md
|
||||
cb1d9a30bc4ab8a397f39b7d786bb82aca0b816077eefc35d7c822017d75f6a5 VERSION
|
||||
275ee643112eac77430dba9ea3f93c8f53dc1676b8d56ba95a25dd3f35a8746f schema.json
|
||||
be56a59e13474a8184576fef90cc01145cc3233886d4147e2ac2b867921fba1d runner.mjs
|
||||
913d3776b27076bf1d89639ef903f80c1c1b9bcd702851e9913def2588d73d83 runner.mjs
|
||||
7c46860adee597e570832c72bcdb418752a20b9f7d1b2d7a656ed065f9632b2a checksums.mjs
|
||||
df6015faf02a7cf7e9b5816b9e22b2e82968678ddd72a61c1f9665a8c0897ddf examples/callback-confirm-wordpress.json
|
||||
f5018ca4fb7d25794ee92168d715aaf47feeba3d907c0550651b16c10a691ceb examples/callback-confirm.json
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Intecion Notifications Webservice — wire contract
|
||||
|
||||
Version: see [`VERSION`](VERSION) (this text describes **1.5.0**). Path prefix of this major version: `/v1`.
|
||||
Version: see [`VERSION`](VERSION) (this text describes **1.6.0**). Path prefix of this major version: `/v1`.
|
||||
|
||||
This is the whole agreement between the Intecion Notifications Webservice ("the service" below) and a client (the mail transport built into a
|
||||
site's plugin). It names no product: nothing here says Payload, WordPress, IAPL or IAWL except the values of
|
||||
@@ -24,12 +24,19 @@ the `product` field. A client written from this document, in any language, works
|
||||
- HTTPS only. Bodies are JSON in UTF-8. A request with a body carries `Content-Type: application/json`.
|
||||
- **The service is for servers, not browsers.** It sends no CORS header, and it refuses any request that
|
||||
carries an `Origin` header or a `Sec-Fetch-Site` header other than `none` (`403 browser-not-allowed`).
|
||||
A client must send neither. A server runtime's `fetch` that adds them by itself has to be told not to, or the
|
||||
header removed, or the service will take the site for a browser. (`Sec-Fetch-Mode` and `Sec-Fetch-Dest` are
|
||||
not looked at: Node's `fetch` sends `sec-fetch-mode: cors` and passes.)
|
||||
- **Requests are closed:** an unknown field is refused with `400 invalid-request` and the field's name. A
|
||||
client cannot set `From`, `Sender`, `Return-Path` or any free header — there are no such fields.
|
||||
- **Answers are open:** a client ignores fields it does not know.
|
||||
- A client identifies itself with `User-Agent: <product>/<version>` (not checked, used for the log).
|
||||
- **An answer that is not JSON** — an error page of the network in front of the service, an empty body, a cut-off
|
||||
answer — is treated exactly like `503 unavailable` with `retryable: true`, whatever its status.
|
||||
- **An answer that is not the service's JSON** — an error page of the network in front of the service, an empty
|
||||
body, a cut-off answer — is no answer of the service. The client may retry it (as if `retryable` were true),
|
||||
and what it means for a message depends on the status alone:
|
||||
- status **400 to 499**: the request was turned away before the service handled it — **not sent**;
|
||||
- **any other status, `200` included**: the service may have handled the request and only its answer was
|
||||
lost — **not confirmed**, exactly like no answer at all (§1, "Retrying").
|
||||
|
||||
### Answers
|
||||
|
||||
@@ -100,9 +107,29 @@ What the client reports:
|
||||
|---|---|---|
|
||||
| `200` | was accepted | sent |
|
||||
| A refusal with `retryable: false` | was not sent | the status of that code |
|
||||
| `rate-limited`, `unavailable`, `enrolment-in-progress` | was not sent | `relay-unreachable` |
|
||||
| `rate-limited`, `unavailable`, `enrolment-in-progress` (as the service's own JSON), or an answer that is not the service's JSON with a status from 400 to 499 | was not sent | `relay-unreachable` |
|
||||
| `backend-failed`, `internal`, or a code the client does not know | **probably** not sent — the mail back end failed in a way it does not explain, and it does not say whether such a message can still go out | `relay-unreachable`, worded as "probably not sent". Like the next row: the same key and bytes if it is tried again |
|
||||
| **No answer** (time-out, connection lost), or `409 in-progress` | **may have been sent** — the service cannot say yet, or will never be able to | `relay-unreachable`, worded as "not confirmed", never as "not sent". If the client tries this message again later it uses the **same key and bytes**: within 24 hours of the first attempt that cannot produce a second mail — once the service has handed a message to the mail back end, its key either answers with the result or goes on answering `in-progress`; it is never sent again. A client never sends the message under a new key by itself |
|
||||
| **No answer** (time-out, connection lost), an answer that is not the service's JSON with any status outside 400–499, or `409 in-progress` | **may have been sent** — the service cannot say yet, or will never be able to | `relay-unreachable`, worded as "not confirmed", never as "not sent". If the client tries this message again later it uses the **same key and bytes**: within 24 hours of the first attempt that cannot produce a second mail — once the service has handed a message to the mail back end, its key either answers with the result or goes on answering `in-progress`; it is never sent again. A client never sends the message under a new key by itself |
|
||||
|
||||
**"The same key and bytes" — and a client that cannot keep them.** The promise that a message is not sent
|
||||
twice holds for as long as the client still has the message's key and its encoded bytes. What a client does
|
||||
depends on what it can keep:
|
||||
|
||||
- **Within one attempt to deliver a message** (the three tries above) every client keeps both in memory.
|
||||
- **A client with storage for unsent mail** keeps key and bytes with the message and may try again later.
|
||||
- **A client without such storage** does not try again by itself once it has reported. "Not confirmed" is then
|
||||
final for that message: the report says that the mail may or may not have gone out. If a person causes the
|
||||
mail again — submits the form again, presses "send again" — that is a **new message with a new key**, and
|
||||
when the first one did go out, the recipient gets it twice. The service cannot prevent that and a client
|
||||
need not; it should say "not confirmed" in a way that does not invite an immediate repeat.
|
||||
- **A key derived from the message's own record** narrows this without storing the mail: when the mail belongs
|
||||
to something the site stores anyway (a form submission, a password-reset request), the client may build the
|
||||
key from that record's id and the mail's role in it (for example the SHA-256 of both, in the key's
|
||||
alphabet). A second attempt for the same record — after a restart, from another process — then arrives under
|
||||
the same key, and the service answers it with the first result (`replayed`), with `in-progress`, or, when the
|
||||
bytes differ because the mail was built again, with `409 idempotency-conflict`. For a derived key the client
|
||||
treats **`idempotency-conflict` as "this record's mail was already handled"**, not as a bug: no second mail
|
||||
either way. A deliberate "send again" by a person uses a new key (the record's id and a counter).
|
||||
|
||||
## 2. Enrolment — `POST /v1/enrol`
|
||||
|
||||
@@ -194,6 +221,12 @@ Rules a client must know:
|
||||
itself after `401 reverify`; beyond the limit the address used longest ago is dropped and gets `reverify`
|
||||
again. A site whose requests leave from many changing addresses (serverless hosting, a pool of egress
|
||||
addresses) must have the limit raised by Intecion, or it will enrol in a loop.
|
||||
- **A site with a token issued by hand cannot heal by itself.** It holds such a token because it cannot be
|
||||
called back, so "enrol again" is not open to it. Its client does **not** enrol on `401 reverify` or
|
||||
`401 invalid-token`; it stops and reports `relay-refused`, with what the administrator has to ask Intecion
|
||||
for: after `reverify` (the site sends from a server address Intecion does not know yet — after a move, or
|
||||
from a second server) that the new address be added; after `invalid-token` a new token. A client knows that
|
||||
its token was issued by hand because it was pasted into it; the service's answer does not say so.
|
||||
- A site on `localhost` or behind a firewall cannot be called back. Intecion can issue a token by hand; the
|
||||
site stores it the same way.
|
||||
- Use the token only from the site's server. Never print it, never send it to a browser.
|
||||
@@ -317,7 +350,7 @@ not go out ([`StatusResponse`](schema.json)):
|
||||
|
||||
```json
|
||||
{ "ok": true, "state": "active", "host": "example.com", "product": "iapl",
|
||||
"service": { "name": "Intecion Notifications Webservice", "version": "1.0.0", "contract": "1.5.0" },
|
||||
"service": { "name": "Intecion Notifications Webservice", "version": "1.0.0", "contract": "1.6.0" },
|
||||
"sender": { "address": "[email protected]" },
|
||||
"limits": { "messagesPerHour": 30, "messagesPerDay": 200, "recipientsPerMessage": 10,
|
||||
"perRecipientPerDay": 10, "newRecipientsPerDay": 50,
|
||||
@@ -444,6 +477,12 @@ for (const example of examples) await runExample(example, driver) // throws on
|
||||
The service runs every example against the Worker under the local Workers runtime
|
||||
(`services/mail-relay/test/contract.test.ts`). A client's local stand-in for the service runs the same files.
|
||||
|
||||
**A stand-in is not the service.** The examples are chosen so that the rules stated in this document decide
|
||||
them (a sender name with an address in it; a file called `.exe`). The service's own lists — names that are
|
||||
never a client's, file types it does not carry — are not part of the contract, can change without a new
|
||||
version, and need not be reproduced: a stand-in approximates them, and a client must not rely on a name or a
|
||||
file type passing because its stand-in let it pass.
|
||||
|
||||
## 11. Using the contract in a client
|
||||
|
||||
Until a client lives in this repository it **copies** this folder (all of it, `CHECKSUMS` included) from a
|
||||
@@ -456,11 +495,14 @@ Checklist for a client:
|
||||
2. A confirm endpoint (public, rate-limited, `404` unless it holds the nonce, constant-time compare, single
|
||||
use, answers the confirmation as the only output, keeps the earlier token until the new one is accepted).
|
||||
3. A token store that is never readable from outside and never printed.
|
||||
4. Enrol on the first send without a token, after `invalid-token` and after `reverify`. Guard against two
|
||||
processes enrolling at once (`enrolment-in-progress`).
|
||||
4. Enrol on the first send without a token, after `invalid-token` and after `reverify` — unless the token was
|
||||
issued by hand: then stop and report (§2). Guard against two processes enrolling at once
|
||||
(`enrolment-in-progress`).
|
||||
5. One `Idempotency-Key` per message and one encoding of it, both kept across retries; at most three attempts,
|
||||
30 seconds each, ten seconds of waiting in all, only when `retryable`; an enrolment on the way does not
|
||||
count; "no answer" and `in-progress` are reported as not confirmed, never as not sent.
|
||||
count; "no answer", `in-progress` and an answer that is not the service's JSON (unless its status is 400 to
|
||||
499) are reported as not confirmed, never as not sent. No `Origin` or `Sec-Fetch-Site` header. Without
|
||||
storage for unsent mail: no retry after the report; consider keys derived from the record (§1).
|
||||
6. **Limit what a visitor can make the site send as `account` mail.** "Forgot password" for an address somebody
|
||||
types is a visitor's lever like a form: the service lets `account` mail use the whole hour and day and no
|
||||
limit per address, so thirty requests use up the site's hour. The client's own limiter (per address and per
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.5.0
|
||||
1.6.0
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// No dependency. Works in Node 20+ and in the Workers runtime (uses only WebCrypto, btoa and TextEncoder).
|
||||
// How to use it: README.md, "The examples and the runner".
|
||||
|
||||
export const CONTRACT_VERSION = '1.5.0'
|
||||
export const CONTRACT_VERSION = '1.6.0'
|
||||
|
||||
export class ContractError extends Error {
|
||||
constructor(exampleId, message) {
|
||||
|
||||
Reference in New Issue
Block a user