Hub client: licence, heartbeat, read-only mode, /health, install script

- Connect with a licence key (/setup last screen, Site settings -> Licence)
- hub-heartbeat job every 15 min: version, health, totals (income as a band)
- Licence tokens verified with the Hub's public key; states active / grace
  (banner for site admins only) / suspended / revoked (read-only) /
  unlicensed; Hub keys kept out of the generic settings endpoints
- /health; "update available" for admins; scripts/install.sh
- docs/hub-protocol.md shared with the events-hub repo
- Unit tests (hub.test.js); docs

The production Hub public key (backend/src/hub/publicKey.js) must be set
before this is released.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mt6TCv85T9VKRq3cV7rXq
This commit is contained in:
2026-10-26 12:25:52 +02:00
co-authored by Claude Opus 5.5
parent 0551226de5
commit eb2159fa33
30 changed files with 1419 additions and 6 deletions
+28
View File
@@ -7,6 +7,34 @@ and this project follows [Semantic Versioning](https://semver.org/).
## [Unreleased]
### Added
- **Hope Events Hub connection** (`docs/hub-protocol.md`). Each install connects to the Hub
(`events-hub.crosscode.co.za`) with a licence key:
- **Licence step in `/setup`** (on the last screen), and **Site settings → Licence** for existing
installs: connect, see the licence (licensed to, plan, end date, grace period), the last check-in,
and "Check now".
- A **heartbeat every 15 minutes** (`hub-heartbeat` job; `HUB_HEARTBEAT_ENABLED=false` to switch off):
version, health (database, background jobs, last backup, free disk, server errors, pending
migrations) and totals (users, events, registrations, tickets, check-ins, payment providers, income
as a range only). Never anyone's personal information.
- **Licences are checked on the site** with the Hub's public key, so a Hub outage never switches a
site off and a licence can't be faked by editing the database:
- **Grace period** (licence past its end date, default 14 days): everything works; **only site
admins** see "Licence needs renewing — X days left".
- **Suspended or revoked**: read-only — no new events, registrations, tickets, payments, waitlist
places, coupons or bundles. Tickets still scan; all data can still be viewed and exported;
refunds, cancellations and privacy requests still work.
- Not connected yet: works as before; admins see "Connect to the Hub".
- **Update available**: admins see when a newer version is out, with the command to run.
- **`/health`** — status, version, database, background jobs and last backup, for monitoring.
- **Install script** (`scripts/install.sh`): a fresh Ubuntu server to a running site in one command —
Node 20, PostgreSQL, PM2, nginx, HTTPS, configuration, migrations, build; then `/setup`.
### Changed
- The generic settings endpoints never read or write the Hub connection (install id, secret, licence).
## [1.40.0] - 2026-10-23
### Added