Approval relay host configuration
The push service setting
A host sends native push alerts through the built-in service,
https://push.ox.oxstack.eu, unless you choose otherwise. That service is the
stateless push worker (mobile-push-worker):
it keeps no registration and no record of a host or a phone. A host contacts
it only for a phone that turned alerts on, and then sends that phone's routing
token, an opaque reference and the kind of alert, never a title or a prompt.
Older releases and hosts configured with https://push.0scar.no reach the
same worker directly. Both names support APNs and approval actions. An
upgrade preserves an explicitly configured origin and its credential.
Change it from the host:
ox host push # show the setting
ox host push off # send no native alerts
ox host push on
ox host push service https://push.example # another stateless worker
ox host push service default # the built-in service again
A paired device can read and change the same setting with the signed settings
request {"action":"push_service"}, adding "edit": {"before": …, "after": …}
to change it. The reply is {"enabled": bool, "origin": "https://…"}, with
"credential": true when the file gives that origin a host credential. A
credential itself is never returned, and an edit that names another origin
drops it. A change takes effect without a restart.
The setting is stored in an optional file, mobile-push-relay.json, in the
existing OX host state directory. With no file the setting is the default: on,
with the built-in service. The rest of this document describes the file. ox host status prints the state
directory, usually $XDG_STATE_HOME/ox/host on Linux, falling back to
~/.local/state/ox/host when XDG_STATE_HOME is unset. On macOS the fallback
is ~/Library/Application Support/ox/host.
The file must be a regular file owned by your user with no group or other
permissions. It must not be a symlink and must be at most 4096 bytes. For a
self-operated relay (mobile-push-relay) it
has exactly two string fields:
{
"origin": "https://relay.example",
"credential": "<43-character base64url value>"
}
originis a canonical HTTPS origin: no path, query, fragment, userinfo or trailing slash.credentialis the relay's 32-byte bearer value, written as 43 base64url characters.
For the stateless push worker
(mobile-push-worker) it has the origin
alone:
{
"origin": "https://push.example"
}
The worker keeps no registration and gives a host no credential. With this
form the host settles an enrollment or a revocation in its own state file
without a request, and sends the phone's provider, routing token and pairing
hint with each alert to POST /v2/push, in place of the installation id. The
rest of this document applies to both forms unless it names the relay's
registration.
Either form may add "enabled": false, which turns native push off and keeps
the origin and credential for turning it on again. A file with only
{"enabled": false} turns off the built-in service.
Create the file with mode 0600, for example:
chmod 600 "$STATE_DIR/mobile-push-relay.json"
The host does not read either value from the environment. It does not follow a symlink, refuses a FIFO without blocking, and reads no more than 4096 bytes. A missing file is the default setting above. The loader returns a fixed diagnostic for a malformed or unsafe file and keeps the file contents private.
Native push enrollment state
The enrollment store keeps mobile-push-enrollment.json in the same state directory. It
holds one enrollment per already-paired device: the relay installation id, the
push provider, the routing token while the registration is live, an operation
generation and any pending registration or revocation. The file is mode 0600
in the private state directory and at most 256 KiB.
New enrollments default to 32 entries so a relay outage cannot fill the state
file with pending work and prevent existing devices from rotating or revoking.
Set OX_HOST_PUSH_MAX_ENROLLMENTS in the host process environment and restart
to change that limit. Set it to 0 to disable the count limit. The file-size
bound still applies. Lowering the count keeps existing enrollments readable
and revocable.
A registration or rotation is pending, and no delivery is enabled, until the relay confirms it. A local revocation takes effect immediately, removes the routing token and keeps a tombstone until the relay confirms the revocation; that confirmation removes the tombstone and frees its slot, so a later enrollment gets a fresh installation id. A confirmation must match both the installation id and the generation, and the delivery integration uses one operation at a time per installation.
The file contains provider routing tokens. Protect the state directory and its backups as credentials. Diagnostics never include a token or the file path.
Approval and question alerts
While push is on and at least one phone has an enrollment record, the host's notification watcher runs even when the browser has no push subscription. It looks for the first enrollment, and for a change to the setting made outside the host process, every 30 seconds. Each new live approval or question ask is turned into one alert per durable, active enrollment whose device is still a live paired phone. For a credentialed relay, the alert carries the installation id, an opaque reference derived from the exact ask token and a short expiry (two minutes, or the relay client's shorter bound). A title, prompt, path, thread name or provider routing token stays out of the credentialed relay’s enqueue body. Its bearer credential authenticates the HTTP request.
Each alert follows the phone's notification preferences, including the master switch and the approval and question choices. A phone that turned approvals off gets no approval alert.
With the stateless worker the host also sends a finished or failed session,
and a reached goal in place of the finished alert for a phone that asked for
goal alerts. The body names the kind (question, finished, goal_reached,
failed; an approval leaves it out) and the worker shows its own fixed words
for it. A session alert has a random reference and lives up to ten minutes. The host keeps a bounded, in-memory mapping to the recipient, route and thread for a signed lookup. The current APNs worker includes a reference in the phone payload only for an approval or question. A relay with a credential has copy for approvals only and is sent
asks only, unless the enrollment is FCM and the phone opted in as described
next.
A relay with a credential carries a typed finished, failed or goal alert only
for an active, confirmed FCM enrollment whose phone set the explicit
fcm_session_alerts opt-in. The host asks the relay for
GET /v1/capabilities before the typed enqueue and sends nothing when the
deployment does not advertise it; it never falls back to the ordinary
approval body. A durable APNs enrollment, a phone without the opt-in, and an
unsupported relay get no session alert.
The host reads the enrollment again immediately before each enqueue, so a
rotation, local revocation or removed pairing in between stops that send. For an approval or question, the
reference is deterministic, so a repeated (installation, reference) is the
relay's existing delivery rather than a second alert. There are no retries: an
error, a full bounded queue or an answered ask drops that alert. A reconnect
cancels the asks it can no longer trust and does not replay a snapshot.
When the setting changes, an open notification feed stops enqueueing with its previous configuration and sends the next alert with the current one; no restart is needed. A stateless worker keeps no registration, so nothing else has to move. When moving to or from a relay with a credential, which does keep registrations, disable enrollment on the phone while the old relay is available and opt in again afterwards so the new one can register it.
The host sends the optional registrationVersion with the durable generation
it read immediately before the enqueue. A relay that understands it checks the
ordered host generation atomically and refuses an alert for a rotated or
revoked binding; an older relay ignores the extra field. The relay still
checks the registration generation and the event expiry at dispatch, and a
revocation invalidates that registration's queued deliveries. The remaining
window is a local revocation committed after the host's final read but before
the relay receives its revocation: the short expiry bounds how long that one
alert can be dispatched.
Paired-phone settings
A paired phone uses the existing signed settings request to read or change its own native push enrollment. The caller is the authenticated paired device; the request carries no device id, and an expired, removed, desktop or worker-host pairing is refused. The existing requests keep their one-field reply:
{"status": "not_configured"}
| Request | Effect |
|---|---|
{"action":"native_push_status"} |
Read the current state. |
{"action":"native_push_status","routing_hint_version":1} |
Read the current state and this phone's opaque routing hint when its enrollment is enabled. |
{"action":"native_push_enable","provider":"apns","routing_token":"..."} |
Record this phone's opt-in. provider is apns or fcm; the token is the provider routing token. |
{"action":"native_push_disable"} |
Make this phone ineligible at once and revoke it at the relay. |
{"action":"native_fcm_session_alerts"} |
Read whether this phone can enable typed session alerts and its stored opt-in. |
{"action":"native_fcm_session_alerts","enabled":true} |
Enable the per-phone typed session-alert opt-in. Refused while the host cannot confirm delivery. |
{"action":"native_fcm_session_alerts","enabled":false} |
Disable the per-phone typed session-alert opt-in, even when the relay is unreachable. |
status is one of:
not_configured— no usable relay configuration, or the host cannot read its enrollment state. The rest of the settings service is unaffected.disabled— no enrollment, or a local revocation is still waiting for the relay.pending— a first registration or a rotation is waiting for the relay.enabled— the relay confirmed the current provider and routing token.
A reply never contains a routing token, an installation id, a generation or a diagnostic. Relay work happens in the background; a timeout is not success and only the relay's answer for the exact operation generation settles the record. A local revocation is written before the relay is told, so delivery stops even when the relay cannot be reached.
An enabled version-1 status reply adds the string field routing_hint.
Other statuses omit it. Hosts that lack version-1 support reject the extended
request. The client can retry the original status request to read enrollment
state from such hosts.
The version-1 hint is unpadded base64url of SHA-256 over the UTF-8 bytes of
ox.push_pairing_hint.v1, one zero byte, and the ASCII bytes of the installation
ID as written on the host-to-relay wire. The ID text is hashed directly. For
the installation ID AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, the hint is
AotRyyBJqaA9SJpj5QmKEth9c6Q0fAgK1whvlSmTBmQ. The hint survives a confirmed
provider token rotation and changes when a completed revocation is followed
by a new enrollment. The phone can use it as an enrollment selector. Approval
lookup and decisions still use the authenticated pairing and the live ask.
The existing signed push_preferences request keeps the per-event choices and
adds one opt-in for typed session alerts on a durable FCM relay. A paired
phone sends {"action":"push_preferences","change":{"event":"fcm_session_alerts","value":true}};
the value defaults to false, is stored with that phone's other push
preferences, and only a phone pairing may write it. The finished, failed and
goal choices still decide which typed alert that phone gets, and the master
switch still silences every kind.
A phone that offers the session-alert control uses the dedicated
native_fcm_session_alerts request instead of reading that preference alone.
Its reply is exactly {"support": bool, "enabled": bool}: enabled is the
stored per-phone opt-in, and support is whether this phone could enable it
right now. The host reports support only for a confirmed, current FCM
enrollment while the configured relay is a credentialed relay whose exact
GET /v1/capabilities answer affirms {"sessionAlerts":1}. It reuses the
send path's request, bearer credential, timeout and parser, and asks nothing
for a stateless worker. A negative, unreachable or otherwise unsupported
answer is false, and the phone hides the control; a manual check asks again.
An explicit enabled: false is a local opt-out: the host stores it before any
relay question, so it stands while the relay is unhealthy, and the reply still
reports the freshly checked support so a healthy relay keeps the control
visible and off. An enabled: true is refused with support: false and
leaves the stored value unchanged. Every reply reads the stored value after
the capability read, and every write rechecks that the caller is still a live
paired phone. Neither reply carries a provider identifier, relay origin or
diagnostic text.