From 957599974b453b9b13653b821658fd0a76d01809 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 2 Dec 2026 10:37:33 -0700 Subject: names: /migrate-grant only hands over a name whose coinos.io account has migrated. "check with the coinos-server agent on desk about the migrate hole. We should fix the issue and get it reenabled" (Adam, 2026-12-02). The bearer token proves the caller is coinos.io, not that the name's own account asked for the grant. The grant now also asks coinos.io for the account and goes ahead only when it exists and is flagged migrated; the old account's session flags itself just before it calls the grant, so a legitimate migration passes. It refuses with 404 when there's no such account, 409 when it hasn't migrated, and 502 when coinos.io can't be asked (the caller retries). New migrate-check.test.js passes. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VMan6WoqaQDYdpWkatPCar --- names/server.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'names/server.js') diff --git a/names/server.js b/names/server.js index 0a8a9f1..a8f7464 100644 --- a/names/server.js +++ b/names/server.js @@ -38,6 +38,7 @@ import { registrationIdentity } from './ownership.js'; import { openStore } from './store.js'; import { withdrawService } from './withdraw.js'; import { accountOf, accountBlockers, forgetAccount } from './forget.js'; +import { migrateGrantRefusal } from './migrate-check.js'; const CFG = JSON.parse(readFileSync(process.env.NAMES_CONFIG || join(import.meta.dir, 'config.json'), 'utf8')); @@ -2104,6 +2105,8 @@ Bun.serve({ try { b = await req.json(); } catch { return json({ error: 'bad body' }, 400); } const name = String(b.name || '').toLowerCase(); if (!NAME_RE.test(name)) return json({ error: 'bad name' }, 400); + const refused = await migrateGrantRefusal(name); + if (refused) return json({ error: refused[1] }, refused[0]); let pubkey = /^[0-9a-f]{64}$/.test(String(b.pubkey || '')) ? b.pubkey : null; let manager = null; if (!pubkey && b.to) { -- cgit v1.2.3