From 3886d35bc10c8cdb01143c30c5ff076d10bcdbae Mon Sep 17 00:00:00 2001 From: martbost Date: Sun, 15 Nov 2026 05:28:03 -0600 Subject: [PATCH] networksso.js: same file as InstantAdPay/LinkSpin again (deliberate-tap sign-in + /sso/resume from 2026-11-14) plus the viraladblitz name; smoke 132/132 (SKIP_UI) Co-Authored-By: Claude Opus 5.5 --- networksso.js | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/networksso.js b/networksso.js index 44254e8..28b9af3 100644 --- a/networksso.js +++ b/networksso.js @@ -34,10 +34,12 @@ const enabled = () => SECRET().length >= 32; const TTL = 60 * 1000; // token life const SKEW = 30 * 1000; // clock skew allowed between the two servers const STATE_AGE = 300; // seconds: the state cookie +const GO_STATE_AGE = 1200; // seconds: the state cookie on a deliberate tap (time to sign in on the provider first, 2026-11-14) +const BACK_AGE = 1200; // seconds: the provider remembers an unfinished deliberate check while the member signs in const TRIED_AGE = 1800; // seconds: one silent check per browser per 30 minutes const OFF_AGE = 12 * 3600; // seconds: no silent check after a sign-out on this site const HINT_AGE = 300; // seconds: the email prefill when the member is not here yet -const NAMES = { iap: 'InstantAdPay', linkspin: 'LinkSpin', bannerline: 'Downline Banners', vbb: 'Viral Banner Blitz', viraladblitz: 'ViralAdBlitz' }; // viraladblitz = ViralAdBlitz, a wallet site like VBB (2026-11-14); the same line must ship in IAP + LinkSpin +const NAMES = { iap: 'InstantAdPay', linkspin: 'LinkSpin', bannerline: 'Downline Banners', vbb: 'Viral Banner Blitz', viraladblitz: 'ViralAdBlitz' }; // vbb = Viral Banner Blitz, a wallet site like Downline Banners (2026-11-14); viraladblitz = ViralAdBlitz, a wallet site like VBB (2026-11-15) const WALLET_RE = /^0x[0-9a-f]{40}$/; let C = null; // { self, peer, peerBase(), isProd, dataDir, db, member(req), accept(email, req, v), signIn(email, req, v), landing(to), signinPath(to), defaultPath, @@ -160,9 +162,15 @@ async function handle(req, res, u) { const c = cookies(req); if (mode === 'check' && (c['nsso.tried'] || c['nsso.off'])) return go(res, to); const st = crypto.randomBytes(16).toString('hex'); - const set = [ck('nsso.st', st, STATE_AGE, true), ck('nsso.tried', '1', TRIED_AGE, true)]; + const set = [ck('nsso.st', st, mode === 'go' ? GO_STATE_AGE : STATE_AGE, true), ck('nsso.tried', '1', TRIED_AGE, true)]; if (mode === 'go' && c['nsso.off']) set.push(ck('nsso.off', '', 0, true)); - return go(res, (from ? from() : C.peerBase()) + '/sso/check?st=' + st + (C.from ? '&r=' + C.self : '') + '&to=' + encodeURIComponent(to), set); + return go(res, (from ? from() : C.peerBase()) + '/sso/check?st=' + st + (C.from ? '&r=' + C.self : '') + '&to=' + encodeURIComponent(to) + (mode === 'go' ? '&m=go' : ''), set); + } + if (p === '/sso/resume') { // signed in on the provider after a deliberate tap: finish the check it was asked for (2026-11-14) + const q = new URLSearchParams(cookies(req)['nsso.back'] || ''); + const clear = [ck('nsso.back', '', 0, true)]; + if (!/^[a-f0-9]{32}$/.test(q.get('st') || '')) return go(res, C.defaultPath, clear); + return go(res, '/sso/check?st=' + q.get('st') + (q.get('r') ? '&r=' + encodeURIComponent(q.get('r')) : '') + '&to=' + encodeURIComponent(safePath(q.get('to'), '/')), clear); } if (p === '/sso/check') { const st = String(u.searchParams.get('st') || ''); @@ -173,7 +181,14 @@ async function handle(req, res, u) { const none = base + '/sso/in?none=1&to=' + encodeURIComponent(to); if (!enabled() || !/^[a-f0-9]{32}$/.test(st)) return go(res, none); let s = null; try { s = await C.member(req); } catch (e) {} - if (!s || !s.email) { log('check: not signed in here', null, 'for ' + forName); return go(res, none); } + if (!s || !s.email) { + if (u.searchParams.get('m') === 'go' && !isBot(req)) { // a deliberate tap: sign in here first, then /sso/resume finishes the trip + log('check: not signed in here, asking to sign in', null, 'for ' + forName); + const back = new URLSearchParams({ st, to }); if (r) back.set('r', r); + return go(res, C.signinPath(C.defaultPath), [ck('nsso.back', back.toString(), BACK_AGE, true)]); + } + log('check: not signed in here', null, 'for ' + forName); return go(res, none); + } let w = null; if (wb) { try { w = await C.wallet(s); } catch (e) {} if (!w || !WALLET_RE.test(String(w.address || '').toLowerCase())) { log('check: no wallet on the account', s.email, 'for ' + forName); return go(res, none); } } log('token issued', s.email, 'for ' + forName); @@ -209,4 +224,7 @@ async function handle(req, res, u) { return false; } -module.exports = { init, handle, enabled, mint, verify, spend, safePath, isBot, offCookie, mask, TTL, NAMES }; +// true when this browser came here from a deliberate network tap and still has to finish it after signing in +const pendingBack = req => !!cookies(req)['nsso.back']; + +module.exports = { init, handle, enabled, pendingBack, mint, verify, spend, safePath, isBot, offCookie, mask, TTL, NAMES };