Contracts 1.4.0: crosscode.link/1 and a public key in the v2 heartbeat

- crosscode.link/1 (link.connect / link.connected / link.disconnect), with
  signLink / verifyLink, PEM conversion, link secrets and nonces.
- The v2 heartbeat can carry the install's publicKey; the reply says
  saved / matches / mismatch (Hub 2.2.0). Never a failed heartbeat.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 11:58:26 +02:00
co-authored by Claude Opus 5.5
parent 9d585c94aa
commit 4952e2cb0f
21 changed files with 595 additions and 5 deletions
+7
View File
@@ -11,6 +11,7 @@ Events and the Hub, uses it, so the key fields are the same in every product's J
| Church | `crosscode.church/1` | The church profile: name, branding, campuses, service times, contact details, product links | `src/church.ts` |
| Identity | `crosscode.identity/1` | Accounts' sign-in claims and back-channel calls (`user.updated`, `user.deleted`, `user.export`) and their replies | `src/identity.ts` |
| Sign-in return | — | The return-path check and OIDC `state` every product uses (ROADMAP-v3 §3) | `src/return-to.ts` |
| Product link | `crosscode.link/1` | **Connect** under Settings → Linked products: the signed handshake that sets up a link's secret (`link.connect`, `link.connected`, `link.disconnect`) | `src/link.ts` |
| Hub protocol v2 | `protocolVersion: 2` | Register, heartbeat (stats per product), linked products, update requests, AI, licence token | `src/hub.ts` (exported as `hub`) |
| Signing | — | HMAC request signing for the Hub and for product links (Node only) | `src/signing.ts` (`@crosscode/contracts/signing`) |
@@ -62,6 +63,12 @@ for install → Hub; `LINK_HEADERS` (`X-Crosscode-Sender`, `-Timestamp`, `-Signa
`event.changed` webhooks and Accounts back-channel calls, with the secret set up by **Connect**.
Verify the raw bytes before parsing the JSON.
**Connect** (`crosscode.link/1`) is signed with each install's Ed25519 key instead: `signLink(message,
privateKeyPem)` and `verifyLink(message, senderPem)`, over the message without `signature` as
canonical JSON. The receiver takes the sender's PEM from its own cached `linkedProducts` (never
from the message) and refuses a nonce it has seen. `ed25519PublicToPem` / `ed25519PublicFromPem`
convert between the raw keys `generateEd25519` makes and the PEM the Hub lists.
### JSON Schema
`schemas/` has a JSON Schema (draft 2020-12) for every contract, for consumers that don't use