Network hub hook (Marty 2026-11-16): sign out everywhere, hub blocks and erases end sessions here; "Sign out everywhere" button

hubevents.js (new, byte-identical in VBB, DLB, ViralAdBlitz, DownlineHydra, 5xYourTeam): POST /api/hub/events, signed by the hub
with HUB_SECRET (same hook InstantAdPay and LinkSpin take). member.signedout and member.blocked: the person is looked up by hub id
(/v1/resolve, signed as vbb) and their sessions here end (by the main wallet or any contract wallet). member.erased: matched by the wallet SHA-256s
(and email SHA-256) the hub now sends with the event. Only sessions made before the event end (a replay never signs anyone out
twice); a failed hub lookup answers 503 so the hub resends. Off with HUB_HOOK=0. Admin status: hubEvents (counts only).
My Banners: "Sign out everywhere" next to Sign out (POST /api/auth/logout-everywhere -> networksso.signOutEverywhere, then every
session of this member here ends).
Smoke: section 16 (refused signatures, signedout in two browsers, replay, older event, blocked, erased by wallet hash, other events, hub down -> 503 -> resent, Sign out everywhere, admin view): 322/322 with UI. my.js?v=5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-16 05:05:34 -06:00
parent 43e8dac257
commit fb45fcddca
6 changed files with 192 additions and 4 deletions
+15 -1
View File
@@ -93,6 +93,7 @@ const isAdmin = req => { const t = String(process.env.ADMIN_TOKEN || ''); const
// The network hub answers first (hubpeople.js, signed as vbb, cached 5 minutes); InstantAdPay's /api/network/member only when
// the hub is unreachable. A person the hub does not know is unknown here too (never "verified" on InstantAdPay's word alone).
const hubpeople = require('./hubpeople');
const hubevents = require('./hubevents'); // network hub hook (2026-11-16): sign-out-everywhere, block and erase end sessions here
const netCache = new Map();
async function netMember(q) {
const h = q.u ? await hubpeople.byRef(q.u) : await hubpeople.byWallet(q.a);
@@ -200,6 +201,8 @@ networksso.init({ self: 'vbb', peer: 'iap', peerBase: () => C.iapBase, from: { i
return cookie('vbb.sid', store.mintSession(v.wallet), store.SESSION_TTL / 1000, true);
},
landing: to => to, signinPath: to => to });
// the hub's member.signedout / member.blocked / member.erased: that person's sessions here end (by any of their wallets)
hubevents.init({ dataDir: C.dataDir, site: 'vbb', end: who => store.endSessions(x => who.match(x) || who.match(store.member(x.address)), who.before) });
// old site links (2026-11-14, the Downline Banners pattern): the old YFW site's referral links were /?<old username>,
// /splashpg.php?pid=N&r=<old username> and /lcp.php?pid=N&r=<old username>. An old username maps to the same person's network
@@ -365,6 +368,17 @@ const server = http.createServer(async (req, res) => {
const s = session(req); if (s) store.dropSession(s.token);
return json(res, 200, { ok: true }, { 'Set-Cookie': [cookie('vbb.sid', '', 0, true), networksso.offCookie()] });
}
// "Sign out everywhere" (2026-11-16): the hub ends every network sign-in of this member and tells every hooked site; every
// session of this wallet here ends now. Same-origin POST only (SameSite=Lax session cookie).
if (p === '/api/auth/logout-everywhere' && req.method === 'POST') {
const s = session(req); let hub = { ok: false };
if (s) { hub = await networksso.signOutEverywhere(s); store.endSessions(x => x.address === s.address, Date.now() + 1000); }
return json(res, 200, { ok: true, everywhere: !!hub.ok }, { 'Set-Cookie': [cookie('vbb.sid', '', 0, true), networksso.offCookie()] });
}
if (p === '/api/hub/events' && req.method === 'POST') {
let raw = ''; try { raw = (await readRaw(req, 256 * 1024)).toString('utf8'); } catch (e) { return json(res, 413, { error: 'too big' }); }
const r = await hubevents.receive(req.headers, raw); return json(res, r.status, r.body);
}
if (p === '/api/me' && req.method === 'GET') {
const s = session(req); if (!s) return json(res, 200, { signedIn: false });
const m = store.member(s.address);
@@ -515,7 +529,7 @@ const server = http.createServer(async (req, res) => {
queue: { length: S.queue.length, next: S.queue.slice(0, 20) }, progress: S.progress, held: S.progress >= C.perShift && !S.queue.length,
today: { visits: t.visits || 0, shifts: t.shifts || 0, cycles: t.cycles || 0, posts: t.posts || 0, clicks: t.clicks || 0 },
totals: S.totals, ledger: { entries: L.length, views: L.reduce((x, e) => x + e.views, 0), viewsByStatus: byStatus, credited: 0 },
members: store.members().length, banners: S.banners.length, visitsKept: store.visits().length, shop: shop.view(), prize: prize.view(), proof: proof.view(), hub: hubreport.view(), hubLookup: hubpeople.view(), lsSpins: lsspins.view(), docstore: docstore.view(), oldrefs: Object.keys(oldRefMap()).length });
members: store.members().length, banners: S.banners.length, visitsKept: store.visits().length, shop: shop.view(), prize: prize.view(), proof: proof.view(), hub: hubreport.view(), hubLookup: hubpeople.view(), hubEvents: hubevents.view(), lsSpins: lsspins.view(), docstore: docstore.view(), oldrefs: Object.keys(oldRefMap()).length });
}
// old username -> network username map for the old-link redirects: { oldrefs: { old: network } } replaces the whole map
if (p === '/api/admin/oldrefs' && req.method === 'POST') {