[FEATURE]: push: allow configuring additional notification relays
Feature hasn't been suggested before.
- [x] I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Problem
The v2 push API from #66130 (/api/experimental/push, specs/v2/push.md) is well suited to mobile clients other than the official apps. The server already encrypts every message for the device, so a relay only carries ciphertext, and a client only needs a relay that can reach its own app.
But PushList.register accepts callback URLs on only the two OpenCode relays:
https://github.com/anomalyco/opencode/blob/c0f4b80323f7a146c893fa8a969bb14bce9929e3/packages/core/src/push/list.ts#L83-L96
A relay can only deliver to apps whose FCM and APNs credentials it holds, so any other client is turned away, even when a user deliberately pairs their own server with it. Today the only option for those clients is a server plugin, which duplicates logic core already has: when to notify, levels and bells, and clearing stale notifications.
I maintain an open-source mobile client for opencode, so this blocks us directly. We already run a relay that implements the same /v2/notify/:token contract. The only thing missing is the server allowing its origin.
It also makes local development harder: a dev server can't be pointed at a local fake relay.
Proposal
Keep the built-in relays and add an opt-in list from config, for example:
// opencode.json
{ "push": { "relays": ["https://relay.example.com"] } }
or an env var such as OPENCODE_PUSH_RELAYS (comma-separated origins).
- Entries must be
httpsorigins, normalised withURL.parse(...).origin.http://localhost/http://127.0.0.1could be allowed for development only. - Validation is unchanged otherwise:
/v2/notify/<base64url>, no userinfo, query or fragment, and the href round-trips. - No change to the relay contract or the message format. A third-party relay implements the same
POST /v2/notify/:tokenwith{ box, silent? }and answers 404 or 410 for dead callbacks.
Security
Unchanged by default. Payloads stay sealed per device, so an added relay only sees ciphertext and timing. Only the person who runs the server can add a relay.
How this differs from #58428
That issue asked the server to push directly to browser push services, a new delivery path, and it was closed as not planned. This one adds no delivery path. It reuses the relay protocol from #66130 and only lets the server owner allow another relay origin.
I'm happy to open a PR (list.ts, the config schema, and a test in push-list.test.ts) if this direction works for you.
Thanks for the detailed proposal, @ivanfenenko. You're asking for an opt-in setting (config or env var) that lets the server owner allow more relay origins for push callback URLs, alongside the built-in ones. That way third-party clients and local dev relays could use core's push support from #66130 without changing the relay contract.
Right now validURL in packages/core/src/push/list.ts only accepts the origins listed in relays ("the only origins a phone's callback URL may be on"). I didn't find any config or env setting that adds to that list. A plugin can't work around it either, because the check runs inside core's registration.
Related:
- #66130: the PR that added the push API you're building on
- #67460: open PR adding a plugin hook that can edit or drop phone notifications (it doesn't change where they're sent)
- #58428: the Web Push request you mentioned, closed
Maintainers will consider the direction. It's probably best to wait for their feedback before opening the PR you offered.