Hub 2.0 step 2: protocol v2 next to v1

- Accepts protocol 1 and 2 (utils/protocol.js); v2 bodies checked with the
  contracts' zod schemas (400 INVALID_REQUEST), v1 unchanged
- v2 register/heartbeat carry product (409 WRONG_PRODUCT on a mismatch),
  register stores the install's public key, stats stored per product
- v2 replies add linkedProducts (the church's other installs in use with a
  public key); v1 replies unchanged
- Licence tokens carry customerId and product
- Until releases per product, only Events installs get releases / "behind"
- Tests: every contract sample through the real routes, replies checked
  against the contract response schemas

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-04 15:37:02 +02:00
co-authored by Claude Opus 5.5
parent 56370419bb
commit ab6a0c6914
6 changed files with 378 additions and 19 deletions
+11 -1
View File
@@ -21,6 +21,15 @@ Hub 2.0.0, Cross Code Hub, in steps (`docs/HUB-2.0-PLAN.md`).
- `npm run check:hub2`: before deploying 2.0, lists customers with two open licences (the 2.0
migration stops on them, naming them). Run it against production first.
- `@crosscode/contracts` 1.0.0, committed as `backend/vendor/crosscode-contracts-1.0.0.tgz`.
- **Protocol v2** (step 2) next to v1 (`utils/protocol.js`; `/api/public-key` lists `[1, 2]`):
register and heartbeat say which `product` they are (it must match the licence, else
`409 WRONG_PRODUCT`), register sends the install's public key, the heartbeat's stats are per
product, and the replies add `linkedProducts`: the church's other installs in use that have a
public key (product, id, address, key; nothing else). v2 bodies are checked against the
contracts' schemas (`400 INVALID_REQUEST` says what's wrong); v1 requests and replies are exactly
as before. Tests put every contract sample through the routes and check the replies against the
contract.
- Licence tokens carry `customerId` and `product` (Cross Events 2.1 ignores them).
### Changed
@@ -28,7 +37,8 @@ Hub 2.0.0, Cross Code Hub, in steps (`docs/HUB-2.0-PLAN.md`).
licence-token prefix stays: it's part of the protocol).
- Installs register with protocol v1 only with a Cross Events licence (`409 WRONG_PRODUCT`
otherwise); the other products register with protocol v2 (step 2). Only Cross Events licences
can be invoiced until billing per customer (step 4).
can be invoiced until billing per customer (step 4). Until releases per product (step 3), only
Cross Events installs are told about releases or shown as behind.
- Migration `20261104132032_products`.
## [1.7.0] - 2026-11-03