Network sign-in with InstantAdPay (Marty approved 2026-11-12): signed in on one site = signed in on the other, no email code

networksso.js (same file in both repos): /go/iap hop for signed-in members' cross-site links; /sso/start (state cookie +
30-minute loop guard) -> InstantAdPay /sso/check -> /sso/in?t=<v1 HMAC-SHA256 token, NETWORK_SSO_SECRET, 60 s, single-use nonce,
bound to the browser's state cookie, email, audience and a same-site relative path>. App host only (not link/pages hosts).
Member sessions only (admin portal never shared), ordinary 4-hour session. An email not here yet (sync not run) or not on
LS_TESTERS gets the normal email-code sign-in, email prefilled; nothing is created. Silent check on every Control Room screen
(cr-shell.js loads public/assets/netsso.js); never for bots/fetches; sign-out pauses it 12 hours. Engine Room, Fuel and the
arrival strip's Back to InstantAdPay go through /go/iap. Chatbot knows it (KNOWLEDGE_DATE 2026-11-12). Off until
NETWORK_SSO_SECRET (32+ chars) is set. ?v= bumped (cr-shell, fuel, engine-room: 20261112sso).

qa: networksso.test.cjs all passed, networksso.e2e.mjs (both servers, real browser) 31/31, run.sh member green (0 bugs)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-12 07:05:51 -06:00
parent 3cc687aff5
commit e79d5ae63e
23 changed files with 618 additions and 21 deletions
+3 -3
View File
@@ -75,9 +75,9 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/cr-shell.js?v=20261112sso"></script>
<script src="/assets/ads-screen.js?v=20261104lf"></script>
<script src="/assets/fuel.js?v=20261025ff"></script>
<script src="/assets/engine-room.js?v=20261101t"></script>
<script src="/assets/fuel.js?v=20261112sso"></script>
<script src="/assets/engine-room.js?v=20261112sso"></script>
</body>
</html>
+3 -1
View File
@@ -4,6 +4,8 @@
// <div id="page">, then CR.mount({active,title,sub,actions}) and CR.requireSession(cb).
window.CR = (function () {
const $ = id => document.getElementById(id);
// network sign-in (2026-11-12): signed in on InstantAdPay = signed in here, no code (netsso.js asks the server once; same file on both sites)
try { if (!document.querySelector('script[src^="/assets/netsso.js"]')) { const ns = document.createElement('script'); ns.src = '/assets/netsso.js?v=20261112sso'; ns.async = true; document.head.appendChild(ns); } } catch (e) {}
// launch day is 2026-11-15 Central: the pre-launch notice shows only before it
function prelaunch() { try { return new Date().toLocaleDateString('en-CA', { timeZone: 'America/Chicago' }) < '2026-11-15'; } catch (e) { return false; } }
const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
@@ -66,7 +68,7 @@ window.CR = (function () {
if (!ARR || $('crArrive')) return '';
if (!document.getElementById('crArriveCss')) { const st = document.createElement('style'); st.id = 'crArriveCss'; st.textContent = '.arrive{display:flex;flex-wrap:wrap;gap:6px 14px;align-items:center;margin:12px 24px 0;padding:10px 14px;border:1px solid var(--sig,#ff6a1a);border-radius:8px;background:var(--sig-soft,#FFF8F2);font-size:13.5px;line-height:1.45}.arrive .grow{flex:1 1 auto}.arrive button{border:0;background:none;font-size:18px;line-height:1;cursor:pointer;color:inherit;padding:0 2px}@media (max-width:900px){.arrive{margin:10px 16px 0}}.cr-flash{animation:crFlash 2.4s ease-out 1}@keyframes crFlash{0%,40%{box-shadow:0 0 0 4px rgba(255,106,26,.55)}100%{box-shadow:0 0 0 0 rgba(255,106,26,0)}}'; document.head.appendChild(st); }
return '<div class="arrive" id="crArrive" role="note"><span><b>You came from InstantAdPay to ' + esc(ARR[0]) + '.</b> <span id="crArriveSi">Sign in with the same email you use on InstantAdPay, then </span><b>Step 1:</b> ' + esc(ARR[1])
+ (ARR[2] ? ' <a href="' + ARR[2] + '" target="_blank" rel="noopener">' + esc(ARR[3]) + '</a>' : '') + '</span><span class="grow"></span><a href="https://instantadpay.com/my#engine">Back to InstantAdPay</a><button type="button" aria-label="Hide this note" id="crArriveX">&times;</button></div>';
+ (ARR[2] ? ' <a href="' + ARR[2] + '" target="_blank" rel="noopener">' + esc(ARR[3]) + '</a>' : '') + '</span><span class="grow"></span><a href="/go/iap?to=%2Fmy%23engine">Back to InstantAdPay</a><button type="button" aria-label="Hide this note" id="crArriveX">&times;</button></div>';
}
// Expired session (Marty 2026-10-23: "told me to sign in but never redirected me"): sessions last 24 h, and a screen
// left open past that got 'Sign in first.' errors with no way forward. Any 401 from our API, or coming back to a tab
+2 -1
View File
@@ -11,7 +11,8 @@
const TASK = { tracking: 'conversions', start: 'refuel', refuel: 'refuel', pitstop: 'refuel', bannerspin: 'bannerspin', testing: 'testing', relaunch: 'ads', topup: 'ads', cut: 'ads', cruise: 'ads' };
let FROM = 'iap';
const siteOf = u => /linkspin/i.test(u.host) ? 'linkspin' : 'iap'; // which site a link belongs to, by its host (also right on a local copy)
const go = (url, task) => { try { const u = new URL(url); if (u.host === location.host || siteOf(u) === FROM) return u.pathname + u.search + u.hash; if (task) { u.searchParams.set('from', FROM); u.searchParams.set('task', task); } return u.href; } catch (e) { return url; } };
// a link to the other site goes through this site's /go/<other> hop (network sign-in, 2026-11-12): the member arrives signed in
const go = (url, task) => { try { const u = new URL(url); if (u.host === location.host || siteOf(u) === FROM) return u.pathname + u.search + u.hash; if (task) { u.searchParams.set('from', FROM); u.searchParams.set('task', task); } return '/go/' + (FROM === 'iap' ? 'linkspin' : 'iap') + '?to=' + encodeURIComponent(u.pathname + u.search + u.hash); } catch (e) { return url; } };
// "Refuel LinkSpin this cycle..." gets a way there (2026-10-25): the other site's buy screen, tagged for its arrival strip
const otherBuy = note => { const m = /^Refuel (LinkSpin|InstantAdPay) /.exec(note || ''); if (!m) return '';
const url = m[1] === 'LinkSpin' ? 'https://linkspin.app/credits#refuel' : 'https://instantadpay.com/my#buy';
+1 -1
View File
@@ -27,7 +27,7 @@
: '<p style="margin:0 0 8px">Next refuel day <b>' + esc(v.refuelDayLabel) + '</b> (Central). Window opens ' + esc(v.opensLabel) + ', grace to ' + esc(v.graceLabel) + '.</p>';
if (c.month) h += '<div style="margin:0 0 8px">' + site('InstantAdPay', c.iap, v.minUsd.iap) + site('LinkSpin', c.linkspin, v.minUsd.linkspin) + '</div>';
if (!v.windowOpen && c.month && !c.both) h += '<p class="muted" style="margin:0 0 8px">Refuel ' + (c.linkspin && c.linkspin.refueled ? 'InstantAdPay ($' + v.minUsd.iap + '+)' : 'LinkSpin ($' + v.minUsd.linkspin + '+)') + ' before ' + esc(v.opensLabel) + ' and both sites move to +' + v.next.secondEngine + '%.'
+ (c.linkspin && c.linkspin.refueled ? ' <a href="https://instantadpay.com/my#buy" target="_blank" rel="noopener">Buy on InstantAdPay &#8599;</a>' : '') + '</p>';
+ (c.linkspin && c.linkspin.refueled ? ' <a href="/go/iap?to=%2Fmy%23buy" target="_blank" rel="noopener">Buy on InstantAdPay &#8599;</a>' : '') + '</p>';
if (v.pitStop && (v.pitStop.linkspin || v.pitStop.usedLinkspin)) h += '<p class="muted" style="margin:0 0 8px"><b>Pit Stop</b> ' + (v.pitStop.linkspin ? 'available here: +' + v.pitStop.pct + '% on a $' + v.minUsd.linkspin + '+ top-up, once this cycle. It does not count as your refuel.' : 'used here this cycle.') + '</p>';
h += '<p class="muted" style="margin:0 0 10px">' + (v.freeMiss.available ? 'One free miss left this year.' : 'Free miss for this year used.') + '</p>';
const lsDone = c.linkspin && c.linkspin.refueled;
+30
View File
@@ -0,0 +1,30 @@
// Network sign-in, the sign-in page side (2026-11-12). The SAME file ships in InstantAdPay and LinkSpin (see networksso.js).
// On a sign-in screen with no session: ask /api/sso/status once; { check: true } means bounce once through the other site,
// which signs the member in here if they are signed in there (the server allows one try per browser per 30 minutes and none
// after a sign-out). { hint } means they came from the other site but need the email code here the first time: fill it in.
(function () {
if (window.__netsso) return; window.__netsso = 1;
const BOXES = '#mcEmail,#jnEmail,#siEmail';
function fill(email, peer) {
let n = 0;
const t = setInterval(() => {
const el = document.querySelector(BOXES);
if (el && el.offsetParent !== null) {
clearInterval(t);
if (!el.value) el.value = email;
if (!document.getElementById('nssoNote')) {
const p = document.createElement('p'); p.id = 'nssoNote'; p.className = 'muted small'; p.setAttribute('role', 'note'); p.style.margin = '6px 0';
p.textContent = 'Welcome over from ' + peer + '. The first time here, send yourself a code with the same email to finish signing in. After that, ' + peer + ' signs you in here.';
(el.closest('label') || el).insertAdjacentElement('afterend', p);
}
try { el.focus(); } catch (e) {}
} else if (++n > 60) clearInterval(t);
}, 250);
}
fetch('/api/sso/status', { credentials: 'same-origin', headers: { Accept: 'application/json' }, cache: 'no-store' })
.then(r => r.json()).then(d => {
if (!d) return;
if (d.check) { location.replace('/sso/start?mode=check&to=' + encodeURIComponent(location.pathname + location.search + location.hash)); return; }
if (d.hint) fill(String(d.hint), String(d.peer || 'the other site'));
}).catch(() => {});
})();
+1 -1
View File
@@ -70,7 +70,7 @@
<div id="goalReports"></div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/cr-shell.js?v=20261112sso"></script>
<script src="/assets/conversions.js?v=20261026a"></script>
</body>
</html>
+2 -2
View File
@@ -83,8 +83,8 @@
</div>
<script src="/assets/common.js?v=20261107tg"></script>
<script src="/assets/wallet.js?v=20261021a"></script>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/cr-shell.js?v=20261112sso"></script>
<script src="/assets/credits-screen.js?v=20261107tg"></script>
<script src="/assets/fuel.js?v=20261025ff"></script>
<script src="/assets/fuel.js?v=20261112sso"></script>
</body>
</html>
+1 -1
View File
@@ -30,7 +30,7 @@
<div id="page">
<div class="body" id="helpBody"><div class="panel"><span class="muted">loading</span></div></div>
</div>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/cr-shell.js?v=20261112sso"></script>
<script src="/assets/help-screen.js?v=20261016a"></script>
</body>
</html>
+1 -1
View File
@@ -270,7 +270,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/cr-shell.js?v=20261112sso"></script>
<script src="/assets/links.js?v=20261111big"></script>
<script src="/assets/banner-spin.js?v=20261105sz"></script>
</body>
+1 -1
View File
@@ -1016,7 +1016,7 @@
</div>
</div>
<script src="/assets/common.js?v=20261107tg"></script>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/cr-shell.js?v=20261112sso"></script>
<script src="/assets/tools.js?v=20261011a"></script>
<script src="/assets/wallet.js?v=20261021a"></script>
<script src="/assets/promo.js?v=20261020bs3"></script>
+1 -1
View File
@@ -73,7 +73,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/cr-shell.js?v=20261112sso"></script>
<script src="/assets/pages-screen.js?v=20261021t"></script>
</body>
</html>
+1 -1
View File
@@ -90,7 +90,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/cr-shell.js?v=20261112sso"></script>
<script src="/assets/reports.js?v=20261107nc"></script>
</body>
</html>
+1 -1
View File
@@ -128,7 +128,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/cr-shell.js?v=20261112sso"></script>
<script src="/assets/traffic-guide-data.js?v=20261028a"></script>
<script src="/assets/sources-screen.js?v=20261028a"></script>
</body>
+1 -1
View File
@@ -38,7 +38,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/cr-shell.js?v=20261112sso"></script>
<script src="/assets/team.js?v=20261105fd"></script>
</body>
</html>
+1 -1
View File
@@ -64,7 +64,7 @@
<div class="rules" id="rules"></div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/cr-shell.js?v=20261112sso"></script>
<script src="/assets/traffic-guide-data.js?v=20261028a"></script>
<script src="/assets/traffic-guide.js?v=20261029b"></script>
</body>
+1 -1
View File
@@ -36,7 +36,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/cr-shell.js?v=20261112sso"></script>
<script src="/assets/wallet-screen.js?v=20261023ov"></script>
</body>
</html>
+1 -1
View File
@@ -42,7 +42,7 @@
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261111tank"></script>
<script src="/assets/cr-shell.js?v=20261112sso"></script>
<script src="/assets/zones-screen.js?v=20261010a"></script>
</body>
</html>