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 bannerline) and every session of their main wallet or any contract wallet ends. member.erased: matched by
the wallet SHA-256s 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 Spots: "Sign out everywhere" next to Sign out (POST /api/auth/logout-everywhere -> networksso.signOutEverywhere, then every
session of this wallet here ends). my.js?v=z2.
Smoke section 9 (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): 145/145 with UI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-16 05:01:22 -06:00
parent 046b3068cb
commit 197aa39fca
6 changed files with 196 additions and 5 deletions
+15 -1
View File
@@ -92,6 +92,7 @@ function limited(req, name, max, windowMs) {
// verify membership"; hubpeople.js, cached 5 minutes); InstantAdPay's GET /api/network/member ?u= / ?a= only when the hub is
// unreachable (cached an hour, misses too; a failed call is not cached). A person the hub does not know is unknown here too.
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();
const fromHub = p => { const a = hubpeople.wallet(p); return a ? { address: a, username: p.username ? String(p.username) : null, hubId: p.id || null, via: 'hub' } : null; };
async function netMember(q) {
@@ -267,6 +268,8 @@ networksso.init({ self: 'bannerline', peer: 'iap', peerBase: () => C.iapBase, fr
accept: async (email, req, v) => (v && v.wallet ? { ok: true } : { fallback: 'no wallet in the token' }),
signIn: async (email, req, v) => { if (v.name) netCache.set('a:' + v.wallet, { at: Date.now(), m: { address: v.wallet, username: v.name } }); return cookie('bl.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: 'bannerline', end: who => store.endSessions(x => who.match(x), who.before) });
const server = http.createServer(async (req, res) => {
const u = new URL(req.url, 'http://x'); const p = u.pathname;
@@ -452,6 +455,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('bl.sid', '', 0, true), networksso.offCookie()] }); // signed out stays signed out here for 12 hours
}
// "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('bl.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') {
// username / refName (Marty 2026-11-15): the footer's network links carry a referral username, the member's own network
// username when signed in, else the sponsor's (usernames only, never the wallet)
@@ -537,7 +551,7 @@ const server = http.createServer(async (req, res) => {
// -- admin (ADMIN_TOKEN header): keeper preview + index status. No key material is ever returned.
if (p === '/api/admin/status' && req.method === 'GET') {
const tok = process.env.ADMIN_TOKEN; if (!tok || req.headers['x-admin-token'] !== tok) return json(res, 401, { error: 'no' });
return json(res, 200, { index: chain.status(), totals: chain.totals(), keeper: keeper.statusInfo(), hub: hubreport.view(), hubLookup: hubpeople.view(), refuelSpots: refuelspots.view(), nas: dlbnas.view() });
return json(res, 200, { index: chain.status(), totals: chain.totals(), keeper: keeper.statusInfo(), hub: hubreport.view(), hubLookup: hubpeople.view(), hubEvents: hubevents.view(), refuelSpots: refuelspots.view(), nas: dlbnas.view() });
}
// -- admin: the network hub's member lookup (Marty 2026-11-14, read-only). GET ?q=<wallet> | <spot id>. No email lives here.