Hub 2.2.0: a public key on the v2 heartbeat, Clear public key

Installs that registered with protocol v1 move to v2 by sending their
public key on a signed v2 heartbeat: saved / matches / mismatch, never a
failed heartbeat. Clear public key (2FA again) for a rebuilt server.
Contracts 1.4.0 vendored; hub-protocol.md §6 updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 12:05:59 +02:00
co-authored by Claude Opus 5.5
parent 7428337aa5
commit 106d71e566
11 changed files with 158 additions and 14 deletions
+16
View File
@@ -19,6 +19,7 @@ const { emailNotice } = require('../utils/notices');
const { parseRepoUrl, syncReleases, releaseSources, cleanSources } = require('../utils/releaseSync');
const ai = require('../utils/ai');
const { AI_MODELS } = require('../utils/aiModels');
const { requireTotp } = require('../utils/jobs');
const router = express.Router();
router.use(protect);
@@ -270,6 +271,21 @@ router.put('/installs/:id', wrap(async (req, res) => {
res.json({ id: install.id, notes: install.notes });
}));
// Hub 2.2.0: forget an install's public key (e.g. its server was restored and made a new one), so
// the next heartbeat's key is saved. Its siblings stop listing it until then, and their links to
// it must be connected again. Needs two-factor again, like an uninstall.
router.post('/installs/:id/public-key/clear', wrap(async (req, res) => {
requireTotp(req.admin, req.body?.totp);
const install = await prisma.install.findUnique({ where: { id: req.params.id } });
if (!install) throw bad('Install not found', 404);
const now = new Date();
await prisma.install.update({ where: { id: install.id }, data: { publicKey: null } });
await prisma.installEvent.updateMany({ where: { installId: install.id, type: 'public_key_mismatch', resolvedAt: null }, data: { resolvedAt: now } });
await prisma.installEvent.create({ data: { installId: install.id, type: 'public_key', level: 'info', message: 'Public key cleared by the provider; the next heartbeat saves the install\'s current key.', resolvedAt: now } });
await audit(req, 'install_public_key_cleared', install.id);
res.json({ cleared: true });
}));
// ─── Alerts and history ───────────────────────────────────────────────────────
router.get('/events', wrap(async (req, res) => {