Login ad on a clock + 5xYourTeam sign-in loop fix (Marty 2026-11-15)

Login ad: shown on the next member page load whenever the member's last finished view on this site is older than loginAdEveryHours (site setting, default 3), signed in just now or not. One row per member in MySQL (loginadclock.js, table login_ad_views; the same file in LinkSpin): /api/ads/slot?type=login answers notDue inside the window and marks the serve; POST /api/ads/login/seen at the end of the countdown restarts the clock only if the serve was at least dwell-2 s earlier (a reload during the countdown does not skip it). Framed gate, 10 s timer, click relay, frameable fallback, delivery and credit accounting unchanged. Welcome tour still outranks it. Member erase forgets the row. Admin site setting label added.

5xYourTeam loop: IAP answered /sso/check?r=fivex as if LinkSpin asked (fivex was missing from the wallets map), so tokens went to LinkSpin and Marty never got back. fivex added (FIVEX_URL, default https://5xyourteam.com); networksso.js now refuses an unknown r instead of answering as the peer. A pending network hop (nsso.back) is finished after sign-in: the login ad (if due) then /sso/resume; the gate's finish button says Continue and goes back to the site and page the member came from. /api/me carries nssoBack. The session pop-up (welcome.js) waits until the login gate is closed.

networksso.js: loop guard TRIED_AGE 30 min -> 120 s (it blocked Marty's silent sign-in on LinkSpin), NAMES gains fivex. The same file now ships byte-identical in IAP, LinkSpin, VBB, DLB, ViralAdBlitz, DownlineHydra, 5xYourTeam.

Tests: qa/networksso-partner.e2e.mjs (new, in run.sh member): a stand-in wallet partner on its own host; signed in on IAP -> straight back with a session, no dashboard, no ad; signed out -> sign in, login ad, Continue -> back on the partner page; the clock (due, too-soon refused, no re-show on reload or another tab, reload during the countdown brings it back); LinkSpin -> partner. networksso unit test: 2-minute guard, unknown site gets nothing. 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 14:45:12 -06:00
parent ad533a0d56
commit 1a13f53b9c
27 changed files with 332 additions and 37 deletions
+76
View File
@@ -0,0 +1,76 @@
// Login-ad clock (Marty 2026-11-15): "I definitely don't want somebody to not look at a login ad for 7 days... if login ads are
// available on those sites, they need to be seen several times a day." The SAME file ships in InstantAdPay and LinkSpin.
//
// A member sees the login ad on their next member-area page load whenever their last finished login-ad view on THIS site is more
// than loginAdEveryHours old (site setting, default 3), whether or not they just signed in. One row per member in MySQL
// (table login_ad_views: k = lowercased email, or 'w:' + wallet for a wallet-only session; seen_at; served_at).
// due(k) true when the member should get the login ad now (no row, or seen_at older than the setting)
// served(k) the login ad was handed to this member (the countdown starts on their screen)
// seen(k, s) the countdown ended: counts only when a serve to this member happened at least s - 2 seconds ago and within the
// last 30 minutes, so reloading during the countdown never skips the ad
// forget(k) member erase
// No database (local QA): the same rules in memory. A failed database read answers "due": when in doubt the ad shows.
'use strict';
let pool = null, tableReady = null, hours = () => 3;
const mem = new Map(); // k -> { seen, served }
const SERVE_WINDOW = 30 * 60 * 1000;
const keyOf = s => {
if (!s) return '';
const e = String(s.email || '').trim().toLowerCase();
if (e) return e.slice(0, 190);
const a = String(s.address || '').trim().toLowerCase();
return /^0x[0-9a-f]{40}$/.test(a) ? 'w:' + a : '';
};
const everyMs = () => { const h = Number(hours()); return (Number.isFinite(h) && h > 0 ? Math.min(h, 24 * 30) : 3) * 3600 * 1000; };
function init(opts) {
const o = opts || {};
if (typeof o.hours === 'function') hours = o.hours;
const url = String(o.url || '').trim();
pool = null; tableReady = null; mem.clear();
if (url) { const mysql = require('mysql2/promise'); pool = mysql.createPool({ uri: url, connectionLimit: 3, charset: 'utf8mb4' }); }
}
async function table() {
if (!tableReady) tableReady = pool.query('CREATE TABLE IF NOT EXISTS login_ad_views (k VARCHAR(200) PRIMARY KEY, seen_at BIGINT NOT NULL DEFAULT 0, served_at BIGINT NOT NULL DEFAULT 0) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4').catch(e => { tableReady = null; throw e; });
return tableReady;
}
async function row(k) {
if (!pool) return mem.get(k) || null;
await table();
const [r] = await pool.query('SELECT seen_at, served_at FROM login_ad_views WHERE k = ?', [k]);
return r[0] ? { seen: Number(r[0].seen_at) || 0, served: Number(r[0].served_at) || 0 } : null;
}
async function due(k, now) {
if (!k) return false;
const t = now || Date.now();
try { const r = await row(k); return !r || !r.seen || t - r.seen >= everyMs(); } catch (e) { console.error('login-ad clock read', e.message); return true; }
}
async function served(k, now) {
if (!k) return;
const t = now || Date.now();
if (!pool) { const r = mem.get(k) || { seen: 0, served: 0 }; r.served = t; mem.set(k, r); return; }
try { await table(); await pool.query('INSERT INTO login_ad_views (k, served_at) VALUES (?, ?) ON DUPLICATE KEY UPDATE served_at = VALUES(served_at)', [k, t]); }
catch (e) { console.error('login-ad clock serve', e.message); }
}
// -> { ok: true } or { ok: false, reason }
async function seen(k, dwellSec, now) {
if (!k) return { ok: false, reason: 'signed out' };
const t = now || Date.now();
const need = Math.max(0, (Number(dwellSec) || 10) - 2) * 1000;
let r = null; try { r = await row(k); } catch (e) { console.error('login-ad clock read', e.message); return { ok: false, reason: 'store' }; }
if (!r || !r.served || t - r.served > SERVE_WINDOW) return { ok: false, reason: 'not served' };
if (t - r.served < need) return { ok: false, reason: 'too soon' };
if (!pool) { r.seen = t; mem.set(k, r); return { ok: true }; }
try { await pool.query('UPDATE login_ad_views SET seen_at = ? WHERE k = ?', [t, k]); return { ok: true }; }
catch (e) { console.error('login-ad clock seen', e.message); return { ok: false, reason: 'store' }; }
}
async function forget(k) {
if (!k) return;
mem.delete(k);
if (pool) { try { await table(); await pool.query('DELETE FROM login_ad_views WHERE k = ?', [k]); } catch (e) { console.error('login-ad clock forget', e.message); } }
}
module.exports = { init, keyOf, due, served, seen, forget, everyMs };
+5 -4
View File
@@ -3,7 +3,7 @@
//
// One flow, used two ways. R = the site the member is going TO (receiver), P = the site they are signed in on (provider).
// 1. R GET /sso/start?mode=go|check&to=/path R makes a random state, keeps it in a 5-minute HttpOnly cookie (nsso.st),
// sets the loop guard (nsso.tried, 30 minutes) and sends the browser to P.
// sets the loop guard (nsso.tried, 2 minutes) and sends the browser to P.
// 2. P GET /sso/check?st=<state>&to=/path P looks at its OWN member session (never the admin portal). Signed in:
// P mints a token bound to R, the state and the email, and sends the browser
// to R /sso/in?t=<token>. Not signed in: R /sso/in?none=1&to=/path.
@@ -14,7 +14,7 @@
// Outbound links: P GET /go/<peer>?to=/path is the hop a signed-in member's cross-site link points at. Signed out (or the
// secret not set), it is a plain redirect to the other site, so it is always safe to link through.
// Silent check: R's sign-in page calls GET /api/sso/status; { check: true } means "bounce once through P". The guard cookie
// stops a second bounce for 30 minutes, signing out sets nsso.off (12 hours, cleared by the next deliberate cross-site link),
// stops a second bounce for 2 minutes (30 until 2026-11-15, when it blocked Marty's silent sign-in on LinkSpin), signing out sets nsso.off (12 hours, cleared by the next deliberate cross-site link),
// bots and non-page fetches never bounce.
// Token: "v1.<base64url JSON>.<base64url HMAC-SHA256(NETWORK_SSO_SECRET, 'nsso.v1.' + JSON part)>", JSON = { iss, aud, email,
// st, to, iat, exp, n[, wallet, name] }. The token grants a plain member session and nothing else: no wallet action, payout or purchase rides on it.
@@ -36,10 +36,10 @@ const SKEW = 30 * 1000; // clock skew allowed between the two ser
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 TRIED_AGE = 120; // seconds: one silent check per browser per 2 minutes (loop guard only; 30 minutes until 2026-11-15)
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', downlinehydra: 'DownlineHydra' }; // vbb = Viral Banner Blitz, a wallet site like Downline Banners (2026-11-14); viraladblitz = ViralAdBlitz, a wallet site like VBB (2026-11-15); downlinehydra = DownlineHydra (2026-11-15)
const NAMES = { iap: 'InstantAdPay', linkspin: 'LinkSpin', bannerline: 'Downline Banners', vbb: 'Viral Banner Blitz', viraladblitz: 'ViralAdBlitz', downlinehydra: 'DownlineHydra', fivex: '5xYourTeam' }; // vbb = Viral Banner Blitz, a wallet site like Downline Banners (2026-11-14); viraladblitz = ViralAdBlitz, a wallet site like VBB (2026-11-15); downlinehydra = DownlineHydra (2026-11-15); fivex = 5xYourTeam (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,
@@ -177,6 +177,7 @@ async function handle(req, res, u) {
const to = safePath(u.searchParams.get('to'), '/');
const r = String(u.searchParams.get('r') || '');
const wb = r && r !== C.peer ? walletBase(r) : null; // a wallet site asking: the token carries the wallet
if (r && r !== C.peer && !wb) { log('check: unknown site asking, nothing sent', null, r.slice(0, 20)); return go(res, C.defaultPath); } // never answer an unknown site as if the peer asked (2026-11-15: 5xYourTeam was sent to LinkSpin)
const base = wb ? wb() : C.peerBase(), aud = wb ? r : C.peer, forName = NAMES[aud] || aud;
const none = base + '/sso/in?none=1&to=' + encodeURIComponent(to);
if (!enabled() || !/^[a-f0-9]{32}$/.test(st)) return go(res, none);
+2 -2
View File
@@ -652,8 +652,8 @@
</div>
</div>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261101th"></script>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261115la"></script>
<script src="/assets/admin-kb.js?v=20261020kb"></script>
<script src="/assets/admin.js?v=20261112txt"></script><script src="/assets/admin-sponsorcheck.js?v=20261107tg"></script><script src="/assets/admin-kits.js?v=20261101th"></script>
<script src="/assets/admin.js?v=20261115la"></script><script src="/assets/admin-sponsorcheck.js?v=20261107tg"></script><script src="/assets/admin-kits.js?v=20261101th"></script>
</body>
</html>
+1 -1
View File
@@ -1202,7 +1202,7 @@
}));
// site settings: key / value rows; booleans as checkboxes, numbers stay numbers
const SITE_META = { noPayoutIds: 'No-payout positions (member #s, comma): linkage only, no buys from them, no joins routed under them', siteName: 'Site name', tagline: 'Tagline', rehearsal: 'Testnet rehearsal banner', defaultSponsorId: 'Fallback sponsor (member #)', walletConnectProjectId: 'WalletConnect project id', moonpayPublicKey: 'MoonPay public key', telegramBotToken: 'Telegram proof feed: bot token', telegramChatId: 'Telegram proof feed: chat id', telegramTopicId: 'Telegram proof feed: topic id (optional)', telegramEvents: 'Telegram proof feed: events (payouts | payouts+purchases | all)', telegramCtaUrl: 'Telegram proof feed: join link under each post', aiCreditsPerGen: 'AI Copy Engine: credits per generation after the free allowance', aiFreeSurge: 'AI Copy Engine: free generations a month at Surge', aiFreeCircuit: 'AI Copy Engine: free generations a month at Circuit', aiFreeNexus: 'AI Copy Engine: free generations a month at Nexus', snapshotEnabled: 'Daily growth snapshot to Telegram (1/0)', snapshotHourUtc: 'Daily growth snapshot: hour (UTC; 14 = 9 AM Central)', snapshotTargets: 'Targets for milestones + daily snapshot: feed = main group, support = IAP support topic, echo = shared payments topic (comma list)', pipelineMode: 'Pipeline board: off (coming soon card) | preview (admin account only) | on (everyone)', pipelineEta: 'Pipeline: opening date shown on the coming-soon card (e.g. Sep 28)', memberWeeklyEmail: 'Weekly member email to everyone active (1) or only sponsors with a line (0)', leaderboardWeeklyPrize: 'Leaderboard: weekly prize text (optional; blank shows the credit ladder)', leaderboardMonthlyPrize: 'Leaderboard: monthly prize text (optional)', leaderboardWeeklyCredits: 'Leaderboard: weekly credits for 1st,2nd,3rd… (e.g. 1000,500,250; blank = none)', leaderboardMonthlyCredits: 'Leaderboard: monthly credits for 1st,2nd,3rd… (e.g. 5000,2500,1000)', leaderboardAnnounceGeneral: 'Leaderboard: announce winners in the main group too (1/0)', telegramSupportChatId: 'Telegram support topic: chat id (milestones + daily snapshot)', telegramSupportTopicId: 'Telegram support topic: topic id', telegramEchoChatId: 'Telegram echo (shared payments topic): chat id', telegramEchoTopicId: 'Telegram echo: topic id', telegramEchoEvents: 'Telegram echo: events (payouts | payouts+purchases | all)', legacyCreditsAdvertiser: 'Legacy welcome credits: former advertisers', legacyCreditsEarner: 'Legacy welcome credits: former earners', pnlFixedMonthlyUsd: 'P&L: fixed monthly cost (USD)' };
const SITE_META = { loginAdEveryHours: 'Login ad: show again on the next member page once the last finished view is this many hours old (default 3)', noPayoutIds: 'No-payout positions (member #s, comma): linkage only, no buys from them, no joins routed under them', siteName: 'Site name', tagline: 'Tagline', rehearsal: 'Testnet rehearsal banner', defaultSponsorId: 'Fallback sponsor (member #)', walletConnectProjectId: 'WalletConnect project id', moonpayPublicKey: 'MoonPay public key', telegramBotToken: 'Telegram proof feed: bot token', telegramChatId: 'Telegram proof feed: chat id', telegramTopicId: 'Telegram proof feed: topic id (optional)', telegramEvents: 'Telegram proof feed: events (payouts | payouts+purchases | all)', telegramCtaUrl: 'Telegram proof feed: join link under each post', aiCreditsPerGen: 'AI Copy Engine: credits per generation after the free allowance', aiFreeSurge: 'AI Copy Engine: free generations a month at Surge', aiFreeCircuit: 'AI Copy Engine: free generations a month at Circuit', aiFreeNexus: 'AI Copy Engine: free generations a month at Nexus', snapshotEnabled: 'Daily growth snapshot to Telegram (1/0)', snapshotHourUtc: 'Daily growth snapshot: hour (UTC; 14 = 9 AM Central)', snapshotTargets: 'Targets for milestones + daily snapshot: feed = main group, support = IAP support topic, echo = shared payments topic (comma list)', pipelineMode: 'Pipeline board: off (coming soon card) | preview (admin account only) | on (everyone)', pipelineEta: 'Pipeline: opening date shown on the coming-soon card (e.g. Sep 28)', memberWeeklyEmail: 'Weekly member email to everyone active (1) or only sponsors with a line (0)', leaderboardWeeklyPrize: 'Leaderboard: weekly prize text (optional; blank shows the credit ladder)', leaderboardMonthlyPrize: 'Leaderboard: monthly prize text (optional)', leaderboardWeeklyCredits: 'Leaderboard: weekly credits for 1st,2nd,3rd… (e.g. 1000,500,250; blank = none)', leaderboardMonthlyCredits: 'Leaderboard: monthly credits for 1st,2nd,3rd… (e.g. 5000,2500,1000)', leaderboardAnnounceGeneral: 'Leaderboard: announce winners in the main group too (1/0)', telegramSupportChatId: 'Telegram support topic: chat id (milestones + daily snapshot)', telegramSupportTopicId: 'Telegram support topic: topic id', telegramEchoChatId: 'Telegram echo (shared payments topic): chat id', telegramEchoTopicId: 'Telegram echo: topic id', telegramEchoEvents: 'Telegram echo: events (payouts | payouts+purchases | all)', legacyCreditsAdvertiser: 'Legacy welcome credits: former advertisers', legacyCreditsEarner: 'Legacy welcome credits: former earners', pnlFixedMonthlyUsd: 'P&L: fixed monthly cost (USD)' };
function drawSite() {
const wrap = $('siteForm');
wrap.innerHTML = Object.entries(siteObj).map(([k, v]) => '<div class="kv-row"><span class="k" title="' + esc(k) + '">' + esc(SITE_META[k] || humanize(k)) + '</span>'
+17 -6
View File
@@ -1009,9 +1009,11 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
render.welcomed = true;
history.replaceState(null, '', '/my' + (location.hash || ''));
(async () => {
try { if (!(await showGauntlet())) await showLoginAd(); } catch (e) {}
try { if (await showGauntlet()) showLoginAd.asked = true; else await showLoginAd(); } catch (e) {}
await render();
})();
} else if (!showLoginAd.asked) { // login ad on the member's clock (Marty 2026-11-15): any page load, signed in just now or not; the server says when it is due
(async () => { try { await showLoginAd(); } catch (e) {} if (me.nssoBack && me.username) location.href = '/sso/resume'; })();
}
starterBanner(me).catch(() => {});
setPane(location.hash.slice(1) || 'overview');
@@ -3381,9 +3383,10 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
$('mcVerifyBtn').addEventListener('click', busy($('mcVerifyBtn'), async () => {
const r = await api('/api/auth/email/verify', { email: $('mcEmail').value, code: $('mcCode').value, newsletter: !!($('nlOptin') && $('nlOptin').checked) });
IAP.status('You are in.', 'ok');
if (r.next === '/sso/resume' && !r.created) { try { await showLoginAd(); } catch (e) {} location.href = r.next; return; } // another network site asked: login ad if due, then straight back there (2026-11-15)
if (r.next && !r.created) { location.href = r.next; return; } // came from Drip Runner: straight back into the game
if (r.created && !(r.account && r.account.username)) await showOnboard(); // pick a username first
if (!(await showGauntlet())) await showLoginAd(); // welcome tour outranks the login ad
if (await showGauntlet()) showLoginAd.asked = true; else await showLoginAd(); // welcome tour outranks the login ad
await render();
}));
})();
@@ -3424,7 +3427,7 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
$('loginBtn').addEventListener('click', busy($('loginBtn'), async () => {
await api('/api/login', { email: $('liEmail').value, password: $('liPass').value });
IAP.status('Logged in.', 'ok');
if (!(await showGauntlet())) await showLoginAd(); // welcome tour outranks the login ad
if (await showGauntlet()) showLoginAd.asked = true; else await showLoginAd(); // welcome tour outranks the login ad
await render();
}));
$('linkBtn').addEventListener('click', busy($('linkBtn'), async () => {
@@ -3649,10 +3652,15 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
// out sit on the ad itself (Brian Holland, 2026-10-09: "no timer, no X").
// Sites that refuse framing open in a new tab instead, with the bar saying
// so; the timer is not paused, the member is expected to be on the ad.
// 2026-11-15: shown on the member's clock (loginadclock.js, site setting loginAdEveryHours), asked once per page load; the end of
// the countdown tells the server (POST /api/ads/login/seen). back = a network sign-in hop waiting (another site asked): the
// finish button continues it, back to the site and page it came from, never the dashboard (Marty was stranded here from 5xYourTeam).
async function showLoginAd() {
if (showLoginAd.asked) return; showLoginAd.asked = true;
try {
const { ad } = await (await fetch('/api/ads/slot?type=login')).json();
const { ad, back } = await (await fetch('/api/ads/slot?type=login')).json();
if (!ad || !ad.targetUrl) return;
$('lgContinue').textContent = back ? 'Continue' : 'Go to dashboard';
const gate = $('loginGate');
const openBtn = $('lgOpen');
const goBtn = $('lgContinue');
@@ -3675,6 +3683,7 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
if (frame) { frame.hidden = true; frame.src = 'about:blank'; }
if (body) body.hidden = false;
openBtn.disabled = false;
const pop = document.querySelector('.iap-welcome'); if (pop) pop.style.display = 'none'; // the session pop-up waits until the login ad is done (welcome.js holds new ones back too)
gate.hidden = false;
await new Promise(done => {
openBtn.onclick = () => {
@@ -3698,13 +3707,15 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
clearInterval(t);
timer.textContent = 'Time is up';
timer.classList.add('done');
$('lgStatus').textContent = 'Thanks for the look. Your dashboard is ready.';
fetch('/api/ads/login/seen', { method: 'POST' }).catch(() => {});
$('lgStatus').textContent = back ? 'Thanks for the look. Continue to finish signing in where you came from.' : 'Thanks for the look. Your dashboard is ready.';
goBtn.hidden = false;
}, 1000);
goBtn.onclick = () => done();
goBtn.onclick = () => { if (back) { goBtn.disabled = true; location.href = back; return; } done(); };
};
});
gate.hidden = true;
if (pop) pop.style.display = '';
if (frame) { frame.src = 'about:blank'; frame.hidden = true; }
if (body) body.hidden = false;
$('lgTimer').classList.remove('done');
+2
View File
@@ -33,6 +33,8 @@
function show(f) {
if (document.querySelector('.iap-welcome')) return;
// the login ad has the screen (2026-11-15: it now shows on any dashboard load): wait until it closes, never on top of it
var lg = document.getElementById('loginGate'); if (lg && !lg.hidden) { setTimeout(function () { show(f); }, 1000); return; }
var fri = fridayLine(f);
var back = document.createElement('div');
+1 -1
View File
@@ -143,7 +143,7 @@
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never spend what you cannot afford.</div>
</footer>
</div>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261101th"></script>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261115la"></script>
<script src="/assets/contract.js?v=20260908p"></script>
<script src="/assets/chat.js?v=20261016n"></script>
</body>
+1 -1
View File
@@ -27,7 +27,7 @@
<p class="muted small">You decide whether, and how much, to spend. Never spend more than you can afford to lose.</p>
</div>
</div></section>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261101th"></script>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261115la"></script>
<script src="/assets/legal.js?v=20260908a"></script>
</body>
</html>
+1 -1
View File
@@ -97,7 +97,7 @@
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
</footer>
</div>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261101th"></script>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261115la"></script>
<script src="/assets/netline.js?v=20261115nr" data-site="iap"></script>
</body>
</html>
+1 -1
View File
@@ -506,7 +506,7 @@
</div>
</section>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261101th"></script>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261115la"></script>
<script src="/assets/wallet.js?v=20260909c"></script>
<script src="/assets/home.js?v=20261027tb"></script>
<script src="/assets/chat.js?v=20261016n"></script>
+1 -1
View File
@@ -158,7 +158,7 @@
InstantAdPay · <a href="/contract">Contract</a> · <a href="/terms">Terms</a> · <a href="/privacy">Privacy</a> · <a href="/disclaimer">Disclaimer</a>
</div>
</div>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261101th"></script>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261115la"></script>
<script src="/assets/join.js?v=20261107nc"></script>
</body>
</html>
+1 -1
View File
@@ -106,7 +106,7 @@
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
</footer>
</div>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261101th"></script>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261115la"></script>
<script src="/assets/launch.js?v=20260915b"></script>
</body>
</html>
+1 -1
View File
@@ -41,7 +41,7 @@
<div class="small">InstantAdPay is the Polygon hub of the <a href="https://cryptoteambuild.com" target="_blank" rel="noopener">Crypto Team Build Network</a>.</div>
</footer>
</div>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261101th"></script>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261115la"></script>
<script src="/assets/ledger.js?v=20260906m"></script>
<script src="https://polhunter.com/embed.js" data-slots="1" async></script>
<script src="/assets/chat.js?v=20261016n"></script>
+2 -2
View File
@@ -1306,12 +1306,12 @@
</div>
</div>
</div>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261101th"></script>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261115la"></script>
<script src="/assets/wallet.js?v=20260911a"></script>
<script src="/assets/promo.js?v=20261103gp"></script>
<script src="/assets/support.js?v=20261115cb"></script>
<script src="/assets/netkits.js?v=20261115nk"></script>
<script src="/assets/my.js?v=20261114kes"></script>
<script src="/assets/my.js?v=20261115la"></script>
<script src="/assets/fuel.js?v=20261113sso"></script>
<script src="/assets/engine-room.js?v=20261113sso"></script>
<script src="/assets/netsso.js?v=20261113sso"></script>
+1 -1
View File
@@ -131,7 +131,7 @@
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never spend what you cannot afford to lose.</div>
</footer>
</div>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261101th"></script>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261115la"></script>
<script src="/assets/partners.js?v=20260914a"></script>
<script src="/assets/netline.js?v=20261115nr" data-site="iap"></script>
</body>
+1 -1
View File
@@ -194,7 +194,7 @@
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never spend what you cannot afford.</div>
</footer>
</div>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261101th"></script>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261115la"></script>
<script src="/assets/plays.js?v=20260910b"></script>
</body>
</html>
+1 -1
View File
@@ -32,7 +32,7 @@
<p class="muted small">We use reasonable safeguards, but no system is perfectly secure. Protect your email and your wallet.</p>
</div>
</div></section>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261101th"></script>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261115la"></script>
<script src="/assets/legal.js?v=20260908a"></script>
</body>
</html>
+1 -1
View File
@@ -20,7 +20,7 @@
<div id="supMain"><div class="card"><p class="muted small">Loading…</p></div></div>
<p class="small muted">We will never ask for your recovery phrase or private key, and nobody from InstantAdPay will message you first asking for money or wallet access.</p>
</div></section>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261101th"></script>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261115la"></script>
<script src="/assets/legal.js?v=20260908a"></script>
<script src="/assets/support.js?v=20261115cb"></script>
<script src="/assets/chat.js?v=20261016n"></script>
+1 -1
View File
@@ -42,7 +42,7 @@
<p class="muted small" style="margin-top:18px">See also the <a href="/disclaimer">Disclaimer</a> and <a href="/privacy">Privacy Policy</a>. Questions: the <a href="/support">support page</a> or <a href="mailto:support@instantadpay.com">support@instantadpay.com</a>.</p>
</div>
</div></section>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261101th"></script>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261115la"></script>
<script src="/assets/legal.js?v=20260908a"></script>
</body>
</html>
+1 -1
View File
@@ -35,7 +35,7 @@
<p><a href="/ledger">← Back to the live ledger</a> · <a href="/contract">Read the contract review</a></p>
</div>
</section>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261101th"></script>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261115la"></script>
<script src="/assets/tx.js?v=20260906m"></script>
</body>
</html>
+1 -1
View File
@@ -48,7 +48,7 @@
</div>
</div>
</section>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261101th"></script>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261115la"></script>
<script src="/assets/wall.js?v=20261030pp"></script>
</body>
</html>
+1 -1
View File
@@ -123,7 +123,7 @@
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never share your recovery phrase.</div>
</footer>
</div>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261101th"></script>
<script src="/assets/common.js?v=20261115nr"></script><script src="/assets/welcome.js?v=20261115la"></script>
<script src="/assets/wallets.js?v=20260911b"></script>
</body>
</html>
+185
View File
@@ -0,0 +1,185 @@
// Network sign-in from a partner wallet site (5xYourTeam pattern) through InstantAdPay, with the login ad on its clock (2026-11-15).
// Same file in InstantAdPay and LinkSpin. node qa/networksso-partner.e2e.mjs
// Marty was stranded: 5xYourTeam's "get a position" sent him to sign in through InstantAdPay; IAP answered r=fivex as if LinkSpin
// asked, and after a fresh sign-in the login ad's "Go to dashboard" left him on the IAP dashboard. This boots IAP and LinkSpin on
// throwaway DATA_DIRs plus a stand-in partner (the same networksso.js as a wallet receiver, self 'fivex', on 127.0.0.2: its own
// cookie host) and drives a real browser. Proves:
// A. signed in on IAP (wallet linked): partner /sso/start -> straight back to the partner page with a session, no IAP page, no ad
// B. signed out: partner -> IAP sign-in -> code -> the login ad -> its finish button says Continue -> back on the partner page,
// signed in; the countdown restarted the member's clock (the next ask answers notDue)
// C. the login-ad clock on a plain dashboard load: due -> the gate shows, after the countdown it does not show again on reload
// D. signed in on LinkSpin (wallet linked): partner via=linkspin -> straight back with a session
// No mail key, JSON stores, devCode. Skips when the other repo is not beside this one.
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import crypto from 'node:crypto';
import http from 'node:http';
import { spawn } from 'node:child_process';
import { pathToFileURL } from 'node:url';
import { createRequire } from 'node:module';
const HERE = path.resolve(path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1')), '..');
const HERE_IS_IAP = fs.existsSync(path.join(HERE, 'lssync.js'));
const peerGuess = [process.env.NSSO_PEER_DIR, path.resolve(HERE, HERE_IS_IAP ? '../../linkspin/site' : '../../onchain-ad-membership/site')].filter(Boolean);
const PEER = peerGuess.find(d => fs.existsSync(path.join(d, 'server.js')));
const IAP_DIR = HERE_IS_IAP ? HERE : PEER, LS_DIR = HERE_IS_IAP ? PEER : HERE;
if (!PEER) { console.log('SKIP partner sign-in e2e: the other repo was not found. Set NSSO_PEER_DIR.'); process.exit(0); }
const require = createRequire(import.meta.url);
const PW = process.env.PW || 'D:/Projects/MarketingAgent/qa-tester/node_modules/playwright';
const { chromium } = (await import(pathToFileURL(PW + '/index.js').href)).default;
const { ethers } = require(path.join(IAP_DIR, 'node_modules', 'ethers'));
const SECRET = crypto.randomBytes(24).toString('hex');
const IP = Number(process.env.NSSO_IAP_PORT || 8831), LP = IP + 1, PP = IP + 2;
const IAP = 'http://127.0.0.1:' + IP, LS = 'http://localhost:' + LP, P = 'http://127.0.0.2:' + PP;
const UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36';
let fails = 0; const ok = (c, label, extra) => { console.log((c ? 'PASS ' : 'FAIL ') + label + (extra ? ' ' + extra : '')); if (!c) fails++; };
const sleep = ms => new Promise(r => setTimeout(r, ms));
// an idle keep-alive socket the server closed (5 s default) while the browser launched: the request never reached it, send again
const fetch0 = globalThis.fetch;
const fetch = async (...a) => { for (let i = 0; ; i++) { try { return await fetch0(...a); } catch (e) { if (i >= 3 || !/ECONNRESET|UND_ERR_SOCKET/.test(String((e.cause && (e.cause.code || e.cause.message)) || ''))) throw e; await sleep(300); } } };
const TMP = fs.mkdtempSync(path.join(os.tmpdir(), 'nsso-partner-'));
const logs = { iap: '', ls: '' };
function boot(name, dir, port, extra) {
const data = path.join(TMP, name); fs.mkdirSync(path.join(data, 'uploads'), { recursive: true });
const env = Object.assign({}, process.env, { PORT: String(port), DATA_DIR: data, NODE_ENV: 'development', ADMIN_EMAIL: 'qa-admin@example.com', ADMIN_PASSWORD: 'localtest', DEV_POL_USD: '0.10',
NETWORK_SSO_SECRET: SECRET, SENDGRID_KEY: '', OUTBOUND: '', DATABASE_URL: '', DOCSTORE_URL: '', LS_SYNC_SECRET: '', HUB_ENABLED: '', FIVEX_URL: P }, extra);
const p = spawn(process.execPath, ['server.js'], { cwd: dir, stdio: ['ignore', 'pipe', 'pipe'], env });
p.stdout.on('data', d => logs[name] += d); p.stderr.on('data', d => logs[name] += d); return p;
}
const srvI = boot('iap', IAP_DIR, IP, { LS_URL: LS });
const srvL = boot('ls', LS_DIR, LP, { IAP_URL: IAP });
// the stand-in partner: a wallet receiver exactly like 5xYourTeam (self fivex, asks IAP or LinkSpin, sessions by wallet)
process.env.NETWORK_SSO_SECRET = SECRET;
const N = require(path.join(IAP_DIR, 'networksso.js'));
const PS = new Map(); const sidOf = req => (/(?:^|;\s*)fx\.sid=([a-f0-9]{32})/.exec(req.headers.cookie || '') || [])[1];
N.init({ self: 'fivex', peer: 'iap', peerBase: () => IAP, from: { iap: () => IAP, linkspin: () => LS }, isProd: false, dataDir: path.join(TMP), defaultPath: '/team',
member: async req => { const s = PS.get(sidOf(req)); return s ? { address: s.address } : null; },
accept: async (e, req, v) => (v && v.wallet ? { ok: true } : { fallback: 'no wallet in the token' }),
signIn: async (e, req, v) => { const id = crypto.randomBytes(16).toString('hex'); PS.set(id, { address: v.wallet, via: v.iss }); return 'fx.sid=' + id + '; Path=/; HttpOnly; SameSite=Lax'; },
landing: to => to, signinPath: to => '/signin?to=' + encodeURIComponent(to) });
const partner = http.createServer(async (req, res) => {
const u = new URL(req.url, 'http://x');
if (await N.handle(req, res, u)) return;
if (u.pathname === '/api/whoami') { res.writeHead(200, { 'Content-Type': 'application/json' }); return res.end(JSON.stringify(PS.get(sidOf(req)) || {})); }
res.writeHead(200, { 'Content-Type': 'text/html' }); res.end('<!doctype html><title>partner</title><p id="pg">' + u.pathname + '</p>');
});
await new Promise((r, j) => { partner.once('error', j); partner.listen(PP, '127.0.0.2', r); });
let ipN = 30;
const H = () => ({ 'Content-Type': 'application/json', 'x-forwarded-for': '10.8.0.' + (ipN++), 'User-Agent': UA });
const sidFrom = r => ((r.headers.getSetCookie ? r.headers.getSetCookie() : []).map(c => c.split(';')[0]).find(c => c.startsWith('iap.sid=')) || '').slice('iap.sid='.length);
async function codeSignIn(base, email) {
const h = H();
const s = await fetch(base + '/api/auth/email/start', { method: 'POST', headers: h, body: JSON.stringify({ email, fts: Date.now() - 5000, fage: 5000 }) }); const sj = await s.json();
const dev = (s.headers.getSetCookie ? s.headers.getSetCookie() : []).map(c => c.split(';')[0]).join('; ');
const v = await fetch(base + '/api/auth/email/verify', { method: 'POST', headers: Object.assign({}, h, dev ? { Cookie: dev } : {}), body: JSON.stringify({ email, code: sj.devCode }) });
const sid = sidFrom(v); if (!sid) throw new Error('code sign-in failed on ' + base + ': ' + JSON.stringify(sj) + ' ' + v.status);
// members have a username (the dashboard asks for one before anything else)
const un = 'p' + email.split('@')[0].replace(/[^a-z0-9]/g, '').slice(0, 14) + crypto.randomBytes(2).toString('hex');
const pr = await fetch(base + '/api/my/profile', { method: 'POST', headers: Object.assign(H(), { Cookie: 'iap.sid=' + sid }), body: JSON.stringify({ username: un }) });
if (!pr.ok) throw new Error('username on ' + base + ': ' + pr.status + ' ' + (await pr.text()).slice(0, 120));
return sid;
}
// link a throwaway wallet to the signed-in account (the dashboard's Link wallet: challenge, personal_sign, verify)
async function linkWallet(base, sid) {
const w = ethers.Wallet.createRandom(); const h = Object.assign(H(), { Cookie: 'iap.sid=' + sid });
const ch = await (await fetch(base + '/api/auth/challenge', { method: 'POST', headers: h, body: JSON.stringify({ address: w.address }) })).json();
const v = await fetch(base + '/api/auth/verify', { method: 'POST', headers: h, body: JSON.stringify({ address: w.address, signature: await w.signMessage(ch.message) }) });
const j = await v.json(); if (j.error) throw new Error('wallet link on ' + base + ': ' + j.error);
return { address: w.address.toLowerCase(), sid: sidFrom(v) || sid };
}
const host = base => new URL(base).hostname;
let browser = null;
async function newCtx(sessions) {
const ctx = await browser.newContext({ userAgent: UA });
const add = Object.entries(sessions || {}).map(([base, sid]) => ({ name: 'iap.sid', value: sid, domain: host(base), path: '/' }));
if (add.length) await ctx.addCookies(add);
return ctx;
}
const whoami = async ctx => (await (await ctx.request.get(P + '/api/whoami')).json());
const mainNavs = page => { const n = []; page.on('framenavigated', f => { if (f === page.mainFrame()) n.push(f.url()); }); return n; };
try {
for (let i = 0; i < 240; i++) { let a = false, b = false; try { a = (await fetch(IAP + '/api/config')).ok; } catch (e) {} try { b = (await fetch(LS + '/api/config')).ok; } catch (e) {} if (a && b) break; if (i === 239) throw new Error('servers not up: iap ' + a + ', linkspin ' + b); await sleep(500); }
browser = await chromium.launch();
// a house login ad on IAP (the admin path), so the gate has something to show
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));
// 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';
const wa = await linkWallet(IAP, await codeSignIn(IAP, A));
let ctx = await newCtx({ [IAP]: wa.sid }); let page = await ctx.newPage(); let navs = mainNavs(page);
await page.goto(P + '/sso/start?mode=go&via=iap&to=' + encodeURIComponent('/team?pick=1#buy')); await page.waitForLoadState('domcontentloaded');
let who = await whoami(ctx);
ok(page.url() === P + '/team?pick=1#buy' && who.address === wa.address && who.via === 'iap', 'A. signed in on IAP: back on the partner page signed in as the linked wallet', page.url() + ' ' + JSON.stringify(who));
ok(!navs.some(u => u.startsWith(IAP + '/my')), 'A. no IAP dashboard and no login ad on the way', navs.join(' , '));
ok(/token issued p\*\*\*@example\.com for 5xYourTeam/.test(logs.iap), 'A. IAP logged a token for 5xYourTeam (never "for LinkSpin")');
await ctx.close();
// B. signed out on IAP: sign in there, the login ad shows, its Continue goes back to the partner page
const B = 'partner-b@example.com';
const wb = await linkWallet(IAP, await codeSignIn(IAP, B));
await fetch(IAP + '/api/auth/logout', { method: 'POST', headers: Object.assign(H(), { Cookie: 'iap.sid=' + wb.sid }), body: '{}' });
ctx = await newCtx(); page = await ctx.newPage(); navs = mainNavs(page);
await page.goto(P + '/sso/start?mode=go&via=iap&to=' + encodeURIComponent('/team?pick=2')); await page.waitForSelector('#mcEmail', { timeout: 15000 });
ok(page.url().startsWith(IAP + '/my') && (await ctx.cookies(IAP)).some(c => c.name === 'nsso.back'), 'B. signed out: IAP asks for its sign-in and remembers the trip', page.url());
await page.fill('#mcEmail', B); await page.waitForTimeout(4600); await page.click('#mcSendBtn');
await page.waitForFunction(() => document.getElementById('mcCode') && document.getElementById('mcCode').value.length === 6, null, { timeout: 15000 });
await page.click('#mcVerifyBtn');
await page.waitForSelector('#loginGate:not([hidden])', { timeout: 15000 });
ok(true, 'B. the login ad shows after the fresh sign-in');
await page.click('#lgOpen');
await page.waitForSelector('#lgContinue:not([hidden])', { timeout: 20000 });
ok((await page.textContent('#lgContinue')).trim() === 'Continue', 'B. its finish button continues the trip (not "Go to dashboard")', await page.textContent('#lgContinue'));
await page.click('#lgContinue');
await page.waitForURL(u => String(u).startsWith(P + '/team'), { timeout: 15000 });
who = await whoami(ctx);
ok(page.url() === P + '/team?pick=2' && who.address === wb.address, 'B. back on the partner page it came from, signed in', page.url() + ' ' + JSON.stringify(who));
const again = await (await ctx.request.get(IAP + '/api/ads/slot?type=login')).json();
ok(again.notDue === true && !again.ad, 'B. the countdown restarted the clock: the next ask on IAP is not due', JSON.stringify(again).slice(0, 120));
await ctx.close();
// C. the clock on a plain dashboard load (no sign-in on this page): due -> the gate; after the countdown, a reload shows no gate
const C = 'partner-c@example.com';
const cI = await codeSignIn(IAP, C);
ctx = await newCtx({ [IAP]: cI }); page = await ctx.newPage();
await page.goto(IAP + '/my'); await page.waitForSelector('#loginGate:not([hidden])', { timeout: 15000 });
ok((await page.textContent('#lgContinue')).trim() === 'Go to dashboard', 'C. signed in earlier, first dashboard load: the login ad shows (due), finish says Go to dashboard');
const early = await (await ctx.request.post(IAP + '/api/ads/login/seen')).json();
ok(early.ok === false && early.reason === 'too soon', 'C. telling the server "seen" before the countdown is refused', JSON.stringify(early));
await page.click('#lgOpen', { timeout: 10000 }); await page.waitForSelector('#lgContinue:not([hidden])', { timeout: 20000 }); await page.waitForTimeout(800); await page.click('#lgContinue');
ok(await page.locator('#loginGate').isHidden(), 'C. Go to dashboard closes the gate');
await page.reload(); await page.waitForTimeout(3500);
ok(await page.locator('#loginGate').isHidden(), 'C. a reload inside the setting (3 hours) shows no login ad');
const d2 = await ctx.newPage(); await d2.goto(IAP + '/my'); await d2.waitForTimeout(3000);
ok(await d2.locator('#loginGate').isHidden(), 'C. nor does another tab');
await ctx.close();
// and a reload DURING the countdown does not skip it
const D0 = 'partner-d0@example.com'; const d0 = await codeSignIn(IAP, D0);
ctx = await newCtx({ [IAP]: d0 }); page = await ctx.newPage();
await page.goto(IAP + '/my'); await page.waitForSelector('#loginGate:not([hidden])', { timeout: 15000 }); await page.click('#lgOpen'); await page.waitForTimeout(2000);
await page.reload(); await page.waitForSelector('#loginGate:not([hidden])', { timeout: 15000 });
ok(true, 'C. a reload during the countdown brings the login ad back');
await ctx.close();
// D. signed in on LinkSpin with a wallet: via=linkspin, straight back to the partner
const D = 'partner-d@example.com';
const wd = await linkWallet(LS, await codeSignIn(LS, D));
ctx = await newCtx({ [LS]: wd.sid }); page = await ctx.newPage(); navs = mainNavs(page);
await page.goto(P + '/sso/start?mode=go&via=linkspin&to=' + encodeURIComponent('/team')); await page.waitForLoadState('domcontentloaded');
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');
await ctx.close();
} catch (e) { console.log('FAIL exception', e && e.stack || e, e && e.cause ? 'cause: ' + (e.cause.stack || e.cause) : ''); fails++; }
finally {
try { if (browser) await browser.close(); } catch (e) {}
try { srvI.kill(); } catch (e) {} try { srvL.kill(); } catch (e) {} try { partner.close(); } catch (e) {}
await sleep(500); try { fs.rmSync(TMP, { recursive: true, force: true }); } catch (e) {}
}
if (fails) { for (const k of ['iap', 'ls']) console.log('--- ' + k + ' log (tail)\n' + logs[k].split('\n').filter(l => !/rpc eth_call/.test(l)).slice(-30).join('\n')); }
console.log(fails ? '\n' + fails + ' FAILED' : '\nALL PASSED'); process.exit(fails ? 1 : 0);
+1 -1
View File
@@ -127,7 +127,7 @@ try {
ok(!(await meOf(ctx, LS)).signedIn && page.url() === LS + '/ads' && starts.length === 1, 'signed in nowhere: one bounce, back on the page signed out', starts.length + ' bounce(s), ' + page.url());
ok(await page.locator('#siEmail').isVisible(), 'the normal email-code sign-in shows');
await page.reload(); await page.waitForTimeout(2500);
ok(starts.length === 1, 'reload inside 30 minutes: no second bounce (loop guard)', starts.length + ' bounce(s)');
ok(starts.length === 1, 'reload inside 2 minutes: no second bounce (loop guard)', starts.length + ' bounce(s)');
await page.goto(IAP + '/my'); await page.waitForTimeout(3000);
ok(!(await meOf(ctx, IAP)).signedIn && starts.length === 2 && (await page.locator('#mcEmail').count()) === 1, 'IAP /my signed in nowhere: one bounce, then the normal sign-in', starts.length + ' bounce(s), ' + page.url());
await ctx.close();
+4 -2
View File
@@ -78,14 +78,14 @@ const b64u = b => Buffer.from(b).toString('base64').replace(/=+$/, '').replace(/
r = await call(R('/sso/start?to=/my', '', undefined, { 'sec-fetch-dest': 'empty' }));
ok(r.loc === '/my' && !r.set.length, 'a fetch (not a page load) never bounces');
r = await call(R('/sso/start?to=/my', 'nsso.tried=1'));
ok(r.loc === '/my', 'loop guard: a second silent check inside 30 minutes goes straight to the page');
ok(r.loc === '/my', 'loop guard: a second silent check inside 2 minutes goes straight to the page');
r = await call(R('/sso/start?to=/my', 'nsso.off=1'));
ok(r.loc === '/my', 'after a sign-out here: no silent check');
r = await call(R('/sso/start?mode=go&to=/my', 'nsso.off=1'));
ok(/^https:\/\/ls\.example\/sso\/check\?st=[a-f0-9]{32}&to=%2Fmy&m=go$/.test(r.loc) && r.set.some(c => /^nsso\.off=;/.test(c)), 'a deliberate link from the other site still signs in after a sign-out (and lifts the 12-hour pause)');
r = await call(R('/sso/start?to=https://evil.example'));
const stc = (r.set.find(c => c.startsWith('nsso.st=')) || '').split(';')[0].split('=')[1];
ok(/^[a-f0-9]{32}$/.test(stc) && r.set.some(c => /^nsso\.tried=1;.*Max-Age=1800/.test(c)) && r.set.every(c => /HttpOnly/.test(c) && /Secure/.test(c)) && r.loc.endsWith('&to=%2Fmy'), '/sso/start: HttpOnly state + 30-minute guard, off-site path replaced', r.loc);
ok(/^[a-f0-9]{32}$/.test(stc) && r.set.some(c => /^nsso\.tried=1;.*Max-Age=120/.test(c)) && r.set.every(c => /HttpOnly/.test(c) && /Secure/.test(c)) && r.loc.endsWith('&to=%2Fmy'), '/sso/start: HttpOnly state + 2-minute guard, off-site path replaced', r.loc);
r = await call(R('/sso/start?to=/my', 'sid=tok-a'));
ok(r.loc === '/my' && !r.set.length, 'already signed in here: no bounce');
r = await call(R('/sso/check?st=' + st + '&to=/ads'));
@@ -95,6 +95,8 @@ const b64u = b => Buffer.from(b).toString('base64').replace(/=+$/, '').replace(/
r = await call(R('/sso/check?st=' + st + '&to=/ads', 'sid=tok-a'));
const issued = new URL(r.loc).searchParams.get('t');
ok(r.loc.startsWith('https://ls.example/sso/in?t=v1.') && N.verify(issued, { iss: 'iap', aud: 'linkspin', st }).email === 'a@example.com', 'provider, signed in: a token for the other site only, bound to the state');
r = await call(R('/sso/check?st=' + st + '&r=fivex&to=/team', 'sid=tok-a'));
ok(r.loc === '/my' && !/sso\/in/.test(r.loc), 'provider: a site it does not know (r=fivex with no wallets entry) gets nothing, never a token for the peer (2026-11-15)', r.loc);
// receiver: a LinkSpin-issued token arriving here
const mk = (email, to) => N.mint({ iss: 'linkspin', aud: 'iap', email, st, to });
r = await call(R('/sso/in?t=' + mk('a@example.com', '/my#buy'), 'nsso.st=' + st));
+2
View File
@@ -66,10 +66,12 @@ if [ "$MODE" = "public" ]; then
elif [ "$MODE" = "sso" ]; then
node qa/networksso.test.cjs || status=1
node qa/networksso.e2e.mjs || status=1
node qa/networksso-partner.e2e.mjs || status=1 # a partner wallet site (5xYourTeam pattern) through this site: signed in -> straight back; signed out -> sign-in, login ad, Continue -> back; the login-ad clock
elif [ "$MODE" = "member" ]; then
start_local 8796 && { LOCAL=http://127.0.0.1:8796 node qa/walk.mjs member || status=1; LOCAL=http://127.0.0.1:8796 node qa/member-extra.mjs || status=1; }; stop_local 8796
node qa/networksso.test.cjs || status=1 # network sign-in with the other site: tokens, replay, open redirects, loop guard
node qa/networksso.e2e.mjs || status=1 # both servers locally, a real browser across them (skips if the other repo is not beside this one)
node qa/networksso-partner.e2e.mjs || status=1 # a partner wallet site (5xYourTeam pattern) through this site: signed in -> straight back; signed out -> sign-in, login ad, Continue -> back; the login-ad clock
node qa/tank-hold.mjs || status=1
node qa/draft-partner.test.mjs || status=1 # 5xYourTeam draft partner routes (DRAFT_E2E_PORT, default 8825)
node qa/walletnudge.test.cjs || status=1
+20 -4
View File
@@ -56,6 +56,7 @@ const lsconv = require('./lsconv'); // conversion tracking: ad click ids pushed
const lsreport = require('./lsreport'); // conversion linkage: the LinkSpin click on the account, sign-up / wallet / purchase reported, reporting only (2026-11-07)
const lsinbound = require('./lsinbound'); // reverse registry sync: LinkSpin-first members arrive as waiting accounts (2026-10-15)
const draftpartner = require('./draftpartner'); // 5xYourTeam The Draft: signed pool / adopt / release / status on the network tank (2026-11-15, needs DRAFT_PARTNER_SECRET)
const loginClock = require('./loginadclock'); // login ads on a clock, not only at sign-in (Marty 2026-11-15): see loginadclock.js
const erase = require('./erase'); // member erase (2026-11-15, LS-1021): POST /api/admin/erase + the hub's member.erased event
const hubsync = require('./hubsync'); // network hub: members from other doors arrive as waiting accounts, ours are reported (2026-11-12, only with HUB_ENABLED)
const SF = require('./sponsorfollow'); // deliberate sponsor changes follow to LinkSpin until chain-bound + one network tank (2026-10-22)
@@ -65,6 +66,7 @@ const LS_BASE = () => String(process.env.LS_URL || 'https://linkspin.app').repla
const BL_BASE = () => String(process.env.BL_URL || 'https://downlinebanners.com').replace(/\/+$/, ''); // Downline Banners (network sign-in by wallet, 2026-11-13)
const VBB_BASE = () => String(process.env.VBB_URL || 'https://viralbannerblitz.com').replace(/\/+$/, ''); // Viral Banner Blitz (network sign-in by wallet, 2026-11-14)
const VAB_BASE = () => String(process.env.VAB_URL || 'https://viraladblitz.com').replace(/\/+$/, ''); // ViralAdBlitz (network sign-in by wallet, 2026-11-15; VAB_URL = the staging host until the domain switch)
const FIVEX_BASE = () => String(process.env.FIVEX_URL || 'https://5xyourteam.com').replace(/\/+$/, ''); // 5xYourTeam (network sign-in by wallet, 2026-11-15: it asked with r=fivex and was answered as LinkSpin)
const DH_BASE = () => String(process.env.DH_URL || 'https://downlinehydra.com').replace(/\/+$/, ''); // DownlineHydra (network sign-in, 2026-11-15; DH_URL = https://dh.saasy.top until the domain switch)
// Refuel spots (Marty 2026-11-13: paid from the company fee share, $50+): refuel.js calls this once per counted $50+ refuel tx
// (either site). Downline Banners buys the spot for the member's main wallet from the engine wallet (its refuelspots.js), with
@@ -611,7 +613,7 @@ async function boot() {
// only (the admin portal is never shared); an account that is not here yet, or is still a waiting LinkSpin/BTC4Hits account,
// gets the normal email-code sign-in with the email filled in, so every new-account check (anti-fraud, sponsor) runs as before.
networksso.init({ self: 'iap', peer: 'linkspin', peerBase: LS_BASE, isProd: IS_PROD, dataDir: DATA_DIR, db, defaultPath: '/my',
wallets: { bannerline: BL_BASE, vbb: VBB_BASE, viraladblitz: VAB_BASE, downlinehydra: DH_BASE }, // Downline Banners members are wallets: vouch for the wallet they signed in with, else the account's linked one
wallets: { bannerline: BL_BASE, vbb: VBB_BASE, viraladblitz: VAB_BASE, downlinehydra: DH_BASE, fivex: FIVEX_BASE }, // Downline Banners members are wallets: vouch for the wallet they signed in with, else the account's linked one
wallet: async s => { const a = await accounts.byEmail(s.email); const addr = String(s.address || (a && a.address) || '').toLowerCase(); return addr ? { address: addr, name: (a && a.username) || '' } : null; },
member: async req => { // a wallet sign-in carries the address, not the email: find the account that owns the wallet (2026-11-13)
const s = await auth.fromRequest(req); if (!s) return null;
@@ -635,6 +637,7 @@ async function boot() {
signinPath: to => { const x = new URL(to, 'http://x'); return x.pathname === '/my' ? '/my' + x.hash : '/my'; } });
accounts.init({ dataDir: DATA_DIR });
ads.init({ dataDir: DATA_DIR, chain, tiers: () => geo.tierLists(siteConfig()) });
loginClock.init({ url: process.env.DATABASE_URL || process.env.DOCSTORE_URL, hours: () => siteConfig().loginAdEveryHours });
mailer.init({ dataDir: DATA_DIR });
messages.init({ dataDir: DATA_DIR });
reports.init({ dataDir: DATA_DIR });
@@ -755,7 +758,7 @@ async function boot() {
'tank-ready.json': tank._ready, ...(db.enabled() ? {} : { 'tank.json': tank._json }),
...(hubsync.enabled() ? { 'hubsync.json': { state: hubsync._state, save: hubsync._save } } : {}) },
reload: { 'legacy.json': () => legacy.reload(), 'legacy-grants.json': () => legacy.reload() },
forget: [email => lssync._forget(email), email => { if (hubsync.enabled()) hubsync._forgetHeld(email); }] });
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(); }
// 5xYourTeam draft picks (draftpartner.js, 2026-11-15): the routes answer 503 until DRAFT_PARTNER_SECRET is set; the pool stays empty
@@ -916,6 +919,7 @@ function siteConfig() {
memberWeeklyEmail: '0', // 1 = the weekly 'Your week on InstantAdPay' email goes to every active member, not only sponsors with a line
noPayoutIds: '25', // positions kept for linkage only (compromised wallets): no buys signed from them, no new joins routed under them or their upline chain (Marty, 2026-09-14)
leaderboardWeeklyPrize: '', leaderboardMonthlyPrize: '', leaderboardWeeklyCredits: '1000,500,250', leaderboardMonthlyCredits: '5000,2500,1000', leaderboardAnnounceGeneral: '1', // referral contest prizes (text shown on /leaderboard; credits granted to the winner automatically at rollover)
loginAdEveryHours: 3, // login ad: shown again on the next member page once the last finished view is this many hours old (Marty 2026-11-15)
tankAdoptCap: 10, // holding tank: people one adopter may hold at one time (not yet switched on payouts), Marty 2026-11-11
legacyCreditsAdvertiser: 500, legacyCreditsEarner: 150, // welcome-back credits for listed Faucet Wave / Tier One Ads emails arriving via /from/<brand>
geoTier1: '', // comma-separated ISO country codes; empty = built-in default (US, CA, GB, AU, NZ, IE, DE, FR, NL, SE, NO, DK, FI, CH, AT, BE)
@@ -3081,7 +3085,7 @@ const server = http.createServer(async (req, res) => {
if (tankHold) sponsorBlocked = 'tankHold';
else if (!sponsorId && memberId !== _defSpon) { sponsorId = _defSpon; sponsorFallback = true; } // orphan fallback → #1 (never self-sponsor)
if (memberId && acct && acct.memberId !== memberId) accounts.setMemberId(acct.email, memberId).catch(() => {});
const out = { signedIn: true, gkShop: !!parseCookies(req)['iap.gkshop'], sdShop: !!parseCookies(req)['iap.sdshop'], pwMint: !!parseCookies(req)['iap.pwmint'], returnTo: ['turkeydrop', 'polhunter', 'driprunner', 'passivedrip', 'gemkingdom', 'gkshop', 'spookydoors', 'sdshop', 'pwmint', 'polybreak', 'polminer', 'warpwares', 'shardsofvalor', 'forum'].includes(parseCookies(req)['iap.return']) ? parseCookies(req)['iap.return'] : (networksso.pendingBack(req) ? 'nsso' : null), sponsorBlocked, sponsorRouted, sponsorName: spdMe.name || null, email: s.email || (acct && acct.email) || null,
const out = { signedIn: true, nssoBack: networksso.pendingBack(req), gkShop: !!parseCookies(req)['iap.gkshop'], sdShop: !!parseCookies(req)['iap.sdshop'], pwMint: !!parseCookies(req)['iap.pwmint'], returnTo: ['turkeydrop', 'polhunter', 'driprunner', 'passivedrip', 'gemkingdom', 'gkshop', 'spookydoors', 'sdshop', 'pwmint', 'polybreak', 'polminer', 'warpwares', 'shardsofvalor', 'forum'].includes(parseCookies(req)['iap.return']) ? parseCookies(req)['iap.return'] : (networksso.pendingBack(req) ? 'nsso' : null), sponsorBlocked, sponsorRouted, sponsorName: spdMe.name || null, email: s.email || (acct && acct.email) || null,
address: s.address || (acct && acct.address) || null, memberId,
username: (acct && acct.username) || null, theme: (acct && acct.theme) || null,
inviteAsk: !memberId && acct ? tank.inviteAsk(acct) : null, // the Who invited you card (2026-11-07)
@@ -5535,10 +5539,22 @@ const server = http.createServer(async (req, res) => {
// -- ad engine (spec §8b v1: banners, text, login ads)
if (p === '/api/ads/slot' && req.method === 'GET') {
const t = String(u.searchParams.get('type') || 'banner');
if (t === 'login') return json(res, 200, { ad: await loginAdFor(req, 'dashboard') });
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 });
const ad = await loginAdFor(req, 'dashboard');
if (ad && lk) await loginClock.served(lk);
return json(res, 200, { ad, back });
}
const ad = await ads.serve(t, Object.assign({ width: Number(u.searchParams.get('w')) || 0, height: Number(u.searchParams.get('h')) || 0 }, viewerGeo(req)));
return json(res, 200, { ad });
}
if (p === '/api/ads/login/seen' && req.method === 'POST') { // the login-ad countdown ended: restart this member's clock
const s = await auth.fromRequest(req).catch(() => null); const k = loginClock.keyOf(s);
if (!k) return json(res, 401, { error: 'Sign in first.' });
return json(res, 200, await loginClock.seen(k, ads.rates().loginDwellSeconds || 10));
}
m = /^\/api\/ads\/click\/(\d+)$/.exec(p);
if (m && req.method === 'GET') {
// an advertiser opening their own ad's link (from Campaigns, a preview, a test) is not a click: relay it uncounted (Marty, 2026-09-30)