aboutsummaryrefslogtreecommitdiffstats
path: root/names/server.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-12-02 10:41:29 -0700
committerAdam Soltys <[email protected]>2026-12-02 10:41:29 -0700
commit8076d1323566fe90a43f857384e5e46c257c692a (patch)
tree16282510dc94a9f1e238e60e8be9fc9ede2f9663 /names/server.js
parentc851718782ec8c26d8fd32372ec50a9f7e9efd23 (diff)
downloadcoinosv3-server-8076d1323566fe90a43f857384e5e46c257c692a.tar.gz
coinosv3-server-8076d1323566fe90a43f857384e5e46c257c692a.zip
names: /migrate-grant needs a fresh v3 hand-off stamp from coinos.io.
"Fix the gap" (Adam, 2026-12-02). The reverted check keyed on `migrated`, which coinos.io has set on every new account since 2023, so it stopped nothing (c851718). coinos-server 796999cb now records `v3migrated`, a timestamp set only when an account's own session posts the hand-off, and shows it on /api/users/<name>. The grant follows within seconds, so it goes ahead only when that stamp is under 5 minutes old. That is the same proof as carrying the old account's session to /api/me, without sending coinos.io JWTs (no expiry, no revocation) to this host. A name handed over earlier can't be re-granted to a different key unless its owner hands it over again. Refused: stale, future-dated or missing stamp (409); no such account (404); coinos.io unreachable (502, the caller retries). migrate-check.test.js runs in `bun run test` (18 pass). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VMan6SSfVopM1ZzXKZmLYU
Diffstat (limited to 'names/server.js')
-rw-r--r--names/server.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/names/server.js b/names/server.js
index 0a8a9f1..3e687c3 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,11 @@ 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) {
+ log(`migrate-grant refused: ${name}@coinos.io (${refused[1]})`);
+ 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) {