Network hub link behind HUB_ENABLED (default off): hub member.joined from another door becomes the same waiting shell account the InstantAdPay registry sync makes (ensure 'carried'/'network', fill empty fields only, sponsor line placed first, wallet last under carry.hold); wallet.connected fills an empty wallet; LinkSpin's own joins and wallet links go to /v1/join and /v1/wallet through a persisted retry outbox (DATA_DIR/hubsync.json). Signed X-Hub-Ts/X-Hub-Sig, 5-minute window, each event seq applied once. sponsor.changed and the rest are ignored (TODO). iapsync and /api/partner/registry unchanged. Test: HUB_DIR=<network-hub with /v1/resolve {id}> bash qa/run.sh hubsync, 10 checks against a local hub in JSON mode.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -44,6 +44,7 @@ const leaderboard = require('./leaderboard');
|
||||
const toolkit = require('./toolkit');
|
||||
const registry = require('./registry'); // network registry: who is who across properties (LinkSpin, 2026-09-15)
|
||||
const iapsync = require('./iapsync'); // reverse registry sync: LinkSpin-first members reach InstantAdPay (2026-10-15)
|
||||
const hubsync = require('./hubsync'); // network hub link, inert unless HUB_ENABLED=1 (2026-11-12)
|
||||
const SF = require('./sponsorfollow'); // deliberate sponsor changes follow to InstantAdPay until chain-bound + one network tank (2026-10-22)
|
||||
let follow = null, followStore = null;
|
||||
const IAP_BASE = () => String(process.env.IAP_URL || 'https://instantadpay.com').replace(/\/+$/, '');
|
||||
@@ -706,7 +707,8 @@ async function boot() {
|
||||
// member numbers for accounts the engine activated before 2026-10-18 (the ledger names people by them); 60 s after boot so a deploy's old copy is gone
|
||||
setTimeout(() => carry.backfillMemberIds().then(r => console.log('memberId backfill', JSON.stringify(r))).catch(e => console.error('memberId backfill', e.message)), 60000);
|
||||
// reverse registry sync (2026-10-15): account changes reach InstantAdPay within seconds; a 2-minute reconcile catches the rest
|
||||
iapsync.init({ dataDir: DATA_DIR, accounts, registry, host: SITE_HOST, follow: followStore, tank: () => tank }); accounts.onChange(email => iapsync.touch(email));
|
||||
iapsync.init({ dataDir: DATA_DIR, accounts, registry, host: SITE_HOST, follow: followStore, tank: () => tank }); accounts.onChange(email => { iapsync.touch(email); hubsync.touch(email); });
|
||||
hubsync.init({ dataDir: DATA_DIR, accounts, registry, carry, follow: followStore }); setInterval(() => hubsync.tick().catch(e => console.error('hubsync', e.message)), 30 * 1000); // touch/tick do nothing while HUB_ENABLED is off
|
||||
setTimeout(() => iapsync.tick().catch(e => console.error('iapsync', e.message)), 2 * 60 * 1000);
|
||||
setInterval(() => iapsync.tick().catch(e => console.error('iapsync', e.message)), 2 * 60 * 1000);
|
||||
const ownHosts = () => [SITE_HOST].concat(String(siteConfig().linkDomains || '').split(',').map(x => x.trim().toLowerCase()).filter(Boolean), pagesHost() ? [pagesHost()] : []);
|
||||
@@ -2970,6 +2972,11 @@ const server = http.createServer(async (req, res) => {
|
||||
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||
const b = await readBody(req); return json(res, 200, await carry.seedAll(Number(b.limit) || 0));
|
||||
}
|
||||
if (p === '/api/hub/events' && req.method === 'POST' && hubsync.on()) { // network hub events (hubsync.js); with HUB_ENABLED off this route does not exist
|
||||
const raw = await new Promise((ok, no) => { let d = ''; req.on('data', c => { d += c; if (d.length > 2e6) { req.destroy(); no(new Error('too big')); } }); req.on('end', () => ok(d)); req.on('error', no); });
|
||||
const r = await hubsync.receive(req.headers, raw); return json(res, r.status, r.body);
|
||||
}
|
||||
if (p === '/api/admin/hubsync' && req.method === 'GET' && hubsync.on()) { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, hubsync.adminView()); }
|
||||
// -- live registry sync from InstantAdPay (2026-10-08): signed rows (HMAC LS_SYNC_SECRET over ts + newline + raw body),
|
||||
// upserted into the registry; new people become shell accounts with their line, existing shells pick up a username,
|
||||
// wallet or sponsor they did not have. Only the posted rows are touched.
|
||||
|
||||
Reference in New Issue
Block a user