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:
martbost
2026-11-15 15:25:58 -06:00
parent 027107b0fd
commit 0e031f477e
11 changed files with 364 additions and 20 deletions
+18
View File
@@ -108,6 +108,12 @@ try {
const hc = await fetch(IAP + '/api/admin/campaigns', { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer localtest' }, body: JSON.stringify({ type: 'login', name: 'QA login sponsor', targetUrl: 'https://example.com/' }) });
const hj = await hc.json().catch(() => ({}));
ok(hc.ok && !hj.error, 'setup: a house login ad on InstantAdPay', JSON.stringify(hj).slice(0, 160));
// signed out (bots, probes, link previews): no login ad drawn and no view counted, on either site
const so = await (await fetch(IAP + '/api/ads/slot?type=login')).json();
const imps = async () => ((await (await fetch(IAP + '/api/admin/campaigns', { headers: { Authorization: 'Bearer localtest' } })).json()).campaigns || []).filter(c => c.type === 'login').reduce((t, c) => t + (Number(c.imps) || 0), 0);
ok(so.signedOut === true && !so.ad && (await imps()) === 0, 'signed out: /api/ads/slot?type=login draws nothing and counts no view on IAP', JSON.stringify(so));
const sl = await (await fetch(LS + '/api/ads/slot?type=login')).json();
ok(sl.signedOut === true && !sl.ad, 'signed out: nothing on LinkSpin either', JSON.stringify(sl));
// A. signed in on IAP with a wallet: straight back to the partner page with a session, never an IAP page, no login ad
const A = 'partner-a@example.com';
@@ -174,6 +180,18 @@ try {
who = await whoami(ctx);
ok(page.url() === P + '/team' && who.address === wd.address && who.via === 'linkspin', 'D. signed in on LinkSpin: back on the partner page signed in', page.url() + ' ' + JSON.stringify(who));
ok(/token issued p\*\*\*@example\.com for 5xYourTeam/.test(logs.ls), 'D. LinkSpin logged a token for 5xYourTeam');
// E. LinkSpin's login-ad clock: a house login ad, then the member's clock (served, too soon refused, finished, not due)
const lh = await fetch(LS + '/api/admin/campaigns', { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: 'Bearer localtest' }, body: JSON.stringify({ type: 'login', name: 'QA LS login sponsor', targetUrl: 'https://example.com/' }) });
const lhj = await lh.json().catch(() => ({}));
if (!lh.ok || lhj.error) ok(false, 'E. setup: a house login ad on LinkSpin', lh.status + ' ' + JSON.stringify(lhj).slice(0, 160));
else {
const lsGet = async () => (await ctx.request.get(LS + '/api/ads/slot?type=login')).json();
const lsSeen = async () => (await ctx.request.post(LS + '/api/ads/login/seen')).json();
let x = await lsGet(); ok(!!(x.ad && x.ad.targetUrl), 'E. LinkSpin: due -> a login ad', JSON.stringify(x).slice(0, 100));
x = await lsSeen(); ok(x.ok === false && x.reason === 'too soon', 'E. LinkSpin: "seen" before the countdown is refused', JSON.stringify(x));
await sleep(9000); x = await lsSeen(); ok(x.ok === true, 'E. LinkSpin: after the countdown the clock restarts', JSON.stringify(x));
x = await lsGet(); ok(x.notDue === true && !x.ad, 'E. LinkSpin: inside the setting, no login ad', JSON.stringify(x));
}
await ctx.close();
} catch (e) { console.log('FAIL exception', e && e.stack || e, e && e.cause ? 'cause: ' + (e.cause.stack || e.cause) : ''); fails++; }
finally {