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:
@@ -221,7 +221,18 @@ export const accountsStatsSchema = z.object({
|
||||
linkedProducts: count,
|
||||
});
|
||||
|
||||
const heartbeatBase = z.object({ protocolVersion, version: semverSchema, health: healthSchema });
|
||||
const heartbeatBase = z.object({
|
||||
protocolVersion,
|
||||
version: semverSchema,
|
||||
health: healthSchema,
|
||||
/**
|
||||
* The install's Ed25519 public key (PEM), contracts 1.4.0 / Hub 2.2.0. Lets an install that
|
||||
* registered with protocol v1 move to v2 without its licence key (the heartbeat is already
|
||||
* signed with the install secret). The Hub saves it when the install has none; see
|
||||
* `publicKeyStatus` in the reply.
|
||||
*/
|
||||
publicKey: z.string().startsWith("-----BEGIN PUBLIC KEY-----").optional(),
|
||||
});
|
||||
|
||||
export const heartbeatRequestSchema = z.discriminatedUnion("product", [
|
||||
heartbeatBase.extend({ product: z.literal("events"), stats: eventsStatsSchema }),
|
||||
@@ -231,6 +242,8 @@ export const heartbeatRequestSchema = z.discriminatedUnion("product", [
|
||||
]);
|
||||
export type HeartbeatRequest = z.infer<typeof heartbeatRequestSchema>;
|
||||
|
||||
export const PUBLIC_KEY_STATUSES = ["saved", "matches", "mismatch"] as const;
|
||||
|
||||
export const heartbeatResponseSchema = z.object({
|
||||
licence: z.string(),
|
||||
latestVersion: semverSchema.nullable(),
|
||||
@@ -239,6 +252,12 @@ export const heartbeatResponseSchema = z.object({
|
||||
/** The church's other installs. The install caches this, so a Hub outage changes nothing. */
|
||||
linkedProducts: z.array(linkedProductSchema),
|
||||
serverTime: dateTimeSchema,
|
||||
/**
|
||||
* Only when the heartbeat sent `publicKey` (Hub 2.2.0+): `saved` (the Hub had none),
|
||||
* `matches`, or `mismatch` (the Hub has another key; it keeps its own and flags the install
|
||||
* until Joshua clears it). Never a failed heartbeat: the licence keeps refreshing either way.
|
||||
*/
|
||||
publicKeyStatus: z.enum(PUBLIC_KEY_STATUSES).optional(),
|
||||
});
|
||||
export type HeartbeatResponse = z.infer<typeof heartbeatResponseSchema>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user