Network hub sign-in, step 3 (Marty 2026-11-15) + signed-out login slot refused
networksso.js (the same file on every network site): with HUB_SSO=on /sso/start asks the network hub, /sso/in takes the hub's h1. token (this site's HUB_SECRET, iss hub, aud iap, 60 s, single use, state cookie), and when the hub has nobody the old pairwise provider is tried once (the fallback until every site is switched). networksso.page() on every GET: a signed-in member's real page load tells the hub once (nsso.hp, hub /sso/set and straight back) and pings the hub's /v1/activity once a day (fire and forget), only while the hub answers /health. Sessions: SESSION_TTL_HOURS (168 = 7 days in production), renewed on use at most hourly; the cookie lives 30 days and the server's sliding expiry decides. auth.endSessions(email, wallet). Sign out everywhere: POST /api/auth/logout-everywhere (hub /v1/sso/signout, every session of the member here ends) and a "Sign out everywhere" link beside Log out; my.js?v=20261115hub. hubsync: member.blocked and member.signedout end every session of that member here. Login ad: /api/ads/slot?type=login refuses signed-out callers (no ad drawn, no view counted; bots and probes cannot run up an advertiser's numbers). The games' kit keeps its own route. Chatbot: a sign-in lasts 7 days and renews; the login ad shows every few hours on its own clock; the silent check is every 2 minutes. Tests: qa/networksso-hub.e2e.mjs (new, run.sh member; real hub + IAP + LinkSpin + a wallet partner on four cookie hosts): page load pushes to the hub once, LinkSpin signs in through the hub, partner gets the wallet from the hub, sign out everywhere, blocked, replay, forged key, no email code. Partner e2e: signed-out slot on both sites, LinkSpin clock. qa member: ALL PASSED (2 known admin warnings). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -762,7 +762,7 @@ async function boot() {
|
||||
reload: { 'legacy.json': () => legacy.reload(), 'legacy-grants.json': () => legacy.reload() },
|
||||
forget: [email => loginClock.forget(String(email || '').toLowerCase()), email => lssync._forget(email), email => { if (hubsync.enabled()) hubsync._forgetHeld(email); }] });
|
||||
// network hub (hubsync.js): nothing at all happens here unless HUB_ENABLED is on; the LinkSpin sync above runs either way
|
||||
if (hubsync.enabled()) { hubsync.init({ dataDir: DATA_DIR, accounts, lsinbound, follow: followStore, chain, erase }); accounts.onChange(email => { lssync.touch(email); hubsync.touch(email); }); hubsync.start(); }
|
||||
if (hubsync.enabled()) { hubsync.init({ dataDir: DATA_DIR, accounts, lsinbound, follow: followStore, chain, erase, endSessions: (email, wallet) => auth.endSessions(email, wallet) }); accounts.onChange(email => { lssync.touch(email); hubsync.touch(email); }); hubsync.start(); }
|
||||
// 5xYourTeam draft picks (draftpartner.js, 2026-11-15): the routes answer 503 until DRAFT_PARTNER_SECRET is set; the pool stays empty
|
||||
// and nobody can be drafted while the hub is off (DRAFT_ALLOW_NO_HUB=1 is for local tests only, refused in production)
|
||||
await draftpartner.init({ maxOpen: () => siteConfig().fiveXDraftCap, dataDir: DATA_DIR, accounts, chain, tank, ads, requireHub: !(process.env.DRAFT_ALLOW_NO_HUB === '1' && process.env.NODE_ENV !== 'production'),
|
||||
@@ -2396,6 +2396,7 @@ const server = http.createServer(async (req, res) => {
|
||||
res.writeHead(302, { Location: to, 'Cache-Control': 'no-store', 'X-Robots-Tag': 'noindex' }); return res.end();
|
||||
} }
|
||||
// network sign-in with LinkSpin (2026-11-12): /go/linkspin, /sso/start, /sso/check, /sso/in, /api/sso/status
|
||||
if (req.method === 'GET' && await networksso.page(req, res, u)) return; // network hub: daily activity ping + the hub sign-in push (2026-11-15)
|
||||
if (req.method === 'GET' && (p === '/go/linkspin' || p === '/go/bannerline' || p === '/go/vbb' || p === '/go/viraladblitz' || p === '/go/downlinehydra' || p.startsWith('/sso/') || p === '/api/sso/status') && await networksso.handle(req, res, u)) return;
|
||||
// network member lookup for Downline Banners (2026-11-13, Marty: share links use the InstantAdPay username): ?u=<username> -> the
|
||||
// account's linked wallet, ?a=<wallet> -> the username. Public data only (usernames are public join links, wallets are on-chain).
|
||||
@@ -3064,6 +3065,15 @@ const server = http.createServer(async (req, res) => {
|
||||
return json(res, 200, { ok: true, address: r.address, memberId },
|
||||
{ 'Set-Cookie': auth.sessionCookie(token) });
|
||||
}
|
||||
// "Sign out everywhere" (Marty 2026-11-15): the network hub ends every hub sign-in of this member and tells every hooked site;
|
||||
// every session of this member here ends too. Same-origin POST only (SameSite=Lax session cookie).
|
||||
if (p === '/api/auth/logout-everywhere' && req.method === 'POST') {
|
||||
const s = await auth.fromRequest(req).catch(() => null);
|
||||
let hub = { ok: false };
|
||||
if (s) { hub = await networksso.signOutEverywhere(s); try { await auth.endSessions(s.email || null, s.address || null); } catch (e) {} }
|
||||
try { await auth.logout(req); } catch (e) {}
|
||||
return json(res, 200, { ok: true, everywhere: !!hub.ok }, { 'Set-Cookie': [auth.clearCookie(), networksso.offCookie()] }); // no silent network sign-in here for 12 h
|
||||
}
|
||||
if (p === '/api/auth/logout' && req.method === 'POST') {
|
||||
await auth.logout(req);
|
||||
return json(res, 200, { ok: true }, { 'Set-Cookie': [auth.clearCookie(), networksso.offCookie()] }); // signed out stays signed out: no silent network sign-in here for 12 hours
|
||||
@@ -5558,7 +5568,8 @@ const server = http.createServer(async (req, res) => {
|
||||
if (t === 'login') { // on the member's clock (loginadclock.js); back = a network sign-in hop to finish when the countdown ends (2026-11-15)
|
||||
const s = await auth.fromRequest(req).catch(() => null); const lk = loginClock.keyOf(s);
|
||||
const back = networksso.pendingBack(req) ? '/sso/resume' : null;
|
||||
if (lk && !(await loginClock.due(lk))) return json(res, 200, { ad: null, notDue: true, back });
|
||||
if (!lk) return json(res, 200, { ad: null, signedOut: true }); // signed out (bots, probes, link previews) never draws or counts a login ad (2026-11-15); the games' kit has its own route
|
||||
if (!(await loginClock.due(lk))) return json(res, 200, { ad: null, notDue: true, back });
|
||||
const ad = await loginAdFor(req, 'dashboard');
|
||||
if (ad && lk) await loginClock.served(lk);
|
||||
return json(res, 200, { ad, back });
|
||||
|
||||
Reference in New Issue
Block a user