Network hub listener (hubsync.js), off unless HUB_ENABLED

POST /api/hub/events: signed hub hooks (HUB_SECRET, 5-minute window), each seq applied once, 503 so the hub retries.
member.joined from another door: /v1/resolve the person (climbing to sponsors not here yet) and make waiting accounts
through lsinbound.receive (joinedVia 'hub', joinedRef 'hub:<door>'); existing accounts keep their sponsor and the
difference is listed in /api/admin/hub. wallet.connected fills waiting accounts only; sponsor.changed is a TODO.
Our own new accounts and wallet links go to /v1/join and /v1/wallet from a persisted outbox (hubsync.json), never
in the way of a sign-up. With the flag off nothing is initialised, wired, routed or written; the LinkSpin sync is
unchanged. Test: qa/hubsync.test.cjs against a local network-hub (needs /v1/resolve by id, branch hub-resolve-id).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-12 17:02:45 -06:00
parent 74354346a3
commit 5c896cb782
6 changed files with 465 additions and 6 deletions
+2 -1
View File
@@ -484,7 +484,8 @@ async function count() { return impl().count(); }
// It exists so the LinkSpin line is already in place; it is not a member yet, so the sweeps that mail, count or adopt
// members (listAll by default) leave it out. It becomes an ordinary account the first time its owner signs in (lastSeen).
// BTC4Hits members imported 2026-11-11 (btc4hits-migration, joinedVia 'btc4hits') are the same kind of waiting account.
const SHELL_VIAS = new Set(['linkspin', 'btc4hits']);
// Network hub members who joined at another door (hubsync.js, 2026-11-12, only while HUB_ENABLED) arrive as joinedVia 'hub'.
const SHELL_VIAS = new Set(['linkspin', 'btc4hits', 'hub']);
const isUnclaimedShell = a => !!a && SHELL_VIAS.has(a.joinedVia) && !a.lastSeen && !a.memberId;
// the limit counts members, not waiting accounts: newest-first LIMIT before the filter let thousands of waiting accounts push
// older real members out of the sweeps that read listAll(5000) (tank, coach, leaderboard, Friday, Wednesday)