IWSN: "Połącz z IWSN" — a person of Intecion connects the site (contract 1.8.0)
- the state block on the e-mail tab (method IWSN): the button while the service offers the confirmation page
(connectAvailable) or before the site has enrolled; a click asks the site's server for the link
(POST /api/iapl/mail-relay/connect-link, admin only), which asks the service (POST /v1/connect, enrolling first),
checks that it begins with the service's own {base}/connect?, and hands it over without storing or logging it;
the browser opens it in a new tab with noopener noreferrer; the block asks /v1/status every 5 s for 10 min
- states: waiting for confirmation (button), waiting for approval (no page), connected, stopped; 503
connect-unavailable and 429 said in the admin's language; a load of the panel asks the service while the site waits
- dashboard alert for a waiting site (live); doctor mail-relay-connect (error) — replaces the pending warning and the
"not enrolled yet" note of mail-relay-state
- opt-out mail.relay.connectButton: false (no button, no route); building blocks requestRelayConnectLink,
isRelayConnectUrl, RELAY_CONNECT_LINK_PATH; the fake service implements /v1/connect, connectAvailable and
confirmConnect
- contract copy 1.8.0 (IWDL working tree, checksums match); docs, AGENT.md, setup / upgrade / debug skills, changelog
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
347e3bafa1
commit
2c0262367d
+36
-12
@@ -136,10 +136,28 @@ What the site needs for it:
|
||||
443, **without a redirect** — the service follows none. No basic auth, no firewall rule, no maintenance page in
|
||||
front of it. (Coolify: nothing to set; the route is part of Payload's API.)
|
||||
- **Outbound HTTPS** from the server to `webservices.intecion.net`.
|
||||
- **A site that passes the call-back is active at once.** Waiting for approval is the exception: the service
|
||||
holds a new site back when many new sites appear at once (more than a few a day from one address or domain, or
|
||||
more than its daily number in all), or when Intecion has set it to approve by hand. Mail is then not sent until
|
||||
Intecion approves the site; the same token works afterwards, and the panel says so.
|
||||
- **A new site is connected by a person of Intecion** (contract 1.8.0 §2.1, the service's `connect` policy). It
|
||||
enrols as before, then **waits** (`pending`): its mail is refused with `site-pending` (status `relay-pending`), not
|
||||
sent and not kept. On Site integrations → E-mail sending, with "IWSN (built-in)" as the method, an administrator
|
||||
presses **"Połącz z IWSN"** ("Connect to IWSN"). The site's **server** asks the service for a link
|
||||
(`POST /v1/connect`) and the panel opens it **in a new tab** (`noopener noreferrer`). A person of Intecion signs
|
||||
in there with an `@intecion.com` address (Cloudflare Access) and presses "Potwierdź". The panel asks the service
|
||||
every 5 seconds for at most 10 minutes and shows "Connected to IWSN" by itself; every load of the panel asks too
|
||||
while the site waits. Mail sent after that leaves; mail refused before it is not sent again.
|
||||
- The link is valid 15 minutes, for one confirmation; each press makes a new one. It is opened only when it begins
|
||||
with the service's own `{base}/connect?` (the plugin checks it on the server and in the browser), and it is
|
||||
never stored, logged or fetched by the server.
|
||||
- What the block says: **"Waiting for confirmation"** with the button (the service offers the page:
|
||||
`connectAvailable`); **"waiting for approval"** with no button (no confirmation page — an operator confirms the
|
||||
site); **"Connected to IWSN"**; **stopped** (suspended). A site that has not enrolled yet shows the button too:
|
||||
pressing it enrols first.
|
||||
- When the service has no confirmation page right now (`503 connect-unavailable`) the panel says "ask your
|
||||
administrator to have the site confirmed"; more than 10 links an hour (`429`) says when to try again.
|
||||
- The dashboard alert shows a waiting site; `iapl-doctor --deep` reports it as an **error** (`mail-relay-connect`).
|
||||
- No token or paste field is involved. Sites on SMTP or Microsoft Graph see nothing of this.
|
||||
- **Opt-out:** `mail: { relay: { connectButton: false } }` — no button and no route; the site is then confirmed by
|
||||
an operator, or by the project's own button with `requestRelayConnectLink(payload)` (open the answered
|
||||
`connectUrl` in a new tab; `isRelayConnectUrl(url, base)` checks it).
|
||||
|
||||
A site on `localhost`, on a private address or without `serverURL` is refused **by the plugin itself**, before any
|
||||
call leaves the server — development machines do not contact the service. To test mail locally use SMTP (a local
|
||||
@@ -392,18 +410,19 @@ await runWithMailKind('account', () => sendWelcomeMails(payload, user))
|
||||
|
||||
Site integrations → E-mail sending starts with "How e-mails are sent" (component `MailRelayStatus` from `/admin`,
|
||||
rendered by the tab's status banner — **no import-map entry of its own, so nothing to regenerate**): the
|
||||
transport in effect; for the mail service the state (connected, waiting for approval, stopped, not connected and
|
||||
why), the address mail leaves from, where replies go, what is left of the hour and the day, and a sender name the
|
||||
transport in effect; for the mail service the state (connected, waiting for confirmation — with "Połącz z IWSN" —,
|
||||
waiting for approval, stopped, not connected and why), the address mail leaves from, where replies go, what is left of the hour and the day, and a sender name the
|
||||
service replaced. Buttons: **Check now**, **Connect again**, **Disconnect** — and **Enter an access key** only
|
||||
with `mail.relay.accessKeyField: true` ("The token" above).
|
||||
|
||||
Routes (all three need the `admin` role: not logged in → 401, other role → 403; none ever answers with a token):
|
||||
Routes (all four need the `admin` role: not logged in → 401, other role → 403; none ever answers with a token):
|
||||
|
||||
| Route | What |
|
||||
|---|---|
|
||||
| `GET /api/iapl/mail-relay/status` | the transport and the stored state; `?refresh=1` asks the service |
|
||||
| `POST /api/iapl/mail-relay/connect` | enrol now; with `{ token }` store a token issued by hand — only with `accessKeyField: true`, otherwise `403` |
|
||||
| `POST /api/iapl/mail-relay/disconnect` | give the token up |
|
||||
| `POST /api/iapl/mail-relay/connect-link` | "Połącz z IWSN": asks the service for the confirmation link (`POST /v1/connect`, enrolling first when there is no token) and answers it as `connectUrl` + `expiresAt`, `Cache-Control: no-store`; nothing is stored. Absent with `connectButton: false` (`RELAY_CONNECT_LINK_PATH`) |
|
||||
| `POST /api/iapl/mail-relay/confirm` | **public** — the service's call-back. `404` and no change unless the site itself started an enrolment in the last 5 minutes; **refused** calls are rate-limited (10 a minute per address, `mail.relay.confirmRateLimit`) — a call that carries the nonce is never turned away by the limit, so junk from the same address cannot keep the site from enrolling |
|
||||
|
||||
These are the first routes under `/api/iapl/`; the others stay under `/api/ipal/` until 2.0. The confirm path is
|
||||
@@ -419,7 +438,7 @@ the service), each with a text in the editor's language:
|
||||
|
||||
| Code | Meaning | What to do |
|
||||
|---|---|---|
|
||||
| `relay-pending` | enrolled, but held for approval by Intecion — the rule while the service runs with enrolment "pending" (from its launch until Intecion switches to open enrolment), every new site waits for approval; after that the exception (many new sites at once, or approval by hand) | Intecion approves the host; nothing to do on the site |
|
||||
| `relay-pending` | enrolled, waiting for confirmation by a person of Intecion (contract 1.8.0) | "Połącz z IWSN" in the panel and the confirmation on the page that opens; without the button (no confirmation page), Intecion confirms the host |
|
||||
| `relay-suspended` | stopped by Intecion | contact Intecion; SMTP in the panel sends meanwhile |
|
||||
| `relay-refused` | the site could not enrol; or a token issued by hand stopped working (new server address, token no longer valid) | "When the site cannot be confirmed" below; hand-issued: ask Intecion for the address to be added or for a new token |
|
||||
| `relay-disconnected` | an admin pressed "Disconnect" | "Connect again", or fill in SMTP |
|
||||
@@ -464,6 +483,7 @@ message); "Connect again" asks at once. Other causes: `host-not-allowed` (not a
|
||||
| `otherHosts` | `'auto'` | a database that holds another host's connection. `'auto'`: a public site enrols by itself (launch, a domain move); a non-public one (`IAPL_NOINDEX=1` or `developmentHosts`) neither enrols nor sends until "Connect again". A list = those hosts are this site's own. `'wait'` = a public site without a connection of its own waits too. `'enrol'` = no rule |
|
||||
| `developmentHosts` | the plugin's list: `iapl({ developmentHosts })`, default `['*.dev.netscale.pl']` (`pluginDevelopmentHosts(payload)`) | host patterns (`*` = any characters) of development, staging and preview addresses, for the mail service alone: a site on such a host is non-public for `otherHosts`, like one with `IAPL_NOINDEX=1`, with no environment variable (`siteIsNonPublic`, `siteNonPublicSignal`, `matchDevelopmentHost`, `isDevelopmentHost`). `[]` = none |
|
||||
| `enrol` | `'auto'` | `'manual'`: only "Connect again" or `enrolRelay()` enrols. `false`: never (the token comes from `token` or `setRelayToken`) |
|
||||
| `connectButton` | `true` | `false`: no "Połącz z IWSN" in the state block and no `connect-link` route; the site is confirmed by an operator or by the project's own code (`requestRelayConnectLink`) |
|
||||
| `accessKeyField` | `false` | `true` shows "Enter an access key" in the state block and lets its route store a hand-issued token an admin pastes |
|
||||
| `token` | — | a token from elsewhere (`string` or a function): the stored token is not used and the site does not enrol |
|
||||
| `senderName` | panel, then site name | a fixed name, or a function |
|
||||
@@ -516,7 +536,9 @@ await payload.sendEmail({ to: '[email protected]', subject: 'Hi', html: '<p>Hi</p>'
|
||||
expect(relay.outbox[0]).toMatchObject({ kind: 'system', to: ['[email protected]'] })
|
||||
```
|
||||
|
||||
- `allow` / `relay.allow(host)`: hosts that are active at once; others wait for approval. `relay.setSite(host, state)`,
|
||||
- `allow` / `relay.allow(host)`: hosts that are active at once; others wait (`pending`). `connect: 'unavailable'` makes
|
||||
`/v1/connect` answer `503 connect-unavailable`; `relay.confirmConnect(connectUrl)` stands in for the person who
|
||||
confirms a link (true when it was the site's current one, not expired). `relay.setSite(host, state)`,
|
||||
`relay.issueToken(host)`, `relay.backend = 'failure'`, `relay.intercept`, `relay.limits`, `relay.clientAddress`
|
||||
arrange what a test needs; `relay.listen(port)` serves it over HTTP for a site in another process
|
||||
(`allowLocalHosts: true` lets it call back `http://localhost:<port>`).
|
||||
@@ -647,7 +669,8 @@ Works on any `text` field. After wiring it in a project you may need
|
||||
To the mail service (when the owner says so):
|
||||
|
||||
1. Upgrade; check that `serverURL` is the site's public address.
|
||||
2. Tell Intecion the host: while the service runs with enrolment "pending" (from its launch until Intecion switches to open enrolment), every new site waits for approval; the panel says so. Under open enrolment the site is active as soon as it enrols.
|
||||
2. After the first e-mail the site waits for confirmation: press "Połącz z IWSN" in Site integrations → E-mail
|
||||
sending and have a person of Intecion confirm it on the page that opens (keep Graph until then).
|
||||
3. Site integrations → E-mail sending → "Sending method": choose **IWSN (built-in)** and save. Then remove the four
|
||||
`GRAPH_*` variables in Coolify and redeploy.
|
||||
4. Site integrations → E-mail sending → send a test e-mail: the answer says "through IWSN".
|
||||
@@ -829,8 +852,9 @@ send (e.g. **Send test e-mail**) the current one appears.
|
||||
|
||||
## Doctor
|
||||
|
||||
`iapl-doctor` ([doctor.md](./doctor.md)): `mail-transport` (nothing set up; sending is failing), `mail-relay-state`
|
||||
(waiting for approval, stopped, refused, disconnected, a replaced sender name), `mail-reply-address`,
|
||||
`iapl-doctor` ([doctor.md](./doctor.md)): `mail-transport` (nothing set up; sending is failing), `mail-relay-connect`
|
||||
(error: the method is IWSN and the site is not connected or not confirmed), `mail-relay-state` (stopped, refused,
|
||||
disconnected, a held copy, a replaced sender name), `mail-reply-address`,
|
||||
`mail-graph-deprecated`, `mail-relay-route` (trailing slashes, another API route, a redirect or a block in front of
|
||||
the confirm route on the live site).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user