Renew the device certificate from the browser, with the recovery phrase

Within the last 30 days the owner page offers it. The node signs a new certificate for the same device key (peer ID and listings stay), saves it, and signs again own listings that would outlive the old certificate. The phrase is used for one request and not kept; another identity's phrase and no-phrase identities are refused. Device.Current gives the certificate to sign with while a renewal happens.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
2026-11-18 23:19:30 +01:00
co-authored by Claude Sonnet 5.5
parent 210ba1b3e9
commit dfe35b422d
23 changed files with 1011 additions and 29 deletions
+4 -1
View File
@@ -204,6 +204,8 @@ export interface GatewayOptions {
statusFails?: boolean;
/** The regions the node reports; default ["u1x"]. */
regions?: string[];
/** The device certificate the node reports in /status; unset, it says nothing (an older node). */
cert?: { expires_at: number; can_renew: boolean };
}
export async function startGateway(opts: GatewayOptions): Promise<Gateway> {
@@ -245,7 +247,7 @@ export async function startGateway(opts: GatewayOptions): Promise<Gateway> {
}
// The owner's token-protected routes are played by the test, if it sets `owner`.
const writesListing = req.method !== "GET" && /^\/api\/v1\/listings(\/[0-9a-f]{32})?$/.test(url.pathname);
if (writesListing || /^\/api\/v1\/(mine|inbox|regions|blocked|signals|reports)|^\/api\/v1\/listings\/[0-9a-f]{32}\/address$/.test(url.pathname)) {
if (writesListing || /^\/api\/v1\/(mine|inbox|regions|blocked|signals|reports|certificate)|^\/api\/v1\/listings\/[0-9a-f]{32}\/address$/.test(url.pathname)) {
let body = "";
req.on("data", (c) => (body += c));
req.on("end", () => {
@@ -292,6 +294,7 @@ export async function startGateway(opts: GatewayOptions): Promise<Gateway> {
listings: opts.listings.length,
difficulty: DIFFICULTY,
message_difficulty: 6,
...(opts.cert ? { cert_expires_at: opts.cert.expires_at, can_renew: opts.cert.can_renew } : {}),
});
}
if (url.pathname === "/api/v1/listings") {