Compare commits
76 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c06c58daf | |||
| e1bee03b95 | |||
| e17d8c4fbb | |||
| 7f57aedcb6 | |||
| 968e60835f | |||
| 911dd623c0 | |||
| 4ccdb914c7 | |||
| 82eab8016b | |||
| 4787390e8b | |||
| d033cc7122 | |||
| efb054d916 | |||
| 32f001aade | |||
| edc484db27 | |||
| 836c7b17c2 | |||
| a01d6f2e8c | |||
| ff568d973c | |||
| 5398faadee | |||
| a7c36a908a | |||
| 92288a30f5 | |||
| d626469980 | |||
| e98a6ebcd8 | |||
| f29f6d1407 | |||
| 9efdfc8ee9 | |||
| 4e2178d779 | |||
| f20062133f | |||
| 24b4ae9134 | |||
| 2d4fc7a9f3 | |||
| 00cfd09c8f | |||
| 4cf3512106 | |||
| 1f584f894f | |||
| ff2f668583 | |||
| fab7732620 | |||
| 5c896cb782 | |||
| 74354346a3 | |||
| dbdeb5a7e6 | |||
| 85d43f7483 | |||
| cedb291aaa | |||
| 574a0cafb1 | |||
| 55d3597f12 | |||
| fe70c857be | |||
| 5585abb663 | |||
| db1ab8359c | |||
| 3eae242dc3 | |||
| 5e8dee7517 | |||
| ffcc0c6339 | |||
| 0013416af7 | |||
| 52eaa20171 | |||
| e00c820d2f | |||
| ef28c16502 | |||
| 3991a5eb79 | |||
| d06394a3d3 | |||
| 2e4d18d77d | |||
| f20e845cf1 | |||
| 5f38c1486d | |||
| 87ea24b8f0 | |||
| 1da37f05ab | |||
| 054ce10985 | |||
| bafeff9bf4 | |||
| 627341e8ad | |||
| 2aa98bdbd2 | |||
| 03284aa281 | |||
| bfbea142b6 | |||
| 973fc80570 | |||
| a845155c88 | |||
| abfb3e3199 | |||
| e61475f89b | |||
| 2e935b3081 | |||
| 769c04e639 | |||
| fb2383ffae | |||
| 0865a4967b | |||
| 7d28ec7b5f | |||
| c0a435343a | |||
| c6b4a84abc | |||
| 7f3f057db0 | |||
| ae3a08b991 | |||
| 4bcc867679 |
+10
-4
@@ -411,6 +411,7 @@ async function signup(email, password, sponsorRef) {
|
|||||||
async function login(email, password) { return impl().login(normEmail(email), String(password || '')); }
|
async function login(email, password) { return impl().login(normEmail(email), String(password || '')); }
|
||||||
// change listener (2026-10-08): LinkSpin's registry sync hears about created / named / wallet-linked / re-sponsored accounts
|
// change listener (2026-10-08): LinkSpin's registry sync hears about created / named / wallet-linked / re-sponsored accounts
|
||||||
let changeFn = null; function onChange(fn) { changeFn = fn; } const changed = e => { try { if (changeFn) changeFn(e); } catch (err) {} };
|
let changeFn = null; function onChange(fn) { changeFn = fn; } const changed = e => { try { if (changeFn) changeFn(e); } catch (err) {} };
|
||||||
|
let walletFn = null; function onWalletLinked(fn) { walletFn = fn; } // reporting only (lsreport.js, 2026-11-07): told after a main wallet is linked, never in the way of it
|
||||||
async function ensure(email, sponsorRef, via, joinedRef) {
|
async function ensure(email, sponsorRef, via, joinedRef) {
|
||||||
const e = normEmail(email);
|
const e = normEmail(email);
|
||||||
if (!EMAIL_RE.test(e)) return { error: 'That email address does not look right.' };
|
if (!EMAIL_RE.test(e)) return { error: 'That email address does not look right.' };
|
||||||
@@ -474,7 +475,7 @@ async function downline(email, depth = 3) {
|
|||||||
async function linkWallet(email, address) {
|
async function linkWallet(email, address) {
|
||||||
const a = normAddr(address);
|
const a = normAddr(address);
|
||||||
if (!/^0x[0-9a-f]{40}$/.test(a)) return { error: 'Bad wallet address.' };
|
if (!/^0x[0-9a-f]{40}$/.test(a)) return { error: 'Bad wallet address.' };
|
||||||
const r = await impl().linkWallet(normEmail(email), a); if (r && !r.error) changed(normEmail(email)); return r;
|
const r = await impl().linkWallet(normEmail(email), a); if (r && !r.error) { changed(normEmail(email)); try { if (walletFn) walletFn(normEmail(email)); } catch (err) {} } return r;
|
||||||
}
|
}
|
||||||
async function count() { return impl().count(); }
|
async function count() { return impl().count(); }
|
||||||
// admin: newest-first account list, and re-pointing a member's sponsor (a
|
// admin: newest-first account list, and re-pointing a member's sponsor (a
|
||||||
@@ -482,8 +483,13 @@ async function count() { return impl().count(); }
|
|||||||
// A waiting account made from a LinkSpin registry row (lsinbound.js, 2026-10-15) that its owner has not signed in to yet.
|
// A waiting account made from a LinkSpin registry row (lsinbound.js, 2026-10-15) that its owner has not signed in to yet.
|
||||||
// It exists so the LinkSpin line is already in place; it is not a member yet, so the sweeps that mail, count or adopt
|
// It exists so the LinkSpin line is already in place; it is not a member yet, so the sweeps that mail, count or adopt
|
||||||
// members (listAll by default) leave it out. It becomes an ordinary account the first time its owner signs in (lastSeen).
|
// members (listAll by default) leave it out. It becomes an ordinary account the first time its owner signs in (lastSeen).
|
||||||
const isUnclaimedShell = a => !!a && a.joinedVia === 'linkspin' && !a.lastSeen && !a.memberId;
|
// BTC4Hits members imported 2026-11-11 (btc4hits-migration, joinedVia 'btc4hits') are the same kind of waiting account.
|
||||||
async function listAll(limit = 500, opts) { const all = await impl().listAll(limit); return opts && opts.shells ? all : all.filter(a => !isUnclaimedShell(a)); }
|
// Network hub members who joined at another door (hubsync.js, 2026-11-12, only while HUB_ENABLED) arrive as joinedVia 'hub'.
|
||||||
|
const SHELL_VIAS = new Set(['linkspin', 'btc4hits', 'hub']);
|
||||||
|
const isUnclaimedShell = a => !!a && SHELL_VIAS.has(a.joinedVia) && !a.lastSeen && !a.memberId;
|
||||||
|
// the limit counts members, not waiting accounts: newest-first LIMIT before the filter let thousands of waiting accounts push
|
||||||
|
// older real members out of the sweeps that read listAll(5000) (tank, coach, leaderboard, Friday, Wednesday)
|
||||||
|
async function listAll(limit = 500, opts) { if (opts && opts.shells) return impl().listAll(limit); const all = await impl().listAll(1e7); return all.filter(a => !isUnclaimedShell(a)).slice(0, limit); }
|
||||||
async function identities() { return impl().identities(); }
|
async function identities() { return impl().identities(); }
|
||||||
async function setSponsorRef(email, ref) { const r = await impl().setSponsorRef(normEmail(email), String(ref || '').trim().toLowerCase().slice(0, 40)); if (r && !r.error) changed(normEmail(email)); return r; }
|
async function setSponsorRef(email, ref) { const r = await impl().setSponsorRef(normEmail(email), String(ref || '').trim().toLowerCase().slice(0, 40)); if (r && !r.error) changed(normEmail(email)); return r; }
|
||||||
|
|
||||||
@@ -509,7 +515,7 @@ async function getChatSettings(email) {
|
|||||||
return { available: a ? a.chatAvailable !== false : true, mutes: await impl().getMutes(String(email || '').toLowerCase()) };
|
return { available: a ? a.chatAvailable !== false : true, mutes: await impl().getMutes(String(email || '').toLowerCase()) };
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { init, signup, login, ensure, onChange, isUnclaimedShell, byEmail, byAddress, byCode, byUsername, byMemberId: id => impl().byMemberId(Number(id) || 0), listAll, identities, setSponsorRef,
|
module.exports = { init, signup, login, ensure, onChange, onWalletLinked, isUnclaimedShell, byEmail, byAddress, byCode, byUsername, byMemberId: id => impl().byMemberId(Number(id) || 0), listAll, identities, setSponsorRef,
|
||||||
setUsername, reservedUsername, setMemberId, namesForMembers, listByReferrer, downline, linkWallet, count,
|
setUsername, reservedUsername, setMemberId, namesForMembers, listByReferrer, downline, linkWallet, count,
|
||||||
setLineBanner: (e, b, t) => impl().setLineBanner(String(e || '').toLowerCase(), b, t),
|
setLineBanner: (e, b, t) => impl().setLineBanner(String(e || '').toLowerCase(), b, t),
|
||||||
setWallOffers: (e, j) => impl().setWallOffers(String(e || '').toLowerCase(), j),
|
setWallOffers: (e, j) => impl().setWallOffers(String(e || '').toLowerCase(), j),
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const path = require('path');
|
|||||||
const { spawn } = require('child_process');
|
const { spawn } = require('child_process');
|
||||||
|
|
||||||
let PUBLIC_DIR = null;
|
let PUBLIC_DIR = null;
|
||||||
const ART = { payouts: { file: 'badge-spark.jpg', ribbonY: 0.728 }, firstBuyer: { file: 'badge-surge.jpg', ribbonY: 0.76 }, level2: { file: 'badge-circuit.jpg', ribbonY: 0.72 }, level3: { file: 'badge-nexus.jpg', ribbonY: 0.73 }, fridays: { file: 'badge-fridays.jpg', ribbonY: 0.719 }, gamepass: { file: 'badge-gamepass.jpg', ribbonY: 0.84 } , refuelStart: { file: 'badge-refuelstart.jpg', ribbonY: 0.735 }, refuel3: { file: 'badge-refuel3.jpg', ribbonY: 0.783 }, refuel6: { file: 'badge-refuel6.jpg', ribbonY: 0.716 }, refuel12: { file: 'badge-refuel12.jpg', ribbonY: 0.744 } };
|
const ART = { payouts: { file: 'badge-spark.jpg', ribbonY: 0.728 }, firstBuyer: { file: 'badge-surge.jpg', ribbonY: 0.76 }, level2: { file: 'badge-circuit.jpg', ribbonY: 0.72 }, level3: { file: 'badge-nexus.jpg', ribbonY: 0.73 }, fridays: { file: 'badge-fridays.jpg', ribbonY: 0.719 }, gamepass: { file: 'badge-gamepass.jpg', ribbonY: 0.84 }, stackpro: { file: 'badge-stackpro.jpg', ribbonY: 0.855 }, refuelStart: { file: 'badge-refuelstart.jpg', ribbonY: 0.735 }, refuel3: { file: 'badge-refuel3.jpg', ribbonY: 0.783 }, refuel6: { file: 'badge-refuel6.jpg', ribbonY: 0.716 }, refuel12: { file: 'badge-refuel12.jpg', ribbonY: 0.744 } };
|
||||||
let FONT;
|
let FONT;
|
||||||
function font() {
|
function font() {
|
||||||
if (FONT !== undefined) return FONT;
|
if (FONT !== undefined) return FONT;
|
||||||
|
|||||||
@@ -105,12 +105,12 @@ function head(o) {
|
|||||||
+ (o.article ? '<meta property="article:published_time" content="' + new Date(o.article.publishedAt || o.article.created).toISOString() + '"><meta property="article:modified_time" content="' + new Date(o.article.updated).toISOString() + '"><meta property="article:author" content="' + esc(AUTHOR) + '">' + (o.article.tags || []).map(t => '<meta property="article:tag" content="' + esc(t) + '">').join('') : '')
|
+ (o.article ? '<meta property="article:published_time" content="' + new Date(o.article.publishedAt || o.article.created).toISOString() + '"><meta property="article:modified_time" content="' + new Date(o.article.updated).toISOString() + '"><meta property="article:author" content="' + esc(AUTHOR) + '">' + (o.article.tags || []).map(t => '<meta property="article:tag" content="' + esc(t) + '">').join('') : '')
|
||||||
+ '<meta name="twitter:card" content="summary_large_image"><meta name="twitter:title" content="' + esc(o.title) + '"><meta name="twitter:description" content="' + esc(o.desc) + '"><meta name="twitter:image" content="' + esc(img) + '">'
|
+ '<meta name="twitter:card" content="summary_large_image"><meta name="twitter:title" content="' + esc(o.title) + '"><meta name="twitter:description" content="' + esc(o.desc) + '"><meta name="twitter:image" content="' + esc(img) + '">'
|
||||||
+ '<link rel="alternate" type="application/rss+xml" title="InstantAdPay blog" href="' + SITE + '/blog/feed.xml"><link rel="icon" type="image/png" href="/logo-icon.png">'
|
+ '<link rel="alternate" type="application/rss+xml" title="InstantAdPay blog" href="' + SITE + '/blog/feed.xml"><link rel="icon" type="image/png" href="/logo-icon.png">'
|
||||||
+ '<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">' + themehead.tag() + '<link rel="stylesheet" href="/assets/site.css?v=20261101th">'
|
+ '<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">' + themehead.tag() + '<link rel="stylesheet" href="/assets/site.css?v=20261112ln">'
|
||||||
+ '<style>.bl{max-width:760px}.bl h1{font-size:clamp(30px,4.6vw,44px);line-height:1.12;margin:10px 0 12px}.bl .meta{color:var(--muted);font-size:14px;margin:0 0 22px}.bl .cover{width:100%;border-radius:14px;border:1px solid var(--line);margin:0 0 26px;display:block}.bl article{font-size:17.5px;line-height:1.7}.bl article p{margin:0 0 18px;max-width:68ch}.bl article h2{font-size:26px;margin:36px 0 12px}.bl article h3{font-size:20px;margin:28px 0 10px}.bl article ul,.bl article ol{margin:0 0 18px 22px;max-width:66ch}.bl article li{margin:6px 0}.bl article blockquote{border-left:4px solid var(--mint);margin:0 0 18px;padding:8px 18px;color:var(--muted);font-style:italic}.bl article img{max-width:100%;border-radius:12px;border:1px solid var(--line)}.bl article a{color:var(--mint)}.bl article pre{background:var(--ground-soft);border:1px solid var(--line);border-radius:10px;padding:14px;overflow:auto;font-size:14px}.bl article table{border-collapse:collapse;width:100%;font-size:15px}.bl article th,.bl article td{border-bottom:1px solid var(--line);padding:8px 10px;text-align:left}.tags a{display:inline-block;font-size:12px;letter-spacing:.06em;text-transform:uppercase;color:var(--mint);border:1px solid var(--mint-line);border-radius:999px;padding:3px 10px;margin:0 6px 6px 0;text-decoration:none}.post-card{display:block;background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:20px 22px;margin:0 0 14px;color:inherit;text-decoration:none}.post-card:hover{border-color:var(--mint)}.post-card h2{font-size:22px;margin:0 0 6px}.post-card p{margin:0;color:var(--muted);font-size:15px;max-width:70ch}.post-card .meta{margin:8px 0 0;font-size:13px}.author{display:flex;gap:14px;align-items:center;border:1px solid var(--line);border-radius:14px;padding:16px 18px;margin:36px 0 0;background:var(--panel)}.author img{width:56px;height:56px;border-radius:50%;object-fit:cover}.author b{display:block}.author span{color:var(--muted);font-size:14px}.share a{margin-right:14px;font-size:14px}.pager{display:flex;justify-content:space-between;margin:26px 0}.related{margin-top:40px}.related h3{margin-bottom:10px}</style>'
|
+ '<style>.bl{max-width:760px}.bl h1{font-size:clamp(30px,4.6vw,44px);line-height:1.12;margin:10px 0 12px}.bl .meta{color:var(--muted);font-size:14px;margin:0 0 22px}.bl .cover{width:100%;border-radius:14px;border:1px solid var(--line);margin:0 0 26px;display:block}.bl article{font-size:17.5px;line-height:1.7}.bl article p{margin:0 0 18px;max-width:68ch}.bl article h2{font-size:26px;margin:36px 0 12px}.bl article h3{font-size:20px;margin:28px 0 10px}.bl article ul,.bl article ol{margin:0 0 18px 22px;max-width:66ch}.bl article li{margin:6px 0}.bl article blockquote{border-left:4px solid var(--mint);margin:0 0 18px;padding:8px 18px;color:var(--muted);font-style:italic}.bl article img{max-width:100%;border-radius:12px;border:1px solid var(--line)}.bl article a{color:var(--mint)}.bl article pre{background:var(--ground-soft);border:1px solid var(--line);border-radius:10px;padding:14px;overflow:auto;font-size:14px}.bl article table{border-collapse:collapse;width:100%;font-size:15px}.bl article th,.bl article td{border-bottom:1px solid var(--line);padding:8px 10px;text-align:left}.tags a{display:inline-block;font-size:12px;letter-spacing:.06em;text-transform:uppercase;color:var(--mint);border:1px solid var(--mint-line);border-radius:999px;padding:3px 10px;margin:0 6px 6px 0;text-decoration:none}.post-card{display:block;background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:20px 22px;margin:0 0 14px;color:inherit;text-decoration:none}.post-card:hover{border-color:var(--mint)}.post-card h2{font-size:22px;margin:0 0 6px}.post-card p{margin:0;color:var(--muted);font-size:15px;max-width:70ch}.post-card .meta{margin:8px 0 0;font-size:13px}.author{display:flex;gap:14px;align-items:center;border:1px solid var(--line);border-radius:14px;padding:16px 18px;margin:36px 0 0;background:var(--panel)}.author img{width:56px;height:56px;border-radius:50%;object-fit:cover}.author b{display:block}.author span{color:var(--muted);font-size:14px}.share a{margin-right:14px;font-size:14px}.pager{display:flex;justify-content:space-between;margin:26px 0}.related{margin-top:40px}.related h3{margin-bottom:10px}</style>'
|
||||||
+ '</head><body><div class="wrap bl">';
|
+ '</head><body><div class="wrap bl">';
|
||||||
}
|
}
|
||||||
function tail() {
|
function tail() {
|
||||||
return '</div><script src="/assets/common.js?v=20261101th"></script><script src="/assets/blog-page.js?v=20261101th"></script></body></html>';
|
return '</div><script src="/assets/common.js?v=20261114ns"></script><script src="/assets/blog-page.js?v=20261101th"></script></body></html>';
|
||||||
}
|
}
|
||||||
const authorBox = () => '<div class="author"><img src="/logo-icon.png" alt="InstantAdPay"><div><b>' + AUTHOR + '</b><span>Founder of InstantAdPay and the Crypto Team Build Network. Twenty-plus years of internet marketing, and a habit of writing down what actually worked.</span></div></div>';
|
const authorBox = () => '<div class="author"><img src="/logo-icon.png" alt="InstantAdPay"><div><b>' + AUTHOR + '</b><span>Founder of InstantAdPay and the Crypto Team Build Network. Twenty-plus years of internet marketing, and a habit of writing down what actually worked.</span></div></div>';
|
||||||
const cardHtml = p => '<a class="post-card" href="/blog/' + esc(p.slug) + '">' + (p.cover ? '<img src="' + esc(p.cover) + '" alt="" loading="lazy" style="width:100%;border-radius:10px;margin:0 0 12px">' : '') + '<h2>' + esc(p.title) + '</h2><p>' + esc(p.excerpt) + '</p><p class="meta">' + fmtDate(p.publishedAt || p.created) + ' · ' + readMinutes(p.body) + ' min read' + (p.tags.length ? ' · ' + p.tags.map(esc).join(', ') : '') + '</p></a>';
|
const cardHtml = p => '<a class="post-card" href="/blog/' + esc(p.slug) + '">' + (p.cover ? '<img src="' + esc(p.cover) + '" alt="" loading="lazy" style="width:100%;border-radius:10px;margin:0 0 12px">' : '') + '<h2>' + esc(p.title) + '</h2><p>' + esc(p.excerpt) + '</p><p class="meta">' + fmtDate(p.publishedAt || p.created) + ' · ' + readMinutes(p.body) + ' min read' + (p.tags.length ? ' · ' + p.tags.map(esc).join(', ') : '') + '</p></a>';
|
||||||
|
|||||||
+80
-23
@@ -19,13 +19,14 @@ const kbSeed = require('./kb-seed');
|
|||||||
|
|
||||||
let DATA_DIR = null;
|
let DATA_DIR = null;
|
||||||
let chain = null;
|
let chain = null;
|
||||||
|
let HERO_SALE = null; // () => gamepass.cfg().heroes + names (server.js): the bonus-hero fact follows heroSales (2026-11-05)
|
||||||
let PASS_TIERS = null; // () => the live pass tiers (server.js, from gamepass.cfg): the tier fact follows the sovTiers switch
|
let PASS_TIERS = null; // () => the live pass tiers (server.js, from gamepass.cfg): the tier fact follows the sovTiers switch
|
||||||
const MODEL = process.env.OPENROUTER_MODEL || 'deepseek/deepseek-v4-flash:nitro';
|
const MODEL = process.env.OPENROUTER_MODEL || 'deepseek/deepseek-v4-flash:nitro';
|
||||||
|
|
||||||
function init(opts) {
|
function init(opts) {
|
||||||
if (opts && typeof opts.gameLive === 'function') GAME_LIVE = opts.gameLive;
|
if (opts && typeof opts.gameLive === 'function') GAME_LIVE = opts.gameLive;
|
||||||
if (opts && typeof opts.refuelOn === 'function') REFUEL_ON = opts.refuelOn;
|
if (opts && typeof opts.refuelOn === 'function') REFUEL_ON = opts.refuelOn;
|
||||||
if (opts && typeof opts.bixLive === 'function') BIX_LIVE = opts.bixLive; DATA_DIR = opts.dataDir; chain = opts.chain; PASS_TIERS = typeof opts.passTiers === 'function' ? opts.passTiers : null; return kb.init({ dataDir: DATA_DIR, seeds: seeds() }); }
|
if (opts && typeof opts.bixLive === 'function') BIX_LIVE = opts.bixLive; DATA_DIR = opts.dataDir; chain = opts.chain; PASS_TIERS = typeof opts.passTiers === 'function' ? opts.passTiers : null; HERO_SALE = typeof opts.heroSale === 'function' ? opts.heroSale : null; return kb.init({ dataDir: DATA_DIR, seeds: seeds() }); }
|
||||||
function key() {
|
function key() {
|
||||||
if (process.env.OPENROUTER_API_KEY) return process.env.OPENROUTER_API_KEY.trim();
|
if (process.env.OPENROUTER_API_KEY) return process.env.OPENROUTER_API_KEY.trim();
|
||||||
try { return fs.readFileSync(path.join(DATA_DIR, 'openrouter.key'), 'utf8').trim(); } catch (e) { return ''; }
|
try { return fs.readFileSync(path.join(DATA_DIR, 'openrouter.key'), 'utf8').trim(); } catch (e) { return ''; }
|
||||||
@@ -33,9 +34,26 @@ function key() {
|
|||||||
function enabled() { return !!key(); }
|
function enabled() { return !!key(); }
|
||||||
|
|
||||||
// ---- canned answers: instant, free, always in voice ----
|
// ---- canned answers: instant, free, always in voice ----
|
||||||
const KNOWLEDGE_DATE = '2026-11-02'; // bump whenever the canned answers / prompt are brought up to date
|
const KNOWLEDGE_DATE = '2026-11-14'; // bump whenever the canned answers / prompt are brought up to date
|
||||||
const SUPPORT_RE = /(contact|reach|email|e-mail|message|talk to|speak (to|with)|get hold of) (the )?(support|admin|administrator|owner|marty|staff|team at instantadpay|someone|a (human|person|real person))|support (email|address|ticket|team|desk)|help ?desk|(open|send|file|submit|raise) (a )?(support )?ticket|\b(human|real person|live (agent|person|chat|support))\b|customer (service|support)|support@|how (do|can) i get (help|support)/i;
|
const SUPPORT_RE = /(contact|reach|email|e-mail|message|talk to|speak (to|with)|get hold of) (the )?(support|admin|administrator|owner|marty|staff|team at instantadpay|someone|a (human|person|real person))|support (email|address|ticket|team|desk)|help ?desk|(open|send|file|submit|raise) (a )?(support )?ticket|\b(human|real person|live (agent|person|chat|support))\b|customer (service|support)|support@|how (do|can) i get (help|support)/i;
|
||||||
const CANNED = [
|
const CANNED = [
|
||||||
|
// network sign-in (2026-11-12): signed in on one of InstantAdPay / LinkSpin = signed in on the other, no code (networksso.js)
|
||||||
|
{ id: 'network-signin', title: 'One sign-in for InstantAdPay and LinkSpin', q: ['Do I have to sign in again on LinkSpin?', 'Why was I signed in on LinkSpin without a code?', 'Is it one sign-in for both sites?'], tags: ['sign in', 'network sign-in', 'linkspin', 'code', 'single sign-on'],
|
||||||
|
re: /(((sign(ed)?|log(ged)?) ?-?(in|on)\b(?! ?-?ads?\b)|\bcodes?\b|password).{0,40}(linkspin|both sites|other site)|(linkspin|both sites|other site).{0,40}((sign(ed)?|log(ged)?) ?-?(in|on)\b(?! ?-?ads?\b)|\bcodes?\b|password)|single sign|sso|one sign.?in|network sign.?in)/i,
|
||||||
|
a: 'One sign-in covers both sites. While you are signed in on InstantAdPay, any link inside your account that opens LinkSpin (the Engine Room, Refuel and the other LinkSpin links) lands you there signed in, with no code. It works the other way too, and if you open the sign-in screen on either site while you are signed in on the other, it signs you in by itself. Both sites use the same email. The one exception: if your account on the other site is not set up yet (for example you joined minutes ago, or it is waiting for your first visit), you get the usual email code that one time, with your email already filled in. Signing out signs you out of that site only, and it stays signed out there until you sign in again or follow a link from the other site. A session still lasts 4 hours on each site. This sign-in never moves money: buying, payouts and wallet actions work exactly as before.' },
|
||||||
|
// Stack POL (2026-11-09): stackpol.com, every POL payout across the network on one page; members opt in to a page in Promo tools
|
||||||
|
// Earners Corner (2026-11-10): earnerscorner.com, the network's forum; sign-in is the InstantAdPay account (DiscourseConnect)
|
||||||
|
{ id: 'earners-corner', title: 'Earners Corner forum', q: ['What is Earners Corner?', 'Is there a forum?', 'How do I sign in to the forum?'], tags: ['earners corner', 'forum', 'earnerscorner', 'community', 'discussion'],
|
||||||
|
re: /\b(earners ?corner|earnerscorner(\.com)?|forum)\b/i,
|
||||||
|
a: 'Earners Corner (https://earnerscorner.com) is our forum for people who earn online: business opportunities, paid to click, traffic exchanges and mailers, crypto earning and wallets, affiliate marketing and tools, with its own section for InstantAdPay, LinkSpin, the games and Stack POL. Anyone can read it. To post, tap Log In there and sign in with your InstantAdPay account, no new password. A new account\'s first post is reviewed before it shows, and referral links belong in the Promote Your Program category. Members with an on-chain position can post links from day one. It also has an assistant that answers questions about the network and finds related threads.' },
|
||||||
|
{ id: 'stack-pol', title: 'Stack POL', q: ['What is Stack POL?', 'How do I get my Stack POL page?', 'What is stackpol.com?'], tags: ['stack pol', 'stackpol', 'payouts', 'ledger', 'promo tools', 'stack pol pro', 'pro'],
|
||||||
|
re: /\b(stack ?pol|stackpol(\.com)?)\b/i,
|
||||||
|
a: 'Stack POL (https://stackpol.com) adds up every POL payout in the network: InstantAdPay and LinkSpin referral payments and the rewards from every game that pays POL. It shows the network total, one page per program, and a public ledger of the latest payouts with the username and a Polygonscan link for every payment. It refreshes every 5 minutes. Every member who has been paid has a page by default at stackpol.com/your-username (Promo tools > Stack POL shows the link and the switch "Show my Stack POL page"). It appears at stackpol.com/your-username within 5 minutes and carries your referral link on every program card. Link a wallet so your payouts can be added up. Switch it off any time. Stack POL Pro is a one-time upgrade: your page then shows your own LinkSpin Banner Spins in its ad spots and your spin links, a purple QR code that opens your page, and blog articles opened from your page show your banners and use your referral links on every button. Any ad package of $10 or more unlocks it automatically, one time, yours for good: Pro switches on when that package settles on chain, and you keep every credit of the package. Credits never unlock it. Pro owners also get the Stack POL Pro badge. The totals are what members were paid, not a promise of what anyone will earn.' },
|
||||||
|
// Shards of Valor bonus heroes (2026-11-05, Marty approved): sold one time. The prices and whether they are on sale live in settings, so
|
||||||
|
// this answer names neither; heroesFact() gives the AI the live state.
|
||||||
|
{ id: 'sov-bonus-heroes', title: 'Shards of Valor bonus heroes', q: ['What are the bonus heroes in Shards of Valor?', 'How do I get Kestrel, Valda, Morag or Roland?', 'Is the hero a subscription?'], tags: ['shards of valor', 'heroes', 'bonus heroes', 'kestrel', 'valda', 'morag', 'roland', 'party'],
|
||||||
|
re: /\b(bonus heroe?s?|kestrel|valda|morag|roland|paladin|barbarian|druid hero|archer hero|hero bundle)\b/i,
|
||||||
|
a: 'Shards of Valor has four bonus heroes: Kestrel the Archer, Valda the Barbarian, Morag the Druid and Roland the Paladin. Kestrel is free for every player: she joins for good once a hero in your party reaches level 20, and she is not sold. Valda, Morag and Roland are each a one-time purchase, yours for good, with no subscription, and there is a bundle of those three. Like a Game Pass, a hero is paid by a new package purchase of at least its price (your sponsor and team are paid as usual and you keep the package credits for your ads); credits you already hold never buy one. When they are on sale they show on the Game Pass card in Members > Games (https://instantadpay.com/my#games) with each price; if you do not see them there, they are not on sale yet. In the game three heroes fight at a time and you pick which three at an inn, a rest spot or a dungeon camp; heroes waiting in the roster keep their gear and level and earn half experience. A bonus hero joins at your party level (at most 20) and is never stronger than the free heroes. The whole story stays free with Aldric, Sylwen and Borin.' },
|
||||||
{ id: 'support', title: 'Contact support or open a ticket', q: ['How do I contact support?', 'How do I talk to a real person?', 'How do I open a support ticket?'], tags: ['support', 'help', 'ticket', 'contact', 'help desk'],
|
{ id: 'support', title: 'Contact support or open a ticket', q: ['How do I contact support?', 'How do I talk to a real person?', 'How do I open a support ticket?'], tags: ['support', 'help', 'ticket', 'contact', 'help desk'],
|
||||||
re: SUPPORT_RE, handoff: true,
|
re: SUPPORT_RE, handoff: true,
|
||||||
a: 'Open Help in your member dashboard (https://instantadpay.com/my#help) to send Marty a ticket, and his replies land right there and in your email. Not signed in or locked out? Use https://instantadpay.com/support, or email support@instantadpay.com. You can also tap "Send this to support" below and I will pass this chat along.' },
|
a: 'Open Help in your member dashboard (https://instantadpay.com/my#help) to send Marty a ticket, and his replies land right there and in your email. Not signed in or locked out? Use https://instantadpay.com/support, or email support@instantadpay.com. You can also tap "Send this to support" below and I will pass this chat along.' },
|
||||||
@@ -62,7 +80,7 @@ const CANNED = [
|
|||||||
a: 'The Level 4 override is 3% of every package bought four levels below you, paid by the company on top of the three levels the contract pays. It goes to the buyer’s 4th sponsor up if that member has 5 or more qualifying buyers (direct referrals who bought $20 or more, the same bar as level 3). If they do not have 5 yet, it moves up the line to the next member who does, up to 25 steps, and each purchase pays one override to one person. It is paid weekly in POL from a company wallet, every Monday after 9 AM Central for the Monday to Sunday week before, through the contract’s award function, so every payment has a Polygon link, and it shows in your Earnings as "Level 4 override". Weekly totals under 0.01 POL carry over to the next week. It counts purchases from the start date on, not earlier ones. It comes from the platform’s 20% share, so the 50/20/10 split does not change. What you earn depends on real purchases in your line; nothing is guaranteed.' },
|
a: 'The Level 4 override is 3% of every package bought four levels below you, paid by the company on top of the three levels the contract pays. It goes to the buyer’s 4th sponsor up if that member has 5 or more qualifying buyers (direct referrals who bought $20 or more, the same bar as level 3). If they do not have 5 yet, it moves up the line to the next member who does, up to 25 steps, and each purchase pays one override to one person. It is paid weekly in POL from a company wallet, every Monday after 9 AM Central for the Monday to Sunday week before, through the contract’s award function, so every payment has a Polygon link, and it shows in your Earnings as "Level 4 override". Weekly totals under 0.01 POL carry over to the next week. It counts purchases from the start date on, not earlier ones. It comes from the platform’s 20% share, so the 50/20/10 split does not change. What you earn depends on real purchases in your line; nothing is guaranteed.' },
|
||||||
{ id: 'game-pass', title: 'Game Pass and daily POL caps', q: ['What is the Game Pass?', 'Why did I hit the daily POL cap in the games?', 'Does a boss reward carry over to the next day?'], tags: ['games', 'game pass', 'daily cap', 'tournament'],
|
{ id: 'game-pass', title: 'Game Pass and daily POL caps', q: ['What is the Game Pass?', 'Why did I hit the daily POL cap in the games?', 'Does a boss reward carry over to the next day?'], tags: ['games', 'game pass', 'daily cap', 'tournament'],
|
||||||
re: /(game ?pass|pass tournament|daily (pol )?cap|pol cap|cap(ped|s)? (on|in|for) (the )?games?|hit (the|my|today.s) (free )?cap|carr(y|ied) (over|forward))/i,
|
re: /(game ?pass|pass tournament|daily (pol )?cap|pol cap|cap(ped|s)? (on|in|for) (the )?games?|hit (the|my|today.s) (free )?cap|carr(y|ied) (over|forward))/i,
|
||||||
a: 'The Game Pass is $5 for 7 days and covers every game in the network on your InstantAdPay account (linked positions included). Free play keeps paying real POL every day; the Pass plays more: higher daily POL caps across every game (1.50 POL a day on repeatable rewards instead of 0.30, and 5 POL a day in all instead of 2), a seat in the weekly Pass Tournament (POL prizes from 5% of pass sales, settled Mondays, top 3 posted to Game Achievements), extra plays or a perk in each game, and the gold Game Pass badge with your name. Per game: PolHunter 5 missions a day instead of 3 plus 2 Ad Detective cases; Gem Kingdom one free continue a day; Spooky Doors one extra door a day; ClutterHunt 2 bonus hints a day; SpellWheel daily streak 0.30 POL instead of 0.15 plus 1 free hint a day; PolyBreak daily gem limit 1.5 POL instead of 0.5 plus an extra paddle every round; POL Miner daily crystal limit 1.5 POL instead of 0.5 plus one free supply crate every day; PolyWarriors a 4th daily mission and defense pays 25 Circuits instead of 15; Drip Runner a free shield at the start of every run; Road Agent 2 patrols a day and 25% more scrap. The full list is on the Game Pass card. Caps are account-wide and reset at midnight Central. A one-time progress reward (a boss, a chapter, a sector) is never lost: whatever is over the day\u2019s total carries to the next day until it is paid in full; repeatable daily play over the daily cap is simply not paid that day. The Pass never changes how much any reward pays, so it is more game, not more payback. Get it in Members > Games > Game Pass: every pass is paid by a NEW package purchase of $5 or more. Tap Get the Pass, then buy the package; the pass starts the moment that purchase settles on chain. Your sponsor and team are paid from that package as usual, and you keep every credit of the package for your ads. Credits you already hold (earned or purchased) never buy a pass, and a package bought before you tapped Get the Pass does not count. Buying again while a pass is active adds 7 days.' },
|
a: 'The Game Pass is $5 for 7 days and covers every game in the network on your InstantAdPay account (linked positions included). Since Nov 2 free play is a taste and the Pass is where the games pay: higher daily POL caps across every game (1.50 POL a day on repeatable rewards instead of 0.30, and 5 POL a day in all instead of 2), a seat in the weekly Pass Tournament (POL prizes from 5% of pass sales, settled Mondays, top 3 posted to Game Achievements), extra plays or a perk in each game, and the gold Game Pass badge with your name. Per game: PolHunter 5 hunts a day at the full 0.05 to 1 POL draw instead of one small free hunt (0.02 to 0.10), plus the weekly prizes, the Mystery Hunt Box and 2 Ad Detective cases; Gem Kingdom one free continue a day; Spooky Doors one extra door a day; ClutterHunt 2 bonus hints a day; SpellWheel daily streak 0.30 POL instead of 0.15 plus 1 free hint a day; PolyBreak daily gem limit 1.5 POL instead of 0.5 plus an extra paddle every round; POL Miner daily crystal limit 1.5 POL instead of 0.5 plus one free supply crate every day; PolyWarriors a 4th daily mission and defense pays 25 Circuits instead of 15; Drip Runner a free shield at the start of every run; Road Agent 2 patrols a day and 25% more scrap. The full list is on the Game Pass card. Caps are account-wide and reset at midnight Central. There is also a free allowance: an account with no pass receives at most 2 POL of game rewards in total, across every game, ever; after that the games keep paying only while a pass is active, and one-time progress rewards earned in the meantime are held and paid once it is. When your allowance is used up, the game you are playing and your Overview tell you, with the amount being held for you. A one-time progress reward (a boss, a chapter, a sector) is never lost: whatever is over the day\u2019s total carries to the next day until it is paid in full; repeatable daily play over the daily cap is simply not paid that day. The Pass never changes how much any reward pays, so it is more game, not more payback. Get it in Members > Games > Game Pass: every pass is paid by a NEW package purchase of $5 or more. Tap Get the Pass, then buy the package; the pass starts the moment that purchase settles on chain. Your sponsor and team are paid from that package as usual, and you keep every credit of the package for your ads. Credits you already hold (earned or purchased) never buy a pass, and a package bought before you tapped Get the Pass does not count. Buying again while a pass is active adds 7 days.' },
|
||||||
// game POL to any linked wallet (Marty, 2026-10-27, "build all three"): sits ahead of the per-game entries so "my Gem Kingdom POL never came" lands here
|
// game POL to any linked wallet (Marty, 2026-10-27, "build all three"): sits ahead of the per-game entries so "my Gem Kingdom POL never came" lands here
|
||||||
{ id: 'game-pol-wallet', title: 'Getting your game POL (link your wallet)', q: ['Why was my game POL not sent?', 'It says POL is waiting for my wallet', 'Do I need to switch on payouts to get game POL?'], tags: ['games', 'game pol', 'link wallet', 'waiting for your wallet', 'not sent'],
|
{ id: 'game-pol-wallet', title: 'Getting your game POL (link your wallet)', q: ['Why was my game POL not sent?', 'It says POL is waiting for my wallet', 'Do I need to switch on payouts to get game POL?'], tags: ['games', 'game pol', 'link wallet', 'waiting for your wallet', 'not sent'],
|
||||||
re: /(pol (is )?waiting for (my |your |a )?wallet|link (my |your |a )?wallet to (receive|get)|(game|games|gem ?kingdom|drip ?runner|clutter ?hunt|spooky ?doors|road ?agent|poly ?break|spell ?wheel|poly ?warriors?)\b[^.?!]{0,60}\bpol\b[^.?!]{0,40}\b(not (been )?(paid|sent)|never (paid|sent|arrived|came)|stuck|waiting|pending|switch on|activat\w*)|(switch on|turn on|activate) payouts?[^.?!]{0,40}\b(game|games)\b[^.?!]{0,20}\bpol\b)/i,
|
re: /(pol (is )?waiting for (my |your |a )?wallet|link (my |your |a )?wallet to (receive|get)|(game|games|gem ?kingdom|drip ?runner|clutter ?hunt|spooky ?doors|road ?agent|poly ?break|spell ?wheel|poly ?warriors?)\b[^.?!]{0,60}\bpol\b[^.?!]{0,40}\b(not (been )?(paid|sent)|never (paid|sent|arrived|came)|stuck|waiting|pending|switch on|activat\w*)|(switch on|turn on|activate) payouts?[^.?!]{0,40}\b(game|games)\b[^.?!]{0,20}\bpol\b)/i,
|
||||||
@@ -78,7 +96,7 @@ const CANNED = [
|
|||||||
a: 'PassiveDrip (https://passivedrip.com) is our earning site, listed under More ways to earn on your Earn tab. Claim the faucet, view paid-to-click ads, complete offers and roll the daily bonus for coins. When your balance reaches 2,000 coins ($1) it is paid out automatically in POL to your wallet on Polygon. Open it from the Earn tab with one tap: it signs you in with your InstantAdPay account, no new password. Add your Polygon wallet there so payouts can reach you. What you earn depends on what you do there; nothing is guaranteed.' },
|
a: 'PassiveDrip (https://passivedrip.com) is our earning site, listed under More ways to earn on your Earn tab. Claim the faucet, view paid-to-click ads, complete offers and roll the daily bonus for coins. When your balance reaches 2,000 coins ($1) it is paid out automatically in POL to your wallet on Polygon. Open it from the Earn tab with one tap: it signs you in with your InstantAdPay account, no new password. Add your Polygon wallet there so payouts can reach you. What you earn depends on what you do there; nothing is guaranteed.' },
|
||||||
{ id: 'spellwheel', title: 'SpellWheel word game', q: ['What is SpellWheel?', 'Is there a daily word puzzle?'], tags: ['games', 'spellwheel', 'word game', 'daily puzzle'],
|
{ id: 'spellwheel', title: 'SpellWheel word game', q: ['What is SpellWheel?', 'Is there a daily word puzzle?'], tags: ['games', 'spellwheel', 'word game', 'daily puzzle'],
|
||||||
re: /(spell ?wheel|letter wheel|word (game|puzzle)|crossword|daily puzzle)/i,
|
re: /(spell ?wheel|letter wheel|word (game|puzzle)|crossword|daily puzzle)/i,
|
||||||
a: 'SpellWheel (https://spellwheel.com, also in Members > Games) is a free word game: swipe the letters on the wheel to fill the crossword grid, travel through six cozy places, and solve a new daily puzzle that everyone gets at the same time. Sign in with your InstantAdPay account right in the game to save progress: clearing levels, finishing a place and solving the daily puzzle each pay POL, collected in your SpellWheel balance and sent to the wallet on your InstantAdPay account automatically. Nothing here is a promise of income.' },
|
a: 'SpellWheel (https://spellwheel.com, also in Members > Games) is a word game: swipe the letters on the wheel to fill the crossword grid, travel through six cozy places, and solve a new daily puzzle that everyone gets at the same time. Guests play the first place. Signing in with your InstantAdPay account opens the second and saves your progress. The Mountain Lodge and the three places after it, plus the POL for the daily puzzle and streaks, are for Game Pass holders. POL is paid for first clears only: a small taste in the first two places, and the full table from the third place on for pass holders, collected in your SpellWheel balance and sent to the wallet on your InstantAdPay account automatically. Nothing here is a promise of income.' },
|
||||||
{ id: 'warpwares', title: 'Warp & Wares season game', q: ['What is Warp & Wares?', 'How does Warp & Wares pay?', 'What is a sponsor dock?'], tags: ['games', 'warp and wares', 'trade wars', 'season', 'sponsor dock', 'turns'],
|
{ id: 'warpwares', title: 'Warp & Wares season game', q: ['What is Warp & Wares?', 'How does Warp & Wares pay?', 'What is a sponsor dock?'], tags: ['games', 'warp and wares', 'trade wars', 'season', 'sponsor dock', 'turns'],
|
||||||
re: /(warp ?(and|&) ?wares|warpwares|trade ?wars|sponsor docks?|bonus turns|trading season)/i,
|
re: /(warp ?(and|&) ?wares|warpwares|trade ?wars|sponsor docks?|bonus turns|trading season)/i,
|
||||||
a: 'Warp & Wares (also in Members > Games) is the network\u2019s 30-day season game in the Trade Wars style. One shared galaxy of 1,200 sectors; every captain gets the same 200 turns a day (reset at midnight Central, never banked) to warp between sectors, buy ore, grain and parts where they are cheap and sell where they are not, haggle, leave fighters and mines to hold sectors, found a base and run a team of up to five with a shared vault. One tap signs you in with your InstantAdPay account. Credits stay in the game; POL is paid for fixed outcomes from a published season budget: the holders of the six landmark sectors and the top traders at each weekly tick (Sundays 9 AM Central), one-time milestones (first base, first garrison, first 100,000 credits traded), and the season-close leaderboard and titles. POL collects in your Warp & Wares balance and is sent automatically to the wallet linked to your InstantAdPay account (one free signature on the Wallet tab). Sponsor markets: docking at one opens a short verified sponsor visit on InstantAdPay and pays bonus turns, the only turns past the daily 200; that is gameplay only, never POL. When the season ends the galaxy resets and the next one starts. Nothing here is a promise of income.' },
|
a: 'Warp & Wares (also in Members > Games) is the network\u2019s 30-day season game in the Trade Wars style. One shared galaxy of 1,200 sectors; every captain gets the same 200 turns a day (reset at midnight Central, never banked) to warp between sectors, buy ore, grain and parts where they are cheap and sell where they are not, haggle, leave fighters and mines to hold sectors, found a base and run a team of up to five with a shared vault. One tap signs you in with your InstantAdPay account. Credits stay in the game; POL is paid for fixed outcomes from a published season budget: the holders of the six landmark sectors and the top traders at each weekly tick (Sundays 9 AM Central), one-time milestones (first base, first garrison, first 100,000 credits traded), and the season-close leaderboard and titles. POL collects in your Warp & Wares balance and is sent automatically to the wallet linked to your InstantAdPay account (one free signature on the Wallet tab). Sponsor markets: docking at one opens a short verified sponsor visit on InstantAdPay and pays bonus turns, the only turns past the daily 200; that is gameplay only, never POL. When the season ends the galaxy resets and the next one starts. Nothing here is a promise of income.' },
|
||||||
@@ -105,13 +123,22 @@ const CANNED = [
|
|||||||
a: 'Members > Games lists the network\u2019s games; one tap signs you in. Drip Runner is a runner game: tap to hop, collect gold drips, dodge the bots, clear chapters. The first clear of each chapter drips a little POL into your game balance, which is sent to your wallet once it reaches the payout line shown in the game. When a run ends you can refuel instead of restarting: a short verified visit to a member\u2019s page (or a member video when you have visited them all), up to 20 refuels a day, separate from your regular Earn visits. Refuels are paid for by advertisers, and a share of that funds the POL pool every drip is paid from, so drips depend on the pool and are small. Share your link from the game lobby: when people on your team refuel, a share of what their refuels add to the pool goes to your game balance. Nothing here is a promise of income. The Games tab also has PolHunter, Gem Kingdom (match-3, POL for first clears of stages and bosses), ClutterHunt (hidden objects), SpellWheel (word puzzle), PolyWarriors (cyberpunk fighting, open Oct 12), PolyBreak (brick breaker, opens Oct 13) and Spooky Doors during Halloween; Road Agent opens Thursday Oct 15. The public list of every game, open now and opening next, is https://instantadpay.com/games (add ?ref=yourusername to keep your referral).' },
|
a: 'Members > Games lists the network\u2019s games; one tap signs you in. Drip Runner is a runner game: tap to hop, collect gold drips, dodge the bots, clear chapters. The first clear of each chapter drips a little POL into your game balance, which is sent to your wallet once it reaches the payout line shown in the game. When a run ends you can refuel instead of restarting: a short verified visit to a member\u2019s page (or a member video when you have visited them all), up to 20 refuels a day, separate from your regular Earn visits. Refuels are paid for by advertisers, and a share of that funds the POL pool every drip is paid from, so drips depend on the pool and are small. Share your link from the game lobby: when people on your team refuel, a share of what their refuels add to the pool goes to your game balance. Nothing here is a promise of income. The Games tab also has PolHunter, Gem Kingdom (match-3, POL for first clears of stages and bosses), ClutterHunt (hidden objects), SpellWheel (word puzzle), PolyWarriors (cyberpunk fighting, open Oct 12), PolyBreak (brick breaker, opens Oct 13) and Spooky Doors during Halloween; Road Agent opens Thursday Oct 15. The public list of every game, open now and opening next, is https://instantadpay.com/games (add ?ref=yourusername to keep your referral).' },
|
||||||
{ id: 'gem-kingdom', title: 'Gem Kingdom match-3 and Crowns', q: ['What is Gem Kingdom?', 'How do I buy Crowns?', 'What do the bosses pay?'], tags: ['games', 'gem kingdom', 'crowns', 'match-3'],
|
{ id: 'gem-kingdom', title: 'Gem Kingdom match-3 and Crowns', q: ['What is Gem Kingdom?', 'How do I buy Crowns?', 'What do the bosses pay?'], tags: ['games', 'gem kingdom', 'crowns', 'match-3'],
|
||||||
re: /(gem ?kingdom|crowns?\b|match.?3|goblin king|ice queen|bog witch|ember dragon|stronghold)/i,
|
re: /(gem ?kingdom|crowns?\b|match.?3|goblin king|ice queen|bog witch|ember dragon|stronghold)/i,
|
||||||
a: 'Gem Kingdom (https://gemkingdom.app) is a free fantasy match-3: match gems so three heroes battle monsters across six chapters (Goblin Woods, the Frozen Pass, the Haunted Swamp, Dragon\u2019s Peak, the Sunken Reef and the Shadow Citadel, where the Shadow King waits), earn stars, and rebuild your Stronghold and forge weapons. It pays POL for first clears only: a little for each stage the first time you clear it, and more for each chapter boss (the Ember Dragon 5 POL, the Kraken 7.5, the Shadow King 10). Replays pay nothing. Rewards go into your game balance and are sent to the wallet on your InstantAdPay account on Polygon once it reaches 0.25 POL. They come from a reward pool funded by a share of Crown purchases, so they pay while the pool has funds (a clear the pool cannot cover pays nothing). Crowns, its upgrade currency, are bought with your InstantAdPay ad credits: tap Buy in the game\u2019s Crown Shop, confirm on InstantAdPay (top up with a pack if you are short), and you land back in the game with the Crowns added. Crowns buy buildings, weapons, battle boosts and a revive after a defeat. Sign in with your InstantAdPay account to save progress, earn badges and appear in the Game Achievements posts in the Crypto Team Build group. After a defeat you can also take a free revive by making a short verified visit to a member’s page. In the shop, Specials has a one-time Hero Bundle ($5: a forge weapon, a building level and 60 Crowns), the Kingdom Pass ($10 for 30 days: 10 Crowns a day, a 25-Crown chest each week and the Royal hero looks, no auto-renew) and Hero looks (Halloween looks for 40 Crowns each through Oct 31, yours to keep). Looks are cosmetic only.' },
|
a: 'Gem Kingdom (https://gemkingdom.app) is a free fantasy match-3: match gems so three heroes battle monsters across six chapters (Goblin Woods, the Frozen Pass, the Haunted Swamp, Dragon\u2019s Peak, the Sunken Reef and the Shadow Citadel, where the Shadow King waits), earn stars, and rebuild your Stronghold and forge weapons. Chapters 1 and 2 are open to everyone; Chapter 3 needs a free InstantAdPay account; Chapters 4 to 6 need the Royal Charter, a one-time $5 (500 purchased credits, paid credits only), which a Kingdom Pass or an active Game Pass also covers. It pays POL for first clears only: a small taste through chapters 1 to 3 (about 1.2 POL in all), and for Charter holders the real ladder in chapters 4 to 6 (the Ember Dragon 3 POL, the Kraken 5, the Shadow King 7.5), never more in total than the player has paid in. Replays pay nothing, and once the Shadow King is beaten the game pays nothing more until new chapters are added. Rewards go into your game balance and are sent to the wallet on your InstantAdPay account on Polygon once it reaches 0.25 POL. They come from a reward pool funded by a share of Crown purchases, so they pay while the pool has funds (a clear the pool cannot cover pays nothing). Crowns, its upgrade currency, are bought with your InstantAdPay ad credits: tap Buy in the game\u2019s Crown Shop, confirm on InstantAdPay (top up with a pack if you are short), and you land back in the game with the Crowns added. Crowns buy buildings, weapons, battle boosts and a revive after a defeat. Sign in with your InstantAdPay account to save progress, earn badges and appear in the Game Achievements posts in the Crypto Team Build group. After a defeat you can also take a free revive by making a short verified visit to a member’s page. In the shop, Specials has a one-time Hero Bundle ($5: a forge weapon, a building level and 60 Crowns), the Kingdom Pass ($10 for 30 days: 10 Crowns a day, a 25-Crown chest each week and the Royal hero looks, no auto-renew) and Hero looks (Halloween looks for 40 Crowns each through Oct 31, yours to keep). Looks are cosmetic only.' },
|
||||||
{ id: 'viral-links', title: 'Viral links: ?ref= on any page', q: ['Can any page be my referral link?', 'Do blog links credit me?'], tags: ['referral', 'viral links', 'ref', 'blog'],
|
{ id: 'viral-links', title: 'Viral links: ?ref= on any page', q: ['Can any page be my referral link?', 'Do blog links credit me?'], tags: ['referral', 'viral links', 'ref', 'blog'],
|
||||||
re: /(viral link|any page.{0,30}(link|referr)|blog.{0,40}(referral|my link|credit)|(referral|invite|my) link.{0,30}(blog|article|any page)|\?ref=|ref=)/i,
|
re: /(viral link|any page.{0,30}(link|referr)|blog.{0,40}(referral|my link|credit)|(referral|invite|my) link.{0,30}(blog|article|any page)|\?ref=|ref=)/i,
|
||||||
a: 'Any page on instantadpay.com becomes your referral link when you add ?ref= and your username to the end, for example instantadpay.com/blog/what-is-a-feeder-program?ref=yourname. Whoever opens it is tagged to you for 30 days, exactly like your invite link, so if they join from any page on the site the credit is yours. Promo tools > Viral links builds these links for you, and every blog article shows your link when you are signed in.' },
|
a: 'Any page on instantadpay.com becomes your referral link when you add ?ref= and your username to the end, for example instantadpay.com/blog/what-is-a-feeder-program?ref=yourname. Whoever opens it is tagged to you for 30 days, exactly like your invite link, so if they join from any page on the site the credit is yours. Promo tools > Viral links builds these links for you, and every blog article shows your link when you are signed in.' },
|
||||||
{ id: 'refuel', title: 'Monthly Refuel streak and Pit Stops', q: ['What is my refuel day?', 'How does the refuel streak work?', 'What is a Pit Stop?', 'How much should I spend each month?'], tags: ['refuel', 'streak', 'pit stop', 'twin engine', 'bonus credits'],
|
{ id: 'refuel', title: 'Monthly Refuel streak and Pit Stops', q: ['What is my refuel day?', 'How does the refuel streak work?', 'What is a Pit Stop?', 'How much should I spend each month?'], tags: ['refuel', 'streak', 'pit stop', 'twin engine', 'bonus credits'],
|
||||||
re: /(refuel(ing)? (day|streak|bonus|window)|my refuel|monthly refuel|pit ?stop|twin engine|both engines|refuel streak|streak bonus|free miss)/i,
|
re: /(refuel(ing)? (day|streak|bonus|window)|my refuel|monthly refuel|pit ?stop|twin engine|both engines|refuel streak|streak bonus|free miss)/i,
|
||||||
a: 'The Monthly Refuel streak rewards members who refuel their ads every month. A counted refuel is a new package of $20 or more on InstantAdPay, or $25 or more on LinkSpin, bought by one of your own positions. Your first one sets your refuel day; the next is due 30 days later, the window opens 5 days before that day and there is a 5-day grace after it (Central time). Each refuel adds bonus ad credits on the site where you bought: month 1 +10%, month 2 +15%, month 3 +20%, month 4 and up +25%. Refuel BOTH sites in the same cycle and each gets +15%, +20%, +30% or +40% (the first site is topped up to that rate), plus a 100-credit Featured bonus on InstantAdPay from month 4 (enough for two Featured days and more). Either site alone keeps your streak going; both sites in a cycle is the bigger bonus. The bonus stacks on Five Dollar Friday and Wired Wednesday. Another $20+/$25+ package on a site you already refueled this cycle, before your next window opens, is a Pit Stop: half your current rate, once per site per cycle, and it does not count as the refuel. Miss the grace and the streak starts again, except for one free miss a year. Badges at your first refuel and at 3, 6 and 12 months. Each counted refuel also unlocks the Refuel Kit for that month: members-only banners (728x90, 300x250, 468x60, 160x600 and 1200x630) with your @name and a QR code to your own link drawn on them, in Promo tools; they stay yours after the month, a 3-month streak adds an animated version and 6 months a custom-banners credit. Your first counted refuel also opens the Engine Room tab in your member area: three plain dials (fuel left on both sites against this cycle’s refuel with days left at your burn, clicks this week with clicks per 1,000 credits, goals this month against a goal you set), warning lights, six part lights with setup links and one next move. Your refuel day, streak, next bonus and Pit Stop status are on the Refuel card on your Overview (with a Refuel LinkSpin link once this site is done for the cycle). Buy here: https://instantadpay.com/my#buy. The full guide, with the flow step by step: https://instantadpay.com/refuel. Bonus credits are ad credits that buy delivery, never cash, and no income is guaranteed.' },
|
a: 'The Monthly Refuel streak rewards members who refuel their ads every month. A counted refuel is a new package of $20 or more on InstantAdPay, or $25 or more on LinkSpin, bought by one of your own positions. Your first one sets your refuel day; the next is due 30 days later, the window opens 5 days before that day and there is a 5-day grace after it (Central time). Each refuel adds bonus ad credits on the site where you bought: month 1 +10%, month 2 +15%, month 3 +20%, month 4 and up +25%. Refuel BOTH sites in the same cycle and each gets +15%, +20%, +30% or +40% (the first site is topped up to that rate), plus a 100-credit Featured bonus on InstantAdPay from month 4 (enough for two Featured days and more). Either site alone keeps your streak going; both sites in a cycle is the bigger bonus. The bonus stacks on Five Dollar Friday and Wired Wednesday. Another $20+/$25+ package on a site you already refueled this cycle, before your next window opens, is a Pit Stop: half your current rate, once per site per cycle, and it does not count as the refuel. Miss the grace and the streak starts again, except for one free miss a year. Badges at your first refuel and at 3, 6 and 12 months. Each counted refuel also unlocks the Refuel Kit for that month: members-only banners (728x90, 300x250, 468x60, 160x600 and 1200x630) with your @name and a QR code to your own link drawn on them, in Promo tools; they stay yours after the month, a 3-month streak adds an animated version and 6 months a custom-banners credit. Your first counted refuel also opens the Engine Room tab in your member area: three plain dials (fuel left on both sites against this cycle’s refuel with days left at your burn, clicks this week with clicks per 1,000 credits, goals this month against a goal you set), warning lights, six part lights with setup links and one next move. Your refuel day, streak, next bonus and Pit Stop status are on the Refuel card on your Overview (with a Refuel LinkSpin link once this site is done for the cycle). Buy here: https://instantadpay.com/my#buy. The full guide, with the flow step by step: https://instantadpay.com/refuel. Bonus credits are ad credits that buy delivery, never cash, and no income is guaranteed. A counted refuel of $50 or more (either site) also earns you one free Downline Banners spot (downlinebanners.com, the network banner board), paid by the company and placed for your main wallet, so link a wallet to receive it.' },
|
||||||
|
{ id: 'downline-banners', title: 'Downline Banners (network banner board)', q: ['What is Downline Banners?', 'How do I use my LinkSpin Banner Spin on Downline Banners?', 'How do I sign in to Downline Banners?'], tags: ['downline banners', 'banner board', 'spot', 'banner spin'],
|
||||||
|
re: /(downline ?banners|banner (board|spot)|banner line)/i,
|
||||||
|
a: 'Downline Banners (https://downlinebanners.com) is the Crypto Team Build Network banner board on Polygon. A $5 spot (paid in POL) buys 300 guaranteed views on the board and a place in one global line; when later spots sell, the contract pays the 10 spots above them and the buyer\u2019s sponsor in the same transaction. Nothing is promised: you are paid only when spots sell after yours. Signed in on InstantAdPay? Open its My Spots page and you arrive signed in as your linked wallet, and your share link uses your InstantAdPay username. In My Spots, the "Use a LinkSpin Banner Spin" button puts one of your 468x60 Banner Spins on a spot in two taps, with click tracking under a Downline Banners source on LinkSpin. A $50+ Monthly Refuel earns one free spot. To promote it: Promo tools > Network sites > Downline Banners (or downlinebanners.com/promote) has your links, creatives in every common size, lines, headlines, an email and posts, all carrying your username.' },
|
||||||
|
{ id: 'viral-banner-blitz', title: 'Viral Banner Blitz (network banner loop)', q: ['What is Viral Banner Blitz?', 'How do I post on Viral Banner Blitz?'], tags: ['viral banner blitz', 'vbb', 'banner loop', '125x125'],
|
||||||
|
re: /(viral ?banner ?blitz|vbb|banner loop)/i,
|
||||||
|
a: 'Viral Banner Blitz (https://viralbannerblitz.com) is the network’s shared loop of 125x125 banners. InstantAdPay and LinkSpin members get one free post credit each day they sign in there (Sign in with InstantAdPay works). Real, verified visitors move the loop; a banner that rides out the end has cycled and earns network ad views, which are advertising, not cash. Weekly leaderboards count the visitors you send and the traffic sources they come from, with a prize pot paid in POL to the top three on each board. Your link is viralbannerblitz.com/?ref=your-username. Promo tools > Network sites > Viral Banner Blitz (or viralbannerblitz.com/promote) has your links, creatives, lines, headlines, an email and posts.' },
|
||||||
|
{ id: 'network-sites-kits', title: 'Promo tools: Network sites', q: ['Where are the Downline Banners and Viral Banner Blitz banners?', 'How do I promote the other network sites?'], tags: ['network sites', 'promo kit', 'promote', 'creatives'],
|
||||||
|
re: /(network sites|promo kit|promote (downline|viral|the other|network))/i,
|
||||||
|
a: 'Members > Promo tools > Network sites shows the promo kits of Downline Banners and Viral Banner Blitz with your InstantAdPay username already in every link: your personal links, creatives in 125x125, 468x60, 728x90, 300x250, 160x600, 1200x630 and 1080x1080 (download, copy the URL or copy ready HTML that links to you), 5 short lines, 3 headlines, an email and 2 social posts. Your username works as your sponsor link on those sites even if you never visited them. Each site keeps its own kit, so the copy here is always the current one; the same kit is on each site’s Promote page. Each link also has a tracked version that goes through LinkSpin first (so the network can see which site sent the visit) and then opens the same page with your username; use either one.' },
|
||||||
{ id: 'wired-wednesday', title: 'Wired Wednesday bonus', q: ['What is Wired Wednesday?', 'What happens on Wednesday?'], tags: ['wired wednesday', 'bonus credits', 'promotion'],
|
{ id: 'wired-wednesday', title: 'Wired Wednesday bonus', q: ['What is Wired Wednesday?', 'What happens on Wednesday?'], tags: ['wired wednesday', 'bonus credits', 'promotion'],
|
||||||
re: /(wired wednesday|wednesday (bonus|promo|deal|special)|what happens on wednesday)/i,
|
re: /(wired wednesday|wednesday (bonus|promo|deal|special)|what happens on wednesday)/i,
|
||||||
a: 'Wired Wednesday: every Wednesday (Central time, midnight to midnight), any ad package from $20 up (the Activation pack and above; there is no $10 pack) earns +25% bonus credits, wired into your balance the moment the purchase settles. They are purchased-grade, so they run on any format, login ads included, and the bonus is labelled in your credit log. The page instantadpay.com/wednesday shows whether it is live now and the next date; add ?ref=yourusername to that address and anyone who joins from it is your referral. Every pack still pays its sponsor line in the same on-chain transaction. Credits buy ad delivery and cannot be withdrawn; no income is guaranteed.' },
|
a: 'Wired Wednesday: every Wednesday (Central time, midnight to midnight), any ad package from $20 up (the Activation pack and above; there is no $10 pack) earns +25% bonus credits, wired into your balance the moment the purchase settles. They are purchased-grade, so they run on any format, login ads included, and the bonus is labelled in your credit log. The page instantadpay.com/wednesday shows whether it is live now and the next date; add ?ref=yourusername to that address and anyone who joins from it is your referral. Every pack still pays its sponsor line in the same on-chain transaction. Credits buy ad delivery and cannot be withdrawn; no income is guaranteed.' },
|
||||||
@@ -119,6 +146,10 @@ const CANNED = [
|
|||||||
re: /(five dollar friday|5 dollar friday|\$5 friday|friday (bonus|promo|deal|special)|what happens on friday)/i,
|
re: /(five dollar friday|5 dollar friday|\$5 friday|friday (bonus|promo|deal|special)|what happens on friday)/i,
|
||||||
a: 'Five Dollar Friday: every Friday (Central time), any ad package from $5 up earns +20% bonus credits, added the moment the purchase settles and labelled in your credit log. The page instantadpay.com/friday shows whether it is live right now and the next date; add ?ref=yourusername to that address and anyone who joins from it is your referral. Every pack pays its sponsor line in the same on-chain transaction, so when the whole network buys on the same day every line gets paid at once. Since 2026-10-23 a $5+ Friday package also gives you a free 7-day Game Pass (once per Friday, all the games); if that package is the one starting a pass you already ordered, it does not add a second week. Five Fridays in a row earn the Five Fridays badge. Buy under My account > Buy packages.' },
|
a: 'Five Dollar Friday: every Friday (Central time), any ad package from $5 up earns +20% bonus credits, added the moment the purchase settles and labelled in your credit log. The page instantadpay.com/friday shows whether it is live right now and the next date; add ?ref=yourusername to that address and anyone who joins from it is your referral. Every pack pays its sponsor line in the same on-chain transaction, so when the whole network buys on the same day every line gets paid at once. Since 2026-10-23 a $5+ Friday package also gives you a free 7-day Game Pass (once per Friday, all the games); if that package is the one starting a pass you already ordered, it does not add a second week. Five Fridays in a row earn the Five Fridays badge. Buy under My account > Buy packages.' },
|
||||||
// 2026-10-23 conversion pixel (LinkSpin counts, IAP shows): Campaigns > Conversion tracking
|
// 2026-10-23 conversion pixel (LinkSpin counts, IAP shows): Campaigns > Conversion tracking
|
||||||
|
// 2026-11-07 conversion linkage (reporting only)
|
||||||
|
{ id: 'network-conversions', title: 'Sign-ups and purchases on your click', q: ['I sent someone and they joined, why do I not see a conversion?', 'Do sign-ups on InstantAdPay show in my LinkSpin reports?', 'Does the landing tag track InstantAdPay purchases?'], tags: ['conversion tracking', 'lsclk', 'landing tag', 'reports', 'join', 'purchase'],
|
||||||
|
re: /((sign.?ups?|joins?|purchases?|sales?|conversions?).{0,40}(show|count|track|see|report).{0,30}(linkspin|reports?|landing tag|bridge|on my click)|(bridge|landing) page.{0,40}(click id|lsclk|track|count)|landing tag.{0,40}(instantadpay|purchases?|sign.?ups?|joins?))/i,
|
||||||
|
a: 'People you send to InstantAdPay or LinkSpin count with no goal and no pixel, as long as the click reaches the join page. With the LinkSpin landing tag on your page, your links to either site carry the click id, also inside a redirect link of your own. A spin link or Banner Spin pointed straight at either site carries it too. We keep the click 30 days and store it on the account at sign-up, then their sign-up, wallet link and each package they buy within 30 days of the click count on your click: a sign-up and a wallet once per click, each package on its own with its USD price. See them on Campaigns > Conversion tracking and in LinkSpin under Reports, Conversions, next to your goals. Your own account is never counted, a button that only runs a script cannot carry the click, and people who joined before 2026-11-07 cannot be matched afterwards. This is reporting only: it never changes who a sponsor is or what anyone is paid.' },
|
||||||
{ id: 'conversion-tracking', title: 'Conversion tracking (goal pixel)', q: ['How do I track conversions?', 'Can I see which ad brought a sign-up or sale?', 'Where do I put the goal pixel?', 'What is the landing tag?', 'How do I set up conversion tracking on WordPress?'], tags: ['conversion tracking', 'goal pixel', 'landing tag', 'cost per goal', 'aweber', 'getresponse', 'wordpress', 'setup guide'],
|
{ id: 'conversion-tracking', title: 'Conversion tracking (goal pixel)', q: ['How do I track conversions?', 'Can I see which ad brought a sign-up or sale?', 'Where do I put the goal pixel?', 'What is the landing tag?', 'How do I set up conversion tracking on WordPress?'], tags: ['conversion tracking', 'goal pixel', 'landing tag', 'cost per goal', 'aweber', 'getresponse', 'wordpress', 'setup guide'],
|
||||||
re: /(conver(sion|t)s?.{0,20}(track|pixel|goal)|track(ing)?.{0,30}(conversions?|sign.?ups?|sales|subscribers|leads)|goal pixel|landing tag|tracking pixel|cost per (goal|lead|sale|sign.?up|conversion)|thank.?you page|lsclk)/i,
|
re: /(conver(sion|t)s?.{0,20}(track|pixel|goal)|track(ing)?.{0,30}(conversions?|sign.?ups?|sales|subscribers|leads)|goal pixel|landing tag|tracking pixel|cost per (goal|lead|sale|sign.?up|conversion)|thank.?you page|lsclk)/i,
|
||||||
a: 'Conversion tracking shows which of your ads bring subscribers and sales, not just clicks. It lives in your dashboard under Campaigns > Conversion tracking (https://instantadpay.com/my#campaigns). Three steps: 1) add a goal, like subscriber or sale (a default value is optional); 2) put the landing tag on the page your ad points to; 3) put the goal pixel on your thank-you page. Every click on your ad carries a click id (lsclk=...), and LinkSpin, our sister site, matches each goal to the click: first by the click id still in the address, then the id the landing tag stored, then LinkSpin\'s cookie, and last a 24-hour match on the same connection and browser (the panel says how sure each kind is). Each goal counts once per click, only within 30 days of a real click on your ad, and each campaign shows its goals and its cost per goal (30 days) in credits: the credits that campaign spent in the same 30 days, divided by its goals. Using Aweber or GetResponse? Set the form\'s thank-you (success) page to a page on YOUR site that carries the goal pixel (Aweber: Thank You Page: custom page; GetResponse: Thank-you page: custom URL). If you cannot change it, the pixel can still count through the cookie or the 24-hour match, just less surely. The Send a test conversion button fires your real pixel in test mode (Last test updates); to check your real thank-you page, add &test=1 to its pixel and open it once. Tests and your own clicks (on your ads, and on your LinkSpin spin links and Banner Spins) never count in your numbers; the card says how many of your own clicks were kept as tests. The step-by-step guide, with copy-paste examples for plain HTML, WordPress, page builders and autoresponder thank-you pages, how to read the report and a troubleshooting checklist: https://instantadpay.com/conversion-tracking' },
|
a: 'Conversion tracking shows which of your ads bring subscribers and sales, not just clicks. It lives in your dashboard under Campaigns > Conversion tracking (https://instantadpay.com/my#campaigns). Three steps: 1) add a goal, like subscriber or sale (a default value is optional); 2) put the landing tag on the page your ad points to; 3) put the goal pixel on your thank-you page. Every click on your ad carries a click id (lsclk=...), and LinkSpin, our sister site, matches each goal to the click: first by the click id still in the address, then the id the landing tag stored, then LinkSpin\'s cookie, and last a 24-hour match on the same connection and browser (the panel says how sure each kind is). Each goal counts once per click, only within 30 days of a real click on your ad, and each campaign shows its goals and its cost per goal (30 days) in credits: the credits that campaign spent in the same 30 days, divided by its goals. Using Aweber or GetResponse? Set the form\'s thank-you (success) page to a page on YOUR site that carries the goal pixel (Aweber: Thank You Page: custom page; GetResponse: Thank-you page: custom URL). If you cannot change it, the pixel can still count through the cookie or the 24-hour match, just less surely. The Send a test conversion button fires your real pixel in test mode (Last test updates); to check your real thank-you page, add &test=1 to its pixel and open it once. Tests and your own clicks (on your ads, and on your LinkSpin spin links and Banner Spins) never count in your numbers; the card says how many of your own clicks were kept as tests. The step-by-step guide, with copy-paste examples for plain HTML, WordPress, page builders and autoresponder thank-you pages, how to read the report and a troubleshooting checklist: https://instantadpay.com/conversion-tracking' },
|
||||||
@@ -145,9 +176,9 @@ const CANNED = [
|
|||||||
{ id: 'split', title: 'How much do I earn: the split', q: ['How much do I earn?', 'What commission do I get?', 'What is the split on a package?'], tags: ['earn', 'commission', 'split', 'percent', 'levels'],
|
{ id: 'split', title: 'How much do I earn: the split', q: ['How much do I earn?', 'What commission do I get?', 'What is the split on a package?'], tags: ['earn', 'commission', 'split', 'percent', 'levels'],
|
||||||
re: /(how (much|do i) earn|how much (do|can|will|would|could|might) (i|we|you|they) (earn|make|get)|what (do|would|will) i (earn|make|get paid)|commission|percent|split)/i,
|
re: /(how (much|do i) earn|how much (do|can|will|would|could|might) (i|we|you|they) (earn|make|get)|what (do|would|will) i (earn|make|get paid)|commission|percent|split)/i,
|
||||||
a: 'Every package splits the same way: 50 percent to the direct sponsor, 20 percent to level 2, 10 percent to level 3, 20 percent to the platform. Those numbers are constants in the contract and cannot be changed. The package ladder is on the home page. No income is promised; nobody earns unless real ad buying happens.' },
|
a: 'Every package splits the same way: 50 percent to the direct sponsor, 20 percent to level 2, 10 percent to level 3, 20 percent to the platform. Those numbers are constants in the contract and cannot be changed. The package ladder is on the home page. No income is promised; nobody earns unless real ad buying happens.' },
|
||||||
{ id: 'network-rate', title: 'Network views and partner visits cost a quarter of the rate', q: ['Do network views use my credits?', 'How much do Network Ad Space views cost?', 'Why are network views cheaper?'], tags: ['network views', 'network ad space', 'syndication', 'passivedrip', 'partner visits', 'credits', 'rate'],
|
{ id: 'network-rate', title: 'Network views and partner visits cost less than views here', q: ['Do network views use my credits?', 'How much do Network Ad Space views cost?', 'Why are network views cheaper?'], tags: ['network views', 'network ad space', 'syndication', 'passivedrip', 'partner visits', 'credits', 'rate'],
|
||||||
re: /((network (views?|ad space)|syndicat\w*|partner (sites?|visits?)).{0,60}(credits?|charge[ds]?|cost|spend|balance|budget|free|pay|rate|cheap)|(credits?|charge[ds]?|cost|spend|balance|budget|pay|rate).{0,60}(network (views?|ad space)|syndicat\w*|partner (sites?|visits?)))/i,
|
re: /((network (views?|ad space)|syndicat\w*|partner (sites?|visits?)).{0,60}(credits?|charge[ds]?|cost|spend|balance|budget|free|pay|rate|cheap)|(credits?|charge[ds]?|cost|spend|balance|budget|pay|rate).{0,60}(network (views?|ad space)|syndicat\w*|partner (sites?|visits?)))/i,
|
||||||
a: 'Views and visits here on InstantAdPay use credits at the normal rate. Your banner and text ads also run on Network Ad Space, and visit packs also get visits from partner sites like PassiveDrip. That delivery costs a quarter of the rate: 4 network views cost what 1 view here does, and 4 partner visits use up 1 visit of your pack. So your budget goes further, and every credit still buys real delivery. You see network views and partner visits in Members > Campaigns, and network charges show as "Network views (1/4 rate)" lines in Credit activity.' },
|
a: 'Views and visits here on InstantAdPay use credits at the normal rate. Your banner and text ads also run on Network Ad Space, and visit packs also get visits from partner sites like PassiveDrip. That delivery costs less: for a banner, 4 network views cost what 1 view here does, and 4 partner visits use up 1 visit of your pack. Text ads go further still: since November 12, 10 network views of a text ad cost what 1 view here does. So your budget goes further, and every credit still buys real delivery. You see network views and partner visits in Members > Campaigns, and network charges show as "Network views (1/4 rate)" or, for text ads, "Network views (1/10 rate)" lines in Credit activity.' },
|
||||||
{ id: 'balance-rule', title: 'Why my balance went down', q: ['Why did my balance go down?', 'Where did my credits go?', 'What does In live campaigns mean?'], tags: ['balance', 'credits', 'campaigns', 'credit activity'],
|
{ id: 'balance-rule', title: 'Why my balance went down', q: ['Why did my balance go down?', 'Where did my credits go?', 'What does In live campaigns mean?'], tags: ['balance', 'credits', 'campaigns', 'credit activity'],
|
||||||
re: /(balance (went|going|keeps going) down|credits? (disappear|missing|gone|dropping|went down|ticking)|why (is|did) my (balance|credits)|in campaigns|set aside|reserved credits|available to spend)/i,
|
re: /(balance (went|going|keeps going) down|credits? (disappear|missing|gone|dropping|went down|ticking)|why (is|did) my (balance|credits)|in campaigns|set aside|reserved credits|available to spend)/i,
|
||||||
a: 'One rule: your balance is what is NOT committed to a live campaign. When you start a campaign its whole budget is set aside right then (earned credits first, then purchased), so your Available number drops once and then sits still while the ad runs. The budget spends down inside that campaign in Members > Campaigns, where you can see delivered views, network views and what is left. The dashboard shows Purchased available, Earned available and In live campaigns as three separate numbers; a paused campaign keeps its unspent budget set aside so it can resume. Nothing is lost when a balance reads low while a campaign is live. Purchased credits live on the blockchain; if we ever refund or credit purchased money it shows under Purchased as "credited to you" and spends like a purchase, login ads included. Earned credits fund every format except login ads. Two formats are flat buys paid in full when booked: featured links (sold by the day) and verified-visit packs. Adding credits to a featured link does nothing, so its row offers Extend run instead, which books more days at the daily rate; a visit pack offers Buy more visits. Every credit that comes in or goes out is listed with its reason under Members > Campaigns > Credit activity (also linked from Earn credits): sign-in bonus, daily claim, video watched, verified visit, campaign buys, views delivered per day, grants and refunds. Check it before assuming credits went missing.' },
|
a: 'One rule: your balance is what is NOT committed to a live campaign. When you start a campaign its whole budget is set aside right then (earned credits first, then purchased), so your Available number drops once and then sits still while the ad runs. The budget spends down inside that campaign in Members > Campaigns, where you can see delivered views, network views and what is left. The dashboard shows Purchased available, Earned available and In live campaigns as three separate numbers; a paused campaign keeps its unspent budget set aside so it can resume. Nothing is lost when a balance reads low while a campaign is live. Purchased credits live on the blockchain; if we ever refund or credit purchased money it shows under Purchased as "credited to you" and spends like a purchase, login ads included. Earned credits fund every format except login ads. Two formats are flat buys paid in full when booked: featured links (sold by the day) and verified-visit packs. Adding credits to a featured link does nothing, so its row offers Extend run instead, which books more days at the daily rate; a visit pack offers Buy more visits. Every credit that comes in or goes out is listed with its reason under Members > Campaigns > Credit activity (also linked from Earn credits): sign-in bonus, daily claim, video watched, verified visit, campaign buys, views delivered per day, grants and refunds. Check it before assuming credits went missing.' },
|
||||||
@@ -167,15 +198,18 @@ const CANNED = [
|
|||||||
{ id: 'pif', title: 'Pay it forward (PIF)', q: ['How do I PIF someone?', 'Can I buy a package for my referral?', 'Should I fund someone from the tank?'], tags: ['pif', 'pay it forward', 'gift', 'holding tank'],
|
{ id: 'pif', title: 'Pay it forward (PIF)', q: ['How do I PIF someone?', 'Can I buy a package for my referral?', 'Should I fund someone from the tank?'], tags: ['pif', 'pay it forward', 'gift', 'holding tank'],
|
||||||
re: /\b(pif|p\.i\.f|pay(ing)? it forward|paid it forward|gift (them|him|her|someone|a member)|send (them|him|her) (some )?pol)\b|\b(fund(ing)?|pay(ing)? for|cover(ing)?|buy(ing)?|purchas(e|ing)|front(ing)?|spot)\b[^.?!]{0,50}\b(for (them|him|her|someone|a member|a new member|my (referral|downline|member))|(their|his|her|someone'?s|a member'?s) (first )?(package|starter|activation|\$?20))\b|\b(front|spot|lend|loan|advance|stake|grubstake)\b[^.?!]{0,30}\b(them|him|her|someone|a member|a new member|my (referral|downline|member))\b/i,
|
re: /\b(pif|p\.i\.f|pay(ing)? it forward|paid it forward|gift (them|him|her|someone|a member)|send (them|him|her) (some )?pol)\b|\b(fund(ing)?|pay(ing)? for|cover(ing)?|buy(ing)?|purchas(e|ing)|front(ing)?|spot)\b[^.?!]{0,50}\b(for (them|him|her|someone|a member|a new member|my (referral|downline|member))|(their|his|her|someone'?s|a member'?s) (first )?(package|starter|activation|\$?20))\b|\b(front|spot|lend|loan|advance|stake|grubstake)\b[^.?!]{0,30}\b(them|him|her|someone|a member|a new member|my (referral|downline|member))\b/i,
|
||||||
a: 'PIF is a gift you send from your own wallet, and the site never touches the money. That is different from other platforms, where the site takes money out of your account balance and buys the position for the other person: InstantAdPay has no balances, so the POL goes straight from your wallet to theirs, and they buy their package themselves, from their own wallet. It only appears on your own free referrals and on members you have adopted, and only once they have linked a wallet, so you cannot PIF somebody who is still sitting in the holding tank. The order is: adopt them from Members > My line > Holding tank, get them to link a wallet on their Wallet tab, then the PIF button shows up, you enter an amount and your own wallet app opens with their address already filled in. Now the part that matters most: do not send anything until you have actually talked to that person and they have told you they will use it. Once that POL leaves your wallet it is gone, there is no refund, no chargeback and nothing we can do to pull it back, because the money goes straight from your wallet to theirs and never touches us. The gift is theirs to keep whatever they do with it, so they can go quiet, spend it on something else, or never sign in again, and none of that is against any rule. Someone in the holding tank joined with nobody working with them and may never have engaged at all, which makes an unanswered PIF the easiest money on this site to lose. Get a reply, get a clear commitment that they are going to buy and build, see that they have linked a wallet and are actually active, and only then decide. If they do buy a $20 package the contract pays you 50 percent as their sponsor and they become one of your qualifying buyers, so a gift that works costs you about half; a gift to somebody who never answers costs you all of it. Never gift money you need, never borrow to do it, and treat every PIF as money you are content to lose.' },
|
a: 'PIF is a gift you send from your own wallet, and the site never touches the money. That is different from other platforms, where the site takes money out of your account balance and buys the position for the other person: InstantAdPay has no balances, so the POL goes straight from your wallet to theirs, and they buy their package themselves, from their own wallet. It only appears on your own free referrals and on members you have adopted, and only once they have linked a wallet, so you cannot PIF somebody who is still sitting in the holding tank. The order is: adopt them from Members > My line > Holding tank, get them to link a wallet on their Wallet tab, then the PIF button shows up, you enter an amount and your own wallet app opens with their address already filled in. Now the part that matters most: do not send anything until you have actually talked to that person and they have told you they will use it. Once that POL leaves your wallet it is gone, there is no refund, no chargeback and nothing we can do to pull it back, because the money goes straight from your wallet to theirs and never touches us. The gift is theirs to keep whatever they do with it, so they can go quiet, spend it on something else, or never sign in again, and none of that is against any rule. Someone in the holding tank joined with nobody working with them and may never have engaged at all, which makes an unanswered PIF the easiest money on this site to lose. Get a reply, get a clear commitment that they are going to buy and build, see that they have linked a wallet and are actually active, and only then decide. If they do buy a $20 package the contract pays you 50 percent as their sponsor and they become one of your qualifying buyers, so a gift that works costs you about half; a gift to somebody who never answers costs you all of it. Never gift money you need, never borrow to do it, and treat every PIF as money you are content to lose.' },
|
||||||
|
{ id: 'who-invited', title: 'Who invited you? (naming your sponsor)', q: ['How do I add the person who invited me?', 'I joined without a link, can I name my sponsor?', 'What is the Who invited you card?'], tags: ['who invited you', 'invited', 'holding tank', 'no sponsor', 'sponsor link'],
|
||||||
|
re: /(who invited|invited (me|by)|joined without a (link|sponsor)|forgot (the|my|to use).{0,12}(link|sponsor)|(add|name|set|enter|pick|choose) (my |a )?sponsor|nobody invited)/i,
|
||||||
|
a: 'If you joined without a sponsor link, your Overview shows a Who invited you? card. Type the username of the person who invited you, confirm it, and they become your sponsor, here and on LinkSpin, and they get a notice. Do it before you switch on payouts or buy, because your sponsor locks on the contract at that point. It has to be a real member: not you, not someone in your own line, and not someone who has not switched on payouts with nobody above them who has (ask them to switch on first). Once you have a sponsor or a member number the card goes away. Nobody invited you? Tap Nobody invited me and stay in the holding tank; a small link on the Overview brings the card back while you are still there. Nothing on the site waits for your answer. New sign-ups cannot be adopted by hand for their first 24 hours, so you have a day to tell us before a member can pick you up.' },
|
||||||
{ id: 'tank-hold', title: 'Matched with a sponsor (activation on hold)', q: ['Why can I not switch on payouts?', 'It says I am being matched with a sponsor'], tags: ['holding tank', 'switch on payouts', 'matched with a sponsor', 'ready to activate'],
|
{ id: 'tank-hold', title: 'Matched with a sponsor (activation on hold)', q: ['Why can I not switch on payouts?', 'It says I am being matched with a sponsor'], tags: ['holding tank', 'switch on payouts', 'matched with a sponsor', 'ready to activate'],
|
||||||
re: /(being matched|matched with a sponsor|(can.?t|cannot|unable to) (i )?(switch on|turn on|activate) (my )?payouts|activate (button|payouts) (is )?(gone|missing|hidden)|ready to activate)/i,
|
re: /(being matched|matched with a sponsor|(can.?t|cannot|unable to) (i )?(switch on|turn on|activate) (my )?payouts|activate (button|payouts) (is )?(gone|missing|hidden)|ready to activate)/i,
|
||||||
a: 'You joined without a sponsor, so you are in the holding tank. The contract locks your sponsor for good the first time you switch on payouts or buy, so switching on payouts on its own waits until a real member picks you up. Buying is never held: you can buy a package any time, and with no sponsor it goes through under the company position. Once your wallet is linked, members see you at the top of their holding tank with a Ready to activate badge. If nobody adopts you within 24 hours, the site assigns you to the next eligible member in turn (someone active with their own $20 package). As soon as you have a sponsor, the Switch on payouts button comes back. If you already have a sponsor on LinkSpin with the same email or wallet, you are placed under them right away.' },
|
a: 'You joined without a sponsor, so you are in the holding tank. If someone invited you, type their username on the Who invited you? card on your Overview and this ends right away. The contract locks your sponsor for good the first time you switch on payouts or buy, so switching on payouts on its own waits until a real member picks you up. Buying is never held: you can buy a package any time, and with no sponsor it goes through under the company position. Once your wallet is linked, members see you at the top of their holding tank with a Ready to activate badge. If nobody adopts you within 24 hours, the site assigns you to the next eligible member in turn (someone active with their own $20 package). As soon as you have a sponsor, the Switch on payouts button comes back. If you already have a sponsor on LinkSpin with the same email or wallet, you are placed under them right away.' },
|
||||||
{ id: 'tank-activate-link', title: 'Switch on payouts after you were picked up (one-tap link)', q: ['I got a Switch on payouts link from my new sponsor', 'How do I switch on payouts after I was adopted?'], tags: ['holding tank', 'switch on payouts', 'adopted', 'one tap', 'reminder'],
|
{ id: 'tank-activate-link', title: 'Switch on payouts after you were picked up (one-tap link)', q: ['I got a Switch on payouts link from my new sponsor', 'How do I switch on payouts after I was adopted?'], tags: ['holding tank', 'switch on payouts', 'adopted', 'one tap', 'reminder'],
|
||||||
re: /((switch on|turn on|activate) payouts? (link|email|reminder)|activate=1|(picked (me )?up|adopted( me)?).*(switch on|activate)|one.?tap.*(payouts|activate)|reminder.*switch on payouts)/i,
|
re: /((switch on|turn on|activate) payouts? (link|email|reminder)|activate=1|(picked (me )?up|adopted( me)?).*(switch on|activate)|one.?tap.*(payouts|activate)|reminder.*switch on payouts)/i,
|
||||||
a: 'When a member picks you up from the holding tank (or the site assigns you to one after 24 hours), the chat and the email you get both carry a Switch on payouts link: instantadpay.com/my?activate=1#wallet. Tap it, sign in if asked, and your wallet opens with your new sponsor already filled in. It is one free transaction, no package needed, and it locks that sponsor in as yours on the contract. No wallet linked yet? The same link asks you to link one first (one free signature) and then carries on. On a phone without a wallet browser, the wallet picker opens and hands you to your wallet app to confirm. Nobody, not even the site, can switch payouts on for you: it has to come from your own wallet. If you have not done it 24 hours after you were picked up you get one reminder email (and your sponsor gets a note to give you a nudge), and one last reminder at 72 hours. They stop as soon as your payouts are on or you buy a package.' },
|
a: 'When a member picks you up from the holding tank (or the site assigns you to one after 24 hours), the chat and the email you get both carry a Switch on payouts link: instantadpay.com/my?activate=1#wallet. Tap it, sign in if asked, and your wallet opens with your new sponsor already filled in. It is one free transaction, no package needed, and it locks that sponsor in as yours on the contract. No wallet linked yet? The same link asks you to link one first (one free signature) and then carries on. On a phone without a wallet browser, the wallet picker opens and hands you to your wallet app to confirm. Nobody, not even the site, can switch payouts on for you: it has to come from your own wallet. If you have not done it 24 hours after you were picked up you get one reminder email (and your sponsor gets a note to give you a nudge), and one last reminder at 72 hours. They stop as soon as your payouts are on or you buy a package.' },
|
||||||
{ id: 'holding-tank', title: 'Holding tank and adoptions', q: ['What is the holding tank?', 'How do I adopt a member?'], tags: ['holding tank', 'adopt', 'unsponsored'],
|
{ id: 'holding-tank', title: 'Holding tank and adoptions', q: ['What is the holding tank?', 'How do I adopt a member?'], tags: ['holding tank', 'adopt', 'unsponsored'],
|
||||||
re: /(holding tank|adopt(ing|ion|ed)? (a |an |from|someone|member)|orphan(ed)? member|no sponsor|unsponsored|release to tank)/i,
|
re: /(holding tank|adopt(ing|ion|ed)? (a |an |from|someone|member)|orphan(ed)? member|no sponsor|unsponsored|release to tank)/i,
|
||||||
a: 'The holding tank is where free members who joined without a sponsor wait, and anyone can be picked up first come. To adopt you need payouts switched on and your own $20 or larger package bought; then open Members > My line > Holding tank. You can hold 2 open adoptions at a time and each one runs for 7 days, and if that person never links a wallet or buys they drop back into the tank. Adopting sets you as their sponsor, opens a chat and emails them, and their first purchase binds to you on the chain. You can also release one of your own free referrals into the tank for somebody else to work with, though not one you adopted less than 3 days ago. A member can be adopted twice in their lifetime at most, so an adoption you drop still costs them one of those chances. Members who have linked a wallet show a Ready to activate badge with the hours left and sit at the top of the list: their payouts are on hold until someone adopts them, and after 24 hours the site assigns them to the next eligible adopter in turn (own $20 package, fewer than 2 open adoptions, signed in within the last 7 days). Adopters take turns, so the one assigned least recently goes first.' },
|
a: 'The holding tank is where free members who joined without a sponsor wait, and anyone can be picked up first come once they have been here 24 hours. A new sign-up shows an Opens in badge until then, with no Adopt button, so they have a day to tell us who invited them (the 24-hour safety net for wallet-linked members still runs on its own clock). To adopt you need payouts switched on and your own $20 or larger package bought; then open Members > My line > Holding tank. You can hold up to 10 people from the tank at one time (counting the ones who have not switched on payouts yet) and each one runs for 7 days, and if that person never links a wallet or buys they drop back into the tank. Adopting sets you as their sponsor, opens a chat and emails them, and their first purchase binds to you on the chain. You can also release one of your own free referrals into the tank for somebody else to work with, though not one you adopted less than 3 days ago. A member can be adopted twice in their lifetime at most, so an adoption you drop still costs them one of those chances. Members who have linked a wallet show a Ready to activate badge with the hours left and sit at the top of the list: their payouts are on hold until someone adopts them, and after 24 hours the site assigns them to the next eligible adopter in turn (own $20 package, fewer than 10 people held from the tank who have not switched on payouts yet, signed in within the last 7 days). Adopters take turns, so the one assigned least recently goes first.' },
|
||||||
{ id: 'qualification', title: 'Qualification, levels 2 and 3, credits vs POL', q: ['How do I unlock level 2?', 'How does qualification work?', 'What is a pass-up?'], tags: ['qualification', 'level 2', 'level 3', 'pass-up', 'qualified start'],
|
{ id: 'qualification', title: 'Qualification, levels 2 and 3, credits vs POL', q: ['How do I unlock level 2?', 'How does qualification work?', 'What is a pass-up?'], tags: ['qualification', 'level 2', 'level 3', 'pass-up', 'qualified start'],
|
||||||
re: /(qualif|unlock level|level 2|level 3|pass.?up)/i,
|
re: /(qualif|unlock level|level 2|level 3|pass.?up)/i,
|
||||||
a: 'Two different things are earned here. CREDITS: every member, free ones included, earns ad credits by viewing ads, videos, visits and the daily sign-in; credits buy your own ads and are never withdrawn. POL: real crypto paid to your wallet when your referrals buy packages, once you are activated: the $20 starter package plus payouts switched on from your wallet. Level 1 pays 50 percent of the packages your direct referrals buy, from the day you are activated. Bring 2 buyers of $20 or more and level 2 unlocks; 5 unlock level 3. When a level is not qualified, its share climbs the sponsor line, checking up to 25 positions, and pays the first qualified person. Qualification never expires and cannot be bought. Qualified Start: you may link extra wallets of your own as positions under your account (Buy packages > Qualified Start); each one that buys a $20+ package counts as a qualifying buyer, its credits pool with yours, and 50% of its purchase comes back to your main wallet. Your own money, your own wallets, a faster start, never an income promise.' },
|
a: 'Two different things are earned here. CREDITS: every member, free ones included, earns ad credits by viewing ads, videos, visits and the daily sign-in; credits buy your own ads and are never withdrawn. POL: real crypto paid to your wallet when your referrals buy packages, once you are activated: the $20 starter package plus payouts switched on from your wallet. Level 1 pays 50 percent of the packages your direct referrals buy, from the day you are activated. Bring 2 buyers of $20 or more and level 2 unlocks; 5 unlock level 3. When a level is not qualified, its share climbs the sponsor line, checking up to 25 positions, and pays the first qualified person. Qualification never expires and cannot be bought. Qualified Start: you may link extra wallets of your own as positions under your account (Buy packages > Qualified Start); each one that buys a $20+ package counts as a qualifying buyer, its credits pool with yours, and 50% of its purchase comes back to your main wallet. Your own money, your own wallets, a faster start, never an income promise.' },
|
||||||
@@ -190,7 +224,7 @@ const CANNED = [
|
|||||||
a: 'You get your share link the moment you sign in, free members included. Open Members > Promo tools: the "Your links" block at the top lists your invite link plus five angle versions (Instant, Ad spend, Free, Ledger, Two), each with a note on who it is for and Copy and Share buttons. They are the same link with a code on the end, so every join and purchase credits you; only the first page the person sees changes. One tip: switch on payouts (one free wallet step in Members) before your people start buying, because the contract locks each buyer to their sponsor at their first purchase.' },
|
a: 'You get your share link the moment you sign in, free members included. Open Members > Promo tools: the "Your links" block at the top lists your invite link plus five angle versions (Instant, Ad spend, Free, Ledger, Two), each with a note on who it is for and Copy and Share buttons. They are the same link with a code on the end, so every join and purchase credits you; only the first page the person sees changes. One tip: switch on payouts (one free wallet step in Members) before your people start buying, because the contract locks each buyer to their sponsor at their first purchase.' },
|
||||||
{ id: 'banner-image', title: 'Banner image link and sizes', q: ['Why was my banner image refused?', 'What banner sizes are there?', 'How do I upload a banner?'], tags: ['banner', 'image', 'sizes', 'campaign'],
|
{ id: 'banner-image', title: 'Banner image link and sizes', q: ['Why was my banner image refused?', 'What banner sizes are there?', 'How do I upload a banner?'], tags: ['banner', 'image', 'sizes', 'campaign'],
|
||||||
re: /(banner (image|url|link|size|creative|file)|image (url|link|field)|broken (banner|image)|upload (a |my |the )?(banner|image|creative)|(png|jpg|jpeg) link|which sizes?)/i,
|
re: /(banner (image|url|link|size|creative|file)|image (url|link|field)|broken (banner|image)|upload (a |my |the )?(banner|image|creative)|(png|jpg|jpeg) link|which sizes?)/i,
|
||||||
a: 'The image field on a banner campaign needs a direct link to the picture itself, one that ends in .png, .jpg, .gif, .webp or .svg, or an upload. A web page link (your join page, an image-hosting page) is refused, because it would show a broken banner. Easiest source: Promo tools > Banners, pick the size you want and tap Copy image URL. Sizes are the standard ad sizes (728x90, 300x250, 160x600, 320x50 and more); the campaign form asks for the size too. Banner and text ads also run out on the wider network.' },
|
a: 'The image field on a banner campaign needs a direct link to the picture itself, one that ends in .png, .jpg, .gif, .webp or .svg, or an upload. A web page link (your join page, an image-hosting page) is refused, because it would show a broken banner. Easiest source: Promo tools > Banners, pick the size you want and tap Copy image URL. Game and BixPay banner links in Promo tools are short (for example https://instantadpay.link/b/turkeydrop/728x90.png) so they fit the image fields on exchanges and safelists that cut long links. Sizes are the standard ad sizes (728x90, 300x250, 160x600, 320x50 and more); the campaign form asks for the size too. Banner and text ads also run out on the wider network.' },
|
||||||
{ id: 'themes', title: 'Light and dark themes', q: ['Is there a light mode?', 'How do I switch themes?'], tags: ['theme', 'dark mode', 'light mode', 'appearance', 'accessibility'],
|
{ id: 'themes', title: 'Light and dark themes', q: ['Is there a light mode?', 'How do I switch themes?'], tags: ['theme', 'dark mode', 'light mode', 'appearance', 'accessibility'],
|
||||||
re: /(dark ?mode|light ?mode|dark theme|light theme|night mode|themes?|appearance|too bright|too dark|high contrast)/i,
|
re: /(dark ?mode|light ?mode|dark theme|light theme|night mode|themes?|appearance|too bright|too dark|high contrast)/i,
|
||||||
a: 'InstantAdPay has light and dark themes (added 2026-11-02). In the member area use the Light, Dark or Auto control in the header, or the Appearance card on your Profile. Dark is the original look, Light is a bright green-grey workspace with the same layout, and Auto follows your device setting and switches with it. Your choice is saved on your account, so it follows you to any device once you sign in, and it applies to the public pages and your wall too. Nothing changes until you pick one. Both themes pass the accessibility contrast standard for text.' },
|
a: 'InstantAdPay has light and dark themes (added 2026-11-02). In the member area use the Light, Dark or Auto control in the header, or the Appearance card on your Profile. Dark is the original look, Light is a bright green-grey workspace with the same layout, and Auto follows your device setting and switches with it. Your choice is saved on your account, so it follows you to any device once you sign in, and it applies to the public pages and your wall too. Nothing changes until you pick one. Both themes pass the accessibility contrast standard for text.' },
|
||||||
@@ -253,6 +287,14 @@ function seeds() {
|
|||||||
// ---- facts for the AI fallback ----
|
// ---- facts for the AI fallback ----
|
||||||
// PASS TIERS (2026-10-22): the passes above the weekly Game Pass (Explorer, Champion, Sovereign, Legend; names from gamepass.js
|
// PASS TIERS (2026-10-22): the passes above the weekly Game Pass (Explorer, Champion, Sovereign, Legend; names from gamepass.js
|
||||||
// TIER_DEFS). While sovTiers is off the assistant only says they are coming soon; once on, it quotes the live prices and contents.
|
// TIER_DEFS). While sovTiers is off the assistant only says they are coming soon; once on, it quotes the live prices and contents.
|
||||||
|
// BONUS HEROES (2026-11-05): sold one time; while heroSales is off the assistant says they are coming soon, once on it quotes the live prices
|
||||||
|
function heroesFact() {
|
||||||
|
let h = null; try { h = HERO_SALE ? HERO_SALE() : null; } catch (e) { h = null; }
|
||||||
|
const base = 'Shards of Valor bonus heroes: Kestrel the Archer, Valda the Barbarian, Morag the Druid, Roland the Paladin. Kestrel is FREE for every player once a hero in the party reaches level 20 (since 2026-11-14) and is NOT sold; anyone who bought her before keeps her. Valda, Morag and Roland are sold ONE TIME, owned for good, never a subscription; paid by a NEW package purchase of at least the price (sponsor and team paid as usual, the member keeps the package credits); credits already held never buy one. Three heroes fight at a time, picked at an inn, rest spot or dungeon camp; the roster keeps gear and level and earns half experience. A bonus hero joins at the party level (at most 20) and is never stronger than the free heroes. The Champion and Sovereign passes no longer include a hero (the Necromancer was dropped); the Legend pass opens every bonus hero while it is active.';
|
||||||
|
if (!h || !h.sale) return '- BONUS HEROES (COMING SOON, not on sale yet): ' + base + ' Never quote their prices or a launch date while they are not on sale.\n';
|
||||||
|
const each = (h.rows || []).map(r => r.name + (r.freeAt ? ' free at level ' + r.freeAt + ' (not sold)' : r.free ? ' free for everyone' : ' $' + r.usd)).join(', ');
|
||||||
|
return '- BONUS HEROES (ON SALE, Members > Games > Game Pass card at https://instantadpay.com/my#games): ' + each + (h.bundle && h.bundle.names.length ? '; the bundle ' + h.bundle.names.join(', ') + ' $' + h.bundle.usd : '') + '. ' + base + ' The bundle is heroes only (no level cap change).\n';
|
||||||
|
}
|
||||||
function passTiersFact() {
|
function passTiersFact() {
|
||||||
let t = null; try { t = PASS_TIERS ? PASS_TIERS() : null; } catch (e) { t = null; }
|
let t = null; try { t = PASS_TIERS ? PASS_TIERS() : null; } catch (e) { t = null; }
|
||||||
const soon = '- MORE GAME PASSES: monthly and yearly passes for Shards of Valor are COMING SOON and are not on sale yet. If someone asks about them (or about an Explorer, Champion, Sovereign or Legend pass, or a monthly or yearly pass), say they are coming soon and that the $5 weekly Game Pass is the pass on sale today. Never quote their prices, contents or a launch date.\n';
|
const soon = '- MORE GAME PASSES: monthly and yearly passes for Shards of Valor are COMING SOON and are not on sale yet. If someone asks about them (or about an Explorer, Champion, Sovereign or Legend pass, or a monthly or yearly pass), say they are coming soon and that the $5 weekly Game Pass is the pass on sale today. Never quote their prices, contents or a launch date.\n';
|
||||||
@@ -265,9 +307,11 @@ function passTiersFact() {
|
|||||||
// SYNDICATED RATE (Marty, 2026-10-27, approved 4:1) follows ads rates().synRateDivisor; the canned answer quotes 1/4, so
|
// SYNDICATED RATE (Marty, 2026-10-27, approved 4:1) follows ads rates().synRateDivisor; the canned answer quotes 1/4, so
|
||||||
// the fast path rewrites it when the admin picks another N, and the AI fact always states the live N.
|
// the fast path rewrites it when the admin picks another N, and the AI fact always states the live N.
|
||||||
const SYN_N = () => { try { return Math.max(1, Math.floor(Number(require('./ads').synRateDivisor()) || 1)); } catch (e) { return 4; } };
|
const SYN_N = () => { try { return Math.max(1, Math.floor(Number(require('./ads').synRateDivisor()) || 1)); } catch (e) { return 4; } };
|
||||||
|
// text ads have their own N since 2026-11-12 (Marty: 1/10); the canned answer quotes 4 and 10
|
||||||
|
const SYN_T = () => { try { return Math.max(1, Math.floor(Number(require('./ads').synRateDivisorText()) || 1)); } catch (e) { return 10; } };
|
||||||
const netRateAnswer = n => n === 1 ? 'Your banner and text ads also run on Network Ad Space, and visit packs also get visits from partner sites like PassiveDrip. That delivery uses credits at the same rate as views and visits here.'
|
const netRateAnswer = n => n === 1 ? 'Your banner and text ads also run on Network Ad Space, and visit packs also get visits from partner sites like PassiveDrip. That delivery uses credits at the same rate as views and visits here.'
|
||||||
: 'Views and visits here on InstantAdPay use credits at the normal rate. Your banner and text ads also run on Network Ad Space, and visit packs also get visits from partner sites like PassiveDrip. That delivery costs 1/' + n + ' of the rate: ' + n + ' network views cost what 1 view here does, and ' + n + ' partner visits use up 1 visit of your pack. So your budget goes further, and every credit still buys real delivery. You see network views and partner visits in Members > Campaigns, and network charges show as "Network views (1/' + n + ' rate)" lines in Credit activity.';
|
: 'Views and visits here on InstantAdPay use credits at the normal rate. Your banner and text ads also run on Network Ad Space, and visit packs also get visits from partner sites like PassiveDrip. That delivery costs 1/' + n + ' of the rate: ' + n + ' network views of a banner cost what 1 view here does, and ' + n + ' partner visits use up 1 visit of your pack.' + (SYN_T() !== n ? ' Text ads: ' + SYN_T() + ' network views cost what 1 view here does.' : '') + ' So your budget goes further, and every credit still buys real delivery. You see network views and partner visits in Members > Campaigns, and network charges show as "Network views (1/' + n + ' rate)" lines in Credit activity.';
|
||||||
function synFact() { const n = SYN_N(); return '- NETWORK RATE (live, Marty 2026-10-27): delivery ON instantadpay.com is charged at the normal rate. Network Ad Space impressions of banner/text ads cost 1/' + n + ' of the on-site rate (' + n + ' network views = the price of 1 view here; credit log line "Network views (1/' + n + ' rate)"), and PassiveDrip partner visits use up 1 visit of a pack per ' + n + ' partner visits. The budget is the limit, burns follow what was charged, nothing charged before 2026-10-27 changed. AdRevLinks popups and DripOffers clicks are not charged. Game refuels and Spooky Doors are charged as normal visits.' + String.fromCharCode(10); }
|
function synFact() { const n = SYN_N(); return '- NETWORK RATE (live, Marty 2026-10-27): delivery ON instantadpay.com is charged at the normal rate. Network Ad Space impressions of BANNER ads cost 1/' + n + ' of the on-site rate (' + n + ' network views = the price of 1 view here; credit log line "Network views (1/' + n + ' rate)"); TEXT ads have their own network rate since 2026-11-12 (Marty): 1/' + SYN_T() + ' of the on-site text rate (' + SYN_T() + ' network views = the price of 1 view here, so 1 credit = ' + (10 * SYN_T()) + ' network text views at the default 1 credit per 10 views; credit log line "Network views (1/' + SYN_T() + ' rate)"), going forward only; and PassiveDrip partner visits use up 1 visit of a pack per ' + n + ' partner visits. The budget is the limit, burns follow what was charged, nothing charged before 2026-10-27 changed. AdRevLinks popups and DripOffers clicks are not charged. Game refuels and Spooky Doors are charged as normal visits.' + String.fromCharCode(10); }
|
||||||
// the refuel fact follows the refuelStreak switch: while it is off the assistant says it is not live yet (2026-10-24)
|
// the refuel fact follows the refuelStreak switch: while it is off the assistant says it is not live yet (2026-10-24)
|
||||||
let REFUEL_ON = () => false;
|
let REFUEL_ON = () => false;
|
||||||
// POL Miner (2026-10-28) follows site config gamesLive: until 'polminer' is in it the assistant only says it is coming soon
|
// POL Miner (2026-10-28) follows site config gamesLive: until 'polminer' is in it the assistant only says it is coming soon
|
||||||
@@ -301,26 +345,32 @@ const TURKEYDROP_OVER_ANSWER = 'Turkey Drop was the network’s Thanksgiving gam
|
|||||||
const tdAnswer = () => tdOver() ? TURKEYDROP_OVER_ANSWER : TURKEYDROP_SOON_ANSWER;
|
const tdAnswer = () => tdOver() ? TURKEYDROP_OVER_ANSWER : TURKEYDROP_SOON_ANSWER;
|
||||||
const TD_PASS_PERK = ' Turkey Drop one free “back on the air” extra life every day;';
|
const TD_PASS_PERK = ' Turkey Drop one free “back on the air” extra life every day;';
|
||||||
const gpWithTd = a => tdLive() ? String(a).replace('plus one free supply crate every day;', 'plus one free supply crate every day;' + TD_PASS_PERK) : a; // the Game Pass answer names the perk only while Turkey Drop is live
|
const gpWithTd = a => tdLive() ? String(a).replace('plus one free supply crate every day;', 'plus one free supply crate every day;' + TD_PASS_PERK) : a; // the Game Pass answer names the perk only while Turkey Drop is live
|
||||||
|
// Shards of Valor (2026-11-06, Marty): open for testing from the Games tab once 'shardsofvalor' is in gamesLive; no POL until a launch date
|
||||||
|
function sovTestFact() { return GAME_LIVE && GAME_LIVE('shardsofvalor') ? '- SHARDS OF VALOR (OPEN TESTING since Nov 6, https://shardsofvalor.com, Members > Games > Shards of Valor > Play): a pixel adventure RPG for many players at once; lead three heroes across the islands, help the townspeople, fight in the dungeons and recover the eight Shards of Valor. It is in open testing: anyone can play it now, but it is NOT live and pays NO POL until a launch date is set; there is no launch date yet. ALL TESTING PROGRESS IS WIPED AT LAUNCH (heroes, levels, gold and items start fresh), because this phase is only for finding bugs. Never promise a date or a payout. Ask testers to report bugs through Support.\n' : ''; }
|
||||||
function turkeydropFact() { return tdLive() ? '- TURKEY DROP (Thanksgiving season game, https://turkeydropgame.com, Members > Games; open Nov 2 through Nov 30 Central, its Games card shows a "Limited time, ends Nov 30" ribbon and is gone after): a free 70s-cartoon arcade game. The WFWL 98.7 radio helicopter drops turkeys over the mall; the player swings a net to catch them before they splat; too many splats and the station pulls them off the air. One-tap sign-in with the InstantAdPay account. PAYS POL: the first time a player reaches each score milestone, plus a weekly top-3 leaderboard POL prize. POL collects in the Turkey Drop balance and is paid automatically to the wallet linked on InstantAdPay. BACK ON THE AIR: after being pulled off the air, a short verified sponsor visit (charged to the advertiser like any game refuel visit) gives one extra life; gameplay only, never POL. Game Pass perk: one free back-on-the-air extra life every day. Never state amounts, caps, totals or a season budget.\n' : tdOver() ? '- TURKEY DROP: the Thanksgiving season game (Nov 2 to 30) has ENDED; say the season is over and point to the other games.\n' : '- TURKEY DROP: COMING SOON, not open yet. Never send members to turkeydropgame.com; say it is coming soon to the Games tab, and do not bring it up unless asked.\n'; }
|
function turkeydropFact() { return tdLive() ? '- TURKEY DROP (Thanksgiving season game, https://turkeydropgame.com, Members > Games; open Nov 2 through Nov 30 Central, its Games card shows a "Limited time, ends Nov 30" ribbon and is gone after): a free 70s-cartoon arcade game. The WFWL 98.7 radio helicopter drops turkeys over the mall; the player swings a net to catch them before they splat; too many splats and the station pulls them off the air. One-tap sign-in with the InstantAdPay account. PAYS POL: the first time a player reaches each score milestone, plus a weekly top-3 leaderboard POL prize. POL collects in the Turkey Drop balance and is paid automatically to the wallet linked on InstantAdPay. BACK ON THE AIR: after being pulled off the air, a short verified sponsor visit (charged to the advertiser like any game refuel visit) gives one extra life; gameplay only, never POL. Game Pass perk: one free back-on-the-air extra life every day. Never state amounts, caps, totals or a season budget.\n' : tdOver() ? '- TURKEY DROP: the Thanksgiving season game (Nov 2 to 30) has ENDED; say the season is over and point to the other games.\n' : '- TURKEY DROP: COMING SOON, not open yet. Never send members to turkeydropgame.com; say it is coming soon to the Games tab, and do not bring it up unless asked.\n'; }
|
||||||
function polminerFact() { return pmLive() ? '- POL MINER (https://polminer.com, Members > Games): a free dig-down mining game. Dig, sell ore for coins, upgrade pick/lamp/cart/thruster, beat a drill boss every 30 m. Pink Polygon crystals pay a random POL amount the first time each one is dug out; each boss pays POL on its first win per account; first trips to 50/100/150/200 m pay POL. Coins never turn into POL. Guests can play and collect at sign-in. POL is paid automatically to the wallet linked on InstantAdPay. The SUPPLY pad opens a sponsored supply crate (full lamp + coins, never POL) after a short sponsor visit.\n' : '- POL MINER: COMING SOON, not open yet. Never send members to polminer.com; say it is coming soon to the Games tab.\n'; }
|
function polminerFact() { return pmLive() ? '- POL MINER (https://polminer.com, Members > Games): a free dig-down mining game. Dig, sell ore for coins, upgrade pick/lamp/cart/thruster, beat a drill boss every 30 m. Pink Polygon crystals pay a random POL amount the first time each one is dug out; each boss pays POL on its first win per account; first trips to 50/100/150/200 m pay POL. Coins never turn into POL. Guests can play and collect at sign-in. POL is paid automatically to the wallet linked on InstantAdPay. The SUPPLY pad opens a sponsored supply crate (full lamp + coins, never POL) after a short sponsor visit.\n' : '- POL MINER: COMING SOON, not open yet. Never send members to polminer.com; say it is coming soon to the Games tab.\n'; }
|
||||||
function refuelFact() { return REFUEL_ON() ? "- MONTHLY REFUEL STREAK (built 2026-10-24, switch refuelStreak): ONE streak per member across InstantAdPay and LinkSpin. Counted refuel = a NEW package of $20+ on InstantAdPay or $25+ on LinkSpin by one of the member's own positions. First one sets the member's own refuel day; next due 30 days after the last counted refuel; window opens 5 days before the due day; 5-day grace after it; Central time. Missing the grace resets the streak, except one free miss per 365 days. Bonus (purchased-grade ad credits on the site where bought, credit log 'Refuel streak'): one engine m1 +10%, m2 +15%, m3 +20%, m4+ +25%; both sites in the same cycle m1 +15%, m2 +20%, m3 +30%, m4+ +40% each (first site topped up to the both rate, difference only) plus a 100-credit Featured bonus on InstantAdPay at m4+ (purchased-grade credits, any format). Stacks on Five Dollar Friday / Wired Wednesday. Pit Stop: another $20+/$25+ package on a site already refueled this cycle, before the next window opens (the other site's first package in the cycle is the second engine instead) = half the current streak rate, once per site per cycle, not a counted refuel. Badges: Engine Started (first refuel), Refueled 3 / 6 / 12 months. ENGINE ROOM: unlocked by the first counted refuel (greyed 'Refuel to start your engine' before), IAP tab Engine Room + LinkSpin Ads screen panel, same data both sites: dials Fuel left (credits free + in campaigns on both sites vs this cycle's refuel credits incl. bonus, days left at the recent burn), Clicks this week (vs last week, clicks per 1,000 credits), Goals this month (conversion pixel conversions since the 1st Central vs the member's own goal); streak panel; warning lights (ads at 80%, ads out, refuel day coming, login slot open); six part lights (fuel, banner spin, spin link, page, testing, conversion tracking: green working, amber needs attention, grey not started with a Set it up link); one Next move button from simple rules. REFUEL KIT: each counted refuel unlocks the Central-month's members-only banner set for this site's own program (5 sizes, personalized server-side with @username + QR to the member's link; IAP: Promo tools card with Use in an IAP banner campaign; LinkSpin: Ads screen card with Load into my Banner Spin); kits stay usable after the month; streak month 3+ adds an animated GIF, month 6+ a BannerKitAI custom-banners credit (coming, entitlement saved). Reminders 5 days before, on the day, last call at the end of grace (email + on-site notice). The member's Refuel card (InstantAdPay Overview, LinkSpin Credits/Ads) shows refuel day, streak, next bonus, Pit Stop status. Either site alone keeps the streak (one-engine rates); both sites in one cycle = the bigger bonus; never say both are required. MEMBER GUIDE PAGE (public, 2026-10-24): /refuel on both sites (https://instantadpay.com/refuel and https://linkspin.app/refuel): the flow, the numbers, the member steps, leader coaching and FAQ; point members there for the full picture. Ad credits only, never cash; never promise income. No auto-billing: the member chooses every package. ROUTES (2026-10-25): LinkSpin menu item Refuel = https://linkspin.app/credits#refuel (the Refuel panel, scrolled to and highlighted); packages of $25+ there are marked counts for Refuel; https://linkspin.app/credits#buy = the package picker; https://linkspin.app/ads#engine = LinkSpin Engine Room. InstantAdPay Engine Room = https://instantadpay.com/my#engine; its Set up conversion tracking opens https://instantadpay.com/my#conversions (Campaigns > Conversion tracking card, same goals LinkSpin counts). Engine Room links that cross to LinkSpin (Banner Spin, spin link, page, testing, refuel LinkSpin) open LinkSpin with a note at the top naming the job, Step 1, a guide link and Back to InstantAdPay; same email signs in on both.\n" : '- MONTHLY REFUEL STREAK: built but NOT switched on yet. If asked, say it is coming and nothing counts toward it today; do not quote bonus rates or dates.\n'; }
|
function refuelFact() { return "- DOWNLINE BANNERS (LIVE 2026-11-13, https://downlinebanners.com, contract verified on Polygonscan): network banner board; a $5 spot in POL = 300 guaranteed views + a place in one line; the contract pays the 10 spots above and the buyer's sponsor when later spots sell; nothing promised. InstantAdPay sign-in carries members in as their linked wallet; share links use the InstantAdPay username; My Spots has a 'Use a LinkSpin Banner Spin' button. A counted Monthly Refuel of $50+ (either site) earns one free spot for the member's main wallet, paid by the company (no wallet linked = no spot).\n" + (REFUEL_ON() ? "- MONTHLY REFUEL STREAK (built 2026-10-24, switch refuelStreak): ONE streak per member across InstantAdPay and LinkSpin. Counted refuel = a NEW package of $20+ on InstantAdPay or $25+ on LinkSpin by one of the member's own positions. First one sets the member's own refuel day; next due 30 days after the last counted refuel; window opens 5 days before the due day; 5-day grace after it; Central time. Missing the grace resets the streak, except one free miss per 365 days. Bonus (purchased-grade ad credits on the site where bought, credit log 'Refuel streak'): one engine m1 +10%, m2 +15%, m3 +20%, m4+ +25%; both sites in the same cycle m1 +15%, m2 +20%, m3 +30%, m4+ +40% each (first site topped up to the both rate, difference only) plus a 100-credit Featured bonus on InstantAdPay at m4+ (purchased-grade credits, any format). Stacks on Five Dollar Friday / Wired Wednesday. Pit Stop: another $20+/$25+ package on a site already refueled this cycle, before the next window opens (the other site's first package in the cycle is the second engine instead) = half the current streak rate, once per site per cycle, not a counted refuel. Badges: Engine Started (first refuel), Refueled 3 / 6 / 12 months. ENGINE ROOM: unlocked by the first counted refuel (greyed 'Refuel to start your engine' before), IAP tab Engine Room + LinkSpin Ads screen panel, same data both sites: dials Fuel left (credits free + in campaigns on both sites vs this cycle's refuel credits incl. bonus, days left at the recent burn), Clicks this week (vs last week, clicks per 1,000 credits), Goals this month (conversion pixel conversions since the 1st Central vs the member's own goal); streak panel; warning lights (ads at 80%, ads out, refuel day coming, login slot open); six part lights (fuel, banner spin, spin link, page, testing, conversion tracking: green working, amber needs attention, grey not started with a Set it up link); one Next move button from simple rules. REFUEL KIT: each counted refuel unlocks the Central-month's members-only banner set for this site's own program (5 sizes, personalized server-side with @username + QR to the member's link; IAP: Promo tools card with Use in an IAP banner campaign; LinkSpin: Ads screen card with Load into my Banner Spin); kits stay usable after the month; streak month 3+ adds an animated GIF, month 6+ a BannerKitAI custom-banners credit (coming, entitlement saved). Reminders 5 days before, on the day, last call at the end of grace (email + on-site notice). The member's Refuel card (InstantAdPay Overview, LinkSpin Credits/Ads) shows refuel day, streak, next bonus, Pit Stop status. Either site alone keeps the streak (one-engine rates); both sites in one cycle = the bigger bonus; never say both are required. MEMBER GUIDE PAGE (public, 2026-10-24): /refuel on both sites (https://instantadpay.com/refuel and https://linkspin.app/refuel): the flow, the numbers, the member steps, leader coaching and FAQ; point members there for the full picture. Ad credits only, never cash; never promise income. No auto-billing: the member chooses every package. ROUTES (2026-10-25): LinkSpin menu item Refuel = https://linkspin.app/credits#refuel (the Refuel panel, scrolled to and highlighted); packages of $25+ there are marked counts for Refuel; https://linkspin.app/credits#buy = the package picker; https://linkspin.app/ads#engine = LinkSpin Engine Room. InstantAdPay Engine Room = https://instantadpay.com/my#engine; its Set up conversion tracking opens https://instantadpay.com/my#conversions (Campaigns > Conversion tracking card, same goals LinkSpin counts). Engine Room links that cross to LinkSpin (Banner Spin, spin link, page, testing, refuel LinkSpin) open LinkSpin with a note at the top naming the job, Step 1, a guide link and Back to InstantAdPay; same email signs in on both.\n" : '- MONTHLY REFUEL STREAK: built but NOT switched on yet. If asked, say it is coming and nothing counts toward it today; do not quote bonus rates or dates.\n'); }
|
||||||
const REFUEL_OFF_ANSWER = 'The Monthly Refuel streak (bonus ad credits for refueling every month, more when you refuel both InstantAdPay and LinkSpin) is built but not switched on yet, so nothing counts toward it today. The bonuses running now are Five Dollar Friday and Wired Wednesday on InstantAdPay. When the streak goes live, your Refuel card will show your refuel day.';
|
const REFUEL_OFF_ANSWER = 'The Monthly Refuel streak (bonus ad credits for refueling every month, more when you refuel both InstantAdPay and LinkSpin) is built but not switched on yet, so nothing counts toward it today. The bonuses running now are Five Dollar Friday and Wired Wednesday on InstantAdPay. When the streak goes live, your Refuel card will show your refuel day.';
|
||||||
function systemPrompt(kbBlock) {
|
function systemPrompt(kbBlock) {
|
||||||
return `You are the assistant on InstantAdPay (https://instantadpay.com), a membership advertising platform.
|
return `You are the assistant on InstantAdPay (https://instantadpay.com), a membership advertising platform.
|
||||||
|
|
||||||
FACTS:
|
FACTS:
|
||||||
- LEVEL 4 OVERRIDE (LIVE 2026-10-26, first payout Monday 2026-11-02): company-paid, off-chain decision, on-chain payment. 3% of every package purchase (the POL actually paid) goes to the buyer's 4th upline on the contract sponsor chain if that member's contract buyerCount is 5 or more (qualifying buyer = direct referral with a $20+ purchase, same bar as level 3); otherwise it hunts up to the next qualified upline, max 25 hops; the company account (#1) or no qualified upline = company keeps it; exactly one recipient per purchase. Paid weekly in POL every Monday after 9 AM Central for the previous Monday to Sunday Central week, from a company payer wallet via the contract's award(memberId), shown in Earnings as 'Level 4 override' with a Polygon link and announced by email and an on-site notice. Under 0.01 POL carries to the next week. Purchases from the start date only, no back pay. Funded from the platform's 20%; the contract split 50/20/10 is unchanged. Never promise amounts.
|
- LEVEL 4 OVERRIDE (LIVE 2026-10-26, first payout Monday 2026-11-02): company-paid, off-chain decision, on-chain payment. 3% of every package purchase (the POL actually paid) goes to the buyer's 4th upline on the contract sponsor chain if that member's contract buyerCount is 5 or more (qualifying buyer = direct referral with a $20+ purchase, same bar as level 3); otherwise it hunts up to the next qualified upline, max 25 hops; the company account (#1) or no qualified upline = company keeps it; exactly one recipient per purchase. Paid weekly in POL every Monday after 9 AM Central for the previous Monday to Sunday Central week, from a company payer wallet via the contract's award(memberId), shown in Earnings as 'Level 4 override' with a Polygon link and announced by email and an on-site notice. Under 0.01 POL carries to the next week. Purchases from the start date only, no back pay. Funded from the platform's 20%; the contract split 50/20/10 is unchanged. Never promise amounts.
|
||||||
${passTiersFact()}${refuelFact()}${synFact()}${polminerFact()}${warpwaresFact()}${bixFact()}${turkeydropFact()}- ROAD AGENT (LIVE 2026-10-15, https://roadagent.app): a night-highway shooter open to every member. Open the Games tab and tap Play on the Road Agent card, or go to roadagent.app and sign in with the InstantAdPay email. Drive the four-lane highway, shoot the hostiles (thug sedans, switchblades, gunner vans), spare the civilians, pull into the weapons truck for oil slicks, smoke and missiles. Clearing a sector for the first time pays POL to the wallet on the member's InstantAdPay account, plus a daily patrol reward; scrap buys garage upgrades. Fuel = a sponsor visit: before a run the player visits an advertiser's page (a FUEL STOP), which is a normal verified visit with the dwell timer and human check, charged to the advertiser like any visit; advertisers' existing visits campaigns are already in the rotation, nothing to set up; to get more traffic from the game, top up the visits campaign. Clickable Pause, Sound and Music buttons sit under the game (P / M / N keys also work), and the Run tab has an Invite a friend card with the member's roadagent.app/?ref=<username> link.
|
- NETWORK SIGN-IN (built 2026-11-12): one sign-in for InstantAdPay and LinkSpin, same email on both. A member signed in on one site who follows a link from inside their account to the other (Engine Room, Refuel, Back to InstantAdPay) arrives signed in with no email code; opening the other site's sign-in screen while signed in here also signs them in by itself (one quiet try per browser every 30 minutes). Exception: when the account on the receiving site does not exist yet or is still a waiting account (never signed in), they get the normal email code once, email prefilled. Sign-out is per site and switches the automatic sign-in off on that site for 12 hours (a deliberate link from the other site still works). Sessions are ordinary member sessions (4 hours), the admin portal is never shared, and the sign-in grants nothing extra: purchases, payouts and wallet actions still need the wallet. If it fails, the email code always works.
|
||||||
|
- EARNERS CORNER (LIVE 2026-11-10, https://earnerscorner.com): the network's own forum (Discourse) for people who earn online: business opportunities, PTC, traffic exchanges and mailers, crypto earning and wallets, affiliate marketing, tools, plus an Our Network section. Read is open to everyone; posting needs signing in with the InstantAdPay account (no separate forum password). New accounts' first posts are reviewed; links unlock with trust and are open from day one for members with an on-chain position; referral links only in Promote Your Program; AI spam detection; a forum assistant answers network questions from the same official knowledge and links threads.
|
||||||
|
- STACK POL (LIVE 2026-11-09, https://stackpol.com): one site that adds up every POL payout in the network (InstantAdPay and LinkSpin TierPaid referral payments plus every game's payouts), refreshed every 5 minutes, with per-program pages (/earn/<program>), a public ledger showing each payout's username and Polygonscan link, and a blog. Members get a public page at stackpol.com/<username> by switching on 'Show my Stack POL page' in Promo tools > Stack POL; it is ON by default for every paid member (since 2026-11-09) and off only when they switch it off. It never holds money. STACK POL PRO (2026-11-09): one-time unlock, NEW MONEY only: ANY package of $10 or more bought by the member's own position unlocks it automatically (since 2026-11-09 evening, no order step); credits never count; it never uses up a package that also fulfils a Game Pass or hero order. Pro pages show the member's own LinkSpin Banner Spins in the ad spots (network zones otherwise), their spin links, a purple QR code to the page, a 'Want a personalized page like this?' button, and articles opened from the page (?ref=<username>) use the member's referral on every call to action. Pro owners get the Stack POL Pro badge. Totals are past payouts, never a promise of earnings.
|
||||||
|
${passTiersFact()}${heroesFact()}${refuelFact()}${synFact()}${polminerFact()}${warpwaresFact()}${bixFact()}${turkeydropFact()}${sovTestFact()}- ROAD AGENT (LIVE 2026-10-15, https://roadagent.app): a night-highway shooter open to every member. Open the Games tab and tap Play on the Road Agent card, or go to roadagent.app and sign in with the InstantAdPay email. Drive the four-lane highway, shoot the hostiles (thug sedans, switchblades, gunner vans), spare the civilians, pull into the weapons truck for oil slicks, smoke and missiles. Clearing a sector for the first time pays POL to the wallet on the member's InstantAdPay account, plus a daily patrol reward; scrap buys garage upgrades. Fuel = a sponsor visit: before a run the player visits an advertiser's page (a FUEL STOP), which is a normal verified visit with the dwell timer and human check, charged to the advertiser like any visit; advertisers' existing visits campaigns are already in the rotation, nothing to set up; to get more traffic from the game, top up the visits campaign. Clickable Pause, Sound and Music buttons sit under the game (P / M / N keys also work), and the Run tab has an Invite a friend card with the member's roadagent.app/?ref=<username> link.
|
||||||
- HELP DESK (LIVE 2026-10-16): members open Help in the dashboard (/my#help) to send Marty a support ticket (pick a category, a subject, the message, up to 2 screenshots), see each ticket's status (Open, Waiting on you, Closed) and read and answer his replies; a badge shows when he has replied, and replies also arrive by email. Anyone signed out or locked out uses the public form at https://instantadpay.com/support (name, email, category, subject, message) and gets an email with the ticket number (like IAP-1042) and a private link to view and reply, no sign-in needed. support@instantadpay.com also reaches Marty. Replying to a closed ticket opens it again. In this chat, "Send this to support" turns the conversation into a ticket. Only Marty answers, so replies are not instant; never promise a response time.
|
- HELP DESK (LIVE 2026-10-16): members open Help in the dashboard (/my#help) to send Marty a support ticket (pick a category, a subject, the message, up to 2 screenshots), see each ticket's status (Open, Waiting on you, Closed) and read and answer his replies; a badge shows when he has replied, and replies also arrive by email. Anyone signed out or locked out uses the public form at https://instantadpay.com/support (name, email, category, subject, message) and gets an email with the ticket number (like IAP-1042) and a private link to view and reply, no sign-in needed. support@instantadpay.com also reaches Marty. Replying to a closed ticket opens it again. In this chat, "Send this to support" turns the conversation into a ticket. Only Marty answers, so replies are not instant; never promise a response time.
|
||||||
- PRESENTATION (2026-10-15): instantadpay.com/presentation is a public page (no sign-in) with the narrated InstantAdPay presentation, about six minutes, Marty's voice, captions in 6 languages (English, Italiano, Français, Español, Deutsch, Português) chosen with pills under the player. Sixteen parts: the platform, ad reach, the nine games that pay POL, the $20 split ($10 / $4 / $2 / $4 platform, same transaction), three rules, packages, the 2-then-5 unlock, pass-up, wide versus narrow ($800 vs $36, an illustration), Qualified Start, the Pipeline, LinkSpin (pre-launch Nov 1), one wallet across the network, the first week, and 'the target is five'. Share link: Members > Promo tools > 'Share the presentation' copies instantadpay.com/presentation?ref=<username>; ?ref sets the same 30-day sponsor cookie as the invite link, the page shows 'Shared with you by @name' with avatar and a Join button to /join/<username>. It is in the site menu as 'Presentation'. BUILD WIDE VIDEO: first card in Promo tools > Videos ('Build wide: watch the payments flow'), matched link ?v=wide.
|
- PRESENTATION (2026-10-15): instantadpay.com/presentation is a public page (no sign-in) with the narrated InstantAdPay presentation, about six minutes, Marty's voice, captions in 6 languages (English, Italiano, Français, Español, Deutsch, Português) chosen with pills under the player. Sixteen parts: the platform, ad reach, the nine games that pay POL, the $20 split ($10 / $4 / $2 / $4 platform, same transaction), three rules, packages, the 2-then-5 unlock, pass-up, wide versus narrow ($800 vs $36, an illustration), Qualified Start, the Pipeline, LinkSpin (pre-launch Nov 1), one wallet across the network, the first week, and 'the target is five'. Share link: Members > Promo tools > 'Share the presentation' copies instantadpay.com/presentation?ref=<username>; ?ref sets the same 30-day sponsor cookie as the invite link, the page shows 'Shared with you by @name' with avatar and a Join button to /join/<username>. It is in the site menu as 'Presentation'. BUILD WIDE VIDEO: first card in Promo tools > Videos ('Build wide: watch the payments flow'), matched link ?v=wide.
|
||||||
- WIRED WEDNESDAY: every Wednesday, Central time (midnight to midnight), any ad package of $20 or more (Activation and up; no $10 pack exists) earns +25% bonus credits wired into the buyer's balance the moment the purchase settles, purchased-grade (usable on every format incl. login ads), credit log label "Wired Wednesday". First one: Wednesday 2026-09-30. Page: instantadpay.com/wednesday. Credits buy ad delivery, never money.
|
- WIRED WEDNESDAY: every Wednesday, Central time (midnight to midnight), any ad package of $20 or more (Activation and up; no $10 pack exists) earns +25% bonus credits wired into the buyer's balance the moment the purchase settles, purchased-grade (usable on every format incl. login ads), credit log label "Wired Wednesday". First one: Wednesday 2026-09-30. Page: instantadpay.com/wednesday. Credits buy ad delivery, never money.
|
||||||
|
- CONVERSION LINKAGE (LIVE 2026-11-07, reporting only: it never changes sponsors, payouts, credits or anything on chain): a LinkSpin click id (lsclk or lsid in the address) arriving on any InstantAdPay page is kept 30 days in a first-party cookie (last click wins) and travels with the code request, and is stored with the account at sign-up, in-game sign-in included when the game passes it on. InstantAdPay then reports sign-up, wallet link and each package purchase (value = the USD price on the chain event, linked positions included) to LinkSpin, which counts join and wallet once per click and each purchase on its own, for the click's owner. The landing tag adds the click id to links to instantadpay.com, linkspin.app and the share domains, also inside a member's own redirect link; a spin link or Banner Spin pointed straight at those sites carries it with no goal needed. 30 days from the click to the event, same as goals. The first account on a click owns it. The click owner's own account and own clicks are never counted. People who joined before 2026-11-07 cannot be matched afterwards. Shown on the Conversion tracking card (with goals, 30 days) and in LinkSpin under Reports, Conversions.
|
||||||
- CONVERSION TRACKING (LIVE 2026-10-23): Campaigns > Conversion tracking in /my#campaigns. Every click on a member's ad (through /api/ads/click) gets a click id added to the target address as lsclk=<id>; the advertiser adds a goal (name like subscriber or sale, optional default value), puts the LinkSpin landing tag (t.js) on the page the ad points to and the goal pixel (cv.gif image, or the cv.js script) on the thank-you page. LinkSpin (sister site, same email) counts the goals; matching order: click id in the address (url, surest), the id the landing tag stored (stored), LinkSpin's cookie (cookie), a 24-hour match on hashed IP plus browser (soft, least sure). Each goal counts once per click, only within 30 days of a real click, only for the pixel owner's own ads; the advertiser's own clicks (signed in, or from a browser they sign in from; their linked positions share their email so count as them too) and the Send a test conversion button count as tests, never in the numbers; the card shows 'N from your own clicks, kept as tests'. SEND A TEST CONVERSION (2026-10-26) loads the member's real LinkSpin pixel in test mode from their browser (falls back to the signed partner call if the browser blocks it), so Last test updates. Each campaign row shows goals and COST PER GOAL (30 DAYS) in credits (2026-10-26: the credits the campaign spent in the last 30 days, from the credit activity log, divided by its goals in the same 30 days; a campaign started inside the window uses its spend since start; never quote it in dollars). Autoresponder tip: set the Aweber or GetResponse thank-you (success) page to a page on the member's own site carrying the goal pixel (Aweber: Thank You Page: custom page; GetResponse: Thank-you page: custom URL); if they cannot, the cookie or the 24-hour match can still count it, less surely. Privacy: the click id is random and nothing personal is sent. SETUP GUIDE (public, 2026-10-24): https://instantadpay.com/conversion-tracking (LinkSpin's copy: https://linkspin.app/conversion-tracking): why track, the flow, the 4 steps (goal, landing tag, goal pixel, test), copy-paste examples (plain HTML, WordPress footer plugin + Custom HTML block, page builders, Aweber/GetResponse custom thank-you page), the page check (add &test=1 to the pixel address, open the thank-you page, Last test updates, then remove it), what to do without code on the thank-you page, how to read the report and a troubleshooting checklist (same domain for landing and thank-you page, goal pixel only on the thank-you page, the script version is surest). Send members there for any setup question.
|
- CONVERSION TRACKING (LIVE 2026-10-23): Campaigns > Conversion tracking in /my#campaigns. Every click on a member's ad (through /api/ads/click) gets a click id added to the target address as lsclk=<id>; the advertiser adds a goal (name like subscriber or sale, optional default value), puts the LinkSpin landing tag (t.js) on the page the ad points to and the goal pixel (cv.gif image, or the cv.js script) on the thank-you page. LinkSpin (sister site, same email) counts the goals; matching order: click id in the address (url, surest), the id the landing tag stored (stored), LinkSpin's cookie (cookie), a 24-hour match on hashed IP plus browser (soft, least sure). Each goal counts once per click, only within 30 days of a real click, only for the pixel owner's own ads; the advertiser's own clicks (signed in, or from a browser they sign in from; their linked positions share their email so count as them too) and the Send a test conversion button count as tests, never in the numbers; the card shows 'N from your own clicks, kept as tests'. SEND A TEST CONVERSION (2026-10-26) loads the member's real LinkSpin pixel in test mode from their browser (falls back to the signed partner call if the browser blocks it), so Last test updates. Each campaign row shows goals and COST PER GOAL (30 DAYS) in credits (2026-10-26: the credits the campaign spent in the last 30 days, from the credit activity log, divided by its goals in the same 30 days; a campaign started inside the window uses its spend since start; never quote it in dollars). Autoresponder tip: set the Aweber or GetResponse thank-you (success) page to a page on the member's own site carrying the goal pixel (Aweber: Thank You Page: custom page; GetResponse: Thank-you page: custom URL); if they cannot, the cookie or the 24-hour match can still count it, less surely. Privacy: the click id is random and nothing personal is sent. SETUP GUIDE (public, 2026-10-24): https://instantadpay.com/conversion-tracking (LinkSpin's copy: https://linkspin.app/conversion-tracking): why track, the flow, the 4 steps (goal, landing tag, goal pixel, test), copy-paste examples (plain HTML, WordPress footer plugin + Custom HTML block, page builders, Aweber/GetResponse custom thank-you page), the page check (add &test=1 to the pixel address, open the thank-you page, Last test updates, then remove it), what to do without code on the thank-you page, how to read the report and a troubleshooting checklist (same domain for landing and thank-you page, goal pixel only on the thank-you page, the script version is surest). Send members there for any setup question.
|
||||||
- FIVE DOLLAR FRIDAY: every Friday, Central time, any ad package of $5 or more earns +20% bonus credits, credited the moment the purchase settles (credit log shows the label). First one: Friday 2026-09-25. Since 2026-10-23 the same $5+ Friday package also gives a FREE 7-day Game Pass automatically (once per member per Friday; not a second week when that package itself fulfils a pass order; the Game Pass badge posts the first time). Five Fridays in a row = the Five Fridays badge. The point: the whole network buys on the same day, every pack pays its sponsor line in the same transaction, so every line gets paid at once. No income promises.
|
- FIVE DOLLAR FRIDAY: every Friday, Central time, any ad package of $5 or more earns +20% bonus credits, credited the moment the purchase settles (credit log shows the label). First one: Friday 2026-09-25. Since 2026-10-23 the same $5+ Friday package also gives a FREE 7-day Game Pass automatically (once per member per Friday; not a second week when that package itself fulfils a pass order; the Game Pass badge posts the first time). Five Fridays in a row = the Five Fridays badge. The point: the whole network buys on the same day, every pack pays its sponsor line in the same transaction, so every line gets paid at once. No income promises.
|
||||||
- SESSIONS LAST 4 HOURS. Sign-ins expire after 4 hours and the member signs in again with a fresh 6-digit code. This is intentional and we say so plainly: it keeps resources optimised, and the login sponsor ad shown on the way back in is part of what pays for the free side. Nothing is lost on expiry - credits, line and account are untouched. Never describe it as a bug, an error, or something to report.
|
- SESSIONS LAST 4 HOURS. Sign-ins expire after 4 hours and the member signs in again with a fresh 6-digit code. This is intentional and we say so plainly: it keeps resources optimised, and the login sponsor ad shown on the way back in is part of what pays for the free side. Nothing is lost on expiry - credits, line and account are untouched. Never describe it as a bug, an error, or something to report.
|
||||||
- Free to join with email only (6-digit code sign-in, no passwords). Wallet appears only at purchase or payout activation. Every new member gets a small welcome batch of ad credits — unlocked by the WELCOME TOUR on first sign-in: they visit their upline's line-banner sites (up to 3, 10 seconds each — the same 3 levels the contract pays), then claim the credits. Members with no upline banners get the credits instantly.
|
- Free to join with email only (6-digit code sign-in, no passwords). Wallet appears only at purchase or payout activation. Every new member gets a small welcome batch of ad credits — unlocked by the WELCOME TOUR on first sign-in: they visit their upline's line-banner sites (up to 3, 10 seconds each — the same 3 levels the contract pays), then claim the credits. Members with no upline banners get the credits instantly.
|
||||||
- SPONSOR ATTRIBUTION: last touch. The invite link opened most recently sets the sponsor (30-day cookie), shown on the join page and again at the code step ("Joining under @name"). It locks when the account is created; the contract binds the buyer to that sponsor at their first purchase. Wrong sponsor before joining: open the right link. Already joined wrong: admin can move the account before the first purchase.
|
- SPONSOR ATTRIBUTION: last touch. The invite link opened most recently sets the sponsor (30-day cookie), shown on the join page and again at the code step ("Joining under @name"). It locks when the account is created; the contract binds the buyer to that sponsor at their first purchase. Wrong sponsor before joining: open the right link. Already joined wrong: admin can move the account before the first purchase.
|
||||||
- YOUR LINKS (top of Members > Promo tools): the plain invite link plus five angle links (?v=instant paid-in-seconds, ?v=adspend you-buy-ads-anyway, ?v=free costs-nothing-to-try, ?v=ledger no-back-office, ?v=two two-buyers-open-level-two, ?v=wide width-unlocks-depth with the Build Wide video; ?v=play opens the games angle), each with a who-it-is-for note, Copy and Share. Same credit either way; only the first page differs. Link stats on the Overview's coaching card show views/joins/buyers per angle.
|
- YOUR LINKS (top of Members > Promo tools): the plain invite link plus five angle links (?v=instant paid-in-seconds, ?v=adspend you-buy-ads-anyway, ?v=free costs-nothing-to-try, ?v=ledger no-back-office, ?v=two two-buyers-open-level-two, ?v=wide width-unlocks-depth with the Build Wide video; ?v=play opens the games angle), each with a who-it-is-for note, Copy and Share. Same credit either way; only the first page differs. Link stats on the Overview's coaching card show views/joins/buyers per angle.
|
||||||
- PROMO TOOLS (Members > Promo tools, pill menu): Social posts for X/Facebook/LinkedIn/Telegram-WhatsApp with post/share buttons; Text a friend (5 SMS-sized messages with Text it / WhatsApp / Telegram / Copy); Email swipes (short, standard, long, follow-up); Banners in every standard ad size plus 1080x1080, 1080x1920 and 1280x720 (download or copy URL); the member's Banner wall link; an Objection handling bank (truth + ready-to-send reply); a Videos tab with five hook videos, one per angle (Paid before the page reloads, You were buying traffic anyway, Watch first spend never, No back office, Two buyers open level two), each with a caption and the matched angle link, and at Circuit the Video Maker renders them with the member's own end card and QR; a Toolkit tab showing the badge ladder and the AI Copy Engine. Every piece carries the member's invite link; angle links add ?v=instant|adspend|free|ledger. Members who want copy in their own voice can use mybrandedvoice.com. The Games tab (2026-10-31) also carries the EnjoyBestGames arcade kit: enjoybestgames.com is an engagement site with hundreds of free HTML5 games; the featured row Games that pay Polygon is the network's own games and the only ones that pay; the member link enjoybestgames.com/?r=username sets a 30-day cookie so every featured game and the site strip credit that member on InstantAdPay; share image, 4 posts and the 11 banner sizes are in the kit.
|
- PROMO TOOLS (Members > Promo tools, pill menu): Social posts for X/Facebook/LinkedIn/Telegram-WhatsApp with post/share buttons; Text a friend (5 SMS-sized messages with Text it / WhatsApp / Telegram / Copy); Email swipes (short, standard, long, follow-up); Banners in every standard ad size plus 1080x1080, 1080x1920 and 1280x720 (download or copy URL); the member's Banner wall link; an Objection handling bank (truth + ready-to-send reply); a Videos tab with five hook videos, one per angle (Paid before the page reloads, You were buying traffic anyway, Watch first spend never, No back office, Two buyers open level two), each with a caption and the matched angle link, and at Circuit the Video Maker renders them with the member's own end card and QR; a Toolkit tab showing the badge ladder and the AI Copy Engine. Every piece carries the member's invite link; angle links add ?v=instant|adspend|free|ledger. Members who want copy in their own voice can use mybrandedvoice.com. The Games tab (2026-10-31) also carries the EnjoyBestGames arcade kit: enjoybestgames.com is an engagement site with hundreds of free HTML5 games; the featured row Games that pay Polygon is the network's own games and the only ones that pay; the member link enjoybestgames.com/?r=username sets a 30-day cookie so every featured game and the site strip credit that member on InstantAdPay; share image, 4 posts and the 11 banner sizes are in the kit. The Network sites tab (2026-11-14) shows the Downline Banners and Viral Banner Blitz promo kits, read live from each site: the member's links (their InstantAdPay username is their sponsor link there too, even if they never visited), creatives in 7 sizes per angle, 5 lines, 3 headlines, an email and 2 posts; the same kits are on downlinebanners.com/promote and viralbannerblitz.com/promote. Viral Banner Blitz: a shared loop of 125x125 banners, one free post credit a day for InstantAdPay/LinkSpin members, verified visitors move the loop, a banner that cycles earns network ad views (advertising, not cash), weekly leaderboards with a POL prize pot.
|
||||||
- INVITE PAGES: a member's link instantadpay.com/join/<username> opens a lead-capture page (email first, wallet later); add ?v=instant|adspend|free|ledger|two|wide|play for an angle-matched headline (?v=wide: 'Width unlocks depth.', opens on the Build Wide video, vertical on phones). New free members get a short getting-started email series over the first week (unsubscribe link in every email; the admin edits the sequence in /admin > Settings).
|
- INVITE PAGES: a member's link instantadpay.com/join/<username> opens a lead-capture page (email first, wallet later); add ?v=instant|adspend|free|ledger|two|wide|play for an angle-matched headline (?v=wide: 'Width unlocks depth.', opens on the Build Wide video, vertical on phones). New free members get a short getting-started email series over the first week (unsubscribe link in every email; the admin edits the sequence in /admin > Settings).
|
||||||
- WALLET DRAIN WARNING: Trust Wallet hard-blocks any purchase that spends most of the wallet's POL ("this transaction will drain your wallet", only "Stop and go back"). It is a balance-proportion heuristic, not a contract issue (there are no token approvals; a buy is one native-POL payable call). Advice: smaller package first, or add POL so the buy is well under half the balance, or use MetaMask/Phantom/SafePal (no hard block). The dashboard warns Trust Wallet users before sending when a buy would use more than ~55% of the balance; other wallets are not prompted. After a blocked attempt the WalletConnect session may be dead: Wallet tab > Disconnect > Connect again.
|
- WALLET DRAIN WARNING: Trust Wallet hard-blocks any purchase that spends most of the wallet's POL ("this transaction will drain your wallet", only "Stop and go back"). It is a balance-proportion heuristic, not a contract issue (there are no token approvals; a buy is one native-POL payable call). Advice: smaller package first, or add POL so the buy is well under half the balance, or use MetaMask/Phantom/SafePal (no hard block). The dashboard warns Trust Wallet users before sending when a buy would use more than ~55% of the balance; other wallets are not prompted. After a blocked attempt the WalletConnect session may be dead: Wallet tab > Disconnect > Connect again.
|
||||||
- WALL OWNERSHIP LADDER: the public wall has 3 positions. Position 1 = the member's line banner. Positions 2 and 3 show upline banners (then house ads) UNTIL the member earns them: 2 qualifying buyers ($20+) unlock position 2, 5 unlock position 3; a fully qualified member's wall is 100% their own links/offers (set in Profile > Your wall: label, https link, optional banner image). Empty unlocked slots fall back to upline banners, then house ads.
|
- WALL OWNERSHIP LADDER: the public wall has 3 positions. Position 1 = the member's line banner. Positions 2 and 3 show upline banners (then house ads) UNTIL the member earns them: 2 qualifying buyers ($20+) unlock position 2, 5 unlock position 3; a fully qualified member's wall is 100% their own links/offers (set in Profile > Your wall: label, https link, optional banner image). Empty unlocked slots fall back to upline banners, then house ads.
|
||||||
@@ -330,8 +380,11 @@ ${passTiersFact()}${refuelFact()}${synFact()}${polminerFact()}${warpwaresFact()}
|
|||||||
- WALLETS + BUYING POL (Training > Wallets and buying POL, /wallets, members only): preferred MetaMask (recommended; extra accounts for Qualified Start), Phantom (PHANTOM GOTCHA: Polygon is OFF by default; Settings > Active Networks > turn on Polygon, otherwise connect/buy fails or shows the wrong network; seen with Jim Watts' EB team 2026-09-13), SafePal, Coinbase Wallet; Trust works but blocks buys spending most of its POL (keep ~2x). MoonPay flow: connect wallet, Buy packages > "Buy POL with a card" opens MoonPay with POL on Polygon + the member's address prefilled; card/Apple Pay/Google Pay; first-time ID check; minimum order ~$30; buy package cost + 2-3 POL for fees; POL arrives in minutes; then buy. Exchanges: withdraw POL on the Polygon network. Never MATIC on Ethereum, never share the recovery phrase.
|
- WALLETS + BUYING POL (Training > Wallets and buying POL, /wallets, members only): preferred MetaMask (recommended; extra accounts for Qualified Start), Phantom (PHANTOM GOTCHA: Polygon is OFF by default; Settings > Active Networks > turn on Polygon, otherwise connect/buy fails or shows the wrong network; seen with Jim Watts' EB team 2026-09-13), SafePal, Coinbase Wallet; Trust works but blocks buys spending most of its POL (keep ~2x). MoonPay flow: connect wallet, Buy packages > "Buy POL with a card" opens MoonPay with POL on Polygon + the member's address prefilled; card/Apple Pay/Google Pay; first-time ID check; minimum order ~$30; buy package cost + 2-3 POL for fees; POL arrives in minutes; then buy. Exchanges: withdraw POL on the Polygon network. Never MATIC on Ethereum, never share the recovery phrase.
|
||||||
- PROHIBITED CONTENT (2026-10-30, Terms section 8, /terms#prohibited): gambling, casinos, betting, lotteries, sweepstakes; adult or sexual content; drugs and prescription pharmaceuticals; weapons; hate or harassment; malware, phishing, counterfeit goods; misleading financial promises. Refused at save time in bios, social links, line banners, wall offers and every campaign field. A bio may not contain a URL or a domain (links go in the social fields). Profile text, avatar and social links appear on the public wall ONLY for members who have bought a package; a free account's wall shows the name, the line's ads and the join button. Link-farm accounts (created to plant links in profile fields) are removed without notice with their profile text.
|
- PROHIBITED CONTENT (2026-10-30, Terms section 8, /terms#prohibited): gambling, casinos, betting, lotteries, sweepstakes; adult or sexual content; drugs and prescription pharmaceuticals; weapons; hate or harassment; malware, phishing, counterfeit goods; misleading financial promises. Refused at save time in bios, social links, line banners, wall offers and every campaign field. A bio may not contain a URL or a domain (links go in the social fields). Profile text, avatar and social links appear on the public wall ONLY for members who have bought a package; a free account's wall shows the name, the line's ads and the join button. Link-farm accounts (created to plant links in profile fields) are removed without notice with their profile text.
|
||||||
- INTRO VIDEO ON THE WALL: Profile > social links has an "Intro video" field (YouTube, Vimeo or direct .mp4 link). It embeds on the member's public wall page (/wall/<username>) right under their bio, above the three-level line and the join button.
|
- INTRO VIDEO ON THE WALL: Profile > social links has an "Intro video" field (YouTube, Vimeo or direct .mp4 link). It embeds on the member's public wall page (/wall/<username>) right under their bio, above the three-level line and the join button.
|
||||||
- HOLDING TANK (Members > My line > Holding tank card): free members who joined with no sponsor wait there; a member who has switched on payouts AND bought their own $20+ package can Adopt one (first come, max 2 open adoptions, 7-day window; if the person never links a wallet or buys, they fall back into the tank; a person can be adopted twice at most). Adopting sets the sponsor, opens a chat and emails the member; their first purchase then binds to the adopter on-chain. Members can also "Release to tank" one of their own free referrals (pay it forward), but NOT someone they adopted less than 3 days ago: an adoption is a commitment, and a dropped adoption still counts toward that person's two-adoption lifetime limit. Releases are posted to the feed and Telegram like pickups. Admin sees the tank under Members.
|
- BTC4HITS (2026-11-11): members of the closed BTC4Hits rotator site with a deliverable email were imported as waiting accounts (no wallet, no password, nothing mailed), with their BTC4Hits sponsor when that sponsor was also imported or already a member; the rest join the holding tank when they first sign in. They sign in here with the same email (code sign-in), or on LinkSpin at linkspin.app/from/btc4hits, where their active rotators became spin links. Pro status and old BTC4Hits commissions do not carry over.
|
||||||
- TANK ACTIVATION HOLD (2026-10-27, Marty: never default a tank member to the company): a tank member (no sponsor, not activated) can NOT switch on payouts on its own yet (a PURCHASE is NEVER held, Marty 2026-10-27: with no sponsor anywhere a buy goes ahead under the catch position #1); the Wallet tab and Getting started card say "You're being matched with a sponsor. Payouts switch on as soon as someone picks you up (within 24 hours)." with the time left, and the activate button is hidden. The 24-hour clock starts when they link a wallet; they then show at the top of every holding tank with a green "Ready to activate" badge and hours left, and a post goes to the team's Telegram payments topic. If nobody adopts them in 24 hours, the site auto-assigns them to the next eligible adopter in rotation (own $20+ package, fewer than 2 open adoptions, signed in within 7 days, not suspended; least recently auto-assigned first); the adopter gets a chat + email and Telegram shows the pickup marked (auto-assigned). If nobody is eligible they stay on hold and the admin is alerted; never the company. Someone whose same email or wallet already has a sponsor on LinkSpin is placed under that sponsor instead (not one they were released or rescued from). A member who arrived through a sponsor link is never held. Once they have a sponsor the hold lifts by itself. ONE-TAP SWITCH ON PAYOUTS (2026-10-27): every tank assignment (manual adoption or the 24-hour auto-assign) sends the member a chat and an email with a Switch on payouts link, https://instantadpay.com/my?activate=1#wallet; it opens the Wallet tab and starts the normal Activate payouts flow with the new sponsor prefilled (after sign-in, and after linking a wallet if none is linked yet). It never starts while the hold applies or when no sponsor resolves. The site cannot activate for anyone: activation is one free transaction from the member's own wallet. Not activated 24 hours after the assignment: one reminder email to the member with the same link and one notice to the sponsor ("@x hasn't switched on payouts yet; a nudge from you helps"); at 72 hours one last email to the member only; both stop once the member switches on payouts or buys.
|
- HOLDING TANK (Members > My line > Holding tank card): free members who joined with no sponsor wait there; new sign-ups cannot be adopted by hand for 24 hours from sign-up (they show an Opens in badge and no Adopt button); a member who has switched on payouts AND bought their own $20+ package can Adopt one (first come, max 10 held at one time, counting those not yet switched on payouts, 7-day window; if the person never links a wallet or buys, they fall back into the tank; a person can be adopted twice at most). Adopting sets the sponsor, opens a chat and emails the member; their first purchase then binds to the adopter on-chain. Members can also "Release to tank" one of their own free referrals (pay it forward), but NOT someone they adopted less than 3 days ago: an adoption is a commitment, and a dropped adoption still counts toward that person's two-adoption lifetime limit. Releases are posted to the feed and Telegram like pickups. Admin sees the tank under Members.
|
||||||
|
- WHO INVITED YOU (2026-11-07, Marty approved): a member with no sponsor and no member number sees a Who invited you? card on their Overview. They type a username, confirm in an in-page box, and that member becomes their sponsor (it follows to LinkSpin, lifts the activation hold, and the sponsor gets a new-referral email and notice). Refused: themselves, a username that does not exist, someone in their own line, a member who cannot take new members, a member with no payouts on and nobody above them on the contract, and anyone who already has a sponsor or a member number. Nobody invited me hides the card (a small Overview link brings it back while they are in the tank) and changes nothing else. It never blocks the site. It is not an adoption: no 7-day window and it does not count toward the two.
|
||||||
|
- SIGN-UP GRACE (2026-11-07): for 24 hours from sign-up nobody can adopt a member by hand. The 24-hour auto-assign is unchanged and runs from the wallet link, so a member who links a wallet in their first hour is matched about 24 hours after linking, with at most a short hand-adoption window first. Members back in the tank later have no grace.
|
||||||
|
- TANK ACTIVATION HOLD (2026-10-27, Marty: never default a tank member to the company): a tank member (no sponsor, not activated) can NOT switch on payouts on its own yet (a PURCHASE is NEVER held, Marty 2026-10-27: with no sponsor anywhere a buy goes ahead under the catch position #1); the Wallet tab and Getting started card say "You're being matched with a sponsor. Payouts switch on as soon as someone picks you up (within 24 hours)." with the time left, and the activate button is hidden. The 24-hour clock starts when they link a wallet; they then show at the top of every holding tank with a green "Ready to activate" badge and hours left, and a post goes to the team's Telegram payments topic. If nobody adopts them in 24 hours, the site auto-assigns them to the next eligible adopter in rotation (own $20+ package, fewer than 10 people held from the tank who have not switched on payouts yet, signed in within 7 days, not suspended; least recently auto-assigned first); the adopter gets a chat + email and Telegram shows the pickup marked (auto-assigned). If nobody is eligible they stay on hold and the admin is alerted; never the company. Someone whose same email or wallet already has a sponsor on LinkSpin is placed under that sponsor instead (not one they were released or rescued from). A member who arrived through a sponsor link is never held. Once they have a sponsor the hold lifts by itself. ONE-TAP SWITCH ON PAYOUTS (2026-10-27): every tank assignment (manual adoption or the 24-hour auto-assign) sends the member a chat and an email with a Switch on payouts link, https://instantadpay.com/my?activate=1#wallet; it opens the Wallet tab and starts the normal Activate payouts flow with the new sponsor prefilled (after sign-in, and after linking a wallet if none is linked yet). It never starts while the hold applies or when no sponsor resolves. The site cannot activate for anyone: activation is one free transaction from the member's own wallet. Not activated 24 hours after the assignment: one reminder email to the member with the same link and one notice to the sponsor ("@x hasn't switched on payouts yet; a nudge from you helps"); at 72 hours one last email to the member only; both stop once the member switches on payouts or buys.
|
||||||
- DAILY CLAIM STREAK: finishing the daily ad set and claiming pays 5 credits on day 1, 7 on day 2, 10 from day 3, and 25 on every 7th consecutive day; miss a day and it restarts. After the set, verified visits (up to 20 a day, 1 credit each) keep earning, and the credits are meant to be spent on a campaign.
|
- DAILY CLAIM STREAK: finishing the daily ad set and claiming pays 5 credits on day 1, 7 on day 2, 10 from day 3, and 25 on every 7th consecutive day; miss a day and it restarts. After the set, verified visits (up to 20 a day, 1 credit each) keep earning, and the credits are meant to be spent on a campaign.
|
||||||
- FOUR-MINUTE OVERVIEW VIDEO (2026-09-16): 'InstantAdPay in four minutes' is the first card on Members > Training (group 'Start here') and embedded on the home page at instantadpay.com/#overview-video (hero button 'Watch the 4-minute overview'). Send it to anyone asking what the platform is; the tab-by-tab walkthrough videos on Training go deeper. It is evergreen: no dates, no launch talk.
|
- FOUR-MINUTE OVERVIEW VIDEO (2026-09-16): 'InstantAdPay in four minutes' is the first card on Members > Training (group 'Start here') and embedded on the home page at instantadpay.com/#overview-video (hero button 'Watch the 4-minute overview'). Send it to anyone asking what the platform is; the tab-by-tab walkthrough videos on Training go deeper. It is evergreen: no dates, no launch talk.
|
||||||
- ANTI-FRAUD CHECKS (2026-09-16): at sign-up the site records IP, browser type and a browser cookie id. A second account from a browser that already has one is refused, so is a burst of new accounts from one connection in a day, and so is a sign-up through an invite link whose owner used that same browser. A sign-up from the same IP as the sponsor is allowed but flagged (households are fine). Flagged accounts never count on the leaderboard and cannot adopt from the holding tank; a suspended account cannot sign in. If a member says they were refused at sign-up, or asks how to get a second account to qualify themselves: one account per person, sign in to the existing one, and use QUALIFIED START (Buy packages tab) to link extra wallets of their own as positions under that account; each linked wallet that buys $20+ counts as one of their qualifying buyers, credits pool, and half of each such purchase returns to their main wallet. Levels 2 and 3 open at 2 and 5 qualifying buyers whether those buyers are referrals or the member's own linked positions. Shared computer at work or a library: contact support. Never suggest a second account.
|
- ANTI-FRAUD CHECKS (2026-09-16): at sign-up the site records IP, browser type and a browser cookie id. A second account from a browser that already has one is refused, so is a burst of new accounts from one connection in a day, and so is a sign-up through an invite link whose owner used that same browser. A sign-up from the same IP as the sponsor is allowed but flagged (households are fine). Flagged accounts never count on the leaderboard and cannot adopt from the holding tank; a suspended account cannot sign in. If a member says they were refused at sign-up, or asks how to get a second account to qualify themselves: one account per person, sign in to the existing one, and use QUALIFIED START (Buy packages tab) to link extra wallets of their own as positions under that account; each linked wallet that buys $20+ counts as one of their qualifying buyers, credits pool, and half of each such purchase returns to their main wallet. Levels 2 and 3 open at 2 and 5 qualifying buyers whether those buyers are referrals or the member's own linked positions. Shared computer at work or a library: contact support. Never suggest a second account.
|
||||||
@@ -345,11 +398,14 @@ ${passTiersFact()}${refuelFact()}${synFact()}${polminerFact()}${warpwaresFact()}
|
|||||||
- PIPELINE (live since 2026-09-15): a follow-up board on the dashboard, tab 'Pipeline' between My line and Buy packages, with its own training video on the Training tab. Columns: Talking to, Joined, Wallet linked, Payouts on, Bought, Building, Later. Prospects (from the My line prospect list) and directs are placed automatically from what they have actually done (coaching rung, on-chain buys); nobody drags cards. The sponsor adds a note, a follow-up date and a tag (hot, later, no response, not interested); a 'Follow up today' strip lists due cards; stalled cards (quiet 3+ days) are flagged; each card carries the message for its exact stage with 'Open chat with this message' (member chat) or copy.
|
- PIPELINE (live since 2026-09-15): a follow-up board on the dashboard, tab 'Pipeline' between My line and Buy packages, with its own training video on the Training tab. Columns: Talking to, Joined, Wallet linked, Payouts on, Bought, Building, Later. Prospects (from the My line prospect list) and directs are placed automatically from what they have actually done (coaching rung, on-chain buys); nobody drags cards. The sponsor adds a note, a follow-up date and a tag (hot, later, no response, not interested); a 'Follow up today' strip lists due cards; stalled cards (quiet 3+ days) are flagged; each card carries the message for its exact stage with 'Open chat with this message' (member chat) or copy.
|
||||||
- LEADER TOOLS (since 2026-10-16): a 'Leader tools' section on the Training tab with the Leader's Guide (a downloadable PDF: building wide, how width unlocks levels 2 and 3, network reach, Qualified Start, LinkSpin, the wallet as your key, the first week), the narrated presentation to share, and the Build wide video. My line and Pipeline each have a Leader tools card with a direct 'Download the Leader's Guide (PDF)' button and 'Open Leader tools'.
|
- LEADER TOOLS (since 2026-10-16): a 'Leader tools' section on the Training tab with the Leader's Guide (a downloadable PDF: building wide, how width unlocks levels 2 and 3, network reach, Qualified Start, LinkSpin, the wallet as your key, the first week), the narrated presentation to share, and the Build wide video. My line and Pipeline each have a Leader tools card with a direct 'Download the Leader's Guide (PDF)' button and 'Open Leader tools'.
|
||||||
- UNACTIVATED SPONSOR = WALK UP, NEVER HOLD (2026-09-16, Marty): if a buyer's sponsor has not linked a wallet or switched on payouts, the purchase is NOT held. The site walks the sponsor line upward to the first upline who is activated with payouts on and the buy goes through under them (on-chain sponsorship for that buyer is then theirs, permanently); if nobody in the line is activated it goes under the company catch position (#1). The buyer sees a one-line notice and proceeds; once the position exists on the chain the skipped sponsor gets a blunt email + on-site message (they lost this referral for good, how to switch on payouts) and the upline who was paid gets a message that the referral is theirs permanently with a nudge to coach the one who missed it; the referral MOVES to whoever got paid (the account's stored sponsor is re-pointed when the position is created on-chain), so the buyer leaves the skipped sponsor's My line for good; the skipped sponsor can never earn from that wallet. Only a transient chain error ('rpc') still pauses a buy ("try again in a minute").
|
- UNACTIVATED SPONSOR = WALK UP, NEVER HOLD (2026-09-16, Marty): if a buyer's sponsor has not linked a wallet or switched on payouts, the purchase is NOT held. The site walks the sponsor line upward to the first upline who is activated with payouts on and the buy goes through under them (on-chain sponsorship for that buyer is then theirs, permanently); if nobody in the line is activated it goes under the company catch position (#1). The buyer sees a one-line notice and proceeds; once the position exists on the chain the skipped sponsor gets a blunt email + on-site message (they lost this referral for good, how to switch on payouts) and the upline who was paid gets a message that the referral is theirs permanently with a nudge to coach the one who missed it; the referral MOVES to whoever got paid (the account's stored sponsor is re-pointed when the position is created on-chain), so the buyer leaves the skipped sponsor's My line for good; the skipped sponsor can never earn from that wallet. Only a transient chain error ('rpc') still pauses a buy ("try again in a minute").
|
||||||
|
- CHASING UNICORNS (2026-11-12): a promo tool at instantadpay.com/chasing-unicorns (Members > Promo tools > 'Chasing Unicorns: the scam-spotting game', copy your own link, which ends in ?ref=<your username> so a join counts for you). It is a clearly labeled training simulation: a fake 'UnicornYield Pro' dashboard (ticking balance, countdown, fake cash-out popups, VIP upgrade, connect-wallet airdrop) where every button reveals one of 8 scam red flags and scores the visitor's 'scam radar'; then it shows what chasing scams costs and how InstantAdPay works instead, with a free join button. Nothing on the fake dashboard is real or touches any account. Made for people still waiting on a payout from another site.
|
||||||
|
- YOUR DIRECTS' DETAILS (2026-11-12): in Members > My line > 'Your line', each person who joined through your link shows their email (with a copy button), where they came from (the referring site and the link's source tag, e.g. 'from mailer.gold/mailergold'; 'no referring site' when the browser hid it; accurate source tags start 2026-11-12, older sign-ups mostly read 'no referring site') and how they joined (your invite link, your bridge page, a link version, a game, came over from LinkSpin, moved over from BTC4Hits). The same email + origin show in the Activity drop-down and the three-level downline card for your directs. Levels 2 and 3 never show emails: they belong to their own sponsor's direct relationship. The search box also matches email and source.
|
||||||
|
- FIND A MEMBER (2026-11-12): every member list on My line (Your line, the three-level downline, the Holding tank) has a search box at the top of its sort/filter bar. Type part of a name, username (with or without @), email or member number and the list narrows as you type, starting on page 1; it works together with the sort and the filter chips. Emails only show (and match) for your own level 1.
|
||||||
- DRILL DOWN FROM THE OVERVIEW (2026-09-15): every name chip in 'Your line at a glance' on the Overview is clickable; it jumps to My line with that person's Activity panel already open and the row highlighted.
|
- DRILL DOWN FROM THE OVERVIEW (2026-09-15): every name chip in 'Your line at a glance' on the Overview is clickable; it jumps to My line with that person's Activity panel already open and the row highlighted.
|
||||||
- VISIT PACKS ARE PAID UP FRONT (2026-09-15, Michael's question): a verified-visits campaign charges the whole pack when it is created (3 credits per visit, so 1,000 visits = 3,000 credits) and then delivers over time as members complete verified visits (each member can do at most 20 a day, so packs fill gradually: tens per day at today's size). The Campaigns row shows 'paid up front' and 'N of M visits delivered'; the credits are not being consumed again, they were reserved once. Same for featured-day bookings: a featured link is a flat buy (featuredPerDay credits per day, whole run charged when booked), its row shows 'paid up front', the day count and 'runs through <date>', and it ends on its last day ('run ended'). FEATURED CANNOT TAKE ADDED CREDITS (2026-09-16, Hugh and Michael both tried): the row offers 'Extend run' which books more days after the current run (or from today if it ended) and charges them right away; there is no 'Buy more views' on a featured row any more. Visit packs offer 'Buy more visits' (charged now, adds to the pack). Credits added to a campaign are set aside immediately (Available drops at once) and whatever is unspent returns to Available when the campaign ends.
|
- VISIT PACKS ARE PAID UP FRONT (2026-09-15, Michael's question): a verified-visits campaign charges the whole pack when it is created (3 credits per visit, so 1,000 visits = 3,000 credits) and then delivers over time as members complete verified visits (each member can do at most 20 a day, so packs fill gradually: tens per day at today's size). The Campaigns row shows 'paid up front' and 'N of M visits delivered'; the credits are not being consumed again, they were reserved once. Same for featured-day bookings: a featured link is a flat buy (featuredPerDay credits per day, whole run charged when booked), its row shows 'paid up front', the day count and 'runs through <date>', and it ends on its last day ('run ended'). FEATURED CANNOT TAKE ADDED CREDITS (2026-09-16, Hugh and Michael both tried): the row offers 'Extend run' which books more days after the current run (or from today if it ended) and charges them right away; there is no 'Buy more views' on a featured row any more. Visit packs offer 'Buy more visits' (charged now, adds to the pack). Credits added to a campaign are set aside immediately (Available drops at once) and whatever is unspent returns to Available when the campaign ends.
|
||||||
- BANNER CREATIVE MUST BE AN IMAGE LINK (2026-09-16): the New campaign image field needs a direct image URL (ends in .png/.jpg/.gif/.webp/.svg) or an upload; a web-page link (a join page, an imgbb/ibb.co page) is refused with a message. Easiest source: Promo tools > Banners > Copy image URL. A campaign created with a page link before this check served a broken banner and was repaired by admin.
|
- BANNER CREATIVE MUST BE AN IMAGE LINK (2026-09-16): the New campaign image field needs a direct image URL (ends in .png/.jpg/.gif/.webp/.svg) or an upload; a web-page link (a join page, an imgbb/ibb.co page) is refused with a message. Easiest source: Promo tools > Banners > Copy image URL. A campaign created with a page link before this check served a broken banner and was repaired by admin.
|
||||||
- PAYMENT TRACE (2026-09-16): Members > Earnings > "Trace a payment": enter a member number or @username (yourself, anyone up to 3 levels below you, or your own 3 uplines) and every purchase they were part of is listed tier by tier — who was paid at level 1/2/3 (50/20/10%), who was skipped and why ("not qualified: had N of 2 qualifying buyers then"), the platform's 20%, and a verify link to the transaction. Use it to answer "why didn't my sponsor / why didn't I get paid on X's purchase" — the usual answers are (a) the sponsor had not unlocked that level when the purchase settled (qualification never applies backwards), (b) the buyer used Qualified Start, so the purchase came from a linked wallet whose on-chain sponsor is the buyer's own main position (level 1 goes to the buyer themselves), (c) the sponsor's payouts were not switched on. Admins see the same trace under the member card in Admin > Members.
|
- PAYMENT TRACE (2026-09-16): Members > Earnings > "Trace a payment": enter a member number or @username (yourself, anyone up to 3 levels below you, or your own 3 uplines) and every purchase they were part of is listed tier by tier — who was paid at level 1/2/3 (50/20/10%), who was skipped and why ("not qualified: had N of 2 qualifying buyers then"), the platform's 20%, and a verify link to the transaction. Use it to answer "why didn't my sponsor / why didn't I get paid on X's purchase" — the usual answers are (a) the sponsor had not unlocked that level when the purchase settled (qualification never applies backwards), (b) the buyer used Qualified Start, so the purchase came from a linked wallet whose on-chain sponsor is the buyer's own main position (level 1 goes to the buyer themselves), (c) the sponsor's payouts were not switched on. Admins see the same trace under the member card in Admin > Members.
|
||||||
- GAME PASS (2026-10-16, Members > Games > Game Pass): $5 for 7 days, one pass per account covering ALL the network games (linked positions share it). PAYMENT (changed 2026-10-22): every pass is paid by a NEW on-chain package purchase of at least the pass price ($5 for the weekly pass), bought from one of the member's own positions AFTER tapping Get the Pass. The pass starts the moment that purchase settles. The sponsor and team are paid from that package exactly like any package, and the member keeps every credit of the package for ads. Credits (earned or purchased, old balances included) NEVER buy a pass, and a package bought before tapping Get the Pass does not count; if someone asks why, say the pass is paid by a fresh package so the team that brought them in is paid too. Passes bought before this change keep running. Buying again while active extends by 7 days. ACCOUNT-WIDE DAILY POL CAPS across the games, reset at midnight Central: free 0.30 POL/day on repeatable daily-play rewards and 2.0 POL/day for everything; Pass 1.50 and 5.0. Caps apply only from the announced start date (capsStartDate); until then the games' own caps stand. A one-time PROGRESS reward (stage, boss, chapter, sector, room) over the day's total is DEFERRED and carried to the next day, never lost (a 10 POL Gem Kingdom boss still pays 10 POL, over a few days); repeatable DAILY-play POL over the daily cap is dropped for that day. Reward AMOUNTS never change with the pass: say 'free play pays; the Pass plays more', NEVER 'earn more' or 'pays for itself' (max repeatable per pass week is 10.5 POL, under the $5). Pass perks per game: PolHunter 5 missions/day and Ad Detective twice; Gem Kingdom a free continue a day; SpellWheel streak 0.30 and a free hint; PolyWarriors +1 mission, defense 25 Circuits, Pass mark; Road Agent 2 patrols and +25% scrap; ClutterHunt 2 free hints; PolyBreak gem cap 1.5 and an extra paddle; Drip Runner a starting shield; Spooky Doors +1 door while the season runs. WEEKLY PASS TOURNAMENT: pass holders ranked by plays reported across the games Monday to Sunday Central; prize pool = 5% of that week's pass sales in POL (50/30/20 to the top 3), settled Mondays 9 AM Central, top 3 posted to the Game Achievements Telegram topic, prizes paid in POL by the games to the winner's InstantAdPay wallet. Members see the card, state and expiry in Members > Games (deep link /my#games?pass=1); an Overview nudge appears once a day after a game reports a free-cap hit. PER-GAME PERKS (live 2026-10-22, also listed on the Game Pass card): PolHunter 5 missions/day instead of 3 + 2 Ad Detective cases/day; Gem Kingdom 1 free continue/day; Spooky Doors +1 door/day; ClutterHunt 2 bonus hints/day; SpellWheel streak 0.30 POL instead of 0.15 + 1 free hint/day; PolyBreak gem limit 1.5 POL/day instead of 0.5 + extra paddle every round; PolyWarriors 4th daily mission + defense 25 Circuits instead of 15; Drip Runner free shield every run; Road Agent 2 patrols/day + 25% more scrap. Buying a pass unlocks the gold Game Pass achievement badge (Members > Overview badges, share or post to Telegram). New free caps started 2026-10-26 (moved up from the announced 10-29).
|
- GAME PASS (2026-10-16, Members > Games > Game Pass): $5 for 7 days, one pass per account covering ALL the network games (linked positions share it). PAYMENT (changed 2026-10-22): every pass is paid by a NEW on-chain package purchase of at least the pass price ($5 for the weekly pass), bought from one of the member's own positions AFTER tapping Get the Pass. The pass starts the moment that purchase settles. The sponsor and team are paid from that package exactly like any package, and the member keeps every credit of the package for ads. Credits (earned or purchased, old balances included) NEVER buy a pass, and a package bought before tapping Get the Pass does not count; if someone asks why, say the pass is paid by a fresh package so the team that brought them in is paid too. Passes bought before this change keep running. Buying again while active extends by 7 days. ACCOUNT-WIDE DAILY POL CAPS across the games, reset at midnight Central: free 0.30 POL/day on repeatable daily-play rewards and 2.0 POL/day for everything; Pass 1.50 and 5.0. FREE ALLOWANCE (2026-11-02, Marty: the games are a loss leader but the giveaway has a ceiling): an account with no pass receives at most 2 POL of game rewards EVER across all games combined; after that, one-time progress rewards wait as deferred and are paid once a pass is active, and repeatable daily rewards are not paid. Since 2026-11-03 the games say so the moment it happens ("You have used your free 2 POL in the games. Get the Game Pass to keep earning." plus the POL being held) and the Overview shows a Get the Game Pass card. Say it plainly: play free as long as you like, the free POL is a taste, the Game Pass is how the games keep paying. Caps apply only from the announced start date (capsStartDate); until then the games' own caps stand. A one-time PROGRESS reward (stage, boss, chapter, sector, room) over the day's total is DEFERRED and carried to the next day, never lost (a 10 POL Gem Kingdom boss still pays 10 POL, over a few days); repeatable DAILY-play POL over the daily cap is dropped for that day. Reward AMOUNTS never change with the pass: say 'free play pays; the Pass plays more', NEVER 'earn more' or 'pays for itself' (max repeatable per pass week is 10.5 POL, under the $5). Pass perks per game: PolHunter 5 missions/day and Ad Detective twice; Gem Kingdom a free continue a day; SpellWheel streak 0.30 and a free hint; PolyWarriors +1 mission, defense 25 Circuits, Pass mark; Road Agent 2 patrols and +25% scrap; ClutterHunt 2 free hints; PolyBreak gem cap 1.5 and an extra paddle; Drip Runner a starting shield; Spooky Doors +1 door while the season runs. WEEKLY PASS TOURNAMENT: pass holders ranked by plays reported across the games Monday to Sunday Central; prize pool = 5% of that week's pass sales in POL (50/30/20 to the top 3), settled Mondays 9 AM Central, top 3 posted to the Game Achievements Telegram topic, prizes paid in POL by the games to the winner's InstantAdPay wallet. Members see the card, state and expiry in Members > Games (deep link /my#games?pass=1); an Overview nudge appears once a day after a game reports a free-cap hit. PER-GAME PERKS (live 2026-10-22, also listed on the Game Pass card): PolHunter 5 missions/day instead of 3 + 2 Ad Detective cases/day; Gem Kingdom 1 free continue/day; Spooky Doors +1 door/day; ClutterHunt 2 bonus hints/day; SpellWheel streak 0.30 POL instead of 0.15 + 1 free hint/day; PolyBreak gem limit 1.5 POL/day instead of 0.5 + extra paddle every round; PolyWarriors 4th daily mission + defense 25 Circuits instead of 15; Drip Runner free shield every run; Road Agent 2 patrols/day + 25% more scrap. Buying a pass unlocks the gold Game Pass achievement badge (Members > Overview badges, share or post to Telegram). New free caps started 2026-10-26 (moved up from the announced 10-29).
|
||||||
- PLATFORM FACTS (2026-10-06): instantadpay.com/facts (footer link 'Platform facts') and instantadpay.com/llms.txt are the verified reference for how InstantAdPay works: contract 0xBE1ECA72AFF47d13D8E907e523F55eB9e2d365E0 on Polygon; split 50% L1 / 20% L2 (needs 2 referred $20+ buyers) / 10% L3 (needs 5) / 10% platform wallet A / 10% platform wallet B, unqualified shares pass up (25 steps) then go to wallet A; purchased credits are on-chain (engine burns them in batches), earned credits are in the site database; credits are not transferable or cashable; POL payments are final, platform may return credits when a campaign fails because of a platform problem. When someone asks how the platform, payouts, credits or refunds work, answer from these facts and link /facts.
|
- PLATFORM FACTS (2026-10-06): instantadpay.com/facts (footer link 'Platform facts') and instantadpay.com/llms.txt are the verified reference for how InstantAdPay works: contract 0xBE1ECA72AFF47d13D8E907e523F55eB9e2d365E0 on Polygon; split 50% L1 / 20% L2 (needs 2 referred $20+ buyers) / 10% L3 (needs 5) / 10% platform wallet A / 10% platform wallet B, unqualified shares pass up (25 steps) then go to wallet A; purchased credits are on-chain (engine burns them in batches), earned credits are in the site database; credits are not transferable or cashable; POL payments are final, platform may return credits when a campaign fails because of a platform problem. When someone asks how the platform, payouts, credits or refunds work, answer from these facts and link /facts.
|
||||||
- CREDIT ACTIVITY LEDGER (2026-09-16): Members > Campaigns has a 'Credit activity' list (last 40 lines, newest first; also linked from the Earn credits pane) showing every real credit movement with a reason: welcome credits, sign-in bonus with streak, daily claim, inbox reads, video watches, verified visits, milestone and leaderboard bonuses, partner codes, admin/team grants, AI Copy Engine charges and refunds, flat buys (featured runs, extensions, visit packs, more visits), login-ad days, and metered delivery rolled up as one line per campaign per day ('Ad views: NAME', 'Inbox deliveries: NAME', 'Video views: NAME'); lines marked '(purchased credits)' spent on-chain purchased credits rather than the earned pool. Reservations (credits set aside for a live campaign) are NOT ledger lines; they show as 'in live campaigns'. Earned credits are spent before purchased ones, so an earn followed by a buy appears as two lines. The ledger starts 2026-09-16; nothing earlier is listed.
|
- CREDIT ACTIVITY LEDGER (2026-09-16): Members > Campaigns has a 'Credit activity' list (last 40 lines, newest first; also linked from the Earn credits pane) showing every real credit movement with a reason: welcome credits, sign-in bonus with streak, daily claim, inbox reads, video watches, verified visits, milestone and leaderboard bonuses, partner codes, admin/team grants, AI Copy Engine charges and refunds, flat buys (featured runs, extensions, visit packs, more visits), login-ad days, and metered delivery rolled up as one line per campaign per day ('Ad views: NAME', 'Inbox deliveries: NAME', 'Video views: NAME'); lines marked '(purchased credits)' spent on-chain purchased credits rather than the earned pool. Reservations (credits set aside for a live campaign) are NOT ledger lines; they show as 'in live campaigns'. Earned credits are spent before purchased ones, so an earn followed by a buy appears as two lines. The ledger starts 2026-09-16; nothing earlier is listed.
|
||||||
- PAYMENT + MISSED-PAYMENT NOTICES (2026-09-15): every payout that lands (who bought, level, share in POL and dollars, transaction link) and every missed payout is delivered BOTH by email and as an on-site inbox message from the company account, shown in the login pop-up and the Messages card, so it is waiting when the member signs in. MISSED-PAYOUT detail: when a level-2 or level-3 share passes a member by because that level is not open on their account, the member gets an email the same minute: who bought, the POL and dollar amount they missed, how many qualifying buyers they have versus the 2 or 5 needed, and the two ways to close the gap (bring buyers, or Qualified Start). Qualified members whose wallet rejected a transfer get a different email telling them to link a regular wallet. MISSED PAYOUTS ARE ALSO PUBLIC (2026-09-16): the team's Telegram payments feed posts, by username, who was passed over on a purchase, why (not qualified yet with N of 2 buyers, or payouts not switched on), the amount, and who received it instead; the same for a sale that routed past an unactivated sponsor. Nothing about the contract changed; it is visibility.
|
- PAYMENT + MISSED-PAYMENT NOTICES (2026-09-15): every payout that lands (who bought, level, share in POL and dollars, transaction link) and every missed payout is delivered BOTH by email and as an on-site inbox message from the company account, shown in the login pop-up and the Messages card, so it is waiting when the member signs in. MISSED-PAYOUT detail: when a level-2 or level-3 share passes a member by because that level is not open on their account, the member gets an email the same minute: who bought, the POL and dollar amount they missed, how many qualifying buyers they have versus the 2 or 5 needed, and the two ways to close the gap (bring buyers, or Qualified Start). Qualified members whose wallet rejected a transfer get a different email telling them to link a regular wallet. MISSED PAYOUTS ARE ALSO PUBLIC (2026-09-16): the team's Telegram payments feed posts, by username, who was passed over on a purchase, why (not qualified yet with N of 2 buyers, or payouts not switched on), the amount, and who received it instead; the same for a sale that routed past an unactivated sponsor. Nothing about the contract changed; it is visibility.
|
||||||
@@ -364,7 +420,7 @@ ${passTiersFact()}${refuelFact()}${synFact()}${polminerFact()}${warpwaresFact()}
|
|||||||
- GETTING STARTED CARD (2026-09-14): the top of every new member's Overview shows four steps (username, link wallet, switch on payouts, first package) with the current one explained and one button that opens the right tab and highlights the control (Wallet tab > Link wallet; then Activate payouts). Encouragement only: it can be hidden, and members who only want to view ads and earn credits are never blocked. It disappears once all four are done.
|
- GETTING STARTED CARD (2026-09-14): the top of every new member's Overview shows four steps (username, link wallet, switch on payouts, first package) with the current one explained and one button that opens the right tab and highlights the control (Wallet tab > Link wallet; then Activate payouts). Encouragement only: it can be hidden, and members who only want to view ads and earn credits are never blocked. It disappears once all four are done.
|
||||||
- LEADERBOARD + REFERRAL CONTEST (2026-09-14): instantadpay.com/leaderboard ranks members by ad packages sold to people they directly sponsor (dollar value, read from the chain; a member's own linked positions and second accounts never count). Periods: this week (Monday to Sunday, Central time), this month, all time. Weekly and monthly winners are recorded automatically at rollover, announced in Telegram, and the credit prizes set by the admin (a ladder: 1st 1,000 / 2nd 500 / 3rd 250 weekly, 5,000 / 2,500 / 1,000 monthly by default) are granted automatically to those positions; the prize text is shown on the page and on the Overview's Leaderboard card, which also shows the member's own rank. Prizes are credits or packages, never cash.
|
- LEADERBOARD + REFERRAL CONTEST (2026-09-14): instantadpay.com/leaderboard ranks members by ad packages sold to people they directly sponsor (dollar value, read from the chain; a member's own linked positions and second accounts never count). Periods: this week (Monday to Sunday, Central time), this month, all time. Weekly and monthly winners are recorded automatically at rollover, announced in Telegram, and the credit prizes set by the admin (a ladder: 1st 1,000 / 2nd 500 / 3rd 250 weekly, 5,000 / 2,500 / 1,000 monthly by default) are granted automatically to those positions; the prize text is shown on the page and on the Overview's Leaderboard card, which also shows the member's own rank. Prizes are credits or packages, never cash.
|
||||||
- WHAT'S NEW / ROADMAP (2026-09-14): instantadpay.com/whats-new lists release notes (what shipped, dated, tagged new/improved/fixed) and the roadmap (planned / building, with rough ETAs). The Overview has a "What's new" card with the latest three notes and what is being built; a dot marks notes since the member's last look. Written by the admin in Admin > Releases.
|
- WHAT'S NEW / ROADMAP (2026-09-14): instantadpay.com/whats-new lists release notes (what shipped, dated, tagged new/improved/fixed) and the roadmap (planned / building, with rough ETAs). The Overview has a "What's new" card with the latest three notes and what is being built; a dot marks notes since the member's last look. Written by the admin in Admin > Releases.
|
||||||
- HOLDING TANK ALERTS: when new members land in the tank, a note at the top of every member's Overview names them (usernames) and a post goes to the team's Telegram payments topic; adopt from My line > Holding tank (your own $20 package required).
|
- HOLDING TANK ALERTS: 24 hours after a new member joins (when they can be adopted), a note at the top of every member's Overview names them (usernames) and a post goes to the team's Telegram payments topic; adopt from My line > Holding tank (your own $20 package required).
|
||||||
- LEGACY WELCOME (former Faucet Wave / Tier One Ads members): they join through instantadpay.com/from/faucetwave or instantadpay.com/from/tieroneads and, if their email is on the legacy list, welcome-back credits are added automatically at signup (former advertisers 500, former earners 150; once per person; credits, not POL). They land in the holding tank like any member who joins without a sponsor. SOCIALPIX GATE (2026-09-20): socialpix.club no longer takes ad posts; its visitors are sent to instantadpay.com/from/socialpix (advertiser copy by default, ?seg=earn for the earner copy). No welcome-back credits for SocialPix arrivals; they join free by email and land in the holding tank.
|
- LEGACY WELCOME (former Faucet Wave / Tier One Ads members): they join through instantadpay.com/from/faucetwave or instantadpay.com/from/tieroneads and, if their email is on the legacy list, welcome-back credits are added automatically at signup (former advertisers 500, former earners 150; once per person; credits, not POL). They land in the holding tank like any member who joins without a sponsor. SOCIALPIX GATE (2026-09-20): socialpix.club no longer takes ad posts; its visitors are sent to instantadpay.com/from/socialpix (advertiser copy by default, ?seg=earn for the earner copy). No welcome-back credits for SocialPix arrivals; they join free by email and land in the holding tank.
|
||||||
- PROMO CODES: partner site owners get a reusable code; a member redeems it on a join link (?promo=CODE) or in the Overview box "Have a promo code?" and receives free ad credits (amount set per code by the admin, one use per account; codes can cap uses or expire). Credits, not POL.
|
- PROMO CODES: partner site owners get a reusable code; a member redeems it on a join link (?promo=CODE) or in the Overview box "Have a promo code?" and receives free ad credits (amount set per code by the admin, one use per account; codes can cap uses or expire). Credits, not POL.
|
||||||
- DORMANT-LEAD RESCUE: a FREE referral (no wallet, no purchase) with no message from their sponsor for 10 days triggers a warning email + dashboard flag to the sponsor ("unreached, tank in N days"); at 14 days (warning at least 4 days old) the lead moves to the holding tank and the sponsor is told. Sponsor resets the clock with a chat, a Nudge, or the "Contacted them" button (for phone/text contact). Leads whose sponsor link resolves to nobody go to the tank after a day. Nothing on-chain moves; anyone bound by a purchase never moves.
|
- DORMANT-LEAD RESCUE: a FREE referral (no wallet, no purchase) with no message from their sponsor for 10 days triggers a warning email + dashboard flag to the sponsor ("unreached, tank in N days"); at 14 days (warning at least 4 days old) the lead moves to the holding tank and the sponsor is told. Sponsor resets the clock with a chat, a Nudge, or the "Contacted them" button (for phone/text contact). Leads whose sponsor link resolves to nobody go to the tank after a day. Nothing on-chain moves; anyone bound by a purchase never moves.
|
||||||
@@ -381,11 +437,12 @@ ${passTiersFact()}${refuelFact()}${synFact()}${polminerFact()}${warpwaresFact()}
|
|||||||
- PASSIVEDRIP (LIVE on the Earn tab for every member since 2026-10-03): https://passivedrip.com, an EARNING SITE (never call it a game): faucet claims, paid-to-click ad views, offers (offer walls) and a daily bonus roll earn coins; at 2,000 coins ($1) the balance is paid out AUTOMATICALLY in POL on Polygon to the wallet saved on PassiveDrip. The Earn tab card (More ways to earn: PassiveDrip) opens it with ONE TAP using the InstantAdPay account (no new password; it offers the member's InstantAdPay wallet to save). No income is promised.
|
- PASSIVEDRIP (LIVE on the Earn tab for every member since 2026-10-03): https://passivedrip.com, an EARNING SITE (never call it a game): faucet claims, paid-to-click ad views, offers (offer walls) and a daily bonus roll earn coins; at 2,000 coins ($1) the balance is paid out AUTOMATICALLY in POL on Polygon to the wallet saved on PassiveDrip. The Earn tab card (More ways to earn: PassiveDrip) opens it with ONE TAP using the InstantAdPay account (no new password; it offers the member's InstantAdPay wallet to save). No income is promised.
|
||||||
- POLYBREAK (opens 2026-10-13, https://polybreak.app, in Members > Games): a free Arkanoid-style brick breaker. Eight hand-built rounds that then repeat with tougher silver bricks; colored bricks break in one hit, silver takes more hits each round, gold never breaks. Capsules: S slow, C catch, L laser, E enlarge, D disrupt (three balls), B break (a gate in the right wall skips the round), P extra paddle. One-tap sign-in with the InstantAdPay account; guests can play and their first clears are paid once they sign in. PAYS POL: the first clear of each round (replays pay nothing) and catches of the purple Polygon gem (a small random amount each time, the gem appears every so often during play), into the PolyBreak game balance, sent automatically to the wallet on the member's InstantAdPay account at the payout line shown in the game; rewards are paid from the game's pool, funded by a share of the one-more-paddle visits. ONE MORE PADDLE: when the last paddle is lost, a verified visit to a member's page (or a member video) continues the round with one paddle; it uses the daily refuel allowance shared with the other games. REFERRALS: each player's share link polybreak.app/r/<username>; a sponsor earns a share of the pool income from the paddle visits of players they invited. Never state a maximum or total a player can earn and never promise income.
|
- POLYBREAK (opens 2026-10-13, https://polybreak.app, in Members > Games): a free Arkanoid-style brick breaker. Eight hand-built rounds that then repeat with tougher silver bricks; colored bricks break in one hit, silver takes more hits each round, gold never breaks. Capsules: S slow, C catch, L laser, E enlarge, D disrupt (three balls), B break (a gate in the right wall skips the round), P extra paddle. One-tap sign-in with the InstantAdPay account; guests can play and their first clears are paid once they sign in. PAYS POL: the first clear of each round (replays pay nothing) and catches of the purple Polygon gem (a small random amount each time, the gem appears every so often during play), into the PolyBreak game balance, sent automatically to the wallet on the member's InstantAdPay account at the payout line shown in the game; rewards are paid from the game's pool, funded by a share of the one-more-paddle visits. ONE MORE PADDLE: when the last paddle is lost, a verified visit to a member's page (or a member video) continues the round with one paddle; it uses the daily refuel allowance shared with the other games. REFERRALS: each player's share link polybreak.app/r/<username>; a sponsor earns a share of the pool income from the paddle visits of players they invited. Never state a maximum or total a player can earn and never promise income.
|
||||||
- POLYWARRIORS (LIVE 2026-10-12, https://www.polywarriors.com, in Members > Games): a free cyberpunk turn-based fighting game. Recruit warriors that are each born with their own traits and rarity (Common, Rare, Epic, Legendary); fight through 24 arena rivals (a 12-rival district ladder, then a 12-rival elite circuit); challenge other members to async duels that play out while they are away. The FIRST win over each rival pays POL to the wallet on the member's InstantAdPay account (replays pay nothing). The first warrior mints to the member's wallet as an NFT on Polygon for free; after that every $5 ad package bought on InstantAdPay earns a mint pass. Fusion: three warriors of the same rarity fuse into one rarer warrior (the three are consumed). Marketplace: warriors trade between members, settled in POL. One-tap sign-in with the InstantAdPay account; guests can try fights but earn nothing until they sign in. A 40-second trailer and a promo kit are in Promo tools > Games > PolyWarriors. Never state a maximum or total a player can earn and never promise income.
|
- POLYWARRIORS (LIVE 2026-10-12, https://www.polywarriors.com, in Members > Games): a free cyberpunk turn-based fighting game. Recruit warriors that are each born with their own traits and rarity (Common, Rare, Epic, Legendary); fight through 24 arena rivals (a 12-rival district ladder, then a 12-rival elite circuit); challenge other members to async duels that play out while they are away. The FIRST win over each rival pays POL to the wallet on the member's InstantAdPay account (replays pay nothing). The first warrior mints to the member's wallet as an NFT on Polygon for free; after that every $5 ad package bought on InstantAdPay earns a mint pass. Fusion: three warriors of the same rarity fuse into one rarer warrior (the three are consumed). Marketplace: warriors trade between members, settled in POL. One-tap sign-in with the InstantAdPay account; guests can try fights but earn nothing until they sign in. A 40-second trailer and a promo kit are in Promo tools > Games > PolyWarriors. Never state a maximum or total a player can earn and never promise income.
|
||||||
- SPELLWHEEL (LIVE 2026-10-10, https://spellwheel.com, in Members > Games): a free letter-wheel word game: swipe letters on the wheel to fill the crossword grid, travel through six cozy places (chapters), and solve a new daily puzzle shared by everyone. Pays POL for clearing levels, finishing a place and solving the daily puzzle, collected in the SpellWheel balance and sent automatically to the wallet on the member's InstantAdPay account. One-tap sign-in with the InstantAdPay account. Never state totals or promise income.
|
- SPELLWHEEL (LIVE 2026-10-10, https://spellwheel.com, in Members > Games): a letter-wheel word game: swipe letters on the wheel to fill the crossword grid, travel through six cozy places (chapters: the Lantern Library, the Harbor Market, the Mountain Lodge, the Desert Caravan, the Snowy Cabin, the Glass Conservatory), and solve a new daily puzzle shared by everyone. LADDER since 2026-11-02: guests play the first place only and earn nothing (their clears carry over as progress at sign-in, never as POL); a free InstantAdPay account plays the first two places; the Mountain Lodge and beyond need an active Game Pass (the game answers "for Game Pass holders" with a link to the pass). POL, first clears only: levels 0.01/0.01/0.03/0.03/0.05/0.05 and a completed place 0.1/0.1/0.5/0.5/1/1 by chapter; from the third place on, and for the daily puzzle (0.03) and the 7-day streak, only pass holders are paid; a player who has cleared every place earns nothing more until new places ship. Collected in the SpellWheel balance and sent automatically to the wallet on the member's InstantAdPay account. One-tap sign-in with the InstantAdPay account. Never state totals or promise income.
|
||||||
- CLUTTERHUNT (LIVE 2026-10-03, https://clutterhunt.com, in Members > Games): a free hidden-object game. Search cozy, cluttered rooms for 12 hidden objects plus one sponsored find (a sealed letter with a sponsor's name; tapping it shows their ad). Rooms change with the seasons: the Haunted Manor (Attic, Library, Witch's Kitchen, Wizard's Study, Moonlit Greenhouse, Wine Cellar) through Oct 31, then new seasonal rooms. Objects move every round. Stars: finish under 3 minutes, use at most 1 hint, at most 6 wrong taps. 2 free hints a round; after that a short verified visit to a member's page earns a hint (shares the daily refuel allowance). Sign in with the InstantAdPay account right inside the game to save stars. PAYS POL since 2026-10-04: fixed rewards per room each season for the first clear and the first 3-star clear (more for Expert rooms, which unlock after all six rooms), collected in the ClutterHunt balance and sent automatically to the wallet on the member's InstantAdPay account once it reaches the payout amount. Players who cleared rooms before 10-04 can replay each room once to collect. NEVER state a maximum or total a player can earn (Marty's rule) and never promise earnings. HARVEST FARMHOUSE season 2026-11-01 to 11-30 (six new rooms: Farmhouse Kitchen, Pantry, Harvest Dining Room, Barn Loft, Front Porch, Cozy Parlor); the Haunted Manor closed 2026-11-01. Rewards unchanged: first clear 0.05 POL per room per season, +0.05 for three stars, Expert 0.15 and +0.10 for three stars, from the season pool while it lasts.
|
- CLUTTERHUNT (LIVE 2026-10-03, https://clutterhunt.com, in Members > Games): a free hidden-object game. Search cozy, cluttered rooms for 12 hidden objects plus one sponsored find (a sealed letter with a sponsor's name; tapping it shows their ad). Rooms change with the seasons: the Haunted Manor (Attic, Library, Witch's Kitchen, Wizard's Study, Moonlit Greenhouse, Wine Cellar) through Oct 31, then new seasonal rooms. Objects move every round. Stars: finish under 3 minutes, use at most 1 hint, at most 6 wrong taps. 2 free hints a round; after that a short verified visit to a member's page earns a hint (shares the daily refuel allowance). Sign in with the InstantAdPay account right inside the game to save stars. PAYS POL since 2026-10-04: fixed rewards per room each season for the first clear and the first 3-star clear (more for Expert rooms, which unlock after all six rooms), collected in the ClutterHunt balance and sent automatically to the wallet on the member's InstantAdPay account once it reaches the payout amount. Players who cleared rooms before 10-04 can replay each room once to collect. NEVER state a maximum or total a player can earn (Marty's rule) and never promise earnings. HARVEST FARMHOUSE season 2026-11-01 to 11-30 (six new rooms: Farmhouse Kitchen, Pantry, Harvest Dining Room, Barn Loft, Front Porch, Cozy Parlor); the Haunted Manor closed 2026-11-01. Rewards unchanged: first clear 0.05 POL per room per season, +0.05 for three stars, Expert 0.15 and +0.10 for three stars, from the season pool while it lasts.
|
||||||
- SPOOKY DOORS (Halloween season game, 2026-10-02): https://spookydoors.com, open 2026-10-04 through Halloween night (closes at midnight Central at the end of Oct 31); its Games tab card shows only during the season, with a "Limited time, ends Oct 31" ribbon. Members sign in with one tap from Members > Games. Walk the street, collect candy, avoid black cats and bats, knock on doors. Each door is a verified visit to a member's page or ad (a member video once every page has been visited), the advertiser is charged as for any visit, the player gets candy not credits; 15 doors per Central day, separate from the 20 Earn-tab visits and the 20 Drip Runner refuels. A treat is 10 candy; about 1 door in 5 is a trick (a ghost or skeleton you tap 5 times quickly; beat it for a 3 candy bonus, miss it for half the treat). If no paid ad is left for that player, the door shows a house ad for one of our own programs: a smaller treat (5 candy), and it still counts toward the 15 doors. CANDY LADDER pays POL once per rung: 100 candy 0.1 POL, 250 0.25, 500 0.5, 1,000 1, 2,000 2 (Halloween 2026 badge at 500), paid from a season pool funded by a share of door ad spend and costume sales, only while the pool covers it; the game balance is sent to the member's InstantAdPay wallet on Polygon at 0.25 POL. COSTUMES bought with ad credits like Gem Kingdom Crowns: witch free, vampire 300 credits (longer trick timer), bedsheet ghost 300 (black cats ignore you), Lucky caramel apple 500 (+2 candy per treat); no cash value. Top 20 by candy on the season leaderboard. DOOR PACKS: creating a verified-visits campaign, the advertiser picks Everywhere (3 credits per visit, as before), Behind Spooky Doors (4 credits per door) or Golden Spooky Door (6 credits per door; the player gets +2 bonus candy). Paid up front like any visit pack. Door packs are served first on doors (Golden Doors before door packs), each player sees a pack at most once per Central day, they never run on the Earn tab or refuels during the season, and from Nov 1 any doors left run as normal visits; the campaign shows doors opened and unique players. Never promise earnings or call it income. CLOSED 2026-11-01: the season is over, the card is hidden, doors and shop are off; Candy Crunch top 10 share 27 POL (10/6/4/1x7) paid after admin approval, unlinked winners paid once they link a wallet; unpaid ladder POL (0.10+) pays once a wallet is linked; next seasonal game is Turkey Drop (opens 2026-11-02).
|
- SPOOKY DOORS (Halloween season game, 2026-10-02): https://spookydoors.com, open 2026-10-04 through Halloween night (closes at midnight Central at the end of Oct 31); its Games tab card shows only during the season, with a "Limited time, ends Oct 31" ribbon. Members sign in with one tap from Members > Games. Walk the street, collect candy, avoid black cats and bats, knock on doors. Each door is a verified visit to a member's page or ad (a member video once every page has been visited), the advertiser is charged as for any visit, the player gets candy not credits; 15 doors per Central day, separate from the 20 Earn-tab visits and the 20 Drip Runner refuels. A treat is 10 candy; about 1 door in 5 is a trick (a ghost or skeleton you tap 5 times quickly; beat it for a 3 candy bonus, miss it for half the treat). If no paid ad is left for that player, the door shows a house ad for one of our own programs: a smaller treat (5 candy), and it still counts toward the 15 doors. CANDY LADDER pays POL once per rung: 100 candy 0.1 POL, 250 0.25, 500 0.5, 1,000 1, 2,000 2 (Halloween 2026 badge at 500), paid from a season pool funded by a share of door ad spend and costume sales, only while the pool covers it; the game balance is sent to the member's InstantAdPay wallet on Polygon at 0.25 POL. COSTUMES bought with ad credits like Gem Kingdom Crowns: witch free, vampire 300 credits (longer trick timer), bedsheet ghost 300 (black cats ignore you), Lucky caramel apple 500 (+2 candy per treat); no cash value. Top 20 by candy on the season leaderboard. DOOR PACKS: creating a verified-visits campaign, the advertiser picks Everywhere (3 credits per visit, as before), Behind Spooky Doors (4 credits per door) or Golden Spooky Door (6 credits per door; the player gets +2 bonus candy). Paid up front like any visit pack. Door packs are served first on doors (Golden Doors before door packs), each player sees a pack at most once per Central day, they never run on the Earn tab or refuels during the season, and from Nov 1 any doors left run as normal visits; the campaign shows doors opened and unique players. Never promise earnings or call it income. CLOSED 2026-11-01: the season is over, the card is hidden, doors and shop are off; Candy Crunch top 10 share 27 POL (10/6/4/1x7) paid after admin approval, unlinked winners paid once they link a wallet; unpaid ladder POL (0.10+) pays once a wallet is linked; next seasonal game is Turkey Drop (opens 2026-11-02).
|
||||||
- GEM KINGDOM (LIVE in the Games tab since 2026-10-02): Gem Kingdom (https://gemkingdom.app) is a free fantasy match-3: match gems so three heroes battle monsters across six chapters (Goblin Woods, the Frozen Pass, the Haunted Swamp, Dragon's Peak, the Sunken Reef, the Shadow Citadel), earn stars, and rebuild your Stronghold and forge weapons. It pays POL for FIRST clears only (stages 0.02 to 0.15 POL rising by chapter; bosses 0.25, 0.5, 2, 5, 7.5 and 10 POL for the Goblin King, Ice Queen, Bog Witch, Ember Dragon, Kraken and Shadow King); replays pay nothing. The game balance is sent to the member's InstantAdPay wallet on Polygon at 0.25 POL. Rewards come from a pool funded by a share of Crown purchases and pay only while the pool has funds; never promise earnings or call it income. No referral bonus on game clears. Crowns, its upgrade currency, are bought with your InstantAdPay ad credits: tap Buy in the game's Crown Shop, confirm on InstantAdPay (top up with a pack if you are short), and you land back in the game with the Crowns added. Crowns buy buildings, weapons, battle boosts and a revive after a defeat. Sign in with your InstantAdPay account to save progress, earn badges and appear in the Game Achievements posts in the Crypto Team Build group. Never promise an amount beyond the posted rewards. (2026-10-03) FREE REVIVE: after a defeat, a short verified visit to a member's page (InstantAdPay verified-visit flow inside the game, shares the 20-a-day refuel allowance with Drip Runner) revives the party once per battle; a revived win earns at most 2 stars. SPECIALS in the Crown shop: Hero Bundle (one time, $5 = 500 credits: a tier-1 forge weapon, one building level, 60 Crowns), Kingdom Pass ($10 = 1,000 credits for 30 days: 10 Crowns a day credited on the first visit each Central day, a 25-Crown chest every 7 days, the three Royal hero looks; no auto-renew, buying again adds 30 days), Hero looks (cosmetic only: Halloween looks Pumpkin Knight, Moon Witch, Scarecrow Ranger for 40 Crowns each, sold through Oct 31 and kept forever; Royal looks with the Pass). Only the purchased-credit part of a purchase funds the POL reward pool.
|
- GEM KINGDOM (LIVE in the Games tab since 2026-10-02): Gem Kingdom (https://gemkingdom.app) is a free fantasy match-3: match gems so three heroes battle monsters across six chapters (Goblin Woods, the Frozen Pass, the Haunted Swamp, Dragon's Peak, the Sunken Reef, the Shadow Citadel), earn stars, and rebuild your Stronghold and forge weapons. LADDER since 2026-11-02 (Marty: the game funds itself): Chapters 1-2 open to everyone (guests included); Chapter 3 needs a free InstantAdPay account; Chapters 4-6 need the ROYAL CHARTER, $5 one time = 500 PURCHASED credits (paid credits only, never earned viewing credits), bought in the game's Specials; a Kingdom Pass or an active Game Pass counts as a Charter; anyone who had already spent $5+ of purchased credits in the game has it. It pays POL for FIRST clears only: chapters 1-3 are a taste (stages 0.01/0.01/0.02, bosses 0.1/0.2/0.5, about 1.2 POL in all); chapters 4-6 pay Charter holders only (stages 0.08/0.12/0.15, bosses 3/5/7.5 for the Ember Dragon, Kraken and Shadow King, about 19 POL for the full ladder) and a player's chapter 4-6 total never exceeds what they paid in. Replays pay nothing; after the Shadow King nothing more is paid until a new chapter ships. The game balance is sent to the member's InstantAdPay wallet on Polygon at 0.25 POL. Rewards come from a pool funded by a share of Crown purchases and pay only while the pool has funds; never promise earnings or call it income. No referral bonus on game clears. Crowns, its upgrade currency, are bought with your InstantAdPay ad credits: tap Buy in the game's Crown Shop, confirm on InstantAdPay (top up with a pack if you are short), and you land back in the game with the Crowns added. Crowns buy buildings, weapons, battle boosts and a revive after a defeat. Sign in with your InstantAdPay account to save progress, earn badges and appear in the Game Achievements posts in the Crypto Team Build group. Never promise an amount beyond the posted rewards. (2026-10-03) FREE REVIVE: after a defeat, a short verified visit to a member's page (InstantAdPay verified-visit flow inside the game, shares the 20-a-day refuel allowance with Drip Runner) revives the party once per battle; a revived win earns at most 2 stars. SPECIALS in the Crown shop: Hero Bundle (one time, $5 = 500 credits: a tier-1 forge weapon, one building level, 60 Crowns), Kingdom Pass ($10 = 1,000 credits for 30 days: 10 Crowns a day credited on the first visit each Central day, a 25-Crown chest every 7 days, the three Royal hero looks; no auto-renew, buying again adds 30 days), Hero looks (cosmetic only: Halloween looks Pumpkin Knight, Moon Witch, Scarecrow Ranger for 40 Crowns each, sold through Oct 31 and kept forever; Royal looks with the Pass). Only the purchased-credit part of a purchase funds the POL reward pool.
|
||||||
- GAME POL TO ANY LINKED WALLET (2026-10-27, Marty): game POL (Drip Runner, Gem Kingdom, ClutterHunt, Spooky Doors, Road Agent, PolyBreak, SpellWheel, PolyWarriors) is paid to the wallet LINKED to the member's InstantAdPay account (one free signature on the Wallet tab, https://instantadpay.com/my#wallet). Activation is NOT needed: a linked wallet that has not switched on payouts (for example a holding-tank member waiting for a sponsor) is paid too. InstantAdPay hands the linked wallet to every game where the member has a balance (hourly, and on every sign-in to a game), and the game sends the POL on its own sweep once the balance reaches that game's payout line, including everything earned before the link. A game that already holds a different wallet keeps paying that one (it is never replaced automatically). Players with no linked wallet get at most three reminders ("X POL is waiting for your wallet": link your wallet, one free signature, and it's sent automatically, including everything you've earned so far), and in the games the reward screen says "Link your wallet to receive this POL" with the same link. Never tell a member to switch on payouts to get game POL.
|
- GAME POL TO ANY LINKED WALLET (2026-10-27, Marty): game POL (Drip Runner, Gem Kingdom, ClutterHunt, Spooky Doors, Road Agent, PolyBreak, SpellWheel, PolyWarriors) is paid to the wallet LINKED to the member's InstantAdPay account (one free signature on the Wallet tab, https://instantadpay.com/my#wallet). Activation is NOT needed: a linked wallet that has not switched on payouts (for example a holding-tank member waiting for a sponsor) is paid too. InstantAdPay hands the linked wallet to every game where the member has a balance (hourly, and on every sign-in to a game), and the game sends the POL on its own sweep once the balance reaches that game's payout line, including everything earned before the link. A game that already holds a different wallet keeps paying that one (it is never replaced automatically). Players with no linked wallet get at most three reminders ("X POL is waiting for your wallet": link your wallet, one free signature, and it's sent automatically, including everything you've earned so far), and in the games the reward screen says "Link your wallet to receive this POL" with the same link. Never tell a member to switch on payouts to get game POL.
|
||||||
|
- GAME TIERS (2026-11-02, Marty: every game funds itself; rolling out game by game, no announcements): guests get a first slice and earn nothing; a free InstantAdPay account gets a small taste of POL; the full content and the full rewards need a purchase (the $5 Game Pass, or a one-time unlock where the content is finite). Done so far: GEM KINGDOM (Royal Charter, see its own line), POLHUNTER (a free account hunts ONE code a day drawn on 0.02 to 0.10 POL; Game Pass holders hunt five a day at the full 0.05 to 1 POL draw and alone qualify for the weekly prizes and the Mystery Hunt Box; advertiser-funded finds pay the advertiser's amount on every tier), SPELLWHEEL (guests the first place, a free account the first two, the Mountain Lodge and beyond plus daily-puzzle and streak POL for Game Pass holders; see its own line). ALL OTHER GAMES since the evening of 2026-11-02: guests play but earn no POL (guest progress carries over at sign-in, guest POL does not); a free account earns 25% of each one-time progress reward (chapters, rounds, sectors, rungs, bosses, depth marks) and keeps the existing free daily limits on repeatable rewards; Game Pass holders earn 100%. Specifics: CLUTTERHUNT guests room 1, a free account rooms 1 and 2 at a quarter, Game Pass rooms 3 to 6 and Expert; POL MINER guests dig the Dirt (to 10 m), a free account to 24 m, Game Pass from the Gravel down; POLYWARRIORS the full table needs a PAID warrior mint or the Game Pass (the free first mint does not count), free accounts earn a quarter and cannot place for weekly prizes; TURKEY DROP weekly top-3 prizes go to Game Pass holders from the week of Nov 9 (the week of Nov 2 settles as announced); Drip Runner, PolyBreak, Road Agent and Spooky Doors follow the general rule. Nothing already paid changed.
|
||||||
- GAMES TAB (2026-10-01): Members > Games (/my#games) shows one card per network game (as of 2026-10-15: PolHunter, Drip Runner, Gem Kingdom, ClutterHunt, SpellWheel, PolyWarriors, PolyBreak, Road Agent, Spooky Doors during Halloween; all pay POL to the member's InstantAdPay wallet), with their own progress and a Play button that signs them in with one tap; new games appear there as they launch (PolHunter is one card). DRIP RUNNER (https://driprunner.app, LIVE for every member since 2026-10-01): tap-to-hop runner; gold drips, magenta bots, orange firewalls from chapter 2; each chapter has a drip goal for one run; the FIRST clear of a chapter pays a small POL drip (amount set by the admin, shown in the game) into the game balance, replays pay nothing; the balance is sent on Polygon to the member's InstantAdPay wallet once it reaches the payout line shown in the game. REFUELS: a run that ends can be refuelled with a verified visit to a member's page (once every page has been visited: a member video, a page seen more than 7 days ago again, or one of the network's own programs, so a game visit is never empty; since 2026-10-28 for every game's refuel, paddle, continue, hint and supply crate), up to 20 a day, separate from the 20 Earn-tab visits; the advertiser is charged as for any visit, the player gets fuel not credits. The POL pool is funded ONLY by a share of refuel ad spend plus POL spent in the hangar, so drips depend on refuels and can be zero when the pool is empty; say so honestly. HANGAR: Drip Magnet and Courier Mk II cost drips (game currency); Shield Core and Slow Field cost POL from the game balance, which returns to the pool. GUESTS can try a run without signing in; their clears pay once they sign in. REFERRALS: each player's share link /r/<username>; when members whose InstantAdPay sponsor is that player refuel, a share (10 percent by default) of each refuel's pool income goes to the sponsor's game balance. Telegram posts achievement badges (chapters, unlocks, refuel milestones, payouts). Never promise amounts or income. The public list of every game, open now and opening next, is https://instantadpay.com/games (shareable; add ?ref=<username> to keep the referral).
|
- GAMES TAB (2026-10-01): Members > Games (/my#games) shows one card per network game (as of 2026-10-15: PolHunter, Drip Runner, Gem Kingdom, ClutterHunt, SpellWheel, PolyWarriors, PolyBreak, Road Agent, Spooky Doors during Halloween; all pay POL to the member's InstantAdPay wallet), with their own progress and a Play button that signs them in with one tap; new games appear there as they launch (PolHunter is one card). DRIP RUNNER (https://driprunner.app, LIVE for every member since 2026-10-01): tap-to-hop runner; gold drips, magenta bots, orange firewalls from chapter 2; each chapter has a drip goal for one run; the FIRST clear of a chapter pays a small POL drip (amount set by the admin, shown in the game) into the game balance, replays pay nothing; the balance is sent on Polygon to the member's InstantAdPay wallet once it reaches the payout line shown in the game. REFUELS: a run that ends can be refuelled with a verified visit to a member's page (once every page has been visited: a member video, a page seen more than 7 days ago again, or one of the network's own programs, so a game visit is never empty; since 2026-10-28 for every game's refuel, paddle, continue, hint and supply crate), up to 20 a day, separate from the 20 Earn-tab visits; the advertiser is charged as for any visit, the player gets fuel not credits. The POL pool is funded ONLY by a share of refuel ad spend plus POL spent in the hangar, so drips depend on refuels and can be zero when the pool is empty; say so honestly. HANGAR: Drip Magnet and Courier Mk II cost drips (game currency); Shield Core and Slow Field cost POL from the game balance, which returns to the pool. GUESTS can try a run without signing in; their clears pay once they sign in. REFERRALS: each player's share link /r/<username>; when members whose InstantAdPay sponsor is that player refuel, a share (10 percent by default) of each refuel's pool income goes to the sponsor's game balance. Telegram posts achievement badges (chapters, unlocks, refuel milestones, payouts). Never promise amounts or income. The public list of every game, open now and opening next, is https://instantadpay.com/games (shareable; add ?ref=<username> to keep the referral).
|
||||||
- Every purchase is split by an immutable smart contract in the same transaction: 50% direct sponsor, 20% level 2, 10% level 3, 20% platform. No withdrawals exist; money lands in members' own wallets instantly.
|
- Every purchase is split by an immutable smart contract in the same transaction: 50% direct sponsor, 20% level 2, 10% level 3, 20% platform. No withdrawals exist; money lands in members' own wallets instantly.
|
||||||
- Qualification: level 1 open to all; 2 buyers of $20+ unlock level 2; 5 unlock level 3. Unqualified shares pass up the sponsor line, checking up to 25 positions, else the platform receives them. Qualification cannot be bought and never expires.
|
- Qualification: level 1 open to all; 2 buyers of $20+ unlock level 2; 5 unlock level 3. Unqualified shares pass up the sponsor line, checking up to 25 positions, else the platform receives them. Qualification cannot be bought and never expires.
|
||||||
@@ -463,7 +520,7 @@ async function answerRaw(message, historyText) {
|
|||||||
if (!kbOk) for (const c of CANNED) if (c.re.test(msg)) return c.id === 'refuel' && !REFUEL_ON() ? { reply: REFUEL_OFF_ANSWER, canned: true } : c.id === 'polminer' && !pmLive() ? { reply: POLMINER_SOON_ANSWER, canned: true } : c.id === 'turkeydrop' && !tdLive() ? { reply: tdAnswer(), canned: true } : c.id === 'game-pass' ? { reply: gpWithTd(c.a), canned: true } : c.id === 'network-rate' && SYN_N() !== 4 ? { reply: netRateAnswer(SYN_N()), canned: true } : Object.assign({ reply: c.a, canned: true }, c.handoff ? { handoff: true } : {});
|
if (!kbOk) for (const c of CANNED) if (c.re.test(msg)) return c.id === 'refuel' && !REFUEL_ON() ? { reply: REFUEL_OFF_ANSWER, canned: true } : c.id === 'polminer' && !pmLive() ? { reply: POLMINER_SOON_ANSWER, canned: true } : c.id === 'turkeydrop' && !tdLive() ? { reply: tdAnswer(), canned: true } : c.id === 'game-pass' ? { reply: gpWithTd(c.a), canned: true } : c.id === 'network-rate' && SYN_N() !== 4 ? { reply: netRateAnswer(SYN_N()), canned: true } : Object.assign({ reply: c.a, canned: true }, c.handoff ? { handoff: true } : {});
|
||||||
if (hit && (hit.id === 'warpwares' || hit.id === 'c-warpwares') && !wwLive()) return { reply: wwAnswer(), canned: true, kb: hit.id };
|
if (hit && (hit.id === 'warpwares' || hit.id === 'c-warpwares') && !wwLive()) return { reply: wwAnswer(), canned: true, kb: hit.id };
|
||||||
if (hit && isBixId(hit.id) && !bixLive()) return { reply: BIX_SOON_ANSWER, canned: true, kb: hit.id };
|
if (hit && isBixId(hit.id) && !bixLive()) return { reply: BIX_SOON_ANSWER, canned: true, kb: hit.id };
|
||||||
if (hit && (hit.id === 'network-rate' || hit.id === 'c-network-rate') && SYN_N() !== 4) return { reply: netRateAnswer(SYN_N()), canned: true, kb: hit.id };
|
if (hit && (hit.id === 'network-rate' || hit.id === 'c-network-rate') && (SYN_N() !== 4 || SYN_T() !== 10)) return { reply: netRateAnswer(SYN_N()), canned: true, kb: hit.id };
|
||||||
if (hit) return Object.assign({ reply: hit.answer, canned: true, kb: hit.id }, hit.handoff ? { handoff: true } : {});
|
if (hit) return Object.assign({ reply: hit.answer, canned: true, kb: hit.id }, hit.handoff ? { handoff: true } : {});
|
||||||
if (!kbOk) for (const c of CANNED) if (c.re.test(msg)) return c.id === 'refuel' && !REFUEL_ON() ? { reply: REFUEL_OFF_ANSWER, canned: true } : c.id === 'polminer' && !pmLive() ? { reply: POLMINER_SOON_ANSWER, canned: true } : c.id === 'warpwares' && !wwLive() ? { reply: wwAnswer(), canned: true } : isBixId(c.id) && !bixLive() ? { reply: BIX_SOON_ANSWER, canned: true } : c.id === 'network-rate' && SYN_N() !== 4 ? { reply: netRateAnswer(SYN_N()), canned: true } : Object.assign({ reply: c.a, canned: true }, c.handoff ? { handoff: true } : {});
|
if (!kbOk) for (const c of CANNED) if (c.re.test(msg)) return c.id === 'refuel' && !REFUEL_ON() ? { reply: REFUEL_OFF_ANSWER, canned: true } : c.id === 'polminer' && !pmLive() ? { reply: POLMINER_SOON_ANSWER, canned: true } : c.id === 'warpwares' && !wwLive() ? { reply: wwAnswer(), canned: true } : isBixId(c.id) && !bixLive() ? { reply: BIX_SOON_ANSWER, canned: true } : c.id === 'network-rate' && SYN_N() !== 4 ? { reply: netRateAnswer(SYN_N()), canned: true } : Object.assign({ reply: c.a, canned: true }, c.handoff ? { handoff: true } : {});
|
||||||
// retrieval: the closest entries ride along in the system prompt (a short follow-up borrows words from the chat so far)
|
// retrieval: the closest entries ride along in the system prompt (a short follow-up borrows words from the chat so far)
|
||||||
|
|||||||
@@ -340,7 +340,7 @@ async function nudgeTick() {
|
|||||||
// weekly member email (Marty, 2026-09-14, modelled on the mailer.gold weekly): credits sitting unspent,
|
// weekly member email (Marty, 2026-09-14, modelled on the mailer.gold weekly): credits sitting unspent,
|
||||||
// the streak, the contest standings with the member's own rank, the tank, and the line for sponsors
|
// the streak, the contest standings with the member's own rank, the tank, and the line for sponsors
|
||||||
let lbWeek = null; try { lbWeek = X.lb ? await X.lb().view('week') : null; } catch (e) {}
|
let lbWeek = null; try { lbWeek = X.lb ? await X.lb().view('week') : null; } catch (e) {}
|
||||||
let tankN = 0; try { tankN = X.tank ? (await X.tank.waiting()).length : 0; } catch (e) {}
|
let tankN = 0; try { tankN = X.tank ? (await X.tank.adoptable()).length : 0; } catch (e) {}
|
||||||
for (const acct of all) {
|
for (const acct of all) {
|
||||||
if (!acct.email) continue;
|
if (!acct.email) continue;
|
||||||
const lastD = await impl().lastDigest(acct.email);
|
const lastD = await impl().lastDigest(acct.email);
|
||||||
|
|||||||
+12
-3
@@ -230,10 +230,19 @@ switched off for members (`sovTiers` 0) until Marty flips it.
|
|||||||
|---|---|---|---|---|
|
|---|---|---|---|---|
|
||||||
| `weekly` | Game Pass | 500 credits ($5) | 7 days | the Game Pass in all nine games, the Sunless Vault, weapons unlocked |
|
| `weekly` | Game Pass | 500 credits ($5) | 7 days | the Game Pass in all nine games, the Sunless Vault, weapons unlocked |
|
||||||
| `explorer` | Explorer | 2000 ($20, the Activation package) | 30 days | weapons, gear, 2 DLC islands |
|
| `explorer` | Explorer | 2000 ($20, the Activation package) | 30 days | weapons, gear, 2 DLC islands |
|
||||||
| `champion` | Champion | 5000 ($50, the Builder package) | 30 days | weapons, gear, 4 DLC islands of your choice, the Druid hero, level cap 30 |
|
| `champion` | Champion | 5000 ($50, the Builder package) | 30 days | weapons, gear, 4 DLC islands of your choice, level cap 30 |
|
||||||
| `sovereign` | Sovereign | 10000 ($100, the Growth package) | 30 days | weapons, gear, all DLC islands, the Necromancer hero, level cap 40 |
|
| `sovereign` | Sovereign | 10000 ($100, the Growth package) | 30 days | weapons, gear, all DLC islands, level cap 40 |
|
||||||
| `legend` | Legend | 25000 ($250, the Leader package) | 365 days | weapons, gear, all DLC islands, every hero including the Archer, level cap 40 |
|
| `legend` | Legend | 25000 ($250, the Leader package) | 365 days | weapons, gear, all DLC islands, every bonus hero while active, level cap 40 |
|
||||||
|
|
||||||
|
**Bonus heroes (2026-11-05, Marty approved).** Kestrel the Archer, Valda the Barbarian, Morag the Druid and Roland the Paladin are
|
||||||
|
SOLD ONE TIME (no subscription, no expiry), not by a tier: $20 each (2000 cents, the Activation package) and a $50 bundle (5000, the
|
||||||
|
Builder package) of Valda, Morag and Roland by default. Paid like a pass: POST /api/my/heroes/buy { hero } opens a waiting order (kind
|
||||||
|
hero); a fresh package of at least the price from one of the member's own positions fulfils it in `onEvent` (one package, one order, the
|
||||||
|
highest-priced it covers). Owned heroes live on the passes record (`heroes`, `heroBundle`) and never in `bought`, so they never feed the
|
||||||
|
Pass Tournament pool. Settings: `heroSales` (sale switch, OFF), `heroPrice<Name>Cents` (0 = free for every account), `heroBundlePriceCents`,
|
||||||
|
`heroBundleHeroes`, `heroBundleCap` (empty: no cap change; not approved). Shards of Valor reads `heroes`, `heroBundle`, `heroSale` (and
|
||||||
|
`heroBundleCap` only when set) on the sign-in hand-off. Admin > Game Pass has a hero test on the admin's own account. QA: qa/sov-heroes-store.cjs.
|
||||||
|
|
||||||
- **One table**: `gamepass.js` `TIER_DEFS` holds the rank, wire key, display name, settings stem, default price/length and the
|
- **One table**: `gamepass.js` `TIER_DEFS` holds the rank, wire key, display name, settings stem, default price/length and the
|
||||||
member-card list for every tier. Rename a tier there (the card, admin pane, charge label and chatbot all read it).
|
member-card list for every tier. Rename a tier there (the card, admin pane, charge label and chatbot all read it).
|
||||||
- **Rank**: weekly < explorer < champion < sovereign < legend. Every tier is a Game Pass holder everywhere with exactly the pass
|
- **Rank**: weekly < explorer < champion < sovereign < legend. Every tier is a Game Pass holder everywhere with exactly the pass
|
||||||
|
|||||||
+191
@@ -0,0 +1,191 @@
|
|||||||
|
// Database-backed data documents (Marty 2026-11-13, standing rule: "everything database-driven ... files only for early
|
||||||
|
// prototyping"). Every *.json / *.jsonl data document under DATA_DIR that a module reads or writes with the fs *Sync calls lives
|
||||||
|
// in MySQL instead of on the volume: table `docs` (name = path relative to DATA_DIR, body LONGTEXT, updated_at). The modules keep
|
||||||
|
// their code; install() routes their fs calls on those paths to an in-memory copy that init() loads from MySQL at boot, and every
|
||||||
|
// change is written through to MySQL (coalesced per document, newest body wins, in order, retried until it lands).
|
||||||
|
//
|
||||||
|
// One writer at a time: init() claims the `docs_writer` row; an older app copy still running during a deploy finds the row taken
|
||||||
|
// and stops writing (logged), so it can never put stale data over the new copy's (the 2026-11-13 rotator.json loss).
|
||||||
|
// First boot: a document missing from MySQL is imported from its file, and the file is renamed <name>.imported-<date> (kept, not
|
||||||
|
// read again). Files the volume keeps on purpose: KEEP (rebuildable caches, uploads, images, the geo database, queues read by
|
||||||
|
// listing a folder). The SAME file ships in InstantAdPay and LinkSpin.
|
||||||
|
'use strict';
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const crypto = require('crypto');
|
||||||
|
|
||||||
|
const KEEP_FILES = new Set(['chain-index.json']); // a rebuildable cache of the blockchain
|
||||||
|
const KEEP_DIRS = ['uploads', 'geo', 'refuel-pending', 'backups', 'marks', 'kits', 'kitimg']; // binary files, or folders read by listing
|
||||||
|
const O = { readFileSync: fs.readFileSync, writeFileSync: fs.writeFileSync, existsSync: fs.existsSync, renameSync: fs.renameSync,
|
||||||
|
unlinkSync: fs.unlinkSync, statSync: fs.statSync, appendFileSync: fs.appendFileSync };
|
||||||
|
|
||||||
|
let ROOT = null, pool = null, ME = crypto.randomBytes(8).toString('hex'), ready = false, writer = true;
|
||||||
|
const cache = new Map(); // name -> { body: string, at: ms }
|
||||||
|
const pending = new Map(); // name -> body string | null (delete)
|
||||||
|
let flushing = false, timer = null;
|
||||||
|
const stats = { writes: 0, deletes: 0, refused: 0, errors: 0, imported: 0, lastError: null };
|
||||||
|
|
||||||
|
function nameOf(p) {
|
||||||
|
if (!ROOT || typeof p !== 'string' || !/\.jsonl?$/i.test(p)) return null;
|
||||||
|
const abs = path.resolve(p); if (!abs.startsWith(ROOT + path.sep)) return null;
|
||||||
|
const rel = abs.slice(ROOT.length + 1).split(path.sep).join('/');
|
||||||
|
if (KEEP_FILES.has(rel) || KEEP_DIRS.some(d => rel === d || rel.startsWith(d + '/'))) return null;
|
||||||
|
return rel;
|
||||||
|
}
|
||||||
|
const enoent = p => { const e = new Error("ENOENT: no such file or directory, open '" + p + "'"); e.code = 'ENOENT'; e.errno = -2; e.path = p; return e; };
|
||||||
|
const enc = o => (typeof o === 'string' ? o : o && o.encoding) || null;
|
||||||
|
|
||||||
|
function put(name, body) { cache.set(name, { body, at: Date.now() }); pending.set(name, body); kick(); }
|
||||||
|
function drop(name) { cache.delete(name); pending.set(name, null); kick(); }
|
||||||
|
function kick() { if (!timer) timer = setTimeout(() => { timer = null; flush().catch(() => {}); }, 300); }
|
||||||
|
|
||||||
|
async function flush() {
|
||||||
|
if (!pool || flushing || !pending.size) return;
|
||||||
|
flushing = true;
|
||||||
|
try {
|
||||||
|
for (const [name, body] of [...pending]) {
|
||||||
|
if (pending.get(name) !== body) continue; // replaced while we were busy: the newer body goes next round
|
||||||
|
if (!writer) { pending.delete(name); stats.refused++; continue; }
|
||||||
|
const c = await pool.getConnection();
|
||||||
|
try {
|
||||||
|
await c.beginTransaction();
|
||||||
|
const [[w]] = await c.query('SELECT owner FROM docs_writer WHERE id = 1 FOR UPDATE');
|
||||||
|
if (!w || w.owner !== ME) { await c.rollback(); writer = false; pending.delete(name); stats.refused++; console.error('docstore: another app copy took over writing; this copy stops writing'); continue; }
|
||||||
|
if (body === null) { await c.query('DELETE FROM docs WHERE name = ?', [name]); stats.deletes++; }
|
||||||
|
else { await c.query('INSERT INTO docs (name, body, updated_at) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE body = VALUES(body), updated_at = VALUES(updated_at)', [name, body, Date.now()]); stats.writes++; }
|
||||||
|
await c.commit();
|
||||||
|
if (pending.get(name) === body) pending.delete(name);
|
||||||
|
} catch (e) { try { await c.rollback(); } catch (x) {} stats.errors++; stats.lastError = String(e.message).slice(0, 200); console.error('docstore write', name, e.message); }
|
||||||
|
finally { c.release(); }
|
||||||
|
}
|
||||||
|
} finally { flushing = false; if (pending.size) setTimeout(() => flush().catch(() => {}), 1000); }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Route the fs *Sync calls on data documents. Installed before any module runs; until init() the documents read from disk.
|
||||||
|
function install(dataDir) {
|
||||||
|
if (ROOT) return; ROOT = path.resolve(dataDir);
|
||||||
|
fs.readFileSync = function (p, o) {
|
||||||
|
if (!ready && process.env.DOCSTORE_URL && nameOf(p)) console.error('docstore: read before init', p, new Error().stack.split('\n')[2]);
|
||||||
|
const n = ready ? nameOf(p) : null; if (!n) return O.readFileSync.apply(fs, arguments);
|
||||||
|
const d = cache.get(n); if (!d) throw enoent(p);
|
||||||
|
return enc(o) ? d.body : Buffer.from(d.body, 'utf8');
|
||||||
|
};
|
||||||
|
fs.existsSync = function (p) { const n = ready ? nameOf(p) : null; return n ? cache.has(n) : O.existsSync.apply(fs, arguments); };
|
||||||
|
fs.writeFileSync = function (p, data, o) {
|
||||||
|
const n = ready ? nameOf(p) : null; if (!n) return O.writeFileSync.apply(fs, arguments);
|
||||||
|
const flag = o && typeof o === 'object' ? o.flag : null;
|
||||||
|
const s = Buffer.isBuffer(data) ? data.toString('utf8') : String(data);
|
||||||
|
put(n, flag && flag[0] === 'a' ? ((cache.get(n) || {}).body || '') + s : s);
|
||||||
|
};
|
||||||
|
fs.appendFileSync = function (p, data) {
|
||||||
|
const n = ready ? nameOf(p) : null; if (!n) return O.appendFileSync.apply(fs, arguments);
|
||||||
|
put(n, ((cache.get(n) || {}).body || '') + (Buffer.isBuffer(data) ? data.toString('utf8') : String(data)));
|
||||||
|
};
|
||||||
|
fs.renameSync = function (a, b) {
|
||||||
|
const nb = ready ? nameOf(b) : null; const na = ready ? nameOf(a) : null;
|
||||||
|
if (!nb && !na) return O.renameSync.apply(fs, arguments);
|
||||||
|
let body;
|
||||||
|
if (na) { const d = cache.get(na); if (!d) throw enoent(a); body = d.body; drop(na); }
|
||||||
|
else { body = O.readFileSync.call(fs, a, 'utf8'); try { O.unlinkSync.call(fs, a); } catch (e) {} }
|
||||||
|
if (nb) put(nb, body); else O.writeFileSync.call(fs, b, body);
|
||||||
|
};
|
||||||
|
fs.unlinkSync = function (p) { const n = ready ? nameOf(p) : null; if (!n) return O.unlinkSync.apply(fs, arguments); if (!cache.has(n)) throw enoent(p); drop(n); };
|
||||||
|
fs.statSync = function (p, o) {
|
||||||
|
const n = ready ? nameOf(p) : null; if (!n) return O.statSync.apply(fs, arguments);
|
||||||
|
const d = cache.get(n); if (!d) { if (o && o.throwIfNoEntry === false) return undefined; throw enoent(p); }
|
||||||
|
const size = Buffer.byteLength(d.body, 'utf8'); const t = new Date(d.at);
|
||||||
|
return { size, mtimeMs: d.at, mtime: t, ctime: t, birthtime: t, isFile: () => true, isDirectory: () => false, isSymbolicLink: () => false };
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Connect, claim writing, load every document, import files MySQL does not have yet. Throws if MySQL is unreachable: the app
|
||||||
|
// must not run on an empty copy.
|
||||||
|
async function init(opts) {
|
||||||
|
const url = String(process.env.DOCSTORE_URL || '').trim();
|
||||||
|
if (!url) { console.log('docstore: no DOCSTORE_URL, documents stay files (prototype mode)'); return false; }
|
||||||
|
const mysql = require('mysql2/promise');
|
||||||
|
pool = mysql.createPool({ uri: url, connectionLimit: 6, charset: 'utf8mb4' });
|
||||||
|
await pool.query('CREATE TABLE IF NOT EXISTS docs (name VARCHAR(190) PRIMARY KEY, body LONGTEXT NOT NULL, updated_at BIGINT NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4');
|
||||||
|
await pool.query('CREATE TABLE IF NOT EXISTS docs_writer (id TINYINT PRIMARY KEY, owner VARCHAR(40) NOT NULL, at BIGINT NOT NULL) ENGINE=InnoDB');
|
||||||
|
await pool.query('INSERT INTO docs_writer (id, owner, at) VALUES (1, ?, ?) ON DUPLICATE KEY UPDATE owner = VALUES(owner), at = VALUES(at)', [ME, Date.now()]);
|
||||||
|
const [rows] = await pool.query('SELECT name, body, updated_at FROM docs');
|
||||||
|
for (const r of rows) cache.set(r.name, { body: r.body, at: Number(r.updated_at) });
|
||||||
|
for (const sp of (opts && opts.splits) || []) await openSplit(sp);
|
||||||
|
// first boot for any document: import its file, then set the file aside
|
||||||
|
const stamp = new Date().toISOString().slice(0, 10);
|
||||||
|
const walk = dir => { let out = []; let ents = []; try { ents = fs.readdirSync(dir, { withFileTypes: true }); } catch (e) {} for (const e of ents) { const p = path.join(dir, e.name); if (e.isDirectory()) out = out.concat(walk(p)); else out.push(p); } return out; };
|
||||||
|
for (const p of walk(ROOT)) {
|
||||||
|
const n = nameOf(p); if (!n || cache.has(n)) continue;
|
||||||
|
const body = O.readFileSync.call(fs, p, 'utf8');
|
||||||
|
if (/\.json$/i.test(n) && body.trim()) { try { JSON.parse(body); } catch (e) { throw new Error('docstore: ' + n + ' is not valid JSON; fix or move it before switching to MySQL'); } }
|
||||||
|
await pool.query('INSERT INTO docs (name, body, updated_at) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE name = name', [n, body, Date.now()]);
|
||||||
|
const [[got]] = await pool.query('SELECT body FROM docs WHERE name = ?', [n]);
|
||||||
|
cache.set(n, { body: got.body, at: Date.now() }); stats.imported++;
|
||||||
|
O.renameSync.call(fs, p, p + '.imported-' + stamp);
|
||||||
|
}
|
||||||
|
for (const sp of (opts && opts.splits) || []) await migrateSplit(sp);
|
||||||
|
ready = true;
|
||||||
|
console.log('docstore: MySQL documents ready,', cache.size, 'documents,', stats.imported, 'imported from files this boot');
|
||||||
|
const shut = () => { flush().catch(() => {}).finally(() => {}); };
|
||||||
|
process.once('beforeExit', shut);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// ---- row tables: an ever-growing array (spin-link clicks) is one row per item, never a rewrite of the whole document ----
|
||||||
|
// spec { doc: 'rotator.json', field: 'hits', table: 'rot_hits', key: 'id', ts: 'ts' }. rows(table) gives the loaded items (oldest
|
||||||
|
// first); the module inserts / deletes rows itself and saves its document WITHOUT the field.
|
||||||
|
const ROWS = new Map(); const rowQ = []; let rowBusy = false;
|
||||||
|
async function openSplit(sp) {
|
||||||
|
await pool.query('CREATE TABLE IF NOT EXISTS `' + sp.table + '` (id VARCHAR(64) PRIMARY KEY, ts BIGINT NOT NULL, body MEDIUMTEXT NOT NULL, KEY ts (ts)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4');
|
||||||
|
const [r] = await pool.query('SELECT body FROM `' + sp.table + '` ORDER BY ts, id');
|
||||||
|
ROWS.set(sp.table, r.map(x => JSON.parse(x.body)));
|
||||||
|
}
|
||||||
|
async function insertMany(table, items, key, ts) {
|
||||||
|
for (let i = 0; i < items.length; i += 500) {
|
||||||
|
const part = items.slice(i, i + 500);
|
||||||
|
await pool.query('INSERT INTO `' + table + '` (id, ts, body) VALUES ? ON DUPLICATE KEY UPDATE body = VALUES(body), ts = VALUES(ts)', [part.map(x => [String(x[key]), Number(x[ts]) || 0, JSON.stringify(x)])]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// first boot: the array still inside the document moves to its table, then the document is saved without it
|
||||||
|
async function migrateSplit(sp) {
|
||||||
|
const d = cache.get(sp.doc); if (!d) return;
|
||||||
|
let obj; try { obj = JSON.parse(d.body); } catch (e) { return; }
|
||||||
|
const arr = Array.isArray(obj[sp.field]) ? obj[sp.field] : null; if (!arr || !arr.length) return;
|
||||||
|
await insertMany(sp.table, arr, sp.key, sp.ts);
|
||||||
|
const [[{ n }]] = await pool.query('SELECT COUNT(*) n FROM `' + sp.table + '`');
|
||||||
|
if (n < arr.length) throw new Error('docstore: ' + sp.table + ' holds ' + n + ' rows after moving ' + arr.length + '; stopping before the document is changed');
|
||||||
|
const seen = new Set((ROWS.get(sp.table) || []).map(x => String(x[sp.key]))); const merged = (ROWS.get(sp.table) || []).concat(arr.filter(x => !seen.has(String(x[sp.key]))));
|
||||||
|
merged.sort((a, b) => (Number(a[sp.ts]) || 0) - (Number(b[sp.ts]) || 0)); ROWS.set(sp.table, merged);
|
||||||
|
obj[sp.field] = []; const body = JSON.stringify(obj);
|
||||||
|
await pool.query('UPDATE docs SET body = ?, updated_at = ? WHERE name = ?', [body, Date.now(), sp.doc]); cache.set(sp.doc, { body, at: Date.now() });
|
||||||
|
console.log('docstore:', arr.length, sp.field, 'moved from', sp.doc, 'to table', sp.table);
|
||||||
|
}
|
||||||
|
function rows(table) { return ROWS.get(table) || null; }
|
||||||
|
function rowOp(op) { if (!pool || !writer) return; rowQ.push(op); if (!rowBusy) runRows(); }
|
||||||
|
async function runRows() {
|
||||||
|
rowBusy = true;
|
||||||
|
try {
|
||||||
|
while (rowQ.length && writer) {
|
||||||
|
const op = rowQ[0];
|
||||||
|
try {
|
||||||
|
if (op.del) await pool.query('DELETE FROM `' + op.table + '` WHERE id IN (?)', [op.ids]);
|
||||||
|
else await pool.query('INSERT INTO `' + op.table + '` (id, ts, body) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE body = VALUES(body), ts = VALUES(ts)', [op.id, op.ts, op.body]);
|
||||||
|
rowQ.shift();
|
||||||
|
} catch (e) { stats.errors++; stats.lastError = String(e.message).slice(0, 200); await new Promise(r => setTimeout(r, 1000)); }
|
||||||
|
}
|
||||||
|
} finally { rowBusy = false; }
|
||||||
|
}
|
||||||
|
const rowPut = (table, id, ts, obj) => rowOp({ table, id: String(id), ts: Number(ts) || 0, body: JSON.stringify(obj) });
|
||||||
|
const rowDel = (table, ids) => { const list = [...ids].map(String); for (let i = 0; i < list.length; i += 1000) rowOp({ table, del: true, ids: list.slice(i, i + 1000) }); };
|
||||||
|
function isOn() { return ready && !!pool; }
|
||||||
|
// once across app copies (two run side by side during a deploy): true for the first caller of a key, false after. Without MySQL: true.
|
||||||
|
async function claim(key) {
|
||||||
|
if (!pool) return true;
|
||||||
|
await pool.query('CREATE TABLE IF NOT EXISTS doc_claims (k VARCHAR(190) PRIMARY KEY, at BIGINT NOT NULL) ENGINE=InnoDB');
|
||||||
|
const [r] = await pool.query('INSERT IGNORE INTO doc_claims (k, at) VALUES (?, ?)', [String(key).slice(0, 190), Date.now()]);
|
||||||
|
return r.affectedRows === 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SIGTERM during a deploy: write what is pending, then exit
|
||||||
|
async function drain(ms) { const end = Date.now() + (ms || 8000); while ((pending.size || flushing || rowQ.length || rowBusy) && Date.now() < end) { await flush().catch(() => {}); await new Promise(r => setTimeout(r, 100)); } }
|
||||||
|
function view() { return Object.assign({ ready, writer, documents: cache.size, pending: pending.size, rowQueue: rowQ.length, rowTables: Object.fromEntries([...ROWS].map(([k, v]) => [k, v.length])), bytes: [...cache.values()].reduce((t, d) => t + d.body.length, 0) }, stats); }
|
||||||
|
module.exports = { install, init, drain, flush, view, nameOf, rows, rowPut, rowDel, isOn, claim };
|
||||||
+313
@@ -0,0 +1,313 @@
|
|||||||
|
'use strict';
|
||||||
|
// 5xYourTeam "The Draft" partner side (Marty approved the rules 2026-11-15). The network holding tank lives HERE (tank.js);
|
||||||
|
// 5xYourTeam coaches draft from it through four signed calls, and every pick is a real tank adoption through tank.adopt():
|
||||||
|
//
|
||||||
|
// POST /api/partner/draft/pool {} -> { ok, rules, pool: [card], excluded: {why: n} }
|
||||||
|
// POST /api/partner/draft/adopt { rid, coach, person, kind, week?, slot?, note? } -> { ok, ref, person, adoptionId, at, expires, holdUntil }
|
||||||
|
// POST /api/partner/draft/release { rid, coach, ref | person, why: 'coach' | 'return' } -> { ok, outcome: 'returned' | 'kept' | 'done' | <closed status>, already? }
|
||||||
|
// POST /api/partner/draft/status { ids: [person id] } -> { ok, people: { id: milestones | null } }
|
||||||
|
// coach = { wallet, hubId?, username?, positions } (the 5xYourTeam claim: positions = 5x positions this wallet holds)
|
||||||
|
// card = { id, username, door, joinedAt, lastSeen, wallet (bool), ready, holdUntil, opensAt, adoptions (outside 5x), adoptionsTotal, games, surfWei, surfCredits }
|
||||||
|
//
|
||||||
|
// Signature: X-Draft-Ts (ms) + X-Draft-Sig = hex HMAC-SHA256(DRAFT_PARTNER_SECRET, 'draft.v1.' + ts + '\n' + raw body), 5-minute
|
||||||
|
// window. A dedicated secret (not NETWORK_SSO_SECRET): this one can move sponsors. adopt and release carry a request id (rid): a
|
||||||
|
// retried or replayed call answers what the first one did and changes nothing.
|
||||||
|
//
|
||||||
|
// The rules (project-5xyourteam-draft, 11-15):
|
||||||
|
// - only 5xYourTeam position holders draft and coach: the signed claim (positions >= 1) REPLACES InstantAdPay's own-$20-buy rule
|
||||||
|
// for these calls only (the member's own tank button keeps its $20 rule); a coach needs an account here with a wallet linked,
|
||||||
|
// and someone on this contract in their line (tank.partnerEligibility); free members cannot adopt
|
||||||
|
// - the pool = tank.waiting() (rule 3 already applied: nobody the hub reports locked on any contract or sponsored, nobody adopted
|
||||||
|
// on LinkSpin) minus spam / suspended / flagged, throwaway or mistyped email domains, and anyone adopted twice already
|
||||||
|
// - max 10 open picks a coach (and the tank's people-held-at-once cap); max 2 adoptions per person (every pick counts, both sites)
|
||||||
|
// - a pick that has not STARTED (payouts on or a first purchase) in 3 days goes back to the pool; a coach cannot release one in its
|
||||||
|
// first 48 hours; a person who has had their 2 adoptions stays with the coach (the tank sweep rule); started picks stay
|
||||||
|
// - never anyone locked on a network contract: asked fresh at adopt and at every return; a hub that does not answer refuses / waits
|
||||||
|
// - 24-hour sign-up grace (tank.adopt refuses it; the card carries opensAt); coaches never see contact data: no email, phone or
|
||||||
|
// address leaves this module, person ids are hub ids (or an opaque i_ id the hub does not know)
|
||||||
|
// - the only mail: tank.adopt's normal "X is now your sponsor" adoption email. No switch-on-payouts reminders for picks, no
|
||||||
|
// payments-topic post (5xYourTeam posts its own Draft Day card)
|
||||||
|
//
|
||||||
|
// Auto-assign vs the 3-day window (the conflict the 5x build flagged), the rule implemented:
|
||||||
|
// - a drafted person is an open adoption with a sponsor, so they are out of the tank: no 24-hour activation hold, no auto-assign,
|
||||||
|
// no sign-up announcement, no dormant-lead rescue while the pick window runs
|
||||||
|
// - the pick's adoption row expires at +3 days (not IAP's 7), and tank.sweep leaves it alone (hooks.isDraftPick): this module
|
||||||
|
// closes it at 3 days with the pick's rule (started = payouts on or a purchase, a wallet alone is not started)
|
||||||
|
// - a returned pick goes back with their ORIGINAL join time (account `created` is never touched, so no new sign-up grace) and,
|
||||||
|
// with a wallet linked, a fresh 24-hour activation hold like anyone back in the tank (never the company)
|
||||||
|
// - sponsor moves go through tank.js setSponsor (sponsorfollow + the hub's /v1/sponsor-change with by 'adopt' / 'release')
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const crypto = require('crypto');
|
||||||
|
const db = require('./db');
|
||||||
|
|
||||||
|
const H = 3600000, D = 86400000;
|
||||||
|
const RULES = { returnMs: 3 * D, holdMs: 48 * H, maxOpen: 10, maxAdoptions: 2 };
|
||||||
|
const ADDR = /^0x[0-9a-f]{40}$/;
|
||||||
|
const lc = v => String(v || '').trim().toLowerCase();
|
||||||
|
// throwaway / disposable inboxes: the adoption email would go nowhere. Plus a mistyped big-provider domain (emailcheck.js).
|
||||||
|
const THROWAWAY = new Set(['mailinator.com', 'guerrillamail.com', 'guerrillamail.net', 'sharklasers.com', 'grr.la', '10minutemail.com', 'tempmail.com', 'temp-mail.org',
|
||||||
|
'yopmail.com', 'trashmail.com', 'getnada.com', 'maildrop.cc', 'dispostable.com', 'throwawaymail.com', 'fakeinbox.com', 'mintemail.com', 'mohmal.com', 'emailondeck.com',
|
||||||
|
'tempail.com', 'tempr.email', 'discard.email', 'spamgourmet.com', 'mailnesia.com', 'mytemp.email', 'tempmailo.com', 'burnermail.io', 'example.com', 'test.com']);
|
||||||
|
const DOORS = { iap: 'InstantAdPay', instantadpay: 'InstantAdPay', linkspin: 'LinkSpin', bannerline: 'Downline Banners', dlb: 'Downline Banners', vbb: 'Viral Banner Blitz',
|
||||||
|
ctb: 'CryptoTeamBuild', fivex: '5xYourTeam', vab: 'ViralAdBlitz', viraladblitz: 'ViralAdBlitz', dh: 'DownlineHydra', btc4hits: 'BTC4Hits', stackpol: 'Stack POL' };
|
||||||
|
|
||||||
|
let R = null; // { dataDir, accounts, chain, tank, ads, hooks: { hubInfo, resolvePerson, excluded, spamEmails, networkOn, suggestDomain }, requireHub, clock }
|
||||||
|
const clock = () => (R && R.clock ? R.clock() : Date.now());
|
||||||
|
const SECRET = () => String((R && R.secret) || process.env.DRAFT_PARTNER_SECRET || '').trim();
|
||||||
|
const enabled = () => SECRET().length >= 32;
|
||||||
|
|
||||||
|
// ---- storage: MySQL (draft_picks, draft_log) when DATABASE_URL is set, else a JSON document (local QA) ----
|
||||||
|
const J = {
|
||||||
|
st: null, FILE: () => path.join(R.dataDir, 'draft-partner.json'),
|
||||||
|
load() { if (this.st) return this.st; try { this.st = JSON.parse(fs.readFileSync(this.FILE(), 'utf8')); } catch (e) { this.st = null; } if (!this.st || typeof this.st !== 'object') this.st = {}; this.st.nextId = this.st.nextId || 1; this.st.picks = this.st.picks || []; this.st.log = this.st.log || []; return this.st; },
|
||||||
|
save() { const f = this.FILE(); fs.writeFileSync(f + '.tmp', JSON.stringify(this.load())); fs.renameSync(f + '.tmp', f); },
|
||||||
|
async add(p) { const s = this.load(); const row = Object.assign({ id: s.nextId++ }, p); s.picks.push(row); this.save(); return Object.assign({}, row); },
|
||||||
|
async put(p) { const s = this.load(); const i = s.picks.findIndex(x => x.id === p.id); if (i >= 0) s.picks[i] = Object.assign({}, p); this.save(); },
|
||||||
|
async byId(id) { const x = this.load().picks.find(r => r.id === Number(id)); return x ? Object.assign({}, x) : null; },
|
||||||
|
async byRid(rid) { const x = this.load().picks.find(r => r.rid === rid); return x ? Object.assign({}, x) : null; },
|
||||||
|
async byAdoption(aid) { const x = this.load().picks.find(r => r.adoptionId === Number(aid)); return x ? Object.assign({}, x) : null; },
|
||||||
|
async ofPerson(pid) { return this.load().picks.filter(r => r.personId === pid).map(x => Object.assign({}, x)); },
|
||||||
|
async open() { return this.load().picks.filter(r => r.status === 'open').map(x => Object.assign({}, x)); },
|
||||||
|
async openOfCoach(w) { return this.load().picks.filter(r => r.status === 'open' && r.coachWallet === w).map(x => Object.assign({}, x)); },
|
||||||
|
async recent(n) { return this.load().picks.slice(-(n || 100)).reverse().map(x => Object.assign({}, x)); },
|
||||||
|
async countsByAdoptee() { const m = new Map(); for (const r of this.load().picks) m.set(r.adoptee, (m.get(r.adoptee) || 0) + 1); return m; },
|
||||||
|
async log(row) { const s = this.load(); s.log.push(row); if (s.log.length > 2000) s.log = s.log.slice(-2000); this.save(); },
|
||||||
|
async logs(n) { return this.load().log.slice(-(n || 100)).reverse(); }
|
||||||
|
};
|
||||||
|
const COLS = ['rid', 'adoptionId', 'adoptee', 'personId', 'coachEmail', 'coachWallet', 'coachHubId', 'kind', 'week', 'slot', 'ts', 'expires', 'holdUntil', 'status', 'closed', 'outcomeWhy', 'walletAt', 'payoutsAt', 'purchaseAt'];
|
||||||
|
const SQLC = { rid: 'rid', adoptionId: 'adoption_id', adoptee: 'adoptee', personId: 'person_id', coachEmail: 'coach_email', coachWallet: 'coach_wallet', coachHubId: 'coach_hub_id', kind: 'kind', week: 'week', slot: 'slot', ts: 'ts', expires: 'expires', holdUntil: 'hold_until', status: 'status', closed: 'closed', outcomeWhy: 'outcome_why', walletAt: 'wallet_at', payoutsAt: 'payouts_at', purchaseAt: 'purchase_at' };
|
||||||
|
const NUM = new Set(['adoptionId', 'ts', 'expires', 'holdUntil', 'closed', 'walletAt', 'payoutsAt', 'purchaseAt']);
|
||||||
|
const rowP = r => { if (!r) return null; const o = { id: Number(r.id) }; for (const k of COLS) { const v = r[SQLC[k]]; o[k] = NUM.has(k) ? Number(v || 0) : (v == null ? null : String(v)); } return o; };
|
||||||
|
const Q = {
|
||||||
|
async add(p) { const r = await db.q('INSERT INTO draft_picks (' + COLS.map(k => SQLC[k]).join(',') + ') VALUES (' + COLS.map(() => '?').join(',') + ')', COLS.map(k => p[k] == null ? null : p[k])); return Object.assign({ id: r.insertId }, p); },
|
||||||
|
async put(p) { await db.q('UPDATE draft_picks SET ' + COLS.map(k => SQLC[k] + '=?').join(',') + ' WHERE id=?', COLS.map(k => p[k] == null ? null : p[k]).concat([p.id])); },
|
||||||
|
async byId(id) { return rowP((await db.q('SELECT * FROM draft_picks WHERE id=?', [Number(id)]))[0]); },
|
||||||
|
async byRid(rid) { return rowP((await db.q('SELECT * FROM draft_picks WHERE rid=?', [rid]))[0]); },
|
||||||
|
async byAdoption(aid) { return rowP((await db.q('SELECT * FROM draft_picks WHERE adoption_id=?', [Number(aid)]))[0]); },
|
||||||
|
async ofPerson(pid) { return (await db.q('SELECT * FROM draft_picks WHERE person_id=? ORDER BY id', [pid])).map(rowP); },
|
||||||
|
async open() { return (await db.q("SELECT * FROM draft_picks WHERE status='open' ORDER BY id")).map(rowP); },
|
||||||
|
async openOfCoach(w) { return (await db.q("SELECT * FROM draft_picks WHERE status='open' AND coach_wallet=?", [w])).map(rowP); },
|
||||||
|
async recent(n) { return (await db.q('SELECT * FROM draft_picks ORDER BY id DESC LIMIT ?', [Number(n) || 100])).map(rowP); },
|
||||||
|
async countsByAdoptee() { return new Map((await db.q('SELECT adoptee, COUNT(*) n FROM draft_picks GROUP BY adoptee')).map(r => [r.adoptee, Number(r.n)])); },
|
||||||
|
async log(x) { await db.q('INSERT INTO draft_log (ts,op,ok,code,reason,coach,person,ref,rid) VALUES (?,?,?,?,?,?,?,?,?)', [x.ts, x.op, x.ok ? 1 : 0, x.code || null, String(x.reason || '').slice(0, 400), x.coach || null, x.person || null, x.ref || null, x.rid || null]); },
|
||||||
|
async logs(n) { return (await db.q('SELECT * FROM draft_log ORDER BY id DESC LIMIT ?', [Number(n) || 100])).map(r => ({ ts: Number(r.ts), op: r.op, ok: !!r.ok, code: r.code, reason: r.reason, coach: r.coach, person: r.person, ref: r.ref, rid: r.rid })); }
|
||||||
|
};
|
||||||
|
const S = () => (db.enabled() ? Q : J);
|
||||||
|
async function ensureTables() {
|
||||||
|
if (!db.enabled()) return;
|
||||||
|
await db.q(`CREATE TABLE IF NOT EXISTS draft_picks (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY, rid VARCHAR(80) NOT NULL, adoption_id INT NOT NULL, adoptee VARCHAR(190) NOT NULL, person_id VARCHAR(40) NOT NULL,
|
||||||
|
coach_email VARCHAR(190) NOT NULL, coach_wallet VARCHAR(42) NOT NULL, coach_hub_id VARCHAR(40) NULL, kind VARCHAR(16) NULL, week VARCHAR(16) NULL, slot VARCHAR(16) NULL,
|
||||||
|
ts BIGINT NOT NULL, expires BIGINT NOT NULL, hold_until BIGINT NOT NULL, status VARCHAR(16) NOT NULL, closed BIGINT NULL, outcome_why VARCHAR(200) NULL,
|
||||||
|
wallet_at BIGINT NULL, payouts_at BIGINT NULL, purchase_at BIGINT NULL,
|
||||||
|
UNIQUE KEY rid (rid), KEY adoption (adoption_id), KEY person (person_id), KEY coach (coach_wallet, status), KEY st (status)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4`); // 5xYourTeam draft picks (each one a tank adoption)
|
||||||
|
await db.q(`CREATE TABLE IF NOT EXISTS draft_log (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY, ts BIGINT NOT NULL, op VARCHAR(16) NOT NULL, ok TINYINT NOT NULL, code VARCHAR(40) NULL, reason VARCHAR(400) NULL,
|
||||||
|
coach VARCHAR(42) NULL, person VARCHAR(40) NULL, ref VARCHAR(40) NULL, rid VARCHAR(80) NULL, KEY t (ts)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4`); // every partner call, with its reason
|
||||||
|
}
|
||||||
|
|
||||||
|
async function init(opts) { R = opts; if (R.tank && R.tank.GRACE_MS) RULES.graceMs = R.tank.GRACE_MS; await ensureTables(); }
|
||||||
|
|
||||||
|
// ---- signature ----
|
||||||
|
function sign(ts, raw, secret) { return crypto.createHmac('sha256', secret || SECRET()).update('draft.v1.' + ts + '\n' + raw).digest('hex'); }
|
||||||
|
function verify(headers, raw) {
|
||||||
|
if (!enabled()) return { status: 503, error: 'draft partner not configured' };
|
||||||
|
const ts = String(headers['x-draft-ts'] || ''), sig = String(headers['x-draft-sig'] || '');
|
||||||
|
if (!/^\d{13}$/.test(ts) || Math.abs(Date.now() - Number(ts)) > 5 * 60000) return { status: 401, error: 'stale' };
|
||||||
|
const want = sign(ts, raw);
|
||||||
|
if (want.length !== sig.length || !crypto.timingSafeEqual(Buffer.from(want), Buffer.from(sig))) return { status: 401, error: 'bad signature' };
|
||||||
|
try { const b = JSON.parse(raw || '{}'); return b && typeof b === 'object' ? { body: b } : { status: 400, error: 'bad json' }; } catch (e) { return { status: 400, error: 'bad json' }; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- helpers ----
|
||||||
|
const idOf = email => { const hi = R.hooks && R.hooks.hubInfo ? R.hooks.hubInfo(email) : null; return hi && /^h_[0-9a-f]{16}$/.test(hi.id) ? hi.id : 'i_' + crypto.createHmac('sha256', SECRET() || 'local').update('pid:' + lc(email)).digest('hex').slice(0, 16); };
|
||||||
|
const doorOf = (email, via) => { const hi = R.hooks && R.hooks.hubInfo ? R.hooks.hubInfo(email) : null; const k = lc((hi && hi.door) || via); return DOORS[k] || (k === 'hub' ? 'Network' : 'InstantAdPay'); };
|
||||||
|
function throwaway(email) {
|
||||||
|
const d = lc(email).split('@')[1] || ''; if (!d) return true;
|
||||||
|
if (THROWAWAY.has(d)) return true;
|
||||||
|
const fix = R.hooks && R.hooks.suggestDomain ? R.hooks.suggestDomain(d) : null; return !!(fix && fix !== d); // a mistyped provider: the mail bounces
|
||||||
|
}
|
||||||
|
function spamSet() { try { return new Set((R.hooks && R.hooks.spamEmails ? R.hooks.spamEmails() : []).map(lc)); } catch (e) { return new Set(); } }
|
||||||
|
const hubOff = () => R.requireHub !== false && !(R.hooks && R.hooks.networkOn && R.hooks.networkOn());
|
||||||
|
async function logCall(op, x) { const row = Object.assign({ ts: clock(), op }, x); try { await S().log(row); } catch (e) { console.error('draft log', e.message); } if (!x.ok) console.log('draft', op, 'refused', x.code || '', String(x.reason || '').slice(0, 120)); return row; }
|
||||||
|
const fail = async (op, code, reason, x) => { await logCall(op, Object.assign({ ok: false, code, reason }, x || {})); return { error: reason, code }; };
|
||||||
|
function purchasers() { const s = new Set(); for (const ev of R.chain.recentEvents(1e9)) if (ev.type === 'Purchase' && ev.buyerId) s.add(Number(ev.buyerId)); return s; }
|
||||||
|
|
||||||
|
// a coach: the wallet that holds the 5x position, then a position wallet here, then the hub's person for the hub id
|
||||||
|
async function coachAccount(c) {
|
||||||
|
const w = lc(c && c.wallet); if (!ADDR.test(w)) return { code: 'bad_coach', reason: 'Which coach? (wallet missing)' };
|
||||||
|
let a = await R.accounts.byAddress(w).catch(() => null);
|
||||||
|
if (!a && R.accounts.positionOwner) { const po = await R.accounts.positionOwner(w).catch(() => null); if (po && po.email) a = await R.accounts.byEmail(po.email); }
|
||||||
|
if (!a && c.hubId && R.hooks && R.hooks.resolvePerson) { try { const p = await R.hooks.resolvePerson({ id: String(c.hubId) }); if (p && p.email && !p.blocked) a = await R.accounts.byEmail(lc(p.email)); } catch (e) {} }
|
||||||
|
if (!a) return { code: 'coach_unknown', reason: 'This coach has no InstantAdPay account yet. Sign in on InstantAdPay once (network sign-in) and link a wallet.' };
|
||||||
|
return { account: a, wallet: w };
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- the pool ----
|
||||||
|
let poolCache = null;
|
||||||
|
async function poolRows(fresh) {
|
||||||
|
if (!fresh && poolCache && clock() - poolCache.at < 30000) return poolCache;
|
||||||
|
const list = await R.tank.waiting(); const spam = spamSet(); const ex = { spam: 0, throwaway: 0, adoptedTwice: 0 };
|
||||||
|
const local = await R.tank.summaryMap(); const mine = await S().countsByAdoptee(); const rows = [];
|
||||||
|
for (const w of list) {
|
||||||
|
if ((R.hooks.excluded && R.hooks.excluded(w.email)) || spam.has(lc(w.email))) { ex.spam++; continue; }
|
||||||
|
if (throwaway(w.email)) { ex.throwaway++; continue; }
|
||||||
|
const n = ((local.get(w.email) || {}).count || 0) + (R.tank.remoteCount ? R.tank.remoteCount(w.email) : 0);
|
||||||
|
if (n >= RULES.maxAdoptions) { ex.adoptedTwice++; continue; }
|
||||||
|
rows.push({ email: w.email, card: { id: idOf(w.email), username: w.username || null, door: doorOf(w.email, w.via), joinedAt: Number(w.joined) || 0, lastSeen: Number(w.lastSeen) || 0,
|
||||||
|
// adoptions = OUTSIDE 5xYourTeam (5xYourTeam adds its own picks; counting them here too would double them); adoptionsTotal = all
|
||||||
|
wallet: !!w.wallet, ready: !!w.ready, holdUntil: w.holdUntil || 0, opensAt: w.opensAt || 0, adoptions: Math.max(0, n - (mine.get(w.email) || 0)), adoptionsTotal: n,
|
||||||
|
games: null, surfWei: null, surfCredits: Number(w.earned) || 0 } }); // games: InstantAdPay keeps no per-member game record (never invented)
|
||||||
|
}
|
||||||
|
poolCache = { at: clock(), rows, excluded: ex }; return poolCache;
|
||||||
|
}
|
||||||
|
async function pool() {
|
||||||
|
if (hubOff()) { await logCall('pool', { ok: false, code: 'hub_off', reason: 'the network hub is off, so locked people cannot be ruled out' }); return { ok: true, rules: rulesView(), pool: [], excluded: {}, hubOff: true }; }
|
||||||
|
const p = await poolRows(false);
|
||||||
|
return { ok: true, rules: rulesView(), pool: p.rows.map(r => r.card), excluded: p.excluded };
|
||||||
|
}
|
||||||
|
const rulesView = () => ({ returnHours: RULES.returnMs / H, holdHours: RULES.holdMs / H, maxOpen: RULES.maxOpen, maxAdoptions: RULES.maxAdoptions, graceHours: (RULES.graceMs || D) / H });
|
||||||
|
|
||||||
|
// ---- adopt ----
|
||||||
|
async function adopt(b) {
|
||||||
|
const rid = String(b.rid || '').slice(0, 80); const c = b.coach || {}; const pid = String(b.person || '').slice(0, 40); const kind = /^(draft|instant)$/.test(b.kind) ? b.kind : 'draft';
|
||||||
|
const x = { coach: lc(c.wallet) || null, person: pid || null, rid };
|
||||||
|
if (!/^[A-Za-z0-9_.:-]{8,80}$/.test(rid)) return fail('adopt', 'bad_rid', 'A request id (rid) is required.', x);
|
||||||
|
const prev = await S().byRid(rid);
|
||||||
|
if (prev) return { ok: true, repeat: true, ref: 'iap:' + prev.id, person: prev.personId, adoptionId: prev.adoptionId, at: prev.ts, expires: prev.expires, holdUntil: prev.holdUntil };
|
||||||
|
if (!(Number(c.positions) >= 1)) return fail('adopt', 'not_vested', 'Only 5xYourTeam position holders can draft and coach.', x);
|
||||||
|
if (hubOff()) return fail('adopt', 'hub_off', 'The network hub is off, so nobody can be drafted right now.', x);
|
||||||
|
const co = await coachAccount(c); if (!co.account) return fail('adopt', co.code, co.reason, x);
|
||||||
|
if ((await S().openOfCoach(co.wallet)).length >= RULES.maxOpen) return fail('adopt', 'full', 'Your team is full (' + RULES.maxOpen + ' open picks). Help one get started first.', x);
|
||||||
|
const hit = (await poolRows(true)).rows.find(r => r.card.id === pid);
|
||||||
|
if (!hit) return fail('adopt', 'gone', 'That player is no longer in the holding tank.', x);
|
||||||
|
const r = await R.tank.adopt(co.account.email, hit.email, String(b.note || ''), { partner: { positions: Number(c.positions), ttlMs: RULES.returnMs, maxOpen: RULES.maxOpen }, recordNote: '5xYourTeam draft pick (' + kind + (b.week ? ', week ' + String(b.week).slice(0, 10) : '') + (b.slot ? ', slot ' + String(b.slot).slice(0, 10) : '') + ')' });
|
||||||
|
if (!r || !r.ok) return fail('adopt', (r && r.code) || 'refused', (r && r.error) || 'The tank refused.', x);
|
||||||
|
poolCache = null;
|
||||||
|
const now = clock(); const acct = await R.accounts.byEmail(hit.email);
|
||||||
|
const pick = await S().add({ rid, adoptionId: Number(r.adoption.id), adoptee: hit.email, personId: pid, coachEmail: co.account.email, coachWallet: co.wallet, coachHubId: c.hubId ? String(c.hubId).slice(0, 40) : null,
|
||||||
|
kind, week: b.week ? String(b.week).slice(0, 16) : null, slot: b.slot ? String(b.slot).slice(0, 16) : null, ts: now, expires: now + RULES.returnMs, holdUntil: now + RULES.holdMs, status: 'open', closed: 0, outcomeWhy: null,
|
||||||
|
walletAt: acct && acct.address ? now : 0, payoutsAt: 0, purchaseAt: 0 });
|
||||||
|
await logCall('adopt', Object.assign(x, { ok: true, ref: 'iap:' + pick.id, reason: kind + ' pick by ' + (c.username ? '@' + String(c.username).slice(0, 40) : x.coach) }));
|
||||||
|
return { ok: true, ref: 'iap:' + pick.id, person: pid, adoptionId: pick.adoptionId, at: pick.ts, expires: pick.expires, holdUntil: pick.holdUntil };
|
||||||
|
}
|
||||||
|
|
||||||
|
// is the pick's adoption still the open one? (released on InstantAdPay itself, moved by a LinkSpin follow, ...) -> closed here too
|
||||||
|
async function reconcile(p) {
|
||||||
|
if (p.status !== 'open') return p;
|
||||||
|
const open = await R.tank.openOf(p.adoptee);
|
||||||
|
if (open.some(ad => Number(ad.id) === p.adoptionId)) return p;
|
||||||
|
p.status = 'moved'; p.closed = clock(); p.outcomeWhy = 'the adoption was closed on InstantAdPay (released, moved or followed from LinkSpin)'; await S().put(p);
|
||||||
|
await logCall('reconcile', { ok: true, code: 'moved', reason: p.outcomeWhy, coach: p.coachWallet, person: p.personId, ref: 'iap:' + p.id });
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
// milestones seen so far (first-seen times; the chain events carry no timestamps here)
|
||||||
|
async function observe(p, a, buyers) {
|
||||||
|
if (!a) return p; const now = clock(); let ch = false;
|
||||||
|
if (a.address && !p.walletAt) { p.walletAt = now; ch = true; }
|
||||||
|
if (Number(a.memberId) > 0 && !p.payoutsAt) { p.payoutsAt = now; ch = true; }
|
||||||
|
if (Number(a.memberId) > 0 && !p.purchaseAt && buyers && buyers.has(Number(a.memberId))) { p.purchaseAt = now; ch = true; }
|
||||||
|
if (ch) await S().put(p); return p;
|
||||||
|
}
|
||||||
|
const started = (p, a) => !!(a && Number(a.memberId) > 0) || !!(p.payoutsAt || p.purchaseAt);
|
||||||
|
|
||||||
|
// close one open pick: 'coach' (released after the 48 h hold) or 'return' (3 days, not started). Shared by release() and sweep().
|
||||||
|
async function closePick(p, why, now) {
|
||||||
|
const a = await R.accounts.byEmail(p.adoptee);
|
||||||
|
await observe(p, a, purchasers());
|
||||||
|
if (started(p, a)) { p.status = 'done'; p.closed = now; p.outcomeWhy = 'started (payouts on or a purchase)'; await S().put(p); await R.tank.closeAdoption(p.adoptionId, 'done'); return { outcome: 'done', why: p.outcomeWhy }; }
|
||||||
|
if (why === 'coach' && now < p.holdUntil) return { code: 'hold', reason: 'You picked them less than ' + (RULES.holdMs / H) + ' hours ago. Give them a little time first (' + Math.ceil((p.holdUntil - now) / H) + ' h left).' };
|
||||||
|
if (why === 'return' && now < p.expires) return { code: 'too_early', reason: 'The pick window runs until ' + new Date(p.expires).toISOString() + '.' };
|
||||||
|
const count = await R.tank.countAll(p.adoptee);
|
||||||
|
if (count >= RULES.maxAdoptions) { // their second adoption: they stay with this coach (the tank sweep rule, never back to nobody)
|
||||||
|
p.status = 'kept'; p.closed = now; p.outcomeWhy = 'adopted twice: stays with this coach'; await S().put(p); await R.tank.closeAdoption(p.adoptionId, 'expired');
|
||||||
|
return { outcome: 'kept', why: p.outcomeWhy };
|
||||||
|
}
|
||||||
|
const lk = await R.tank.lockedWhy(p.adoptee);
|
||||||
|
if (lk === 'unknown') return { code: 'hub_unknown', reason: 'The network record cannot be checked right now. Try again later.' };
|
||||||
|
if (lk === 'locked') { p.status = 'kept'; p.closed = now; p.outcomeWhy = 'locked on a network contract: never moved'; await S().put(p); await R.tank.closeAdoption(p.adoptionId, 'expired'); return { outcome: 'kept', why: p.outcomeWhy }; }
|
||||||
|
const note = why === 'return' ? '5xYourTeam pick returned: not started in ' + (RULES.returnMs / D) + ' days' : '5xYourTeam pick released by the coach';
|
||||||
|
const r = await R.tank.setSponsorDeliberate(p.adoptee, '', 'release', note);
|
||||||
|
if (r && r.error) return { code: 'refused', reason: r.error };
|
||||||
|
await R.tank.closeAdoption(p.adoptionId, why === 'return' ? 'expired' : 'dropped'); // both still count toward their two adoptions
|
||||||
|
p.status = 'returned'; p.closed = now; p.outcomeWhy = note; await S().put(p); poolCache = null;
|
||||||
|
return { outcome: 'returned', why: note };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function findPick(b) {
|
||||||
|
const ref = String(b.ref || ''); const m = /^iap:(\d+)$/.exec(ref);
|
||||||
|
if (m) return S().byId(Number(m[1]));
|
||||||
|
const pid = String(b.person || ''); const w = lc(b.coach && b.coach.wallet);
|
||||||
|
const rows = (await S().ofPerson(pid)).filter(p => p.coachWallet === w); return rows.find(p => p.status === 'open') || rows[rows.length - 1] || null;
|
||||||
|
}
|
||||||
|
async function release(b) {
|
||||||
|
const why = b.why === 'return' ? 'return' : 'coach'; const w = lc(b.coach && b.coach.wallet); const rid = String(b.rid || '').slice(0, 80);
|
||||||
|
const x = { coach: w || null, person: b.person ? String(b.person).slice(0, 40) : null, rid, ref: b.ref ? String(b.ref).slice(0, 40) : null };
|
||||||
|
let p = await findPick(b);
|
||||||
|
if (!p) return fail('release', 'no_pick', 'No such pick.', x);
|
||||||
|
if (p.coachWallet !== w) return fail('release', 'not_yours', 'Not your pick.', x);
|
||||||
|
x.person = p.personId; x.ref = 'iap:' + p.id;
|
||||||
|
p = await reconcile(p);
|
||||||
|
if (p.status !== 'open') { await logCall('release', Object.assign(x, { ok: true, code: 'already', reason: why + ': already ' + p.status })); return { ok: true, already: true, outcome: p.status }; }
|
||||||
|
const r = await closePick(p, why, clock());
|
||||||
|
if (!r.outcome) return fail('release', r.code, r.reason, x);
|
||||||
|
await logCall('release', Object.assign(x, { ok: true, code: r.outcome, reason: why + ': ' + r.why }));
|
||||||
|
return { ok: true, outcome: r.outcome };
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- status: milestones for the people 5xYourTeam holds picks for (anyone else answers null) ----
|
||||||
|
async function status(b) {
|
||||||
|
const ids = [...new Set((Array.isArray(b.ids) ? b.ids : []).map(v => String(v || '').slice(0, 40)).filter(Boolean))].slice(0, 500);
|
||||||
|
const buyers = purchasers(); const out = {};
|
||||||
|
const emails = []; const picksBy = {};
|
||||||
|
for (const id of ids) { const rows = await S().ofPerson(id); if (!rows.length) { out[id] = null; continue; } picksBy[id] = rows; emails.push(rows[0].adoptee); }
|
||||||
|
const tot = R.ads && R.ads.earnedTotals ? await R.ads.earnedTotals(emails).catch(() => ({})) : {};
|
||||||
|
for (const id of Object.keys(picksBy)) {
|
||||||
|
const rows = picksBy[id]; let last = rows[rows.length - 1]; const email = last.adoptee;
|
||||||
|
const a = await R.accounts.byEmail(email); if (!a) { out[id] = null; continue; }
|
||||||
|
last = await reconcile(last); last = await observe(last, a, buyers);
|
||||||
|
const count = await R.tank.countAll(email);
|
||||||
|
out[id] = { username: a.username || null, door: doorOf(email, a.joinedVia), lastSeen: Number(a.lastSeen) || 0,
|
||||||
|
wallet: a.address ? (rows.map(r => r.walletAt).filter(Boolean).sort((x, y) => x - y)[0] || clock()) : 0,
|
||||||
|
payouts: Number(a.memberId) > 0 ? (last.payoutsAt || clock()) : 0, purchase: Number(a.memberId) > 0 && buyers.has(Number(a.memberId)) ? (last.purchaseAt || clock()) : 0,
|
||||||
|
adoptions: Math.max(0, count - rows.length), // adoptions outside 5xYourTeam (5x counts its own picks itself)
|
||||||
|
games: null, surfWei: null, surfCredits: (tot[email] || {}).earned || 0,
|
||||||
|
pick: { ref: 'iap:' + last.id, status: last.status, coachWallet: last.coachWallet, expires: last.expires, holdUntil: last.holdUntil } };
|
||||||
|
}
|
||||||
|
return { ok: true, people: out };
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- the hourly sweep (server.js, beside tank.sweep): started picks close as done, unstarted ones past 3 days go back ----
|
||||||
|
let sweeping = null;
|
||||||
|
function sweep() { if (!sweeping) sweeping = sweepRun().finally(() => { sweeping = null; }); return sweeping; }
|
||||||
|
async function sweepRun() {
|
||||||
|
const now = clock(); const out = { done: 0, returned: 0, kept: 0, moved: 0, waiting: 0 }; const buyers = purchasers();
|
||||||
|
for (let p of await S().open()) {
|
||||||
|
p = await reconcile(p); if (p.status !== 'open') { out.moved++; continue; }
|
||||||
|
const a = await R.accounts.byEmail(p.adoptee); await observe(p, a, buyers);
|
||||||
|
if (!started(p, a) && now < p.expires) continue;
|
||||||
|
const r = await closePick(p, 'return', now);
|
||||||
|
if (!r.outcome) { out.waiting++; continue; }
|
||||||
|
out[r.outcome] = (out[r.outcome] || 0) + 1;
|
||||||
|
await logCall('sweep', { ok: true, code: r.outcome, reason: r.why, coach: p.coachWallet, person: p.personId, ref: 'iap:' + p.id });
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
// tank.sweep asks this before closing an expired adoption (the pick's own rule decides)
|
||||||
|
async function isDraftPick(adoptionId) { if (!R) return false; const p = await S().byAdoption(adoptionId); return !!(p && p.status === 'open'); }
|
||||||
|
|
||||||
|
async function adminView() { return { enabled: enabled(), rules: rulesView(), hubOff: hubOff(), picks: (await S().recent(200)).map(p => Object.assign({}, p, { adoptee: undefined, coachEmail: undefined })), log: await S().logs(200) }; }
|
||||||
|
|
||||||
|
// one entry for the HTTP routes (server.js) and the cross-repo test: op = pool | adopt | release | status
|
||||||
|
async function handle(op, body) {
|
||||||
|
if (op === 'pool') return pool();
|
||||||
|
if (op === 'adopt') return adopt(body);
|
||||||
|
if (op === 'release') return release(body);
|
||||||
|
if (op === 'status') return status(body);
|
||||||
|
return { error: 'unknown op', code: 'unknown_op' };
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { init, enabled, verify, sign, handle, pool, adopt, release, status, sweep, isDraftPick, adminView, RULES, _poolReset: () => { poolCache = null; } };
|
||||||
+55
@@ -0,0 +1,55 @@
|
|||||||
|
// Earners Corner forum sign-in (Marty 2026-11-10): earnerscorner.com runs Discourse with DiscourseConnect, and InstantAdPay is the
|
||||||
|
// identity provider, so every forum name is a real InstantAdPay account (no separate forum sign-ups to farm). Discourse sends
|
||||||
|
// /forum/sso?sso=<base64 payload>&sig=<hex HMAC-SHA256>; we check the signature, make sure the visitor is signed in here, and send
|
||||||
|
// back a signed payload with the member's email, username and groups. Secret: env FORUM_SSO_SECRET (the same value is set in
|
||||||
|
// Discourse as discourse_connect_secret). Groups: network_members (paying member: an on-chain position) and wallet_linked; in
|
||||||
|
// Discourse those groups grant the trust level that may post links, so link spam needs a real member behind it.
|
||||||
|
'use strict';
|
||||||
|
const crypto = require('crypto');
|
||||||
|
|
||||||
|
const SECRET = () => String(process.env.FORUM_SSO_SECRET || '').trim();
|
||||||
|
const FORUM_URL = () => String(process.env.FORUM_URL || 'https://earnerscorner.com').replace(/\/+$/, '');
|
||||||
|
const sign = s => crypto.createHmac('sha256', SECRET()).update(s).digest('hex');
|
||||||
|
|
||||||
|
// -> { nonce, returnUrl } or { error }
|
||||||
|
function verify(sso, sig) {
|
||||||
|
if (SECRET().length < 32) return { error: 'The forum sign-in is not connected yet.' };
|
||||||
|
sso = String(sso || ''); sig = String(sig || '').toLowerCase();
|
||||||
|
if (!sso || !/^[0-9a-f]{64}$/.test(sig)) return { error: 'That forum sign-in link is incomplete.' };
|
||||||
|
const want = Buffer.from(sign(sso), 'hex'), got = Buffer.from(sig, 'hex');
|
||||||
|
if (want.length !== got.length || !crypto.timingSafeEqual(want, got)) return { error: 'That forum sign-in link is not valid.' };
|
||||||
|
const q = new URLSearchParams(Buffer.from(sso, 'base64').toString('utf8'));
|
||||||
|
const nonce = q.get('nonce'), returnUrl = q.get('return_sso_url') || '';
|
||||||
|
if (!nonce) return { error: 'That forum sign-in link is incomplete.' };
|
||||||
|
if (!returnUrl.startsWith(FORUM_URL() + '/')) return { error: 'That forum sign-in link points somewhere else.' };
|
||||||
|
return { nonce, returnUrl };
|
||||||
|
}
|
||||||
|
|
||||||
|
// the signed redirect back to the forum for this account
|
||||||
|
function redirectFor(v, acct, site) {
|
||||||
|
const email = String(acct.email || '').toLowerCase();
|
||||||
|
const groups = [];
|
||||||
|
if (Number(acct.memberId) > 0) groups.push('network_members');
|
||||||
|
if (acct.address) groups.push('wallet_linked');
|
||||||
|
const p = new URLSearchParams({ nonce: v.nonce, email, external_id: email, require_activation: 'false', suppress_welcome_message: 'false' });
|
||||||
|
if (acct.username) { p.set('username', acct.username); p.set('name', acct.username); }
|
||||||
|
if (acct.avatarUrl) p.set('avatar_url', /^https?:/.test(acct.avatarUrl) ? acct.avatarUrl : site + acct.avatarUrl);
|
||||||
|
// no website on sign-in (Marty 2026-11-14): Discourse holds a new user who "entered profile information without reading" for
|
||||||
|
// approval, and the stackpol.com link we filled in put every new member in the review queue. Members add their own.
|
||||||
|
if (groups.length) p.set('add_groups', groups.join(','));
|
||||||
|
const remove = ['network_members', 'wallet_linked'].filter(g => !groups.includes(g)); if (remove.length) p.set('remove_groups', remove.join(','));
|
||||||
|
const out = Buffer.from(p.toString()).toString('base64');
|
||||||
|
return v.returnUrl + (v.returnUrl.includes('?') ? '&' : '?') + 'sso=' + encodeURIComponent(out) + '&sig=' + sign(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
// server-to-server: the forum's reward service asks "is this email an activated member, and where are payouts sent?" The request is
|
||||||
|
// signed with the same shared secret: header x-forum-sig = hex HMAC-SHA256 of "<email>.<unix seconds>", x-forum-ts = those seconds,
|
||||||
|
// valid for 5 minutes.
|
||||||
|
function verifyServer(email, ts, sig) {
|
||||||
|
if (SECRET().length < 32) return false;
|
||||||
|
const t = Number(ts); if (!(t > 0) || Math.abs(Date.now() / 1000 - t) > 300) return false;
|
||||||
|
const want = Buffer.from(sign(String(email || '').toLowerCase() + '.' + t), 'hex'), got = Buffer.from(String(sig || ''), 'hex');
|
||||||
|
return want.length === got.length && crypto.timingSafeEqual(want, got);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { verify, verifyServer, redirectFor, sign, SECRET, FORUM_URL };
|
||||||
+225
-19
@@ -52,11 +52,11 @@ const TIER_DEFS = [
|
|||||||
{ key: 'explorer', name: 'Explorer', set: 'Explorer', price: 2000, days: 30,
|
{ key: 'explorer', name: 'Explorer', set: 'Explorer', price: 2000, days: 30,
|
||||||
perks: ['Everything in the Game Pass, in every game', 'Shards of Valor: weapons and gear unlocked', 'Shards of Valor: 2 bonus islands'] },
|
perks: ['Everything in the Game Pass, in every game', 'Shards of Valor: weapons and gear unlocked', 'Shards of Valor: 2 bonus islands'] },
|
||||||
{ key: 'champion', name: 'Champion', set: 'Champion', price: 5000, days: 30,
|
{ key: 'champion', name: 'Champion', set: 'Champion', price: 5000, days: 30,
|
||||||
perks: ['Everything in Explorer', 'Shards of Valor: 4 bonus islands of your choice', 'Shards of Valor: the Druid hero', 'Shards of Valor: level cap 30'] },
|
perks: ['Everything in Explorer', 'Shards of Valor: 4 bonus islands of your choice', 'Shards of Valor: level cap 30'] }, // 2026-11-05: the Druid moved to the one-time bonus heroes
|
||||||
{ key: 'sovereign', name: 'Sovereign', set: 'Sovereign', price: 10000, days: 30,
|
{ key: 'sovereign', name: 'Sovereign', set: 'Sovereign', price: 10000, days: 30,
|
||||||
perks: ['Everything in Champion', 'Shards of Valor: every bonus island', 'Shards of Valor: the Necromancer hero', 'Shards of Valor: level cap 40'] },
|
perks: ['Everything in Champion', 'Shards of Valor: every bonus island', 'Shards of Valor: level cap 40'] }, // 2026-11-05: the Necromancer was dropped
|
||||||
{ key: 'legend', name: 'Legend', set: 'Legend', price: 25000, days: 365,
|
{ key: 'legend', name: 'Legend', set: 'Legend', price: 25000, days: 365,
|
||||||
perks: ['Everything in Sovereign, for a full year', 'Shards of Valor: every bonus island', 'Shards of Valor: every hero, the Archer included, and every new hero as it ships', 'Shards of Valor: level cap 40'] }, // new heroes as a Legend perk: Marty 2026-10-30 (Dallas's $100/year idea folded in here)
|
perks: ['Everything in Sovereign, for a full year', 'Shards of Valor: every bonus island', 'Shards of Valor: every bonus hero while Legend is active (Kestrel, Valda, Morag, Roland), and every new hero as it ships', 'Shards of Valor: level cap 40'] }, // new heroes as a Legend perk: Marty 2026-10-30 (Dallas's $100/year idea folded in here)
|
||||||
];
|
];
|
||||||
const TIERS = TIER_DEFS.map(d => d.key); // lowest to highest
|
const TIERS = TIER_DEFS.map(d => d.key); // lowest to highest
|
||||||
const TIER_NAMES = Object.fromEntries(TIER_DEFS.map(d => [d.key, d.name]));
|
const TIER_NAMES = Object.fromEntries(TIER_DEFS.map(d => [d.key, d.name]));
|
||||||
@@ -64,9 +64,30 @@ const TIER_DEF = Object.fromEntries(TIER_DEFS.map(d => [d.key, d]));
|
|||||||
const tierOk = t => TIERS.includes(t);
|
const tierOk = t => TIERS.includes(t);
|
||||||
const rowTier = b => (b && tierOk(b.tier)) ? b.tier : 'weekly'; // bought rows before 2026-10-18 have no tier: weekly
|
const rowTier = b => (b && tierOk(b.tier)) ? b.tier : 'weekly'; // bought rows before 2026-10-18 have no tier: weekly
|
||||||
const r6 = x => Math.round((Number(x) || 0) * 1e6) / 1e6;
|
const r6 = x => Math.round((Number(x) || 0) * 1e6) / 1e6;
|
||||||
|
// Bonus heroes for Shards of Valor (Marty approved 2026-11-05, Dallas's request): SOLD ONE TIME, no subscription, owned for good. Paid
|
||||||
|
// exactly like a pass: no credits, no direct POL; buying opens a waiting order, fulfilled by a FRESH package of at least the price
|
||||||
|
// bought by one of the member's own positions, so the sponsor line is paid as usual (onEvent). $20 each = the Activation package; the
|
||||||
|
// $50 bundle (the Builder package) is a settings list, default Valda + Morag + Roland (Dallas 13:26; Marty approved a $50 bundle of
|
||||||
|
// three). Settings (Admin > Settings, no deploy): heroSales (sale switch, default OFF), heroPrice<Set>Cents per hero (0 = free for
|
||||||
|
// every account, granted like a base hero), heroBundlePriceCents, heroBundleHeroes, heroBundleCap (a level the bundle would raise the
|
||||||
|
// cap to; UNSET = no cap change, Marty has not approved one). key = the wire value Shards of Valor reads (classes.json paid buy).
|
||||||
|
// 2026-11-14 (Marty approved, "Yes make it free"; Dallas: "The Archer should be free to everyone at level 20"): Kestrel is FREE for every
|
||||||
|
// player once a hero in their party reaches level 20 (the game decides, Shards of Valor classes.json freeAt) and is NOT SOLD here any more
|
||||||
|
// (freeAt): no buy, not in any bundle, waiting Kestrel orders are cancelled unpaid. A member who bought her keeps her (record.heroes.kestrel);
|
||||||
|
// nothing refunded. Valda, Morag and Roland, the $50 bundle and every price are unchanged.
|
||||||
|
const HERO_DEFS = [
|
||||||
|
{ key: 'kestrel', set: 'Kestrel', name: 'Kestrel the Archer', price: 2000, freeAt: 20, blurb: 'Quick and sharp-eyed: arrows on every foe.' },
|
||||||
|
{ key: 'valda', set: 'Valda', name: 'Valda the Barbarian', price: 2000, blurb: 'A berserker: hits harder the more she is hurt, light on armour.' },
|
||||||
|
{ key: 'morag', set: 'Morag', name: 'Morag the Druid', price: 2000, blurb: 'A healer of the wild: heals the whole party.' },
|
||||||
|
{ key: 'roland', set: 'Roland', name: 'Roland the Paladin', price: 2000, blurb: 'A holy knight: sword and shield, heals one hero at a time.' },
|
||||||
|
];
|
||||||
|
const HERO_KEYS = HERO_DEFS.map(d => d.key);
|
||||||
|
const HERO_DEF = Object.fromEntries(HERO_DEFS.map(d => [d.key, d]));
|
||||||
|
const HERO_SOLD = HERO_DEFS.filter(d => !d.freeAt).map(d => d.key); // free at a level in the game (Kestrel at 20): never sold, never in a bundle
|
||||||
|
const HERO_BUNDLE_DEFAULT = 'valda,morag,roland';
|
||||||
|
|
||||||
let R = null; // deps from server.js
|
let R = null; // deps from server.js
|
||||||
let passes, orders, prizes; // durable persisted maps (server.js open-tokens store, DURABLE set)
|
let passes, orders, prizes, stackpro; // stackpro: Stack POL Pro owners, email -> { ts, tx, cents, order } (2026-11-09). durable persisted maps (server.js open-tokens store, DURABLE set)
|
||||||
let L = null; // the cap ledger: { members: { email: { days: {}, deferred: {}, weeks: {} } }, refs: { 'game:ref': {...} } }
|
let L = null; // the cap ledger: { members: { email: { days: {}, deferred: {}, weeks: {} } }, refs: { 'game:ref': {...} } }
|
||||||
let saveTimer = null;
|
let saveTimer = null;
|
||||||
|
|
||||||
@@ -101,11 +122,23 @@ function cfg() {
|
|||||||
sale: on('gamePassEnabled') && on('sovTiers') && !offExplicit('gamePass' + d.set + 'Enabled') }])),
|
sale: on('gamePassEnabled') && on('sovTiers') && !offExplicit('gamePass' + d.set + 'Enabled') }])),
|
||||||
tournamentTierSales: on('passTournamentTierSales'), // off: only weekly pass sales feed the Pass Tournament pool (exactly as before tiers)
|
tournamentTierSales: on('passTournamentTierSales'), // off: only weekly pass sales feed the Pass Tournament pool (exactly as before tiers)
|
||||||
free: { daily: Math.max(0, n('capFreeDaily', 0.30)), total: Math.max(0, n('capFreeTotal', 2.0)) },
|
free: { daily: Math.max(0, n('capFreeDaily', 0.30)), total: Math.max(0, n('capFreeTotal', 2.0)) },
|
||||||
|
// the free allowance (Marty 2026-11-02, "cap these so that if the user wants to keep playing they spend a tiny amount"):
|
||||||
|
// the most game POL an account EVER receives while it holds no pass, across every game. After that, progress rewards
|
||||||
|
// wait as deferred until a pass is active and repeatable rewards are dropped. 2 POL default; admin key capFreeLifetime.
|
||||||
|
freeLifetime: Math.max(0, n('capFreeLifetime', 2.0)),
|
||||||
pass: { daily: Math.max(0, n('capPassDaily', 1.50)), total: Math.max(0, n('capPassTotal', 5.0)) },
|
pass: { daily: Math.max(0, n('capPassDaily', 1.50)), total: Math.max(0, n('capPassTotal', 5.0)) },
|
||||||
start: /^\d{4}-\d{2}-\d{2}$/.test(start) ? start : '',
|
start: /^\d{4}-\d{2}-\d{2}$/.test(start) ? start : '',
|
||||||
pct: Math.max(0, n('passTournamentPct', 5)),
|
pct: Math.max(0, n('passTournamentPct', 5)),
|
||||||
gamesChat: String(sc.telegramGamesChatId || sc.telegramEchoChatId || '').trim(),
|
gamesChat: String(sc.telegramGamesChatId || sc.telegramEchoChatId || '').trim(),
|
||||||
gamesTopic: String(sc.telegramGamesTopicId || '').trim(),
|
gamesTopic: String(sc.telegramGamesTopicId || '').trim(),
|
||||||
|
heroes: (() => {
|
||||||
|
const price = Object.fromEntries(HERO_DEFS.map(d => [d.key, Math.max(0, Math.round(n('heroPrice' + d.set + 'Cents', d.price)))]));
|
||||||
|
const raw = sc.heroBundleHeroes == null || String(sc.heroBundleHeroes).trim() === '' ? HERO_BUNDLE_DEFAULT : String(sc.heroBundleHeroes);
|
||||||
|
const list = [...new Set(raw.split(',').map(x => x.trim().toLowerCase()).filter(k => HERO_SOLD.includes(k) && price[k] > 0))];
|
||||||
|
const capRaw = String(sc.heroBundleCap == null ? '' : sc.heroBundleCap).trim(), cap = capRaw === '' ? NaN : Number(capRaw);
|
||||||
|
return { sale: on('heroSales'), price, free: HERO_KEYS.filter(k => price[k] === 0), bundle: { heroes: list.length >= 2 ? list : [], price: Math.max(1, Math.round(n('heroBundlePriceCents', 5000))) },
|
||||||
|
cap: Number.isInteger(cap) && cap > 0 ? cap : null };
|
||||||
|
})(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const enforcedOn = (c, day) => !!(c.start && day >= c.start);
|
const enforcedOn = (c, day) => !!(c.start && day >= c.start);
|
||||||
@@ -127,6 +160,7 @@ function init(deps) {
|
|||||||
passes = R.persistedMap('gamepass');
|
passes = R.persistedMap('gamepass');
|
||||||
orders = R.persistedMap('gporders');
|
orders = R.persistedMap('gporders');
|
||||||
prizes = R.persistedMap('gpprizes');
|
prizes = R.persistedMap('gpprizes');
|
||||||
|
stackpro = R.persistedMap('stackpro');
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +197,7 @@ function extend(e, via, extra, now, tier) {
|
|||||||
passes.set(e, writeTiers(cur, T, { bought, ts: t }));
|
passes.set(e, writeTiers(cur, T, { bought, ts: t }));
|
||||||
return { until, days: tc.days, tier };
|
return { until, days: tc.days, tier };
|
||||||
}
|
}
|
||||||
function waitingOrders(e) { const out = []; for (const [k, o] of orders) if (o.status === 'waiting' && o.email === e) out.push(Object.assign({ order: k }, o, { tier: tierOk(o.tier) ? o.tier : 'weekly' })); return out; }
|
function waitingOrders(e) { const out = []; for (const [k, o] of orders) if (o.status === 'waiting' && o.email === e && o.kind !== 'hero' && o.kind !== 'stackpro') out.push(Object.assign({ order: k }, o, { tier: tierOk(o.tier) ? o.tier : 'weekly' })); return out; }
|
||||||
function waitingOrder(e, tier) { return waitingOrders(e).find(o => o.tier === (tier || 'weekly')) || null; }
|
function waitingOrder(e, tier) { return waitingOrders(e).find(o => o.tier === (tier || 'weekly')) || null; }
|
||||||
// the admin's tier test: drop a waiting order that was opened for testing, so a later real package never fulfils it by surprise
|
// the admin's tier test: drop a waiting order that was opened for testing, so a later real package never fulfils it by surprise
|
||||||
function cancelOrder(email, tier) {
|
function cancelOrder(email, tier) {
|
||||||
@@ -206,7 +240,8 @@ function view(email, now, opts) {
|
|||||||
waiting: !!w, waitingSince: w ? w.ts : null, bought: p ? (p.bought || []).length : 0,
|
waiting: !!w, waitingSince: w ? w.ts : null, bought: p ? (p.bought || []).length : 0,
|
||||||
caps, capsStart: c.start || null, lastCapHit: p && p.lastCapHit && (t - p.lastCapHit.ts) < 2 * 86400000 ? p.lastCapHit : null,
|
caps, capsStart: c.start || null, lastCapHit: p && p.lastCapHit && (t - p.lastCapHit.ts) < 2 * 86400000 ? p.lastCapHit : null,
|
||||||
tournament: { pct: c.pct, shares: SHARES, next: nextTournamentAt(t) },
|
tournament: { pct: c.pct, shares: SHARES, next: nextTournamentAt(t) },
|
||||||
show: c.enabled || tiered, passes: passRows, tierPreview: tiered && admin && !c.tierSales };
|
show: c.enabled || tiered, passes: passRows, tierPreview: tiered && admin && !c.tierSales,
|
||||||
|
heroes: heroView(e, t, opts) }; // bonus heroes (2026-11-05): sold one time, shown while heroSales is on, to an owner, or in the admin test
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST /api/my/gamepass/buy { tier }. tier missing = weekly (exactly the pass as it was before tiers). opts.preview = the admin
|
// POST /api/my/gamepass/buy { tier }. tier missing = weekly (exactly the pass as it was before tiers). opts.preview = the admin
|
||||||
@@ -230,6 +265,47 @@ function buy(email, now, tier, opts) {
|
|||||||
message: (tier === 'weekly' ? 'Your Game Pass' : 'Your ' + name + ' pass') + ' starts the moment your next package of $' + pkg + ' or more settles on chain. Your sponsor and team are paid from it as usual, and you keep every credit of the package for your ads.' };
|
message: (tier === 'weekly' ? 'Your Game Pass' : 'Your ' + name + ' pass') + ' starts the moment your next package of $' + pkg + ' or more settles on chain. Your sponsor and team are paid from it as usual, and you keep every credit of the package for your ads.' };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stack POL Pro (Marty 2026-11-09): a one-time unlock for the member's stackpol.com page (their LinkSpin Banner Spins and spin links
|
||||||
|
// on the page, the shareable stack card). Like a pass or a hero it is NEW MONEY only: "Get Pro" opens a waiting order, and the next
|
||||||
|
// package purchase of $10 or more by one of the member's own positions fulfils it (onEvent). Never credits, never direct POL; the
|
||||||
|
// member keeps every credit of the package and the sponsor line is paid on chain as usual. Owned for good once paid.
|
||||||
|
const STACK_PRO_CENTS = 1000;
|
||||||
|
function stackOrders(e) { const out = []; for (const [k, o] of orders) if (o.status === 'waiting' && o.email === e && o.kind === 'stackpro') out.push(Object.assign({ order: k }, o)); return out; }
|
||||||
|
function stackPro(email) { const e = String(email || '').toLowerCase(); return stackpro.get(e) || null; }
|
||||||
|
function stackProView(email) { const e = String(email || '').toLowerCase(); const own = stackpro.get(e) || null; const w = stackOrders(e)[0] || null; return { pro: !!own, since: own ? own.ts : null, waiting: !!w, order: w ? w.order : null, usd: STACK_PRO_CENTS / 100 }; }
|
||||||
|
function buyStackPro(email, now) {
|
||||||
|
const e = String(email || '').toLowerCase(); const t = now || Date.now();
|
||||||
|
if (stackpro.get(e)) return { ok: true, pro: true };
|
||||||
|
let w = stackOrders(e)[0]; const reused = !!w;
|
||||||
|
if (!w) { const k = 'sp-' + t.toString(36) + '-' + Math.random().toString(36).slice(2, 8); orders.set(k, { status: 'waiting', email: e, ts: t, kind: 'stackpro' }); w = Object.assign({ order: k }, orders.get(k)); console.log('stack pro order opened', e, k); }
|
||||||
|
return { ok: false, needPay: true, payUrl: '/my?from=stackpro#buy', order: w.order, orderTs: w.ts, reused, usd: STACK_PRO_CENTS / 100, package: packageFor(STACK_PRO_CENTS / 100),
|
||||||
|
message: 'Stack POL Pro switches on the moment your next package of $10 or more settles on chain. Your sponsor and team are paid from it as usual, and you keep every credit of the package for your ads.' };
|
||||||
|
}
|
||||||
|
function cancelStackOrder(email) { const e = String(email || '').toLowerCase(); const w = stackOrders(e)[0]; if (!w) return { ok: true }; orders.set(w.order, Object.assign({}, orders.get(w.order), { status: 'cancelled', cancelledAt: Date.now() })); return { ok: true, order: w.order }; }
|
||||||
|
function compStackPro(email, on, note) { const e = String(email || '').toLowerCase(); if (on) stackpro.set(e, { ts: Date.now(), via: 'comp', note: String(note || '').slice(0, 120) }); else stackpro.delete(e); return { ok: true, pro: !!on }; }
|
||||||
|
// a package bought WITHOUT a Pro order first, granted by the admin (Marty 2026-11-09, Orlando's $10 package): recorded as a
|
||||||
|
// package sale with its tx so it counts as new money, and the tx is marked used like any fulfilment
|
||||||
|
function grantStackProForPackage(email, tx, cents, buyerId, note) {
|
||||||
|
const e = String(email || '').toLowerCase(); if (!e) return { error: 'No account.' };
|
||||||
|
if (stackpro.get(e)) return { ok: true, already: true };
|
||||||
|
stackpro.set(e, { ts: Date.now(), via: 'package', tx, cents, buyerId, note: String(note || 'admin grant: package bought without a Pro order').slice(0, 120) });
|
||||||
|
console.log('stack pro granted for package', e, tx, cents, 'cents');
|
||||||
|
return { ok: true, pro: true };
|
||||||
|
}
|
||||||
|
// Marty 2026-11-09 (evening): "Any $10 package or higher unlocks it". No Get Pro step: the member's own package purchase of $10 or more,
|
||||||
|
// on chain, switches Pro on for good. Still new money only (credits never reach onEvent). Only packages from the Pro launch on count
|
||||||
|
// (a reindex of older history never hands it out). A Pro order left waiting from the first version is closed as paid by the same tx.
|
||||||
|
const PRO_START = Date.parse('2026-11-09T21:30:00Z');
|
||||||
|
function proFromPackage(e, ev, cents) {
|
||||||
|
if (cents < STACK_PRO_CENTS || stackpro.get(e)) return false;
|
||||||
|
const t = (ev.devNow && !R.isProd) ? Number(ev.devNow) : (ev.ts || Date.now()); if (t < PRO_START) return false;
|
||||||
|
stackpro.set(e, { ts: t, via: 'package', tx: ev.tx, cents, buyerId: Number(ev.buyerId) || 0 });
|
||||||
|
for (const o of stackOrders(e)) orders.set(o.order, Object.assign({}, orders.get(o.order), { status: 'paid', tx: ev.tx, cents, paidAt: Date.now(), buyerId: Number(ev.buyerId) || 0 }));
|
||||||
|
console.log('stack pro unlocked by package', e, 'tx', String(ev.tx).slice(0, 12), cents, 'cents');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
function stackProOwners() { return [...stackpro.keys()]; }
|
||||||
|
|
||||||
// A package purchase landing on chain fulfils one of this account's waiting orders: the highest-priced one the package covers.
|
// A package purchase landing on chain fulfils one of this account's waiting orders: the highest-priced one the package covers.
|
||||||
// Rules (2026-10-22): the buyer must be one of this account's own positions (main member id or a linked position); the purchase must
|
// Rules (2026-10-22): the buyer must be one of this account's own positions (main member id or a linked position); the purchase must
|
||||||
// be mined AFTER the order was opened (block time, ORDER_SKEW_MS for clock drift); one pass per purchase of $5 or more; each tx used
|
// be mined AFTER the order was opened (block time, ORDER_SKEW_MS for clock drift); one pass per purchase of $5 or more; each tx used
|
||||||
@@ -259,18 +335,130 @@ async function minedAt(ev) { // block time in ms; the indexed-at time only when
|
|||||||
async function onEvent(ev) {
|
async function onEvent(ev) {
|
||||||
if (!ev || ev.type !== 'Purchase' || (ev.priceCents || 0) < 500) return null;
|
if (!ev || ev.type !== 'Purchase' || (ev.priceCents || 0) < 500) return null;
|
||||||
const c = cfg(); const cents = ev.priceCents || 0;
|
const c = cfg(); const cents = ev.priceCents || 0;
|
||||||
if (!TIERS.some(k => cents >= c.tiers[k].price)) return null;
|
if (!TIERS.some(k => cents >= c.tiers[k].price) && !heroOrderPrices(c).some(x => cents >= x) && cents < STACK_PRO_CENTS) return null;
|
||||||
const e = await ownerOf(ev); if (!e) return null;
|
const e = await ownerOf(ev); if (!e) return null;
|
||||||
if (!waitingOrders(e).length) return null;
|
const pro = proFromPackage(e, ev, cents); // any $10+ package unlocks Stack POL Pro; it rides along, never takes the package from an order
|
||||||
if (txUsed(ev.tx)) return null; // each purchase counts once, everywhere
|
const withPro = r => pro ? Object.assign(r || {}, { stackPro: true, email: e }) : r;
|
||||||
|
if (!waitingOrders(e).length && !heroOrders(e).length) return withPro(null);
|
||||||
|
if (txUsed(ev.tx)) return withPro(null); // each purchase counts once, everywhere
|
||||||
const at = await minedAt(ev);
|
const at = await minedAt(ev);
|
||||||
const w = waitingOrders(e).filter(o => cents >= c.tiers[o.tier].price && at + ORDER_SKEW_MS >= o.ts)
|
// one package fulfils ONE order, pass or bonus hero (2026-11-05): the highest-priced one it covers, then the oldest
|
||||||
.sort((x, y) => c.tiers[y.tier].price - c.tiers[x.tier].price || x.ts - y.ts)[0];
|
const all = waitingOrders(e).map(o => Object.assign({ price: c.tiers[o.tier].price }, o)).concat(heroOrders(e).filter(o => heroOrderOpen(e, o.hero)).map(o => Object.assign({ price: heroOrderPrice(c, o.hero) }, o))).concat(stackpro.get(e) ? [] : stackOrders(e).map(o => Object.assign({ price: STACK_PRO_CENTS }, o)));
|
||||||
if (!w) { console.log('gamepass: package', String(ev.tx).slice(0, 12), 'by', e, 'fulfils no order (bought before the order or too small)'); return null; }
|
const w = all.filter(o => cents >= o.price && at + ORDER_SKEW_MS >= o.ts).sort((x, y) => y.price - x.price || x.ts - y.ts)[0];
|
||||||
|
if (!w) { console.log('gamepass: package', String(ev.tx).slice(0, 12), 'by', e, 'fulfils no order (bought before the order or too small)'); return withPro(null); }
|
||||||
|
if (w.kind === 'stackpro') {
|
||||||
|
orders.set(w.order, Object.assign({}, orders.get(w.order), { status: 'paid', tx: ev.tx, cents, paidAt: Date.now(), minedAt: at, buyerId: Number(ev.buyerId) || 0 }));
|
||||||
|
stackpro.set(e, { ts: (ev.devNow && !R.isProd) ? Number(ev.devNow) : (ev.ts || Date.now()), via: 'package', tx: ev.tx, cents, order: w.order, buyerId: Number(ev.buyerId) || 0 });
|
||||||
|
console.log('stack pro fulfilled by package', e, 'tx', String(ev.tx).slice(0, 12), cents, 'cents');
|
||||||
|
return { order: w.order, stackPro: true, email: e };
|
||||||
|
}
|
||||||
|
if (w.kind === 'hero') {
|
||||||
|
orders.set(w.order, Object.assign({}, orders.get(w.order), { status: 'paid', tx: ev.tx, cents, paidAt: Date.now(), minedAt: at, buyerId: Number(ev.buyerId) || 0 }));
|
||||||
|
const g = grantHeroes(e, w.hero, 'package', { tx: ev.tx, cents, order: w.order, buyerId: Number(ev.buyerId) || 0, usd: heroOrderPrice(c, w.hero) / 100, packageUsd: cents / 100 }, (ev.devNow && !R.isProd) ? Number(ev.devNow) : (ev.ts || Date.now()));
|
||||||
|
console.log('bonus heroes fulfilled by package', w.hero, e, 'tx', String(ev.tx).slice(0, 12), cents, 'cents:', g.heroes.join(','));
|
||||||
|
return withPro({ order: w.order, hero: w.hero, heroes: g.heroes });
|
||||||
|
}
|
||||||
orders.set(w.order, Object.assign({}, orders.get(w.order), { status: 'paid', tx: ev.tx, cents, paidAt: Date.now(), minedAt: at, buyerId: Number(ev.buyerId) || 0 }));
|
orders.set(w.order, Object.assign({}, orders.get(w.order), { status: 'paid', tx: ev.tx, cents, paidAt: Date.now(), minedAt: at, buyerId: Number(ev.buyerId) || 0 }));
|
||||||
const x = extend(e, 'package', { tx: ev.tx, cents, order: w.order, buyerId: Number(ev.buyerId) || 0, usd: c.tiers[w.tier].price / 100, packageUsd: cents / 100 }, (ev.devNow && !R.isProd) ? Number(ev.devNow) : (ev.ts || Date.now()), w.tier);
|
const x = extend(e, 'package', { tx: ev.tx, cents, order: w.order, buyerId: Number(ev.buyerId) || 0, usd: c.tiers[w.tier].price / 100, packageUsd: cents / 100 }, (ev.devNow && !R.isProd) ? Number(ev.devNow) : (ev.ts || Date.now()), w.tier);
|
||||||
console.log('gamepass fulfilled by package', w.tier, e, 'tx', String(ev.tx).slice(0, 12), cents, 'cents, until', new Date(x.until).toISOString());
|
console.log('gamepass fulfilled by package', w.tier, e, 'tx', String(ev.tx).slice(0, 12), cents, 'cents, until', new Date(x.until).toISOString());
|
||||||
return { order: w.order, until: x.until, tier: w.tier };
|
return withPro({ order: w.order, until: x.until, tier: w.tier });
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- bonus heroes (2026-11-05) ----
|
||||||
|
// owned for good: record.heroes = { kestrel: { ts, via, tx, order, cents, usd, bundle? } }, record.heroBundle = { ts, via, heroes, tx, order }
|
||||||
|
// (in the passes map, the same durable record as the passes). A hero is never in `bought`, so hero sales never feed the Pass Tournament pool.
|
||||||
|
function heroOrders(e) {
|
||||||
|
const out = [];
|
||||||
|
for (const [k, o] of orders) if (o.status === 'waiting' && o.email === e && o.kind === 'hero') {
|
||||||
|
if (HERO_DEF[o.hero] && HERO_DEF[o.hero].freeAt) { orders.set(k, Object.assign({}, o, { status: 'cancelled', cancelledAt: Date.now(), why: 'free at level ' + HERO_DEF[o.hero].freeAt + ' in the game' })); continue; } // never paid: she is free now
|
||||||
|
out.push(Object.assign({ order: k }, o));
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
function heroOrder(e, key) { return heroOrders(e).find(o => o.hero === key) || null; }
|
||||||
|
const heroOrderPrice = (c, key) => key === 'bundle' ? c.heroes.bundle.price : (c.heroes.price[key] || 0);
|
||||||
|
const heroOrderPrices = c => [c.heroes.bundle.price].concat(HERO_SOLD.map(k => c.heroes.price[k]).filter(x => x > 0));
|
||||||
|
// a waiting hero order still worth fulfilling: nothing in it is owned yet (a bundle also needs its list set)
|
||||||
|
function heroOrderOpen(e, key) { const c = cfg(), own = new Set(heroesOwned(e).owned); if (key === 'bundle') return c.heroes.bundle.heroes.length > 0 && !c.heroes.bundle.heroes.some(k => own.has(k)); return HERO_SOLD.includes(key) && !own.has(key); }
|
||||||
|
// -> { owned: bought, comped and free heroes; bought: on the record; bundle: bought as the bundle }
|
||||||
|
function heroesOwned(email) {
|
||||||
|
const p = rec(String(email || '').toLowerCase()), c = cfg(), H = (p && p.heroes) || {};
|
||||||
|
return { owned: HERO_KEYS.filter(k => H[k] || c.heroes.free.includes(k)), bought: HERO_KEYS.filter(k => H[k]), bundle: !!(p && p.heroBundle) };
|
||||||
|
}
|
||||||
|
// the hand-off claim for Shards of Valor (server.js sovMint): what this member owns, and the current sale (the game keeps it, so a free
|
||||||
|
// hero opens for guests too)
|
||||||
|
function heroClaim(email) {
|
||||||
|
const c = cfg(), h = heroesOwned(email), out = { heroes: h.owned, heroBundle: h.bundle, heroSale: { free: c.heroes.free, bundle: c.heroes.bundle.heroes, each: (c.heroes.price.valda || 2000) / 100, bundlePrice: c.heroes.bundle.price / 100 } };
|
||||||
|
if (h.bundle && c.heroes.cap) out.heroBundleCap = c.heroes.cap; // only once Marty sets heroBundleCap (unset today: heroes only)
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
function grantHeroes(e, key, via, extra, now) {
|
||||||
|
const t = now || Date.now(), c = cfg(), cur = passes.get(e) || { until: 0, bought: [] }, H = Object.assign({}, cur.heroes || {});
|
||||||
|
const list = key === 'bundle' ? c.heroes.bundle.heroes.slice() : [key], got = [];
|
||||||
|
for (const k of list) if (!H[k]) { H[k] = Object.assign({ ts: t, via }, extra || {}, key === 'bundle' ? { bundle: true } : {}); got.push(k); }
|
||||||
|
const upd = { heroes: H }; if (key === 'bundle') upd.heroBundle = Object.assign({ ts: t, via, heroes: list }, extra || {});
|
||||||
|
passes.set(e, Object.assign({}, cur, upd));
|
||||||
|
// never a second charge for a hero you have: drop waiting orders that are now owned (in full or in part)
|
||||||
|
for (const o of heroOrders(e)) if (!heroOrderOpen(e, o.hero)) orders.set(o.order, Object.assign({}, orders.get(o.order), { status: 'cancelled', cancelledAt: t, why: 'already owned' }));
|
||||||
|
return { heroes: got, owned: heroesOwned(e).owned };
|
||||||
|
}
|
||||||
|
// the member card part: every hero, its price and state, and the bundle. open = on sale (heroSales) or the admin portal's test (opts.preview)
|
||||||
|
function heroView(email, now, opts) {
|
||||||
|
const e = String(email || '').toLowerCase(), c = cfg(), h = heroesOwned(e), own = new Set(h.owned), preview = !!(opts && opts.preview), open = c.heroes.sale || preview;
|
||||||
|
const items = HERO_DEFS.map(d => { const price = c.heroes.price[d.key], fa = d.freeAt || null; return { key: d.key, name: d.name, blurb: d.blurb, price, usd: price / 100, package: packageFor(price / 100), free: price === 0, freeAt: fa, owned: own.has(d.key), waiting: !fa && !!heroOrder(e, d.key), open: !fa && open && price > 0 && !own.has(d.key) }; });
|
||||||
|
const B = c.heroes.bundle, bOwn = B.heroes.filter(k => own.has(k));
|
||||||
|
const bundle = B.heroes.length ? { key: 'bundle', names: B.heroes.map(k => HERO_DEF[k].name), heroes: B.heroes, price: B.price, usd: B.price / 100, package: packageFor(B.price / 100), owned: bOwn.length === B.heroes.length, some: bOwn.length > 0, waiting: !!heroOrder(e, 'bundle'), open: open && !bOwn.length } : null;
|
||||||
|
return { sale: c.heroes.sale, preview: preview && !c.heroes.sale, show: c.heroes.sale || preview || h.bought.length > 0, items, bundle, owned: h.owned, bundleOwned: h.bundle };
|
||||||
|
}
|
||||||
|
// POST /api/my/heroes/buy { hero: kestrel | valda | morag | roland | bundle }: opens (or reuses) a waiting order; a fresh package of at
|
||||||
|
// least the price fulfils it (onEvent). Never spends credits. Refuses a hero already owned, a free one, and a bundle when any of its
|
||||||
|
// heroes is already owned (the rest one at a time costs less).
|
||||||
|
function buyHero(email, now, key, opts) {
|
||||||
|
const e = String(email || '').toLowerCase(), c = cfg(), t = now || Date.now(); key = String(key || '').toLowerCase();
|
||||||
|
if (key !== 'bundle' && !HERO_KEYS.includes(key)) return { error: 'There is no such hero.' };
|
||||||
|
if (!(c.heroes.sale || (opts && opts.preview))) return { error: 'Bonus heroes are not on sale yet.' };
|
||||||
|
const own = new Set(heroesOwned(e).owned);
|
||||||
|
if (key === 'bundle') {
|
||||||
|
const B = c.heroes.bundle; if (!B.heroes.length) return { error: 'There is no hero bundle right now.' };
|
||||||
|
const have = B.heroes.filter(k => own.has(k)); if (have.length) return { error: 'You already have ' + have.map(k => HERO_DEF[k].name).join(' and ') + ', so the bundle is not for you: get the others one at a time.' };
|
||||||
|
} else {
|
||||||
|
if (HERO_DEF[key].freeAt) return { error: HERO_DEF[key].name + ' is free for every player at level ' + HERO_DEF[key].freeAt + ' in Shards of Valor, so she is not for sale.' };
|
||||||
|
if (c.heroes.price[key] === 0) return { error: HERO_DEF[key].name + ' is free for everyone.' };
|
||||||
|
if (own.has(key)) return { error: 'You already have ' + HERO_DEF[key].name + '. Heroes are yours for good.' };
|
||||||
|
}
|
||||||
|
let w = heroOrder(e, key); const reused = !!w;
|
||||||
|
if (!w) { const k = 'hero-' + t.toString(36) + '-' + Math.random().toString(36).slice(2, 8); orders.set(k, { status: 'waiting', kind: 'hero', hero: key, email: e, ts: t }); w = Object.assign({ order: k }, orders.get(k)); }
|
||||||
|
const price = heroOrderPrice(c, key), pkg = packageFor(price / 100);
|
||||||
|
const name = key === 'bundle' ? 'The hero bundle (' + c.heroes.bundle.heroes.map(k => HERO_DEF[k].name).join(', ') + ')' : HERO_DEF[key].name;
|
||||||
|
if (!reused) console.log('bonus hero order opened', key, e, w.order, 'needs a package of', price, 'cents');
|
||||||
|
return { ok: false, needPay: true, hero: key, payUrl: '/my?from=heroes&hero=' + key + '#buy', order: w.order, orderTs: w.ts, reused, price, usd: price / 100, package: pkg,
|
||||||
|
message: name + ' joins you in Shards of Valor the moment your next package of $' + pkg + ' or more settles on chain. One time, yours for good. Your sponsor and team are paid from it as usual, and you keep every credit of the package for your ads.' };
|
||||||
|
}
|
||||||
|
function cancelHeroOrder(email, key) {
|
||||||
|
const e = String(email || '').toLowerCase(), w = heroOrder(e, String(key || '').toLowerCase()); if (!w) return { ok: true, none: true };
|
||||||
|
orders.set(w.order, Object.assign({}, orders.get(w.order), { status: 'cancelled', cancelledAt: Date.now() })); return { ok: true, order: w.order, hero: w.hero };
|
||||||
|
}
|
||||||
|
function compHero(email, key, why) { // support or the admin test: counts as no sale
|
||||||
|
const e = String(email || '').toLowerCase(); key = String(key || '').toLowerCase(); if (key !== 'bundle' && !HERO_KEYS.includes(key)) return { error: 'There is no such hero.' };
|
||||||
|
return Object.assign({ ok: true }, grantHeroes(e, key, 'admin', { note: String(why || 'support').slice(0, 80), usd: 0 }));
|
||||||
|
}
|
||||||
|
function revokeHero(email, key, why) { // support only (an admin test, a mistaken comp); never automatic
|
||||||
|
const e = String(email || '').toLowerCase(); key = String(key || '').toLowerCase(); const p = passes.get(e); const H = Object.assign({}, (p && p.heroes) || {});
|
||||||
|
const keys = key === 'all' ? Object.keys(H) : [key]; if (!p || !keys.some(k => H[k])) return { error: 'This account does not own that hero.' };
|
||||||
|
const gone = []; for (const k of keys) if (H[k]) { gone.push(Object.assign({}, H[k], { hero: k, revokedAt: Date.now(), why: String(why || 'support').slice(0, 80) })); delete H[k]; }
|
||||||
|
const upd = { heroes: H, heroRevokes: gone.concat(p.heroRevokes || []).slice(0, 50) };
|
||||||
|
if (p.heroBundle && !(p.heroBundle.heroes || []).every(k => H[k])) upd.heroBundle = null;
|
||||||
|
passes.set(e, Object.assign({}, p, upd)); return { ok: true, revoked: gone.map(g => g.hero) };
|
||||||
|
}
|
||||||
|
function heroStats() {
|
||||||
|
const c = cfg(); const out = { sale: c.heroes.sale, sold: Object.fromEntries(HERO_KEYS.map(k => [k, 0])), bundles: 0, comped: 0, usd: 0, waiting: 0 };
|
||||||
|
for (const [, p] of passes) {
|
||||||
|
if (!p) continue;
|
||||||
|
for (const [k, h] of Object.entries(p.heroes || {})) { if (!(k in out.sold)) continue; if (h.via === 'admin') { out.comped += 1; continue; } out.sold[k] += 1; if (!h.bundle) out.usd += Number(h.usd) || 0; }
|
||||||
|
if (p.heroBundle && p.heroBundle.via !== 'admin') { out.bundles += 1; out.usd += Number(p.heroBundle.usd) || 0; }
|
||||||
|
}
|
||||||
|
for (const [, o] of orders) if (o.status === 'waiting' && o.kind === 'hero' && !(HERO_DEF[o.hero] && HERO_DEF[o.hero].freeAt)) out.waiting += 1;
|
||||||
|
out.usd = Math.round(out.usd * 100) / 100; return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- the caps ----
|
// ---- the caps ----
|
||||||
@@ -279,10 +467,19 @@ function capsFor(email, now, game) {
|
|||||||
const lim = pass ? c.pass : c.free; const M = L.members[e]; const D = M && M.days[day];
|
const lim = pass ? c.pass : c.free; const M = L.members[e]; const D = M && M.days[day];
|
||||||
const used = { daily: r6(D ? D.daily : 0), total: r6(D ? D.total : 0) };
|
const used = { daily: r6(D ? D.daily : 0), total: r6(D ? D.total : 0) };
|
||||||
const out = { daily: lim.daily, total: lim.total, used, day, enforced: enforcedOn(c, day), pass };
|
const out = { daily: lim.daily, total: lim.total, used, day, enforced: enforcedOn(c, day), pass };
|
||||||
|
out.lifetime = { cap: c.freeLifetime, used: r6(M && M.freeTotal != null ? M.freeTotal : (M ? Object.values(M.days).reduce((n, d) => n + ((d.tier && d.tier.free && d.tier.free.allowed) || 0), 0) : 0)) }; // the free allowance, what has been used of it
|
||||||
if (game && M) out.pending = r6((M.deferred[game] || []).reduce((n, x) => n + x.left, 0));
|
if (game && M) out.pending = r6((M.deferred[game] || []).reduce((n, x) => n + x.left, 0));
|
||||||
|
out.lifetime.done = !pass && out.lifetime.used + 1e-9 >= out.lifetime.cap; // the free allowance is used up (only a pass pays from here)
|
||||||
|
out.lifetime.waiting = M ? r6(Object.values(M.deferred).reduce((n, q) => n + (q || []).reduce((m, x) => m + (x.left || 0), 0), 0)) : 0;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// quest-site check (Zealy, 2026-11-05): has this account earned any game reward, and how much in total
|
||||||
|
function activity(email) {
|
||||||
|
const M = L.members[String(email || '').toLowerCase()]; if (!M) return { grants: 0, pol: 0 };
|
||||||
|
return Object.values(M.days).reduce((o, d) => ({ grants: o.grants + (d.grants || 0), pol: r6(o.pol + (d.total || 0)) }), { grants: 0, pol: 0 });
|
||||||
|
}
|
||||||
|
|
||||||
// POST /api/partner/polgrant. Returns { allowed, deferred, pass, day } (+ carried, capHit, enforced, repeat).
|
// POST /api/partner/polgrant. Returns { allowed, deferred, pass, day } (+ carried, capHit, enforced, repeat).
|
||||||
function grant(o) {
|
function grant(o) {
|
||||||
const e = String(o.email || '').toLowerCase(); const game = String(o.game || '').toLowerCase(); const kind = o.kind === 'progress' ? 'progress' : 'daily';
|
const e = String(o.email || '').toLowerCase(); const game = String(o.game || '').toLowerCase(); const kind = o.kind === 'progress' ? 'progress' : 'daily';
|
||||||
@@ -294,6 +491,11 @@ function grant(o) {
|
|||||||
const c = cfg(); const pass = flag(e, t).active; const lim = pass ? c.pass : c.free; const enforced = enforcedOn(c, day);
|
const c = cfg(); const pass = flag(e, t).active; const lim = pass ? c.pass : c.free; const enforced = enforcedOn(c, day);
|
||||||
const M = member(e); const D = dayRow(M, day); const tier = D.tier[pass ? 'pass' : 'free'];
|
const M = member(e); const D = dayRow(M, day); const tier = D.tier[pass ? 'pass' : 'free'];
|
||||||
let totalRem = Math.max(0, r6(lim.total - D.total)), dailyRem = Math.max(0, r6(lim.daily - D.daily));
|
let totalRem = Math.max(0, r6(lim.total - D.total)), dailyRem = Math.max(0, r6(lim.daily - D.daily));
|
||||||
|
// the free allowance: a running total of what this account received while it held no pass (seeded once from the day rows
|
||||||
|
// still on file); once it reaches freeLifetime, a free account's room for today is zero, carry included
|
||||||
|
if (M.freeTotal == null) M.freeTotal = r6(Object.values(M.days).reduce((n, d) => n + ((d.tier && d.tier.free && d.tier.free.allowed) || 0), 0));
|
||||||
|
let lifetimeHit = false;
|
||||||
|
if (!pass && enforced) { const room = Math.max(0, r6(c.freeLifetime - M.freeTotal)); if (room < totalRem) totalRem = room; lifetimeHit = room < pol; } // hit = the allowance, not the day, is what trims this grant
|
||||||
// carry-forward: progress POL deferred on an EARLIER day for this game is paid first, inside today's total cap
|
// carry-forward: progress POL deferred on an EARLIER day for this game is paid first, inside today's total cap
|
||||||
let carried = 0; const q = M.deferred[game] || [];
|
let carried = 0; const q = M.deferred[game] || [];
|
||||||
for (const d of q) {
|
for (const d of q) {
|
||||||
@@ -319,12 +521,16 @@ function grant(o) {
|
|||||||
}
|
}
|
||||||
if (kind === 'daily') D.daily = r6(D.daily + allowed);
|
if (kind === 'daily') D.daily = r6(D.daily + allowed);
|
||||||
D.total = r6(D.total + allowed); tier.allowed = r6(tier.allowed + allowed); D.grants += 1;
|
D.total = r6(D.total + allowed); tier.allowed = r6(tier.allowed + allowed); D.grants += 1;
|
||||||
|
if (!pass) M.freeTotal = r6((M.freeTotal || 0) + allowed + carried); // counts toward the free allowance only while no pass is held
|
||||||
// tournament activity: one point per reported grant (progress and daily weigh the same)
|
// tournament activity: one point per reported grant (progress and daily weigh the same)
|
||||||
if (pol > 0) { const wk = weekKey(t); M.weeks[wk] = M.weeks[wk] || {}; M.weeks[wk][game] = (M.weeks[wk][game] || 0) + 1; }
|
if (pol > 0) { const wk = weekKey(t); M.weeks[wk] = M.weeks[wk] || {}; M.weeks[wk][game] = (M.weeks[wk][game] || 0) + 1; }
|
||||||
if (capHit) { const p = passes.get(e) || { until: 0, bought: [] }; passes.set(e, Object.assign({}, p, { lastCapHit: { ts: t, day, game, kind: capHit, pass } })); }
|
if (capHit) { const p = passes.get(e) || { until: 0, bought: [] }; passes.set(e, Object.assign({}, p, { lastCapHit: { ts: t, day, game, kind: capHit, pass, lifetime: !!lifetimeHit } })); }
|
||||||
const out = { allowed: r6(carried + allowed), deferred, pass, day, carried, capHit, enforced, kind, pol, email: e, ts: t, own: allowed };
|
const out = { allowed: r6(carried + allowed), deferred, pass, day, carried, capHit, enforced, kind, pol, email: e, ts: t, own: allowed, lifetimeHit };
|
||||||
L.refs[key] = out; touch();
|
L.refs[key] = out; touch();
|
||||||
return { allowed: out.allowed, deferred, pass, day, carried, capHit, enforced, repeat: false };
|
// waiting = every game's progress POL deferred for this account (it pays once a pass is active, inside the pass cap); the games
|
||||||
|
// show it in the allowance note (Marty 2026-11-03: tell members at the cap to get the Pass, and what is waiting for them)
|
||||||
|
const waiting = r6(Object.values(M.deferred).reduce((n, q) => n + (q || []).reduce((m, x) => m + (x.left || 0), 0), 0));
|
||||||
|
return { allowed: out.allowed, deferred, pass, day, carried, capHit, enforced, repeat: false, lifetimeHit, freeUsed: r6(M.freeTotal || 0), freeLifetime: c.freeLifetime, waiting };
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST /api/partner/polgrant/void: the game decided not to pay after all. Reverses this ref's own share (the carry it triggered
|
// POST /api/partner/polgrant/void: the game decided not to pay after all. Reverses this ref's own share (the carry it triggered
|
||||||
@@ -426,7 +632,7 @@ function tierStats(t) {
|
|||||||
if (b.ts >= d30 && rows.some(x => x !== b && rowTier(x) === k && x.ts < b.ts)) o.renewals30d += 1;
|
if (b.ts >= d30 && rows.some(x => x !== b && rowTier(x) === k && x.ts < b.ts)) o.renewals30d += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const [, o] of orders) if (o.status === 'waiting') out[tierOk(o.tier) ? o.tier : 'weekly'].waitingOrders += 1;
|
for (const [, o] of orders) if (o.status === 'waiting' && o.kind !== 'hero' && o.kind !== 'stackpro') out[tierOk(o.tier) ? o.tier : 'weekly'].waitingOrders += 1;
|
||||||
for (const k of TIERS) for (const f of ['usdWeek', 'usdMonth', 'usdTotal']) out[k][f] = Math.round(out[k][f] * 100) / 100;
|
for (const k of TIERS) for (const f of ['usdWeek', 'usdMonth', 'usdTotal']) out[k][f] = Math.round(out[k][f] * 100) / 100;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@@ -457,7 +663,7 @@ function adminStats(now) {
|
|||||||
const t = now || Date.now(); const c = cfg(); const ws = weekStart(t); const day = dayKey(t); const wkFrom = dayKey(ws);
|
const t = now || Date.now(); const c = cfg(); const ws = weekStart(t); const day = dayKey(t); const wkFrom = dayKey(ws);
|
||||||
let active = 0, soldTotal = 0, usdTotal = 0, soldWeek = 0, usdWeek = 0, waiting = 0, comped = 0;
|
let active = 0, soldTotal = 0, usdTotal = 0, soldWeek = 0, usdWeek = 0, waiting = 0, comped = 0;
|
||||||
for (const [, p] of passes) { if (!p) continue; if (topTier(tiersOf(p), t)) active += 1; for (const b of p.bought || []) { if (!isSale(b)) { comped += 1; continue; } soldTotal += 1; usdTotal += Number(b.usd) || 0; if (b.ts >= ws) { soldWeek += 1; usdWeek += Number(b.usd) || 0; } } }
|
for (const [, p] of passes) { if (!p) continue; if (topTier(tiersOf(p), t)) active += 1; for (const b of p.bought || []) { if (!isSale(b)) { comped += 1; continue; } soldTotal += 1; usdTotal += Number(b.usd) || 0; if (b.ts >= ws) { soldWeek += 1; usdWeek += Number(b.usd) || 0; } } }
|
||||||
for (const [, o] of orders) if (o.status === 'waiting') waiting += 1;
|
for (const [, o] of orders) if (o.status === 'waiting' && o.kind !== 'hero' && o.kind !== 'stackpro') waiting += 1;
|
||||||
const wk = { pass: { allowed: 0, hitsDaily: 0, hitsTotal: 0 }, free: { allowed: 0, hitsDaily: 0, hitsTotal: 0 }, carried: 0, dropped: 0, deferredOut: 0, grants: 0, would: { dropped: 0, deferred: 0, hitsDaily: 0, hitsTotal: 0 }, players: 0 };
|
const wk = { pass: { allowed: 0, hitsDaily: 0, hitsTotal: 0 }, free: { allowed: 0, hitsDaily: 0, hitsTotal: 0 }, carried: 0, dropped: 0, deferredOut: 0, grants: 0, would: { dropped: 0, deferred: 0, hitsDaily: 0, hitsTotal: 0 }, players: 0 };
|
||||||
const today = { allowed: 0, grants: 0, players: 0 };
|
const today = { allowed: 0, grants: 0, players: 0 };
|
||||||
let qEntries = 0, qPol = 0, qMembers = 0; const byGame = {};
|
let qEntries = 0, qPol = 0, qMembers = 0; const byGame = {};
|
||||||
@@ -502,5 +708,5 @@ function prune(now) {
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { init, cfg, GAMES, NAMES, TIERS, TIER_NAMES, TIER_DEFS, flag, view, buy, cancelOrder, comp, revoke, onEvent, capsFor, grant, voidGrant, tournamentTick, runTournament, pending, markPaid, adminStats, prune, weekStart, dayKey,
|
module.exports = { STACK_PRO_CENTS, stackPro, stackProView, buyStackPro, cancelStackOrder, compStackPro, stackProOwners, grantStackProForPackage, init, cfg, GAMES, NAMES, TIERS, TIER_NAMES, TIER_DEFS, HERO_DEFS, HERO_KEYS, heroesOwned, heroClaim, heroView, buyHero, cancelHeroOrder, compHero, revokeHero, heroStats, flag, activity, view, buy, cancelOrder, comp, revoke, onEvent, capsFor, grant, voidGrant, tournamentTick, runTournament, pending, markPaid, adminStats, prune, weekStart, dayKey,
|
||||||
_ledger: () => L };
|
_ledger: () => L };
|
||||||
|
|||||||
+362
@@ -0,0 +1,362 @@
|
|||||||
|
// Network hub sync (2026-11-12, Marty 2026-11-06: one membership from any door; the hub is the single identity).
|
||||||
|
// Everything here sleeps unless HUB_ENABLED is on: server.js does not even init this module without it, so no file is
|
||||||
|
// written, no route answers and no hook is wired. The InstantAdPay <-> LinkSpin direct sync (lssync.js / lsinbound.js)
|
||||||
|
// keeps running exactly as before either way.
|
||||||
|
//
|
||||||
|
// Inbound (POST /api/hub/events, signed by the hub with HUB_SECRET: X-Hub-Ts + X-Hub-Sig = hex HMAC-SHA256(ts + newline +
|
||||||
|
// raw body), 5-minute window). The hub only moves its cursor after a 2xx and may send an event twice:
|
||||||
|
// member.joined someone joined at another door: /v1/resolve the person (and, climbing, any sponsor not here yet) and
|
||||||
|
// hand the rows to lsinbound.receive, the same waiting-account path LinkSpin-first members take, with
|
||||||
|
// joinedVia 'hub' and joinedRef 'hub:<door>'. First-platform rule as there: an account that already
|
||||||
|
// exists here keeps its sponsor and only gets empty fields filled. Joins from this site are skipped.
|
||||||
|
// wallet.connected filled only on a waiting account that still has no wallet (lsinbound fill rules). A claimed account
|
||||||
|
// links its own wallet here; the hub's wallet is not proof of ownership on InstantAdPay.
|
||||||
|
// sponsor.changed ignored on purpose (2026-11-14): lsinbound's follow rule needs sponsorSetAt / By / PrevEmail, which the
|
||||||
|
// hub view does not expose, and someone the InstantAdPay contract holds never moves anyway.
|
||||||
|
// Rule 2 (2026-11-14): the sponsor written for an arrival is person.locks.iap's sponsor when that lock exists, never the
|
||||||
|
// plain network sponsor. QUIET: nothing on this path sends mail, a notice or a post, and lssync.js never
|
||||||
|
// pushes a hub waiting account to LinkSpin (qa/hubsync.test.cjs, mail audit).
|
||||||
|
// anything else ignored.
|
||||||
|
// Each seq is applied once (done map). A failing event answers 503 so the hub retries it; after 5 tries it is set aside
|
||||||
|
// in the log so one bad row cannot hold every later event back.
|
||||||
|
//
|
||||||
|
// Outbound (/v1/join, /v1/wallet, signed as HUB_SITE): new accounts made here since the flag first went on and every main
|
||||||
|
// wallet linked here go into a persisted outbox (DATA_DIR/hubsync.json) and are sent in order, never in the way of a
|
||||||
|
// sign-up. Retried with backoff on 5xx / network / 404-before-join; a 400/409 refusal is final and logged.
|
||||||
|
// Gaps closed 2026-11-13 (Marty: "let's get the gaps report built"), all still one way:
|
||||||
|
// - any later change to a member's username or sponsor goes to /v1/join again (names them; a sponsor only lands where the
|
||||||
|
// hub has none), old members included, not only accounts made since the flag went on;
|
||||||
|
// - a DELIBERATE sponsor change (sponsorfollow: adopt, rescue, release, expire->expiry, admin) goes to /v1/sponsor-change;
|
||||||
|
// - every MemberActivated on the InstantAdPay contract goes to /v1/contract-bind (contract 'iap', the sponsor by wallet),
|
||||||
|
// by email when the wallet belongs to an account here, else by wallet alone.
|
||||||
|
// - every paid Purchase goes to /v1/contract-spend (2026-11-14, rule 2: the contract with money spent decides the network
|
||||||
|
// sponsor when two contracts hold different ones).
|
||||||
|
// Where the hub and InstantAdPay name different sponsors, nothing is forced on either side: the case goes to `disagree`
|
||||||
|
// (Admin > /api/admin/hub) for Marty, since an InstantAdPay member bound on our contract cannot move anyway.
|
||||||
|
'use strict';
|
||||||
|
const crypto = require('crypto');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
let R = null, st = null, chain_ = Promise.resolve(), timer = null, sending = false, interval = null;
|
||||||
|
const MAX_UP = 25, EVENT_TRIES = 5, OUT_TRIES = 20, KEEP_DONE = 5000;
|
||||||
|
const SHELL_ORIGINS = new Set(['linkspin', 'btc4hits', 'hub']);
|
||||||
|
const DELIBERATE = new Set(['adopt', 'rescue', 'release', 'expire', 'expiry', 'admin']); // sponsorfollow.js kinds the hub accepts // came here from another site: that site tells the hub itself
|
||||||
|
const enabled = () => /^(1|true|yes|on)$/i.test(String(process.env.HUB_ENABLED || '').trim());
|
||||||
|
const URL_ = () => String(process.env.HUB_URL || '').trim().replace(/\/+$/, '');
|
||||||
|
const SECRET = () => String(process.env.HUB_SECRET || '').trim();
|
||||||
|
const SITE = () => String(process.env.HUB_SITE || 'iap').trim().toLowerCase();
|
||||||
|
const on = () => enabled() && !!URL_() && SECRET().length >= 32;
|
||||||
|
const norm = v => String(v || '').trim().toLowerCase();
|
||||||
|
const FILE = () => path.join(R.dataDir, 'hubsync.json');
|
||||||
|
function load() {
|
||||||
|
if (st) return st;
|
||||||
|
try { st = JSON.parse(fs.readFileSync(FILE(), 'utf8')); } catch (e) { st = null; }
|
||||||
|
if (!st || typeof st !== 'object') st = {};
|
||||||
|
st.since = Number(st.since) || Date.now(); // only accounts made after the flag first went on are reported as joins
|
||||||
|
st.done = st.done || {}; st.tries = st.tries || {}; st.outbox = st.outbox || []; st.reported = st.reported || {};
|
||||||
|
st.disagree = st.disagree || {}; st.log = st.log || [];
|
||||||
|
st.stats = Object.assign({ batches: 0, events: 0, applied: 0, skipped: 0, ignored: 0, gaveUp: 0, sent: 0, refused: 0, sendErrors: 0 }, st.stats || {});
|
||||||
|
return st;
|
||||||
|
}
|
||||||
|
function save() { try { const tmp = FILE() + '.tmp'; fs.writeFileSync(tmp, JSON.stringify(load())); fs.renameSync(tmp, FILE()); } catch (e) { console.error('hubsync save', e.message); } }
|
||||||
|
function note(ev) { const s = load(); s.log.push(Object.assign({ ts: Date.now() }, ev)); if (s.log.length > 300) s.log = s.log.slice(-300); }
|
||||||
|
// deps: { dataDir, accounts, lsinbound }
|
||||||
|
function init(deps) { R = deps; load(); save(); }
|
||||||
|
|
||||||
|
const sign = (ts, raw) => crypto.createHmac('sha256', SECRET()).update(String(ts) + '\n' + raw).digest('hex');
|
||||||
|
function verify(headers, raw) {
|
||||||
|
if (SECRET().length < 32) return false;
|
||||||
|
const ts = String(headers['x-hub-ts'] || ''), sig = String(headers['x-hub-sig'] || '');
|
||||||
|
if (!/^\d{10,16}$/.test(ts) || Math.abs(Date.now() - Number(ts)) > 5 * 60000) return false;
|
||||||
|
const want = sign(ts, raw);
|
||||||
|
return want.length === sig.length && crypto.timingSafeEqual(Buffer.from(want), Buffer.from(sig));
|
||||||
|
}
|
||||||
|
async function hubPost(p, body, timeout) {
|
||||||
|
const raw = JSON.stringify(body); const ts = String(Date.now());
|
||||||
|
const r = await fetch(URL_() + p, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Hub-Site': SITE(), 'X-Hub-Ts': ts, 'X-Hub-Sig': sign(ts, raw) }, body: raw, signal: AbortSignal.timeout(timeout || 15000) });
|
||||||
|
let j = null; try { j = await r.json(); } catch (e) {}
|
||||||
|
return { status: r.status, body: j };
|
||||||
|
}
|
||||||
|
async function resolve(q) {
|
||||||
|
const r = await hubPost('/v1/resolve', q);
|
||||||
|
if (r.status !== 200) throw new Error('hub resolve ' + r.status);
|
||||||
|
return (r.body && r.body.person) || null;
|
||||||
|
}
|
||||||
|
const doorOf = p => norm(p && p.firstDoor && p.firstDoor.site).replace(/[^a-z0-9_-]/g, '').slice(0, 30) || 'network';
|
||||||
|
// Rule 2 (Marty 2026-11-14): the sponsor written here is the one the InstantAdPay CONTRACT holds for them when it holds them
|
||||||
|
// (person.locks.iap), never the plain network sponsor, which may come from another contract where they spent money
|
||||||
|
const CONTRACT = 'iap';
|
||||||
|
const sponsorFor = p => { const l = p && p.locks && p.locks[CONTRACT]; if (l) return (l.sponsor && l.sponsor.email) || null; return (p && p.sponsor && p.sponsor.email) || null; };
|
||||||
|
const rowOf = p => ({ email: norm(p.email), username: p.username || null, wallet: p.wallet || null, sponsorEmail: sponsorFor(p), joinedAt: Number(p.firstDoor && p.firstDoor.at) || null, profile: null });
|
||||||
|
|
||||||
|
// what InstantAdPay and the hub each say the sponsor is; a difference is recorded, never forced
|
||||||
|
async function compare(email, hubSponsorEmail, how) {
|
||||||
|
const sp = await R.accounts.sponsorOf(email); const here = sp ? norm(sp.email) : null; const there = norm(hubSponsorEmail) || null;
|
||||||
|
const s = load();
|
||||||
|
if (here === there) { delete s.disagree[email]; return; }
|
||||||
|
s.disagree[email] = { at: Date.now(), iap: here, hub: there, how };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function memberJoined(ev) {
|
||||||
|
if (norm(ev.data && ev.data.site) === SITE()) return 'own';
|
||||||
|
const first = await resolve({ id: ev.personId });
|
||||||
|
if (!first || !first.email) return first ? 'no-email' : 'unknown'; // the hub must give this site seeEmails
|
||||||
|
if (first.blocked) return 'blocked';
|
||||||
|
const email = norm(first.email); const A = R.accounts;
|
||||||
|
const existing = await A.byEmail(email);
|
||||||
|
const rows = [rowOf(first)]; const doors = { [email]: doorOf(first) }; const seen = new Set([email]);
|
||||||
|
if (existing && !A.isUnclaimedShell(existing)) rows[0].wallet = null; // a real account links its own wallet here
|
||||||
|
// sponsors not on InstantAdPay yet come along as waiting accounts too (lsinbound builds them from rows in the same batch)
|
||||||
|
let p = first;
|
||||||
|
for (let i = 0; i < MAX_UP && sponsorFor(p); i++) {
|
||||||
|
const se = norm(sponsorFor(p)); if (seen.has(se) || await A.byEmail(se)) break;
|
||||||
|
const up = await resolve({ email: se }); if (!up || !up.email || up.blocked) break;
|
||||||
|
seen.add(se); rows.push(rowOf(up)); doors[se] = doorOf(up); p = up;
|
||||||
|
}
|
||||||
|
const sum = await R.lsinbound.receive(rows, { via: 'hub', refOf: e => 'hub:' + (doors[e] || 'network') });
|
||||||
|
if (sum && sum.errors) throw new Error('lsinbound errors ' + sum.errors);
|
||||||
|
await compare(email, rows[0].sponsorEmail, 'hub-join');
|
||||||
|
note({ type: 'joined', email, door: doors[email], created: sum ? sum.created : 0, existed: !!existing });
|
||||||
|
return 'applied';
|
||||||
|
}
|
||||||
|
async function walletConnected(ev) {
|
||||||
|
const p = await resolve({ id: ev.personId });
|
||||||
|
if (!p || !p.email || !p.wallet || p.blocked) return 'skip';
|
||||||
|
const a = await R.accounts.byEmail(p.email);
|
||||||
|
if (!a) return 'not-here'; // member.joined makes the account; a wallet alone does not
|
||||||
|
if (!R.accounts.isUnclaimedShell(a) || a.address) return 'kept'; // claimed accounts link their own wallet here
|
||||||
|
const sum = await R.lsinbound.receive([rowOf(p)], { via: 'hub', refOf: () => 'hub:' + doorOf(p) });
|
||||||
|
if (sum && sum.errors) throw new Error('lsinbound errors ' + sum.errors);
|
||||||
|
return 'applied';
|
||||||
|
}
|
||||||
|
async function apply(ev) {
|
||||||
|
if (ev.type === 'member.joined') return memberJoined(ev);
|
||||||
|
if (ev.type === 'wallet.connected') return walletConnected(ev);
|
||||||
|
// sponsor.changed is IGNORED here on purpose (checked 2026-11-14 for the switch-on): it would need the deliberate-change
|
||||||
|
// record (at / by / previous sponsor) to go through sponsorfollow's rule, and a member locked on the InstantAdPay contract
|
||||||
|
// must never move anyway (the contract pays whoever it holds). qa/hubsync.test.cjs proves a locked member stays put.
|
||||||
|
return 'ignored';
|
||||||
|
}
|
||||||
|
function prune() {
|
||||||
|
const s = load(); const seqs = Object.keys(s.done).map(Number).sort((a, b) => a - b);
|
||||||
|
for (const q of seqs.slice(0, Math.max(0, seqs.length - KEEP_DONE))) delete s.done[q];
|
||||||
|
}
|
||||||
|
async function handle(events) {
|
||||||
|
const s = load(); s.stats.batches++; let failed = null;
|
||||||
|
for (const ev of Array.isArray(events) ? events : []) {
|
||||||
|
const seq = Number(ev && ev.seq); if (!seq) continue;
|
||||||
|
if (s.done[seq]) { s.stats.skipped++; continue; } // delivered twice: already applied
|
||||||
|
s.stats.events++;
|
||||||
|
try {
|
||||||
|
const r = await apply(ev);
|
||||||
|
s.done[seq] = Date.now(); delete s.tries[seq];
|
||||||
|
if (r === 'applied') s.stats.applied++; else s.stats.ignored++;
|
||||||
|
} catch (e) {
|
||||||
|
s.tries[seq] = (s.tries[seq] || 0) + 1;
|
||||||
|
console.error('hubsync event', seq, ev.type, e.message);
|
||||||
|
if (s.tries[seq] >= EVENT_TRIES) { s.done[seq] = Date.now(); delete s.tries[seq]; s.stats.gaveUp++; note({ type: 'gave-up', seq, event: ev.type, error: String(e.message).slice(0, 160) }); continue; }
|
||||||
|
failed = e; break; // answer 503: the hub sends this one (and everything after it) again
|
||||||
|
}
|
||||||
|
}
|
||||||
|
prune(); save();
|
||||||
|
return failed ? { status: 503, body: { error: 'retry' } } : { status: 200, body: { ok: true } };
|
||||||
|
}
|
||||||
|
// the POST /api/hub/events handler: { status, body }. Batches run one at a time.
|
||||||
|
function receive(headers, raw) {
|
||||||
|
if (!R || !enabled()) return Promise.resolve({ status: 404, body: { error: 'not found' } });
|
||||||
|
if (!verify(headers, raw)) return Promise.resolve({ status: 401, body: { error: 'unauthorized' } });
|
||||||
|
let b; try { b = JSON.parse(raw || '{}'); } catch (e) { return Promise.resolve({ status: 400, body: { error: 'bad json' } }); }
|
||||||
|
const run = chain_.then(() => handle(b.events)); chain_ = run.catch(() => {}); return run;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- outbound ----------
|
||||||
|
function enqueue(kind, email) {
|
||||||
|
const s = load(); if (s.outbox.length >= 20000) { s.stats.sendErrors++; return; }
|
||||||
|
s.outbox.push({ kind, email, at: Date.now(), tries: 0, next: 0 }); save(); kick();
|
||||||
|
}
|
||||||
|
function kick() { if (!timer) timer = setTimeout(() => { timer = null; flush().catch(e => console.error('hubsync flush', e.message)); }, 2000); }
|
||||||
|
// accounts.onChange: a new account made here, or a later username / sponsor change on any account, goes to /v1/join;
|
||||||
|
// a deliberate sponsor change also goes to /v1/sponsor-change
|
||||||
|
function touch(email) {
|
||||||
|
if (!R || !on() || !email) return;
|
||||||
|
(async () => {
|
||||||
|
const e = norm(email); const a = await R.accounts.byEmail(e); const s = load();
|
||||||
|
if (!a || SHELL_ORIGINS.has(a.joinedVia)) return;
|
||||||
|
const sp = await R.accounts.sponsorOf(e); const spE = sp ? norm(sp.email) : '';
|
||||||
|
const key = (a.username || '') + '|' + spE;
|
||||||
|
const rep = s.reported[e];
|
||||||
|
if (!rep) { s.reported[e] = { u: a.username || null, k: key }; enqueue('join', e); } // new here, or an older member's first change since the flag
|
||||||
|
else if (rep.k !== key) { rep.u = a.username || null; rep.k = key; enqueue('join', e); }
|
||||||
|
const rec = R.follow && R.follow.get ? R.follow.get(e) : null;
|
||||||
|
if (rec && DELIBERATE.has(rec.by) && norm(rec.sponsorEmail) === spE && Number(rec.at) > 0 && s.reported[e].sc !== Number(rec.at)) {
|
||||||
|
s.reported[e].sc = Number(rec.at); enqueue('sponsor', e);
|
||||||
|
}
|
||||||
|
save();
|
||||||
|
})().catch(err => console.error('hubsync touch', err.message));
|
||||||
|
}
|
||||||
|
// chain.onEvent (once across copies): a payout switch-on on the InstantAdPay contract goes to /v1/contract-bind
|
||||||
|
function onChain(ev) {
|
||||||
|
if (ev && ev.type === 'Purchase') return onPurchase(ev);
|
||||||
|
if (!R || !on() || !ev || ev.type !== 'MemberActivated' || !ev.account) return;
|
||||||
|
(async () => {
|
||||||
|
let spW = null; try { const m = ev.sponsorId ? await R.chain.member(ev.sponsorId) : null; spW = m && m.account ? norm(m.account) : null; } catch (e) {}
|
||||||
|
const s = load(); if (s.outbox.length >= 20000) { s.stats.sendErrors++; return; }
|
||||||
|
s.outbox.push({ kind: 'bind', email: norm(ev.account), wallet: norm(ev.account), sponsorWallet: spW, at: Date.now(), tries: 0, next: 0 }); save(); kick();
|
||||||
|
})().catch(err => console.error('hubsync onChain', err.message));
|
||||||
|
}
|
||||||
|
// chain.onEvent: money paid into the InstantAdPay contract (Purchase with POL in) goes to /v1/contract-spend (Marty 2026-11-14,
|
||||||
|
// rule 2: when two contracts hold different sponsors, the one with money spent decides the network sponsor). Keyed by the
|
||||||
|
// buyer's position wallet, the same key as its bind, so the bind is always sent first; the tx hash makes a resend count once.
|
||||||
|
// A 404 (bind not there yet, or a linked extra position the hub does not know) is retried like any other miss.
|
||||||
|
function onPurchase(ev) {
|
||||||
|
if (!R || !on() || !ev.buyerId || !(Number(ev.priceCents) > 0)) return;
|
||||||
|
try { if (BigInt(ev.paidWei || '0') <= 0n) return; } catch (e) { return; } // nothing paid in: not a spend
|
||||||
|
(async () => {
|
||||||
|
const m = await R.chain.member(ev.buyerId); const w = m && m.account ? norm(m.account) : null; if (!w) return;
|
||||||
|
const s = load(); if (s.outbox.length >= 20000) { s.stats.sendErrors++; return; }
|
||||||
|
s.outbox.push({ kind: 'spend', email: w, wallet: w, cents: Number(ev.priceCents), tx: ev.tx || null, paidAt: Number(ev.ts) || Date.now(), at: Date.now(), tries: 0, next: 0 }); save(); kick();
|
||||||
|
})().catch(err => console.error('hubsync onPurchase', err.message));
|
||||||
|
}
|
||||||
|
// accounts.onWalletLinked: a main wallet linked here goes to /v1/wallet
|
||||||
|
function wallet(email) {
|
||||||
|
if (!R || !on() || !email) return;
|
||||||
|
(async () => {
|
||||||
|
const a = await R.accounts.byEmail(email);
|
||||||
|
if (a && a.address && !R.accounts.isUnclaimedShell(a)) enqueue('wallet', norm(email)); // a waiting account's wallet came from a sync
|
||||||
|
})().catch(err => console.error('hubsync wallet', err.message));
|
||||||
|
}
|
||||||
|
// sponsorfollow / tank.js label a window expiry 'expire'; the hub (and its DELIBERATE list) calls it 'expiry' (fixed 2026-11-15:
|
||||||
|
// before, IAP window-expiry moves never reached the hub as a sponsor change)
|
||||||
|
const HUB_BY = { expire: 'expiry' };
|
||||||
|
const hubBy = by => HUB_BY[by] || by;
|
||||||
|
const ROUTE = { join: '/v1/join', wallet: '/v1/wallet', sponsor: '/v1/sponsor-change', bind: '/v1/contract-bind', spend: '/v1/contract-spend' };
|
||||||
|
async function bodyFor(item) {
|
||||||
|
if (item.kind === 'spend') {
|
||||||
|
let owner = null; try { owner = (await R.accounts.byAddress(item.wallet)) || (R.accounts.positionOwner ? await R.accounts.positionOwner(item.wallet) : null); } catch (e) {}
|
||||||
|
return { contract: 'iap', email: owner && owner.email ? owner.email : undefined, wallet: item.wallet, cents: item.cents, tx: item.tx || undefined, at: item.paidAt };
|
||||||
|
}
|
||||||
|
if (item.kind === 'bind') {
|
||||||
|
let owner = null; try { owner = await R.accounts.byAddress(item.wallet); } catch (e) {}
|
||||||
|
return { contract: 'iap', email: owner && owner.email ? owner.email : undefined, wallet: item.wallet, sponsorRef: item.sponsorWallet || '' };
|
||||||
|
}
|
||||||
|
const a = await R.accounts.byEmail(item.email); if (!a) return null;
|
||||||
|
if (item.kind === 'sponsor') {
|
||||||
|
const sp = await R.accounts.sponsorOf(a.email); const rec = R.follow && R.follow.get ? R.follow.get(a.email) : null;
|
||||||
|
if (!rec || !DELIBERATE.has(rec.by) || norm(rec.sponsorEmail) !== (sp ? norm(sp.email) : '')) return null; // superseded since
|
||||||
|
return { email: a.email, sponsorEmail: sp ? sp.email : null, by: hubBy(rec.by) };
|
||||||
|
}
|
||||||
|
if (item.kind === 'wallet') return a.address ? { email: a.email, wallet: a.address } : null;
|
||||||
|
const sp = await R.accounts.sponsorOf(a.email);
|
||||||
|
return { email: a.email, ref: sp ? sp.email : (a.sponsorRef || undefined), username: a.username || undefined };
|
||||||
|
}
|
||||||
|
async function flush(force) { // force (tests, admin): ignore the backoff wait
|
||||||
|
if (!R || !on() || sending) return { skipped: true };
|
||||||
|
sending = true; const s = load(); const now = Date.now(); const held = new Set(); let sent = 0;
|
||||||
|
try {
|
||||||
|
for (const item of s.outbox.slice()) {
|
||||||
|
if (held.has(item.email)) continue; // keep each member's calls in order (join before wallet)
|
||||||
|
if (item.next > now && !force) { held.add(item.email); continue; }
|
||||||
|
const drop = (why, code) => { s.outbox.splice(s.outbox.indexOf(item), 1); if (why) note({ type: 'out-' + why, kind: item.kind, email: item.email, code: code || null }); };
|
||||||
|
let r = null;
|
||||||
|
try {
|
||||||
|
const body = await bodyFor(item); if (!body) { drop('gone'); save(); continue; }
|
||||||
|
r = await hubPost(ROUTE[item.kind] || '/v1/wallet', body);
|
||||||
|
} catch (e) { r = { status: 0, body: { error: e.message } }; }
|
||||||
|
const code = (r.body && r.body.error) || null;
|
||||||
|
if (r.status >= 200 && r.status < 300) {
|
||||||
|
drop(null); s.stats.sent++; sent++;
|
||||||
|
if (item.kind === 'join' && r.body && r.body.person) await compare(item.email, r.body.person.sponsor && r.body.person.sponsor.email, 'iap-join');
|
||||||
|
} else if ((r.status === 400 || r.status === 409) || (r.status === 403 && code === 'blocked') || (item.kind === 'sponsor' && r.status === 404)) {
|
||||||
|
drop('refused', code); s.stats.refused++;
|
||||||
|
} else {
|
||||||
|
item.tries++; s.stats.sendErrors++;
|
||||||
|
if (item.tries >= OUT_TRIES) drop('gave-up', code || String(r.status));
|
||||||
|
else { item.next = now + Math.min(3600000, 30000 * Math.pow(2, item.tries)); held.add(item.email); }
|
||||||
|
}
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
} finally { sending = false; }
|
||||||
|
return { sent, waiting: s.outbox.length };
|
||||||
|
}
|
||||||
|
// password sign-ups do not fire accounts.onChange until they pick a username: every 10 minutes, any account made here since
|
||||||
|
// the flag went on that the hub has not heard about yet is queued
|
||||||
|
async function reconcile() {
|
||||||
|
if (!R || !on()) return { skipped: true };
|
||||||
|
const s = load(); let queued = 0;
|
||||||
|
for (const a of await R.accounts.listAll(1e6)) {
|
||||||
|
const e = norm(a.email);
|
||||||
|
if (!e || s.reported[e] || SHELL_ORIGINS.has(a.joinedVia) || Number(a.created) < s.since) continue;
|
||||||
|
s.reported[e] = { u: a.username || null }; s.outbox.push({ kind: 'join', email: e, at: Date.now(), tries: 0, next: 0 }); queued++;
|
||||||
|
}
|
||||||
|
if (queued) { save(); kick(); }
|
||||||
|
return { queued };
|
||||||
|
}
|
||||||
|
function start() {
|
||||||
|
if (interval) return;
|
||||||
|
interval = setInterval(() => flush().catch(e => console.error('hubsync flush', e.message)), 30000);
|
||||||
|
const rec = setInterval(() => reconcile().catch(e => console.error('hubsync reconcile', e.message)), 10 * 60000);
|
||||||
|
for (const t of [interval, rec]) if (t.unref) t.unref();
|
||||||
|
}
|
||||||
|
// ---------- rule 3: the holding tank asks the hub (Marty 2026-11-14) ----------
|
||||||
|
// The tank never offers anyone locked on ANY network contract, or anyone the hub already knows a sponsor for. tank.js asks
|
||||||
|
// through its hooks (networkHeld, networkLocked, network); server.js wires them only with HUB_ENABLED, so with the flag off
|
||||||
|
// the tank works exactly as before. One /v1/locked {emails, detail} call per 2,000 emails, cached per email: fresh for 10
|
||||||
|
// minutes. CONSERVATIVE when the hub cannot be reached: the last answer stands for up to 1 hour, after that the person is
|
||||||
|
// held ('unknown', not offered, not moved to the tank, not auto-assigned) until the hub answers again. A held tank for a
|
||||||
|
// while is the safe side; offering someone a contract already holds is not. After a failed call the hub is left alone
|
||||||
|
// for 2 minutes (page views must not each wait for a timeout).
|
||||||
|
const HELD_FRESH_MS = 10 * 60000, HELD_STALE_MS = 60 * 60000, HELD_DOWN_MS = 2 * 60000, HELD_CHUNK = 2000;
|
||||||
|
const held = new Map(); let heldDownUntil = 0, heldBusy = Promise.resolve();
|
||||||
|
async function refreshHeld(emails, timeout) {
|
||||||
|
const run = heldBusy.then(async () => {
|
||||||
|
const now = Date.now(); const miss = emails.filter(e => { const c = held.get(e); return !c || now - c.at > HELD_FRESH_MS; });
|
||||||
|
if (!miss.length || now < heldDownUntil) return;
|
||||||
|
try {
|
||||||
|
for (let i = 0; i < miss.length; i += HELD_CHUNK) {
|
||||||
|
const part = miss.slice(i, i + HELD_CHUNK);
|
||||||
|
const r = await hubPost('/v1/locked', { emails: part, detail: true, ids: true }, timeout || 5000); // ids: hub id + door per row (a hub without it ignores the flag)
|
||||||
|
if (r.status !== 200 || !r.body || !r.body.found || typeof r.body.found !== 'object') throw new Error('hub locked ' + r.status);
|
||||||
|
if (held.size > 60000) held.clear();
|
||||||
|
const at = Date.now(); for (const e of part) held.set(e, { at, row: r.body.found[e] || null });
|
||||||
|
}
|
||||||
|
} catch (e) { heldDownUntil = Date.now() + HELD_DOWN_MS; load().stats.heldErrors = (load().stats.heldErrors || 0) + 1; console.log('hubsync: hub /v1/locked unreachable:', e.message); }
|
||||||
|
});
|
||||||
|
heldBusy = run.catch(() => {}); return run;
|
||||||
|
}
|
||||||
|
const whyHeld = (c, now) => (!c || now - c.at > HELD_STALE_MS ? 'unknown' : c.row && c.row.locked ? 'locked' : c.row && c.row.sponsored ? 'sponsored' : null);
|
||||||
|
// accounts -> Map email -> 'locked' | 'sponsored' | 'unknown' for the ones the tank must not offer
|
||||||
|
async function heldAmong(accts, opts) {
|
||||||
|
const out = new Map(); if (!R || !on()) return out;
|
||||||
|
const emails = [...new Set((accts || []).map(a => norm(a && a.email)).filter(Boolean))]; if (!emails.length) return out;
|
||||||
|
await refreshHeld(emails, opts && opts.timeout);
|
||||||
|
const now = Date.now(); for (const e of emails) { const w = whyHeld(held.get(e), now); if (w) out.set(e, w); }
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
// release, rescue and expiry moves: 'locked' (on any network contract) | 'unknown' (hub not answering) | null
|
||||||
|
async function lockedAnywhere(email) {
|
||||||
|
if (!R || !on()) return null; const e = norm(email); if (!e) return null;
|
||||||
|
await refreshHeld([e]); const w = whyHeld(held.get(e), Date.now());
|
||||||
|
return w === 'locked' || w === 'unknown' ? w : null;
|
||||||
|
}
|
||||||
|
// the sponsor the hub knows for a tank member, for tank.alignToNetwork: this contract's lock first, else the network sponsor
|
||||||
|
// OFF unless HUB_TANK_ALIGN=on: aligning moves sponsors (and on LinkSpin a linked wallet then has its payouts switched on, which
|
||||||
|
// locks that sponsor on the contract), so the first run over a full tank is Marty's deliberate step, not a side effect of the
|
||||||
|
// deploy. While it is off the people the hub knows a sponsor for are simply held out of the tank (rule 3).
|
||||||
|
const alignOn = () => /^(1|true|on|yes)$/i.test(String(process.env.HUB_TANK_ALIGN || '').trim());
|
||||||
|
async function hubSponsor(email) {
|
||||||
|
if (!R || !on() || !alignOn()) return null; const e = norm(email); if (!e) return null;
|
||||||
|
await refreshHeld([e]); const c = held.get(e); if (!c || !c.row || Date.now() - c.at > HELD_STALE_MS) return null;
|
||||||
|
const l = c.row.locks && Object.prototype.hasOwnProperty.call(c.row.locks, CONTRACT) ? c.row.locks[CONTRACT] : undefined;
|
||||||
|
const sp = norm(l !== undefined ? l : c.row.sponsorEmail);
|
||||||
|
return sp && sp !== e ? { sponsorEmail: sp, via: l !== undefined ? 'network hub, InstantAdPay contract' : 'network hub' } : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the hub id and first door of a person the tank cache holds (5xYourTeam draft pool, 2026-11-15): { id, door } | null. Read-only, no call.
|
||||||
|
function hubInfo(email) { const c = held.get(norm(email)); return c && c.row && c.row.id ? { id: c.row.id, door: c.row.door || null } : null; }
|
||||||
|
function adminView() {
|
||||||
|
const s = load();
|
||||||
|
return Object.assign({ enabled: enabled(), on: on(), site: SITE(), url: URL_(), since: s.since, outbox: s.outbox.length, retrying: Object.keys(s.tries).length,
|
||||||
|
disagree: Object.keys(s.disagree).length, tankCache: held.size, tankHubDownUntil: heldDownUntil || null }, s.stats, { disagreements: Object.entries(s.disagree).slice(-25).map(([email, d]) => Object.assign({ email }, d)), recent: s.log.slice(-25).reverse() });
|
||||||
|
}
|
||||||
|
module.exports = { _hubBy: hubBy, init, enabled, on, receive, touch, wallet, onChain, flush, reconcile, start, adminView, heldAmong, lockedAnywhere, hubSponsor, hubInfo, resolvePerson: q => resolve(q), _sign: sign, _heldReset: () => { held.clear(); heldDownUntil = 0; }, _heldAge: ms => { for (const c of held.values()) c.at -= ms; } };
|
||||||
+2
-2
@@ -133,7 +133,7 @@ async function renderPage() {
|
|||||||
const fmtD = ts => new Date(ts).toLocaleDateString('en-US', { timeZone: TZ, month: 'short', day: 'numeric' });
|
const fmtD = ts => new Date(ts).toLocaleDateString('en-US', { timeZone: TZ, month: 'short', day: 'numeric' });
|
||||||
const desc = 'Who is selling the most ad packages on InstantAdPay this week and this month. Weekly and monthly referral contest standings, read from the chain.';
|
const desc = 'Who is selling the most ad packages on InstantAdPay this week and this month. Weekly and monthly referral contest standings, read from the chain.';
|
||||||
let h = '<!doctype html><html lang="en"' + themehead.htmlAttr('dark') + '><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Leaderboard | InstantAdPay</title><meta name="description" content="' + esc(desc) + '"><link rel="canonical" href="https://instantadpay.com/leaderboard"><meta property="og:title" content="InstantAdPay leaderboard"><meta property="og:description" content="' + esc(desc) + '"><meta property="og:image" content="https://instantadpay.com/banners/iap-hero-1200x630.png"><meta name="twitter:card" content="summary_large_image">'
|
let h = '<!doctype html><html lang="en"' + themehead.htmlAttr('dark') + '><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Leaderboard | InstantAdPay</title><meta name="description" content="' + esc(desc) + '"><link rel="canonical" href="https://instantadpay.com/leaderboard"><meta property="og:title" content="InstantAdPay leaderboard"><meta property="og:description" content="' + esc(desc) + '"><meta property="og:image" content="https://instantadpay.com/banners/iap-hero-1200x630.png"><meta name="twitter:card" content="summary_large_image">'
|
||||||
+ '<link rel="icon" type="image/png" href="/logo-icon.png"><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">' + themehead.tag() + '<link rel="stylesheet" href="/assets/site.css?v=20261101th">'
|
+ '<link rel="icon" type="image/png" href="/logo-icon.png"><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">' + themehead.tag() + '<link rel="stylesheet" href="/assets/site.css?v=20261112ln">'
|
||||||
+ '<style>.lbw{max-width:860px}.lb{width:100%;border-collapse:collapse;margin:8px 0 26px;font-variant-numeric:tabular-nums}.lb th{text-align:left;color:var(--muted);font-size:11px;letter-spacing:.08em;text-transform:uppercase;padding:8px 10px;border-bottom:1px solid var(--line)}.lb td{padding:10px;border-bottom:1px solid var(--line)}.lb tr:first-child + tr td:first-child{color:var(--gold);font-weight:800}.prize{border-left:4px solid var(--mint);background:var(--mint-soft);padding:12px 16px;border-radius:0 12px 12px 0;margin:0 0 18px}.win{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:12px 16px;margin:0 0 10px}</style></head><body><div class="wrap lbw">'
|
+ '<style>.lbw{max-width:860px}.lb{width:100%;border-collapse:collapse;margin:8px 0 26px;font-variant-numeric:tabular-nums}.lb th{text-align:left;color:var(--muted);font-size:11px;letter-spacing:.08em;text-transform:uppercase;padding:8px 10px;border-bottom:1px solid var(--line)}.lb td{padding:10px;border-bottom:1px solid var(--line)}.lb tr:first-child + tr td:first-child{color:var(--gold);font-weight:800}.prize{border-left:4px solid var(--mint);background:var(--mint-soft);padding:12px 16px;border-radius:0 12px 12px 0;margin:0 0 18px}.win{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:12px 16px;margin:0 0 10px}</style></head><body><div class="wrap lbw">'
|
||||||
+ '<section class="hero" style="padding:56px 0 8px"><p class="eyebrow">Referral contest</p><h1>Leaderboard: <em>who is selling</em>.</h1><p class="lead">Ranked by ad packages sold to other people (your own positions never count, and the company account is not a contestant). Read from the chain, updated live. Weeks run Monday to Sunday, Central time.</p></section>';
|
+ '<section class="hero" style="padding:56px 0 8px"><p class="eyebrow">Referral contest</p><h1>Leaderboard: <em>who is selling</em>.</h1><p class="lead">Ranked by ad packages sold to other people (your own positions never count, and the company account is not a contestant). Read from the chain, updated live. Weeks run Monday to Sunday, Central time.</p></section>';
|
||||||
h += '<h2 style="font-size:24px;margin:0 0 4px">' + week.label + ' <span class="muted small">' + fmtD(week.start) + ' to Sunday</span></h2>' + (week.prize ? '<div class="prize"><b>Weekly prizes:</b> ' + esc(week.prize) + '</div>' : '') + table(week);
|
h += '<h2 style="font-size:24px;margin:0 0 4px">' + week.label + ' <span class="muted small">' + fmtD(week.start) + ' to Sunday</span></h2>' + (week.prize ? '<div class="prize"><b>Weekly prizes:</b> ' + esc(week.prize) + '</div>' : '') + table(week);
|
||||||
@@ -142,7 +142,7 @@ async function renderPage() {
|
|||||||
const w = winners();
|
const w = winners();
|
||||||
if (w.length) h += '<h2 style="font-size:24px;margin:0 0 10px">Past winners</h2>' + w.slice(0, 12).map(x => '<div class="win"><b>' + (x.kind === 'week' ? 'Week of ' : 'Month of ') + fmtD(x.start) + '</b>: ' + (x.top[0] ? esc(x.top[0].name) + ' (' + x.top[0].sales + ' sold, $' + x.top[0].usd + ')' : 'no sales') + (x.granted && x.granted.length ? ' · awarded: ' + x.granted.map(g => esc(g.name) + ' +' + g.credits.toLocaleString()).join(', ') : (x.prize ? ' · prize ' + esc(x.prize) : '')) + '</div>').join('');
|
if (w.length) h += '<h2 style="font-size:24px;margin:0 0 10px">Past winners</h2>' + w.slice(0, 12).map(x => '<div class="win"><b>' + (x.kind === 'week' ? 'Week of ' : 'Month of ') + fmtD(x.start) + '</b>: ' + (x.top[0] ? esc(x.top[0].name) + ' (' + x.top[0].sales + ' sold, $' + x.top[0].usd + ')' : 'no sales') + (x.granted && x.granted.length ? ' · awarded: ' + x.granted.map(g => esc(g.name) + ' +' + g.credits.toLocaleString()).join(', ') : (x.prize ? ' · prize ' + esc(x.prize) : '')) + '</div>').join('');
|
||||||
h += '<p class="muted small" style="margin-top:30px">Sales are $ of packages bought by members you directly sponsor. Prizes are advertising credits or packages, never cash. No income is guaranteed.</p>';
|
h += '<p class="muted small" style="margin-top:30px">Sales are $ of packages bought by members you directly sponsor. Prizes are advertising credits or packages, never cash. No income is guaranteed.</p>';
|
||||||
h += '</div><script src="/assets/common.js?v=20261023ov"></script><script src="/assets/blog-page.js?v=20260914a"></script></body></html>';
|
h += '</div><script src="/assets/common.js?v=20261114ns"></script><script src="/assets/blog-page.js?v=20260914a"></script></body></html>';
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
module.exports = { init, view, compute, renderPage, rolloverTick, winners, periodBounds };
|
module.exports = { init, view, compute, renderPage, rolloverTick, winners, periodBounds };
|
||||||
|
|||||||
@@ -173,4 +173,4 @@ async function goalOp(email, op, fields) {
|
|||||||
cache.delete(e); return out;
|
cache.delete(e); return out;
|
||||||
}
|
}
|
||||||
function adminView() { return { on: on(), url: URL_(), pushed: stats.pushed, lastAt: stats.lastAt, errors: stats.errors, lastError: stats.lastError, fails, nextAt: nextAt || null }; }
|
function adminView() { return { on: on(), url: URL_(), pushed: stats.pushed, lastAt: stats.lastAt, errors: stats.errors, lastError: stats.lastError, fails, nextAt: nextAt || null }; }
|
||||||
module.exports = { init, record, flush, summary, goalOp, withClickId, softKey, placementOf, deviceOf, newId, adminView, on, noteSession, isOwnerSk };
|
module.exports = { signedPost, init, record, flush, summary, goalOp, withClickId, softKey, placementOf, deviceOf, newId, adminView, on, noteSession, isOwnerSk };
|
||||||
|
|||||||
+5
-4
@@ -127,7 +127,7 @@ async function place(email, depth, ctx) {
|
|||||||
const sp = await sponsorAccount(r.sponsorEmail, depth, ctx);
|
const sp = await sponsorAccount(r.sponsorEmail, depth, ctx);
|
||||||
if (sp) tok = tokenOf(sp); else { s.pending[email] = r.sponsorEmail; ctx.sum.pendingSponsor++; }
|
if (sp) tok = tokenOf(sp); else { s.pending[email] = r.sponsorEmail; ctx.sum.pendingSponsor++; }
|
||||||
}
|
}
|
||||||
const x = await A.ensure(email, tok, 'linkspin', 'linkspin');
|
const x = await A.ensure(email, tok, ctx.via || 'linkspin', ctx.refOf ? ctx.refOf(email) : 'linkspin'); // hubsync.js passes its own via (2026-11-12)
|
||||||
if (!x || x.error) { conflict(ctx.sum, email, 'create', x && x.error); return null; }
|
if (!x || x.error) { conflict(ctx.sum, email, 'create', x && x.error); return null; }
|
||||||
a = x.account;
|
a = x.account;
|
||||||
if (x.created) { ctx.sum.created++; wrote = true; note({ type: 'shell', email, sponsor: tok || null, pending: tok ? null : (r.sponsorEmail || null) }); }
|
if (x.created) { ctx.sum.created++; wrote = true; note({ type: 'shell', email, sponsor: tok || null, pending: tok ? null : (r.sponsorEmail || null) }); }
|
||||||
@@ -156,10 +156,10 @@ async function resolvePending(ctx) {
|
|||||||
note({ type: 'sponsored', email, sponsor: tokenOf(sp) });
|
note({ type: 'sponsored', email, sponsor: tokenOf(sp) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function handle(rows) {
|
async function handle(rows, opts) {
|
||||||
const s = load(); s.stats.batches++;
|
const s = load(); s.stats.batches++;
|
||||||
const sum = { rows: 0, noop: 0, created: 0, filled: 0, sponsored: 0, conflicts: 0, pendingSponsor: 0, errors: 0, followed: 0, followKept: 0, tank: 0 };
|
const sum = { rows: 0, noop: 0, created: 0, filled: 0, sponsored: 0, conflicts: 0, pendingSponsor: 0, errors: 0, followed: 0, followKept: 0, tank: 0 };
|
||||||
const ctx = { sum, done: new Set() }; const batch = [];
|
const ctx = { sum, done: new Set(), via: opts && opts.via, refOf: opts && opts.refOf }; const batch = [];
|
||||||
for (const x of rows || []) { const r = clean(x); if (!r) continue; sum.rows++; s.rows[r.email] = r; batch.push(r); }
|
for (const x of rows || []) { const r = clean(x); if (!r) continue; sum.rows++; s.rows[r.email] = r; batch.push(r); }
|
||||||
if (R.store) for (const r of batch) if (Object.prototype.hasOwnProperty.call(r, 'tank')) { R.store.setRemote(r.email, r.tank); sum.tank++; } // network tank
|
if (R.store) for (const r of batch) if (Object.prototype.hasOwnProperty.call(r, 'tank')) { R.store.setRemote(r.email, r.tank); sum.tank++; } // network tank
|
||||||
try {
|
try {
|
||||||
@@ -176,7 +176,8 @@ async function handle(rows) {
|
|||||||
return Object.assign({ proto: SF.PROTO }, sum); // proto 2: this side understands sponsor follow + network tank facts
|
return Object.assign({ proto: SF.PROTO }, sum); // proto 2: this side understands sponsor follow + network tank facts
|
||||||
}
|
}
|
||||||
// batches are applied one at a time (two overlapping posts must not both create the same sponsor shell)
|
// batches are applied one at a time (two overlapping posts must not both create the same sponsor shell)
|
||||||
function receive(rows) { const run = chain_.then(() => handle(rows)); chain_ = run.catch(() => {}); return run; }
|
// opts (hubsync.js only): { via, refOf(email) } names where a new waiting account came from; LinkSpin's posts pass none
|
||||||
|
function receive(rows, opts) { const run = chain_.then(() => handle(rows, opts)); chain_ = run.catch(() => {}); return run; }
|
||||||
function adminView() {
|
function adminView() {
|
||||||
const s = load();
|
const s = load();
|
||||||
return Object.assign({}, s.stats, { knownRows: Object.keys(s.rows).length, pendingSponsors: Object.keys(s.pending).length, last: s.last || null, lastError: s.stats.lastError || null, recent: s.log.slice(-25).reverse() });
|
return Object.assign({}, s.stats, { knownRows: Object.keys(s.rows).length, pendingSponsors: Object.keys(s.pending).length, last: s.last || null, lastError: s.stats.lastError || null, recent: s.log.slice(-25).reverse() });
|
||||||
|
|||||||
+151
@@ -0,0 +1,151 @@
|
|||||||
|
// Conversion linkage, InstantAdPay half (Marty 2026-11-07, "Yes ship these"). REPORTING ONLY: this module never reads or changes a
|
||||||
|
// sponsor, a payout, credits or anything on chain. LinkSpin owns the counting; this keeps the click and tells it what happened.
|
||||||
|
// the click arrives as ?lsclk= or ?lsid= on any page: a first-party cookie iap.lsclk, 30 days, last click wins (the same life
|
||||||
|
// and last-touch rule as the sponsor cookie), plus the page's own copy sent with the code request, because the
|
||||||
|
// cookie is refused inside a traffic-exchange frame and never crosses browsers (the 2026-09-29 sponsor lesson)
|
||||||
|
// the account kept in its own table, ls_account_clicks, keyed by email: remembered when the code is requested, bound when the
|
||||||
|
// account is created (or a waiting LinkSpin shell is claimed). Its own table on purpose: accounts is not touched
|
||||||
|
// the events sign-up, wallet link, each package Purchase on the chain, by an account with a bound click. One row each in
|
||||||
|
// ls_events; its primary key is the idempotency key (join:<hash>, wallet:<hash>, purchase:<tx>:<log index>), so two
|
||||||
|
// app copies during a deploy can both try and only one row exists
|
||||||
|
// the delivery a loop in the background posts unsent rows to LinkSpin (POST /api/partner/conv op events, signed like lsconv), 100
|
||||||
|
// at a time, every ~5 s with backoff to 5 minutes. A row is marked sent only after LinkSpin answers, and LinkSpin
|
||||||
|
// dedupes by the same key, so a row sent by both copies, or twice, counts once
|
||||||
|
// Nothing here runs in the chain event handler's path or in a sign-up's path beyond one local write: LinkSpin down, slow or
|
||||||
|
// blocked changes nothing except that rows wait. No LS_SYNC_SECRET: rows wait too.
|
||||||
|
'use strict';
|
||||||
|
const crypto = require('crypto');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const lsconv = require('./lsconv');
|
||||||
|
|
||||||
|
let R = null, timer = null, flushing = false, fails = 0, nextAt = 0, jstate = null, saveT = null;
|
||||||
|
const stats = { sent: 0, lastAt: null, lastError: null, errors: 0 };
|
||||||
|
const DAY = 86400000, WINDOW = 30 * DAY;
|
||||||
|
const useDb = () => !!(R && R.db && R.db.enabled());
|
||||||
|
const JFILE = () => path.join(R.dataDir, 'lsreport.json');
|
||||||
|
const norm = e => String(e || '').trim().toLowerCase();
|
||||||
|
const isId = v => /^(?:[a-f0-9]{10}|[aik][a-f0-9]{11})$/.test(String(v || ''));
|
||||||
|
const hash = email => crypto.createHash('sha256').update(norm(email)).digest('hex').slice(0, 24);
|
||||||
|
// the id in a page address, or '' (lsclk first: it is the id the landing tag and ad clicks carry)
|
||||||
|
const fromUrl = u => { const v = u.searchParams.get('lsclk') || u.searchParams.get('lsid') || ''; return isId(v) ? v : ''; };
|
||||||
|
const pick = (...vals) => { for (const v of vals) if (isId(v)) return String(v); return ''; };
|
||||||
|
const COOKIE = 'iap.lsclk';
|
||||||
|
const cookieHeader = (id, isProd) => COOKIE + '=' + id + '; Path=/; Max-Age=' + (30 * 86400) + '; ' + (isProd ? 'SameSite=None; Secure' : 'SameSite=Lax');
|
||||||
|
|
||||||
|
function init(deps) {
|
||||||
|
R = deps;
|
||||||
|
if (useDb()) ensureTables().catch(e => console.error('lsreport tables', e.message));
|
||||||
|
if (!deps.noTimers) {
|
||||||
|
if (!timer) { timer = setInterval(() => { flush().catch(() => {}); }, 5000); if (timer.unref) timer.unref(); }
|
||||||
|
setInterval(() => prune().catch(() => {}), 6 * 3600 * 1000).unref();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// column names checked against MySQL 8 reserved words (none of email, click_id, ts, bound, k, ev, cents, ev_ts, tx, sk, pushed, outcome is reserved)
|
||||||
|
async function ensureTables() {
|
||||||
|
await R.db.q(`CREATE TABLE IF NOT EXISTS ls_account_clicks (
|
||||||
|
email VARCHAR(190) PRIMARY KEY,
|
||||||
|
click_id VARCHAR(16) NOT NULL,
|
||||||
|
ts BIGINT NOT NULL,
|
||||||
|
bound TINYINT NOT NULL DEFAULT 0
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4`);
|
||||||
|
await R.db.q(`CREATE TABLE IF NOT EXISTS ls_events (
|
||||||
|
k VARCHAR(120) PRIMARY KEY,
|
||||||
|
ev VARCHAR(10) NOT NULL,
|
||||||
|
email VARCHAR(190) NOT NULL,
|
||||||
|
click_id VARCHAR(16) NOT NULL,
|
||||||
|
cents INT NOT NULL DEFAULT 0,
|
||||||
|
ev_ts BIGINT NOT NULL,
|
||||||
|
tx VARCHAR(80) NULL,
|
||||||
|
sk VARCHAR(24) NULL,
|
||||||
|
pushed TINYINT NOT NULL DEFAULT 0,
|
||||||
|
outcome VARCHAR(12) NULL,
|
||||||
|
INDEX (pushed, ev_ts)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- JSON store (local runs) ----
|
||||||
|
function jload() { if (jstate) return jstate; try { jstate = JSON.parse(fs.readFileSync(JFILE(), 'utf8')); if (!jstate.clicks || !Array.isArray(jstate.events)) throw 0; } catch (e) { jstate = { clicks: {}, events: [] }; } return jstate; }
|
||||||
|
function jsave() { if (saveT) return; saveT = setTimeout(() => { saveT = null; try { fs.writeFileSync(JFILE(), JSON.stringify(jload())); } catch (e) {} }, 300); if (saveT.unref) saveT.unref(); }
|
||||||
|
|
||||||
|
// ---- the click on the account ----
|
||||||
|
async function clickOf(email) {
|
||||||
|
const e = norm(email);
|
||||||
|
if (useDb()) { const r = (await R.db.q('SELECT click_id, ts, bound FROM ls_account_clicks WHERE email=?', [e]))[0]; return r ? { click: r.click_id, ts: Number(r.ts), bound: Number(r.bound) ? 1 : 0 } : null; }
|
||||||
|
return jload().clicks[e] || null;
|
||||||
|
}
|
||||||
|
// at the code request: the click travels with the email, so verifying in another browser still finds it. Last click wins until bound.
|
||||||
|
async function remember(email, click) {
|
||||||
|
const e = norm(email); if (!e || e.length > 190 || !isId(click)) return false;
|
||||||
|
const now = Date.now();
|
||||||
|
if (useDb()) { await R.db.q('INSERT INTO ls_account_clicks (email, click_id, ts, bound) VALUES (?,?,?,0) ON DUPLICATE KEY UPDATE click_id=IF(bound=0,VALUES(click_id),click_id), ts=IF(bound=0,VALUES(ts),ts)', [e, click, now]); return true; }
|
||||||
|
const st = jload(); if (st.clicks[e] && st.clicks[e].bound) return false; st.clicks[e] = { click, ts: now, bound: 0 }; jsave(); return true;
|
||||||
|
}
|
||||||
|
// the account now exists: bind the click (this request's, else the remembered one), once, and queue the join
|
||||||
|
async function signup(email, click, sk) {
|
||||||
|
const e = norm(email); if (!e || e.length > 190) return false;
|
||||||
|
const row = await clickOf(e); if (row && row.bound) return false;
|
||||||
|
const c = isId(click) ? click : (row && Date.now() - row.ts <= WINDOW ? row.click : ''); if (!c) return false;
|
||||||
|
const now = Date.now();
|
||||||
|
if (useDb()) {
|
||||||
|
await R.db.q('INSERT IGNORE INTO ls_account_clicks (email, click_id, ts, bound) VALUES (?,?,?,0)', [e, c, now]);
|
||||||
|
const u = await R.db.q('UPDATE ls_account_clicks SET click_id=?, ts=?, bound=1 WHERE email=? AND bound=0', [c, now, e]);
|
||||||
|
if (!(u && u.affectedRows === 1)) return false;
|
||||||
|
} else { const st = jload(); st.clicks[e] = { click: c, ts: now, bound: 1 }; jsave(); }
|
||||||
|
await enqueue({ k: 'join:' + hash(e), ev: 'join', email: e, click: c, cents: 0, ts: now, sk: /^s:[a-f0-9]{20}$/.test(String(sk || '')) ? sk : null });
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
async function wallet(email) {
|
||||||
|
const e = norm(email); const row = await clickOf(e); if (!row || !row.bound) return false;
|
||||||
|
return enqueue({ k: 'wallet:' + hash(e), ev: 'wallet', email: e, click: row.click, cents: 0, ts: Date.now() });
|
||||||
|
}
|
||||||
|
// a Purchase chain event, already resolved to its account. Value = the USD price on the event. Linked positions sit on the same
|
||||||
|
// account, so they count as that account's purchases. Past the click window nothing is queued: LinkSpin would refuse it anyway
|
||||||
|
// (the bind is never earlier than the click, so more than 30 days after the bind is more than 30 days after the click).
|
||||||
|
async function purchase(ev, email) {
|
||||||
|
const e = norm(email); const cents = Number(ev && ev.priceCents) || 0; if (!e || cents <= 0 || !ev.tx) return false;
|
||||||
|
const row = await clickOf(e); if (!row || !row.bound) return false;
|
||||||
|
const ts = Number(ev.ts) || Date.now();
|
||||||
|
if (ts < row.ts - 60000 || ts - row.ts > WINDOW) return false; // before the sign-up, or past the window
|
||||||
|
return enqueue({ k: ('purchase:' + ev.tx + ':' + ev.li).slice(0, 120), ev: 'purchase', email: e, click: row.click, cents, ts, tx: String(ev.tx).slice(0, 80) });
|
||||||
|
}
|
||||||
|
async function enqueue(x) {
|
||||||
|
if (useDb()) { const r = await R.db.q('INSERT IGNORE INTO ls_events (k, ev, email, click_id, cents, ev_ts, tx, sk, pushed) VALUES (?,?,?,?,?,?,?,?,0)', [x.k, x.ev, x.email, x.click, x.cents, x.ts, x.tx || null, x.sk || null]); return !!(r && r.affectedRows === 1); }
|
||||||
|
const st = jload(); if (st.events.some(r => r.k === x.k)) return false; st.events.push(Object.assign({ pushed: 0 }, x)); if (st.events.length > 5000) st.events = st.events.slice(-4000); jsave(); return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- delivery ----
|
||||||
|
async function unsent(n) {
|
||||||
|
if (useDb()) return (await R.db.q('SELECT k, ev, email, click_id, cents, ev_ts, tx, sk FROM ls_events WHERE pushed=0 ORDER BY ev_ts LIMIT ?', [n])).map(r => ({ k: r.k, ev: r.ev, email: r.email, click: r.click_id, cents: Number(r.cents) || 0, ts: Number(r.ev_ts), tx: r.tx, sk: r.sk }));
|
||||||
|
return jload().events.filter(r => !r.pushed).slice(0, n);
|
||||||
|
}
|
||||||
|
async function markSent(k, outcome) {
|
||||||
|
if (useDb()) { await R.db.q('UPDATE ls_events SET pushed=1, outcome=? WHERE k=?', [String(outcome || '').slice(0, 12) || null, k]); return; }
|
||||||
|
const r = jload().events.find(x => x.k === k); if (r) { r.pushed = 1; r.outcome = outcome; jsave(); }
|
||||||
|
}
|
||||||
|
async function flush() {
|
||||||
|
if (!lsconv.on() || flushing || Date.now() < nextAt) return { skipped: true };
|
||||||
|
flushing = true; let sent = 0;
|
||||||
|
try {
|
||||||
|
for (let round = 0; round < 10; round++) {
|
||||||
|
const rows = await unsent(100); if (!rows.length) break;
|
||||||
|
const res = await lsconv.signedPost('/api/partner/conv', { op: 'events', events: rows.map(r => ({ k: r.k, ev: r.ev, email: r.email, click: r.click, value: r.cents / 100, ts: r.ts, tx: r.tx || undefined, sk: r.sk || undefined })) }, 15000);
|
||||||
|
if (!res || res.ok !== true || !Array.isArray(res.results)) throw new Error('linkspin answered without results');
|
||||||
|
for (const a of res.results) { await markSent(a.k, a.result); sent++; stats.sent++; }
|
||||||
|
stats.lastAt = Date.now();
|
||||||
|
if (rows.length < 100) break;
|
||||||
|
}
|
||||||
|
fails = 0; nextAt = 0; return { sent };
|
||||||
|
} catch (e) {
|
||||||
|
fails++; stats.errors++; stats.lastError = e.message; nextAt = Date.now() + Math.min(300000, 5000 * Math.pow(2, Math.min(fails, 6)));
|
||||||
|
if (fails <= 3 || fails % 20 === 0) console.error('lsreport push', e.message);
|
||||||
|
return { error: e.message, sent };
|
||||||
|
} finally { flushing = false; }
|
||||||
|
}
|
||||||
|
async function prune() {
|
||||||
|
const now = Date.now(); const old = now - 60 * DAY, stale = now - 31 * DAY;
|
||||||
|
if (useDb()) { await R.db.q('DELETE FROM ls_events WHERE ev_ts<?', [old]); await R.db.q('DELETE FROM ls_account_clicks WHERE (bound=0 AND ts<?) OR ts<?', [stale, old]); return; }
|
||||||
|
const st = jload(); st.events = st.events.filter(r => r.ts >= old); for (const k of Object.keys(st.clicks)) { const c = st.clicks[k]; if (c.ts < old || (!c.bound && c.ts < stale)) delete st.clicks[k]; } jsave();
|
||||||
|
}
|
||||||
|
function adminView() { return { on: lsconv.on(), sent: stats.sent, lastAt: stats.lastAt, errors: stats.errors, lastError: stats.lastError, fails, nextAt: nextAt || null }; }
|
||||||
|
module.exports = { init, ensureTables, fromUrl, pick, cookieHeader, COOKIE, isId, remember, signup, wallet, purchase, clickOf, flush, prune, adminView };
|
||||||
@@ -32,6 +32,7 @@ async function rowFor(acct, byRef, tankMap) {
|
|||||||
const ref = String(acct.sponsorRef || '').toLowerCase(); let sponsorEmail = null;
|
const ref = String(acct.sponsorRef || '').toLowerCase(); let sponsorEmail = null;
|
||||||
if (ref) { const sp = byRef ? byRef.get(ref) : (await R.accounts.byUsername(ref) || await R.accounts.byCode(ref)); if (sp && sp.email !== acct.email) sponsorEmail = sp.email; }
|
if (ref) { const sp = byRef ? byRef.get(ref) : (await R.accounts.byUsername(ref) || await R.accounts.byCode(ref)); if (sp && sp.email !== acct.email) sponsorEmail = sp.email; }
|
||||||
const row = { email: acct.email, username: acct.username || null, wallet: acct.address || null, sponsorEmail, joinedAt: Number(acct.created) || null, memberId: acct.memberId || null, profile: profileOf(acct) };
|
const row = { email: acct.email, username: acct.username || null, wallet: acct.address || null, sponsorEmail, joinedAt: Number(acct.created) || null, memberId: acct.memberId || null, profile: profileOf(acct) };
|
||||||
|
if (acct.joinedVia === 'btc4hits') row.origin = 'btc4hits'; // BTC4Hits import (2026-11-11): LinkSpin words its holding-tank mail for them
|
||||||
if (R.follow) Object.assign(row, SF.rowFields(R.follow.get(acct.email), sponsorEmail) || {});
|
if (R.follow) Object.assign(row, SF.rowFields(R.follow.get(acct.email), sponsorEmail) || {});
|
||||||
const T = R.tank && R.tank();
|
const T = R.tank && R.tank();
|
||||||
if (T) { try { row.tank = (tankMap ? tankMap.get(String(acct.email).toLowerCase()) : await T.summaryFor(acct.email)) || null; } catch (e) {} }
|
if (T) { try { row.tank = (tankMap ? tankMap.get(String(acct.email).toLowerCase()) : await T.summaryFor(acct.email)) || null; } catch (e) {} }
|
||||||
@@ -74,10 +75,14 @@ async function push(rows) {
|
|||||||
}
|
}
|
||||||
st.pushed += sent; st.last = { at: Date.now(), rows: sent }; save(); return sent;
|
st.pushed += sent; st.last = { at: Date.now(), rows: sent }; save(); return sent;
|
||||||
}
|
}
|
||||||
|
// QUIET (Marty 2026-11-14, "join one = join all"): a waiting account the network hub made here (joinedVia 'hub', never signed
|
||||||
|
// in) is never pushed to LinkSpin. The hub tells LinkSpin itself, quietly; pushed from here, LinkSpin's registry route would
|
||||||
|
// link the wallet and its engine would switch payouts on and email them. Once they sign in here they sync like anyone.
|
||||||
|
const hubShell = a => !!a && a.joinedVia === 'hub' && R.accounts.isUnclaimedShell && R.accounts.isUnclaimedShell(a);
|
||||||
// an account just changed: send its row shortly (debounced so a join + username + wallet in a row go as one)
|
// an account just changed: send its row shortly (debounced so a join + username + wallet in a row go as one)
|
||||||
function touch(email) {
|
function touch(email) {
|
||||||
if (!on() || !email) return; pending.set(String(email).toLowerCase(), Date.now());
|
if (!on() || !email) return; pending.set(String(email).toLowerCase(), Date.now());
|
||||||
if (!timer) timer = setTimeout(async () => { timer = null; const st = load(); const emails = [...pending.keys()].filter(e => !muted.has(e)); for (const e of emails) pending.delete(e); try { const rows = []; for (const e of emails) { const a = await R.accounts.byEmail(e); if (a) { const r = await rowFor(a); if (st.hashes[r.email] !== hashOf(r)) rows.push(r); } } if (rows.length) await push(rows); } catch (e) { load().errors++; save(); console.error('lssync touch', e.message); } }, 3000);
|
if (!timer) timer = setTimeout(async () => { timer = null; const st = load(); const emails = [...pending.keys()].filter(e => !muted.has(e)); for (const e of emails) pending.delete(e); try { const rows = []; for (const e of emails) { const a = await R.accounts.byEmail(e); if (a && !hubShell(a)) { const r = await rowFor(a); if (st.hashes[r.email] !== hashOf(r)) rows.push(r); } } if (rows.length) await push(rows); } catch (e) { load().errors++; save(); console.error('lssync touch', e.message); } }, 3000);
|
||||||
}
|
}
|
||||||
// the reconcile pass: only rows whose hash changed since the last push
|
// the reconcile pass: only rows whose hash changed since the last push
|
||||||
async function tick(force) {
|
async function tick(force) {
|
||||||
@@ -87,7 +92,7 @@ async function tick(force) {
|
|||||||
const all = await R.accounts.listAll(50000, { shells: true }); const st = load();
|
const all = await R.accounts.listAll(50000, { shells: true }); const st = load();
|
||||||
const byRef = new Map(); for (const a of all) { if (a.username) byRef.set(String(a.username).toLowerCase(), a); if (a.code) byRef.set(String(a.code).toLowerCase(), a); }
|
const byRef = new Map(); for (const a of all) { if (a.username) byRef.set(String(a.username).toLowerCase(), a); if (a.code) byRef.set(String(a.code).toLowerCase(), a); }
|
||||||
const T = R.tank && R.tank(); let tankMap = null; if (T) { try { tankMap = await T.summaryMap(); } catch (e) { tankMap = null; } }
|
const T = R.tank && R.tank(); let tankMap = null; if (T) { try { tankMap = await T.summaryMap(); } catch (e) { tankMap = null; } }
|
||||||
const rows = []; for (const a of all) { if (!a.email || muted.has(a.email)) continue; const r = await rowFor(a, byRef, tankMap || (T ? new Map() : null)); if (force || st.hashes[r.email] !== hashOf(r)) rows.push(r); }
|
const rows = []; for (const a of all) { if (!a.email || muted.has(a.email) || hubShell(a)) continue; const r = await rowFor(a, byRef, tankMap || (T ? new Map() : null)); if (force || st.hashes[r.email] !== hashOf(r)) rows.push(r); }
|
||||||
const sent = rows.length ? await push(rows) : 0;
|
const sent = rows.length ? await push(rows) : 0;
|
||||||
return { accounts: all.length, changed: rows.length, sent };
|
return { accounts: all.length, changed: rows.length, sent };
|
||||||
} catch (e) { load().errors++; save(); console.error('lssync tick', e.message); return { error: e.message }; }
|
} catch (e) { load().errors++; save(); console.error('lssync tick', e.message); return { error: e.message }; }
|
||||||
|
|||||||
+60
@@ -0,0 +1,60 @@
|
|||||||
|
// The network sites list for the footer's "Part of the network" line (Marty 2026-11-14 trust pack).
|
||||||
|
// One source: the hub's public GET /v1/network-sites (HUB_URL). Cached 10 minutes, refreshed in the background, never waits on a
|
||||||
|
// slow hub (2.5 s timeout), and falls back to the same built-in list. Never RM Circle, never the games.
|
||||||
|
// The same file lives in every network site (InstantAdPay, LinkSpin, Downline Banners, VBB, Stack POL).
|
||||||
|
const FALLBACK = [
|
||||||
|
{ id: 'iap', name: 'InstantAdPay', url: 'https://instantadpay.com' },
|
||||||
|
{ id: 'linkspin', name: 'LinkSpin', url: 'https://linkspin.app' },
|
||||||
|
{ id: 'dlb', name: 'Downline Banners', url: 'https://downlinebanners.com' },
|
||||||
|
{ id: 'vbb', name: 'Viral Banner Blitz', url: 'https://viralbannerblitz.com' },
|
||||||
|
{ id: 'stackpol', name: 'Stack POL', url: 'https://stackpol.com' },
|
||||||
|
{ id: 'earnerscorner', name: 'Earners Corner', url: 'https://earnerscorner.com' }
|
||||||
|
];
|
||||||
|
const TTL = 10 * 60 * 1000;
|
||||||
|
let cache = { at: 0, list: FALLBACK, from: 'fallback' };
|
||||||
|
let inflight = null;
|
||||||
|
|
||||||
|
const hubUrl = () => String(process.env.HUB_URL || 'https://hub.saasy.top').trim().replace(/\/+$/, '');
|
||||||
|
function clean(list) {
|
||||||
|
if (!Array.isArray(list)) return null;
|
||||||
|
const ok = list.filter(s => s && typeof s.name === 'string' && /^https:\/\/[a-z0-9.-]+(\/[^\s"'<>]*)?$/i.test(String(s.url || '')))
|
||||||
|
.slice(0, 30).map(s => ({ id: String(s.id || s.name).toLowerCase().replace(/[^a-z0-9]+/g, '').slice(0, 30), name: String(s.name).slice(0, 60), url: String(s.url).replace(/\/+$/, '') }));
|
||||||
|
return ok.length ? ok : null;
|
||||||
|
}
|
||||||
|
function refresh() {
|
||||||
|
if (inflight || process.env.NETWORK_SITES_HUB === '0') return inflight;
|
||||||
|
const ac = new AbortController(); const t = setTimeout(() => ac.abort(), 2500);
|
||||||
|
inflight = fetch(hubUrl() + '/v1/network-sites', { signal: ac.signal })
|
||||||
|
.then(r => (r.ok ? r.json() : null))
|
||||||
|
.then(j => { const l = clean(j); if (l) cache = { at: Date.now(), list: l, from: 'hub' }; else cache.at = Date.now(); })
|
||||||
|
.catch(() => { cache.at = Date.now() - TTL + 60 * 1000; }) // hub down: try again in a minute, keep the last good list
|
||||||
|
.finally(() => { clearTimeout(t); inflight = null; });
|
||||||
|
return inflight;
|
||||||
|
}
|
||||||
|
function list() { if (Date.now() - cache.at > TTL) refresh(); return cache.list; }
|
||||||
|
// Tracked links (Marty 2026-11-14: "make sure each of these sites is its own traffic source and link spun so we can track it"): each
|
||||||
|
// entry also gets go = the LinkSpin network link for that site with ?src=<this site>, so a click shows in LinkSpin Reports under the
|
||||||
|
// site that sent it (LinkSpin netlinks.js: fixed codes on the admin account). This site = NETWORK_SITE_ID, else the request host.
|
||||||
|
// No go for this site itself, or when this site cannot be told (a test host): the page then uses the plain url.
|
||||||
|
const CODES = { iap: 'nwiap', linkspin: 'nwls', dlb: 'nwdlb', vbb: 'nwvbb', stackpol: 'nwsp', earnerscorner: 'nwec' };
|
||||||
|
const linksBase = () => String(process.env.NETWORK_LINKS_BASE || 'https://linkspin.app').trim().replace(/\/+$/, '');
|
||||||
|
const hostOf = u => { try { return new URL(u).hostname.toLowerCase().replace(/^www\./, ''); } catch (e) { return ''; } };
|
||||||
|
function selfId(req, l) {
|
||||||
|
const env = String(process.env.NETWORK_SITE_ID || '').trim().toLowerCase(); if (env) return env;
|
||||||
|
const h = String((req && req.headers && (req.headers['x-forwarded-host'] || req.headers.host)) || '').split(',')[0].trim().toLowerCase().replace(/:\d+$/, '').replace(/^www\./, '');
|
||||||
|
const m = h && (l || list()).find(s => hostOf(s.url) === h); return m ? m.id : '';
|
||||||
|
}
|
||||||
|
// the LinkSpin-tracked link to site `id` sent from site `from` (from = id: the site's own promo kit); extra = { s1: member username, s2: one path segment }
|
||||||
|
function tracked(id, from, extra) {
|
||||||
|
const code = CODES[id]; if (!code || !from) return '';
|
||||||
|
const q = new URLSearchParams({ src: from }); for (const [k, v] of Object.entries(extra || {})) if (v) q.set(k, String(v));
|
||||||
|
return linksBase() + '/r/' + code + '?' + q.toString();
|
||||||
|
}
|
||||||
|
function withGo(l, me) { return l.map(s => { const go = me && s.id !== me ? tracked(s.id, me) : ''; return go ? Object.assign({}, s, { go }) : s; }); }
|
||||||
|
// GET /api/network-sites: public, cacheable, the same answer on every page
|
||||||
|
function handle(req, res) {
|
||||||
|
const l = list();
|
||||||
|
res.writeHead(200, { 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'public, max-age=300', 'X-Content-Type-Options': 'nosniff' });
|
||||||
|
res.end(JSON.stringify(withGo(l, selfId(req, l))));
|
||||||
|
}
|
||||||
|
module.exports = { list, handle, refresh, tracked, selfId, withGo, CODES, FALLBACK, _state: () => cache };
|
||||||
+230
@@ -0,0 +1,230 @@
|
|||||||
|
// Network sign-in between InstantAdPay and LinkSpin (Marty approved 2026-11-12). The SAME file ships in both repos; each
|
||||||
|
// server calls init({ self, peer, peerBase, ... hooks }) and hands every request to handle() before its own routes.
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
// 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.
|
||||||
|
// 3. R GET /sso/in?t=<token> R checks signature, audience, expiry (60 s), the state against its cookie
|
||||||
|
// (so nobody can push their own token into someone else's browser), and spends
|
||||||
|
// the nonce (a second use is refused). The email must already be a member
|
||||||
|
// here; then R makes an ordinary session and redirects to the relative path.
|
||||||
|
// 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),
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
// Wallet sites (Downline Banners, 2026-11-13, Marty: "sign in once and be logged into all these sites"). Downline Banners has no email
|
||||||
|
// accounts; its members are wallets. IAP and LinkSpin list it under `wallets: { bannerline: base }` and vouch one way: /go/bannerline
|
||||||
|
// and /sso/check?r=bannerline mint a token that also carries the member's wallet (the one they signed in with, else the main wallet
|
||||||
|
// their account linked by signature) and username. Downline Banners runs this file with `from: { iap, linkspin }`, accepts a token from
|
||||||
|
// either, and makes a session for that wallet. /sso/start?via=<site> picks which site to ask; old copies ignore the new parameters.
|
||||||
|
'use strict';
|
||||||
|
const crypto = require('crypto');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const SECRET = () => String(process.env.NETWORK_SSO_SECRET || '').trim();
|
||||||
|
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', 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 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,
|
||||||
|
// wallets?: { site: base() } + wallet(session) -> { address, name }, from?: { site: base() } }
|
||||||
|
|
||||||
|
const b64u = buf => Buffer.from(buf).toString('base64').replace(/=+$/, '').replace(/\+/g, '-').replace(/\//g, '_');
|
||||||
|
const unb64u = s => Buffer.from(String(s).replace(/-/g, '+').replace(/_/g, '/'), 'base64');
|
||||||
|
const mac = s => crypto.createHmac('sha256', SECRET()).update('nsso.v1.' + s).digest();
|
||||||
|
const mask = e => String(e || '').replace(/^(.).*(@.*)$/, '$1***$2');
|
||||||
|
const log = (what, email, extra) => console.log('network-sso', what, email ? mask(email) : '-', extra || '');
|
||||||
|
|
||||||
|
// a same-site relative path, or the default. No scheme, no host, no protocol-relative //x, no backslashes, no control characters.
|
||||||
|
function safePath(to, dflt) {
|
||||||
|
const d = dflt == null ? '/' : dflt;
|
||||||
|
const s = String(to == null ? '' : to);
|
||||||
|
if (!s || s.length > 600 || s[0] !== '/' || s[1] === '/' || s[1] === '\\' || /[\\\u0000-\u001f\u007f\s]/.test(s)) return d;
|
||||||
|
try { const x = new URL(s, 'http://x.invalid'); if (x.host !== 'x.invalid' || x.protocol !== 'http:') return d; return x.pathname + x.search + x.hash; } catch (e) { return d; }
|
||||||
|
}
|
||||||
|
|
||||||
|
function mint(o) {
|
||||||
|
const now = o.now || Date.now();
|
||||||
|
const t = { iss: o.iss, aud: o.aud, email: String(o.email || '').trim().toLowerCase(), st: o.st, to: safePath(o.to), iat: now, exp: now + TTL, n: crypto.randomBytes(16).toString('hex') };
|
||||||
|
if (o.wallet) t.wallet = String(o.wallet).toLowerCase();
|
||||||
|
if (o.name) t.name = String(o.name).slice(0, 40);
|
||||||
|
const body = b64u(JSON.stringify(t));
|
||||||
|
return 'v1.' + body + '.' + b64u(mac(body));
|
||||||
|
}
|
||||||
|
|
||||||
|
// -> { ok, email, to, n, exp } or { error: reason }
|
||||||
|
function verify(tok, o) {
|
||||||
|
if (!enabled()) return { error: 'off' };
|
||||||
|
const m = /^v1\.([A-Za-z0-9_-]{20,2000})\.([A-Za-z0-9_-]{43})$/.exec(String(tok || ''));
|
||||||
|
if (!m) return { error: 'malformed' };
|
||||||
|
const want = mac(m[1]), got = unb64u(m[2]);
|
||||||
|
if (want.length !== got.length || !crypto.timingSafeEqual(want, got)) return { error: 'signature' };
|
||||||
|
let p; try { p = JSON.parse(unb64u(m[1]).toString('utf8')); } catch (e) { return { error: 'malformed' }; }
|
||||||
|
const now = (o && o.now) || Date.now();
|
||||||
|
if (!p || p.aud !== o.aud || ![].concat(o.iss).includes(p.iss)) return { error: 'audience' };
|
||||||
|
if (!(Number(p.exp) > now) || Number(p.iat) > now + SKEW || Number(p.exp) - Number(p.iat) > TTL) return { error: 'expired' };
|
||||||
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(String(p.email || ''))) return { error: 'email' };
|
||||||
|
if (!/^[a-f0-9]{32}$/.test(String(p.n || ''))) return { error: 'malformed' };
|
||||||
|
const st = String((o && o.st) || '');
|
||||||
|
if (!/^[a-f0-9]{32}$/.test(st) || !/^[a-f0-9]{32}$/.test(String(p.st || '')) || !crypto.timingSafeEqual(Buffer.from(st), Buffer.from(p.st))) return { error: 'state' };
|
||||||
|
if (p.wallet != null && !WALLET_RE.test(String(p.wallet))) return { error: 'wallet' };
|
||||||
|
const name = p.name != null && /^[A-Za-z0-9_.-]{1,40}$/.test(String(p.name)) ? String(p.name) : null;
|
||||||
|
return { ok: true, iss: p.iss, email: String(p.email).toLowerCase(), wallet: p.wallet || null, name, to: safePath(p.to), n: p.n, exp: Number(p.exp) };
|
||||||
|
}
|
||||||
|
|
||||||
|
// single use: true the first time a nonce is spent. MySQL when the site runs on it (two app copies during a deploy share it),
|
||||||
|
// else memory + a small file in DATA_DIR (survives a restart inside the 60-second window).
|
||||||
|
const used = new Map(); let fileLoaded = false, tableReady = null;
|
||||||
|
const FILE = () => C && C.dataDir ? path.join(C.dataDir, 'network-sso-nonces.json') : null;
|
||||||
|
function prune(now) { for (const [k, exp] of used) if (exp < now) used.delete(k); }
|
||||||
|
function loadFile() {
|
||||||
|
if (fileLoaded) return; fileLoaded = true;
|
||||||
|
try { const o = JSON.parse(fs.readFileSync(FILE(), 'utf8')); for (const k of Object.keys(o)) used.set(k, Number(o[k])); } catch (e) {}
|
||||||
|
}
|
||||||
|
function saveFile() { const f = FILE(); if (!f) return; try { fs.writeFileSync(f + '.tmp', JSON.stringify(Object.fromEntries(used))); fs.renameSync(f + '.tmp', f); } catch (e) { console.error('network-sso nonce save', e.message); } }
|
||||||
|
async function spend(n, exp) {
|
||||||
|
const now = Date.now(); loadFile(); prune(now);
|
||||||
|
if (used.has(n)) return false;
|
||||||
|
used.set(n, Number(exp) + SKEW); saveFile();
|
||||||
|
const db = C && C.db;
|
||||||
|
if (db && db.enabled && db.enabled()) {
|
||||||
|
try {
|
||||||
|
if (!tableReady) tableReady = db.q('CREATE TABLE IF NOT EXISTS network_sso_nonces (n VARCHAR(40) PRIMARY KEY, exp BIGINT NOT NULL) ENGINE=InnoDB').catch(e => { tableReady = null; throw e; });
|
||||||
|
await tableReady;
|
||||||
|
await db.q('INSERT INTO network_sso_nonces (n, exp) VALUES (?, ?)', [n, Number(exp) + SKEW]);
|
||||||
|
if (Math.random() < 0.05) db.q('DELETE FROM network_sso_nonces WHERE exp < ?', [now]).catch(() => {});
|
||||||
|
} catch (e) { if (/duplicate/i.test(e.message || '') || e.code === 'ER_DUP_ENTRY') return false; console.error('network-sso nonce db', e.message); return false; } // fail closed
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// crawlers, link previews and headless browsers never bounce
|
||||||
|
const BOT_RE = /bot|crawl|spider|slurp|preview|facebookexternalhit|embedly|quora link|whatsapp|telegram|discord|skype|curl|wget|python|httpclient|headless|lighthouse|pingdom|monitor|go-http|java\/|okhttp|axios|node-fetch|undici/i;
|
||||||
|
const isBot = req => { const ua = String(req.headers['user-agent'] || ''); return !ua || BOT_RE.test(ua); };
|
||||||
|
// only a real top-level page load may start a bounce (sec-fetch-dest is sent by every current browser)
|
||||||
|
const notPage = req => { const d = req.headers['sec-fetch-dest']; return !!d && d !== 'document'; };
|
||||||
|
|
||||||
|
function cookies(req) {
|
||||||
|
const out = {};
|
||||||
|
for (const p of String(req.headers.cookie || '').split(';')) { const i = p.indexOf('='); if (i > 0) { try { out[p.slice(0, i).trim()] = decodeURIComponent(p.slice(i + 1).trim()); } catch (e) {} } }
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
const ck = (k, v, age, httpOnly) => k + '=' + encodeURIComponent(v) + '; Path=/; SameSite=Lax; Max-Age=' + age + (httpOnly ? '; HttpOnly' : '') + (C && C.isProd ? '; Secure' : '');
|
||||||
|
const go = (res, loc, set) => { const h = { Location: loc, 'Cache-Control': 'no-store', 'Referrer-Policy': 'no-referrer', 'X-Robots-Tag': 'noindex' }; if (set && set.length) h['Set-Cookie'] = set; res.writeHead(302, h); res.end(); return true; };
|
||||||
|
const sendJson = (res, obj, set) => { const h = { 'Content-Type': 'application/json', 'Cache-Control': 'no-store' }; if (set && set.length) h['Set-Cookie'] = set; res.writeHead(200, h); res.end(JSON.stringify(obj)); return true; };
|
||||||
|
|
||||||
|
function init(opts) { C = Object.assign({ defaultPath: '/' }, opts); fileLoaded = false; used.clear(); }
|
||||||
|
|
||||||
|
// the cookie a sign-out adds: no silent check on this site for 12 hours (a deliberate cross-site link still signs in)
|
||||||
|
const offCookie = () => ck('nsso.off', '1', OFF_AGE, true);
|
||||||
|
|
||||||
|
// -> true when the request was one of ours and has been answered
|
||||||
|
async function handle(req, res, u) {
|
||||||
|
if (!C || req.method !== 'GET') return false;
|
||||||
|
const p = u.pathname;
|
||||||
|
const peerName = NAMES[C.peer] || C.peer;
|
||||||
|
const goTo = p.startsWith('/go/') ? p.slice(4) : '';
|
||||||
|
const walletBase = x => (C.wallets && Object.prototype.hasOwnProperty.call(C.wallets, x) ? C.wallets[x] : null);
|
||||||
|
if (goTo && (goTo === C.peer || walletBase(goTo))) {
|
||||||
|
const base = goTo === C.peer ? C.peerBase() : walletBase(goTo)();
|
||||||
|
const to = safePath(u.searchParams.get('to'), '/');
|
||||||
|
const plain = base + to;
|
||||||
|
if (!enabled() || isBot(req)) return go(res, plain);
|
||||||
|
let s = null; try { s = await C.member(req); } catch (e) {}
|
||||||
|
if (!s || !s.email) return go(res, plain);
|
||||||
|
if (goTo !== C.peer) { let w = null; try { w = await C.wallet(s); } catch (e) {} if (!w || !w.address) return go(res, plain); } // no wallet to vouch for: a plain link
|
||||||
|
return go(res, base + '/sso/start?mode=go' + (goTo === C.peer ? '' : '&via=' + C.self) + '&to=' + encodeURIComponent(to));
|
||||||
|
}
|
||||||
|
if (p === '/sso/start') {
|
||||||
|
const to = safePath(u.searchParams.get('to'), C.defaultPath);
|
||||||
|
const mode = u.searchParams.get('mode') === 'go' ? 'go' : 'check';
|
||||||
|
const via = String(u.searchParams.get('via') || '');
|
||||||
|
const from = C.from && Object.prototype.hasOwnProperty.call(C.from, via) ? C.from[via] : null; // a wallet site may ask either provider
|
||||||
|
if (!enabled() || isBot(req) || notPage(req)) return go(res, to);
|
||||||
|
let s = null; try { s = await C.member(req); } catch (e) {}
|
||||||
|
if (s && (s.email || s.address)) return go(res, to); // already signed in here
|
||||||
|
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, 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) + (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') || '');
|
||||||
|
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
|
||||||
|
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);
|
||||||
|
let s = null; try { s = await C.member(req); } catch (e) {}
|
||||||
|
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);
|
||||||
|
return go(res, base + '/sso/in?t=' + mint({ iss: C.self, aud, email: s.email, wallet: w && w.address, name: w && w.name, st, to }));
|
||||||
|
}
|
||||||
|
if (p === '/sso/in') {
|
||||||
|
const c = cookies(req);
|
||||||
|
const set = [ck('nsso.st', '', 0, true)];
|
||||||
|
if (u.searchParams.get('none')) { log('none: not signed in on ' + peerName); return go(res, C.signinPath(safePath(u.searchParams.get('to'), C.defaultPath)), set); }
|
||||||
|
const v = verify(u.searchParams.get('t'), { iss: [C.peer].concat(Object.keys(C.from || {})), aud: C.self, st: c['nsso.st'] });
|
||||||
|
if (v.error) { log('refused: ' + v.error); return go(res, C.signinPath(C.defaultPath), set); }
|
||||||
|
if (!(await spend(v.n, v.exp))) { log('refused: token already used', v.email); return go(res, C.signinPath(v.to), set); }
|
||||||
|
let a = null; try { a = await C.accept(v.email, req, v); } catch (e) { a = { fallback: 'error ' + e.message }; }
|
||||||
|
if (!a || !a.ok) { // not a member here yet (or not allowed to sign in): the normal email-code sign-in, email filled in
|
||||||
|
log('fallback to email code: ' + ((a && a.fallback) || 'not accepted'), v.email);
|
||||||
|
set.push(ck('nsso.hint', v.email, HINT_AGE, true));
|
||||||
|
return go(res, C.signinPath(v.to), set);
|
||||||
|
}
|
||||||
|
let cookie = null; try { cookie = await C.signIn(v.email, req, v); } catch (e) { console.error('network-sso sign-in', e.message); }
|
||||||
|
if (!cookie) { log('fallback to email code: session not made', v.email); return go(res, C.signinPath(v.to), set); }
|
||||||
|
set.push(cookie); if (c['nsso.off']) set.push(ck('nsso.off', '', 0, true));
|
||||||
|
log('signed in from ' + (NAMES[v.iss] || peerName), v.email);
|
||||||
|
return go(res, C.landing(v.to === '/' ? C.defaultPath : v.to), set); // no page named: the dashboard, not the public home page (2026-11-13)
|
||||||
|
}
|
||||||
|
if (p === '/api/sso/status') {
|
||||||
|
const c = cookies(req); const set = [];
|
||||||
|
let s = null; try { s = await C.member(req); } catch (e) {}
|
||||||
|
const signedIn = !!(s && (s.email || s.address));
|
||||||
|
const out = { peer: peerName, check: enabled() && !signedIn && !isBot(req) && !c['nsso.tried'] && !c['nsso.off'] };
|
||||||
|
if (c['nsso.hint']) { if (!signedIn) out.hint = c['nsso.hint']; set.push(ck('nsso.hint', '', 0, true)); }
|
||||||
|
return sendJson(res, out, set);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 };
|
||||||
+4
-3
@@ -7,7 +7,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
<style>
|
<style>
|
||||||
.adm-table{width:100%;table-layout:auto}
|
.adm-table{width:100%;table-layout:auto}
|
||||||
.adm-table th{cursor:pointer;user-select:none;white-space:nowrap}
|
.adm-table th{cursor:pointer;user-select:none;white-space:nowrap}
|
||||||
@@ -270,6 +270,7 @@
|
|||||||
<button type="button" class="btn small sec" data-mcact="sponsor">Set sponsor</button>
|
<button type="button" class="btn small sec" data-mcact="sponsor">Set sponsor</button>
|
||||||
<button type="button" class="btn small sec" data-mcact="wallet">Swap main wallet</button>
|
<button type="button" class="btn small sec" data-mcact="wallet">Swap main wallet</button>
|
||||||
<button type="button" class="btn small sec" data-mcact="credits">Grant credits</button>
|
<button type="button" class="btn small sec" data-mcact="credits">Grant credits</button>
|
||||||
|
<button type="button" class="btn small sec" data-mcact="message">Message (inbox + email)</button>
|
||||||
<a class="btn small sec" id="mcWall" href="#" target="_blank" rel="noopener">Public wall</a>
|
<a class="btn small sec" id="mcWall" href="#" target="_blank" rel="noopener">Public wall</a>
|
||||||
<button type="button" class="btn small sec" data-mcact="delete" style="margin-left:auto">Delete account</button>
|
<button type="button" class="btn small sec" data-mcact="delete" style="margin-left:auto">Delete account</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -651,8 +652,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||||
<script src="/assets/admin-kb.js?v=20261020kb"></script>
|
<script src="/assets/admin-kb.js?v=20261020kb"></script>
|
||||||
<script src="/assets/admin.js?v=20261101th"></script><script src="/assets/admin-sponsorcheck.js?v=20261022sc"></script><script src="/assets/admin-kits.js?v=20261101th"></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>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
||||||
const day = ts => ts ? new Date(Number(ts)).toLocaleString([], { year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) : '';
|
const day = ts => ts ? new Date(Number(ts)).toLocaleString([], { year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) : '';
|
||||||
const say = (m, k) => { try { IAP.status(m, k); } catch (e) {} };
|
const say = (m, k) => { try { IAP.status(m, k); } catch (e) {} };
|
||||||
const HOW = { adopt: 'adopted from the tank', rescue: 'rescued to the tank', release: 'released to the tank', expire: 'adoption window ended', admin: 'admin edit' };
|
const HOW = { adopt: 'adopted from the tank', rescue: 'rescued to the tank', release: 'released to the tank', expire: 'adoption window ended', admin: 'admin edit', invited: 'the member named who invited them' };
|
||||||
const NAME = { instantadpay: 'InstantAdPay', linkspin: 'LinkSpin' };
|
const NAME = { instantadpay: 'InstantAdPay', linkspin: 'LinkSpin' };
|
||||||
function side(f) {
|
function side(f) {
|
||||||
if (!f) return '<span class="muted">no account</span>';
|
if (!f) return '<span class="muted">no account</span>';
|
||||||
|
|||||||
+44
-4
@@ -299,10 +299,10 @@
|
|||||||
$('tankAdmSub').textContent = r.waiting.length + ' waiting' + (nReady ? ' (' + nReady + ' ready to activate)' : '') + ' · cap ' + r.cap + ' open per adopter · ' + r.ttlDays + '-day window · ready members held ' + (r.holdHours || 24) + ' h, then auto-assigned in rotation';
|
$('tankAdmSub').textContent = r.waiting.length + ' waiting' + (nReady ? ' (' + nReady + ' ready to activate)' : '') + ' · cap ' + r.cap + ' open per adopter · ' + r.ttlDays + '-day window · ready members held ' + (r.holdHours || 24) + ' h, then auto-assigned in rotation';
|
||||||
// ready = wallet linked: activation is held (never the company) until someone adopts them or the 24-hour safety net assigns them (2026-10-27)
|
// ready = wallet linked: activation is held (never the company) until someone adopts them or the 24-hour safety net assigns them (2026-10-27)
|
||||||
const left = w => { const ms = (w.holdUntil || 0) - Date.now(); if (ms <= 0) return 'assigning now'; const m = Math.round(ms / 60000); return (m >= 60 ? Math.floor(m / 60) + ' h ' + (m % 60) + ' min' : m + ' min') + ' left'; };
|
const left = w => { const ms = (w.holdUntil || 0) - Date.now(); if (ms <= 0) return 'assigning now'; const m = Math.round(ms / 60000); return (m >= 60 ? Math.floor(m / 60) + ' h ' + (m % 60) + ' min' : m + ' min') + ' left'; };
|
||||||
const rb = w => w.ready ? ' <span class="badge" style="background:var(--ok-soft);border-color:var(--ok);color:var(--ok)">Ready to activate · ' + left(w) + '</span>' : '';
|
const rb = w => (w.opensAt > Date.now() ? ' <span class="badge amber" title="New sign-up: hand adoption opens 24 hours after they joined">Opens ' + when(w.opensAt) + '</span>' : '') + (w.ready ? ' <span class="badge" style="background:var(--ok-soft);border-color:var(--ok);color:var(--ok)">Ready to activate · ' + left(w) + '</span>' : '');
|
||||||
$('tankWait').innerHTML = '<tr><th>Waiting</th><th>Email</th><th>Joined</th><th>Last sign-in</th></tr>' + (r.waiting.length ? r.waiting.map(w => '<tr><td>' + esc(w.name) + rb(w) + '</td><td>' + esc(w.email) + '</td><td class="when">' + when(w.joined) + '</td><td class="when">' + (w.lastSeen ? when(w.lastSeen) : '<span class="muted">never</span>') + '</td></tr>').join('') : '<tr><td colspan="4" class="muted">empty</td></tr>')
|
$('tankWait').innerHTML = '<tr><th>Waiting</th><th>Email</th><th>Joined</th><th>Last sign-in</th></tr>' + (r.waiting.length ? r.waiting.map(w => '<tr><td>' + esc(w.name) + rb(w) + '</td><td>' + esc(w.email) + '</td><td class="when">' + when(w.joined) + '</td><td class="when">' + (w.lastSeen ? when(w.lastSeen) : '<span class="muted">never</span>') + '</td></tr>').join('') : '<tr><td colspan="4" class="muted">empty</td></tr>')
|
||||||
+ ((r.aligned || []).length ? '<tr><th colspan="4">Aligned to their network sponsor (LinkSpin) instead of the tank</th></tr>' + r.aligned.slice(0, 15).map(x => '<tr><td>' + esc(x.email) + '</td><td>' + esc(x.toName || x.to) + '</td><td class="when">' + when(x.at) + '</td><td class="muted">' + esc(x.via || '') + '</td></tr>').join('') : '');
|
+ ((r.aligned || []).length ? '<tr><th colspan="4">Aligned to their network sponsor (LinkSpin) instead of the tank</th></tr>' + r.aligned.slice(0, 15).map(x => '<tr><td>' + esc(x.email) + '</td><td>' + esc(x.toName || x.to) + '</td><td class="when">' + when(x.at) + '</td><td class="muted">' + esc(x.via || '') + '</td></tr>').join('') : '');
|
||||||
$('tankAdopt').innerHTML = '<tr><th>Member</th><th>Adopted by</th><th>When</th><th>Window ends</th><th>Status</th></tr>' + (r.adoptions.length ? r.adoptions.map(a => '<tr><td>' + esc(a.adopteeName) + '</td><td>' + esc(a.adopterName) + '</td><td class="when">' + when(a.ts) + '</td><td class="when">' + (a.status === 'released' ? '' : when(a.expires)) + '</td><td>' + esc(a.status) + '</td></tr>').join('') : '<tr><td colspan="5" class="muted">none yet</td></tr>');
|
$('tankAdopt').innerHTML = '<tr><th>Member</th><th>Adopted by</th><th>When</th><th>Window ends</th><th>Status</th></tr>' + (r.adoptions.length ? r.adoptions.map(a => '<tr><td>' + esc(a.adopteeName) + '</td><td>' + esc(a.adopterName) + '</td><td class="when">' + when(a.ts) + '</td><td class="when">' + (a.status === 'released' || a.status === 'invited' ? '' : when(a.expires)) + '</td><td>' + esc(a.status) + '</td></tr>').join('') : '<tr><td colspan="5" class="muted">none yet</td></tr>');
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
async function loadMembers() {
|
async function loadMembers() {
|
||||||
@@ -544,6 +544,14 @@
|
|||||||
if (act === 'sponsor') { const v = await IAP.ask({ title: 'Sponsor for ' + (a.username ? '@' + a.username : a.email), text: 'Username, share code or member #. Blank = no sponsor (company). Re-points free referrals and future purchases; on-chain sponsorship never changes.', value: a.sponsorRef || '', ok: 'Save' }); if (v === null || v === undefined) return; body = { sponsorRef: v }; }
|
if (act === 'sponsor') { const v = await IAP.ask({ title: 'Sponsor for ' + (a.username ? '@' + a.username : a.email), text: 'Username, share code or member #. Blank = no sponsor (company). Re-points free referrals and future purchases; on-chain sponsorship never changes.', value: a.sponsorRef || '', ok: 'Save' }); if (v === null || v === undefined) return; body = { sponsorRef: v }; }
|
||||||
if (act === 'wallet') { const v = await IAP.ask({ title: 'Main wallet for ' + a.email, text: 'Paste the 0x address that should be their main wallet (the one that paid, if a purchase came from an unlinked account). The member number is re-read from the chain. Blank = unlink.', value: a.address || '', ok: 'Swap' }); if (v === null || v === undefined) return; if (!await IAP.confirmBox('Swap the main wallet for ' + a.email + ' to ' + (v.trim() || 'nothing') + '?', { title: 'Sure?', ok: 'Swap it', cancel: 'Cancel' })) return; body = { address: v }; }
|
if (act === 'wallet') { const v = await IAP.ask({ title: 'Main wallet for ' + a.email, text: 'Paste the 0x address that should be their main wallet (the one that paid, if a purchase came from an unlinked account). The member number is re-read from the chain. Blank = unlink.', value: a.address || '', ok: 'Swap' }); if (v === null || v === undefined) return; if (!await IAP.confirmBox('Swap the main wallet for ' + a.email + ' to ' + (v.trim() || 'nothing') + '?', { title: 'Sure?', ok: 'Swap it', cancel: 'Cancel' })) return; body = { address: v }; }
|
||||||
if (act === 'credits') { const v = await IAP.ask({ title: 'Grant credits to ' + (a.username ? '@' + a.username : a.email), text: 'Whole number of earned-pool credits (1 credit = 1 cent of delivery). They can spend them on campaigns right away.', type: 'number', value: '', placeholder: '250', ok: 'Grant' }); if (!v) return; const note = await IAP.ask({ title: 'Reason (kept in the server log)', value: '', placeholder: 'e.g. refund for broken banner', ok: 'Grant' }); body = { grantCredits: v, note: note || '' }; }
|
if (act === 'credits') { const v = await IAP.ask({ title: 'Grant credits to ' + (a.username ? '@' + a.username : a.email), text: 'Whole number of earned-pool credits (1 credit = 1 cent of delivery). They can spend them on campaigns right away.', type: 'number', value: '', placeholder: '250', ok: 'Grant' }); if (!v) return; const note = await IAP.ask({ title: 'Reason (kept in the server log)', value: '', placeholder: 'e.g. refund for broken banner', ok: 'Grant' }); body = { grantCredits: v, note: note || '' }; }
|
||||||
|
// message the member (Marty 2026-11-12): lands in their member inbox AND emails them (opt-outs honoured by the mailer)
|
||||||
|
if (act === 'message') {
|
||||||
|
const who = a.username ? '@' + a.username : a.email;
|
||||||
|
const subject = await IAP.ask({ title: 'Message ' + who, text: 'Subject line. The message goes to their member inbox and is emailed to them (unless they unsubscribed from email).', value: '', placeholder: 'A quick note from Marty', ok: 'Next' }); if (!subject) return;
|
||||||
|
const text = await IAP.ask({ title: subject, text: 'Your message. Plain text; blank lines start new paragraphs.', type: 'textarea', value: '', ok: 'Send' }); if (!text || !text.trim()) return;
|
||||||
|
const r = await api('/api/admin/member/message', { email: a.email, subject, text }, 'POST');
|
||||||
|
IAP.status('Sent to ' + who + "'s inbox" + (r.emailed ? ' and emailed.' : r.emailSkipped ? '. Email skipped: ' + r.emailSkipped + '.' : '.'), r.emailed ? 'ok' : 'warn'); return;
|
||||||
|
}
|
||||||
if (act === 'delete') {
|
if (act === 'delete') {
|
||||||
if (a.memberId) { IAP.status('Registered members cannot be deleted; their position is on-chain.', 'bad'); return; }
|
if (a.memberId) { IAP.status('Registered members cannot be deleted; their position is on-chain.', 'bad'); return; }
|
||||||
if (!await IAP.confirmBox('Delete the free account ' + a.email + '? Their sign-in, referrals link and credits go away. There is no undo.', { title: 'Delete account', ok: 'Delete', cancel: 'Keep it' })) return;
|
if (!await IAP.confirmBox('Delete the free account ' + a.email + '? Their sign-in, referrals link and credits go away. There is no undo.', { title: 'Delete account', ok: 'Delete', cancel: 'Keep it' })) return;
|
||||||
@@ -1137,7 +1145,8 @@
|
|||||||
loginCreditsPerDay: ['Login ad: credits per day', 'flat daily charge while active'],
|
loginCreditsPerDay: ['Login ad: credits per day', 'flat daily charge while active'],
|
||||||
loginDwellSeconds: ['Login ad: seconds shown', 'full-screen interstitial after sign-in'],
|
loginDwellSeconds: ['Login ad: seconds shown', 'full-screen interstitial after sign-in'],
|
||||||
burnBatchMin: ['On-chain burn batch (credits)', 'accrued spend is burned once it reaches this'],
|
burnBatchMin: ['On-chain burn batch (credits)', 'accrued spend is burned once it reaches this'],
|
||||||
synRateDivisor: ['Network rate divisor (N)', 'Network Ad Space views and PassiveDrip visits cost 1/N of the on-site rate; 1 = same rate as on-site; whole numbers'],
|
synRateDivisor: ['Network rate divisor (N)', 'Network Ad Space banner views and PassiveDrip visits cost 1/N of the on-site rate; 1 = same rate as on-site; whole numbers'],
|
||||||
|
synRateDivisorText: ['Network rate divisor for TEXT ads (N)', 'Network Ad Space text-ad views cost 1/N of the on-site text rate (10 = 1 credit per 100 network views); whole numbers'],
|
||||||
welcomeCredits: ['Welcome credits', 'granted after the welcome tour'],
|
welcomeCredits: ['Welcome credits', 'granted after the welcome tour'],
|
||||||
dailyViewTarget: ['Daily view set (ads)', 'ads a member views for the daily claim'],
|
dailyViewTarget: ['Daily view set (ads)', 'ads a member views for the daily claim'],
|
||||||
dailyClaimCredits: ['Daily claim (credits)', 'paid when the set is complete'],
|
dailyClaimCredits: ['Daily claim (credits)', 'paid when the set is complete'],
|
||||||
@@ -1276,6 +1285,35 @@
|
|||||||
// Tier test and preview (2026-10-25, Marty): the member Games card shows the admin exactly what a member sees, so every tier test lives
|
// Tier test and preview (2026-10-25, Marty): the member Games card shows the admin exactly what a member sees, so every tier test lives
|
||||||
// here. Every action touches ONLY the signed-in admin's own account; a test buy opens the same waiting order a member gets (a fresh
|
// here. Every action touches ONLY the signed-in admin's own account; a test buy opens the same waiting order a member gets (a fresh
|
||||||
// package on /my fulfils it, sponsors paid as usual), a test comp starts the tier at once with no sale recorded.
|
// package on /my fulfils it, sponsors paid as usual), a test comp starts the tier at once with no sale recorded.
|
||||||
|
// Shards of Valor bonus heroes (2026-11-05, Marty approved): sold ONE TIME. The same test path as the tiers, on the admin's own account:
|
||||||
|
// a test buy opens the real waiting order (a fresh $20 / $50 package on /my fulfils it), Give grants it at once as comped, Remove takes it back.
|
||||||
|
function heroTestHtml(H) {
|
||||||
|
if (!H || !H.items) return '';
|
||||||
|
const row = (key, name, sub, usd, pkg, owned, waiting, free) => '<div class="gpt-tier' + (owned ? ' on' : '') + '"><h4>' + esc(name) + '</h4><p class="small muted" style="margin:0 0 4px">' + esc(sub) + '</p>'
|
||||||
|
+ '<p class="gpt-price">' + (free ? 'Free for everyone' : '$' + usd + ' <span class="small muted">one time, the $' + pkg + ' package</span>') + '</p>'
|
||||||
|
+ '<p class="small" style="margin:4px 0">' + (owned ? '<b>Your account: owned</b>' : waiting ? '<b>Your account: test order waiting for a $' + pkg + ' package</b>' : 'Your account: not owned') + '</p><div class="gpt-acts">'
|
||||||
|
+ (free || owned ? '' : waiting ? '<a class="btn small" href="/my?from=heroes#buy" target="_blank" rel="noopener">Buy the $' + pkg + ' package on /my</a><button class="btn small sec" type="button" data-ht-cancel="' + key + '">Cancel test order</button>' : '<button class="btn small" type="button" data-ht-buy="' + key + '">Test buy (real order, $' + pkg + ' package)</button>')
|
||||||
|
+ (owned || free ? '' : '<button class="btn small sec" type="button" data-ht-comp="' + key + '">Give my account ' + esc(name.split(' ')[0]) + ' now (test)</button>')
|
||||||
|
+ (owned && !free && key !== 'bundle' ? '<button class="btn small sec" type="button" data-ht-revoke="' + key + '">Remove from my account</button>' : '') + '</div></div>';
|
||||||
|
const B = H.bundle;
|
||||||
|
return '<h3 style="margin:16px 0 6px">Shards of Valor bonus heroes <span class="chip flat">' + (H.sale ? 'on sale: members see them' : 'hidden from members (heroSales off)') + '</span></h3>'
|
||||||
|
+ '<p class="muted" style="margin:0 0 8px">Sold one time, owned for good, paid by a fresh package like a pass (no credits). Prices, the free list and the bundle are settings: heroPrice<Name>Cents (0 = free for everyone), heroBundleHeroes, heroBundlePriceCents. heroBundleCap stays empty (the bundle is heroes only). Members see heroes only once <b>heroSales</b> is on.</p>'
|
||||||
|
+ '<div class="gpt-grid">' + H.items.map(i => row(i.key, i.name, i.blurb, i.usd, i.package, i.owned, i.waiting, i.free)).join('')
|
||||||
|
+ (B ? row('bundle', 'Hero bundle', B.names.join(', '), B.usd, B.package, B.owned, B.waiting, false) : '') + '</div>';
|
||||||
|
}
|
||||||
|
function wireHeroTest(box, g) {
|
||||||
|
const nm = k => k === 'bundle' ? 'the hero bundle' : ((g.heroes.items.find(i => i.key === k) || {}).name || k);
|
||||||
|
box.querySelectorAll('[data-ht-buy]').forEach(b => b.addEventListener('click', busy(b, async () => {
|
||||||
|
const k = b.dataset.htBuy; if (!(await IAP.confirmBox('Open a TEST order for ' + nm(k) + ' on your own account (' + g.email + ')? It is fulfilled when a fresh package of at least its price from one of your positions settles on chain. Members still cannot buy heroes while heroSales is off.', { title: 'Test buy: ' + nm(k), ok: 'Open the test order', cancel: 'Not now' }))) return;
|
||||||
|
const x = await api('/api/admin/heroes/test-buy', { hero: k }); IAP.status('Test order for ' + nm(k) + ' is waiting for a $' + x.package + ' package on ' + x.email + '.', 'ok'); await loadGpTest();
|
||||||
|
})));
|
||||||
|
box.querySelectorAll('[data-ht-cancel]').forEach(b => b.addEventListener('click', busy(b, async () => { const k = b.dataset.htCancel; await api('/api/admin/heroes/test-cancel', { hero: k }); IAP.status('Test order for ' + nm(k) + ' cancelled.', 'ok'); await loadGpTest(); })));
|
||||||
|
box.querySelectorAll('[data-ht-comp]').forEach(b => b.addEventListener('click', busy(b, async () => {
|
||||||
|
const k = b.dataset.htComp; if (!(await IAP.confirmBox('Give your own account ' + nm(k) + ' now, for testing? Recorded as comped (no sale); the game shows it the next time you sign in to it from /my Games.', { title: 'Test ' + nm(k), ok: 'Give it to me', cancel: 'Not now' }))) return;
|
||||||
|
await api('/api/admin/heroes/test-comp', { hero: k }); IAP.status(nm(k) + ' is on your account (test).', 'ok'); await loadGpTest();
|
||||||
|
})));
|
||||||
|
box.querySelectorAll('[data-ht-revoke]').forEach(b => b.addEventListener('click', busy(b, async () => { const k = b.dataset.htRevoke; await api('/api/admin/heroes/test-revoke', { hero: k }); IAP.status(nm(k) + ' removed from your account.', 'ok'); await loadGpTest(); })));
|
||||||
|
}
|
||||||
async function loadGpTest() {
|
async function loadGpTest() {
|
||||||
const box = $('gpTest'); if (!box) return;
|
const box = $('gpTest'); if (!box) return;
|
||||||
let g; try { g = await api('/api/admin/gamepass/preview'); } catch (e) { box.innerHTML = '<p class="muted">' + esc(e.message) + '</p>'; return; }
|
let g; try { g = await api('/api/admin/gamepass/preview'); } catch (e) { box.innerHTML = '<p class="muted">' + esc(e.message) + '</p>'; return; }
|
||||||
@@ -1299,8 +1337,10 @@
|
|||||||
+ 'These are the tier cards as members will see them. Every button here acts on your own account (' + esc(g.email) + ') and nobody else’s. The member Games card on /my shows you exactly what a member sees: while you hold a test tier it shows that tier the way it would for any member who holds one.</p>'
|
+ 'These are the tier cards as members will see them. Every button here acts on your own account (' + esc(g.email) + ') and nobody else’s. The member Games card on /my shows you exactly what a member sees: while you hold a test tier it shows that tier the way it would for any member who holds one.</p>'
|
||||||
+ '<div class="gpt-grid">' + rows.map(card).join('') + '</div>'
|
+ '<div class="gpt-grid">' + rows.map(card).join('') + '</div>'
|
||||||
+ '<p class="muted" style="margin:10px 0 0"><b>Test buy</b> opens the same waiting order a member gets: a fresh package of at least the price, bought on /my by one of your positions, starts it (sponsors paid as usual). Cancel a test order you will not pay, or a later real package of that size fulfils it. <b>Give my account</b> starts one pass period at once, recorded as comped (no sale); <b>End</b> stops it. '
|
+ '<p class="muted" style="margin:10px 0 0"><b>Test buy</b> opens the same waiting order a member gets: a fresh package of at least the price, bought on /my by one of your positions, starts it (sponsors paid as usual). Cancel a test order you will not pay, or a later real package of that size fulfils it. <b>Give my account</b> starts one pass period at once, recorded as comped (no sale); <b>End</b> stops it. '
|
||||||
+ 'To test it in game, open <b>Shards of Valor > Passes</b> (key P) after signing in to the game again from /my Games: the game reads your highest tier from InstantAdPay at sign-in.</p>';
|
+ 'To test it in game, open <b>Shards of Valor > Passes</b> (key P) after signing in to the game again from /my Games: the game reads your highest tier from InstantAdPay at sign-in.</p>'
|
||||||
|
+ heroTestHtml(g.heroes);
|
||||||
const tierName = k => (rows.find(r => r.tier === k) || {}).name || k;
|
const tierName = k => (rows.find(r => r.tier === k) || {}).name || k;
|
||||||
|
wireHeroTest(box, g);
|
||||||
box.querySelectorAll('[data-gpt-buy]').forEach(b => b.addEventListener('click', busy(b, async () => {
|
box.querySelectorAll('[data-gpt-buy]').forEach(b => b.addEventListener('click', busy(b, async () => {
|
||||||
const k = b.dataset.gptBuy; const r = rows.find(x => x.tier === k);
|
const k = b.dataset.gptBuy; const r = rows.find(x => x.tier === k);
|
||||||
if (!(await IAP.confirmBox('Open a TEST order for ' + tierName(k) + ' on your own account (' + g.email + ')? It starts when a fresh $' + r.package + ' or bigger package from one of your positions settles on chain. Members still cannot see or buy this tier.', { title: 'Test buy: ' + tierName(k), ok: 'Open the test order', cancel: 'Not now' }))) return;
|
if (!(await IAP.confirmBox('Open a TEST order for ' + tierName(k) + ' on your own account (' + g.email + ')? It starts when a fresh $' + r.package + ' or bigger package from one of your positions settles on chain. Members still cannot see or buy this tier.', { title: 'Test buy: ' + tierName(k), ok: 'Open the test order', cancel: 'Not now' }))) return;
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 212 KiB |
@@ -0,0 +1,122 @@
|
|||||||
|
// Chasing Unicorns (Marty, 2026-11-12): a promo-tool lead magnet. A fake earnings dashboard where every button, tile and popup
|
||||||
|
// is one of the classic scam warning signs; clicking one reveals it and scores the visitor's "scam radar", and the ending
|
||||||
|
// contrasts the unicorn with how InstantAdPay works. Shared as /chasing-unicorns?ref=<username> (the viral ?ref= link sets the
|
||||||
|
// sponsor cookie server-side). Nothing here touches an account: it is all made up on the page.
|
||||||
|
(function () {
|
||||||
|
var $ = function (id) { return document.getElementById(id); };
|
||||||
|
var usd = function (n) { return '$' + n.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 }); };
|
||||||
|
var calm = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||||
|
|
||||||
|
var FLAGS = {
|
||||||
|
daily: { name: 'A fixed daily return', short: 'Guaranteed % a day on your deposit',
|
||||||
|
h: 'Nobody pays a fixed 3% a day.', p: 'That is over 4 million percent a year, compounded. No business earns that. The only way to pay a fixed daily return is with the next person\'s deposit.',
|
||||||
|
tell: 'Your "interest" is a line of code adding to a number. Watch it: it goes up even though nothing happened.', do: 'Ask what the product is and who buys it. If the answer is "the return", walk away.' },
|
||||||
|
withdraw: { name: 'Withdrawals that never arrive', short: 'Always "processing"',
|
||||||
|
h: 'Withdrawal processing... forever.', p: 'Deposits are instant. Withdrawals need "verification", a "maintenance window", a new minimum. That is how a site with no money buys time.',
|
||||||
|
tell: 'The balance on screen is not money. Money is what lands in your own wallet or bank.', do: 'Withdraw a small amount early. If $20 is a hostage negotiation, you have your answer.' },
|
||||||
|
vip: { name: 'Pay to unlock your own money', short: 'Upgrade or "release fee" first',
|
||||||
|
h: 'Pay $199 to unlock your own $25,000?', p: 'The "upgrade", the "tax", the "release fee", a "small miner fee" or "gas fee". It always sounds minor next to the balance waiting for you. It is the oldest trick: the balance is bait, and the fee is the real product. Some sites are free right up until the countdown ends, then everybody gets the fee at once.',
|
||||||
|
tell: 'If the money were there, they would take the fee out of it. They want new money from you instead.', do: 'Never pay to withdraw. A real balance pays its own fees.' },
|
||||||
|
team: { name: 'The product is recruiting', short: 'Paid mainly for sign-ups',
|
||||||
|
h: '+$500 per sign-up. Paid with what?', p: 'If you earn for bringing people in and nobody is buying anything real, the money for your bonus comes from the people you brought in.',
|
||||||
|
tell: 'A team bonus with no product is your friends\' deposits with your name on them.', do: 'Ask: if nobody new joined tomorrow, where would the money come from?' },
|
||||||
|
clock: { name: 'The clock is always ticking', short: 'Countdowns and "spots left"',
|
||||||
|
h: 'The countdown resets. It always does.', p: 'Urgency is there to stop you thinking and to get you recruiting before you check anything. Watch the timer: when it hits zero, it starts over.',
|
||||||
|
tell: 'A good opportunity is still there after you sleep on it. A bad one needs you not to.', do: 'Wait 48 hours and search the name plus "withdrawal" and "scam" first.' },
|
||||||
|
coin: { name: 'Paid in their own coin', short: 'Tokens you cannot sell anywhere real',
|
||||||
|
h: '48,000 UYP, worth whatever they say.', p: 'A token you can only "sell" back on their own site is Monopoly money with better branding. They print it, they price it, they decide when you can sell.',
|
||||||
|
tell: '"Soon x100" is a promise from the people holding all the supply.', do: 'Check whether it trades anywhere real, with real volume, and who holds most of it.' },
|
||||||
|
keys: { name: 'Anything that touches your keys', short: '"Connect wallet to claim"',
|
||||||
|
h: 'Connect wallet to claim? That is the scam.', p: 'Claim pages ask you to sign an approval that lets them spend your tokens. Some ask for your seed phrase outright. Nobody legit ever needs either.',
|
||||||
|
tell: 'One signature can empty a wallet. The "airdrop" is the bait.', do: 'Never type a seed phrase into a website. Read what a signature approves before you sign it.' },
|
||||||
|
proof: { name: 'Fake social proof', short: 'People "cashing out" every few seconds',
|
||||||
|
h: '"Dave from Denver just withdrew $19,350."', p: 'These popups are a few lines of code picking a random name and a random amount. They are on scam sites because they work on all of us.',
|
||||||
|
tell: 'A popup is not a receipt. A transaction you can look up is.', do: 'Ask for a payment you can verify yourself, on a public ledger, not a screenshot.' }
|
||||||
|
};
|
||||||
|
var ORDER = ['daily', 'withdraw', 'vip', 'team', 'clock', 'coin', 'keys', 'proof'];
|
||||||
|
var seen = [];
|
||||||
|
|
||||||
|
// the visitor's sponsor rides the share link (?ref=), so the join button and the share line keep it
|
||||||
|
var ref = (new URLSearchParams(location.search).get('ref') || '').toLowerCase().replace(/[^a-z0-9_]/g, '').slice(0, 20);
|
||||||
|
// where the page link was posted (?src=massifly, ?src=leasedadspace...) rides into the join, so a sign-up says which channel
|
||||||
|
var chan = (new URLSearchParams(location.search).get('src') || '').toLowerCase().replace(/[^a-z0-9_.-]/g, '').slice(0, 18);
|
||||||
|
var srcTag = chan ? 'unicorns-' + chan : 'chasing-unicorns';
|
||||||
|
$('joinBtn').href = '/join?src=' + srcTag;
|
||||||
|
if (ref) {
|
||||||
|
$('joinBtn').href = '/join/' + ref + '?src=' + srcTag;
|
||||||
|
$('ledgerBtn').href = '/ledger?ref=' + ref;
|
||||||
|
$('shareLink').textContent = 'https://instantadpay.com/chasing-unicorns?ref=' + ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
// radar
|
||||||
|
var dots = $('dots'); ORDER.forEach(function () { dots.appendChild(document.createElement('i')); });
|
||||||
|
function renderRadar() {
|
||||||
|
[].forEach.call(dots.children, function (d, i) { d.className = i < seen.length ? 'on' : ''; });
|
||||||
|
$('score').textContent = seen.length + ' of 8';
|
||||||
|
$('endH').textContent = seen.length === 8 ? 'Scam radar: 8 of 8. You are a unicorn hunter.' : 'Your scam radar: ' + seen.length + ' of 8 red flags spotted';
|
||||||
|
$('flags').innerHTML = ORDER.map(function (k) { var f = FLAGS[k]; return '<li class="' + (seen.indexOf(k) >= 0 ? 'on' : '') + '"><b>' + f.name + '</b><span class="fine">' + f.short + '</span></li>'; }).join('');
|
||||||
|
document.querySelectorAll('[data-flag]').forEach(function (b) { b.classList.toggle('done', seen.indexOf(b.getAttribute('data-flag')) >= 0); });
|
||||||
|
if (seen.length >= 3) $('after').hidden = false;
|
||||||
|
}
|
||||||
|
renderRadar();
|
||||||
|
|
||||||
|
// the reveal card
|
||||||
|
var lastFocus = null;
|
||||||
|
function reveal(k) {
|
||||||
|
var f = FLAGS[k]; if (!f) return;
|
||||||
|
if (seen.indexOf(k) < 0) seen.push(k);
|
||||||
|
renderRadar();
|
||||||
|
$('cardK').textContent = 'Red flag ' + seen.length + ' of 8 spotted: ' + f.name;
|
||||||
|
$('cardH').textContent = f.h; $('cardP').textContent = f.p;
|
||||||
|
$('cardTell').textContent = f.tell; $('cardDo').textContent = 'What to do: ' + f.do;
|
||||||
|
$('cardNext').textContent = seen.length === 8 ? 'See my result' : 'Keep hunting';
|
||||||
|
lastFocus = document.activeElement; $('veil').hidden = false; $('cardNext').focus();
|
||||||
|
}
|
||||||
|
function closeCard(toEnd) {
|
||||||
|
$('veil').hidden = true;
|
||||||
|
if (toEnd || seen.length === 8) $('end').scrollIntoView({ behavior: calm ? 'auto' : 'smooth', block: 'start' });
|
||||||
|
else if (lastFocus) lastFocus.focus();
|
||||||
|
}
|
||||||
|
document.querySelectorAll('[data-flag]').forEach(function (b) { b.addEventListener('click', function () { reveal(b.getAttribute('data-flag')); }); });
|
||||||
|
$('cardNext').addEventListener('click', function () { closeCard(false); });
|
||||||
|
$('cardEnd').addEventListener('click', function () { closeCard(true); });
|
||||||
|
$('veil').addEventListener('click', function (e) { if (e.target === $('veil')) closeCard(false); });
|
||||||
|
document.addEventListener('keydown', function (e) { if (e.key === 'Escape' && !$('veil').hidden) closeCard(false); });
|
||||||
|
$('showAll').addEventListener('click', function () { ORDER.forEach(function (k) { if (seen.indexOf(k) < 0) seen.push(k); }); renderRadar(); $('after').scrollIntoView({ behavior: calm ? 'auto' : 'smooth', block: 'start' }); });
|
||||||
|
$('copyShare').addEventListener('click', function () {
|
||||||
|
var t = $('shareLink').textContent, b = $('copyShare');
|
||||||
|
navigator.clipboard.writeText(t).then(function () { b.textContent = 'Copied'; }, function () { var r = document.createRange(); r.selectNodeContents($('shareLink')); var s = getSelection(); s.removeAllRanges(); s.addRange(r); b.textContent = 'Press Ctrl+C'; });
|
||||||
|
});
|
||||||
|
|
||||||
|
// the ticking balance: 3% a day of $25,000, out of thin air
|
||||||
|
var START = 25000, perSec = START * 0.03 / 86400, t0 = performance.now(), midnight = new Date(); midnight.setHours(0, 0, 0, 0);
|
||||||
|
function tick() {
|
||||||
|
var gain = (performance.now() - t0) / 1000 * perSec;
|
||||||
|
$('bal').textContent = usd(START + gain);
|
||||||
|
$('rate').textContent = '+3.00% daily compound interest · +' + usd(gain) + ' since you opened this page';
|
||||||
|
$('today').textContent = usd((Date.now() - midnight.getTime()) / 1000 * perSec);
|
||||||
|
}
|
||||||
|
tick(); setInterval(tick, calm ? 1000 : 100);
|
||||||
|
|
||||||
|
// the countdown that starts over at zero, and spots that never run out
|
||||||
|
var LEN = 600, end = Date.now() + LEN * 1000, spots = 3;
|
||||||
|
setInterval(function () {
|
||||||
|
var left = Math.round((end - Date.now()) / 1000);
|
||||||
|
if (left <= 0) { end = Date.now() + LEN * 1000; left = LEN; spots = 3; }
|
||||||
|
else if (left % 89 === 0 && spots > 1) spots--;
|
||||||
|
$('clock').textContent = String(Math.floor(left / 60)).padStart(2, '0') + ':' + String(left % 60).padStart(2, '0');
|
||||||
|
$('spots').textContent = 'Only ' + spots + ' VIP spot' + (spots === 1 ? '' : 's') + ' left';
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
// fake "cash out" popups every few seconds: random made-up names and amounts
|
||||||
|
var who = ['Jessica from Ohio', 'Mike in Texas', 'Priya from London', 'Carlos in Miami', 'Ahmed from Dubai', 'Linda in Phoenix', 'Tom from Sydney', 'Grace in Toronto', 'Dave from Denver', 'Nina in Berlin', 'Kwame from Accra', 'Rosa in Manila'];
|
||||||
|
var what = ['just withdrew', 'just cashed out', 'just earned', 'just got a team bonus of'];
|
||||||
|
function pop() {
|
||||||
|
var n = who[Math.floor(Math.random() * who.length)], amt = Math.round((Math.random() * 40000 + 1500) / 10) * 10;
|
||||||
|
$('pAv').textContent = n.charAt(0);
|
||||||
|
$('pT').innerHTML = n + ' ' + what[Math.floor(Math.random() * what.length)] + ' <b>' + usd(amt) + '</b> ' + (1 + Math.floor(Math.random() * 9)) + ' min ago';
|
||||||
|
$('proof').classList.add('on');
|
||||||
|
setTimeout(function () { $('proof').classList.remove('on'); }, 4500);
|
||||||
|
}
|
||||||
|
setTimeout(function () { pop(); setInterval(pop, 8000); }, 3000);
|
||||||
|
})();
|
||||||
+352
-310
@@ -1,310 +1,352 @@
|
|||||||
// Shared page runtime: site config, nav, formatting. Zero dependencies.
|
// Shared page runtime: site config, nav, formatting. Zero dependencies.
|
||||||
window.IAP = (function () {
|
window.IAP = (function () {
|
||||||
let config = null;
|
let config = null;
|
||||||
const $ = id => document.getElementById(id);
|
const $ = id => document.getElementById(id);
|
||||||
|
|
||||||
async function getConfig() {
|
async function getConfig() {
|
||||||
if (!config) config = await (await fetch('/api/config')).json();
|
if (!config) config = await (await fetch('/api/config')).json();
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
// POL amounts display with two decimals (rounded half-up), e.g. 523.39
|
// POL amounts display with two decimals (rounded half-up), e.g. 523.39
|
||||||
function fmtPol(wei) {
|
function fmtPol(wei) {
|
||||||
const cents = (BigInt(wei) + 5000000000000000n) / 10000000000000000n; // wei -> hundredths of a POL
|
const cents = (BigInt(wei) + 5000000000000000n) / 10000000000000000n; // wei -> hundredths of a POL
|
||||||
const s = cents.toString().padStart(3, '0');
|
const s = cents.toString().padStart(3, '0');
|
||||||
return s.slice(0, -2) + '.' + s.slice(-2);
|
return s.slice(0, -2) + '.' + s.slice(-2);
|
||||||
}
|
}
|
||||||
const fmtUsd = cents => '$' + (cents / 100).toFixed(2);
|
const fmtUsd = cents => '$' + (cents / 100).toFixed(2);
|
||||||
|
|
||||||
function status(msg, cls) {
|
function status(msg, cls) {
|
||||||
let el = $('status');
|
let el = $('status');
|
||||||
if (!el) { el = document.createElement('div'); el.id = 'status'; document.body.appendChild(el); }
|
if (!el) { el = document.createElement('div'); el.id = 'status'; document.body.appendChild(el); }
|
||||||
el.textContent = msg; el.className = cls || ''; el.hidden = false;
|
el.textContent = msg; el.className = cls || ''; el.hidden = false;
|
||||||
clearTimeout(status._t);
|
clearTimeout(status._t);
|
||||||
if (cls === 'ok') status._t = setTimeout(() => { el.hidden = true; }, 6000);
|
if (cls === 'ok') status._t = setTimeout(() => { el.hidden = true; }, 6000);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function renderNav(active) {
|
async function renderNav(active) {
|
||||||
const c = await getConfig();
|
const c = await getConfig();
|
||||||
const nav = document.createElement('nav');
|
const nav = document.createElement('nav');
|
||||||
nav.innerHTML = '<div class="wrap">'
|
nav.innerHTML = '<div class="wrap">'
|
||||||
+ '<span class="logo-wrap"><a class="logo" href="/"><img src="/logo.png" alt="InstantAdPay" style="height:30px;display:block"></a><span class="byline">Brought to you by the <b>Crypto Team Build Network</b></span></span>'
|
+ '<span class="logo-wrap"><a class="logo" href="/"><img src="/logo.png" alt="InstantAdPay" style="height:30px;display:block"></a><span class="byline">Brought to you by the <b>Crypto Team Build Network</b></span></span>'
|
||||||
+ '<span class="links">'
|
+ '<span class="links">'
|
||||||
+ '<a href="/#how" data-p="home">How it works</a>'
|
+ '<a href="/#how" data-p="home">How it works</a>'
|
||||||
+ '<a href="/presentation" data-p="presentation">Presentation</a>'
|
+ '<a href="/presentation" data-p="presentation">Presentation</a>'
|
||||||
+ '<a href="/#packages" data-p="pricing">Ad packages</a>'
|
+ '<a href="/#packages" data-p="pricing">Ad packages</a>'
|
||||||
+ '<a href="/ledger" data-p="ledger">Live ledger</a>'
|
+ '<a href="/ledger" data-p="ledger">Live ledger</a>'
|
||||||
+ '<a href="/leaderboard" data-p="leaderboard">Leaderboard</a>'
|
+ '<a href="/leaderboard" data-p="leaderboard">Leaderboard</a>'
|
||||||
+ '<a href="/contract" data-p="contract">The contract</a>'
|
+ '<a href="/contract" data-p="contract">The contract</a>'
|
||||||
+ '<a href="/support" data-p="support">Support</a>'
|
+ '<a href="/support" data-p="support">Support</a>'
|
||||||
+ '<a href="/my" data-p="my">Members</a>'
|
+ '<a href="/my" data-p="my">Members</a>'
|
||||||
+ '</span><span id="navWallet" class="muted">…</span></div>';
|
+ '</span><span id="navWallet" class="muted">…</span></div>';
|
||||||
document.body.prepend(nav);
|
document.body.prepend(nav);
|
||||||
if (c.rehearsal) {
|
if (c.rehearsal) {
|
||||||
const b = document.createElement('div');
|
const b = document.createElement('div');
|
||||||
b.className = 'rehearsal';
|
b.className = 'rehearsal';
|
||||||
b.innerHTML = '<b>Testnet rehearsal</b>: running on ' + c.chainName + '. Purchases use valueless test POL while we prove every payout in public.';
|
b.innerHTML = '<b>Testnet rehearsal</b>: running on ' + c.chainName + '. Purchases use valueless test POL while we prove every payout in public.';
|
||||||
document.body.prepend(b);
|
document.body.prepend(b);
|
||||||
}
|
}
|
||||||
const a = nav.querySelector('[data-p="' + active + '"]');
|
const a = nav.querySelector('[data-p="' + active + '"]');
|
||||||
if (a) a.className = 'active';
|
if (a) a.className = 'active';
|
||||||
refreshNavWallet();
|
refreshNavWallet();
|
||||||
renderFooter();
|
renderFooter();
|
||||||
}
|
}
|
||||||
function renderFooter() {
|
function renderFooter() {
|
||||||
if (document.getElementById('iapFooter')) return;
|
if (document.getElementById('iapFooter')) return;
|
||||||
const f = document.createElement('footer'); f.id = 'iapFooter';
|
const f = document.createElement('footer'); f.id = 'iapFooter';
|
||||||
f.style.cssText = 'border-top:1px solid var(--line);margin-top:48px;padding:26px 22px;text-align:center;color:var(--muted);font-size:13px';
|
f.style.cssText = 'border-top:1px solid var(--line);margin-top:48px;padding:26px 22px;text-align:center;color:var(--muted);font-size:13px';
|
||||||
f.innerHTML = '<div>© ' + new Date().getFullYear() + ' InstantAdPay</div>'
|
f.innerHTML = '<div>© ' + new Date().getFullYear() + ' InstantAdPay</div>'
|
||||||
+ '<div style="margin-top:8px;display:flex;gap:16px;justify-content:center;flex-wrap:wrap">'
|
+ '<div style="margin-top:8px;display:flex;gap:16px;justify-content:center;flex-wrap:wrap">'
|
||||||
+ '<a href="/">How it works</a><a href="/presentation">Presentation</a><a href="/ledger">Live ledger</a><a href="/contract">The contract</a><a href="/blog">Blog</a><a href="/leaderboard">Leaderboard</a><a href="/whats-new">What\'s new</a>'
|
+ '<a href="/">How it works</a><a href="/presentation">Presentation</a><a href="/ledger">Live ledger</a><a href="/contract">The contract</a><a href="/blog">Blog</a><a href="/leaderboard">Leaderboard</a><a href="/whats-new">What\'s new</a>'
|
||||||
+ '<a href="/facts">Platform facts</a><a href="/support">Support</a><a href="/terms">Terms</a><a href="/privacy">Privacy</a><a href="/disclaimer">Disclaimer</a></div>';
|
+ '<a href="/facts">Platform facts</a><a href="/support">Support</a><a href="/terms">Terms</a><a href="/disclaimer">Earnings Disclaimer</a><a href="/privacy">Privacy</a></div>'
|
||||||
document.body.appendChild(f);
|
+ '<div style="margin-top:10px">TrustClickz · 615 Green Valley Drive, Moody, AL 35004</div>';
|
||||||
}
|
document.body.appendChild(f);
|
||||||
async function refreshNavWallet() {
|
renderNetworkLine(f);
|
||||||
try {
|
}
|
||||||
const me = await (await fetch('/api/me')).json();
|
// "Part of the network" (Marty 2026-11-14 trust pack): the list comes from the hub through /api/network-sites, built-in copy if not
|
||||||
const el = $('navWallet');
|
const NET_FALLBACK = [['iap', 'InstantAdPay', 'https://instantadpay.com'], ['linkspin', 'LinkSpin', 'https://linkspin.app'], ['dlb', 'Downline Banners', 'https://downlinebanners.com'],
|
||||||
if (!el) return;
|
['vbb', 'Viral Banner Blitz', 'https://viralbannerblitz.com'], ['stackpol', 'Stack POL', 'https://stackpol.com'], ['earnerscorner', 'Earners Corner', 'https://earnerscorner.com']].map(a => ({ id: a[0], name: a[1], url: a[2] }));
|
||||||
if (me.signedIn) {
|
let netList = null;
|
||||||
// identity order: username, then email, then wallet
|
async function networkSites() {
|
||||||
const who = me.username
|
if (!netList) netList = fetch('/api/network-sites').then(r => r.json()).then(l => (Array.isArray(l) && l.length ? l : NET_FALLBACK)).catch(() => NET_FALLBACK);
|
||||||
? '<b>@' + String(me.username).replace(/[&<>]/g, '') + '</b>'
|
return netList;
|
||||||
: (me.email ? String(me.email).replace(/[&<>]/g, '')
|
}
|
||||||
: (me.address ? '<span class="mono">' + me.address.slice(0, 6) + '…' + me.address.slice(-4) + '</span>' : 'signed in'));
|
function renderNetworkLine(host) {
|
||||||
el.innerHTML = (me.memberId ? '<span class="badge">member #' + me.memberId + '</span> ' : '') + who;
|
if (!host || host.querySelector('.netline')) return;
|
||||||
} else {
|
const d = document.createElement('div'); d.className = 'netline';
|
||||||
el.innerHTML = '<a href="/my">Sign in</a>';
|
d.style.cssText = 'margin-top:10px;display:flex;gap:6px 14px;justify-content:center;flex-wrap:wrap;align-items:baseline;font-size:12.5px';
|
||||||
}
|
host.appendChild(d);
|
||||||
return me;
|
const esc = s => String(s).replace(/[&<>"]/g, ch => ({ '&': '&', '<': '<', '>': '>', '"': '"' })[ch]);
|
||||||
} catch (e) { return null; }
|
const paint = list => {
|
||||||
}
|
d.innerHTML = '<b>Part of the network</b><span>One account across the network:</span>' + list.map(s => (s.id === 'iap' || /instantadpay\.com/.test(s.url))
|
||||||
function describeEvent(ev, c) {
|
? '<span aria-current="page" style="font-weight:700;color:var(--ink)">' + esc(s.name) + ' (you are here)</span>'
|
||||||
const pol = w => fmtPol(w) + ' POL';
|
: '<a href="' + esc(s.go || s.url) + '" target="_blank" rel="noopener nofollow">' + esc(s.name) + '</a>').join('');
|
||||||
// real people, not numbers: use usernames when the site knows them
|
};
|
||||||
const nm = id => (ev.names && ev.names[id])
|
paint(NET_FALLBACK);
|
||||||
? String(ev.names[id]).replace(/[&<>]/g, '')
|
networkSites().then(paint);
|
||||||
: 'member #' + id;
|
}
|
||||||
switch (ev.type) {
|
// pages with their own footer (the members area) get the network line too
|
||||||
case 'Purchase': return '🧾 ' + nm(ev.buyerId) + ' bought package #' + ev.productId
|
function decorateFooters() { document.querySelectorAll('footer.bo-pagefoot').forEach(f => { const w = document.createElement('div'); w.style.width = '100%'; f.appendChild(w); renderNetworkLine(w); }); }
|
||||||
+ ' (' + fmtUsd(ev.priceCents) + ') for ' + pol(ev.paidWei) + ' → +' + ev.creditAmount.toLocaleString() + ' credits';
|
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', decorateFooters); else decorateFooters();
|
||||||
case 'TierPaid': return '💸 level ' + ev.tier + ' payout → ' + nm(ev.recipientId) + ': ' + pol(ev.amountWei)
|
async function refreshNavWallet() {
|
||||||
+ (ev.hops ? ' (passed up ' + ev.hops + ')' : '');
|
try {
|
||||||
case 'PassedUp': return '↷ level ' + ev.tier + ' passed over ' + nm(ev.skippedId) + ' (' + ev.reason + ')';
|
const me = await (await fetch('/api/me')).json();
|
||||||
case 'AdminPaid': return '🏛 platform fee settled: ' + pol(ev.amountWei);
|
const el = $('navWallet');
|
||||||
case 'BuyerCounted': return '⭐ ' + nm(ev.sponsorId) + ' now has ' + ev.newCount + ' qualifying buyer(s)';
|
if (!el) return;
|
||||||
case 'MemberActivated': return '👤 ' + nm(ev.id) + ' activated a payout wallet';
|
if (me.signedIn) {
|
||||||
case 'AwardPaid': return ev.override ? '🏅 Level 4 override' + (ev.overrideWeek ? ' (week of ' + ev.overrideWeek + ')' : '') + ': ' + pol(ev.amountWei) + ' → ' + nm(ev.toId) : '🎁 award: ' + pol(ev.amountWei) + ' → ' + nm(ev.toId);
|
// identity order: username, then email, then wallet
|
||||||
case 'CreditsConsumed': return '📣 ' + nm(ev.memberId) + ' ran ads: −' + ev.amount.toLocaleString() + ' credits';
|
const who = me.username
|
||||||
case 'PriceCached': return '🔮 oracle price refreshed';
|
? '<b>@' + String(me.username).replace(/[&<>]/g, '') + '</b>'
|
||||||
case 'FallbackPriceUsed': return '🔮 cached price bridged an oracle gap';
|
: (me.email ? String(me.email).replace(/[&<>]/g, '')
|
||||||
default: return '· ' + ev.type;
|
: (me.address ? '<span class="mono">' + me.address.slice(0, 6) + '…' + me.address.slice(-4) + '</span>' : 'signed in'));
|
||||||
}
|
el.innerHTML = (me.memberId ? '<span class="badge">member #' + me.memberId + '</span> ' : '') + who;
|
||||||
}
|
} else {
|
||||||
function feedRow(ev, c) {
|
el.innerHTML = '<a href="/my">Sign in</a>';
|
||||||
const div = document.createElement('div');
|
}
|
||||||
div.className = 'row t-' + ev.type;
|
return me;
|
||||||
const when = ev.ts ? new Date(ev.ts).toLocaleString(undefined, { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) : '';
|
} catch (e) { return null; }
|
||||||
div.innerHTML = (when ? '<span class="when" title="' + new Date(ev.ts).toLocaleString() + '">' + when + '</span>' : '') + '<span>' + describeEvent(ev, c) + '</span>'
|
}
|
||||||
+ (c.explorer
|
function describeEvent(ev, c) {
|
||||||
? '<span class="tx"><a target="_blank" rel="noopener" href="' + c.explorer + '/tx/' + ev.tx + '">verify ↗</a></span>'
|
const pol = w => fmtPol(w) + ' POL';
|
||||||
: '<span class="tx"><a href="/tx/' + ev.tx + '">verify ↗</a></span>'); // built-in viewer when the chain has no public explorer
|
// real people, not numbers: use usernames when the site knows them
|
||||||
return div;
|
const nm = id => (ev.names && ev.names[id])
|
||||||
}
|
? String(ev.names[id]).replace(/[&<>]/g, '')
|
||||||
// Render one served ad into #<elId>. Silent if no inventory.
|
: 'member #' + id;
|
||||||
// report an ad (auto-approved ads need a member-facing flag → admin notified)
|
switch (ev.type) {
|
||||||
// 2026-09-16: was a native prompt() with 'broken' pre-filled, so a stray tap on OK filed a
|
case 'Purchase': return '🧾 ' + nm(ev.buyerId) + ' bought package #' + ev.productId
|
||||||
// "broken" report with no note (campaign #27). Now the site dialog, no default, reason validated.
|
+ ' (' + fmtUsd(ev.priceCents) + ') for ' + pol(ev.paidWei) + ' → +' + ev.creditAmount.toLocaleString() + ' credits';
|
||||||
const REPORT_REASONS = ['broken', 'inappropriate', 'spam', 'scam', 'other'];
|
case 'TierPaid': return '💸 level ' + ev.tier + ' payout → ' + nm(ev.recipientId) + ': ' + pol(ev.amountWei)
|
||||||
async function reportAd(campaignId) {
|
+ (ev.hops ? ' (passed up ' + ev.hops + ')' : '');
|
||||||
if (!campaignId) return;
|
case 'PassedUp': return '↷ level ' + ev.tier + ' passed over ' + nm(ev.skippedId) + ' (' + ev.reason + ')';
|
||||||
const raw = await ask({ title: 'Report this ad', text: 'What is wrong with it? Type one: broken, inappropriate, spam, scam, or other.', placeholder: 'e.g. broken', ok: 'Next' });
|
case 'AdminPaid': return '🏛 platform fee settled: ' + pol(ev.amountWei);
|
||||||
if (raw === null) return;
|
case 'BuyerCounted': return '⭐ ' + nm(ev.sponsorId) + ' now has ' + ev.newCount + ' qualifying buyer(s)';
|
||||||
const reason = String(raw || '').trim().toLowerCase();
|
case 'MemberActivated': return '👤 ' + nm(ev.id) + ' activated a payout wallet';
|
||||||
if (!REPORT_REASONS.includes(reason)) { status('Pick one of: broken, inappropriate, spam, scam, or other.', 'bad'); return; }
|
case 'AwardPaid': return ev.override ? '🏅 Level 4 override' + (ev.overrideWeek ? ' (week of ' + ev.overrideWeek + ')' : '') + ': ' + pol(ev.amountWei) + ' → ' + nm(ev.toId) : '🎁 award: ' + pol(ev.amountWei) + ' → ' + nm(ev.toId);
|
||||||
const note = await ask({ title: 'Report: ' + reason, text: 'Tell the admin what you saw, so it can be fixed. Optional, but it helps.', type: 'textarea', ok: 'Send report' });
|
case 'CreditsConsumed': return '📣 ' + nm(ev.memberId) + ' ran ads: −' + ev.amount.toLocaleString() + ' credits';
|
||||||
if (note === null) return;
|
case 'PriceCached': return '🔮 oracle price refreshed';
|
||||||
fetch('/api/report-ad', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ campaignId, reason, note: String(note || '').slice(0, 500) }) })
|
case 'FallbackPriceUsed': return '🔮 cached price bridged an oracle gap';
|
||||||
.then(() => status('Thanks — this ad was reported to the admin for review.', 'ok'))
|
default: return '· ' + ev.type;
|
||||||
.catch(() => status('Could not send the report. Try again.', 'bad'));
|
}
|
||||||
}
|
}
|
||||||
const reportTag = ad => ' <a class="ad-report small muted" href="#" data-cid="' + ad.id + '" style="margin-left:8px">⚠ report</a>';
|
function feedRow(ev, c) {
|
||||||
function wireReport(el) {
|
const div = document.createElement('div');
|
||||||
const rl = el.querySelector('.ad-report');
|
div.className = 'row t-' + ev.type;
|
||||||
if (rl) rl.addEventListener('click', e => { e.preventDefault(); reportAd(Number(rl.dataset.cid)); });
|
const when = ev.ts ? new Date(ev.ts).toLocaleString(undefined, { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) : '';
|
||||||
}
|
div.innerHTML = (when ? '<span class="when" title="' + new Date(ev.ts).toLocaleString() + '">' + when + '</span>' : '') + '<span>' + describeEvent(ev, c) + '</span>'
|
||||||
async function adSlot(type, elId, opts) {
|
+ (c.explorer
|
||||||
try {
|
? '<span class="tx"><a target="_blank" rel="noopener" href="' + c.explorer + '/tx/' + ev.tx + '">verify ↗</a></span>'
|
||||||
const q = '/api/ads/slot?type=' + type + (opts && opts.width ? '&w=' + opts.width + '&h=' + opts.height : '');
|
: '<span class="tx"><a href="/tx/' + ev.tx + '">verify ↗</a></span>'); // built-in viewer when the chain has no public explorer
|
||||||
const { ad } = await (await fetch(q)).json();
|
return div;
|
||||||
const el = $(elId);
|
}
|
||||||
if (!ad || !el) return;
|
// Render one served ad into #<elId>. Silent if no inventory.
|
||||||
el.hidden = false;
|
// report an ad (auto-approved ads need a member-facing flag → admin notified)
|
||||||
if (ad.imageUrl) {
|
// 2026-09-16: was a native prompt() with 'broken' pre-filled, so a stray tap on OK filed a
|
||||||
el.style.textAlign = 'center';
|
// "broken" report with no note (campaign #27). Now the site dialog, no default, reason validated.
|
||||||
el.innerHTML = '<a href="' + ad.targetUrl + '" target="_blank" rel="noopener nofollow">'
|
const REPORT_REASONS = ['broken', 'inappropriate', 'spam', 'scam', 'other'];
|
||||||
+ '<img src="' + ad.imageUrl + '" alt="advertisement" style="max-width:min(100%,728px);height:auto;display:block;margin:0 auto;border-radius:8px"></a>'
|
async function reportAd(campaignId) {
|
||||||
+ '<div class="small muted">member ad' + reportTag(ad) + '</div>';
|
if (!campaignId) return;
|
||||||
} else {
|
const raw = await ask({ title: 'Report this ad', text: 'What is wrong with it? Type one: broken, inappropriate, spam, scam, or other.', placeholder: 'e.g. broken', ok: 'Next' });
|
||||||
el.innerHTML = '<a href="' + ad.targetUrl + '" target="_blank" rel="noopener nofollow"><b>' + ad.title + '</b>'
|
if (raw === null) return;
|
||||||
+ (ad.body ? ' · ' + ad.body : '') + '</a> <span class="small muted">member ad' + reportTag(ad) + '</span>';
|
const reason = String(raw || '').trim().toLowerCase();
|
||||||
}
|
if (!REPORT_REASONS.includes(reason)) { status('Pick one of: broken, inappropriate, spam, scam, or other.', 'bad'); return; }
|
||||||
wireReport(el);
|
const note = await ask({ title: 'Report: ' + reason, text: 'Tell the admin what you saw, so it can be fixed. Optional, but it helps.', type: 'textarea', ok: 'Send report' });
|
||||||
el.hidden = false;
|
if (note === null) return;
|
||||||
} catch (e) {}
|
fetch('/api/report-ad', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ campaignId, reason, note: String(note || '').slice(0, 500) }) })
|
||||||
}
|
.then(() => status('Thanks — this ad was reported to the admin for review.', 'ok'))
|
||||||
// ── sign-up code request with the invisible guard fields (form age + honeypot)
|
.catch(() => status('Could not send the report. Try again.', 'bad'));
|
||||||
// and the icon check the server asks for only after an IP trips a limit ──
|
}
|
||||||
const FORM_TS = Date.now();
|
const reportTag = ad => ' <a class="ad-report small muted" href="#" data-cid="' + ad.id + '" style="margin-left:8px">⚠ report</a>';
|
||||||
function iconCheck(host, ch, note) {
|
function wireReport(el) {
|
||||||
return new Promise(resolve => {
|
const rl = el.querySelector('.ad-report');
|
||||||
host.hidden = false;
|
if (rl) rl.addEventListener('click', e => { e.preventDefault(); reportAd(Number(rl.dataset.cid)); });
|
||||||
host.innerHTML = '<div class="small" style="margin:0 0 8px">' + (note ? esc(note) + ' ' : '') + 'Tap the <b>' + esc(ch.prompt) + '</b>.</div>'
|
}
|
||||||
+ '<div class="icon-check">' + ch.options.map(o => '<button type="button" class="ic-btn">' + esc(o) + '</button>').join('') + '</div>';
|
async function adSlot(type, elId, opts) {
|
||||||
host.querySelectorAll('.ic-btn').forEach(b => b.addEventListener('click', () => { host.innerHTML = ''; host.hidden = true; resolve(b.textContent); }, { once: true }));
|
try {
|
||||||
});
|
const q = '/api/ads/slot?type=' + type + (opts && opts.width ? '&w=' + opts.width + '&h=' + opts.height : '');
|
||||||
}
|
const { ad } = await (await fetch(q)).json();
|
||||||
// honeypot fields (join + sign-in): read-only until a trusted focus, so browser autofill and
|
const el = $(elId);
|
||||||
// password managers leave them alone; a value that appeared without a trusted event is ignored
|
if (!ad || !el) return;
|
||||||
function armHoneypots() {
|
el.hidden = false;
|
||||||
document.querySelectorAll('.hp-field').forEach(el => {
|
if (ad.imageUrl) {
|
||||||
if (el.dataset.armed) return; el.dataset.armed = '1'; el.readOnly = true;
|
el.style.textAlign = 'center';
|
||||||
const touch = e => { if (e.isTrusted) { el.readOnly = false; el.dataset.touched = '1'; } };
|
el.innerHTML = '<a href="' + ad.targetUrl + '" target="_blank" rel="noopener nofollow">'
|
||||||
el.addEventListener('focus', touch); el.addEventListener('input', touch); el.addEventListener('keydown', touch);
|
+ '<img src="' + ad.imageUrl + '" alt="advertisement" style="max-width:min(100%,728px);height:auto;display:block;margin:0 auto;border-radius:8px"></a>'
|
||||||
});
|
+ '<div class="small muted">member ad' + reportTag(ad) + '</div>';
|
||||||
}
|
} else {
|
||||||
armHoneypots(); document.addEventListener('DOMContentLoaded', armHoneypots);
|
el.innerHTML = '<a href="' + ad.targetUrl + '" target="_blank" rel="noopener nofollow"><b>' + ad.title + '</b>'
|
||||||
const hpValue = el => (el && el.dataset.touched === '1') ? (el.value || '') : '';
|
+ (ad.body ? ' · ' + ad.body : '') + '</a> <span class="small muted">member ad' + reportTag(ad) + '</span>';
|
||||||
// The server refuses a code request that arrives within a couple of seconds of the page loading,
|
}
|
||||||
// because a script fills a form instantly and a person does not. A returning member whose email
|
wireReport(el);
|
||||||
// is already autofilled has nothing to type, taps straight away, and gets told off for being
|
el.hidden = false;
|
||||||
// quick (Marty, 2026-09-23). So the page waits out the remainder itself: the person sees the
|
} catch (e) {}
|
||||||
// normal sending state, and anything posting at the endpoint without a page behind it still
|
}
|
||||||
// fails the same check.
|
// ── sign-up code request with the invisible guard fields (form age + honeypot)
|
||||||
const MIN_FORM_MS = 2400; // the server wants 2000; leave headroom for clock skew in transit
|
// and the icon check the server asks for only after an IP trips a limit ──
|
||||||
function formSettled() {
|
const FORM_TS = Date.now();
|
||||||
const left = MIN_FORM_MS - (Date.now() - FORM_TS);
|
function iconCheck(host, ch, note) {
|
||||||
return left > 0 ? new Promise(r => setTimeout(r, left)) : Promise.resolve();
|
return new Promise(resolve => {
|
||||||
}
|
host.hidden = false;
|
||||||
async function requestCode(email, opts) {
|
host.innerHTML = '<div class="small" style="margin:0 0 8px">' + (note ? esc(note) + ' ' : '') + 'Tap the <b>' + esc(ch.prompt) + '</b>.</div>'
|
||||||
const o = opts || {};
|
+ '<div class="icon-check">' + ch.options.map(o => '<button type="button" class="ic-btn">' + esc(o) + '</button>').join('') + '</div>';
|
||||||
let pick = null;
|
host.querySelectorAll('.ic-btn').forEach(b => b.addEventListener('click', () => { host.innerHTML = ''; host.hidden = true; resolve(b.textContent); }, { once: true }));
|
||||||
await formSettled();
|
});
|
||||||
for (let i = 0; i < 4; i++) {
|
}
|
||||||
const r = await (await fetch('/api/auth/email/start', { method: 'POST', headers: { 'Content-Type': 'application/json' },
|
// honeypot fields (join + sign-in): read-only until a trusted focus, so browser autofill and
|
||||||
body: JSON.stringify({ email, fts: FORM_TS, fage: Date.now() - FORM_TS, hp_field_x9: hpValue(o.honeypot), pick, ref: o.ref || null, angle: o.angle || null }) })).json(); // ref = the join page's own link token, so the sponsor survives a lost cookie
|
// password managers leave them alone; a value that appeared without a trusted event is ignored
|
||||||
if (r.challenge && o.host) { pick = await iconCheck(o.host, r.challenge, r.error); continue; }
|
function armHoneypots() {
|
||||||
if (r.error) throw new Error(r.error);
|
document.querySelectorAll('.hp-field').forEach(el => {
|
||||||
return r;
|
if (el.dataset.armed) return; el.dataset.armed = '1'; el.readOnly = true;
|
||||||
}
|
const touch = e => { if (e.isTrusted) { el.readOnly = false; el.dataset.touched = '1'; } };
|
||||||
throw new Error('Could not verify. Refresh the page and try again.');
|
el.addEventListener('focus', touch); el.addEventListener('input', touch); el.addEventListener('keydown', touch);
|
||||||
}
|
});
|
||||||
const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
}
|
||||||
// ── founding-week checklist, read from the live account. Shared by /launch and
|
armHoneypots(); document.addEventListener('DOMContentLoaded', armHoneypots);
|
||||||
// the dashboard mark. Two items are the member's own call and persist locally.
|
const hpValue = el => (el && el.dataset.touched === '1') ? (el.value || '') : '';
|
||||||
const LAUNCH_KEY = 'iap.launch.manual';
|
// The server refuses a code request that arrives within a couple of seconds of the page loading,
|
||||||
const manualSet = () => { try { return new Set(JSON.parse(localStorage.getItem(LAUNCH_KEY) || '[]')); } catch (e) { return new Set(); } };
|
// because a script fills a form instantly and a person does not. A returning member whose email
|
||||||
function launchToggle(key) { const s = manualSet(); if (s.has(key)) s.delete(key); else s.add(key); try { localStorage.setItem(LAUNCH_KEY, JSON.stringify([...s])); } catch (e) {} }
|
// is already autofilled has nothing to type, taps straight away, and gets told off for being
|
||||||
function launchChecks(me) {
|
// quick (Marty, 2026-09-23). So the page waits out the remainder itself: the person sees the
|
||||||
const m = me || {}, man = manualSet();
|
// normal sending state, and anything posting at the endpoint without a page behind it still
|
||||||
const bc = Number(m.buyerCount || 0), refs = (m.referrals || []).length;
|
// fails the same check.
|
||||||
return [
|
const MIN_FORM_MS = 2400; // the server wants 2000; leave headroom for clock skew in transit
|
||||||
{ key: 'username', title: 'Pick your username', done: !!m.username, href: '/my#profile', cta: 'Profile',
|
function formSettled() {
|
||||||
how: 'Profile tab. It becomes your invite link and your public page, and it is permanent.',
|
const left = MIN_FORM_MS - (Date.now() - FORM_TS);
|
||||||
why: 'Every link, banner and video you hand out this week carries it. Change it later and the links you already sent die.' },
|
return left > 0 ? new Promise(r => setTimeout(r, left)) : Promise.resolve();
|
||||||
{ key: 'wallet', title: 'Link your wallet', done: !!m.address, href: '/my#wallet', cta: 'Wallet',
|
}
|
||||||
how: 'Wallet tab, Connect, sign the free message. MetaMask recommended. Never held crypto? The wallet guide in Training walks through buying POL with a card.',
|
async function requestCode(email, opts) {
|
||||||
why: 'Payouts go to this address. No wallet, nowhere to pay you.' },
|
const o = opts || {};
|
||||||
{ key: 'payouts', title: 'Switch on payouts', done: !!m.memberId, href: '/my#wallet', cta: 'Wallet',
|
let pick = null;
|
||||||
how: 'Wallet tab, one small transaction. It registers your address with the contract.',
|
await formSettled();
|
||||||
why: 'The contract binds each buyer to their sponsor at their first purchase. If payouts are off when your first person buys, that commission is not yours.' },
|
for (let i = 0; i < 4; i++) {
|
||||||
{ key: 'level2', title: 'Qualify: open level 2', done: bc >= 2, href: '/my#buy', cta: 'Buy packages',
|
const r = await (await fetch('/api/auth/email/start', { method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||||||
how: 'Two of your people buy a $20 or more package. Or use Qualified Start: add two positions from extra wallets in your own MetaMask and buy a $20 package from each (about $23 of POL in each wallet).',
|
body: JSON.stringify({ email, fts: FORM_TS, fage: Date.now() - FORM_TS, hp_field_x9: hpValue(o.honeypot), pick, ref: o.ref || null, angle: o.angle || null, lsclk: o.lsclk || null }) })).json(); // ref = the join page's own link token, so the sponsor survives a lost cookie
|
||||||
why: 'Until you have two qualifying buyers, every level 2 payment from your team climbs past you.',
|
if (r.challenge && o.host) { pick = await iconCheck(o.host, r.challenge, r.error); continue; }
|
||||||
note: 'Qualifying buyers so far: <b>' + bc + '</b> of 2.' },
|
if (r.error) throw new Error(r.error);
|
||||||
{ key: 'level3', title: 'The leader play: open all three levels', done: bc >= 5, href: '/my#buy', cta: 'Qualified Start',
|
return r;
|
||||||
how: 'Five qualifying buyers, real or Qualified Start, up to five linked positions. Once qualified, buy from your main wallet so your sponsor is paid in full.',
|
}
|
||||||
why: 'A leader whose team goes three deep this week collects level 3 from day one instead of watching those 10% payments pass upward. Optional for members, the play for leaders.',
|
throw new Error('Could not verify. Refresh the page and try again.');
|
||||||
note: 'Qualifying buyers so far: <b>' + bc + '</b> of 5.' },
|
}
|
||||||
{ key: 'banner', title: 'Upload your line banner', done: !!m.lineBannerUrl, href: '/my#profile', cta: 'Profile',
|
const esc = s => String(s == null ? '' : s).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
||||||
how: 'Profile tab, line banner. It shows on the welcome tour to everyone in your next three levels.',
|
// ── founding-week checklist, read from the live account. Shared by /launch and
|
||||||
why: 'Your first advertising to your own team, free, and it is live the moment they join.' },
|
// the dashboard mark. Two items are the member's own call and persist locally.
|
||||||
{ key: 'links', title: 'Copy your links and pick a play', done: man.has('links'), manual: true,
|
const LAUNCH_KEY = 'iap.launch.manual';
|
||||||
how: 'Promo tools, Your links: the invite link and the five angle links, plus the matching hook videos. Then read the plays page and choose one.',
|
const manualSet = () => { try { return new Set(JSON.parse(localStorage.getItem(LAUNCH_KEY) || '[]')); } catch (e) { return new Set(); } };
|
||||||
why: 'On launch day you send links, not explanations. Having them ready is the whole difference between a launch and a scramble.' },
|
function launchToggle(key) { const s = manualSet(); if (s.has(key)) s.delete(key); else s.add(key); try { localStorage.setItem(LAUNCH_KEY, JSON.stringify([...s])); } catch (e) {} }
|
||||||
{ key: 'two', title: 'Place your first two', done: refs >= 2, href: '/my#line', cta: 'My line',
|
function launchChecks(me) {
|
||||||
how: 'Two people you have actually talked to, joined through your link, walked through items 1 to 3 on their own accounts.',
|
const m = me || {}, man = manualSet();
|
||||||
why: 'Your first two are the shape of your whole line. Choose them, do not wait for them.',
|
const bc = Number(m.buyerCount || 0), refs = (m.referrals || []).length;
|
||||||
note: 'Joined through you so far: <b>' + refs + '</b>.' }
|
return [
|
||||||
];
|
{ key: 'username', title: 'Pick your username', done: !!m.username, href: '/my#profile', cta: 'Profile',
|
||||||
}
|
how: 'Profile tab. It becomes your invite link and your public page, and it is permanent.',
|
||||||
// In-page dialogs instead of window.prompt / confirm. Mobile Safari shows a red "Suppress dialogs"
|
why: 'Every link, banner and video you hand out this week carries it. Change it later and the links you already sent die.' },
|
||||||
// option on the second native pop-up in a row and, once tapped, swallows every later prompt on the
|
{ key: 'wallet', title: 'Link your wallet', done: !!m.address, href: '/my#wallet', cta: 'Wallet',
|
||||||
// site until reload. ask() resolves the typed value (null on cancel); confirmBox() resolves true/false.
|
how: 'Wallet tab, Connect, sign the free message. MetaMask recommended. Never held crypto? The wallet guide in Training walks through buying POL with a card.',
|
||||||
function dialog(o) {
|
why: 'Payouts go to this address. No wallet, nowhere to pay you.' },
|
||||||
return new Promise(resolve => {
|
{ key: 'payouts', title: 'Switch on payouts', done: !!m.memberId, href: '/my#wallet', cta: 'Wallet',
|
||||||
const esc = t => String(t == null ? '' : t).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
how: 'Wallet tab, one small transaction. It registers your address with the contract.',
|
||||||
const back = document.createElement('div'); back.className = 'modal-back'; back.style.zIndex = '200';
|
why: 'The contract binds each buyer to their sponsor at their first purchase. If payouts are off when your first person buys, that commission is not yours.' },
|
||||||
const field = o.type === 'none' ? '' : o.type === 'textarea'
|
{ key: 'level2', title: 'Qualify: open level 2', done: bc >= 2, href: '/my#buy', cta: 'Buy packages',
|
||||||
? '<textarea id="dlgInput" rows="5" style="width:100%;margin-top:12px">' + esc(o.value) + '</textarea>'
|
how: 'Two of your people buy a $20 or more package. Or use Qualified Start: add two positions from extra wallets in your own MetaMask and buy a $20 package from each (about $23 of POL in each wallet).',
|
||||||
: '<input id="dlgInput" type="' + (o.type === 'number' ? 'number' : 'text') + '" ' + (o.type === 'number' ? 'inputmode="decimal" min="0" step="any" ' : '') + 'value="' + esc(o.value) + '" placeholder="' + esc(o.placeholder) + '" style="width:100%;margin-top:12px" autocomplete="off">';
|
why: 'Until you have two qualifying buyers, every level 2 payment from your team climbs past you.',
|
||||||
back.innerHTML = '<div class="modal-card" role="dialog" aria-modal="true">' + (o.title ? '<h3 style="margin:0 0 8px">' + esc(o.title) + '</h3>' : '')
|
note: 'Qualifying buyers so far: <b>' + bc + '</b> of 2.' },
|
||||||
+ (o.text ? '<p class="muted small" style="margin:0;white-space:pre-line">' + esc(o.text) + '</p>' : '') + field
|
{ key: 'level3', title: 'The leader play: open all three levels', done: bc >= 5, href: '/my#buy', cta: 'Qualified Start',
|
||||||
+ '<div style="display:flex;gap:10px;justify-content:flex-end;margin-top:16px;flex-wrap:wrap">' + (o.noCancel ? '' : '<button type="button" class="btn sec small" id="dlgCancel">' + esc(o.cancel || 'Cancel') + '</button>') + '<button type="button" class="btn small" id="dlgOk">' + esc(o.ok || 'OK') + '</button></div></div>';
|
how: 'Five qualifying buyers, real or Qualified Start, up to five linked positions. Once qualified, buy from your main wallet so your sponsor is paid in full.',
|
||||||
document.body.appendChild(back);
|
why: 'A leader whose team goes three deep this week collects level 3 from day one instead of watching those 10% payments pass upward. Optional for members, the play for leaders.',
|
||||||
const inp = back.querySelector('#dlgInput');
|
note: 'Qualifying buyers so far: <b>' + bc + '</b> of 5.' },
|
||||||
const done = v => { document.removeEventListener('keydown', onKey); back.remove(); resolve(v); };
|
{ key: 'banner', title: 'Upload your line banner', done: !!m.lineBannerUrl, href: '/my#profile', cta: 'Profile',
|
||||||
const okv = () => done(o.type === 'none' ? true : (inp ? inp.value : ''));
|
how: 'Profile tab, line banner. It shows on the welcome tour to everyone in your next three levels.',
|
||||||
const onKey = e => { if (e.key === 'Escape') { e.preventDefault(); done(o.type === 'none' ? false : null); } else if (e.key === 'Enter' && o.type !== 'textarea') { e.preventDefault(); okv(); } };
|
why: 'Your first advertising to your own team, free, and it is live the moment they join.' },
|
||||||
document.addEventListener('keydown', onKey);
|
{ key: 'links', title: 'Copy your links and pick a play', done: man.has('links'), manual: true,
|
||||||
back.querySelector('#dlgOk').addEventListener('click', okv);
|
how: 'Promo tools, Your links: the invite link and the five angle links, plus the matching hook videos. Then read the plays page and choose one.',
|
||||||
if (back.querySelector('#dlgCancel')) back.querySelector('#dlgCancel').addEventListener('click', () => done(o.type === 'none' ? false : null));
|
why: 'On launch day you send links, not explanations. Having them ready is the whole difference between a launch and a scramble.' },
|
||||||
back.addEventListener('click', e => { if (e.target === back) done(o.type === 'none' ? false : null); });
|
{ key: 'two', title: 'Place your first two', done: refs >= 2, href: '/my#line', cta: 'My line',
|
||||||
setTimeout(() => { if (inp) { inp.focus(); if (inp.select && o.type !== 'textarea') inp.select(); } else back.querySelector('#dlgOk').focus(); }, 30);
|
how: 'Two people you have actually talked to, joined through your link, walked through items 1 to 3 on their own accounts.',
|
||||||
});
|
why: 'Your first two are the shape of your whole line. Choose them, do not wait for them.',
|
||||||
}
|
note: 'Joined through you so far: <b>' + refs + '</b>.' }
|
||||||
function ask(o) { return dialog(Object.assign({ type: 'text', value: '', placeholder: '' }, o || {})); }
|
];
|
||||||
function confirmBox(text, o) { return dialog(Object.assign({ type: 'none', text, ok: 'Yes', cancel: 'No' }, o || {})); }
|
}
|
||||||
// ── appearance (2026-11-01): Light / Dark / Auto, mirrored from LinkSpin. The head script (themehead.js) owns window.IAPTheme and
|
// In-page dialogs instead of window.prompt / confirm. Mobile Safari shows a red "Suppress dialogs"
|
||||||
// localStorage iap.theme; this paints every .theme-seg on the page (member-area header, Profile pane, admin header), saves a
|
// option on the second native pop-up in a row and, once tapped, swallows every later prompt on the
|
||||||
// click to the account when signed in (POST /api/my/profile {theme}), and at sign-in lets the account value win over the local
|
// site until reload. ask() resolves the typed value (null on cancel); confirmBox() resolves true/false.
|
||||||
// one (a local choice is pushed up when the account has none yet). Pages without a .theme-seg still get the theme from the head script.
|
function dialog(o) {
|
||||||
const THEME_VALUES = ['light', 'dark', 'auto'];
|
return new Promise(resolve => {
|
||||||
function storedTheme() { try { const v = localStorage.getItem('iap.theme'); return THEME_VALUES.includes(v) ? v : null; } catch (e) { return null; } }
|
const esc = t => String(t == null ? '' : t).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
||||||
function paintTheme() { const c = window.IAPTheme ? IAPTheme.get() : 'dark'; document.querySelectorAll('.theme-seg [data-theme]').forEach(b => { const on = b.dataset.theme === c; b.classList.toggle('on', on); b.setAttribute('aria-pressed', on ? 'true' : 'false'); }); }
|
const back = document.createElement('div'); back.className = 'modal-back'; back.style.zIndex = '200';
|
||||||
const saveTheme = v => fetch('/api/my/profile', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ theme: v }) }).catch(() => {});
|
const field = o.type === 'none' ? '' : o.type === 'textarea'
|
||||||
function themeSync(m) { if (!window.IAPTheme) return; const acct = m && m.signedIn && THEME_VALUES.includes(m.theme) ? m.theme : null; const local = storedTheme(); if (acct) { if (acct !== local) IAPTheme.set(acct, true); } else if (m && m.signedIn && local) saveTheme(local); paintTheme(); }
|
? '<textarea id="dlgInput" rows="5" style="width:100%;margin-top:12px">' + esc(o.value) + '</textarea>'
|
||||||
// the controls only exist on signed-in surfaces (member-area shell, admin), so a click always tries the save; signed out it is a harmless 401
|
: '<input id="dlgInput" type="' + (o.type === 'number' ? 'number' : 'text') + '" ' + (o.type === 'number' ? 'inputmode="decimal" min="0" step="any" ' : '') + 'value="' + esc(o.value) + '" placeholder="' + esc(o.placeholder) + '" style="width:100%;margin-top:12px" autocomplete="off">';
|
||||||
document.addEventListener('click', e => { const b = e.target.closest && e.target.closest('.theme-seg [data-theme]'); if (!b || !window.IAPTheme) return; const v = b.dataset.theme; IAPTheme.set(v); saveTheme(v); });
|
back.innerHTML = '<div class="modal-card" role="dialog" aria-modal="true">' + (o.title ? '<h3 style="margin:0 0 8px">' + esc(o.title) + '</h3>' : '')
|
||||||
window.addEventListener('iap-theme', paintTheme);
|
+ (o.text ? '<p class="muted small" style="margin:0;white-space:pre-line">' + esc(o.text) + '</p>' : '') + field
|
||||||
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', paintTheme); else paintTheme();
|
+ '<div style="display:flex;gap:10px;justify-content:flex-end;margin-top:16px;flex-wrap:wrap">' + (o.noCancel ? '' : '<button type="button" class="btn sec small" id="dlgCancel">' + esc(o.cancel || 'Cancel') + '</button>') + '<button type="button" class="btn small" id="dlgOk">' + esc(o.ok || 'OK') + '</button></div></div>';
|
||||||
return { getConfig, fmtPol, fmtUsd, status, renderNav, refreshNavWallet, describeEvent, feedRow, adSlot, reportAd, requestCode, launchChecks, launchToggle, ask, confirmBox, $, themeSync, paintTheme,
|
document.body.appendChild(back);
|
||||||
guard: { FORM_TS, iconCheck, hpValue, formSettled } }; // guard: the sign-up walls, reused by the support form and the chatbot hand-off
|
const inp = back.querySelector('#dlgInput');
|
||||||
})();
|
const done = v => { document.removeEventListener('keydown', onKey); back.remove(); resolve(v); };
|
||||||
// shown inside someone else's frame (traffic exchanges, 2026-10-03): sign-in, join and off-site links open in a new tab,
|
const okv = () => done(o.type === 'none' ? true : (inp ? inp.value : ''));
|
||||||
// because browsers refuse our session cookie inside another site's frame
|
const onKey = e => { if (e.key === 'Escape') { e.preventDefault(); done(o.type === 'none' ? false : null); } else if (e.key === 'Enter' && o.type !== 'textarea') { e.preventDefault(); okv(); } };
|
||||||
(function () {
|
document.addEventListener('keydown', onKey);
|
||||||
var framed = false; try { framed = window.top !== window.self; } catch (e) { framed = true; }
|
back.querySelector('#dlgOk').addEventListener('click', okv);
|
||||||
if (!framed) return;
|
if (back.querySelector('#dlgCancel')) back.querySelector('#dlgCancel').addEventListener('click', () => done(o.type === 'none' ? false : null));
|
||||||
// the sponsor this page was opened for (?ref=, /join/<tok>, /wall/<tok>); its cookie was refused in the frame, so the
|
back.addEventListener('click', e => { if (e.target === back) done(o.type === 'none' ? false : null); });
|
||||||
// new tab gets it in the link and the viral-link rule sets it there
|
setTimeout(() => { if (inp) { inp.focus(); if (inp.select && o.type !== 'textarea') inp.select(); } else back.querySelector('#dlgOk').focus(); }, 30);
|
||||||
var ref = ''; try { ref = new URLSearchParams(location.search).get('ref') || (location.pathname.match(/^\/(?:join|wall)\/([^/?#]+)/) || [])[1] || ''; } catch (e) {}
|
});
|
||||||
ref = String(ref).toLowerCase().replace(/[^a-z0-9_]/g, '').slice(0, 20);
|
}
|
||||||
document.addEventListener('click', function (e) {
|
function ask(o) { return dialog(Object.assign({ type: 'text', value: '', placeholder: '' }, o || {})); }
|
||||||
var a = e.target && e.target.closest && e.target.closest('a[href]'); if (!a) return;
|
function confirmBox(text, o) { return dialog(Object.assign({ type: 'none', text, ok: 'Yes', cancel: 'No' }, o || {})); }
|
||||||
var h = a.getAttribute('href') || ''; if (h.charAt(0) === '#' || /^javascript:/i.test(h)) return;
|
// ── appearance (2026-11-01): Light / Dark / Auto, mirrored from LinkSpin. The head script (themehead.js) owns window.IAPTheme and
|
||||||
var sign = a.host === location.host && /^\/(my|join|signin|login|from|admin)(\/|$)/.test(a.pathname);
|
// localStorage iap.theme; this paints every .theme-seg on the page (member-area header, Profile pane, admin header), saves a
|
||||||
if (sign && ref && a.pathname === '/my' && !/[?&]ref=/.test(a.search)) a.search = (a.search ? a.search + '&' : '?') + 'ref=' + ref;
|
// click to the account when signed in (POST /api/my/profile {theme}), and at sign-in lets the account value win over the local
|
||||||
if (sign || a.host !== location.host) { a.target = '_blank'; a.rel = 'noopener'; }
|
// one (a local choice is pushed up when the account has none yet). Pages without a .theme-seg still get the theme from the head script.
|
||||||
}, true);
|
const THEME_VALUES = ['light', 'dark', 'auto'];
|
||||||
})();
|
function storedTheme() { try { const v = localStorage.getItem('iap.theme'); return THEME_VALUES.includes(v) ? v : null; } catch (e) { return null; } }
|
||||||
// Level 4 override copy (2026-10-23): blocks marked data-when="override-live" stay hidden until the site setting
|
function paintTheme() { const c = window.IAPTheme ? IAPTheme.get() : 'dark'; document.querySelectorAll('.theme-seg [data-theme]').forEach(b => { const on = b.dataset.theme === c; b.classList.toggle('on', on); b.setAttribute('aria-pressed', on ? 'true' : 'false'); }); }
|
||||||
// overrideMode is 'live' and overrideGoLive is set; [data-ov-start] gets the start date in Central time
|
const saveTheme = v => fetch('/api/my/profile', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ theme: v }) }).catch(() => {});
|
||||||
(function () {
|
function themeSync(m) { if (!window.IAPTheme) return; const acct = m && m.signedIn && THEME_VALUES.includes(m.theme) ? m.theme : null; const local = storedTheme(); if (acct) { if (acct !== local) IAPTheme.set(acct, true); } else if (m && m.signedIn && local) saveTheme(local); paintTheme(); }
|
||||||
var els = document.querySelectorAll('[data-when="override-live"]'); if (!els.length || !window.IAP) return;
|
// the controls only exist on signed-in surfaces (member-area shell, admin), so a click always tries the save; signed out it is a harmless 401
|
||||||
IAP.getConfig().then(function (c) {
|
document.addEventListener('click', e => { const b = e.target.closest && e.target.closest('.theme-seg [data-theme]'); if (!b || !window.IAPTheme) return; const v = b.dataset.theme; IAPTheme.set(v); saveTheme(v); });
|
||||||
if (String(c.overrideMode || '') !== 'live' || !Number(c.overrideGoLive)) return;
|
window.addEventListener('iap-theme', paintTheme);
|
||||||
var d = new Date(Number(c.overrideGoLive)).toLocaleDateString('en-US', { timeZone: 'America/Chicago', month: 'long', day: 'numeric', year: 'numeric' });
|
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', paintTheme); else paintTheme();
|
||||||
document.querySelectorAll('[data-ov-start]').forEach(function (e) { e.textContent = d; });
|
return { getConfig, fmtPol, fmtUsd, status, renderNav, refreshNavWallet, describeEvent, feedRow, adSlot, reportAd, requestCode, launchChecks, launchToggle, ask, confirmBox, $, themeSync, paintTheme,
|
||||||
els.forEach(function (e) { e.hidden = false; });
|
guard: { FORM_TS, iconCheck, hpValue, formSettled } }; // guard: the sign-up walls, reused by the support form and the chatbot hand-off
|
||||||
}).catch(function () {});
|
})();
|
||||||
})();
|
// shown inside someone else's frame (traffic exchanges, 2026-10-03): sign-in, join and off-site links open in a new tab,
|
||||||
|
// because browsers refuse our session cookie inside another site's frame
|
||||||
|
(function () {
|
||||||
|
var framed = false; try { framed = window.top !== window.self; } catch (e) { framed = true; }
|
||||||
|
if (!framed) return;
|
||||||
|
// the sponsor this page was opened for (?ref=, /join/<tok>, /wall/<tok>); its cookie was refused in the frame, so the
|
||||||
|
// new tab gets it in the link and the viral-link rule sets it there
|
||||||
|
var ref = ''; try { ref = new URLSearchParams(location.search).get('ref') || (location.pathname.match(/^\/(?:join|wall)\/([^/?#]+)/) || [])[1] || ''; } catch (e) {}
|
||||||
|
ref = String(ref).toLowerCase().replace(/[^a-z0-9_]/g, '').slice(0, 20);
|
||||||
|
document.addEventListener('click', function (e) {
|
||||||
|
var a = e.target && e.target.closest && e.target.closest('a[href]'); if (!a) return;
|
||||||
|
var h = a.getAttribute('href') || ''; if (h.charAt(0) === '#' || /^javascript:/i.test(h)) return;
|
||||||
|
var sign = a.host === location.host && /^\/(my|join|signin|login|from|admin)(\/|$)/.test(a.pathname);
|
||||||
|
if (sign && ref && a.pathname === '/my' && !/[?&]ref=/.test(a.search)) a.search = (a.search ? a.search + '&' : '?') + 'ref=' + ref;
|
||||||
|
if (sign || a.host !== location.host) { a.target = '_blank'; a.rel = 'noopener'; }
|
||||||
|
}, true);
|
||||||
|
})();
|
||||||
|
// Level 4 override copy (2026-10-23): blocks marked data-when="override-live" stay hidden until the site setting
|
||||||
|
// overrideMode is 'live' and overrideGoLive is set; [data-ov-start] gets the start date in Central time
|
||||||
|
(function () {
|
||||||
|
var els = document.querySelectorAll('[data-when="override-live"]'); if (!els.length || !window.IAP) return;
|
||||||
|
IAP.getConfig().then(function (c) {
|
||||||
|
if (String(c.overrideMode || '') !== 'live' || !Number(c.overrideGoLive)) return;
|
||||||
|
var d = new Date(Number(c.overrideGoLive)).toLocaleDateString('en-US', { timeZone: 'America/Chicago', month: 'long', day: 'numeric', year: 'numeric' });
|
||||||
|
document.querySelectorAll('[data-ov-start]').forEach(function (e) { e.textContent = d; });
|
||||||
|
els.forEach(function (e) { e.hidden = false; });
|
||||||
|
}).catch(function () {});
|
||||||
|
})();
|
||||||
|
|
||||||
|
// Network links (2026-11-13): a click on a link to LinkSpin goes through /go/linkspin, which signs a signed-in member in over there and is a
|
||||||
|
// plain redirect for everyone else. Rewritten at click time only, so links people copy to share stay clean. data-nogo opts a link out.
|
||||||
|
(function () {
|
||||||
|
if (window.__netlinks) return; window.__netlinks = 1;
|
||||||
|
const HOSTS = ['linkspin.app', 'www.linkspin.app'];
|
||||||
|
document.addEventListener('click', e => {
|
||||||
|
if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
|
||||||
|
const a = e.target && e.target.closest ? e.target.closest('a[href]') : null;
|
||||||
|
if (!a || a.hasAttribute('download') || a.hasAttribute('data-nogo')) return;
|
||||||
|
let u; try { u = new URL(a.href); } catch (x) { return; }
|
||||||
|
if (u.protocol !== 'https:' || !HOSTS.includes(u.hostname)) return;
|
||||||
|
a.href = '/go/linkspin?to=' + encodeURIComponent(u.pathname + u.search + u.hash);
|
||||||
|
}, true);
|
||||||
|
})();
|
||||||
|
|||||||
@@ -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' };
|
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';
|
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 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
|
// "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 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';
|
const url = m[1] === 'LinkSpin' ? 'https://linkspin.app/credits#refuel' : 'https://instantadpay.com/my#buy';
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
let twin = '';
|
let twin = '';
|
||||||
if (!v.windowOpen && c.month && !c.both) twin = '<p class="small">Refuel ' + (c.iap && c.iap.refueled ? 'LinkSpin ($' + v.minUsd.linkspin + '+)' : 'InstantAdPay ($' + v.minUsd.iap + '+)') + ' before ' + esc(v.opensLabel) + ' and both sites move to <b>+' + v.next.secondEngine + '%</b>; the one you already refueled is topped up to match.'
|
if (!v.windowOpen && c.month && !c.both) twin = '<p class="small">Refuel ' + (c.iap && c.iap.refueled ? 'LinkSpin ($' + v.minUsd.linkspin + '+)' : 'InstantAdPay ($' + v.minUsd.iap + '+)') + ' before ' + esc(v.opensLabel) + ' and both sites move to <b>+' + v.next.secondEngine + '%</b>; the one you already refueled is topped up to match.'
|
||||||
// the second engine is on the other site: a direct way there (2026-10-25), landing on LinkSpin's Refuel panel with an arrival strip
|
// the second engine is on the other site: a direct way there (2026-10-25), landing on LinkSpin's Refuel panel with an arrival strip
|
||||||
+ (c.iap && c.iap.refueled ? ' <a href="https://linkspin.app/credits?from=iap&task=refuel#refuel" target="_blank" rel="noopener">Refuel LinkSpin ↗</a> (same email signs you in)' : '') + '</p>';
|
+ (c.iap && c.iap.refueled ? ' <a href="/go/linkspin?to=%2Fcredits%3Ffrom%3Diap%26task%3Drefuel%23refuel" target="_blank" rel="noopener">Refuel LinkSpin ↗</a> (same email signs you in)' : '') + '</p>';
|
||||||
let pit = '';
|
let pit = '';
|
||||||
if (v.pitStop) {
|
if (v.pitStop) {
|
||||||
const here = v.pitStop.iap ? 'available here (+' + v.pitStop.pct + '% on a $' + v.minUsd.iap + '+ top-up, once this cycle)' : v.pitStop.usedIap ? 'used here this cycle' : null;
|
const here = v.pitStop.iap ? 'available here (+' + v.pitStop.pct + '% on a $' + v.minUsd.iap + '+ top-up, once this cycle)' : v.pitStop.usedIap ? 'used here this cycle' : null;
|
||||||
|
|||||||
@@ -84,7 +84,8 @@
|
|||||||
function busy(btn, fn) {
|
function busy(btn, fn) {
|
||||||
return async () => { if (btn.disabled) return; btn.disabled = true; err(''); try { await fn(); } catch (e) { err(e.message || 'Something went wrong.'); } finally { btn.disabled = false; } };
|
return async () => { if (btn.disabled) return; btn.disabled = true; err(''); try { await fn(); } catch (e) { err(e.message || 'Something went wrong.'); } finally { btn.disabled = false; } };
|
||||||
}
|
}
|
||||||
const codeOpts = () => ({ honeypot: $('jnWebsite'), host: $('jnCheck'), ref: linkTok, angle: v || '' }); // the page's own token rides with the code request (cookie may be blocked in a frame)
|
const pageClick = (() => { const q = new URLSearchParams(location.search); return q.get('lsclk') || q.get('lsid') || ''; })(); // the LinkSpin click in this page's address: travels with the requests, the cookie may be refused in a frame (reporting only)
|
||||||
|
const codeOpts = () => ({ honeypot: $('jnWebsite'), host: $('jnCheck'), ref: linkTok, angle: v || '', lsclk: pageClick }); // the page's own token rides with the code request (cookie may be blocked in a frame)
|
||||||
const send = busy($('jnSend'), async () => {
|
const send = busy($('jnSend'), async () => {
|
||||||
const r = await IAP.requestCode($('jnEmail').value, codeOpts());
|
const r = await IAP.requestCode($('jnEmail').value, codeOpts());
|
||||||
$('jnCodeRow').hidden = false; $('jnVerify').hidden = false; $('jnSend').hidden = true; $('jnResend').hidden = false;
|
$('jnCodeRow').hidden = false; $('jnVerify').hidden = false; $('jnSend').hidden = true; $('jnResend').hidden = false;
|
||||||
@@ -105,7 +106,7 @@
|
|||||||
IAP.status('Fresh code sent.', 'ok');
|
IAP.status('Fresh code sent.', 'ok');
|
||||||
}));
|
}));
|
||||||
$('jnVerify').addEventListener('click', busy($('jnVerify'), async () => {
|
$('jnVerify').addEventListener('click', busy($('jnVerify'), async () => {
|
||||||
await api('/api/auth/email/verify', { email: $('jnEmail').value, code: $('jnCode').value, newsletter: !!$('jnNews').checked, followups: !!$('jnNews').checked, ref: linkTok });
|
await api('/api/auth/email/verify', { email: $('jnEmail').value, code: $('jnCode').value, newsletter: !!$('jnNews').checked, followups: !!$('jnNews').checked, ref: linkTok, lsclk: pageClick });
|
||||||
IAP.status('You are in. Taking you to your dashboard…', 'ok');
|
IAP.status('You are in. Taking you to your dashboard…', 'ok');
|
||||||
location.href = '/my?welcome=1'; // dashboard runs the username step + welcome tour on arrival
|
location.href = '/my?welcome=1'; // dashboard runs the username step + welcome tour on arrival
|
||||||
}));
|
}));
|
||||||
|
|||||||
+167
-22
@@ -1,4 +1,4 @@
|
|||||||
// member share links go out on the share domain (2026-10-20): https://ctbgo.com/<name> -> /join/<name> on InstantAdPay.
|
// member share links go out on the share domain (2026-10-20): https://instantadpay.link/<name> (ctbgo.com before 2026-11-04) -> /join/<name> on InstantAdPay.
|
||||||
// The domain comes from site config (shareDomain); empty falls back to this site's own /join link.
|
// The domain comes from site config (shareDomain); empty falls back to this site's own /join link.
|
||||||
let SHARE_DOMAIN = '';
|
let SHARE_DOMAIN = '';
|
||||||
const SHARE_READY = fetch('/api/config').then(r => r.json()).then(c => { SHARE_DOMAIN = String((c && c.shareDomain) || '').trim(); }).catch(() => {});
|
const SHARE_READY = fetch('/api/config').then(r => r.json()).then(c => { SHARE_DOMAIN = String((c && c.shareDomain) || '').trim(); }).catch(() => {});
|
||||||
@@ -39,7 +39,35 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
function tankHoldText(h) {
|
function tankHoldText(h) {
|
||||||
let t = "You're being matched with a sponsor. Payouts switch on as soon as someone picks you up (within 24 hours).";
|
let t = "You're being matched with a sponsor. Payouts switch on as soon as someone picks you up (within 24 hours).";
|
||||||
if (h && h.until) { const ms = h.until - Date.now(); t += ms > 0 ? ' Time left: ' + holdLeft(ms) + '.' : ' Any minute now.'; }
|
if (h && h.until) { const ms = h.until - Date.now(); t += ms > 0 ? ' Time left: ' + holdLeft(ms) + '.' : ' Any minute now.'; }
|
||||||
return t;
|
return t + ' Did someone invite you? Tell us on your Overview.';
|
||||||
|
}
|
||||||
|
// "Who invited you?" card (Marty approved 2026-11-07): a member with no sponsor and no member number can name who invited
|
||||||
|
// them. Soft: nothing else on the site waits for it, and "Nobody invited me" leaves a small link to bring it back.
|
||||||
|
function paintInvite(me) {
|
||||||
|
const c = $('inviteCard'), s = $('inviteSmall'); if (!c || !s) return;
|
||||||
|
const ask = !me.memberId && me.inviteAsk;
|
||||||
|
const small = !!(ask && ask.dismissed) && !paintInvite.reopened; // reopened from the small link: the next render must not close it under their fingers
|
||||||
|
c.hidden = !ask || small; s.hidden = !small;
|
||||||
|
}
|
||||||
|
if ($('inviteGo')) {
|
||||||
|
const say = (t, bad) => { const m = $('inviteMsg'); m.textContent = t || ''; m.style.color = bad ? 'var(--bad)' : ''; };
|
||||||
|
const go = async () => {
|
||||||
|
say('');
|
||||||
|
try {
|
||||||
|
const who = $('inviteWho').value;
|
||||||
|
const chk = await api('/api/my/tank/invited', { who, check: true });
|
||||||
|
if (!(await IAP.confirmBox(chk.name + ' becomes your sponsor. Your sponsor locks on the contract the first time you switch on payouts or buy, so check this is the right person.', { title: 'Who invited you?', ok: 'Yes, ' + chk.name, cancel: 'Not them' }))) return;
|
||||||
|
const r = await api('/api/my/tank/invited', { who });
|
||||||
|
$('inviteCard').hidden = true; IAP.status(r.name + ' is now your sponsor.', 'ok'); render();
|
||||||
|
} catch (e) { say(e.message, true); }
|
||||||
|
};
|
||||||
|
$('inviteGo').addEventListener('click', go);
|
||||||
|
$('inviteWho').addEventListener('keydown', e => { if (e.key === 'Enter') { e.preventDefault(); go(); } });
|
||||||
|
$('inviteNo').addEventListener('click', async () => {
|
||||||
|
try { await api('/api/my/tank/invited/dismiss', {}); } catch (e) {}
|
||||||
|
paintInvite.reopened = false; $('inviteCard').hidden = true; $('inviteSmall').hidden = false;
|
||||||
|
});
|
||||||
|
$('inviteBack').addEventListener('click', e => { e.preventDefault(); paintInvite.reopened = true; $('inviteSmall').hidden = true; $('inviteCard').hidden = false; $('inviteWho').focus(); });
|
||||||
}
|
}
|
||||||
// one-tap switch on payouts (2026-10-27): the tank assignment chat + emails link to /my?activate=1#wallet. The intent
|
// one-tap switch on payouts (2026-10-27): the tank assignment chat + emails link to /my?activate=1#wallet. The intent
|
||||||
// survives the sign-in and the wallet link (memory + sessionStorage) and runs the Activate button's own flow once.
|
// survives the sign-in and the wallet link (memory + sessionStorage) and runs the Activate button's own flow once.
|
||||||
@@ -127,6 +155,7 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
{ key: 'level3', label: 'Nexus', sub: 'fully qualified', img: '/badges/badge-nexus.jpg?v=2', ribbonY: 0.73 },
|
{ key: 'level3', label: 'Nexus', sub: 'fully qualified', img: '/badges/badge-nexus.jpg?v=2', ribbonY: 0.73 },
|
||||||
{ key: 'fridays', label: 'Five Fridays', sub: 'five Five Dollar Fridays in a row', img: '/badges/badge-fridays.jpg', ribbonY: 0.719 },
|
{ key: 'fridays', label: 'Five Fridays', sub: 'five Five Dollar Fridays in a row', img: '/badges/badge-fridays.jpg', ribbonY: 0.719 },
|
||||||
{ key: 'gamepass', label: 'Game Pass', sub: 'bought a Game Pass', img: '/badges/badge-gamepass.jpg', ribbonY: 0.84 },
|
{ key: 'gamepass', label: 'Game Pass', sub: 'bought a Game Pass', img: '/badges/badge-gamepass.jpg', ribbonY: 0.84 },
|
||||||
|
{ key: 'stackpro', label: 'Stack POL Pro', sub: 'unlocked Stack POL Pro', img: '/badges/badge-stackpro.jpg', ribbonY: 0.855 }, // 2026-11-09
|
||||||
// Monthly Refuel badges (2026-10-24): final art, ribbon heights measured per image
|
// Monthly Refuel badges (2026-10-24): final art, ribbon heights measured per image
|
||||||
{ key: 'refuelStart', label: 'Engine Started', sub: 'first monthly refuel', img: '/badges/badge-refuelstart.jpg?v=2', ribbonY: 0.735, earnedOnly: true },
|
{ key: 'refuelStart', label: 'Engine Started', sub: 'first monthly refuel', img: '/badges/badge-refuelstart.jpg?v=2', ribbonY: 0.735, earnedOnly: true },
|
||||||
{ key: 'refuel3', label: 'Refueled 3 months', sub: 'three monthly refuels in a row', img: '/badges/badge-refuel3.jpg?v=3', ribbonY: 0.783, earnedOnly: true },
|
{ key: 'refuel3', label: 'Refueled 3 months', sub: 'three monthly refuels in a row', img: '/badges/badge-refuel3.jpg?v=3', ribbonY: 0.783, earnedOnly: true },
|
||||||
@@ -316,20 +345,30 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
{ k: 'payouts', label: 'Payouts on', t: m => !!m.activated },
|
{ k: 'payouts', label: 'Payouts on', t: m => !!m.activated },
|
||||||
{ k: 'nowallet', label: 'No wallet', t: m => !m.wallet },
|
{ k: 'nowallet', label: 'No wallet', t: m => !m.wallet },
|
||||||
];
|
];
|
||||||
const listState = key => LIST_UI[key] || (LIST_UI[key] = { sort: 'seen', dir: -1, on: new Set() });
|
const listState = key => LIST_UI[key] || (LIST_UI[key] = { sort: 'seen', dir: -1, on: new Set(), q: '' });
|
||||||
|
// search box (Marty, 2026-11-12: "a user can find their member in the list"): name, username, email or member number
|
||||||
|
const listHay = m => [m.name, m.username, m.email, m.ref, m.src, m.memberId ? '#' + m.memberId : ''].filter(Boolean).join(' ').toLowerCase();
|
||||||
function listApply(key, rows) {
|
function listApply(key, rows) {
|
||||||
const st = listState(key); const s = LIST_SORTS.find(x => x.k === st.sort) || LIST_SORTS[0];
|
const st = listState(key); const s = LIST_SORTS.find(x => x.k === st.sort) || LIST_SORTS[0];
|
||||||
const out = (rows || []).filter(m => m.own || [...st.on].every(k => { const f = LIST_FILTERS.find(x => x.k === k); return !f || f.t(m); }));
|
const q = String(st.q || '').trim().toLowerCase().replace(/^@/, '');
|
||||||
|
const out = (rows || []).filter(m => (!q || listHay(m).includes(q))
|
||||||
|
&& (m.own || [...st.on].every(k => { const f = LIST_FILTERS.find(x => x.k === k); return !f || f.t(m); })));
|
||||||
out.sort((a, b) => { const x = s.v(a), y = s.v(b); return (s.str ? String(x).localeCompare(String(y)) : x - y) * st.dir; });
|
out.sort((a, b) => { const x = s.v(a), y = s.v(b); return (s.str ? String(x).localeCompare(String(y)) : x - y) * st.dir; });
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
function listBar(key, total, shown, rerender, opts) {
|
function listBar(key, total, shown, rerender, opts) {
|
||||||
const st = listState(key); const hide = (opts && opts.hide) || [];
|
const st = listState(key); const hide = (opts && opts.hide) || [];
|
||||||
const bar = document.createElement('div'); bar.className = 'lst-bar';
|
const bar = document.createElement('div'); bar.className = 'lst-bar';
|
||||||
bar.innerHTML = '<label class="lst-sort">Sort <select aria-label="Sort by">' + LIST_SORTS.map(s => '<option value="' + s.k + '"' + (s.k === st.sort ? ' selected' : '') + '>' + s.label + '</option>').join('') + '</select></label>'
|
bar.innerHTML = '<input type="search" class="lst-q" placeholder="Find a member: name, username or email" aria-label="Find a member in this list" autocomplete="off" spellcheck="false">'
|
||||||
|
+ '<label class="lst-sort">Sort <select aria-label="Sort by">' + LIST_SORTS.map(s => '<option value="' + s.k + '"' + (s.k === st.sort ? ' selected' : '') + '>' + s.label + '</option>').join('') + '</select></label>'
|
||||||
+ '<button type="button" class="lst-dir" title="Flip the order">' + (st.dir < 0 ? '↓ high to low' : '↑ low to high') + '</button>'
|
+ '<button type="button" class="lst-dir" title="Flip the order">' + (st.dir < 0 ? '↓ high to low' : '↑ low to high') + '</button>'
|
||||||
+ '<span class="lst-chips">' + LIST_FILTERS.filter(f => !hide.includes(f.k)).map(f => '<button type="button" class="lst-chip' + (st.on.has(f.k) ? ' on' : '') + '" data-f="' + f.k + '" aria-pressed="' + (st.on.has(f.k) ? 'true' : 'false') + '">' + f.label + '</button>').join('') + '</span>'
|
+ '<span class="lst-chips">' + LIST_FILTERS.filter(f => !hide.includes(f.k)).map(f => '<button type="button" class="lst-chip' + (st.on.has(f.k) ? ' on' : '') + '" data-f="' + f.k + '" aria-pressed="' + (st.on.has(f.k) ? 'true' : 'false') + '">' + f.label + '</button>').join('') + '</span>'
|
||||||
+ '<span class="lst-n">' + (shown === total ? total + (total === 1 ? ' person' : ' people') : shown + ' of ' + total) + '</span>';
|
+ '<span class="lst-n">' + (shown === total ? total + (total === 1 ? ' person' : ' people') : shown + ' of ' + total) + '</span>';
|
||||||
|
// the list (and this bar with it) is rebuilt on every keystroke, so the new box takes the focus and caret back
|
||||||
|
const qi = bar.querySelector('.lst-q'); qi.value = st.q || '';
|
||||||
|
if (Date.now() - (st.qAt || 0) < 1000) setTimeout(() => { qi.focus(); const n = qi.value.length; try { qi.setSelectionRange(n, n); } catch (e) {} }, 0);
|
||||||
|
let qt = null;
|
||||||
|
qi.addEventListener('input', () => { clearTimeout(qt); qt = setTimeout(() => { st.q = qi.value; st.qAt = Date.now(); Object.keys(PAGE_AT).forEach(k => { if (k === key || k.startsWith(key + '-')) delete PAGE_AT[k]; }); rerender(); }, 150); }); // a new search starts on page 1
|
||||||
bar.querySelector('select').addEventListener('change', e => { st.sort = e.target.value; st.dir = st.sort === 'name' ? 1 : -1; rerender(); });
|
bar.querySelector('select').addEventListener('change', e => { st.sort = e.target.value; st.dir = st.sort === 'name' ? 1 : -1; rerender(); });
|
||||||
bar.querySelector('.lst-dir').addEventListener('click', () => { st.dir = -st.dir; rerender(); });
|
bar.querySelector('.lst-dir').addEventListener('click', () => { st.dir = -st.dir; rerender(); });
|
||||||
bar.querySelectorAll('[data-f]').forEach(b => b.addEventListener('click', () => { const k = b.dataset.f; if (st.on.has(k)) st.on.delete(k); else st.on.add(k); rerender(); }));
|
bar.querySelectorAll('[data-f]').forEach(b => b.addEventListener('click', () => { const k = b.dataset.f; if (st.on.has(k)) st.on.delete(k); else st.on.add(k); rerender(); }));
|
||||||
@@ -593,18 +632,28 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
}).join('');
|
}).join('');
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
// where a direct came from + how they joined (Marty, 2026-11-12: "it was kind of buried in there"). src = the first-touch
|
||||||
|
// referring site, with the link's ?src= tag since 2026-11-12 ("mailer.gold/mailergold", or just "mailergold"); via = the path.
|
||||||
|
const VIA_LABEL = { btc4hits: 'moved over from BTC4Hits', linkspin: 'came over from LinkSpin', page: 'your bridge page', direct: 'your invite link',
|
||||||
|
'fw-earn': 'FaucetWave', 't1-adv': 'Tier1Ads', polminer: 'POL Miner', seek: 'ClutterHunt', polhunter: 'PolHunter', driprunner: 'Drip Runner', gemkingdom: 'Gem Kingdom', tank: 'adopted from the holding tank' };
|
||||||
|
const srcLabel = s => !s ? '' : s === 'direct' ? 'no referring site' : s === 'linkspin' ? 'LinkSpin' : /^legacy:/.test(s) ? s.split(':')[1] : s;
|
||||||
|
const originText = m => { const a = srcLabel(m.src), b = m.via ? (VIA_LABEL[m.via] || ('link "' + m.via + '"')) : '';
|
||||||
|
return (a ? 'from ' + a : '') + (a && b ? ' · ' : '') + (b ? 'via ' + b : ''); };
|
||||||
// visual line tree on the Overview: YOU + three levels, qualified directs in gold
|
// visual line tree on the Overview: YOU + three levels, qualified directs in gold
|
||||||
function renderRoster(wrap, all) {
|
function renderRoster(wrap, all) {
|
||||||
const rows = listApply('roster', all);
|
const rows = listApply('roster', all);
|
||||||
wrap.querySelectorAll(':scope > .lst-bar, :scope > table, :scope > .pgr, :scope > .lst-none').forEach(n => n.remove());
|
wrap.querySelectorAll(':scope > .lst-bar, :scope > table, :scope > .pgr, :scope > .lst-none').forEach(n => n.remove());
|
||||||
wrap.appendChild(listBar('roster', all.length, rows.length, () => renderRoster(wrap, all)));
|
wrap.appendChild(listBar('roster', all.length, rows.length, () => renderRoster(wrap, all)));
|
||||||
if (!rows.length) { wrap.insertAdjacentHTML('beforeend', '<p class="muted small lst-none">Nobody in your line matches those filters.</p>'); return; }
|
if (!rows.length) { wrap.insertAdjacentHTML('beforeend', '<p class="muted small lst-none">Nobody in your line matches your search or filters.</p>'); return; }
|
||||||
const t = document.createElement('table'); t.className = 'roster';
|
const t = document.createElement('table'); t.className = 'roster';
|
||||||
t.innerHTML = rows.map(r => '<tr><td>' + esc(r.name || r.email || '') + '</td>'
|
t.innerHTML = rows.map(r => '<tr><td>' + (r.email && /\*\*\*/.test(r.name || '') ? '<span class="muted">no username yet</span>' : esc(r.name ? (/^@|\*\*\*/.test(r.name) ? r.name : '@' + r.name) : r.email || ''))
|
||||||
|
+ (r.email ? '<div class="small mono roster-em">' + esc(r.email) + ' <button type="button" class="lst-copy" data-copy="' + esc(r.email) + '" title="Copy email">copy</button></div>' : '')
|
||||||
|
+ (originText(r) ? '<div class="muted small">' + esc(originText(r)) + '</div>' : '') + '</td>'
|
||||||
+ '<td><span class="muted">joined</span> ' + new Date(r.joined).toLocaleDateString() + '</td>'
|
+ '<td><span class="muted">joined</span> ' + new Date(r.joined).toLocaleDateString() + '</td>'
|
||||||
+ '<td>' + memberChips(r) + '</td>'
|
+ '<td>' + memberChips(r) + '</td>'
|
||||||
+ '<td><span class="badge' + (r.status === 'joined free' ? ' amber' : '') + '">' + esc(r.status) + '</span></td></tr>').join('');
|
+ '<td><span class="badge' + (r.status === 'joined free' ? ' amber' : '') + '">' + esc(r.status) + '</span></td></tr>').join('');
|
||||||
wrap.appendChild(t);
|
wrap.appendChild(t);
|
||||||
|
t.querySelectorAll('[data-copy]').forEach(b => b.addEventListener('click', async () => { try { await navigator.clipboard.writeText(b.dataset.copy); IAP.status('Email copied.', 'ok'); } catch (e) { IAP.status('Copy failed. Select the address and copy it.', 'bad'); } }));
|
||||||
pageList('roster', wrap, 'table.roster tr', { per: LINE_PER });
|
pageList('roster', wrap, 'table.roster tr', { per: LINE_PER });
|
||||||
}
|
}
|
||||||
async function loadLineTree(buyerCount) {
|
async function loadLineTree(buyerCount) {
|
||||||
@@ -812,6 +861,10 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
{ const tokP = d.username || d.refCode || d.memberId; const ps = $('promoPresStrip');
|
{ const tokP = d.username || d.refCode || d.memberId; const ps = $('promoPresStrip');
|
||||||
if (ps && tokP) { const pl = 'https://instantadpay.com/presentation?ref=' + encodeURIComponent(tokP); ps.hidden = false; $('promoPresLink').textContent = pl; $('promoPresOpen').href = '/presentation?ref=' + encodeURIComponent(tokP);
|
if (ps && tokP) { const pl = 'https://instantadpay.com/presentation?ref=' + encodeURIComponent(tokP); ps.hidden = false; $('promoPresLink').textContent = pl; $('promoPresOpen').href = '/presentation?ref=' + encodeURIComponent(tokP);
|
||||||
$('promoPresCopy').onclick = async () => { try { await navigator.clipboard.writeText(pl); IAP.status('Presentation link copied.', 'ok'); } catch (e) { IAP.status('Copy failed. Select the link and copy it.', 'bad'); } }; } }
|
$('promoPresCopy').onclick = async () => { try { await navigator.clipboard.writeText(pl); IAP.status('Presentation link copied.', 'ok'); } catch (e) { IAP.status('Copy failed. Select the link and copy it.', 'bad'); } }; } }
|
||||||
|
// Chasing Unicorns (2026-11-12): the scam-spotting lead magnet, shared with the member's ?ref= (the viral link sets the sponsor)
|
||||||
|
{ const tokU = d.username || d.refCode || d.memberId; const us = $('promoUniStrip');
|
||||||
|
if (us && tokU) { const ul = 'https://instantadpay.com/chasing-unicorns?ref=' + encodeURIComponent(tokU); us.hidden = false; $('promoUniLink').textContent = ul; $('promoUniOpen').href = '/chasing-unicorns?ref=' + encodeURIComponent(tokU);
|
||||||
|
$('promoUniCopy').onclick = async () => { try { await navigator.clipboard.writeText(ul); IAP.status('Chasing Unicorns link copied.', 'ok'); } catch (e) { IAP.status('Copy failed. Select the link and copy it.', 'bad'); } }; } }
|
||||||
if (d.username) { // wall link rides the username
|
if (d.username) { // wall link rides the username
|
||||||
const wl = location.origin + '/wall/' + d.username;
|
const wl = location.origin + '/wall/' + d.username;
|
||||||
$('wallLine').textContent = wl;
|
$('wallLine').textContent = wl;
|
||||||
@@ -884,6 +937,7 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
if (name === 'campaigns') ['cTarget', 'cImage', 'cVideoUrl'].forEach(id => { if ($(id)) $(id).value = ''; }); // no residual URL between visits
|
if (name === 'campaigns') ['cTarget', 'cImage', 'cVideoUrl'].forEach(id => { if ($(id)) $(id).value = ''; }); // no residual URL between visits
|
||||||
if (name === 'training') { if (/(^|&)g=leader/.test(paneQ)) loadTraining.filter = 'Leader tools'; loadTraining(); }
|
if (name === 'training') { if (/(^|&)g=leader/.test(paneQ)) loadTraining.filter = 'Leader tools'; loadTraining(); }
|
||||||
if (name === 'pipeline') loadPipeline();
|
if (name === 'pipeline') loadPipeline();
|
||||||
|
if (name === 'promo') { const ps = /(^|&)s=([a-z]+)/.exec(paneQ || ''); if (ps) setPromoSub(ps[2]); }
|
||||||
if (name === 'games') loadGames(paneQ);
|
if (name === 'games') loadGames(paneQ);
|
||||||
if (name === 'help' && window.IAPSupport) IAPSupport.help(paneQ); // help desk tickets (2026-10-16)
|
if (name === 'help' && window.IAPSupport) IAPSupport.help(paneQ); // help desk tickets (2026-10-16)
|
||||||
document.getElementById('memberArea').classList.remove('side-open'); // close mobile drawer
|
document.getElementById('memberArea').classList.remove('side-open'); // close mobile drawer
|
||||||
@@ -928,12 +982,15 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
if (!render.gating) { render.gating = true; showOnboard(true).then(() => { render.gating = false; render(); }); }
|
if (!render.gating) { render.gating = true; showOnboard(true).then(() => { render.gating = false; render(); }); }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
paintInvite(me);
|
||||||
// came from a Drip Runner share link: once they have a username, straight back into the game (2026-09-30)
|
// came from a Drip Runner share link: once they have a username, straight back into the game (2026-09-30)
|
||||||
if (me.returnTo === 'driprunner' && !render.toGame) { render.toGame = true; location.href = '/api/my/driprunner'; return; }
|
if (me.returnTo === 'driprunner' && !render.toGame) { render.toGame = true; location.href = '/api/my/driprunner'; return; }
|
||||||
if (me.returnTo === 'gemkingdom' && !render.toGame) { render.toGame = true; location.href = '/api/my/gemkingdom'; return; } // Gem Kingdom sent them here to sign in (2026-10-01)
|
if (me.returnTo === 'gemkingdom' && !render.toGame) { render.toGame = true; location.href = '/api/my/gemkingdom'; return; } // Gem Kingdom sent them here to sign in (2026-10-01)
|
||||||
if (me.returnTo === 'gkshop' && !render.toGame) { render.toGame = true; location.href = '/gk/shop/resume'; return; }
|
if (me.returnTo === 'gkshop' && !render.toGame) { render.toGame = true; location.href = '/gk/shop/resume'; return; }
|
||||||
if (me.returnTo === 'spookydoors' && !render.toGame) { render.toGame = true; location.href = '/api/my/spookydoors'; return; } // Spooky Doors sent them here to sign in (2026-10-02)
|
if (me.returnTo === 'spookydoors' && !render.toGame) { render.toGame = true; location.href = '/api/my/spookydoors'; return; } // Spooky Doors sent them here to sign in (2026-10-02)
|
||||||
if (me.returnTo === 'polybreak' && !render.toGame) { render.toGame = true; location.href = '/api/my/polybreak'; return; } // PolyBreak sent them here to sign in (2026-10-13)
|
if (me.returnTo === 'polybreak' && !render.toGame) { render.toGame = true; location.href = '/api/my/polybreak'; return; } // PolyBreak sent them here to sign in (2026-10-13)
|
||||||
|
if (me.returnTo === 'nsso' && !render.toGame) { render.toGame = true; location.href = '/sso/resume'; return; } // tapped "Sign in with InstantAdPay" on another network site while signed out here (2026-11-14)
|
||||||
|
if (me.returnTo === 'forum' && !render.toGame) { render.toGame = true; location.href = '/api/my/forum'; return; } // Earners Corner forum sign-in (2026-11-10)
|
||||||
if (me.returnTo === 'polminer' && !render.toGame) { render.toGame = true; location.href = '/api/my/polminer'; return; } // POL Miner sent them here to sign in (2026-10-28)
|
if (me.returnTo === 'polminer' && !render.toGame) { render.toGame = true; location.href = '/api/my/polminer'; return; } // POL Miner sent them here to sign in (2026-10-28)
|
||||||
if (me.returnTo === 'warpwares' && !render.toGame) { render.toGame = true; location.href = '/api/my/warpwares'; return; } // Warp & Wares sent them here to sign in (2026-10-29)
|
if (me.returnTo === 'warpwares' && !render.toGame) { render.toGame = true; location.href = '/api/my/warpwares'; return; } // Warp & Wares sent them here to sign in (2026-10-29)
|
||||||
if (me.returnTo === 'turkeydrop' && !render.toGame) { render.toGame = true; location.href = '/api/my/turkeydrop'; return; } // Turkey Drop sent them here to sign in (2026-10-28)
|
if (me.returnTo === 'turkeydrop' && !render.toGame) { render.toGame = true; location.href = '/api/my/turkeydrop'; return; } // Turkey Drop sent them here to sign in (2026-10-28)
|
||||||
@@ -1172,7 +1229,7 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
else if (Number(c.created) >= since) { spent = Number(c.spent || 0); basis = 'the credits it spent since it started on ' + new Date(Number(c.created)).toLocaleDateString([], { month: 'short', day: 'numeric' }) + ', inside the 30 days'; }
|
else if (Number(c.created) >= since) { spent = Number(c.spent || 0); basis = 'the credits it spent since it started on ' + new Date(Number(c.created)).toLocaleDateString([], { month: 'short', day: 'numeric' }) + ', inside the 30 days'; }
|
||||||
const parts = d.goals.map(g => { const n = Number(b && b.conv && b.conv[g.px]) || 0;
|
const parts = d.goals.map(g => { const n = Number(b && b.conv && b.conv[g.px]) || 0;
|
||||||
return '<span>' + esc(g.name) + ' ' + n.toLocaleString() + (n > 0 && spent != null ? ' (' + convFmt(spent / n) + ' credits each)' : '') + '</span>'; });
|
return '<span>' + esc(g.name) + ' ' + n.toLocaleString() + (n > 0 && spent != null ? ' (' + convFmt(spent / n) + ' credits each)' : '') + '</span>'; });
|
||||||
el.innerHTML = '\u{1F3AF} <span class="muted">Goals and cost per goal (30 days):</span> ' + parts.join(' · ') + (spent == null ? ' <span class="muted">· no spend on record for these 30 days, so no cost per goal</span>' : '') + (b && b.clicks ? ' <span class="muted">· ' + Number(b.clicks).toLocaleString() + ' tracked clicks</span>' : '');
|
el.innerHTML = '\u{1F3AF} <span class="muted">Goals and cost per goal (30 days):</span> ' + parts.join(' · ') + (spent == null ? ' <span class="muted">· no spend on record for these 30 days, so no cost per goal</span>' : '') + (b && b.clicks ? ' <span class="muted">· ' + Number(b.clicks).toLocaleString() + ' tracked clicks</span>' : '') + (() => { const nb = ((d.network || {}).byCampaign || {})[id]; if (!nb) return ''; const bits = [['join', 'joins'], ['wallet', 'wallets'], ['purchase', 'purchases']].filter(([k]) => nb[k]).map(([k, l]) => nb[k].toLocaleString() + ' ' + l); return bits.length ? ' <span>· ' + bits.join(' · ') + (nb.value ? ' ($' + Number(nb.value).toFixed(2) + ')' : '') + '</span>' : ''; })();
|
||||||
el.title = 'Goals counted for this campaign in the last 30 days. Cost per goal (30 days) = ' + (spent != null ? basis : 'the credits it spent in the same 30 days') + ', divided by those goals.';
|
el.title = 'Goals counted for this campaign in the last 30 days. Cost per goal (30 days) = ' + (spent != null ? basis : 'the credits it spent in the same 30 days') + ', divided by those goals.';
|
||||||
el.hidden = false;
|
el.hidden = false;
|
||||||
});
|
});
|
||||||
@@ -1186,6 +1243,10 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
const st = $('convStatus'), list = $('convGoals'), snips = $('convSnips'), add = $('convAddRow');
|
const st = $('convStatus'), list = $('convGoals'), snips = $('convSnips'), add = $('convAddRow');
|
||||||
if (!d || !d.ok) { st.textContent = (d && d.error) || 'Conversion tracking is not available right now.'; list.innerHTML = ''; snips.innerHTML = ''; add.hidden = !!(d && d.reason === 'off'); return; }
|
if (!d || !d.ok) { st.textContent = (d && d.error) || 'Conversion tracking is not available right now.'; list.innerHTML = ''; snips.innerHTML = ''; add.hidden = !!(d && d.reason === 'off'); return; }
|
||||||
add.hidden = false;
|
add.hidden = false;
|
||||||
|
// network events (2026-11-07): sign-ups, wallets and purchases on the member's clicks, plus goals, each once (LinkSpin's one list)
|
||||||
|
{ const nt = $('convNet'), rows = (d.network && d.network.rows) || []; const NAME = { join: 'joins', lead: 'leads', wallet: 'wallets', purchase: 'purchases', external: 'partner postbacks' };
|
||||||
|
nt.hidden = !rows.length;
|
||||||
|
if (rows.length) nt.innerHTML = '<b>Everything your clicks led to (30 days):</b> ' + rows.map(x => esc(Number(x.n).toLocaleString() + ' ' + (NAME[x.k] || String(x.k).replace(/^goal:\s*/, '') + ' (goal)')) + (x.value ? ' ($' + Number(x.value).toFixed(2) + ')' : '')).join(' \u00b7 ') + '.'; }
|
||||||
const goals = d.goals || [];
|
const goals = d.goals || [];
|
||||||
const m = d.methods || {}; const mt = ['url', 'stored', 'cookie', 'soft'].reduce((s, k) => s + (Number(m[k]) || 0), 0);
|
const m = d.methods || {}; const mt = ['url', 'stored', 'cookie', 'soft'].reduce((s, k) => s + (Number(m[k]) || 0), 0);
|
||||||
const selfN = Number(d.selfTests) || 0; // own clicks (ads here, spin links and Banner Spins on LinkSpin), kept as tests
|
const selfN = Number(d.selfTests) || 0; // own clicks (ads here, spin links and Banner Spins on LinkSpin), kept as tests
|
||||||
@@ -1274,10 +1335,13 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
tbl.className = 'tablewrap';
|
tbl.className = 'tablewrap';
|
||||||
// syndicated rate (Marty, 2026-10-27, 4:1): network views and partner visits cost 1/N of a view or visit here
|
// syndicated rate (Marty, 2026-10-27, 4:1): network views and partner visits cost 1/N of a view or visit here
|
||||||
const synN = Math.max(1, Math.floor(Number(r.rates && r.rates.synRateDivisor) || 1));
|
const synN = Math.max(1, Math.floor(Number(r.rates && r.rates.synRateDivisor) || 1));
|
||||||
const netCell = c => ['banner', 'text'].includes(c.type) ? (c.impsNas || 0).toLocaleString() + (synN > 1 && c.impsNas ? ' <span class="muted small">at 1/' + synN + '</span>' : '')
|
// text ads have their own network rate since 2026-11-12 (Marty: 1/10, text budgets were gone in about a week)
|
||||||
|
const synT = Math.max(1, Math.floor(Number(r.rates && r.rates.synRateDivisorText != null ? r.rates.synRateDivisorText : synN) || 1));
|
||||||
|
const nOf = c => c.type === 'text' ? synT : synN;
|
||||||
|
const netCell = c => ['banner', 'text'].includes(c.type) ? (c.impsNas || 0).toLocaleString() + (nOf(c) > 1 && c.impsNas ? ' <span class="muted small">at 1/' + nOf(c) + '</span>' : '')
|
||||||
: (c.type === 'visits' && c.impsSyn) ? c.impsSyn.toLocaleString() + ' <span class="muted small">partner visits' + (synN > 1 ? ', ' + synN + ' = 1 visit' : '') + '</span>'
|
: (c.type === 'visits' && c.impsSyn) ? c.impsSyn.toLocaleString() + ' <span class="muted small">partner visits' + (synN > 1 ? ', ' + synN + ' = 1 visit' : '') + '</span>'
|
||||||
: '<span class="muted small" title="only banner and text ads syndicate to the network">n/a</span>';
|
: '<span class="muted small" title="only banner and text ads syndicate to the network">n/a</span>';
|
||||||
if (synN > 1) { const n = document.createElement('p'); n.className = 'muted small'; n.textContent = 'Views and visits here on InstantAdPay use credits at the normal rate. Your ads also run on Network Ad Space and partner sites, and that delivery costs a ' + (synN === 4 ? 'quarter' : '1/' + synN) + ' of the rate: ' + synN + ' network views cost what 1 view here does, and ' + synN + ' partner visits use up 1 visit of your pack. Your budget goes further and every credit still buys real delivery.'; el.appendChild(n); }
|
if (synN > 1) { const n = document.createElement('p'); n.className = 'muted small'; n.textContent = 'Views and visits here on InstantAdPay use credits at the normal rate. Your ads also run on Network Ad Space and partner sites, and that delivery costs a ' + (synN === 4 ? 'quarter' : '1/' + synN) + ' of the rate: ' + synN + ' network views of a banner cost what 1 view here does, and ' + synN + ' partner visits use up 1 visit of your pack.' + (synT !== synN ? ' Text ads go further still: ' + synT + ' network views of a text ad cost what 1 view here does.' : '') + ' Your budget goes further and every credit still buys real delivery.'; el.appendChild(n); }
|
||||||
tbl.innerHTML = '<table class="camp-table"><thead><tr><th>Name</th><th>Type</th><th class="num">Views here</th><th class="num" title="Impressions delivered by Network Ad Space across the wider network (banner and text ads), and visits from partner sites (visit packs)' + (synN > 1 ? ', at 1/' + synN + ' of the rate here' : '') + '">Network views</th><th class="num">Clicks</th>'
|
tbl.innerHTML = '<table class="camp-table"><thead><tr><th>Name</th><th>Type</th><th class="num">Views here</th><th class="num" title="Impressions delivered by Network Ad Space across the wider network (banner and text ads), and visits from partner sites (visit packs)' + (synN > 1 ? ', at 1/' + synN + ' of the rate here' : '') + '">Network views</th><th class="num">Clicks</th>'
|
||||||
+ '<th class="num">Spent</th><th class="num">Budget</th><th>Status</th><th></th></tr></thead><tbody>'
|
+ '<th class="num">Spent</th><th class="num">Budget</th><th>Status</th><th></th></tr></thead><tbody>'
|
||||||
+ r.campaigns.map(c => '<tr><td data-l="Campaign"><b>' + c.name + '</b>' + hourBars(r.hours && r.hours[c.id]) + geoLine(r.geo && r.geo[c.id]) + '<div class="muted small conv-line" data-convcamp="' + c.id + '" hidden></div></td>'
|
+ r.campaigns.map(c => '<tr><td data-l="Campaign"><b>' + c.name + '</b>' + hourBars(r.hours && r.hours[c.id]) + geoLine(r.geo && r.geo[c.id]) + '<div class="muted small conv-line" data-convcamp="' + c.id + '" hidden></div></td>'
|
||||||
@@ -1900,15 +1964,17 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
function renderTank(el, r) {
|
function renderTank(el, r) {
|
||||||
const rows = listApply('tank', r.waiting).sort((a, b) => (b.ready ? 1 : 0) - (a.ready ? 1 : 0)); // ready to activate always on top (stable: the chosen order stays inside each group)
|
const opens = w => w.opensAt > Date.now(); // new sign-up: they have 24 hours to say who invited them
|
||||||
|
const opensBadge = w => ' <span class="badge amber" title="New member. They have 24 hours from sign-up to tell us who invited them. You can adopt them after that.">Opens in ' + holdLeft(w.opensAt - Date.now()) + '</span>';
|
||||||
|
const rows = listApply('tank', r.waiting).sort((a, b) => (opens(a) ? 1 : 0) - (opens(b) ? 1 : 0) || (b.ready ? 1 : 0) - (a.ready ? 1 : 0)); // ready to activate always on top, the sign-up grace ones last (stable: the chosen order stays inside each group)
|
||||||
el.innerHTML = '';
|
el.innerHTML = '';
|
||||||
el.appendChild(listBar('tank', r.waiting.length, rows.length, () => renderTank(el, r), { hide: ['payouts'] })); // nobody in the tank has payouts on
|
el.appendChild(listBar('tank', r.waiting.length, rows.length, () => renderTank(el, r), { hide: ['payouts'] })); // nobody in the tank has payouts on
|
||||||
const readyBadge = w => w.ready ? ' <span class="badge" style="background:var(--ok-soft);border-color:var(--ok);color:var(--ok)" title="Wallet linked. If nobody adopts them, the site assigns them to the next eligible adopter when the time runs out.">Ready to activate \u00b7 ' + (w.holdUntil > Date.now() ? holdLeft(w.holdUntil - Date.now()) + ' left' : 'assigning now') + '</span>' : '';
|
const readyBadge = w => w.ready ? ' <span class="badge" style="background:var(--ok-soft);border-color:var(--ok);color:var(--ok)" title="Wallet linked. If nobody adopts them, the site assigns them to the next eligible adopter when the time runs out.">Ready to activate \u00b7 ' + (w.holdUntil > Date.now() ? holdLeft(w.holdUntil - Date.now()) + ' left' : 'assigning now') + '</span>' : '';
|
||||||
el.insertAdjacentHTML('beforeend', rows.length ? rows.map(w => '<div class="lin-row"><span class="nm">' + esc(w.name) + readyBadge(w) + '</span>'
|
el.insertAdjacentHTML('beforeend', rows.length ? rows.map(w => '<div class="lin-row"><span class="nm">' + esc(w.name) + (opens(w) ? opensBadge(w) : readyBadge(w)) + '</span>'
|
||||||
+ '<span class="em">joined ' + ago(w.joined) + '<span class="sp wrap">' + memberChips(w) + '</span></span>'
|
+ '<span class="em">joined ' + ago(w.joined) + '<span class="sp wrap">' + memberChips(w) + '</span></span>'
|
||||||
+ '<span class="dt">last sign-in: <b>' + ago(w.lastSeen) + '</b></span>'
|
+ '<span class="dt">last sign-in: <b>' + ago(w.lastSeen) + '</b></span>'
|
||||||
+ (r.eligible ? '<button class="btn small" type="button" data-adopt="' + esc(w.username || w.email) + '" data-aname="' + esc(w.name) + '">Adopt</button>' : '') + '</div>').join('')
|
+ (r.eligible && !opens(w) ? '<button class="btn small" type="button" data-adopt="' + esc(w.username || w.email) + '" data-aname="' + esc(w.name) + '">Adopt</button>' : '') + '</div>').join('')
|
||||||
: '<p class="muted small">Nobody in the tank matches those filters.</p>');
|
: '<p class="muted small">Nobody in the tank matches your search or filters.</p>');
|
||||||
pageList('tank', el, ':scope > .lin-row', { per: LINE_PER });
|
pageList('tank', el, ':scope > .lin-row', { per: LINE_PER });
|
||||||
el.querySelectorAll('[data-adopt]').forEach(b => b.addEventListener('click', async () => {
|
el.querySelectorAll('[data-adopt]').forEach(b => b.addEventListener('click', async () => {
|
||||||
const note = await IAP.ask({ title: 'Adopt ' + b.dataset.aname, text: 'Your first message to ' + b.dataset.aname + ' (sent as a chat and an email):', type: 'textarea', ok: 'Adopt and send', value: 'Hi, I picked you up from the InstantAdPay holding tank so you have a sponsor who will actually help. Reply here and I will walk you through the first three steps.' });
|
const note = await IAP.ask({ title: 'Adopt ' + b.dataset.aname, text: 'Your first message to ' + b.dataset.aname + ' (sent as a chat and an email):', type: 'textarea', ok: 'Adopt and send', value: 'Hi, I picked you up from the InstantAdPay holding tank so you have a sponsor who will actually help. Reply here and I will walk you through the first three steps.' });
|
||||||
@@ -2048,6 +2114,35 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
// package's ad credits (the base credits per package, same table as Buy packages; day bonuses can add more)
|
// package's ad credits (the base credits per package, same table as Buy packages; day bonuses can add more)
|
||||||
const GP_PKG_CREDITS = { 5: 500, 10: 1000, 20: 2000, 50: 5500, 100: 12000, 250: 32500, 500: 70000 };
|
const GP_PKG_CREDITS = { 5: 500, 10: 1000, 20: 2000, 50: 5500, 100: 12000, 250: 32500, 500: 70000 };
|
||||||
const gpLen = d => d >= 365 && d % 365 === 0 ? (d === 365 ? '1 year' : (d / 365) + ' years') : d + ' days';
|
const gpLen = d => d >= 365 && d % 365 === 0 ? (d === 365 ? '1 year' : (d / 365) + ' years') : d + ' days';
|
||||||
|
// Shards of Valor bonus heroes (2026-11-05, Marty approved): sold ONE TIME, yours for good, paid by a new package like a pass (credits
|
||||||
|
// never buy one). Shown while heroSales is on, or to a member who owns one. gp.heroes comes from gamepass.js heroView.
|
||||||
|
function heroesHtml(H) {
|
||||||
|
if (!H || !H.show) return '';
|
||||||
|
const btn = (key, label, pkg) => '<button class="btn small" type="button" data-hero-buy="' + esc(key) + '">' + esc(label) + ' · $' + pkg + ' package</button>';
|
||||||
|
const item = i => '<div class="gp-tier' + (i.owned ? ' on' : '') + '"><h4>' + esc(i.name) + '</h4>'
|
||||||
|
+ '<p class="gp-price">' + (i.free ? 'Free for everyone' : i.freeAt ? 'Free at level ' + i.freeAt : '$' + i.usd + ' <span class="small muted">one time</span>') + '</p>'
|
||||||
|
+ '<p class="small muted" style="margin:0 0 6px">' + esc(i.blurb) + '</p>'
|
||||||
|
+ (i.owned ? '<p class="small"><b>Yours for good</b></p>' : i.freeAt ? '<span class="small muted">Not for sale: joins every player free in the game once a hero reaches level ' + i.freeAt + '.</span>' : i.waiting ? '<button class="btn small" type="button" data-gp-go="1">Buy a $' + i.package + ' package</button>' : i.open ? btn(i.key, 'Get ' + i.name.split(' ')[0], i.package) : '<span class="small muted">Not on sale right now.</span>') + '</div>';
|
||||||
|
const B = H.bundle;
|
||||||
|
const bundle = !B ? '' : '<div class="gp-tier' + (B.owned ? ' on' : '') + '"><h4>Hero bundle</h4><p class="gp-price">$' + B.usd + ' <span class="small muted">one time</span></p>'
|
||||||
|
+ '<p class="small muted" style="margin:0 0 6px">' + esc(B.names.join(', ')) + ', together.</p>'
|
||||||
|
+ (B.owned ? '<p class="small"><b>Yours for good</b></p>' : B.waiting ? '<button class="btn small" type="button" data-gp-go="1">Buy a $' + B.package + ' package</button>' : B.open ? btn('bundle', 'Get all three', B.package) : B.some ? '<span class="small muted">You already have one of them: get the others one at a time.</span>' : '<span class="small muted">Not on sale right now.</span>') + '</div>';
|
||||||
|
return '<div id="gpHeroes" style="margin-top:14px"><h4 style="margin:0 0 6px">Shards of Valor bonus heroes</h4>'
|
||||||
|
+ '<p class="small" style="margin:0 0 8px">Extra heroes for your party, bought <b>one time</b> and yours for good: no subscription. Three heroes fight at a time and you pick which three. A bonus hero joins at your party level (at most 20) with its own bound gear, never stronger than heroes and gear you can earn. The whole story stays free with Aldric, Sylwen and Borin.</p>'
|
||||||
|
+ '<div class="gp-tiers">' + H.items.map(item).join('') + bundle + '</div>'
|
||||||
|
+ '<p class="small muted" style="margin:8px 0 0">Every hero is paid by a new package purchase of at least its price, so your sponsor and team are paid; you keep the package credits for your ads. Credits you already hold never buy a hero.</p></div>';
|
||||||
|
}
|
||||||
|
function wireHeroes(card, H) {
|
||||||
|
if (!H) return;
|
||||||
|
card.querySelectorAll('[data-hero-buy]').forEach(b => b.addEventListener('click', async () => {
|
||||||
|
const k = b.dataset.heroBuy, i = k === 'bundle' ? Object.assign({ name: 'the hero bundle (' + H.bundle.names.join(', ') + ')' }, H.bundle) : H.items.find(x => x.key === k); if (!i) return;
|
||||||
|
const yes = await IAP.confirmBox('Get ' + i.name + ' for $' + i.usd + ', one time? It is paid by a new package purchase of $' + i.package + ' or more: your sponsor and team are paid from it as usual, you keep all its credits for your ads, and ' + (k === 'bundle' ? 'the heroes join' : 'the hero joins') + ' you in Shards of Valor the moment it settles. Credits you already hold never buy a hero.', { title: 'Bonus heroes', ok: 'Get ' + (k === 'bundle' ? 'the bundle' : i.name.split(' ')[0]), cancel: 'Not now' });
|
||||||
|
if (!yes) return; b.disabled = true;
|
||||||
|
try { const x = await api('/api/my/heroes/buy', { hero: k }); if (x.needPay) { IAP.status(x.message || 'Buy a package and the hero joins when it settles.', 'ok'); setPane('buy'); return; } }
|
||||||
|
catch (e) { IAP.status(e.message, 'bad'); b.disabled = false; }
|
||||||
|
}));
|
||||||
|
card.querySelectorAll('#gpHeroes [data-gp-go]').forEach(b => b.addEventListener('click', () => setPane('buy')));
|
||||||
|
}
|
||||||
function renderPassTiers(card, gp, highlight) {
|
function renderPassTiers(card, gp, highlight) {
|
||||||
const rows = gp.passes || []; const top = rows.find(r => r.tier === gp.tier);
|
const rows = gp.passes || []; const top = rows.find(r => r.tier === gp.tier);
|
||||||
const state = top ? '<span class="badge" style="background:var(--gold);color:var(--gold-ink)">' + esc(top.name) + ' active · until ' + esc(gpCT(top.until)) + '</span>'
|
const state = top ? '<span class="badge" style="background:var(--gold);color:var(--gold-ink)">' + esc(top.name) + ' active · until ' + esc(gpCT(top.until)) + '</span>'
|
||||||
@@ -2071,7 +2166,9 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
+ '<p>Free play pays real POL every day, and the main story of Shards of Valor is free for everyone. Every pass gives the same higher POL caps in every game. Each higher pass includes everything below it and adds more of Shards of Valor: weapons, gear, bonus islands, heroes and a higher level cap. <b>Paid passes add heroes, islands, a higher level cap and new looks.</b> Pass gear is never better than gear players can earn, and passes never pay more POL.</p>'
|
+ '<p>Free play pays real POL every day, and the main story of Shards of Valor is free for everyone. Every pass gives the same higher POL caps in every game. Each higher pass includes everything below it and adds more of Shards of Valor: weapons, gear, bonus islands, heroes and a higher level cap. <b>Paid passes add heroes, islands, a higher level cap and new looks.</b> Pass gear is never better than gear players can earn, and passes never pay more POL.</p>'
|
||||||
+ '<div class="gp-tiers">' + rows.map(box).join('') + '</div>'
|
+ '<div class="gp-tiers">' + rows.map(box).join('') + '</div>'
|
||||||
+ (capsLine ? '<p class="small muted" style="margin-top:10px">' + capsLine + '</p>' : '')
|
+ (capsLine ? '<p class="small muted" style="margin-top:10px">' + capsLine + '</p>' : '')
|
||||||
+ '<p class="small muted" style="margin:10px 0 0">Every pass is paid by a new package purchase of at least its price, so your sponsor and team are paid; you keep the package credits for your ads. Credits you already hold never buy a pass. Passes run side by side: a higher pass shows first, and the one underneath keeps its own end date. No auto-renew: buy again any time and that pass extends from its end date. When a pass ends, nothing you earned in a game is taken away.</p>';
|
+ '<p class="small muted" style="margin:10px 0 0">Every pass is paid by a new package purchase of at least its price, so your sponsor and team are paid; you keep the package credits for your ads. Credits you already hold never buy a pass. Passes run side by side: a higher pass shows first, and the one underneath keeps its own end date. No auto-renew: buy again any time and that pass extends from its end date. When a pass ends, nothing you earned in a game is taken away.</p>'
|
||||||
|
+ heroesHtml(gp.heroes);
|
||||||
|
wireHeroes(card, gp.heroes);
|
||||||
card.querySelectorAll('[data-gp-tier]').forEach(b => b.addEventListener('click', async () => {
|
card.querySelectorAll('[data-gp-tier]').forEach(b => b.addEventListener('click', async () => {
|
||||||
const r = rows.find(x => x.tier === b.dataset.gpTier); if (!r) return;
|
const r = rows.find(x => x.tier === b.dataset.gpTier); if (!r) return;
|
||||||
const yes = await IAP.confirmBox((r.active ? 'Extend your ' + r.name + ' by ' + gpLen(r.days) : 'Get ' + r.name + ' for ' + gpLen(r.days)) + ' ($' + r.usd + ')? Every pass is paid by a new package purchase of $' + r.package + ' or more: your sponsor and team are paid from it as usual, you keep all its credits for your ads, and the pass starts the moment it settles. Credits you already hold never buy a pass. The same POL caps as every pass: no extra POL.', { title: r.name, ok: r.active ? 'Extend' : 'Get ' + r.name, cancel: 'Not now' });
|
const yes = await IAP.confirmBox((r.active ? 'Extend your ' + r.name + ' by ' + gpLen(r.days) : 'Get ' + r.name + ' for ' + gpLen(r.days)) + ' ($' + r.usd + ')? Every pass is paid by a new package purchase of $' + r.package + ' or more: your sponsor and team are paid from it as usual, you keep all its credits for your ads, and the pass starts the moment it settles. Credits you already hold never buy a pass. The same POL caps as every pass: no extra POL.', { title: r.name, ok: r.active ? 'Extend' : 'Get ' + r.name, cancel: 'Not now' });
|
||||||
@@ -2116,6 +2213,10 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
async function loadGamePassCard(highlight) {
|
async function loadGamePassCard(highlight) {
|
||||||
const card = $('gpCard'); if (!card) return;
|
const card = $('gpCard'); if (!card) return;
|
||||||
let gp = null; try { gp = await (await fetch('/api/my/gamepass')).json(); } catch (e) {}
|
let gp = null; try { gp = await (await fetch('/api/my/gamepass')).json(); } catch (e) {}
|
||||||
|
if (gp && !(gp.enabled || gp.show) && gp.heroes && gp.heroes.show) { // heroes on sale (or owned) while no pass is: a card with the heroes only
|
||||||
|
card.hidden = false; card.classList.toggle('gp-hl', !!highlight);
|
||||||
|
card.innerHTML = '<div class="card-head"><h3>\u{1F6E1}\uFE0F Shards of Valor heroes</h3><span class="sub">one time · yours for good</span></div>' + heroesHtml(gp.heroes); wireHeroes(card, gp.heroes); return;
|
||||||
|
}
|
||||||
if (!gp || !(gp.enabled || gp.show)) { card.hidden = true; return; }
|
if (!gp || !(gp.enabled || gp.show)) { card.hidden = true; return; }
|
||||||
await gpShownLoad();
|
await gpShownLoad();
|
||||||
if ((gp.passes || []).some(r => r.tier !== 'weekly')) return renderPassTiers(card, gp, highlight);
|
if ((gp.passes || []).some(r => r.tier !== 'weekly')) return renderPassTiers(card, gp, highlight);
|
||||||
@@ -2139,7 +2240,9 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
+ (gp.waiting ? '<p class="small">Your pass is waiting: buy a $' + (gp.usd || 5) + ' package and it starts the moment the purchase settles. You keep every credit of the package for your ads.</p>' : '')
|
+ (gp.waiting ? '<p class="small">Your pass is waiting: buy a $' + (gp.usd || 5) + ' package and it starts the moment the purchase settles. You keep every credit of the package for your ads.</p>' : '')
|
||||||
+ '<p style="display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin:10px 0 0">'
|
+ '<p style="display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin:10px 0 0">'
|
||||||
+ (gp.waiting ? '<button class="btn" type="button" id="gpGoBuy">Buy a $' + (gp.usd || 5) + ' package</button>' : '<button class="btn" type="button" id="gpBuy">' + (gp.active ? 'Extend ' + (gp.days || 7) + ' more days' : 'Get the Pass') + ' \u00b7 buy a $' + (gp.usd || 5) + ' package</button>')
|
+ (gp.waiting ? '<button class="btn" type="button" id="gpGoBuy">Buy a $' + (gp.usd || 5) + ' package</button>' : '<button class="btn" type="button" id="gpBuy">' + (gp.active ? 'Extend ' + (gp.days || 7) + ' more days' : 'Get the Pass') + ' \u00b7 buy a $' + (gp.usd || 5) + ' package</button>')
|
||||||
+ '<span class="small muted">Paid by a new $' + (gp.usd || 5) + ' or bigger package, so your sponsor and team are paid. You keep the package credits for your ads; credits you already hold never buy a pass.</span></p>';
|
+ '<span class="small muted">Paid by a new $' + (gp.usd || 5) + ' or bigger package, so your sponsor and team are paid. You keep the package credits for your ads; credits you already hold never buy a pass.</span></p>'
|
||||||
|
+ heroesHtml(gp.heroes);
|
||||||
|
wireHeroes(card, gp.heroes);
|
||||||
const b = $('gpBuy'); if (b) b.addEventListener('click', async () => {
|
const b = $('gpBuy'); if (b) b.addEventListener('click', async () => {
|
||||||
const yes = await IAP.confirmBox((gp.active ? 'Extend your Game Pass by ' + (gp.days || 7) + ' days' : 'Get the Game Pass for ' + (gp.days || 7) + ' days') + '? The Pass is paid by a new package purchase of $' + (gp.usd || 5) + ' or more: your sponsor and team are paid from it as usual, you keep all its credits for your ads, and the Pass starts the moment it settles. Credits you already hold never buy a pass.', { title: 'Game Pass', ok: gp.active ? 'Extend the Pass' : 'Get the Pass', cancel: 'Not now' });
|
const yes = await IAP.confirmBox((gp.active ? 'Extend your Game Pass by ' + (gp.days || 7) + ' days' : 'Get the Game Pass for ' + (gp.days || 7) + ' days') + '? The Pass is paid by a new package purchase of $' + (gp.usd || 5) + ' or more: your sponsor and team are paid from it as usual, you keep all its credits for your ads, and the Pass starts the moment it settles. Credits you already hold never buy a pass.', { title: 'Game Pass', ok: gp.active ? 'Extend the Pass' : 'Get the Pass', cancel: 'Not now' });
|
||||||
if (!yes) return;
|
if (!yes) return;
|
||||||
@@ -2160,9 +2263,22 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
const card = $('gpNudge'); if (!card) return;
|
const card = $('gpNudge'); if (!card) return;
|
||||||
if (cardHidden('gpnudge')) { card.hidden = true; return; }
|
if (cardHidden('gpnudge')) { card.hidden = true; return; }
|
||||||
let gp = null; try { gp = await (await fetch('/api/my/gamepass')).json(); } catch (e) {}
|
let gp = null; try { gp = await (await fetch('/api/my/gamepass')).json(); } catch (e) {}
|
||||||
if (!gp || !gp.enabled || gp.active || !gp.lastCapHit || gp.lastCapHit.pass) { card.hidden = true; return; }
|
const allowanceDone = !!(gp && gp.caps && gp.caps.lifetime && gp.caps.lifetime.done && gp.caps.enforced);
|
||||||
|
if (!gp || !gp.enabled || gp.active || (!allowanceDone && (!gp.lastCapHit || gp.lastCapHit.pass))) { card.hidden = true; return; }
|
||||||
const NAMES = { polhunter: 'PolHunter', gemkingdom: 'Gem Kingdom', spellwheel: 'SpellWheel', spookydoors: 'Spooky Doors', polywarriors: 'PolyWarriors', clutterhunt: 'ClutterHunt', polybreak: 'PolyBreak', polminer: 'POL Miner', warpwares: 'Warp & Wares', turkeydrop: 'Turkey Drop', driprunner: 'Drip Runner', roadagent: 'Road Agent' };
|
const NAMES = { polhunter: 'PolHunter', gemkingdom: 'Gem Kingdom', spellwheel: 'SpellWheel', spookydoors: 'Spooky Doors', polywarriors: 'PolyWarriors', clutterhunt: 'ClutterHunt', polybreak: 'PolyBreak', polminer: 'POL Miner', warpwares: 'Warp & Wares', turkeydrop: 'Turkey Drop', driprunner: 'Drip Runner', roadagent: 'Road Agent' };
|
||||||
card.hidden = false;
|
card.hidden = false;
|
||||||
|
const lt = gp.caps && gp.caps.lifetime;
|
||||||
|
if (lt && lt.done) { // the free allowance is used up (Marty 2026-11-03): only the Pass pays from here, and what it unlocks
|
||||||
|
const fmt = n => String(Math.round(n * 100) / 100);
|
||||||
|
card.innerHTML = '<div class="card-head"><h3>\u{1F39F}\uFE0F You have used your free ' + fmt(lt.cap) + ' POL in the games</h3><span class="sub">the Game Pass keeps them paying</span></div>'
|
||||||
|
+ '<p>Every member gets ' + fmt(lt.cap) + ' POL of game rewards free, and yours is used. The games stay free to play, but from here rewards pay only with the <b>Game Pass</b>: ' + (gp.days || 7) + ' days for $' + (gp.usd || 5) + ', paid with a new package, with full rewards in every game, the weekly Pass Tournament and a perk in each game.'
|
||||||
|
+ (lt.waiting > 0 ? ' <b>' + fmt(lt.waiting) + ' POL</b> you have earned since is saved and pays out once your Pass is active.' : '') + '</p>'
|
||||||
|
+ '<button class="btn" type="button" id="gpNudgeGo">Get the Game Pass</button>';
|
||||||
|
$('gpNudgeGo').addEventListener('click', () => setPane('games?pass=1'));
|
||||||
|
try { localStorage.setItem('iap-hide-gpnudge', String(Date.now())); } catch (e) {}
|
||||||
|
cardDismiss(card, 'gpnudge');
|
||||||
|
return;
|
||||||
|
}
|
||||||
card.innerHTML = '<div class="card-head"><h3>\u{1F39F}\uFE0F You reached today\u2019s free cap in ' + esc(NAMES[gp.lastCapHit.game] || 'the games') + '</h3><span class="sub">free play keeps paying; the Pass plays more</span></div>'
|
card.innerHTML = '<div class="card-head"><h3>\u{1F39F}\uFE0F You reached today\u2019s free cap in ' + esc(NAMES[gp.lastCapHit.game] || 'the games') + '</h3><span class="sub">free play keeps paying; the Pass plays more</span></div>'
|
||||||
+ '<p>Every member earns real POL in the games up to the daily cap. The <b>Game Pass</b> raises the caps across all the games for ' + (gp.days || 7) + ' days ($' + (gp.usd || 5) + ', paid with a new package), adds the weekly Pass Tournament and a perk in every game.</p>'
|
+ '<p>Every member earns real POL in the games up to the daily cap. The <b>Game Pass</b> raises the caps across all the games for ' + (gp.days || 7) + ' days ($' + (gp.usd || 5) + ', paid with a new package), adds the weekly Pass Tournament and a perk in every game.</p>'
|
||||||
+ '<button class="btn" type="button" id="gpNudgeGo">See the Game Pass</button>';
|
+ '<button class="btn" type="button" id="gpNudgeGo">See the Game Pass</button>';
|
||||||
@@ -2465,10 +2581,10 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
const kept = shown.reduce((n, L) => n + L.members.length, 0);
|
const kept = shown.reduce((n, L) => n + L.members.length, 0);
|
||||||
el.innerHTML = '';
|
el.innerHTML = '';
|
||||||
el.appendChild(listBar('line', all, kept, () => renderLineage(el)));
|
el.appendChild(listBar('line', all, kept, () => renderLineage(el)));
|
||||||
el.insertAdjacentHTML('beforeend', !kept ? '<p class="muted small">Nobody in your downline matches those filters.</p>' : shown.map(L => !L.members.length ? '' :
|
el.insertAdjacentHTML('beforeend', !kept ? '<p class="muted small">Nobody in your downline matches your search or filters.</p>' : shown.map(L => !L.members.length ? '' :
|
||||||
'<div class="lin-lvl"><div class="cap">Level ' + L.level + ' · ' + L.members.length + (L.level === 1 ? ' direct' : '') + '</div>'
|
'<div class="lin-lvl"><div class="cap">Level ' + L.level + ' · ' + L.members.length + (L.level === 1 ? ' direct' : '') + '</div>'
|
||||||
+ L.members.map(m => '<div class="lin-row' + (m.own ? ' own' : '') + '"><span class="nm">' + esc(m.name) + (m.own ? ' <span class="badge">yours</span>' : '') + '</span>'
|
+ L.members.map(m => '<div class="lin-row' + (m.own ? ' own' : '') + '"><span class="nm">' + esc(m.name) + (m.own ? ' <span class="badge">yours</span>' : '') + '</span>'
|
||||||
+ '<span class="em">' + (m.email ? esc(m.email) : (m.memberId ? '<span class="id">#' + m.memberId + '</span>' : '')) + (m.sponsor ? '<span class="sp">sponsored by ' + esc(m.sponsor) + '</span>' : '') + (m.own ? '' : '<span class="sp">' + (m.bought ? '$20+ buy ✓' : 'no $20+ buy yet') + (m.buyers ? ' · ' + m.buyers + ' qualifying buyer' + (m.buyers === 1 ? '' : 's') + ' of their own' : '') + '</span><span class="sp wrap">' + memberChips(m) + '</span>') + '</span>'
|
+ '<span class="em">' + (m.email ? esc(m.email) : (m.memberId ? '<span class="id">#' + m.memberId + '</span>' : '')) + (m.sponsor ? '<span class="sp">sponsored by ' + esc(m.sponsor) + '</span>' : '') + (!m.own && originText(m) ? '<span class="sp">' + esc(originText(m)) + '</span>' : '') + (m.own ? '' : '<span class="sp">' + (m.bought ? '$20+ buy ✓' : 'no $20+ buy yet') + (m.buyers ? ' · ' + m.buyers + ' qualifying buyer' + (m.buyers === 1 ? '' : 's') + ' of their own' : '') + '</span><span class="sp wrap">' + memberChips(m) + '</span>') + '</span>'
|
||||||
+ '<span class="earn' + (m.earnedWei && m.earnedWei !== '0' ? ' on' : '') + '" title="POL this person has paid you so far">'
|
+ '<span class="earn' + (m.earnedWei && m.earnedWei !== '0' ? ' on' : '') + '" title="POL this person has paid you so far">'
|
||||||
+ (m.earnedWei && m.earnedWei !== '0' ? '+' + IAP.fmtPol(m.earnedWei) + ' POL' : '0.00 POL') + '</span>'
|
+ (m.earnedWei && m.earnedWei !== '0' ? '+' + IAP.fmtPol(m.earnedWei) + ' POL' : '0.00 POL') + '</span>'
|
||||||
+ '<span class="dt">' + new Date(m.joined).toLocaleDateString() + '</span>'
|
+ '<span class="dt">' + new Date(m.joined).toLocaleDateString() + '</span>'
|
||||||
@@ -2503,7 +2619,9 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
const ago = t => { if (!t) return 'never'; const d = Date.now() - t; if (d < 3600e3) return Math.max(1, Math.round(d / 60e3)) + ' min ago'; if (d < 86400e3) return Math.round(d / 3600e3) + 'h ago'; return Math.round(d / 86400e3) + 'd ago'; };
|
const ago = t => { if (!t) return 'never'; const d = Date.now() - t; if (d < 3600e3) return Math.max(1, Math.round(d / 60e3)) + ' min ago'; if (d < 86400e3) return Math.round(d / 3600e3) + 'h ago'; return Math.round(d / 86400e3) + 'd ago'; };
|
||||||
const chip = (label, val, cls) => '<span class="lin-chip' + (cls ? ' ' + cls : '') + '"><b>' + esc(label) + '</b>' + esc(val) + '</span>';
|
const chip = (label, val, cls) => '<span class="lin-chip' + (cls ? ' ' + cls : '') + '"><b>' + esc(label) + '</b>' + esc(val) + '</span>';
|
||||||
const working = (a.viewsToday || 0) > 0 || (a.campaignsActive || 0) > 0 || (a.linkViews30 || 0) > 0 || (a.lastSeen && Date.now() - a.lastSeen < 2 * 86400e3);
|
const working = (a.viewsToday || 0) > 0 || (a.campaignsActive || 0) > 0 || (a.linkViews30 || 0) > 0 || (a.lastSeen && Date.now() - a.lastSeen < 2 * 86400e3);
|
||||||
box.innerHTML = chip('Last seen', ago(a.lastSeen), a.lastSeen && Date.now() - a.lastSeen < 2 * 86400e3 ? 'on' : (a.quietDays >= 3 ? 'warn' : ''))
|
box.innerHTML = (a.direct && a.email ? chip('Email', a.email) : '') // your own directs only (2026-11-12)
|
||||||
|
+ (a.direct && originText(a) ? chip('Came', originText(a)) : '')
|
||||||
|
+ chip('Last seen', ago(a.lastSeen), a.lastSeen && Date.now() - a.lastSeen < 2 * 86400e3 ? 'on' : (a.quietDays >= 3 ? 'warn' : ''))
|
||||||
+ chip('Joined', new Date(a.joined).toLocaleDateString())
|
+ chip('Joined', new Date(a.joined).toLocaleDateString())
|
||||||
+ chip('Stage', (a.rung || 'Joined') + (a.next ? ' · next: ' + a.next : ''), a.stalled ? 'warn' : '')
|
+ chip('Stage', (a.rung || 'Joined') + (a.next ? ' · next: ' + a.next : ''), a.stalled ? 'warn' : '')
|
||||||
+ chip('Ads today', (a.viewsToday || 0) + '/' + (a.target || 5) + (a.claimedToday ? ' claimed' : '') + (a.streakDay ? ' · streak day ' + a.streakDay : ''), (a.viewsToday || 0) > 0 ? 'on' : '')
|
+ chip('Ads today', (a.viewsToday || 0) + '/' + (a.target || 5) + (a.claimedToday ? ' claimed' : '') + (a.streakDay ? ' · streak day ' + a.streakDay : ''), (a.viewsToday || 0) > 0 ? 'on' : '')
|
||||||
@@ -2695,9 +2813,11 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
if ($('tkGo')) { $('tkGo').addEventListener('click', tkGenerate); $('tkAgain').addEventListener('click', tkGenerate); $('tkCopy').addEventListener('click', async () => { try { await navigator.clipboard.writeText($('tkText').value); IAP.status('Copied.', 'ok'); } catch (e) { $('tkText').select(); } }); $('tkSendBc').addEventListener('click', tkSendBroadcast); }
|
if ($('tkGo')) { $('tkGo').addEventListener('click', tkGenerate); $('tkAgain').addEventListener('click', tkGenerate); $('tkCopy').addEventListener('click', async () => { try { await navigator.clipboard.writeText($('tkText').value); IAP.status('Copied.', 'ok'); } catch (e) { $('tkText').select(); } }); $('tkSendBc').addEventListener('click', tkSendBroadcast); }
|
||||||
// promo tools: pill menu switches between posts / swipes / banners / wall / videos
|
// promo tools: pill menu switches between posts / swipes / banners / wall / videos
|
||||||
function setPromoSub(name) {
|
function setPromoSub(name) {
|
||||||
const ids = ['toolkit', 'posts', 'text', 'swipe', 'banners', 'wall', 'objections', 'videos', 'viral', 'games', 'bixpay']; // bixpay: the BixPay partner kit, pill hidden while bixpayLive is off (2026-10-29)
|
const ids = ['toolkit', 'posts', 'text', 'swipe', 'banners', 'wall', 'objections', 'videos', 'viral', 'stackpol', 'games', 'network', 'bixpay']; // bixpay: the BixPay partner kit, pill hidden while bixpayLive is off (2026-10-29)
|
||||||
if (['polhunter', 'spookydoors', 'gamebanners'].includes(name)) name = 'games'; // those tabs live inside Games now (2026-10-06)
|
if (['polhunter', 'spookydoors', 'gamebanners'].includes(name)) name = 'games'; // those tabs live inside Games now (2026-10-06)
|
||||||
if (name === 'toolkit') loadToolkit();
|
if (name === 'toolkit') loadToolkit();
|
||||||
|
if (name === 'stackpol') loadStackPol();
|
||||||
|
if (name === 'network' && window.IAPNetKits) IAPNetKits.load(); // Network sites kits (2026-11-14), loaded when the tab opens
|
||||||
const pill = document.querySelector('.promo-pills [data-promo="' + name + '"]');
|
const pill = document.querySelector('.promo-pills [data-promo="' + name + '"]');
|
||||||
if (!ids.includes(name) || !pill || pill.hidden) name = 'posts';
|
if (!ids.includes(name) || !pill || pill.hidden) name = 'posts';
|
||||||
ids.forEach(id => { const el = $('promo-' + id); if (el) el.hidden = id !== name; });
|
ids.forEach(id => { const el = $('promo-' + id); if (el) el.hidden = id !== name; });
|
||||||
@@ -2707,9 +2827,33 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
});
|
});
|
||||||
try { localStorage.setItem('iap.promoSub', name); } catch (e) {}
|
try { localStorage.setItem('iap.promoSub', name); } catch (e) {}
|
||||||
}
|
}
|
||||||
|
// Stack POL page switch (2026-11-09): GET/POST /api/my/stackpol, the opt-in the stackpol.com indexer reads every 5 minutes
|
||||||
|
function showStackPol(d) {
|
||||||
|
$('spOn').checked = !!d.on; $('spLinkRow').hidden = !d.on; $('spUrl').textContent = d.url || ''; $('spOpen').href = d.url || '#';
|
||||||
|
$('spNote').textContent = d.on ? (d.wallet ? 'Your page is live once a payout reaches your wallet and updates every 5 minutes.' : 'Link a wallet (Wallet tab) so your payouts can be added up on your page.') : '';
|
||||||
|
const pv = d.pro || {}; $('spProOn').hidden = !pv.pro; $('spProOff').hidden = !!pv.pro; // any $10+ package unlocks Pro (2026-11-09): no order to wait on
|
||||||
|
// owned state (Marty 2026-11-10): say plainly that the member OWNS the upgrade, since when, with a link to the Pro page
|
||||||
|
$('spProSince').textContent = pv.pro && pv.since ? 'Unlocked ' + new Date(pv.since).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' }) + '. ' : '';
|
||||||
|
$('spProOpen').href = d.url || '#';
|
||||||
|
}
|
||||||
|
async function stackPolPost(body) { const r = await fetch('/api/my/stackpol', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) }); const d = await r.json(); if (!r.ok) throw new Error(d.error || 'Could not save that.'); return d; }
|
||||||
|
// a purchase made in another tab or on chain while this pane was open (Marty 2026-11-10): re-check when the member comes back
|
||||||
|
document.addEventListener('visibilitychange', () => { const el = $('promo-stackpol'); if (!document.hidden && el && !el.hidden) loadStackPol(); });
|
||||||
|
async function loadStackPol() { try { const r = await fetch('/api/my/stackpol'); const d = await r.json(); if (!r.ok) { $('spNote').textContent = d.error || ''; return; } showStackPol(d); } catch (e) {} }
|
||||||
|
if ($('spOn')) {
|
||||||
|
$('spOn').addEventListener('change', async () => {
|
||||||
|
const on = $('spOn').checked;
|
||||||
|
try { const r = await fetch('/api/my/stackpol', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ on }) }); const d = await r.json();
|
||||||
|
if (!r.ok) { $('spOn').checked = !on; IAP.status(d.error || 'Could not save that.', 'bad'); return; }
|
||||||
|
showStackPol(d); IAP.status(on ? 'Stack POL page switched on.' : 'Stack POL page switched off.', 'ok');
|
||||||
|
} catch (e) { $('spOn').checked = !on; IAP.status('Could not save that. Try again.', 'bad'); }
|
||||||
|
});
|
||||||
|
$('spCopy').addEventListener('click', async () => { try { await navigator.clipboard.writeText($('spUrl').textContent); IAP.status('Link copied.', 'ok'); } catch (e) { const r = document.createRange(); r.selectNodeContents($('spUrl')); const sel = getSelection(); sel.removeAllRanges(); sel.addRange(r); } });
|
||||||
|
}
|
||||||
document.querySelectorAll('.promo-pills [data-promo]').forEach(b =>
|
document.querySelectorAll('.promo-pills [data-promo]').forEach(b =>
|
||||||
b.addEventListener('click', () => setPromoSub(b.dataset.promo)));
|
b.addEventListener('click', () => setPromoSub(b.dataset.promo)));
|
||||||
try { setPromoSub(localStorage.getItem('iap.promoSub') || 'posts'); } catch (e) { setPromoSub('posts'); }
|
const promoDeep = /^#promo\?(?:.*&)?s=([a-z]+)/.exec(location.hash); // a deep link to one tab, e.g. stackpol.com's Pro button: /my#promo?s=stackpol (2026-11-09)
|
||||||
|
try { setPromoSub((promoDeep && promoDeep[1]) || localStorage.getItem('iap.promoSub') || 'posts'); } catch (e) { setPromoSub('posts'); }
|
||||||
async function loadInbox() {
|
async function loadInbox() {
|
||||||
try {
|
try {
|
||||||
const r = await (await fetch('/api/my/inbox')).json();
|
const r = await (await fetch('/api/my/inbox')).json();
|
||||||
@@ -2812,6 +2956,7 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
// ── promo tools: content + rendering live in promo.js (IAPPromo.fill) ──
|
// ── promo tools: content + rendering live in promo.js (IAPPromo.fill) ──
|
||||||
function fillPromo(link, me) {
|
function fillPromo(link, me) {
|
||||||
if (window.IAPPromo) IAPPromo.fill(link, me || {});
|
if (window.IAPPromo) IAPPromo.fill(link, me || {});
|
||||||
|
if (window.IAPNetKits && me && me.username) { IAPNetKits.setUser(me.username); const ns = $('promo-network'); if (ns && !ns.hidden) IAPNetKits.load(); }
|
||||||
// banner kit
|
// banner kit
|
||||||
const bwrap = $('promoBanners');
|
const bwrap = $('promoBanners');
|
||||||
if (bwrap && !bwrap.dataset.filled) {
|
if (bwrap && !bwrap.dataset.filled) {
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
// Promo tools > Network sites (Marty 2026-11-14): the promo kits of the other network sites, read live from each site's own public
|
||||||
|
// feed (GET <site>/api/promo-kit?u=<username>), so a creative or line changed on Downline Banners or Viral Banner Blitz shows here
|
||||||
|
// at once. Usernames are network-wide: the member's InstantAdPay username is their sponsor link on those sites even if they never
|
||||||
|
// visited them. Nothing is stored here.
|
||||||
|
window.IAPNetKits = (function () {
|
||||||
|
const SITES = [
|
||||||
|
{ key: 'dlb', name: 'Downline Banners', feed: 'https://downlinebanners.com/api/promo-kit', blurb: 'One global line of $5 banner spots on Polygon. A spot buys 300 guaranteed views on the board and a place in the line; every sale is split on-chain in the same transaction. Nothing is promised: a spot is paid only when spots sell after it.' },
|
||||||
|
{ key: 'vbb', name: 'Viral Banner Blitz', feed: 'https://viralbannerblitz.com/api/promo-kit', blurb: 'One shared loop of 125x125 banners. Network members post free once a day, real visitors push the loop, and a banner that rides out earns network ad views. Weekly leaderboards for visitors sent. Advertising, not income.' }
|
||||||
|
];
|
||||||
|
const esc = s => String(s == null ? '' : s).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
||||||
|
const $ = id => document.getElementById(id);
|
||||||
|
let user = '', cur = '', cache = {}, txt = [];
|
||||||
|
try { cur = localStorage.getItem('iap.netkit') || ''; } catch (e) {}
|
||||||
|
if (!SITES.some(s => s.key === cur)) cur = SITES[0].key;
|
||||||
|
function setUser(u) { if (u && u !== user) { user = u; cache = {}; } }
|
||||||
|
async function copy(t, btn) {
|
||||||
|
try { await navigator.clipboard.writeText(t); } catch (e) { const a = document.createElement('textarea'); a.value = t; document.body.appendChild(a); a.select(); try { document.execCommand('copy'); } catch (e2) {} a.remove(); }
|
||||||
|
if (window.IAP && IAP.status) IAP.status('Copied.', 'ok');
|
||||||
|
if (btn) { const o = btn.textContent; btn.textContent = 'Copied'; setTimeout(() => { btn.textContent = o; }, 1300); }
|
||||||
|
}
|
||||||
|
const cb = (t, label, cls) => { txt.push(t); return '<button type="button" class="btn small ' + (cls == null ? 'sec' : cls) + '" data-nkc="' + (txt.length - 1) + '">' + esc(label || 'Copy') + '</button>'; };
|
||||||
|
function pick() {
|
||||||
|
const p = $('nkPick'); if (!p) return;
|
||||||
|
p.innerHTML = SITES.map(s => '<button type="button" class="chip-t' + (s.key === cur ? ' on' : '') + '" data-nk="' + s.key + '">' + esc(s.name) + '</button>').join('');
|
||||||
|
p.querySelectorAll('[data-nk]').forEach(b => b.addEventListener('click', () => { cur = b.dataset.nk; try { localStorage.setItem('iap.netkit', cur); } catch (e) {} pick(); show(); }));
|
||||||
|
}
|
||||||
|
function render(site, k) {
|
||||||
|
txt = [];
|
||||||
|
const by = {}; const angles = [];
|
||||||
|
(k.creatives || []).forEach(c => { if (!by[c.angle]) { by[c.angle] = []; angles.push(c); } by[c.angle].push(c); });
|
||||||
|
let h = '<p class="muted small" style="margin:0 0 12px">' + esc(site.blurb) + '</p>';
|
||||||
|
// tracked links (2026-11-14): the site's LinkSpin network link, credited here to InstantAdPay as the site that sent the visit
|
||||||
|
const strip = (label, url, cls) => '<div class="promo-strip" style="padding:0 0 12px"><div><span class="eyebrow" style="margin:0 0 4px">' + esc(label) + '</span><div class="mono small" style="overflow-wrap:anywhere">' + esc(url) + '</div></div><span>' + cb(url, 'Copy link', cls) + '</span></div>';
|
||||||
|
const fromHere = u => String(u).replace(/([?&]src=)[a-z0-9]+/i, '$1iap');
|
||||||
|
h += k.links.map(l => strip(l.label, l.url, '') + (l.tracked ? strip(l.label + ', tracked', fromHere(l.tracked), 'sec') : '')).join('');
|
||||||
|
if (k.links.some(l => l.tracked)) h += '<p class="muted small" style="margin:0 0 12px">A tracked link goes through LinkSpin first, so the network can see the visit came from InstantAdPay, then opens the same page with your username. Use either one.</p>';
|
||||||
|
h += '<div class="card-head" style="margin-top:6px"><h3>Creatives</h3><span class="sub">every HTML snippet already links to you</span></div>';
|
||||||
|
angles.forEach(a => {
|
||||||
|
h += '<details class="promo-block nk-set"' + (a === angles[0] ? ' open' : '') + '><summary class="pb-head" style="cursor:pointer"><span class="lab"><b>' + esc(a.angleLabel) + '</b></span> <span class="muted small">' + by[a.angle].length + ' sizes</span></summary><div class="nk-grid">'
|
||||||
|
+ by[a.angle].map(c => '<figure class="nk-fig"><a href="' + esc(c.url) + '" target="_blank" rel="noopener"><img src="' + esc(c.url) + '" alt="' + esc(k.name + ', ' + c.label) + '" width="' + c.w + '" height="' + c.h + '" loading="lazy" style="max-width:' + Math.min(c.w, c.w > 600 ? 420 : c.w) + 'px"></a>'
|
||||||
|
+ '<figcaption class="small"><b>' + esc(c.label) + '</b> <span class="muted">' + c.w + '×' + c.h + '</span></figcaption><div class="pb-actions"><a class="btn small sec" href="' + esc(c.url) + '" target="_blank" rel="noopener" download>Download</a> ' + cb(c.url, 'Copy URL') + ' ' + cb(c.html, 'Copy HTML') + '</div></figure>').join('')
|
||||||
|
+ '</div></details>';
|
||||||
|
});
|
||||||
|
h += '<div class="card-head" style="margin-top:14px"><h3>Short lines</h3><span class="sub">chats, comments, text ads, signatures</span></div>'
|
||||||
|
+ k.lines.map(t => '<div class="promo-block"><div class="pb-text">' + esc(t) + '</div><div class="pb-actions">' + cb(t) + '</div></div>').join('');
|
||||||
|
h += '<div class="card-head" style="margin-top:14px"><h3>Headlines</h3></div>' + k.headlines.map(t => '<div class="promo-block"><div class="pb-text"><b>' + esc(t) + '</b></div><div class="pb-actions">' + cb(t) + '</div></div>').join('');
|
||||||
|
h += '<div class="card-head" style="margin-top:14px"><h3>Email</h3><span class="sub">plain text, paste it into any mailer</span></div><div class="promo-block"><div class="pb-head"><span class="lab">Subject:</span> ' + esc(k.email.subject) + '</div><div class="pb-text">' + esc(k.email.body) + '</div><div class="pb-actions">' + cb(k.email.subject, 'Copy subject') + ' ' + cb(k.email.body, 'Copy email', '') + '</div></div>';
|
||||||
|
h += '<div class="card-head" style="margin-top:14px"><h3>Social posts</h3></div>' + k.posts.map(t => '<div class="promo-block"><div class="pb-text">' + esc(t) + '</div><div class="pb-actions">' + cb(t, 'Copy post') + '</div></div>').join('');
|
||||||
|
if (k.note) h += '<p class="muted small" style="margin:12px 0 0">' + esc(k.note) + '</p>';
|
||||||
|
if (k.promotePage) h += '<p class="small" style="margin:8px 0 0">The same kit is on <a href="' + esc(k.promotePage + '?u=' + encodeURIComponent(user)) + '" target="_blank" rel="noopener">' + esc(k.name) + ' › Promote</a>.</p>';
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
async function show() {
|
||||||
|
const box = $('nkBody'); if (!box) return;
|
||||||
|
const site = SITES.find(s => s.key === cur);
|
||||||
|
if (!user) { box.innerHTML = '<p class="muted">Pick a username first: it becomes your link on every network site.</p>'; return; }
|
||||||
|
box.innerHTML = '<p class="muted small">Loading the ' + esc(site.name) + ' kit...</p>';
|
||||||
|
try {
|
||||||
|
if (!cache[cur]) {
|
||||||
|
const r = await fetch(site.feed + '?u=' + encodeURIComponent(user), { cache: 'no-store' });
|
||||||
|
if (!r.ok) throw new Error('HTTP ' + r.status);
|
||||||
|
cache[cur] = await r.json();
|
||||||
|
}
|
||||||
|
if (cur !== site.key) return;
|
||||||
|
box.innerHTML = render(site, cache[cur]);
|
||||||
|
box.querySelectorAll('[data-nkc]').forEach(b => b.addEventListener('click', () => copy(txt[Number(b.dataset.nkc)], b)));
|
||||||
|
} catch (e) { box.innerHTML = '<p class="muted">Could not load the ' + esc(site.name) + ' kit right now. Try again in a minute.</p>'; }
|
||||||
|
}
|
||||||
|
function load(u) { if (u) setUser(u); pick(); show(); }
|
||||||
|
return { load, setUser, SITES };
|
||||||
|
})();
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
// "Part of the network" footer line for pages that do not load common.js (Marty 2026-11-14 trust pack): company line + the network
|
||||||
|
// list from the hub (/api/network-sites, built-in copy if it does not answer). The current site comes from data-site on this tag.
|
||||||
|
(function () {
|
||||||
|
var me = (document.currentScript && document.currentScript.getAttribute('data-site')) || 'iap';
|
||||||
|
var FALLBACK = [['iap', 'InstantAdPay', 'https://instantadpay.com'], ['linkspin', 'LinkSpin', 'https://linkspin.app'], ['dlb', 'Downline Banners', 'https://downlinebanners.com'],
|
||||||
|
['vbb', 'Viral Banner Blitz', 'https://viralbannerblitz.com'], ['stackpol', 'Stack POL', 'https://stackpol.com'], ['earnerscorner', 'Earners Corner', 'https://earnerscorner.com']].map(function (a) { return { id: a[0], name: a[1], url: a[2] }; });
|
||||||
|
function esc(s) { return String(s).replace(/[&<>"]/g, function (c) { return { '&': '&', '<': '<', '>': '>', '"': '"' }[c]; }); }
|
||||||
|
function run() {
|
||||||
|
var f = document.querySelector('footer'); if (!f || f.querySelector('.netline')) return;
|
||||||
|
var hasLegal = !!f.querySelector('a[href="/terms"]'); // decided once, before this line adds its own links
|
||||||
|
var host = f.querySelector('.wrap') || f;
|
||||||
|
var box = document.createElement('div'); box.className = 'netline';
|
||||||
|
box.style.cssText = 'flex-basis:100%;width:100%;margin-top:10px;display:flex;gap:6px 14px;flex-wrap:wrap;align-items:baseline;font-size:12.5px';
|
||||||
|
host.appendChild(box);
|
||||||
|
var paint = function (list) {
|
||||||
|
box.innerHTML = (hasLegal ? '' : '<span style="flex-basis:100%"><a href="/terms">Terms</a> · <a href="/disclaimer">Earnings Disclaimer</a> · <a href="/privacy">Privacy</a> · <a href="/contract">Contract</a> · <a href="/ledger">Ledger</a> · <a href="/support">Support</a></span>') + '<span style="flex-basis:100%">TrustClickz · 615 Green Valley Drive, Moody, AL 35004</span><b>Part of the network</b><span>One account across the network:</span>' + list.map(function (s) {
|
||||||
|
return s.id === me ? '<span aria-current="page" style="font-weight:700">' + esc(s.name) + ' (you are here)</span>' : '<a href="' + esc(s.go || s.url) + '" target="_blank" rel="noopener nofollow">' + esc(s.name) + '</a>';
|
||||||
|
}).join('');
|
||||||
|
};
|
||||||
|
paint(FALLBACK);
|
||||||
|
fetch('/api/network-sites').then(function (r) { return r.json(); }).then(function (l) { if (Array.isArray(l) && l.length) paint(l); }).catch(function () {});
|
||||||
|
}
|
||||||
|
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run); else run();
|
||||||
|
})();
|
||||||
@@ -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(() => {});
|
||||||
|
})();
|
||||||
+11
-8
@@ -286,7 +286,10 @@ window.IAPPromo = (function () {
|
|||||||
const gms = $('promo-games');
|
const gms = $('promo-games');
|
||||||
if (gms && token && gms.dataset.filled !== token) {
|
if (gms && token && gms.dataset.filled !== token) {
|
||||||
gms.dataset.filled = token;
|
gms.dataset.filled = token;
|
||||||
const enc = encodeURIComponent, CDN = 'https://coolify-saasytop.nyc3.cdn.digitaloceanspaces.com/game-banners/';
|
const enc = encodeURIComponent;
|
||||||
|
// short image host (2026-11-03, Michael Camire via Marty): /b/<slug>/<file> on the share domain serves the game-banners CDN files in
|
||||||
|
// place; the ~105-character CDN URLs were cut off by exchange and safelist image fields. 728x90.png expands to <slug>-728x90.png.
|
||||||
|
const CDN = ((typeof SHARE_DOMAIN === 'string' && SHARE_DOMAIN) ? 'https://' + SHARE_DOMAIN : location.origin) + '/b/';
|
||||||
const preLaunch = (y, m, d) => Date.now() < Date.UTC(y, m - 1, d, 5); // before midnight Central on that day
|
const preLaunch = (y, m, d) => Date.now() < Date.UTC(y, m - 1, d, 5); // before midnight Central on that day
|
||||||
const GAMES = [
|
const GAMES = [
|
||||||
// the public games page (2026-10-10, Marty: "make sure that's in the promo tools for everyone"): every game on one page, with the member's referral on the Join button
|
// the public games page (2026-10-10, Marty: "make sure that's in the promo tools for everyone"): every game on one page, with the member's referral on the Join button
|
||||||
@@ -312,18 +315,18 @@ window.IAPPromo = (function () {
|
|||||||
{ name: 'Friendly post', text: 'If you ever played Trade Wars on a BBS, this is that feeling again, on your phone. Warp & Wares: 30 days, 1,200 sectors, three goods, a team of five, and prizes in Polygon at published positions. Free to play: {L}' },
|
{ name: 'Friendly post', text: 'If you ever played Trade Wars on a BBS, this is that feeling again, on your phone. Warp & Wares: 30 days, 1,200 sectors, three goods, a team of five, and prizes in Polygon at published positions. Free to play: {L}' },
|
||||||
{ name: 'Telegram or WhatsApp line', text: 'New season game in the network: Warp & Wares. 200 turns a day, trade and hold territory, weekly Polygon prizes. Free: {L}' }] },
|
{ name: 'Telegram or WhatsApp line', text: 'New season game in the network: Warp & Wares. 200 turns a day, trade and hold territory, weekly Polygon prizes. Free: {L}' }] },
|
||||||
// Turkey Drop (2026-10-28, the Thanksgiving season game): shows only while it is in the public games list (gamesLive, through Nov 30) and from Nov 2
|
// Turkey Drop (2026-10-28, the Thanksgiving season game): shows only while it is in the public games list (gamesLive, through Nov 30) and from Nov 2
|
||||||
{ slug: 'turkeydrop', name: 'Turkey Drop', link: 'https://turkeydropgame.com/?ref=', img: 'https://coolify-saasytop.nyc3.cdn.digitaloceanspaces.com/game-banners/turkeydrop/og-turkeydrop.jpg', sub: 'Thanksgiving game that pays Polygon, through Nov 30',
|
{ slug: 'turkeydrop', name: 'Turkey Drop', link: 'https://turkeydropgame.com/?ref=', img: CDN + 'turkeydrop/og-turkeydrop.jpg', sub: 'Thanksgiving game that pays Polygon, through Nov 30',
|
||||||
posts: [
|
posts: [
|
||||||
{ name: 'Short post', text: 'Turkey Drop is a free Thanksgiving game. The radio station helicopter is dropping turkeys over the mall, and you swing the net to catch them before they splat. Score milestones pay Polygon the first time you reach them, and the top 3 each week win a Polygon prize. Here through Nov 30: {L}' },
|
{ name: 'Short post', text: 'Turkey Drop is a free Thanksgiving game. The radio station helicopter is dropping turkeys over the mall, and you swing the net to catch them before they splat. Score milestones pay Polygon the first time you reach them, and the top 3 each week win a Polygon prize. Here through Nov 30: {L}' },
|
||||||
{ name: 'Telegram or WhatsApp line', text: 'Thanksgiving game in the network: Turkey Drop. Catch the turkeys before they splat, score milestones pay Polygon. Free, through Nov 30: {L}' }] },
|
{ name: 'Telegram or WhatsApp line', text: 'Thanksgiving game in the network: Turkey Drop. Catch the turkeys before they splat, score milestones pay Polygon. Free, through Nov 30: {L}' }] },
|
||||||
// POL Miner (2026-10-28): shows once 'polminer' is in gamesLive (the public games list), like PolyBreak
|
// POL Miner (2026-10-28): shows once 'polminer' is in gamesLive (the public games list), like PolyBreak
|
||||||
{ slug: 'polminer', name: 'POL Miner', link: 'https://polminer.com/?ref=', img: 'https://coolify-saasytop.nyc3.cdn.digitaloceanspaces.com/game-banners/polminer/og-polminer.jpg', sub: 'mining game that pays Polygon',
|
{ slug: 'polminer', name: 'POL Miner', link: 'https://polminer.com/?ref=', img: CDN + 'polminer/og-polminer.jpg', sub: 'mining game that pays Polygon',
|
||||||
posts: [
|
posts: [
|
||||||
{ name: 'Short post', text: 'POL Miner is a free mining game. Dig down through the layers, haul ore up to sell, upgrade your pick, lamp and cart, and beat a drill boss every 30 m. The rare pink Polygon crystals pay Polygon to the wallet on your InstantAdPay account. {L}' },
|
{ name: 'Short post', text: 'POL Miner is a free mining game. Dig down through the layers, haul ore up to sell, upgrade your pick, lamp and cart, and beat a drill boss every 30 m. The rare pink Polygon crystals pay Polygon to the wallet on your InstantAdPay account. {L}' },
|
||||||
{ name: 'Friendly post', text: 'This one is easy to lose an hour in. POL Miner is free, it plays fine on a phone, and you sign in with your InstantAdPay account. Each pink Polygon crystal you dig out pays Polygon, and so does each drill boss the first time you beat it. Give it a dig: {L}' },
|
{ name: 'Friendly post', text: 'This one is easy to lose an hour in. POL Miner is free, it plays fine on a phone, and you sign in with your InstantAdPay account. Each pink Polygon crystal you dig out pays Polygon, and so does each drill boss the first time you beat it. Give it a dig: {L}' },
|
||||||
{ name: 'Crystal angle', text: 'Somewhere under the gravel there is a pink glow. In POL Miner the rare Polygon crystals pay Polygon when you dig them out. Free to play: {L}' },
|
{ name: 'Crystal angle', text: 'Somewhere under the gravel there is a pink glow. In POL Miner the rare Polygon crystals pay Polygon when you dig them out. Free to play: {L}' },
|
||||||
{ name: 'Telegram or WhatsApp line', text: 'New game in the network: POL Miner. Free mining game, the pink Polygon crystals pay Polygon: {L}' }] },
|
{ name: 'Telegram or WhatsApp line', text: 'New game in the network: POL Miner. Free mining game, the pink Polygon crystals pay Polygon: {L}' }] },
|
||||||
{ slug: 'polybreak', name: 'PolyBreak', link: 'https://polybreak.app/?ref=', img: 'https://coolify-saasytop.nyc3.cdn.digitaloceanspaces.com/game-banners/polybreak/og-polybreak.jpg', sub: 'brick breaker that pays Polygon',
|
{ slug: 'polybreak', name: 'PolyBreak', link: 'https://polybreak.app/?ref=', img: CDN + 'polybreak/og-polybreak.jpg', sub: 'brick breaker that pays Polygon',
|
||||||
posts: [
|
posts: [
|
||||||
{ name: 'Short post', text: 'PolyBreak is a free brick breaker in the old Amiga arcade style. Smash a wall of glass jewel bricks, grab the capsules, and catch the purple Polygon gem when it drops. Your first clear of each round pays Polygon to the wallet on your InstantAdPay account. {L}' },
|
{ name: 'Short post', text: 'PolyBreak is a free brick breaker in the old Amiga arcade style. Smash a wall of glass jewel bricks, grab the capsules, and catch the purple Polygon gem when it drops. Your first clear of each round pays Polygon to the wallet on your InstantAdPay account. {L}' },
|
||||||
{ name: 'Friendly post', text: 'I grew up on brick breakers, so this one got me. PolyBreak is free, it plays great on a phone, and it signs in with your InstantAdPay account. First round clears pay Polygon, and so does every purple gem you catch. Out of paddles? Visit a member\'s page and you get one more. Give it a try: {L}' },
|
{ name: 'Friendly post', text: 'I grew up on brick breakers, so this one got me. PolyBreak is free, it plays great on a phone, and it signs in with your InstantAdPay account. First round clears pay Polygon, and so does every purple gem you catch. Out of paddles? Visit a member\'s page and you get one more. Give it a try: {L}' },
|
||||||
@@ -340,7 +343,7 @@ window.IAPPromo = (function () {
|
|||||||
{ name: 'Telegram or WhatsApp line', text: 'New game in the network: PolyWarriors. Free cyberpunk battler, pays Polygon for first wins, your first warrior mints free: {L}' }] },
|
{ name: 'Telegram or WhatsApp line', text: 'New game in the network: PolyWarriors. Free cyberpunk battler, pays Polygon for first wins, your first warrior mints free: {L}' }] },
|
||||||
{ slug: 'gemkingdom', name: 'Gem Kingdom', link: 'https://gemkingdom.app/?ref=', img: 'https://gemkingdom.app/fantasy/og-gemkingdom.jpg', sub: 'fantasy match-3 with boss battles',
|
{ slug: 'gemkingdom', name: 'Gem Kingdom', link: 'https://gemkingdom.app/?ref=', img: 'https://gemkingdom.app/fantasy/og-gemkingdom.jpg', sub: 'fantasy match-3 with boss battles',
|
||||||
posts: [
|
posts: [
|
||||||
{ name: 'Short post', text: 'Gem Kingdom is a free fantasy match-3. Lead three heroes, beat the Goblin King’s bosses and rebuild your village. Boss wins come with POL rewards. Play here: {L}' },
|
{ name: 'Short post', text: 'Gem Kingdom is a fantasy match-3 you can start playing free. Lead three heroes, beat the Goblin King’s bosses and rebuild your village. A one-time $5 Royal Charter opens the last three chapters and their POL rewards. Play here: {L}' },
|
||||||
{ name: 'Friendly post', text: 'Looking for a game to unwind with? Gem Kingdom is match-3 with a story: forge weapons, collect stars and climb the leaderboard. Free in your browser: {L}' }] },
|
{ name: 'Friendly post', text: 'Looking for a game to unwind with? Gem Kingdom is match-3 with a story: forge weapons, collect stars and climb the leaderboard. Free in your browser: {L}' }] },
|
||||||
{ slug: 'roadagent', name: 'Road Agent', link: 'https://roadagent.app/?ref=', img: 'https://roadagent.app/og-roadagent.jpg', sub: 'night highway shooter',
|
{ slug: 'roadagent', name: 'Road Agent', link: 'https://roadagent.app/?ref=', img: 'https://roadagent.app/og-roadagent.jpg', sub: 'night highway shooter',
|
||||||
posts: [
|
posts: [
|
||||||
@@ -350,7 +353,7 @@ window.IAPPromo = (function () {
|
|||||||
posts: [
|
posts: [
|
||||||
{ name: 'Short post', text: 'Drip Runner is a quick free runner game. Hop the network, dodge the drones, clear chapters and refuel for POL rewards. Play in your browser: {L}' },
|
{ name: 'Short post', text: 'Drip Runner is a quick free runner game. Hop the network, dodge the drones, clear chapters and refuel for POL rewards. Play in your browser: {L}' },
|
||||||
{ name: 'Friendly post', text: 'Got two minutes? Drip Runner is a fast little runner game I keep coming back to. See how far you get: {L}' }] },
|
{ name: 'Friendly post', text: 'Got two minutes? Drip Runner is a fast little runner game I keep coming back to. See how far you get: {L}' }] },
|
||||||
{ slug: 'clutterhunt', name: 'ClutterHunt', link: 'https://clutterhunt.com/?ref=', img: 'https://coolify-saasytop.nyc3.cdn.digitaloceanspaces.com/game-banners/clutterhunt/og-harvest-farmhouse.jpg', sub: 'hidden-object game, Harvest Farmhouse rooms through Nov 30',
|
{ slug: 'clutterhunt', name: 'ClutterHunt', link: 'https://clutterhunt.com/?ref=', img: CDN + 'clutterhunt/og-harvest-farmhouse.jpg', sub: 'hidden-object game, Harvest Farmhouse rooms through Nov 30',
|
||||||
posts: [
|
posts: [
|
||||||
{ name: 'Short post', text: 'ClutterHunt is a free hidden-object game, and the Harvest Farmhouse just opened: six new rooms through Nov 30, a clock running, and everything moves each time you play. First clears pay POL. Can you three-star Expert? {L}' },
|
{ name: 'Short post', text: 'ClutterHunt is a free hidden-object game, and the Harvest Farmhouse just opened: six new rooms through Nov 30, a clock running, and everything moves each time you play. First clears pay POL. Can you three-star Expert? {L}' },
|
||||||
{ name: 'Friendly post', text: 'If you like spot-the-object puzzles, try ClutterHunt. New farmhouse rooms this month, free in your browser, with POL rewards for clearing rooms: {L}' },
|
{ name: 'Friendly post', text: 'If you like spot-the-object puzzles, try ClutterHunt. New farmhouse rooms this month, free in your browser, with POL rewards for clearing rooms: {L}' },
|
||||||
@@ -393,7 +396,7 @@ window.IAPPromo = (function () {
|
|||||||
for (const p of posts) pp.appendChild(block(p.text, '<span class="lab">' + esc(p.name) + '</span>', [linkBtn('https://x.com/intent/tweet?text=' + enc(p.text), 'X'), linkBtn('https://t.me/share/url?url=' + enc(link) + '&text=' + enc(p.text.replace(link, '').trim()), 'Telegram'), linkBtn('https://wa.me/?text=' + enc(p.text), 'WhatsApp')]));
|
for (const p of posts) pp.appendChild(block(p.text, '<span class="lab">' + esc(p.name) + '</span>', [linkBtn('https://x.com/intent/tweet?text=' + enc(p.text), 'X'), linkBtn('https://t.me/share/url?url=' + enc(link) + '&text=' + enc(p.text.replace(link, '').trim()), 'Telegram'), linkBtn('https://wa.me/?text=' + enc(p.text), 'WhatsApp')]));
|
||||||
}
|
}
|
||||||
const grid = $('gbGrid'); grid.innerHTML = '';
|
const grid = $('gbGrid'); grid.innerHTML = '';
|
||||||
for (const [s, n] of SIZES) { const w = s.split('x')[0], h = s.split('x')[1], src = CDN + g.slug + '/' + g.slug + '-' + s + '.png';
|
for (const [s, n] of SIZES) { const w = s.split('x')[0], h = s.split('x')[1], src = CDN + g.slug + '/' + s + '.png';
|
||||||
const code = '<a href="' + link + '" target="_blank" rel="noopener"><img src="' + src + '" width="' + w + '" height="' + h + '" alt="' + g.name + '"></a>';
|
const code = '<a href="' + link + '" target="_blank" rel="noopener"><img src="' + src + '" width="' + w + '" height="' + h + '" alt="' + g.name + '"></a>';
|
||||||
const d = document.createElement('div'); d.className = 'promo-block'; d.innerHTML = '<div class="pb-head"><span class="lab">' + s + '</span> <span class="muted small">' + esc(n) + '</span></div><div style="overflow:auto;margin:8px 0"><img loading="lazy" src="' + src + '" alt="' + esc(g.name) + ' ' + s + '" style="max-width:100%;height:auto;border-radius:6px"></div><div class="pb-text mono small" style="overflow-wrap:anywhere">' + esc(code) + '</div>';
|
const d = document.createElement('div'); d.className = 'promo-block'; d.innerHTML = '<div class="pb-head"><span class="lab">' + s + '</span> <span class="muted small">' + esc(n) + '</span></div><div style="overflow:auto;margin:8px 0"><img loading="lazy" src="' + src + '" alt="' + esc(g.name) + ' ' + s + '" style="max-width:100%;height:auto;border-radius:6px"></div><div class="pb-text mono small" style="overflow-wrap:anywhere">' + esc(code) + '</div>';
|
||||||
const row = document.createElement('div'); row.className = 'pb-actions'; row.appendChild(copyBtn(code, 'Copy embed code')); row.appendChild(copyBtn(src, 'Copy image URL')); row.appendChild(linkBtn(src, 'Open image')); d.appendChild(row); grid.appendChild(d); }
|
const row = document.createElement('div'); row.className = 'pb-actions'; row.appendChild(copyBtn(code, 'Copy embed code')); row.appendChild(copyBtn(src, 'Copy image URL')); row.appendChild(linkBtn(src, 'Open image')); d.appendChild(row); grid.appendChild(d); }
|
||||||
@@ -455,7 +458,7 @@ window.IAPPromo = (function () {
|
|||||||
{ name: 'Partner angle', net: 'LinkedIn', text: 'BixPay pays partners on every card and on card spending, ten levels deep. If you\'re building a team anyway, this fits right in: {L}' }
|
{ name: 'Partner angle', net: 'LinkedIn', text: 'BixPay pays partners on every card and on card spending, ten levels deep. If you\'re building a team anyway, this fits right in: {L}' }
|
||||||
];
|
];
|
||||||
const BIX_SWIPE = { subject: 'A Visa card for the crypto you already earn', body: 'Hey,\n\nQuick one, because this solved something for me.\n\nI earn crypto in a few places, and for a long time the awkward part was spending it. Exchange, bank, waiting, fees. BixPay took that out of the loop: it is a self-custody wallet with a Visa card in one app. You send USDT or USDC to it on Polygon, load the card, and pay wherever Visa is accepted, Apple Pay and Google Pay included.\n\nThe parts I liked:\n- The keys stay with you. It is your wallet, not an account someone else holds.\n- No load fee. 3% per purchase, and BIX\'s terms cover the rest.\n- A virtual card is $9.99 and you can be using it the same day.\n- If you build a team, BixPay pays partners on every card and on card spending, ten levels deep.\n\nUS note: it is open in 31 states so far. If yours is not on the list yet, you can still get the wallet and build.\n\nHere is my link: {L}\n\nBixPay is a separate company. BIX issues the wallet and the card through its banking partners and sets its own fees, limits, eligibility and terms. Crypto assets can lose value.\n\nTalk soon,' };
|
const BIX_SWIPE = { subject: 'A Visa card for the crypto you already earn', body: 'Hey,\n\nQuick one, because this solved something for me.\n\nI earn crypto in a few places, and for a long time the awkward part was spending it. Exchange, bank, waiting, fees. BixPay took that out of the loop: it is a self-custody wallet with a Visa card in one app. You send USDT or USDC to it on Polygon, load the card, and pay wherever Visa is accepted, Apple Pay and Google Pay included.\n\nThe parts I liked:\n- The keys stay with you. It is your wallet, not an account someone else holds.\n- No load fee. 3% per purchase, and BIX\'s terms cover the rest.\n- A virtual card is $9.99 and you can be using it the same day.\n- If you build a team, BixPay pays partners on every card and on card spending, ten levels deep.\n\nUS note: it is open in 31 states so far. If yours is not on the list yet, you can still get the wallet and build.\n\nHere is my link: {L}\n\nBixPay is a separate company. BIX issues the wallet and the card through its banking partners and sets its own fees, limits, eligibility and terms. Crypto assets can lose value.\n\nTalk soon,' };
|
||||||
const BIX_CDN = 'https://coolify-saasytop.nyc3.cdn.digitaloceanspaces.com/game-banners/bixpay/';
|
const BIX_CDN = ((typeof SHARE_DOMAIN === 'string' && SHARE_DOMAIN) ? 'https://' + SHARE_DOMAIN : location.origin) + '/b/bixpay/'; // short image host, same files as the game-banners CDN (2026-11-03)
|
||||||
const BIX_SIZES = [['728x90', 'Leaderboard'], ['300x250', 'Medium rectangle'], ['468x60', 'Banner'], ['600x300', 'Traffic exchange / splash page']];
|
const BIX_SIZES = [['728x90', 'Leaderboard'], ['300x250', 'Medium rectangle'], ['468x60', 'Banner'], ['600x300', 'Traffic exchange / splash page']];
|
||||||
function fillBix(me) {
|
function fillBix(me) {
|
||||||
const b = (me && me.bix) || {}; const sec = $('promo-bixpay'); if (!sec) return;
|
const b = (me && me.bix) || {}; const sec = $('promo-bixpay'); if (!sec) return;
|
||||||
|
|||||||
@@ -509,6 +509,7 @@ textarea{resize:vertical;font:inherit}
|
|||||||
.lin-row .sp.wrap{white-space:normal;line-height:1.7}
|
.lin-row .sp.wrap{white-space:normal;line-height:1.7}
|
||||||
/* list toolbar: sort + filter chips shared by the tank, roster and downline (2026-09-29) */
|
/* list toolbar: sort + filter chips shared by the tank, roster and downline (2026-09-29) */
|
||||||
.lst-bar{display:flex;flex-wrap:wrap;align-items:center;gap:6px 10px;margin:4px 0 10px;padding:8px 10px;border:1px solid var(--line);border-radius:12px;background:var(--ink-faint)}
|
.lst-bar{display:flex;flex-wrap:wrap;align-items:center;gap:6px 10px;margin:4px 0 10px;padding:8px 10px;border:1px solid var(--line);border-radius:12px;background:var(--ink-faint)}
|
||||||
|
.lst-q{flex:1 1 100%;min-width:0;background:var(--panel);color:var(--ink);border:1px solid var(--line-strong);border-radius:8px;padding:6px 10px;font-size:13px}
|
||||||
.lst-sort{font-size:12px;color:var(--muted);display:inline-flex;align-items:center;gap:6px}
|
.lst-sort{font-size:12px;color:var(--muted);display:inline-flex;align-items:center;gap:6px}
|
||||||
.lst-sort select{background:var(--panel);color:var(--ink);border:1px solid var(--line-strong);border-radius:8px;padding:4px 8px;font-size:12.5px}
|
.lst-sort select{background:var(--panel);color:var(--ink);border:1px solid var(--line-strong);border-radius:8px;padding:4px 8px;font-size:12.5px}
|
||||||
.lst-dir{background:transparent;color:var(--ink);border:1px solid var(--line-strong);border-radius:8px;padding:4px 9px;font-size:12px;cursor:pointer;white-space:nowrap}
|
.lst-dir{background:transparent;color:var(--ink);border:1px solid var(--line-strong);border-radius:8px;padding:4px 9px;font-size:12px;cursor:pointer;white-space:nowrap}
|
||||||
@@ -516,6 +517,8 @@ textarea{resize:vertical;font:inherit}
|
|||||||
.lst-chip{font-size:12px;color:var(--muted);background:transparent;border:1px solid var(--line);border-radius:999px;padding:3px 10px;cursor:pointer;white-space:nowrap}
|
.lst-chip{font-size:12px;color:var(--muted);background:transparent;border:1px solid var(--line);border-radius:999px;padding:3px 10px;cursor:pointer;white-space:nowrap}
|
||||||
.lst-chip.on{border-color:var(--mint);color:var(--ink);background:var(--mint-soft)}
|
.lst-chip.on{border-color:var(--mint);color:var(--ink);background:var(--mint-soft)}
|
||||||
.lst-n{margin-left:auto;font-size:12px;color:var(--muted);font-variant-numeric:tabular-nums}
|
.lst-n{margin-left:auto;font-size:12px;color:var(--muted);font-variant-numeric:tabular-nums}
|
||||||
|
.roster-em{color:var(--mint);word-break:break-all;margin-top:2px}
|
||||||
|
.lst-copy{background:transparent;color:var(--muted);border:1px solid var(--line);border-radius:6px;padding:0 6px;font-size:11px;cursor:pointer;margin-left:4px}
|
||||||
.lchip{display:inline-block;font-size:11.5px;color:var(--muted);border:1px solid var(--line);border-radius:999px;padding:1px 8px;white-space:nowrap;vertical-align:middle}
|
.lchip{display:inline-block;font-size:11.5px;color:var(--muted);border:1px solid var(--line);border-radius:999px;padding:1px 8px;white-space:nowrap;vertical-align:middle}
|
||||||
.lchip.on{border-color:var(--mint-line);color:var(--ink)} .lchip.warn{border-color:var(--gold-line);color:var(--gold)}
|
.lchip.on{border-color:var(--mint-line);color:var(--ink)} .lchip.warn{border-color:var(--gold-line);color:var(--gold)}
|
||||||
.roster td:nth-child(3){white-space:normal;line-height:1.8}
|
.roster td:nth-child(3){white-space:normal;line-height:1.8}
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 210 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 170 KiB |
+2
-2
@@ -14,7 +14,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
<style>
|
<style>
|
||||||
.rg{max-width:900px}
|
.rg{max-width:900px}
|
||||||
.rg .hero{padding:44px 0 10px}
|
.rg .hero{padding:44px 0 10px}
|
||||||
@@ -165,7 +165,7 @@
|
|||||||
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
|
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/common.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script>
|
||||||
<script src="/assets/bixpay-guide.js?v=20261029bz"></script>
|
<script src="/assets/bixpay-guide.js?v=20261029bz"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -0,0 +1,208 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||||
|
<title>Chasing Unicorns: spot the scam before it spots you</title>
|
||||||
|
<meta name="description" content="A fake earnings dashboard with a ticking balance, a countdown and people cashing out every few seconds. Click anything and see the red flag behind it. A free training simulation from InstantAdPay.">
|
||||||
|
<meta property="og:type" content="website">
|
||||||
|
<meta property="og:title" content="Chasing Unicorns: can you spot all 8 red flags?">
|
||||||
|
<meta property="og:description" content="A fake earnings dashboard that looks like the real thing. Click anything on it and see the red flag behind it. Free, takes two minutes.">
|
||||||
|
<meta property="og:url" content="https://instantadpay.com/chasing-unicorns">
|
||||||
|
<meta property="og:image" content="https://instantadpay.com/assets/chasing-unicorns-og.png?v=20261112">
|
||||||
|
<meta property="og:image:width" content="1200"><meta property="og:image:height" content="630">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<link rel="canonical" href="https://instantadpay.com/chasing-unicorns">
|
||||||
|
<link rel="icon" href="/favicon.ico">
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@400;600;800&family=JetBrains+Mono:wght@500;700&display=swap">
|
||||||
|
<style>
|
||||||
|
/* Layout: an honest frame (training bar, scam radar, the ending) wrapped around a deliberately over-the-top fake console. Single dark look. */
|
||||||
|
:root {
|
||||||
|
--bg: #090a12; --panel: #121527; --panel2: #191d35; --line: #262c4d; --ink: #f1f2fb; --muted: #969cbf;
|
||||||
|
--uni: #c084fc; --uni2: #f472b6; --gold: #f8cf4f; --mint: #34e3a0; --warn: #ff5d6c; --warn-ink: #fff; --ok: #34e3a0;
|
||||||
|
--display: 'Sora', 'Segoe UI', system-ui, sans-serif; --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
* { box-sizing: border-box; }
|
||||||
|
[hidden] { display: none !important; }
|
||||||
|
html, body { margin: 0; }
|
||||||
|
body { background: var(--bg); color: var(--ink); font-family: var(--display); font-size: 15px; line-height: 1.5; }
|
||||||
|
a { color: var(--mint); }
|
||||||
|
button { font-family: var(--display); cursor: pointer; }
|
||||||
|
button:focus-visible, a:focus-visible { outline: 3px solid var(--mint); outline-offset: 3px; }
|
||||||
|
.sim { position: sticky; top: 0; z-index: 30; background: #1b1030; border-bottom: 1px solid #3b2463; padding-block: 8px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; justify-content: space-between; font-size: 13px; }
|
||||||
|
.sim b { color: var(--uni); }
|
||||||
|
.radar { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12.5px; }
|
||||||
|
.radar .dots { display: flex; gap: 4px; }
|
||||||
|
.radar .dots i { width: 10px; height: 10px; border-radius: 50%; background: #3b3460; display: block; }
|
||||||
|
.radar .dots i.on { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
|
||||||
|
.wrap { max-width: 1000px; margin: 0 auto; padding-block: 22px 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: grid; gap: 16px; }
|
||||||
|
.intro { display: grid; gap: 6px; }
|
||||||
|
.intro h1 { margin: 0; font-size: clamp(24px, 4.4vw, 38px); line-height: 1.15; text-wrap: balance; }
|
||||||
|
.intro h1 span { background: linear-gradient(90deg, var(--uni), var(--uni2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
|
||||||
|
.intro p { margin: 0; color: var(--muted); max-width: 66ch; }
|
||||||
|
/* the fake console */
|
||||||
|
.console { border: 1px solid var(--line); border-radius: 20px; background: radial-gradient(140% 120% at 0% 0%, #22184a 0%, var(--panel) 50%); padding: 18px; display: grid; gap: 14px; }
|
||||||
|
.ctop { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
|
||||||
|
.brand { font-weight: 800; font-size: 19px; display: flex; align-items: center; gap: 8px; }
|
||||||
|
.brand svg { width: 28px; height: 28px; }
|
||||||
|
.brand em { font-style: normal; background: linear-gradient(90deg, var(--uni), var(--uni2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
|
||||||
|
.tier { font-family: var(--mono); font-size: 12px; color: var(--gold); border: 1px solid var(--gold); border-radius: 999px; padding: 3px 11px; }
|
||||||
|
.bal { display: grid; gap: 4px; }
|
||||||
|
.lbl { font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
|
||||||
|
.big { font-family: var(--mono); font-weight: 700; font-size: clamp(30px, 7vw, 60px); color: var(--gold); font-variant-numeric: tabular-nums; line-height: 1.05; word-break: break-all; text-shadow: 0 0 26px rgba(248, 207, 79, .35); }
|
||||||
|
.rate { font-family: var(--mono); color: var(--mint); font-size: 14px; font-variant-numeric: tabular-nums; }
|
||||||
|
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
|
||||||
|
.tile { background: rgba(9, 10, 18, .55); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: grid; gap: 4px; min-width: 0; text-align: left; color: var(--ink); }
|
||||||
|
.tile .v { font-family: var(--mono); font-weight: 700; font-size: 19px; font-variant-numeric: tabular-nums; color: var(--mint); }
|
||||||
|
.tile .s { font-size: 12px; color: var(--muted); }
|
||||||
|
button.tile { cursor: pointer; }
|
||||||
|
.timer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; background: linear-gradient(90deg, #3b0d1c, #1e0b16); border: 1px solid var(--warn); border-radius: 14px; padding: 12px 14px; }
|
||||||
|
.timer .m { font-weight: 800; min-width: 0; }
|
||||||
|
.timer .m small { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; }
|
||||||
|
.clock { font-family: var(--mono); font-weight: 700; font-size: 28px; color: var(--warn); font-variant-numeric: tabular-nums; }
|
||||||
|
.acts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
|
||||||
|
.act { border: 0; border-radius: 13px; padding: 13px 14px; font-weight: 800; font-size: 15px; text-align: left; display: grid; gap: 2px; color: #170f00; background: linear-gradient(180deg, #ffe07a, var(--gold)); }
|
||||||
|
.act small { font-weight: 600; font-size: 12px; opacity: .75; }
|
||||||
|
.act.alt { background: var(--panel2); color: var(--ink); border: 1px solid var(--uni); }
|
||||||
|
.act.alt small { color: var(--muted); opacity: 1; }
|
||||||
|
.act.hot { background: linear-gradient(180deg, #ff8fa0, var(--warn)); color: #fff; }
|
||||||
|
.act.done, .tile.done { outline: 2px solid var(--warn); outline-offset: -2px; }
|
||||||
|
/* fake social proof */
|
||||||
|
.proof { position: fixed; left: max(16px, env(safe-area-inset-left, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); width: min(330px, calc(100vw - 32px)); background: #fff; color: #11131d; border-radius: 12px; padding: 11px 13px; box-shadow: 0 12px 30px rgba(0, 0, 0, .5); display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center; transform: translateY(150%); opacity: 0; transition: transform .35s ease, opacity .35s ease; z-index: 25; border: 0; text-align: left; font-family: var(--display); }
|
||||||
|
.proof.on { transform: none; opacity: 1; }
|
||||||
|
.proof .av { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--uni), var(--uni2)); color: #fff; display: grid; place-items: center; font-weight: 800; grid-row: span 2; }
|
||||||
|
.proof .t { font-size: 13.5px; line-height: 1.35; }
|
||||||
|
.proof .t b { color: #0a8f55; }
|
||||||
|
.proof .f { font-size: 11px; color: #6b6f85; }
|
||||||
|
/* the reveal */
|
||||||
|
.veil { position: fixed; inset: 0; z-index: 40; background: rgba(5, 5, 12, .78); display: grid; place-items: center; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 16px; }
|
||||||
|
.card { background: var(--panel); border: 1px solid var(--warn); border-radius: 18px; max-width: 560px; width: 100%; padding: 20px; display: grid; gap: 10px; max-height: calc(100vh - 32px); overflow: auto; }
|
||||||
|
.card .k { font-family: var(--mono); font-size: 12px; color: var(--warn); letter-spacing: .1em; text-transform: uppercase; }
|
||||||
|
.card h2 { margin: 0; font-size: 22px; line-height: 1.25; text-wrap: balance; }
|
||||||
|
.card p { margin: 0; }
|
||||||
|
.card .tell { background: rgba(255, 93, 108, .08); border-left: 3px solid var(--warn); padding: 8px 12px; border-radius: 6px; font-size: 14px; }
|
||||||
|
.card .do { background: rgba(52, 227, 160, .08); border-left: 3px solid var(--ok); padding: 8px 12px; border-radius: 6px; font-size: 14px; }
|
||||||
|
.card .row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
|
||||||
|
.btn { border: 0; border-radius: 11px; padding: 11px 16px; font-weight: 800; font-size: 14.5px; text-decoration: none; display: inline-block; }
|
||||||
|
.btn.go { background: var(--mint); color: #04130d; }
|
||||||
|
.btn.sec { background: transparent; color: var(--ink); border: 1px solid var(--line); }
|
||||||
|
/* the ending */
|
||||||
|
.end { display: grid; gap: 14px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); padding: 22px 18px; }
|
||||||
|
.end h2 { margin: 0; font-size: clamp(22px, 3.6vw, 30px); text-wrap: balance; }
|
||||||
|
.end p { margin: 0; max-width: 68ch; }
|
||||||
|
.flags { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
|
||||||
|
.flags li { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; display: grid; gap: 2px; background: var(--panel2); }
|
||||||
|
.flags li b { font-size: 14px; }
|
||||||
|
.flags li.on { border-color: var(--warn); }
|
||||||
|
.flags li.on b::before { content: "SPOTTED "; color: var(--warn); font-family: var(--mono); font-size: 11px; }
|
||||||
|
.flags li:not(.on) { opacity: .6; }
|
||||||
|
.vs { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
|
||||||
|
.vs > div { border-radius: 14px; padding: 14px; display: grid; gap: 6px; align-content: start; }
|
||||||
|
.vs .bad { background: rgba(255, 93, 108, .07); border: 1px solid rgba(255, 93, 108, .4); }
|
||||||
|
.vs .good { background: rgba(52, 227, 160, .07); border: 1px solid rgba(52, 227, 160, .4); }
|
||||||
|
.vs h3 { margin: 0; font-size: 16px; }
|
||||||
|
.vs ul { margin: 0; padding-left: 18px; font-size: 14px; display: grid; gap: 4px; }
|
||||||
|
.agit { display: grid; gap: 10px; border: 1px solid rgba(255, 93, 108, .45); background: linear-gradient(180deg, rgba(255, 93, 108, .08), transparent); border-radius: 16px; padding: 16px; }
|
||||||
|
.agit ul { margin: 0; padding-left: 18px; display: grid; gap: 8px; max-width: 70ch; }
|
||||||
|
.agit li b { color: var(--warn); }
|
||||||
|
.cta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
|
||||||
|
.fine { font-size: 12.5px; color: var(--muted); }
|
||||||
|
.share { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
|
||||||
|
.share code { font-family: var(--mono); font-size: 12.5px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; word-break: break-all; }
|
||||||
|
.foot { font-size: 12px; color: var(--muted); text-align: center; }
|
||||||
|
@media (prefers-reduced-motion: reduce) { .proof { transition: none; } .big { text-shadow: none; } }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="sim" role="note"><span><b>Training simulation.</b> Nothing on this dashboard is real. Click anything to see the red flag behind it.</span>
|
||||||
|
<span class="radar" aria-label="Red flags spotted">Scam radar <span class="dots" id="dots"></span> <span id="score">0 of 8</span></span></div>
|
||||||
|
|
||||||
|
<main class="wrap">
|
||||||
|
<div class="intro">
|
||||||
|
<h1>Still waiting on a payout? <span>Let's go chasing unicorns.</span></h1>
|
||||||
|
<p>You signed up, you watched the balance grow, you maybe even brought a friend. Then you hit Withdraw, and you are still waiting. Below is the kind of dashboard those sites show you: a balance that never stops climbing, a countdown, people cashing out every few seconds. It looks great. That is the point. Click anything on it, the way you would on the real thing, and see what is really going on.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<section class="console" aria-label="Fake earnings dashboard">
|
||||||
|
<div class="ctop">
|
||||||
|
<div class="brand"><svg viewBox="0 0 32 32" aria-hidden="true"><defs><linearGradient id="ug" x1="0" x2="1"><stop offset="0" stop-color="#c084fc"/><stop offset="1" stop-color="#f472b6"/></linearGradient></defs><path d="M6 26c2-7 6-11 11-12l3-9 2 8c3 1 5 4 5 7-2 0-4-1-5-2-1 4-4 7-9 8H6z" fill="url(#ug)"/></svg>Unicorn<em>Yield</em> Pro</div>
|
||||||
|
<button type="button" class="tier" data-flag="vip">VIP DIAMOND · Upgrade</button>
|
||||||
|
</div>
|
||||||
|
<div class="bal">
|
||||||
|
<div class="lbl">Your balance</div>
|
||||||
|
<div class="big" id="bal">$25,000.00</div>
|
||||||
|
<div class="rate" id="rate">+3.00% daily compound interest · +$0.00 since you opened this page</div>
|
||||||
|
</div>
|
||||||
|
<div class="tiles">
|
||||||
|
<button type="button" class="tile" data-flag="daily"><span class="lbl">Interest today</span><span class="v" id="today">$0.00</span><span class="s">Fixed 3% a day, guaranteed</span></button>
|
||||||
|
<button type="button" class="tile" data-flag="team"><span class="lbl">Team bonus</span><span class="v" id="team">$1,240.00</span><span class="s">12 people under you</span></button>
|
||||||
|
<button type="button" class="tile" data-flag="coin"><span class="lbl">UYP token holdings</span><span class="v">48,000 UYP</span><span class="s">Value: $4,800.00 (soon x100)</span></button>
|
||||||
|
</div>
|
||||||
|
<div class="timer">
|
||||||
|
<div class="m">BONUS DOUBLER ENDS SOON! Lock in 6% a day.<small><span id="spots">Only 3 VIP spots left</span> · tell your friends before it closes</small></div>
|
||||||
|
<div class="clock" id="clock">09:59</div>
|
||||||
|
<button type="button" class="act hot" data-flag="clock">Lock it in now<small>before the timer hits zero</small></button>
|
||||||
|
</div>
|
||||||
|
<div class="acts">
|
||||||
|
<button type="button" class="act" data-flag="withdraw">Withdraw $25,000<small>Fast and easy</small></button>
|
||||||
|
<button type="button" class="act alt" data-flag="vip">Unlock withdrawals<small>VIP upgrade, $199 one time</small></button>
|
||||||
|
<button type="button" class="act alt" data-flag="team">Invite friends<small>+$500 per sign-up</small></button>
|
||||||
|
<button type="button" class="act alt" data-flag="keys">Connect wallet to claim<small>Claim 48,000 UYP airdrop</small></button>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="end" id="end" aria-label="Your scam radar">
|
||||||
|
<h2 id="endH">Your scam radar: 0 of 8 red flags spotted</h2>
|
||||||
|
<p id="endP">Every button, tile and popup on that dashboard is one of the classic warning signs. Find them all, or <button type="button" class="btn sec" id="showAll" style="padding:4px 10px;font-size:13px">show me all 8</button></p>
|
||||||
|
<ul class="flags" id="flags"></ul>
|
||||||
|
<div id="after" hidden style="display:grid;gap:14px">
|
||||||
|
<div class="agit">
|
||||||
|
<h2>Here is what chasing unicorns really costs you</h2>
|
||||||
|
<ul>
|
||||||
|
<li><b>The deposit.</b> The number on the screen was never your money. The money you sent in was, and it is already gone.</li>
|
||||||
|
<li><b>The "free" ones.</b> Some never ask for a penny up front. Free to join, free to "earn", a big withdrawal promised for later, knowing it is never coming. Everybody piles in for free while the countdown runs, inviting friends to grow their balance. When the timer hits zero, the fee shows up, and now thousands of people are lined up to pay it.</li>
|
||||||
|
<li><b>The "release fee".</b> When withdrawals stall, the next message asks you to pay something small to unlock the big balance: a miner fee, a gas fee, an admin fee, a tax, a verification fee, a VIP upgrade. It always sounds minor next to what is "waiting" for you. Pay it, and another one appears.</li>
|
||||||
|
<li><b>Your friends.</b> Everyone you invited is now asking you where their money is. You did not mean to, but you sold them the unicorn.</li>
|
||||||
|
<li><b>Your time.</b> Months of checking a dashboard, waiting on a Telegram admin, hoping this week is the week.</li>
|
||||||
|
<li><b>The next one.</b> When this site goes dark, a "recovery service" shows up offering to get your money back, for a fee. Then a new unicorn with a new countdown.</li>
|
||||||
|
</ul>
|
||||||
|
<p>And the worst part: after enough of these, people stop trusting anything online, including the things that actually work.</p>
|
||||||
|
</div>
|
||||||
|
<h2>Quit chasing unicorns. Look for receipts.</h2>
|
||||||
|
<p>A real program does not need a magic number on a screen. It needs a product people actually buy, and payments you can check yourself without asking anyone. That is how we built InstantAdPay.</p>
|
||||||
|
<div class="vs">
|
||||||
|
<div class="bad"><h3>The unicorn</h3><ul>
|
||||||
|
<li>A fixed daily return on your deposit</li><li>Withdrawals always "processing"</li><li>Pay a fee to unlock your own money</li><li>Paid in their own coin</li><li>A countdown that never ends</li></ul></div>
|
||||||
|
<div class="good"><h3>What InstantAdPay does instead</h3><ul>
|
||||||
|
<li>Sells real advertising: ad packages from $5 buy text ads, banners, visits and more across the network</li>
|
||||||
|
<li>When a package sells, the sponsor line is paid by smart contract in the same transaction. Nothing is held by the company.</li>
|
||||||
|
<li>Every payment is on the Polygon blockchain, so you can look it up yourself</li>
|
||||||
|
<li>Joining is free and starts with just your email. No card, no wallet needed to look around.</li>
|
||||||
|
<li>No balance to "unlock" and no countdown</li></ul></div>
|
||||||
|
</div>
|
||||||
|
<div class="cta"><a class="btn go" id="joinBtn" href="/join?src=chasing-unicorns">Look around InstantAdPay free</a><a class="btn sec" href="/ledger" id="ledgerBtn">See the public payment ledger</a></div>
|
||||||
|
<p class="fine">Ad credits buy advertising, not income. No income is promised: what you earn depends on the packages bought by people you bring in.</p>
|
||||||
|
<div class="share" id="shareRow"><span class="fine">Know someone still waiting on a payout? Send them this:</span> <code id="shareLink">https://instantadpay.com/chasing-unicorns</code> <button type="button" class="btn sec" id="copyShare" style="padding:6px 12px;font-size:13px">Copy link</button></div>
|
||||||
|
<p class="fine">The full checklist, with a 3 minute video: <a href="https://earnerscorner.com/t/what-do-you-check-before-joining-a-new-program/25/6" target="_blank" rel="noopener">Spot a scam before it spots you, on Earners Corner</a>.</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<p class="foot">Training simulation by InstantAdPay. UnicornYield Pro, its balance, token, team, countdown and every "withdrawal" popup are made up, and nothing on the dashboard can be deposited, earned or withdrawn.</p>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<button type="button" class="proof" id="proof" data-flag="proof" aria-live="polite"><span class="av" id="pAv">J</span><span class="t" id="pT"></span><span class="f">Tap to check this one</span></button>
|
||||||
|
|
||||||
|
<div class="veil" id="veil" hidden><div class="card" role="dialog" aria-modal="true" aria-labelledby="cardH">
|
||||||
|
<div class="k" id="cardK">Red flag 1 of 8</div>
|
||||||
|
<h2 id="cardH"></h2>
|
||||||
|
<p id="cardP"></p>
|
||||||
|
<div class="tell" id="cardTell"></div>
|
||||||
|
<div class="do" id="cardDo"></div>
|
||||||
|
<div class="row"><button type="button" class="btn go" id="cardNext">Keep hunting</button><button type="button" class="btn sec" id="cardEnd">Show my scam radar</button></div>
|
||||||
|
</div></div>
|
||||||
|
|
||||||
|
<script src="/assets/chasing-unicorns.js?v=20261112d"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
@@ -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>
|
<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>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||||
<script src="/assets/contract.js?v=20260908p"></script>
|
<script src="/assets/contract.js?v=20260908p"></script>
|
||||||
<script src="/assets/chat.js?v=20261016n"></script>
|
<script src="/assets/chat.js?v=20261016n"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
<style>
|
<style>
|
||||||
.rg{max-width:900px}
|
.rg{max-width:900px}
|
||||||
.rg .hero{padding:44px 0 10px}
|
.rg .hero{padding:44px 0 10px}
|
||||||
@@ -119,6 +119,7 @@
|
|||||||
<li class="f-win"><span class="k">5</span><b>Counted on your campaign</b>The goal shows on the ad that sent them, with its cost per goal in credits.</li>
|
<li class="f-win"><span class="k">5</span><b>Counted on your campaign</b>The goal shows on the ad that sent them, with its cost per goal in credits.</li>
|
||||||
</ol>
|
</ol>
|
||||||
<p class="rg-note">The id is random. It identifies the click, not the person. Nothing personal is read from your page or sent anywhere.</p>
|
<p class="rg-note">The id is random. It identifies the click, not the person. Nothing personal is read from your page or sent anywhere.</p>
|
||||||
|
<p class="rg-note"><b>Sending people to InstantAdPay or LinkSpin?</b> Those two count by themselves, with no goal and no pixel. The landing tag adds the click id to your links to either site, also when the address sits inside a redirect link of your own. A LinkSpin spin link or Banner Spin pointed straight at either site carries it too. Their sign-up, wallet link and each package they buy within 30 days of the click then show on your Conversion tracking card and in LinkSpin under Reports, Conversions, purchases with their USD price. This is reporting only. It never changes who a sponsor is or what anyone is paid.</p>
|
||||||
|
|
||||||
<p class="rg-eye">Set it up</p>
|
<p class="rg-eye">Set it up</p>
|
||||||
<h2>Four steps, one time</h2>
|
<h2>Four steps, one time</h2>
|
||||||
@@ -252,7 +253,8 @@
|
|||||||
<div><dt>Will the tags slow down or break my page?</dt><dd>No. Both load in the background, never stop your page from showing, and do nothing visible. If LinkSpin cannot be reached, your page works exactly as before.</dd></div>
|
<div><dt>Will the tags slow down or break my page?</dt><dd>No. Both load in the background, never stop your page from showing, and do nothing visible. If LinkSpin cannot be reached, your page works exactly as before.</dd></div>
|
||||||
<div><dt>Do I need a separate goal for each ad?</dt><dd>No. One goal covers all your ads. Each conversion is counted against whichever ad sent that visitor.</dd></div>
|
<div><dt>Do I need a separate goal for each ad?</dt><dd>No. One goal covers all your ads. Each conversion is counted against whichever ad sent that visitor.</dd></div>
|
||||||
<div><dt>Do my ads get the click id automatically?</dt><dd>Yes. Every click through your InstantAdPay ads carries one. Your page address keeps all its own parameters; the click id is added to the end.</dd></div>
|
<div><dt>Do my ads get the click id automatically?</dt><dd>Yes. Every click through your InstantAdPay ads carries one. Your page address keeps all its own parameters; the click id is added to the end.</dd></div>
|
||||||
<div><dt>Is any personal data sent?</dt><dd>No. The click id is random. No name or email from your page is read or sent.</dd></div>
|
<div><dt>Is any personal data sent?</dt><dd>No. The click id is random. No name or email from your page is read or sent. When someone joins here on your click, the two sites match the event to your click server to server, and your reports show counts and values, never who the person is.</dd></div>
|
||||||
|
<div><dt>Why does a sign-up I sent not show?</dt><dd>The click has to reach the join page. Check that your landing tag is on the page and the link is a real link (a button that only runs a script cannot carry it), and that the visitor opened it from your click within the last 30 days. A sign-up and a wallet count once per click, each package counts on its own, and your own account is left out. People who joined before this was switched on on 2026-11-07 cannot be matched afterwards.</dd></div>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<div class="rg-rule"><b>What a credit is.</b> One credit is one cent of ad delivery across the network. Credits are not money and cannot be withdrawn. Cost per goal is shown in credits for that reason.</div>
|
<div class="rg-rule"><b>What a credit is.</b> One credit is one cent of ad delivery across the network. Credits are not money and cannot be withdrawn. Cost per goal is shown in credits for that reason.</div>
|
||||||
@@ -263,7 +265,8 @@
|
|||||||
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
|
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/common.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script>
|
||||||
<script src="/assets/conversion-guide.js?v=20261024ct"></script>
|
<script src="/assets/conversion-guide.js?v=20261024ct"></script>
|
||||||
|
<script src="/assets/netline.js?v=20261114ns" data-site="iap"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="nav"></div>
|
<div id="nav"></div>
|
||||||
@@ -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>
|
<p class="muted small">You decide whether, and how much, to spend. Never spend more than you can afford to lose.</p>
|
||||||
</div>
|
</div>
|
||||||
</div></section>
|
</div></section>
|
||||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||||
<script src="/assets/legal.js?v=20260908a"></script>
|
<script src="/assets/legal.js?v=20260908a"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+3
-2
@@ -9,7 +9,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
<style>
|
<style>
|
||||||
.eg{max-width:820px}
|
.eg{max-width:820px}
|
||||||
.eg h2{font-size:23px;margin:40px 0 10px;padding-top:18px;border-top:1px solid var(--line)}
|
.eg h2{font-size:23px;margin:40px 0 10px;padding-top:18px;border-top:1px solid var(--line)}
|
||||||
@@ -97,6 +97,7 @@
|
|||||||
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
|
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||||
|
<script src="/assets/netline.js?v=20261114ns" data-site="iap"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+2
-2
@@ -8,7 +8,7 @@
|
|||||||
<link rel="alternate" type="text/plain" href="/llms.txt" title="Plain-text summary for AI systems">
|
<link rel="alternate" type="text/plain" href="/llms.txt" title="Plain-text summary for AI systems">
|
||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
<style>
|
<style>
|
||||||
.facts h3 { margin-top: 18px; }
|
.facts h3 { margin-top: 18px; }
|
||||||
.facts table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0 4px; }
|
.facts table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0 4px; }
|
||||||
@@ -127,7 +127,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div></section>
|
</div></section>
|
||||||
<script src="/assets/common.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script>
|
||||||
<script src="/assets/legal.js?v=20260908a"></script>
|
<script src="/assets/legal.js?v=20260908a"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+3
-2
@@ -14,7 +14,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
<style>
|
<style>
|
||||||
.fr{max-width:860px}
|
.fr{max-width:860px}
|
||||||
.fr .hero{padding:44px 0 10px}
|
.fr .hero{padding:44px 0 10px}
|
||||||
@@ -72,6 +72,7 @@
|
|||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/friday.js?v=20260925a"></script>
|
<script src="/assets/friday.js?v=20260925a"></script>
|
||||||
<script src="/assets/common.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script>
|
||||||
|
<script src="/assets/netline.js?v=20261114ns" data-site="iap"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+3
-2
@@ -15,7 +15,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
<style>
|
<style>
|
||||||
.gp{max-width:1040px}
|
.gp{max-width:1040px}
|
||||||
.gp .hero{padding:56px 0 10px}
|
.gp .hero{padding:56px 0 10px}
|
||||||
@@ -79,6 +79,7 @@
|
|||||||
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
|
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/games-page.js?v=20261012b"></script>
|
<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/games-page.js?v=20261012b"></script>
|
||||||
|
<script src="/assets/netline.js?v=20261114ns" data-site="iap"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+2
-2
@@ -22,7 +22,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
@@ -506,7 +506,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||||
<script src="/assets/wallet.js?v=20260909c"></script>
|
<script src="/assets/wallet.js?v=20260909c"></script>
|
||||||
<script src="/assets/home.js?v=20261027tb"></script>
|
<script src="/assets/home.js?v=20261027tb"></script>
|
||||||
<script src="/assets/chat.js?v=20261016n"></script>
|
<script src="/assets/chat.js?v=20261016n"></script>
|
||||||
|
|||||||
+3
-3
@@ -7,7 +7,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
<style>
|
<style>
|
||||||
.jn-nav{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;padding:16px 0}
|
.jn-nav{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;padding:16px 0}
|
||||||
.jn-nav>a{white-space:nowrap;flex:0 0 auto;padding-top:8px}
|
.jn-nav>a{white-space:nowrap;flex:0 0 auto;padding-top:8px}
|
||||||
@@ -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>
|
InstantAdPay · <a href="/contract">Contract</a> · <a href="/terms">Terms</a> · <a href="/privacy">Privacy</a> · <a href="/disclaimer">Disclaimer</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||||
<script src="/assets/join.js?v=20261016p"></script>
|
<script src="/assets/join.js?v=20261107nc"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+2
-2
@@ -9,7 +9,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
<style>
|
<style>
|
||||||
.lw-rule{border-left:4px solid var(--gold-2);background:var(--gold-soft);padding:16px 20px;border-radius:0 12px 12px 0;margin:0 0 24px}
|
.lw-rule{border-left:4px solid var(--gold-2);background:var(--gold-soft);padding:16px 20px;border-radius:0 12px 12px 0;margin:0 0 24px}
|
||||||
.lw-rule b{font-family:var(--disp);font-size:17px;display:block;margin-bottom:6px}
|
.lw-rule b{font-family:var(--disp);font-size:17px;display:block;margin-bottom:6px}
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
|
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||||
<script src="/assets/launch.js?v=20260915b"></script>
|
<script src="/assets/launch.js?v=20260915b"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+2
-2
@@ -18,7 +18,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
@@ -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>
|
<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>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||||
<script src="/assets/ledger.js?v=20260906m"></script>
|
<script src="/assets/ledger.js?v=20260906m"></script>
|
||||||
<script src="https://polhunter.com/embed.js" data-slots="1" async></script>
|
<script src="https://polhunter.com/embed.js" data-slots="1" async></script>
|
||||||
<script src="/assets/chat.js?v=20261016n"></script>
|
<script src="/assets/chat.js?v=20261016n"></script>
|
||||||
|
|||||||
+57
-8
@@ -6,7 +6,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
</head>
|
</head>
|
||||||
<body class="bo-body">
|
<body class="bo-body">
|
||||||
|
|
||||||
@@ -148,6 +148,8 @@
|
|||||||
<button data-pane="training" type="button"><svg viewBox="0 0 24 24"><path d="M3 5l9-2 9 2v11l-9 2-9-2z"/><path d="M12 3v13"/><path d="M9 11l3 2 3-2"/></svg>Training</button>
|
<button data-pane="training" type="button"><svg viewBox="0 0 24 24"><path d="M3 5l9-2 9 2v11l-9 2-9-2z"/><path d="M12 3v13"/><path d="M9 11l3 2 3-2"/></svg>Training</button>
|
||||||
<button data-pane="help" type="button"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="8.5"/><path d="M9.6 9.4a2.5 2.5 0 0 1 4.8.9c0 1.7-2.4 2.1-2.4 3.7"/><path d="M12 17v.5"/></svg>Help<span class="pill" id="helpBadge" hidden></span></button>
|
<button data-pane="help" type="button"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="8.5"/><path d="M9.6 9.4a2.5 2.5 0 0 1 4.8.9c0 1.7-2.4 2.1-2.4 3.7"/><path d="M12 17v.5"/></svg>Help<span class="pill" id="helpBadge" hidden></span></button>
|
||||||
<button data-pane="games" id="gamesNav" type="button" hidden><svg viewBox="0 0 24 24"><rect x="2.5" y="7" width="19" height="11" rx="5.5"/><path d="M7 11v3M5.5 12.5h3"/><circle cx="15.5" cy="11.5" r="1.1"/><circle cx="18" cy="13.5" r="1.1"/></svg>Games</button>
|
<button data-pane="games" id="gamesNav" type="button" hidden><svg viewBox="0 0 24 24"><rect x="2.5" y="7" width="19" height="11" rx="5.5"/><path d="M7 11v3M5.5 12.5h3"/><circle cx="15.5" cy="11.5" r="1.1"/><circle cx="18" cy="13.5" r="1.1"/></svg>Games</button>
|
||||||
|
<!-- Earners Corner (2026-11-10): the network forum; /session/sso signs a member in with this account in one tap -->
|
||||||
|
<a href="https://earnerscorner.com/session/sso" target="_blank" rel="noopener" id="forumNav"><svg viewBox="0 0 24 24"><path d="M4 5.5h16v10H9l-5 4z"/><path d="M8 9.5h8M8 12.5h5"/></svg>Earners Corner</a>
|
||||||
<button data-pane="wallet" type="button"><svg viewBox="0 0 24 24"><rect x="3" y="6" width="18" height="13" rx="2"/><path d="M3 10h18"/><circle cx="16.5" cy="14.5" r="1.4"/></svg>Wallet</button>
|
<button data-pane="wallet" type="button"><svg viewBox="0 0 24 24"><rect x="3" y="6" width="18" height="13" rx="2"/><path d="M3 10h18"/><circle cx="16.5" cy="14.5" r="1.4"/></svg>Wallet</button>
|
||||||
<button data-pane="profile" type="button"><svg viewBox="0 0 24 24"><circle cx="12" cy="8.5" r="3.6"/><path d="M4.5 20c1.6-3.6 4.2-5.2 7.5-5.2s5.9 1.6 7.5 5.2"/></svg>Profile</button>
|
<button data-pane="profile" type="button"><svg viewBox="0 0 24 24"><circle cx="12" cy="8.5" r="3.6"/><path d="M4.5 20c1.6-3.6 4.2-5.2 7.5-5.2s5.9 1.6 7.5 5.2"/></svg>Profile</button>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -184,6 +186,17 @@
|
|||||||
back, and it was sitting below two promotions, one of which announces the site they
|
back, and it was sitting below two promotions, one of which announces the site they
|
||||||
just came from. Hidden for everyone else, so nobody else's page changes. -->
|
just came from. Hidden for everyone else, so nobody else's page changes. -->
|
||||||
<div class="card" id="phReturn" hidden></div>
|
<div class="card" id="phReturn" hidden></div>
|
||||||
|
<div class="card" id="inviteCard" hidden>
|
||||||
|
<div class="card-head"><h3>Who invited you?</h3></div>
|
||||||
|
<p class="muted small" style="margin:0 0 8px">You joined without a sponsor. If someone told you about InstantAdPay, type their username and they become your sponsor. Do it before you switch on payouts or buy: your sponsor locks on the contract at that point.</p>
|
||||||
|
<div style="display:flex;flex-wrap:wrap;gap:8px;align-items:center">
|
||||||
|
<input id="inviteWho" autocomplete="off" autocapitalize="none" spellcheck="false" aria-label="Their username" placeholder="their username" style="flex:1 1 180px;max-width:280px">
|
||||||
|
<button class="btn small" type="button" id="inviteGo">Set my sponsor</button>
|
||||||
|
<button class="btn sec small" type="button" id="inviteNo">Nobody invited me</button>
|
||||||
|
</div>
|
||||||
|
<p class="small" id="inviteMsg" style="margin:8px 0 0"></p>
|
||||||
|
</div>
|
||||||
|
<p class="small muted" id="inviteSmall" hidden style="margin:0 0 10px">Remembered who invited you? <a href="#" id="inviteBack">Tell us</a></p>
|
||||||
<div class="card" id="phLaunch" hidden></div>
|
<div class="card" id="phLaunch" hidden></div>
|
||||||
<div class="card" id="fdfCard" hidden></div>
|
<div class="card" id="fdfCard" hidden></div>
|
||||||
<div class="card" id="wwCard" hidden></div>
|
<div class="card" id="wwCard" hidden></div>
|
||||||
@@ -336,7 +349,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card" id="tankCard" data-jump="Holding tank">
|
<div class="card" id="tankCard" data-jump="Holding tank">
|
||||||
<div class="card-head"><h3>Holding tank</h3><span class="sub" id="tankSub">members who arrived with no sponsor</span></div>
|
<div class="card-head"><h3>Holding tank</h3><span class="sub" id="tankSub">members who arrived with no sponsor</span></div>
|
||||||
<p class="muted small">People who joined without a sponsor wait here. Adopt one and you become their sponsor: a chat opens, they get an email with your message, and their first purchase binds to you on the contract. First come. At most <b id="tankCap">2</b> open adoptions at a time, and an adoption goes back to the tank after <b id="tankTtl">7</b> days if they have not linked a wallet or bought.</p>
|
<p class="muted small">People who joined without a sponsor wait here. New sign-ups open for adoption 24 hours after they join, so they have time to tell us who invited them. Adopt one and you become their sponsor: a chat opens, they get an email with your message, and their first purchase binds to you on the contract. First come. At most <b id="tankCap">2</b> open adoptions at a time, and an adoption goes back to the tank after <b id="tankTtl">7</b> days if they have not linked a wallet or bought.</p>
|
||||||
<div class="small" style="border:1px solid var(--line-strong);border-radius:10px;padding:10px 12px;margin:8px 0 0"><b>How pay it forward works here.</b> It is not what other platforms mean by it. Elsewhere, the site takes money from your account balance and buys the position for the other person. InstantAdPay has no balances and never holds funds, so a PIF here is a gift between two wallets:<br>1. You tap <b>PIF</b> next to a member who has linked a wallet.<br>2. Your own wallet app opens with their address filled in, and you send POL from your wallet straight to theirs, in good faith.<br>3. The site records the transaction and tells them, with the Polygonscan proof. They then buy their package themselves, from their own wallet, and that purchase binds to you as their sponsor on the contract.<br>Nothing obliges them to buy. InstantAdPay cannot reverse, refund or recover the POL, because it never passes through us. Talk to the person first, and only send what you are willing to give.</div>
|
<div class="small" style="border:1px solid var(--line-strong);border-radius:10px;padding:10px 12px;margin:8px 0 0"><b>How pay it forward works here.</b> It is not what other platforms mean by it. Elsewhere, the site takes money from your account balance and buys the position for the other person. InstantAdPay has no balances and never holds funds, so a PIF here is a gift between two wallets:<br>1. You tap <b>PIF</b> next to a member who has linked a wallet.<br>2. Your own wallet app opens with their address filled in, and you send POL from your wallet straight to theirs, in good faith.<br>3. The site records the transaction and tells them, with the Polygonscan proof. They then buy their package themselves, from their own wallet, and that purchase binds to you as their sponsor on the contract.<br>Nothing obliges them to buy. InstantAdPay cannot reverse, refund or recover the POL, because it never passes through us. Talk to the person first, and only send what you are willing to give.</div>
|
||||||
<p class="small" id="tankWhy" hidden></p>
|
<p class="small" id="tankWhy" hidden></p>
|
||||||
<div id="tankMine"></div>
|
<div id="tankMine"></div>
|
||||||
@@ -627,13 +640,14 @@
|
|||||||
<div class="card" id="convCard" hidden>
|
<div class="card" id="convCard" hidden>
|
||||||
<h3>Conversion tracking</h3>
|
<h3>Conversion tracking</h3>
|
||||||
<p class="small" style="margin:0 0 6px"><a href="/conversion-tracking" target="_blank" rel="noopener">How to set it up: the step-by-step guide with copy-paste examples</a></p>
|
<p class="small" style="margin:0 0 6px"><a href="/conversion-tracking" target="_blank" rel="noopener">How to set it up: the step-by-step guide with copy-paste examples</a></p>
|
||||||
<p class="muted small">See which of your ads bring subscribers and sales, not just clicks. Every click on your ad carries a click id. Put two small tags on your own site and each goal is counted against the ad that sent the visitor, with a cost per goal in credits on each campaign above. The counting is done by LinkSpin, our sister site, under this same email.</p>
|
<p class="muted small">See which of your ads bring subscribers and sales, not just clicks. Every click on your ad carries a click id. Put two small tags on your own site and each goal is counted against the ad that sent the visitor, with a cost per goal in credits on each campaign above. The counting is done by LinkSpin, our sister site, under this same email. People you send to InstantAdPay or LinkSpin count without any goal: with the landing tag on your page, or a spin link pointed straight at the join page, their sign-up, wallet link and package purchases within 30 days of the click show below, with values. This is reporting only: it never changes who a sponsor is or what anyone is paid. The full list is in LinkSpin under Reports, Conversions.</p>
|
||||||
<ol class="small" style="margin:6px 0 10px 18px;padding:0">
|
<ol class="small" style="margin:6px 0 10px 18px;padding:0">
|
||||||
<li>Add a goal below, for example <b>subscriber</b> or <b>sale</b>.</li>
|
<li>Add a goal below, for example <b>subscriber</b> or <b>sale</b>.</li>
|
||||||
<li>Put the <b>landing tag</b> on the page your ad sends people to (once per page, just before </body>).</li>
|
<li>Put the <b>landing tag</b> on the page your ad sends people to (once per page, just before </body>).</li>
|
||||||
<li>Put the <b>goal pixel</b> on your thank-you page, the page people see after they sign up or buy.</li>
|
<li>Put the <b>goal pixel</b> on your thank-you page, the page people see after they sign up or buy.</li>
|
||||||
</ol>
|
</ol>
|
||||||
<p class="small" id="convStatus"></p>
|
<p class="small" id="convStatus"></p>
|
||||||
|
<p class="small" id="convNet" hidden></p>
|
||||||
<div id="convGoals"></div>
|
<div id="convGoals"></div>
|
||||||
<div id="convAddRow" class="grid c3" style="margin-top:10px">
|
<div id="convAddRow" class="grid c3" style="margin-top:10px">
|
||||||
<p><input id="convName" maxlength="32" placeholder="Goal name, like subscriber or sale" style="width:100%"></p>
|
<p><input id="convName" maxlength="32" placeholder="Goal name, like subscriber or sale" style="width:100%"></p>
|
||||||
@@ -821,6 +835,10 @@
|
|||||||
<div><span class="eyebrow" style="margin:0 0 4px">Share the presentation</span><div class="small muted" style="margin:0 0 4px">The narrated Build Wide presentation, captions in six languages. Your name rides on the link, and the page shows you as the person who shared it.</div><div class="mono small" id="promoPresLink" style="overflow-wrap:anywhere">…</div></div>
|
<div><span class="eyebrow" style="margin:0 0 4px">Share the presentation</span><div class="small muted" style="margin:0 0 4px">The narrated Build Wide presentation, captions in six languages. Your name rides on the link, and the page shows you as the person who shared it.</div><div class="mono small" id="promoPresLink" style="overflow-wrap:anywhere">…</div></div>
|
||||||
<span><button class="btn small" id="promoPresCopy" type="button">Copy link</button> <a class="btn small sec" id="promoPresOpen" href="/presentation" target="_blank" rel="noopener">Open</a></span>
|
<span><button class="btn small" id="promoPresCopy" type="button">Copy link</button> <a class="btn small sec" id="promoPresOpen" href="/presentation" target="_blank" rel="noopener">Open</a></span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="card promo-strip" id="promoUniStrip" hidden>
|
||||||
|
<div><span class="eyebrow" style="margin:0 0 4px">Chasing Unicorns: the scam-spotting game</span><div class="small muted" style="margin:0 0 4px">A fake earnings dashboard that looks like the real thing. Every button is a red flag, the visitor scores their "scam radar", then sees how InstantAdPay works instead. Made for people still waiting on a payout somewhere else. Your link carries your name, so a join counts for you.</div><div class="mono small" id="promoUniLink" style="overflow-wrap:anywhere">…</div></div>
|
||||||
|
<span><button class="btn small" id="promoUniCopy" type="button">Copy link</button> <a class="btn small sec" id="promoUniOpen" href="/chasing-unicorns" target="_blank" rel="noopener">Open</a></span>
|
||||||
|
</div>
|
||||||
<div class="card promo-strip" id="promoWallStrip" hidden>
|
<div class="card promo-strip" id="promoWallStrip" hidden>
|
||||||
<div><span class="eyebrow" style="margin:0 0 4px">Your banner wall</span><div class="mono small" id="promoWallLink" style="overflow-wrap:anywhere">…</div></div>
|
<div><span class="eyebrow" style="margin:0 0 4px">Your banner wall</span><div class="mono small" id="promoWallLink" style="overflow-wrap:anywhere">…</div></div>
|
||||||
<span><button class="btn small sec" id="promoWallCopy" type="button">Copy wall link</button> <a class="btn small sec" id="promoWallOpen" href="#" target="_blank" rel="noopener">Open</a></span>
|
<span><button class="btn small sec" id="promoWallCopy" type="button">Copy wall link</button> <a class="btn small sec" id="promoWallOpen" href="#" target="_blank" rel="noopener">Open</a></span>
|
||||||
@@ -835,9 +853,26 @@
|
|||||||
<button class="chip-t" data-promo="objections" type="button" role="tab">Objections</button>
|
<button class="chip-t" data-promo="objections" type="button" role="tab">Objections</button>
|
||||||
<button class="chip-t" data-promo="videos" type="button" role="tab">Videos</button>
|
<button class="chip-t" data-promo="videos" type="button" role="tab">Videos</button>
|
||||||
<button class="chip-t" data-promo="viral" type="button" role="tab">Viral links</button>
|
<button class="chip-t" data-promo="viral" type="button" role="tab">Viral links</button>
|
||||||
|
<button class="chip-t" data-promo="stackpol" type="button" role="tab">📈 Stack POL</button>
|
||||||
<button class="chip-t" data-promo="games" type="button" role="tab">🎮 Games</button>
|
<button class="chip-t" data-promo="games" type="button" role="tab">🎮 Games</button>
|
||||||
|
<button class="chip-t" data-promo="network" type="button" role="tab">🌐 Network sites</button>
|
||||||
<button class="chip-t" data-promo="bixpay" type="button" role="tab" hidden>💳 BixPay</button>
|
<button class="chip-t" data-promo="bixpay" type="button" role="tab" hidden>💳 BixPay</button>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Stack POL page switch (2026-11-09): stackpol.com/<username> shows every POL payout to the member's wallets across the network -->
|
||||||
|
<div class="card promo-sec" id="promo-stackpol" hidden>
|
||||||
|
<div class="card-head"><h3>📈 Your Stack POL page</h3><span class="sub">every POL payout you have received across the network, on one page</span></div>
|
||||||
|
<p class="muted small" style="margin:0 0 12px">Stack POL adds up what InstantAdPay, LinkSpin and the network games have paid to your wallet, with a Polygonscan link for every payment. Your public page at stackpol.com/your-username is on by default once payouts reach your wallet: your total, where it came from, and your own referral link on every program. It updates every 5 minutes. Switch it off any time and the page goes away.</p>
|
||||||
|
<label style="display:flex;gap:10px;align-items:center;font-weight:700;cursor:pointer"><input type="checkbox" id="spOn"> Show my Stack POL page</label>
|
||||||
|
<div class="promo-strip" id="spLinkRow" style="padding:12px 0 0" hidden><div><span class="eyebrow" style="margin:0 0 4px">Your page</span><div class="mono small" id="spUrl" style="overflow-wrap:anywhere"></div></div><div style="display:flex;gap:8px;flex-wrap:wrap"><button class="btn small sec" type="button" id="spCopy">Copy link</button><a class="btn small" id="spOpen" href="#" target="_blank" rel="noopener">Open</a></div></div>
|
||||||
|
<p class="muted small" id="spNote" style="margin:10px 0 0"></p>
|
||||||
|
<div style="margin-top:16px;padding-top:14px;border-top:1px solid var(--line)">
|
||||||
|
<h4 style="margin:0 0 6px">⭐ Stack POL Pro</h4>
|
||||||
|
<p class="muted small" style="margin:0 0 10px">Pro puts your own LinkSpin Banner Spins and spin links in the ad spots of your Stack POL page, adds a QR code that opens it, and makes every blog article opened from your page use your referral links. One time, yours for good: any ad package of $10 or more unlocks it automatically. You keep every credit of that package for your ads, and your sponsor line is paid on chain as usual.</p>
|
||||||
|
<div id="spProOff"><a class="btn small" href="/my?from=stackpro#buy">Buy a $10+ package to unlock Pro</a></div>
|
||||||
|
<div id="spProOn" hidden style="display:flex;flex-wrap:wrap;gap:10px 14px;align-items:center;padding:12px 14px;border:1px solid var(--mint);border-radius:12px"><span class="pill" style="background:var(--mint);color:#062016;font-weight:800;padding:4px 10px;border-radius:999px">⭐ You own Stack POL Pro</span><span class="small" style="flex:1 1 260px;min-width:0"><span id="spProSince"></span>Yours for good. Your LinkSpin Banner Spins and spin links show on your page within 5 minutes of any change.</span><a class="btn small" id="spProOpen" href="#" target="_blank" rel="noopener">Open my Pro page</a></div>
|
||||||
|
</div>
|
||||||
|
<p class="muted small" style="margin:10px 0 0">Your page shows your own results only. Nothing on it is a promise of what anyone else will earn.</p>
|
||||||
|
</div>
|
||||||
<!-- BixPay partner kit (2026-10-29): the member's resolved partner link, posts, an email swipe and four text-only banners; promo.js fillBix -->
|
<!-- BixPay partner kit (2026-10-29): the member's resolved partner link, posts, an email swipe and four text-only banners; promo.js fillBix -->
|
||||||
<div class="card promo-sec" id="promo-bixpay" hidden>
|
<div class="card promo-sec" id="promo-bixpay" hidden>
|
||||||
<div class="card-head"><h3>💳 BixPay: a Visa card for your POL</h3><span class="sub" id="bixPromoSub">every link and banner here carries your partner link</span></div>
|
<div class="card-head"><h3>💳 BixPay: a Visa card for your POL</h3><span class="sub" id="bixPromoSub">every link and banner here carries your partner link</span></div>
|
||||||
@@ -852,6 +887,14 @@
|
|||||||
<div id="bixPromoBanners"></div>
|
<div id="bixPromoBanners"></div>
|
||||||
<p class="small muted" style="margin:12px 0 0">BixPay is a separate company. BIX issues the wallet and the card through its banking partners and sets its own fees, limits, eligibility and terms. InstantAdPay is not the card issuer and earns a referral commission when you sign up through a partner link. Card availability varies by country. Crypto assets can lose value.</p>
|
<p class="small muted" style="margin:12px 0 0">BixPay is a separate company. BIX issues the wallet and the card through its banking partners and sets its own fees, limits, eligibility and terms. InstantAdPay is not the card issuer and earns a referral commission when you sign up through a partner link. Card availability varies by country. Crypto assets can lose value.</p>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Network sites (2026-11-14): Downline Banners + Viral Banner Blitz kits, read live from each site's /api/promo-kit feed; netkits.js -->
|
||||||
|
<div class="card promo-sec" id="promo-network" hidden>
|
||||||
|
<div class="card-head"><h3>🌐 Network sites</h3><span class="sub">your username is your link on every network site</span></div>
|
||||||
|
<p class="muted small" style="margin:0 0 10px">Your InstantAdPay username works as your sponsor link on the other network sites too, even if you have never visited them. Every link, creative and line below carries it. Each site keeps its own kit, so what you see here is always the current one.</p>
|
||||||
|
<style>.nk-grid{display:flex;flex-wrap:wrap;gap:16px;align-items:flex-start;margin-top:10px}.nk-fig{margin:0;display:flex;flex-direction:column;gap:6px;max-width:100%}.nk-fig img{display:block;max-width:100%;height:auto;border-radius:6px}.nk-set{margin:10px 0}</style>
|
||||||
|
<div class="chips" id="nkPick" style="margin:0 0 12px"></div>
|
||||||
|
<div id="nkBody"></div>
|
||||||
|
</div>
|
||||||
<div class="card promo-sec" id="promo-games" hidden>
|
<div class="card promo-sec" id="promo-games" hidden>
|
||||||
<div class="card-head"><h3>🎮 Our games</h3><span class="sub">free to play, every link carries your username</span></div>
|
<div class="card-head"><h3>🎮 Our games</h3><span class="sub">free to play, every link carries your username</span></div>
|
||||||
<p class="muted small" style="margin:0 0 10px">Every game here is free to play and brings players into InstantAdPay. Your username is built into each link, post and banner, so anyone who joins through them lands on your line. Pick a game.</p>
|
<p class="muted small" style="margin:0 0 10px">Every game here is free to play and brings players into InstantAdPay. Your username is built into each link, post and banner, so anyone who joins through them lands on your line. Pick a game.</p>
|
||||||
@@ -1235,7 +1278,11 @@
|
|||||||
<a href="/ledger">Live ledger</a>
|
<a href="/ledger">Live ledger</a>
|
||||||
<a href="/contract">The contract</a>
|
<a href="/contract">The contract</a>
|
||||||
<a href="#help">Support</a>
|
<a href="#help">Support</a>
|
||||||
|
<a href="/terms">Terms</a>
|
||||||
|
<a href="/disclaimer">Earnings Disclaimer</a>
|
||||||
|
<a href="/privacy">Privacy</a>
|
||||||
<a href="https://cryptoteambuild.com" target="_blank" rel="noopener">Crypto Team Build Network</a>
|
<a href="https://cryptoteambuild.com" target="_blank" rel="noopener">Crypto Team Build Network</a>
|
||||||
|
<span style="width:100%;text-align:center;color:var(--muted)">TrustClickz · 615 Green Valley Drive, Moody, AL 35004</span>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1259,13 +1306,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||||
<script src="/assets/wallet.js?v=20260911a"></script>
|
<script src="/assets/wallet.js?v=20260911a"></script>
|
||||||
<script src="/assets/promo.js?v=20261102td"></script>
|
<script src="/assets/promo.js?v=20261103gp"></script>
|
||||||
<script src="/assets/support.js?v=20261101th"></script>
|
<script src="/assets/support.js?v=20261101th"></script>
|
||||||
<script src="/assets/my.js?v=20261102tt"></script>
|
<script src="/assets/netkits.js?v=20261114ns"></script>
|
||||||
<script src="/assets/fuel.js?v=20261025ff"></script>
|
<script src="/assets/my.js?v=20261114kes"></script>
|
||||||
<script src="/assets/engine-room.js?v=20261101th"></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>
|
||||||
<script src="/assets/chat.js?v=20261016n"></script>
|
<script src="/assets/chat.js?v=20261016n"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
<style>
|
<style>
|
||||||
.pk{max-width:820px}
|
.pk{max-width:820px}
|
||||||
.pk h2{font-size:24px;margin:44px 0 12px;padding-top:20px;border-top:1px solid var(--line)}
|
.pk h2{font-size:24px;margin:44px 0 12px;padding-top:20px;border-top:1px solid var(--line)}
|
||||||
@@ -131,7 +131,8 @@
|
|||||||
<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>
|
<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>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||||
<script src="/assets/partners.js?v=20260914a"></script>
|
<script src="/assets/partners.js?v=20260914a"></script>
|
||||||
|
<script src="/assets/netline.js?v=20261114ns" data-site="iap"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+2
-2
@@ -9,7 +9,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
<style>
|
<style>
|
||||||
.pl-rule{border-left:4px solid var(--gold-2);background:var(--gold-soft);padding:16px 20px;border-radius:0 12px 12px 0;margin:0 0 28px}
|
.pl-rule{border-left:4px solid var(--gold-2);background:var(--gold-soft);padding:16px 20px;border-radius:0 12px 12px 0;margin:0 0 28px}
|
||||||
.pl-rule b{font-family:var(--disp);font-size:17px;display:block;margin-bottom:6px}
|
.pl-rule b{font-family:var(--disp);font-size:17px;display:block;margin-bottom:6px}
|
||||||
@@ -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>
|
<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>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||||
<script src="/assets/plays.js?v=20260910b"></script>
|
<script src="/assets/plays.js?v=20260910b"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
<style>
|
<style>
|
||||||
.pr{max-width:1040px}
|
.pr{max-width:1040px}
|
||||||
.pr .hero{padding:44px 0 6px;text-align:center}
|
.pr .hero{padding:44px 0 6px;text-align:center}
|
||||||
@@ -87,6 +87,6 @@
|
|||||||
<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>
|
<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>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/presentation.js?v=20261015b"></script>
|
<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/presentation.js?v=20261015b"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+3
-3
@@ -6,7 +6,7 @@
|
|||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="nav"></div>
|
<div id="nav"></div>
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
<p class="muted small">We use a session cookie to keep you signed in, a referral cookie to credit the sponsor whose link you arrived through, and a browser identifier cookie used only to enforce one account per person. No third-party ad-tracking cookies.</p>
|
<p class="muted small">We use a session cookie to keep you signed in, a referral cookie to credit the sponsor whose link you arrived through, and a browser identifier cookie used only to enforce one account per person. No third-party ad-tracking cookies.</p>
|
||||||
<p class="muted small"><strong>Abuse prevention.</strong> When you create an account and when you sign in we record your IP address, browser type and the browser identifier. We use them to detect duplicate accounts and self-referral, which the Terms prohibit, and for nothing else. They are visible to the site administrator only and are not sold or shared.</p>
|
<p class="muted small"><strong>Abuse prevention.</strong> When you create an account and when you sign in we record your IP address, browser type and the browser identifier. We use them to detect duplicate accounts and self-referral, which the Terms prohibit, and for nothing else. They are visible to the site administrator only and are not sold or shared.</p>
|
||||||
<h3>Conversion tracking on ad links</h3>
|
<h3>Conversion tracking on ad links</h3>
|
||||||
<p class="muted small">When you click an ad here, the link to the advertiser's site gets a random click id added to its address (it looks like <code>lsclk=i3f9a0c1b2d4e</code>). The id says nothing about you. We record which ad it belongs to, the time, your country, phone or computer, and the page the click came from, and pass that to LinkSpin, our sister site, which counts the advertiser's results. If the advertiser has added the LinkSpin landing tag to their own site, that tag keeps the click id on their site (in the browser's local storage and a first-party cookie of their site). If you later sign up or buy there, their goal pixel on the thank-you page tells LinkSpin that one goal happened for that click. Nothing personal is sent: no name, no email, no wallet. Your IP address is never stored; it is only used in hashed form, together with your browser type, for a match within 24 hours of the click when the click id is missing.</p>
|
<p class="muted small">When you click an ad here, the link to the advertiser's site gets a random click id added to its address (it looks like <code>lsclk=i3f9a0c1b2d4e</code>). The id says nothing about you. We record which ad it belongs to, the time, your country, phone or computer, and the page the click came from, and pass that to LinkSpin, our sister site, which counts the advertiser's results. If the advertiser has added the LinkSpin landing tag to their own site, that tag keeps the click id on their site (in the browser's local storage and a first-party cookie of their site). If you later sign up or buy there, their goal pixel on the thank-you page tells LinkSpin that one goal happened for that click. Nothing personal is sent: no name, no email, no wallet. Your IP address is never stored; it is only used in hashed form, together with your browser type, for a match within 24 hours of the click when the click id is missing. If you arrive here from a LinkSpin click (the address carries lsclk or lsid), we keep that click id in a cookie for 30 days and with your account when you join, and tell LinkSpin about your sign-up, wallet link and package purchases on that click. The owner of the click sees counts and values in their reports, never who you are.</p>
|
||||||
<h3>Sharing</h3>
|
<h3>Sharing</h3>
|
||||||
<p class="muted small">Your username, public profile, and public wall are visible to others by design, and on-chain transactions are public by nature. We share data with infrastructure providers (hosting, email delivery) only as needed to operate the service, and when required by law.</p>
|
<p class="muted small">Your username, public profile, and public wall are visible to others by design, and on-chain transactions are public by nature. We share data with infrastructure providers (hosting, email delivery) only as needed to operate the service, and when required by law.</p>
|
||||||
<h3>Your choices</h3>
|
<h3>Your choices</h3>
|
||||||
@@ -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>
|
<p class="muted small">We use reasonable safeguards, but no system is perfectly secure. Protect your email and your wallet.</p>
|
||||||
</div>
|
</div>
|
||||||
</div></section>
|
</div></section>
|
||||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||||
<script src="/assets/legal.js?v=20260908a"></script>
|
<script src="/assets/legal.js?v=20260908a"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
<style>
|
<style>
|
||||||
.rg{max-width:900px}
|
.rg{max-width:900px}
|
||||||
.rg .hero{padding:44px 0 10px}
|
.rg .hero{padding:44px 0 10px}
|
||||||
@@ -261,6 +261,6 @@
|
|||||||
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
|
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/common.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
<meta name="robots" content="noindex,nofollow">
|
<meta name="robots" content="noindex,nofollow">
|
||||||
<title>Refuel · InstantAdPay verified visit</title>
|
<title>Refuel · InstantAdPay verified visit</title>
|
||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
<style>
|
<style>
|
||||||
html,body{height:100%}
|
html,body{height:100%}
|
||||||
body{margin:0;display:flex;flex-direction:column;background:#0b1020;color:#e6edf3}
|
body{margin:0;display:flex;flex-direction:column;background:#0b1020;color:#e6edf3}
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
<style>
|
<style>
|
||||||
html,body{height:100%;margin:0;overflow:hidden;background:#000}
|
html,body{height:100%;margin:0;overflow:hidden;background:#000}
|
||||||
/* the Shorts stage is a black video player in both themes, so its text keeps the dark ink set whatever data-theme says (2026-11-01) */
|
/* the Shorts stage is a black video player in both themes, so its text keeps the dark ink set whatever data-theme says (2026-11-01) */
|
||||||
|
|||||||
+2
-2
@@ -8,7 +8,7 @@
|
|||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<section><div class="wrap" style="max-width:720px">
|
<section><div class="wrap" style="max-width:720px">
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<div id="supMain"><div class="card"><p class="muted small">Loading…</p></div></div>
|
<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>
|
<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>
|
</div></section>
|
||||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||||
<script src="/assets/legal.js?v=20260908a"></script>
|
<script src="/assets/legal.js?v=20260908a"></script>
|
||||||
<script src="/assets/support.js?v=20261101th"></script>
|
<script src="/assets/support.js?v=20261101th"></script>
|
||||||
<script src="/assets/chat.js?v=20261016n"></script>
|
<script src="/assets/chat.js?v=20261016n"></script>
|
||||||
|
|||||||
+2
-2
@@ -6,7 +6,7 @@
|
|||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="nav"></div>
|
<div id="nav"></div>
|
||||||
@@ -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>
|
<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>
|
||||||
</div></section>
|
</div></section>
|
||||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||||
<script src="/assets/legal.js?v=20260908a"></script>
|
<script src="/assets/legal.js?v=20260908a"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+2
-2
@@ -6,7 +6,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="nav"></div>
|
<div id="nav"></div>
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
<p><a href="/ledger">← Back to the live ledger</a> · <a href="/contract">Read the contract review</a></p>
|
<p><a href="/ledger">← Back to the live ledger</a> · <a href="/contract">Read the contract review</a></p>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||||
<script src="/assets/tx.js?v=20260906m"></script>
|
<script src="/assets/tx.js?v=20260906m"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
<title>Viewing ad — InstantAdPay</title>
|
<title>Viewing ad — InstantAdPay</title>
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
<style>
|
<style>
|
||||||
html,body{height:100%;margin:0;overflow:hidden}
|
html,body{height:100%;margin:0;overflow:hidden}
|
||||||
.vw{display:flex;flex-direction:column;height:100vh;height:100dvh;background:var(--ground);color:var(--ink,#e8fff7)}
|
.vw{display:flex;flex-direction:column;height:100vh;height:100dvh;background:var(--ground);color:var(--ink,#e8fff7)}
|
||||||
|
|||||||
+2
-2
@@ -7,7 +7,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="nav"></div>
|
<div id="nav"></div>
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||||
<script src="/assets/wall.js?v=20261030pp"></script>
|
<script src="/assets/wall.js?v=20261030pp"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+2
-2
@@ -9,7 +9,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
<style>
|
<style>
|
||||||
.wl-rule{border-left:4px solid var(--gold-2);background:var(--gold-soft);padding:16px 20px;border-radius:0 12px 12px 0;margin:0 0 28px}
|
.wl-rule{border-left:4px solid var(--gold-2);background:var(--gold-soft);padding:16px 20px;border-radius:0 12px 12px 0;margin:0 0 28px}
|
||||||
.wl-rule b{font-family:var(--disp);font-size:17px;display:block;margin-bottom:6px}
|
.wl-rule b{font-family:var(--disp);font-size:17px;display:block;margin-bottom:6px}
|
||||||
@@ -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>
|
<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>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||||
<script src="/assets/wallets.js?v=20260911b"></script>
|
<script src="/assets/wallets.js?v=20260911b"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
<!--theme-head--><script>(function(){var A=0,h=document.documentElement,b=h.getAttribute("data-theme-base")||"dark",m=window.matchMedia?matchMedia("(prefers-color-scheme: dark)"):{matches:false},v;function g(){try{v=localStorage.getItem("iap.theme")}catch(e){v=null}return v==="light"||v==="dark"||v==="auto"?v:(A?"auto":b)}function ap(){var c=g();h.setAttribute("data-theme",c==="auto"?(m.matches?"dark":"light"):c);h.setAttribute("data-theme-choice",c)}ap();if(m.addEventListener)m.addEventListener("change",ap);else if(m.addListener)m.addListener(ap);window.IAPTheme={base:b,get:g,apply:ap,set:function(c,quiet){try{if(c==="light"||c==="dark"||c==="auto")localStorage.setItem("iap.theme",c);else localStorage.removeItem("iap.theme")}catch(e){}ap();if(!quiet)try{dispatchEvent(new CustomEvent("iap-theme",{detail:g()}))}catch(e){}}}})()</script><!--/theme-head-->
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">
|
||||||
<link rel="icon" type="image/png" href="/logo-icon.png">
|
<link rel="icon" type="image/png" href="/logo-icon.png">
|
||||||
<link rel="stylesheet" href="/assets/site.css?v=20261101th">
|
<link rel="stylesheet" href="/assets/site.css?v=20261112ln">
|
||||||
<style>
|
<style>
|
||||||
.fr{max-width:860px}
|
.fr{max-width:860px}
|
||||||
.fr .hero{padding:44px 0 10px}
|
.fr .hero{padding:44px 0 10px}
|
||||||
@@ -65,6 +65,7 @@
|
|||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
<script src="/assets/wednesday.js?v=20260929c"></script>
|
<script src="/assets/wednesday.js?v=20260929c"></script>
|
||||||
<script src="/assets/common.js?v=20261101th"></script>
|
<script src="/assets/common.js?v=20261114ns"></script>
|
||||||
|
<script src="/assets/netline.js?v=20261114ns" data-site="iap"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
// Chasing Unicorns promo page (Marty, 2026-11-12). Boots a throwaway server, opens /chasing-unicorns?ref=<a real member> and checks:
|
||||||
|
// the viral ?ref= sets the sponsor cookie, every red-flag button opens its card and lights the radar, the ending unlocks after 3,
|
||||||
|
// the join button keeps the sponsor, no page errors, no sideways scroll on a phone. Writes the 1200x630 share image too:
|
||||||
|
// public/assets/chasing-unicorns-og.png (pass --og to refresh it). node qa/chasing-unicorns.mjs [--og]
|
||||||
|
import { spawn } from 'node:child_process';
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import os from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
const PW = process.env.PW || 'D:/Projects/MarketingAgent/qa-tester/node_modules/playwright/index.js';
|
||||||
|
const { chromium } = (await import('file:///' + PW.replace(/^\/+/, ''))).default;
|
||||||
|
const PORT = 8796, B = 'http://127.0.0.1:' + PORT;
|
||||||
|
const DATA = path.join(os.tmpdir(), 'iap-unicorns-' + Date.now()); fs.mkdirSync(DATA, { recursive: true });
|
||||||
|
const ok = [], bad = []; const t = (n, c, x) => (c ? ok : bad).push(n + (c || !x ? '' : ' -> ' + x));
|
||||||
|
const srv = spawn(process.execPath, ['server.js'], { env: { ...process.env, PORT: String(PORT), DATA_DIR: DATA, ADMIN_PASSWORD: 'localtest', NODE_ENV: 'test', DATABASE_URL: '' }, stdio: 'ignore' });
|
||||||
|
const bye = c => { try { srv.kill(); } catch (e) {} setTimeout(() => { try { fs.rmSync(DATA, { recursive: true, force: true }); } catch (e) {} process.exit(c); }, 500); };
|
||||||
|
for (let i = 0; i < 60; i++) { try { if ((await fetch(B + '/api/stats')).ok) break; } catch (e) {} await new Promise(r => setTimeout(r, 500)); }
|
||||||
|
// a real member to share the page
|
||||||
|
const DEV = 'c0ffee00c0ffee00c0ffee00c0ffee00';
|
||||||
|
const jf = async (p, body, cookie) => { const r = await fetch(B + p, { method: body ? 'POST' : 'GET', redirect: 'manual', headers: { 'Content-Type': 'application/json', Cookie: cookie || '', 'X-Forwarded-For': '203.0.113.9' }, body: body ? JSON.stringify(body) : undefined }); let b = {}; try { b = await r.json(); } catch (e) {} return { r, b }; };
|
||||||
|
const st = await jf('/api/auth/email/start', { email: 'sharer@example.com', fts: Date.now() - 20000 }, 'iap.dev=' + DEV);
|
||||||
|
const vf = await jf('/api/auth/email/verify', { email: 'sharer@example.com', code: st.b.devCode || st.b.code }, 'iap.dev=' + DEV);
|
||||||
|
const jar = ['iap.dev=' + DEV, ...(vf.r.headers.getSetCookie ? vf.r.headers.getSetCookie() : []).map(c => String(c).split(';')[0])].join('; ');
|
||||||
|
await jf('/api/my/profile', { username: 'unisharer' }, jar);
|
||||||
|
const pg = await fetch(B + '/chasing-unicorns?ref=unisharer', { redirect: 'manual' });
|
||||||
|
const sc = (pg.headers.getSetCookie ? pg.headers.getSetCookie() : []).join(' | ');
|
||||||
|
t('page serves 200', pg.status === 200, pg.status);
|
||||||
|
t('?ref= sets the sponsor cookie', /iap\.sponsor=unisharer/.test(sc), sc.slice(0, 160));
|
||||||
|
|
||||||
|
const br = await chromium.launch(); const errs = [];
|
||||||
|
const page = await br.newPage({ viewport: { width: 1280, height: 900 } }); page.on('pageerror', e => errs.push(e.message)); page.on('console', m => { if (m.type() === 'error') errs.push(m.text()); });
|
||||||
|
await page.goto(B + '/chasing-unicorns?ref=unisharer', { waitUntil: 'domcontentloaded' }); await page.waitForTimeout(1500);
|
||||||
|
if (process.argv.includes('--og')) {
|
||||||
|
const og = await br.newPage({ viewport: { width: 1200, height: 630 }, deviceScaleFactor: 1 });
|
||||||
|
await og.goto(B + '/chasing-unicorns', { waitUntil: 'domcontentloaded' }); await og.waitForTimeout(3500);
|
||||||
|
await og.evaluate(() => { const i = document.querySelector('.intro p'); if (i) i.hidden = true; });
|
||||||
|
await og.screenshot({ path: 'public/assets/chasing-unicorns-og.png' }); await og.close(); ok.push('share image written');
|
||||||
|
}
|
||||||
|
const join0 = await page.$eval('#joinBtn', a => a.getAttribute('href')); t('join button keeps the sponsor', join0 === '/join/unisharer?src=chasing-unicorns', join0);
|
||||||
|
t('ending is locked at first', await page.$eval('#after', e => e.hidden));
|
||||||
|
const flags = ['daily', 'withdraw', 'vip', 'team', 'clock', 'coin', 'keys'];
|
||||||
|
for (const f of flags) {
|
||||||
|
await page.click('.console [data-flag="' + f + '"] >> nth=0'); await page.waitForTimeout(150);
|
||||||
|
const h = await page.$eval('#cardH', e => e.textContent); const open = await page.$eval('#veil', e => !e.hidden);
|
||||||
|
t('flag ' + f + ' opens its card', open && h.length > 8, h);
|
||||||
|
await page.click('#cardNext'); await page.waitForTimeout(100);
|
||||||
|
}
|
||||||
|
t('radar counts 7', (await page.$eval('#score', e => e.textContent)) === '7 of 8');
|
||||||
|
t('ending unlocks after 3', !(await page.$eval('#after', e => e.hidden)));
|
||||||
|
await page.waitForSelector('#proof.on', { timeout: 12000 }).catch(() => {});
|
||||||
|
await page.click('#proof', { timeout: 5000 }).catch(() => {}); await page.waitForTimeout(150);
|
||||||
|
const last = await page.$eval('#cardH', e => e.textContent).catch(() => ''); t('the popup is the 8th flag', /Dave from Denver|withdrew/.test(last), last);
|
||||||
|
await page.click('#cardNext').catch(() => {}); await page.waitForTimeout(400);
|
||||||
|
t('8 of 8 result', /8 of 8/.test(await page.$eval('#endH', e => e.textContent)));
|
||||||
|
await page.screenshot({ path: 'qa/out/unicorns-end.png', fullPage: true });
|
||||||
|
const ph = await br.newPage({ viewport: { width: 390, height: 844 } }); ph.on('pageerror', e => errs.push(e.message));
|
||||||
|
await ph.goto(B + '/chasing-unicorns', { waitUntil: 'domcontentloaded' }); await ph.waitForTimeout(1200);
|
||||||
|
const over = await ph.evaluate(() => document.documentElement.scrollWidth - document.documentElement.clientWidth); t('phone: no sideways scroll', over <= 1, over);
|
||||||
|
await ph.screenshot({ path: 'qa/out/unicorns-phone.png' });
|
||||||
|
t('no page errors', !errs.filter(e => !/favicon/.test(e)).length, errs.join(' | ').slice(0, 300));
|
||||||
|
await br.close();
|
||||||
|
console.log(ok.map(x => ' ok ' + x).join('\n')); if (bad.length) console.log(bad.map(x => ' FAIL ' + x).join('\n'));
|
||||||
|
bye(bad.length ? 1 : 0);
|
||||||
@@ -74,7 +74,7 @@ t('it never sells PIF as a tactic', !/you should (definitely |really )?pif/i.tes
|
|||||||
// pattern edit must keep this table green.
|
// pattern edit must keep this table green.
|
||||||
const WANT = {
|
const WANT = {
|
||||||
PIF: /PIF is a gift/,
|
PIF: /PIF is a gift/,
|
||||||
PRICE: /Five packages, priced/,
|
PRICE: /packages, priced in dollars/, // the count changed (five, then seven); match the answer, not the number
|
||||||
EARN: /Every package splits the same way/,
|
EARN: /Every package splits the same way/,
|
||||||
TANK: /The holding tank is where free members/,
|
TANK: /The holding tank is where free members/,
|
||||||
GAMEPOL: /Game POL is paid to the wallet linked/
|
GAMEPOL: /Game POL is paid to the wallet linked/
|
||||||
|
|||||||
@@ -0,0 +1,287 @@
|
|||||||
|
// 5xYourTeam "The Draft" partner routes (draftpartner.js + the tank.adopt partner path, 2026-11-15).
|
||||||
|
// node qa/draft-partner.test.mjs (also part of `bash qa/run.sh member`; `bash qa/run.sh draft` alone)
|
||||||
|
// Part A, no server: the REAL tank.js + draftpartner.js with in-memory accounts, a fake chain, a fake hub and a MOCKED CLOCK.
|
||||||
|
// signature, the pool rules (locked / sponsored / spam / throwaway / adopted twice / grace shown with opensAt / no contact data),
|
||||||
|
// adopt (the 5x claim replaces the $20 rule only here, wallet + contract line, 10 open, fresh lock check, hub off, rid repeat,
|
||||||
|
// the normal adoption email is the only mail), the auto-assign conflict rule (a drafted person is out of the tank; tank.sweep
|
||||||
|
// leaves a pick's adoption alone), release (48 h hold, back with the original join time, two adoptions = kept, started = done,
|
||||||
|
// locked = kept, hub silent = wait), the hourly sweep (wallet alone is not started), reconcile, status, the log.
|
||||||
|
// Part B, LOCAL copy (throwaway DATA_DIR, JSON store, DRAFT_ALLOW_NO_HUB=1): the HTTP routes answer signed calls only.
|
||||||
|
// Never production. Exit code 1 on any failure.
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import os from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
import crypto from 'node:crypto';
|
||||||
|
import { spawn } from 'node:child_process';
|
||||||
|
import { createRequire } from 'node:module';
|
||||||
|
|
||||||
|
const SITE = path.resolve(path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1')), '..');
|
||||||
|
const require = createRequire(path.join(SITE, 'package.json'));
|
||||||
|
delete process.env.DATABASE_URL; // JSON stores only
|
||||||
|
const SECRET = 'draft-test-secret-' + 'x'.repeat(40);
|
||||||
|
let fails = 0, passes = 0; const ok = (cond, label, extra) => { console.log((cond ? 'PASS ' : 'FAIL ') + label + (cond || extra === undefined ? '' : ' ' + (typeof extra === 'string' ? extra : JSON.stringify(extra)))); if (!cond) fails++; else passes++; };
|
||||||
|
const H = 3600000, D = 86400000;
|
||||||
|
const addr = () => '0x' + crypto.randomBytes(20).toString('hex');
|
||||||
|
|
||||||
|
function fakeAccounts() {
|
||||||
|
const by = new Map(); let nextId = 100;
|
||||||
|
const pub = a => a ? Object.assign({}, a) : null;
|
||||||
|
const find = f => { for (const a of by.values()) if (f(a)) return pub(a); return null; };
|
||||||
|
return {
|
||||||
|
_by: by,
|
||||||
|
add(email, o) { const a = Object.assign({ email, username: email.split('@')[0].replace(/[^a-z0-9_]/g, ''), code: 'c' + (nextId++), sponsorRef: '', memberId: 0, address: null, created: Date.now() - 30 * D, lastSeen: Date.now() - H, joinedVia: null }, o || {}); by.set(email, a); return pub(a); },
|
||||||
|
async byEmail(e) { return pub(by.get(String(e || '').toLowerCase())); },
|
||||||
|
async byUsername(u) { const x = String(u || '').toLowerCase(); return find(a => a.username === x); },
|
||||||
|
async byCode(c) { const x = String(c || '').toLowerCase(); return find(a => a.code === x); },
|
||||||
|
async byMemberId(id) { return find(a => Number(a.memberId) === Number(id) && id > 0); },
|
||||||
|
async byAddress(w) { const x = String(w || '').toLowerCase(); return find(a => a.address && a.address.toLowerCase() === x); },
|
||||||
|
async positionOwner() { return null; },
|
||||||
|
async setSponsorRef(e, ref) { const a = by.get(e); if (!a) return { error: 'No such account.' }; a.sponsorRef = String(ref || '').toLowerCase(); return { ok: true }; },
|
||||||
|
async listAll() { return [...by.values()].map(pub); },
|
||||||
|
isUnclaimedShell: () => false,
|
||||||
|
async sponsorOf(e) { const a = by.get(e); if (!a || !a.sponsorRef) return null; return (await this.byUsername(a.sponsorRef)) || (await this.byCode(a.sponsorRef)); }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function bench(o) {
|
||||||
|
o = o || {};
|
||||||
|
for (const m of ['tank.js', 'draftpartner.js']) delete require.cache[require.resolve(path.join(SITE, m))];
|
||||||
|
const tank = require(path.join(SITE, 'tank.js'));
|
||||||
|
const dp = require(path.join(SITE, 'draftpartner.js'));
|
||||||
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'iap-draft-'));
|
||||||
|
const accounts = fakeAccounts(); const events = []; const chats = []; const mails = []; const notices = []; const assigned = []; const deliberate = [];
|
||||||
|
const hub = { locked: new Set(), sponsored: new Set(), down: false, on: true, ids: new Map() };
|
||||||
|
const flagged = new Set(); const spamList = [];
|
||||||
|
const env = { now: Date.now() };
|
||||||
|
const follow = { setDeliberate: async (email, token, by, note) => { deliberate.push({ email, token, by, note }); return accounts.setSponsorRef(email, token); } };
|
||||||
|
const why = e => hub.down ? 'unknown' : hub.locked.has(e) ? 'locked' : hub.sponsored.has(e) ? 'sponsored' : null;
|
||||||
|
tank.init({ dataDir: dir, accounts, chain: { recentEvents: () => events.slice().reverse(), getConfig: () => ({}) }, follow,
|
||||||
|
messages: { sendChat: async (id, from, to, text) => { chats.push({ from, to, text }); }, lastFrom: async () => 0 },
|
||||||
|
mailer: { hasKey: () => true, send: async (to, subject, body) => { mails.push({ to, subject, body }); } }, site: 'https://iap.test',
|
||||||
|
hooks: { network: () => null, isSuspended: () => false, excluded: e => flagged.has(e), payoutBlocked: async () => false, companyId: () => 1,
|
||||||
|
networkHeld: async accts => new Map(accts.map(a => [a.email, why(a.email)]).filter(x => x[1])),
|
||||||
|
networkLocked: async e => { const w = why(e); return w === 'locked' || w === 'unknown' ? w : null; },
|
||||||
|
isDraftPick: id => dp.isDraftPick(id),
|
||||||
|
assigned: r => { assigned.push(r); }, adminAlert: () => {}, claim: () => true, activated: () => false, notify: async (to, subject, text) => { notices.push({ to, subject, text }); } } });
|
||||||
|
tank.setClock(() => env.now);
|
||||||
|
process.env.DRAFT_PARTNER_SECRET = SECRET;
|
||||||
|
const ready = dp.init({ dataDir: dir, accounts, chain: { recentEvents: () => events.slice().reverse() }, tank, ads: { earnedTotals: async em => Object.fromEntries(em.map(e => [e, { earned: e.startsWith('surf') ? 420 : 0, balance: 0 }])) },
|
||||||
|
requireHub: true, clock: () => env.now,
|
||||||
|
hooks: { hubInfo: e => hub.ids.has(e) ? { id: hub.ids.get(e), door: 'linkspin' } : null, networkOn: () => hub.on, excluded: e => flagged.has(e), spamEmails: () => spamList,
|
||||||
|
suggestDomain: d => require(path.join(SITE, 'emailcheck.js')).suggestDomain(d) } });
|
||||||
|
let block = 1000;
|
||||||
|
// a coach: a wallet linked here and payouts on (member id), but NO $20 purchase (their vesting is the 5x position)
|
||||||
|
const coach = (email, memberId, extra) => accounts.add(email, Object.assign({ memberId, address: addr() }, extra || {}));
|
||||||
|
const buy = (memberId, cents) => events.push({ type: 'Purchase', buyerId: memberId, priceCents: cents || 2000, block: block++ });
|
||||||
|
return { tank, dp, ready, accounts, events, chats, mails, notices, assigned, deliberate, hub, flagged, spamList, env, coach, buy, dir };
|
||||||
|
}
|
||||||
|
const claimOf = (a, positions) => ({ wallet: a.address, username: a.username, positions: positions === undefined ? 1 : positions });
|
||||||
|
let ridN = 0; const rid = () => 'rid-test-' + (++ridN) + '-' + crypto.randomBytes(3).toString('hex');
|
||||||
|
|
||||||
|
async function partA() {
|
||||||
|
console.log('-- Part A: draftpartner.js + tank.js, mocked clock, fake hub');
|
||||||
|
// ---- signature ----
|
||||||
|
{
|
||||||
|
const B = bench(); await B.ready;
|
||||||
|
const raw = JSON.stringify({}); const ts = String(Date.now());
|
||||||
|
const good = B.dp.verify({ 'x-draft-ts': ts, 'x-draft-sig': B.dp.sign(ts, raw) }, raw);
|
||||||
|
ok(good.body && typeof good.body === 'object', 'signature: a good signature passes');
|
||||||
|
ok(B.dp.verify({ 'x-draft-ts': ts, 'x-draft-sig': B.dp.sign(ts, raw, 'other-secret-' + 'y'.repeat(30)) }, raw).status === 401, 'signature: another secret is refused');
|
||||||
|
ok(B.dp.verify({ 'x-draft-ts': ts, 'x-draft-sig': B.dp.sign(ts, raw) }, raw + ' ').status === 401, 'signature: a changed body is refused');
|
||||||
|
const old = String(Date.now() - 6 * 60000);
|
||||||
|
ok(B.dp.verify({ 'x-draft-ts': old, 'x-draft-sig': B.dp.sign(old, raw) }, raw).status === 401, 'signature: older than 5 minutes is refused');
|
||||||
|
const keep = process.env.DRAFT_PARTNER_SECRET; process.env.DRAFT_PARTNER_SECRET = 'short';
|
||||||
|
ok(B.dp.verify({ 'x-draft-ts': ts, 'x-draft-sig': 'x' }, raw).status === 503, 'signature: no (or a short) secret = 503, nothing answers');
|
||||||
|
process.env.DRAFT_PARTNER_SECRET = keep;
|
||||||
|
}
|
||||||
|
// ---- the pool ----
|
||||||
|
const B = bench(); await B.ready; const { tank, dp, accounts, env, hub } = B;
|
||||||
|
accounts.add('live@x.co', { address: addr(), lastSeen: env.now - 2 * H });
|
||||||
|
accounts.add('plain@x.co');
|
||||||
|
accounts.add('surfer@x.co');
|
||||||
|
accounts.add('locked@x.co'); hub.locked.add('locked@x.co');
|
||||||
|
accounts.add('sponsoredhub@x.co'); hub.sponsored.add('sponsoredhub@x.co');
|
||||||
|
accounts.add('flagged@x.co'); B.flagged.add('flagged@x.co');
|
||||||
|
accounts.add('farm@x.co'); B.spamList.push('farm@x.co');
|
||||||
|
accounts.add('temp@mailinator.com');
|
||||||
|
accounts.add('typo@gmial.com');
|
||||||
|
accounts.add('fresh@x.co', { created: env.now - 2 * H });
|
||||||
|
accounts.add('kid@x.co', { sponsorRef: 'someone' });
|
||||||
|
accounts.add('twice@x.co');
|
||||||
|
hub.ids.set('live@x.co', 'h_0123456789abcdef');
|
||||||
|
const C1 = B.coach('coach1@x.co', 41); const C2 = B.coach('coach2@x.co', 42);
|
||||||
|
// twice@ has had two adoptions already (an old IAP one and a dropped one)
|
||||||
|
B.buy(43); B.coach('iapadopter@x.co', 43);
|
||||||
|
await tank.adopt('iapadopter@x.co', 'twice@x.co'); await accounts.setSponsorRef('twice@x.co', ''); // back in the tank by hand: 1 counted
|
||||||
|
await tank.adopt('iapadopter@x.co', 'twice@x.co'); await accounts.setSponsorRef('twice@x.co', ''); // 2 counted
|
||||||
|
for (const ad of await tank.openOf('twice@x.co')) await tank.closeAdoption(ad.id, 'dropped');
|
||||||
|
B.mails.length = 0; B.chats.length = 0;
|
||||||
|
const P = await dp.pool();
|
||||||
|
const names = P.pool.map(c => c.username).sort();
|
||||||
|
ok(P.ok && names.join(',') === ['fresh', 'live', 'plain', 'surfer'].join(','), 'pool: only people who pass every rule', names.join(','));
|
||||||
|
ok(P.excluded.spam === 2 && P.excluded.throwaway === 2 && P.excluded.adoptedTwice === 1, 'pool: spam/flagged, throwaway + mistyped domains and adopted-twice counted out', P.excluded);
|
||||||
|
ok(!names.includes('locked') && !names.includes('sponsoredhub') && !names.includes('kid'), 'pool: nobody locked on a contract, sponsored on the hub or sponsored here');
|
||||||
|
const live = P.pool.find(c => c.username === 'live'); const fresh = P.pool.find(c => c.username === 'fresh'); const plain = P.pool.find(c => c.username === 'plain');
|
||||||
|
ok(live.id === 'h_0123456789abcdef' && live.door === 'LinkSpin' && live.wallet === true && live.joinedAt > 0, 'card: hub id + door from the hub cache, wallet linked yes/no, joined', live);
|
||||||
|
ok(/^i_[0-9a-f]{16}$/.test(plain.id) && plain.door === 'InstantAdPay', 'card: someone the hub does not know gets an opaque i_ id');
|
||||||
|
ok(fresh.opensAt > env.now, 'card: a sign-up inside the 24-hour grace is shown with opensAt');
|
||||||
|
ok(live.games === null && live.surfWei === null && typeof live.surfCredits === 'number', 'card: games null (not tracked here), surfing as credits, never invented');
|
||||||
|
const keys = new Set(P.pool.flatMap(c => Object.keys(c)));
|
||||||
|
ok(!JSON.stringify(P).includes('@') && !keys.has('email') && !keys.has('address'), 'pool: no contact data (no email, no wallet address) in the answer');
|
||||||
|
ok(P.rules.returnHours === 72 && P.rules.holdHours === 48 && P.rules.maxOpen === 10 && P.rules.maxAdoptions === 2 && P.rules.graceHours === 24, 'pool: the rules travel with it', P.rules);
|
||||||
|
|
||||||
|
// ---- adopt ----
|
||||||
|
const a0 = await dp.adopt({ rid: rid(), coach: claimOf(C1, 0), person: plain.id, kind: 'draft' });
|
||||||
|
ok(a0.code === 'not_vested', 'adopt: no 5x position = refused (free members cannot adopt)', a0);
|
||||||
|
const a1 = await dp.adopt({ rid: rid(), coach: { wallet: addr(), positions: 1 }, person: plain.id });
|
||||||
|
ok(a1.code === 'coach_unknown', 'adopt: a wallet with no account here is refused', a1);
|
||||||
|
const nw = accounts.add('nowallet@x.co', { memberId: 0 });
|
||||||
|
accounts._by.get('nowallet@x.co').address = null;
|
||||||
|
const nwc = B.coach('freecoach@x.co', 0);
|
||||||
|
const a2 = await dp.adopt({ rid: rid(), coach: claimOf(nwc), person: plain.id });
|
||||||
|
ok(a2.code === 'no_contract_line', 'adopt: a coach with nobody on this contract in their line is refused (a pick would land under the company)', a2);
|
||||||
|
void nw;
|
||||||
|
hub.on = false;
|
||||||
|
const a3 = await dp.adopt({ rid: rid(), coach: claimOf(C1), person: plain.id });
|
||||||
|
ok(a3.code === 'hub_off', 'adopt: hub off = nobody can be drafted', a3);
|
||||||
|
ok((await dp.pool()).pool.length === 0, 'pool: hub off = empty pool');
|
||||||
|
hub.on = true;
|
||||||
|
ok(!(await tank.eligibility('coach1@x.co')).ok, "the coach is NOT eligible for InstantAdPay's own tank button (keeps its $20 rule)");
|
||||||
|
const r1 = rid();
|
||||||
|
const g = await dp.adopt({ rid: rid(), coach: claimOf(C1), person: fresh.id });
|
||||||
|
ok(g.code === 'grace', 'adopt: a sign-up inside the 24-hour grace is refused', g);
|
||||||
|
const ok1 = await dp.adopt({ rid: r1, coach: claimOf(C1), person: live.id, kind: 'draft', week: '2026-11-16', slot: '1.1' });
|
||||||
|
ok(ok1.ok && /^iap:\d+$/.test(ok1.ref) && ok1.person === live.id && ok1.expires === env.now + 3 * D && ok1.holdUntil === env.now + 48 * H, 'adopt: a 5x coach with payouts on and no $20 buy adopts; 3-day window, 48 h hold', ok1);
|
||||||
|
const la = await accounts.byEmail('live@x.co');
|
||||||
|
ok(la.sponsorRef === 'coach1', 'adopt: the sponsor is now the coach (InstantAdPay record)', la.sponsorRef);
|
||||||
|
ok(B.deliberate.some(d => d.email === 'live@x.co' && d.by === 'adopt'), "adopt: the move went through the deliberate path (sponsorfollow + the hub's sponsor-change, by 'adopt')");
|
||||||
|
const open = await tank.openOf('live@x.co');
|
||||||
|
ok(open.length === 1 && open[0].expires - open[0].ts === 3 * D && /5xYourTeam draft pick/.test(open[0].note), "adopt: the tank adoption's own window is 3 days, noted as a draft pick", open[0]);
|
||||||
|
ok(B.mails.length === 1 && B.mails[0].to === 'live@x.co' && /is now your sponsor on InstantAdPay/.test(B.mails[0].subject), 'mail: exactly one, the normal "X is now your sponsor" adoption email', B.mails.map(m => m.subject));
|
||||||
|
ok(B.chats.some(c => c.to === 'live@x.co' && /your coach from 5xYourTeam/.test(c.text)), 'adopt: a site chat from the coach (site messages only)');
|
||||||
|
ok(!tank.payView().some(x => x.email === 'live@x.co'), 'adopt: no switch-on-payouts reminder mails are queued for a pick');
|
||||||
|
ok(B.assigned.length === 0, 'adopt: no payments-topic pickup post');
|
||||||
|
const rep = await dp.adopt({ rid: r1, coach: claimOf(C1), person: live.id });
|
||||||
|
ok(rep.ok && rep.repeat && rep.ref === ok1.ref && B.mails.length === 1, 'adopt: the same rid again answers the first result and sends nothing');
|
||||||
|
const tw = await dp.adopt({ rid: rid(), coach: claimOf(C2), person: live.id });
|
||||||
|
ok(tw.code === 'gone', 'adopt: someone already picked is no longer in the pool', tw);
|
||||||
|
// fresh lock check at adopt (the pool cache is 30 s old at most; the adopt asks the hub again)
|
||||||
|
accounts.add('late@x.co'); const lp = (await dp.pool()).pool; dp._poolReset();
|
||||||
|
const late = (await dp.pool()).pool.find(c => c.username === 'late');
|
||||||
|
hub.locked.add('late@x.co'); const al = await dp.adopt({ rid: rid(), coach: claimOf(C2), person: late.id });
|
||||||
|
ok(al.code === 'gone' || al.code === 'locked', 'adopt: locked a moment ago = refused', al); hub.locked.delete('late@x.co'); void lp;
|
||||||
|
hub.down = true; dp._poolReset();
|
||||||
|
const ad = await dp.adopt({ rid: rid(), coach: claimOf(C2), person: late.id });
|
||||||
|
ok(ad.error && (ad.code === 'gone' || ad.code === 'hub_unknown'), 'adopt: a hub that does not answer refuses (the conservative side)', ad);
|
||||||
|
hub.down = false; dp._poolReset();
|
||||||
|
// 10 open picks at most
|
||||||
|
for (let i = 0; i < 10; i++) accounts.add('fill' + i + '@x.co');
|
||||||
|
const pl = (await dp.pool()).pool; let made = 0;
|
||||||
|
for (const c of pl.filter(c => /^fill/.test(c.username))) { const r = await dp.adopt({ rid: rid(), coach: claimOf(C2), person: c.id }); if (r.ok) made++; }
|
||||||
|
const over = await dp.adopt({ rid: rid(), coach: claimOf(C2), person: plain.id });
|
||||||
|
ok(made === 10 && over.code === 'full', 'adopt: 10 open picks a coach, the 11th is refused', { made, over });
|
||||||
|
|
||||||
|
// ---- auto-assign vs the pick window ----
|
||||||
|
env.now += 30 * H; // past any 24-hour activation hold
|
||||||
|
const tick = await tank.readyTick();
|
||||||
|
ok(!tick.assigned.some(x => x.adoptee === 'live@x.co') && (await accounts.byEmail('live@x.co')).sponsorRef === 'coach1', 'conflict rule: a drafted person (wallet linked) is out of the tank, never auto-assigned while the pick runs');
|
||||||
|
ok(!(await tank.waiting()).some(w => w.email === 'live@x.co'), 'conflict rule: not on the waiting list while picked');
|
||||||
|
|
||||||
|
// ---- release ----
|
||||||
|
const early = await dp.release({ rid: rid(), coach: claimOf(C1), ref: ok1.ref, why: 'coach' });
|
||||||
|
ok(early.code === 'hold', 'release: not inside the 48-hour hold', early);
|
||||||
|
const notMine = await dp.release({ rid: rid(), coach: claimOf(C2), ref: ok1.ref, why: 'coach' });
|
||||||
|
ok(notMine.code === 'not_yours', 'release: another coach cannot release it', notMine);
|
||||||
|
const tooEarly = await dp.release({ rid: rid(), coach: claimOf(C1), ref: ok1.ref, why: 'return' });
|
||||||
|
ok(tooEarly.code === 'too_early', 'return: not before the 3 days', tooEarly);
|
||||||
|
env.now += 20 * H; // 50 h after the pick
|
||||||
|
const rel = await dp.release({ rid: rid(), coach: claimOf(C1), ref: ok1.ref, why: 'coach' });
|
||||||
|
const back = await accounts.byEmail('live@x.co');
|
||||||
|
ok(rel.ok && rel.outcome === 'returned' && back.sponsorRef === '', 'release: after 48 h the pick goes back to the tank', rel);
|
||||||
|
ok(B.deliberate.some(d => d.email === 'live@x.co' && d.by === 'release' && /released by the coach/.test(d.note)), "release: the move went through the deliberate path (by 'release')");
|
||||||
|
dp._poolReset();
|
||||||
|
const again = (await dp.pool()).pool.find(c => c.id === live.id);
|
||||||
|
ok(again && again.joinedAt === live.joinedAt && !again.opensAt, 'release: back in the pool with the ORIGINAL join time, no new sign-up grace', again);
|
||||||
|
ok(again.adoptionsTotal === 1 && again.adoptions === 0, 'release: the dropped pick still counts toward their two (total 1; 0 outside 5xYourTeam, which counts its own picks)', again);
|
||||||
|
const relAgain = await dp.release({ rid: rid(), coach: claimOf(C1), ref: ok1.ref, why: 'coach' });
|
||||||
|
ok(relAgain.ok && relAgain.already && relAgain.outcome === 'returned', 'release: a repeat answers "already" and changes nothing');
|
||||||
|
ok(B.mails.length === 11, 'mail: still only the adoption emails (1 + 10), nothing on release', B.mails.length);
|
||||||
|
// second adoption: C3 picks them again; at 3 days unstarted they stay with C3 (adopted twice)
|
||||||
|
const C3 = B.coach('coach3@x.co', 44);
|
||||||
|
const p2 = await dp.adopt({ rid: rid(), coach: claimOf(C3), person: live.id, kind: 'instant' });
|
||||||
|
ok(p2.ok, 'second pick of the same person (their 2nd adoption)', p2);
|
||||||
|
env.now += 3 * D + H;
|
||||||
|
const sw = await dp.sweep();
|
||||||
|
ok(sw.kept === 1 && (await accounts.byEmail('live@x.co')).sponsorRef === 'coach3', 'sweep: at 3 days, a person on their 2nd adoption stays with the coach (kept)', sw);
|
||||||
|
dp._poolReset();
|
||||||
|
ok(!(await dp.pool()).pool.some(c => c.id === live.id), 'pool: someone adopted twice is never offered again');
|
||||||
|
|
||||||
|
// ---- the hourly sweep: wallet alone is not started; started = done; locked = kept; hub silent = wait ----
|
||||||
|
const C4 = B.coach('coach4@x.co', 45);
|
||||||
|
accounts.add('w1@x.co'); accounts.add('s1@x.co'); accounts.add('k1@x.co'); accounts.add('u1@x.co'); dp._poolReset();
|
||||||
|
const pool4 = (await dp.pool()).pool; const idOf = u => pool4.find(c => c.username === u).id;
|
||||||
|
const pw = await dp.adopt({ rid: rid(), coach: claimOf(C4), person: idOf('w1') }); const ps = await dp.adopt({ rid: rid(), coach: claimOf(C4), person: idOf('s1') });
|
||||||
|
const pk = await dp.adopt({ rid: rid(), coach: claimOf(C4), person: idOf('k1') }); const pu = await dp.adopt({ rid: rid(), coach: claimOf(C4), person: idOf('u1') });
|
||||||
|
ok(pw.ok && ps.ok && pk.ok && pu.ok, 'four more picks for the sweep checks');
|
||||||
|
accounts._by.get('w1@x.co').address = addr(); // linked a wallet only
|
||||||
|
accounts._by.get('s1@x.co').address = addr(); accounts._by.get('s1@x.co').memberId = 77; B.buy(77, 1000); // switched on payouts + bought
|
||||||
|
// tank.sweep (the IAP 7-day sweep) leaves a pick's expired adoption alone
|
||||||
|
env.now += 3 * D + H;
|
||||||
|
hub.locked.add('k1@x.co');
|
||||||
|
const st0 = await dp.status({ ids: [idOf('s1'), idOf('w1'), 'h_ffffffffffffffff'] });
|
||||||
|
ok(st0.people['h_ffffffffffffffff'] === null, 'status: someone 5xYourTeam holds no pick for answers null');
|
||||||
|
ok(st0.people[idOf('s1')].payouts > 0 && st0.people[idOf('s1')].purchase > 0 && st0.people[idOf('w1')].wallet > 0 && !st0.people[idOf('w1')].payouts, 'status: milestones (wallet / payouts / purchase as first-seen times)', st0.people[idOf('w1')]);
|
||||||
|
ok(!JSON.stringify(st0).includes('@'), 'status: no contact data');
|
||||||
|
hub.down = true;
|
||||||
|
const swU = await dp.sweep();
|
||||||
|
ok(swU.waiting >= 1 && swU.done === 1 && (await accounts.byEmail('u1@x.co')).sponsorRef === 'coach4', 'sweep: hub not answering = the return waits, nobody moved', swU);
|
||||||
|
hub.down = false;
|
||||||
|
const sw2 = await dp.sweep();
|
||||||
|
ok(sw2.returned === 2 && sw2.kept === 1, 'sweep: started = done (even with the hub silent), wallet-only + plain = returned, locked = kept', sw2);
|
||||||
|
ok((await accounts.byEmail('w1@x.co')).sponsorRef === '' && (await accounts.byEmail('s1@x.co')).sponsorRef === 'coach4' && (await accounts.byEmail('k1@x.co')).sponsorRef === 'coach4', 'sweep: sponsors after the 3 days (wallet-only back to the tank; started and locked stay)');
|
||||||
|
const tsw = await tank.sweep();
|
||||||
|
ok(tsw.back === 0, 'tank.sweep: never touches a pick (the pick rule decides, not the 7-day wallet rule)', tsw);
|
||||||
|
// a pick whose tank adoption was closed some other way (released on InstantAdPay itself, a LinkSpin follow) reconciles
|
||||||
|
accounts.add('m1@x.co'); dp._poolReset(); const pm = (await dp.pool()).pool.find(c => c.username === 'm1');
|
||||||
|
const pmk = await dp.adopt({ rid: rid(), coach: claimOf(C4), person: pm.id });
|
||||||
|
for (const a of await tank.openOf('m1@x.co')) await tank.closeAdoption(a.id, 'moved');
|
||||||
|
const stm = await dp.status({ ids: [pm.id] });
|
||||||
|
ok(pmk.ok && stm.people[pm.id].pick.status === 'moved', 'reconcile: a pick closed on InstantAdPay shows as moved', stm.people[pm.id].pick);
|
||||||
|
// the log: every call with a reason
|
||||||
|
const av = await dp.adminView();
|
||||||
|
ok(av.log.length > 20 && av.log.every(l => l.op && l.ts && (l.ok || l.code)) && av.log.some(l => l.op === 'adopt' && !l.ok && l.code === 'not_vested') && av.log.some(l => l.op === 'sweep' && l.code === 'kept'), 'log: every call is logged with an outcome code / reason', av.log.slice(0, 3));
|
||||||
|
ok(!JSON.stringify(av.picks).includes('@'), 'admin view: picks carry no emails');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------- Part B: the routes on a local copy ----------------
|
||||||
|
async function partB() {
|
||||||
|
console.log('-- Part B: HTTP routes on a local copy');
|
||||||
|
const port = Number(process.env.DRAFT_E2E_PORT || 8825);
|
||||||
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'iap-draft-b-'));
|
||||||
|
const env = Object.assign({}, process.env, { PORT: String(port), DATA_DIR: dir, ADMIN_EMAIL: 'admin@iap.test', ADMIN_PASSWORD: 'localtest', DRAFT_PARTNER_SECRET: SECRET, DRAFT_ALLOW_NO_HUB: '1', LS_URL: 'http://127.0.0.1:9', HUB_ENABLED: '' });
|
||||||
|
delete env.DATABASE_URL; delete env.NODE_ENV;
|
||||||
|
const child = spawn(process.execPath, ['server.js'], { cwd: SITE, env, stdio: ['ignore', 'pipe', 'pipe'] });
|
||||||
|
let log = ''; child.stdout.on('data', d => { log += d; }); child.stderr.on('data', d => { log += d; });
|
||||||
|
const base = 'http://127.0.0.1:' + port;
|
||||||
|
try {
|
||||||
|
let up = false; for (let i = 0; i < 40 && !up; i++) { try { up = (await fetch(base + '/api/config')).ok; } catch (e) {} if (!up) await new Promise(r => setTimeout(r, 500)); }
|
||||||
|
ok(up, 'local copy up on :' + port, up ? undefined : log.slice(-600));
|
||||||
|
if (!up) return;
|
||||||
|
const call = async (op, body, opts) => { const raw = JSON.stringify(body || {}); const ts = String(Date.now()); const sig = (opts && opts.sig) || crypto.createHmac('sha256', SECRET).update('draft.v1.' + ts + '\n' + raw).digest('hex');
|
||||||
|
const r = await fetch(base + '/api/partner/draft/' + op, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Draft-Ts': ts, 'X-Draft-Sig': sig }, body: raw }); return { status: r.status, body: await r.json().catch(() => null) }; };
|
||||||
|
const p = await call('pool', {});
|
||||||
|
ok(p.status === 200 && p.body.ok && Array.isArray(p.body.pool) && p.body.rules.maxOpen === 10, 'POST /api/partner/draft/pool signed: 200 with rules + pool', p);
|
||||||
|
ok((await call('pool', {}, { sig: 'f'.repeat(64) })).status === 401, 'unsigned / wrong signature: 401');
|
||||||
|
ok((await call('nope', {})).status === 404, 'unknown op: 404');
|
||||||
|
const a = await call('adopt', { rid: 'rid-route-0001', coach: { wallet: addr(), positions: 1 }, person: 'h_0000000000000000' });
|
||||||
|
ok(a.status === 400 && a.body.code === 'coach_unknown', 'adopt for an unknown coach: 400 with a code', a.body);
|
||||||
|
const s = await call('status', { ids: ['h_0000000000000000'] });
|
||||||
|
ok(s.status === 200 && s.body.people['h_0000000000000000'] === null, 'status: 200, unknown person null');
|
||||||
|
ok((await fetch(base + '/api/admin/draft')).status === 401, 'GET /api/admin/draft needs the admin');
|
||||||
|
} finally { child.kill(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
await partA();
|
||||||
|
if (!process.env.DRAFT_SKIP_B) await partB();
|
||||||
|
console.log(fails ? 'FAILED ' + fails + ' (passed ' + passes + ')' : 'ALL PASSED (' + passes + ')');
|
||||||
|
process.exit(fails ? 1 : 0);
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
// Earners Corner forum sign-in (DiscourseConnect, 2026-11-10), end to end against a LOCAL copy. node qa/forumsso.mjs
|
||||||
|
// Boots server.js on its own port with a throwaway DATA_DIR (JSON store, devCode sign-in). Nothing touches production.
|
||||||
|
// Pro is NEW MONEY only: "Get Pro" opens a waiting order; only a package of $10 or more, mined after the order, by the member's own
|
||||||
|
// position, fulfils it; one package fulfils one order (a pass and Pro never ride the same purchase); credits never count.
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import os from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
import { spawn } from 'node:child_process';
|
||||||
|
import crypto from 'node:crypto';
|
||||||
|
const SECRET = 'x'.repeat(40);
|
||||||
|
const sig = s => crypto.createHmac('sha256', SECRET).update(s).digest('hex');
|
||||||
|
|
||||||
|
const SITE = path.resolve(path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1')), '..');
|
||||||
|
const PORT = Number(process.env.FS_PORT || 8804);
|
||||||
|
const B = 'http://127.0.0.1:' + PORT;
|
||||||
|
const DATA = fs.mkdtempSync(path.join(os.tmpdir(), 'iap-forumsso-')); fs.mkdirSync(path.join(DATA, 'uploads'));
|
||||||
|
let fails = 0; const ok = (cond, label, extra) => { console.log((cond ? 'PASS ' : 'FAIL ') + label + (extra ? ' ' + extra : '')); if (!cond) fails++; };
|
||||||
|
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||||||
|
const srv = spawn(process.execPath, ['server.js'], { cwd: SITE, stdio: ['ignore', 'pipe', 'pipe'],
|
||||||
|
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', FORUM_SSO_SECRET: SECRET, FORUM_URL: 'https://earnerscorner.com' }) });
|
||||||
|
let log = ''; srv.stdout.on('data', d => log += d); srv.stderr.on('data', d => log += d);
|
||||||
|
async function api(p, o, headers) {
|
||||||
|
const opts = { method: (o && 'data' in o) ? 'POST' : 'GET', headers: Object.assign({ 'Content-Type': 'application/json' }, headers || {}) };
|
||||||
|
if (o && 'data' in o) opts.body = JSON.stringify(o.data);
|
||||||
|
const r = await fetch(B + p, opts); let j = null; try { j = await r.json(); } catch (e) {} return { status: r.status, j };
|
||||||
|
}
|
||||||
|
async function signIn(email, username) {
|
||||||
|
const s = await api('/api/auth/email/start', { data: { email, fts: Date.now() - 5000 } });
|
||||||
|
const v = await fetch(B + '/api/auth/email/verify', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email, code: s.j && s.j.devCode }) });
|
||||||
|
const cookie = (v.headers.getSetCookie ? v.headers.getSetCookie() : [v.headers.get('set-cookie')]).map(c => String(c).split(';')[0]).join('; ');
|
||||||
|
if (username) await api('/api/my/profile', { data: { username } }, { Cookie: cookie });
|
||||||
|
return { Cookie: cookie };
|
||||||
|
}
|
||||||
|
const buy = (email, cents, extra) => api('/api/dev/gamepass-purchase', { data: Object.assign({ email, cents }, extra || {}) });
|
||||||
|
const optin = () => { try { return JSON.parse(fs.readFileSync(path.join(DATA, 'stack-optin.json'), 'utf8')); } catch (e) { return {}; } };
|
||||||
|
try {
|
||||||
|
for (let i = 0; i < 40; i++) { try { if ((await fetch(B + '/api/config')).ok) break; } catch (e) {} await sleep(500); }
|
||||||
|
const sso = Buffer.from('nonce=abc123&return_sso_url=' + encodeURIComponent('https://earnerscorner.com/session/sso_login')).toString('base64');
|
||||||
|
const get = (path, headers) => fetch(B + path, { redirect: 'manual', headers: headers || {} });
|
||||||
|
let r = await get('/forum/sso?sso=' + encodeURIComponent(sso) + '&sig=' + '0'.repeat(64)); ok(r.status === 302 && r.headers.get('location') === 'https://earnerscorner.com/', 'bad signature -> back to the forum, nothing signed');
|
||||||
|
const evil = Buffer.from('nonce=n&return_sso_url=' + encodeURIComponent('https://evil.example/x')).toString('base64');
|
||||||
|
r = await get('/forum/sso?sso=' + encodeURIComponent(evil) + '&sig=' + sig(evil)); ok(r.status === 302 && r.headers.get('location') === 'https://earnerscorner.com/', 'return URL off the forum is refused');
|
||||||
|
r = await get('/forum/sso?sso=' + encodeURIComponent(sso) + '&sig=' + sig(sso));
|
||||||
|
const ck = (r.headers.getSetCookie ? r.headers.getSetCookie() : []).map(c => c.split(';')[0]);
|
||||||
|
ok(r.status === 302 && r.headers.get('location') === '/my' && ck.some(c => c === 'iap.return=forum') && ck.some(c => c.startsWith('iap.forumsso=')), 'signed out -> /my with the request kept in a cookie');
|
||||||
|
const h = await signIn('fs-a@example.com', 'forumfan');
|
||||||
|
const me = await api('/api/me', null, { Cookie: h.Cookie + '; ' + ck.join('; ') }); ok(me.j && me.j.returnTo === 'forum', '/api/me tells /my to hand back to the forum', JSON.stringify(me.j && me.j.returnTo));
|
||||||
|
r = await get('/api/my/forum', { Cookie: h.Cookie + '; ' + ck.filter(c => c.startsWith('iap.forumsso=')).join('; ') });
|
||||||
|
const loc = r.headers.get('location') || ''; ok(r.status === 302 && loc.startsWith('https://earnerscorner.com/session/sso_login?sso='), 'signed in -> back to the forum with a payload', loc.slice(0, 80));
|
||||||
|
const q = new URL(loc).searchParams, out = q.get('sso');
|
||||||
|
ok(q.get('sig') === sig(out), 'payload is signed with the shared secret');
|
||||||
|
const pl = new URLSearchParams(Buffer.from(out, 'base64').toString('utf8'));
|
||||||
|
ok(pl.get('nonce') === 'abc123' && pl.get('email') === 'fs-a@example.com' && pl.get('external_id') === 'fs-a@example.com' && pl.get('username') === 'forumfan', 'payload: nonce, email, external id, username', pl.toString().slice(0, 200));
|
||||||
|
ok(pl.get('website') === 'https://stackpol.com/forumfan' && (pl.get('remove_groups') || '').includes('network_members'), 'free member: no network_members group, profile links their Stack POL page');
|
||||||
|
r = await get('/forum/sso?sso=' + encodeURIComponent(sso) + '&sig=' + sig(sso), { Cookie: h.Cookie }); ok(r.status === 302 && (r.headers.get('location') || '').startsWith('https://earnerscorner.com/session/sso_login?sso='), 'already signed in -> straight back');
|
||||||
|
// invite link + shared-thread credit (2026-11-10)
|
||||||
|
r = await get('/forum/join/forumfan?to=' + encodeURIComponent('/t/some-thread/23?u=forumfan'));
|
||||||
|
const ick = (r.headers.getSetCookie ? r.headers.getSetCookie() : []).map(c => c.split(';')[0]);
|
||||||
|
ok(r.status === 302 && r.headers.get('location') === 'https://earnerscorner.com/t/some-thread/23?u=forumfan' && ick.includes('iap.sponsor=forumfan'), 'invite link sets the member as sponsor and forwards to the thread', JSON.stringify(ick));
|
||||||
|
r = await get('/forum/join/nosuchperson'); ok(r.status === 302 && !(r.headers.getSetCookie ? r.headers.getSetCookie() : []).some(c => c.startsWith('iap.sponsor=')), 'unknown username: forwards, sets no sponsor');
|
||||||
|
r = await get('/forum/join/forumfan?to=' + encodeURIComponent('//evil.example/x')); ok(r.headers.get('location') === 'https://earnerscorner.com/', 'off-site ?to= is refused');
|
||||||
|
const inv = await fetch(B + '/forum/invite', { headers: { Cookie: h.Cookie } }); const ih = await inv.text();
|
||||||
|
ok(inv.status === 200 && ih.includes('https://instantadpay.com/forum/join/forumfan'), 'invite page shows the member their link');
|
||||||
|
const nb = await fetch(B + '/api/auth/email/start', { method: 'POST', headers: { 'Content-Type': 'application/json', Cookie: 'iap.sponsor=forumfan' }, body: JSON.stringify({ email: 'fs-new@example.com', fts: Date.now() - 5000 }) }); const nbj = await nb.json();
|
||||||
|
const nv = await fetch(B + '/api/auth/email/verify', { method: 'POST', headers: { 'Content-Type': 'application/json', Cookie: 'iap.sponsor=forumfan' }, body: JSON.stringify({ email: 'fs-new@example.com', code: nbj.devCode }) });
|
||||||
|
const nck = (nv.headers.getSetCookie ? nv.headers.getSetCookie() : []).map(c => c.split(';')[0]).join('; ');
|
||||||
|
const nme = await api('/api/me', null, { Cookie: nck + '; iap.sponsor=forumfan' });
|
||||||
|
ok(nme.j && (nme.j.sponsorName === '@forumfan' || String(nme.j.sponsorRef || '').toLowerCase() === 'forumfan' || JSON.stringify(nme.j).includes('forumfan')), 'a new sign-up through the forum invite lands under the inviter', JSON.stringify(nme.j && { sponsorName: nme.j.sponsorName, sponsorRef: nme.j.sponsorRef }));
|
||||||
|
// reward-service lookup (2026-11-10)
|
||||||
|
const ts = Math.floor(Date.now() / 1000), msig = sig('fs-a@example.com.' + ts);
|
||||||
|
let lk = await fetch(B + '/api/forum/member?email=fs-a%40example.com', { headers: { 'x-forum-ts': String(ts), 'x-forum-sig': msig } }); let lj = await lk.json();
|
||||||
|
ok(lk.status === 200 && lj.found === true && lj.username === 'forumfan' && lj.activated === false, 'member lookup: signed request answers (free member = not activated)', JSON.stringify(lj));
|
||||||
|
lk = await fetch(B + '/api/forum/member?email=fs-a%40example.com', { headers: { 'x-forum-ts': String(ts), 'x-forum-sig': '0'.repeat(64) } }); ok(lk.status === 401, 'member lookup: bad signature refused');
|
||||||
|
const old = ts - 900; lk = await fetch(B + '/api/forum/member?email=fs-a%40example.com', { headers: { 'x-forum-ts': String(old), 'x-forum-sig': sig('fs-a@example.com.' + old) } }); ok(lk.status === 401, 'member lookup: stale signature refused');
|
||||||
|
} catch (e) { console.log('FAIL exception', e && e.stack || e); fails++; }
|
||||||
|
finally { try { srv.kill(); } catch (e) {} try { fs.rmSync(DATA, { recursive: true, force: true }); } catch (e) {} }
|
||||||
|
if (fails) console.log(log.split('\n').filter(l => /forum|error/i.test(l)).slice(-15).join('\n'));
|
||||||
|
console.log(fails ? '\n' + fails + ' FAILED' : '\nALL PASSED'); process.exit(fails ? 1 : 0);
|
||||||
+18
-1
@@ -132,7 +132,8 @@ try {
|
|||||||
ok(st && st.enabled === true && st.settings.enforced === false, 'admin stats: enabled, caps not enforced', JSON.stringify(st.settings));
|
ok(st && st.enabled === true && st.settings.enforced === false, 'admin stats: enabled, caps not enforced', JSON.stringify(st.settings));
|
||||||
|
|
||||||
// 6. enforced: daily within / over the cap, idempotent ref, progress deferral
|
// 6. enforced: daily within / over the cap, idempotent ref, progress deferral
|
||||||
await api('/api/admin/site', { method: 'PATCH', data: { capsStartDate: '2026-10-20' } }, adminH);
|
// capFreeLifetime is parked high here so the daily/total cap checks below read as they always did; it gets its own block at the end
|
||||||
|
await api('/api/admin/site', { method: 'PATCH', data: { capsStartDate: '2026-10-20', capFreeLifetime: 1000 } }, adminH);
|
||||||
const D1 = '2026-10-20', D2 = '2026-10-21', D3 = '2026-10-22';
|
const D1 = '2026-10-20', D2 = '2026-10-21', D3 = '2026-10-22';
|
||||||
gr = await grant({ memberId: 0, email: C, game: 'gemkingdom', kind: 'daily', pol: 0.2, ref: 'f1', devDay: D1 });
|
gr = await grant({ memberId: 0, email: C, game: 'gemkingdom', kind: 'daily', pol: 0.2, ref: 'f1', devDay: D1 });
|
||||||
ok(gr.j.allowed === 0.2 && gr.j.deferred === 0 && gr.j.enforced === true && gr.j.capHit === null, 'D1 daily 0.2 -> allowed 0.2', JSON.stringify(gr.j));
|
ok(gr.j.allowed === 0.2 && gr.j.deferred === 0 && gr.j.enforced === true && gr.j.capHit === null, 'D1 daily 0.2 -> allowed 0.2', JSON.stringify(gr.j));
|
||||||
@@ -216,6 +217,22 @@ try {
|
|||||||
ok(tokenClaims && tokenClaims.gamePass && tokenClaims.gamePass.active === true && tokenClaims.gamePass.until === until1 + 7 * 86400000, 'in-game sign-in token carries gamePass { active, until }', JSON.stringify(tokenClaims && tokenClaims.gamePass));
|
ok(tokenClaims && tokenClaims.gamePass && tokenClaims.gamePass.active === true && tokenClaims.gamePass.until === until1 + 7 * 86400000, 'in-game sign-in token carries gamePass { active, until }', JSON.stringify(tokenClaims && tokenClaims.gamePass));
|
||||||
|
|
||||||
// the ledger file on the volume (saves are debounced 500 ms)
|
// the ledger file on the volume (saves are debounced 500 ms)
|
||||||
|
// 9. the free allowance (2026-11-02): an account with no pass receives at most capFreeLifetime POL of game rewards, ever
|
||||||
|
await api('/api/admin/site', { method: 'PATCH', data: { capFreeLifetime: 2 } }, adminH);
|
||||||
|
const LF = 'qa-gp-lifetime@example.com'; await signIn(LF, 'qagplife');
|
||||||
|
gr = await grant({ memberId: 0, email: LF, game: 'gemkingdom', kind: 'progress', pol: 1.5, ref: 'lf:boss:1', devDay: D1 });
|
||||||
|
ok(gr.j.allowed === 1.5 && gr.j.deferred === 0 && gr.j.lifetimeHit === false && gr.j.freeUsed === 1.5, 'allowance: progress 1.5 -> allowed 1.5, 1.5 of 2 used', JSON.stringify(gr.j));
|
||||||
|
gr = await grant({ memberId: 0, email: LF, game: 'gemkingdom', kind: 'daily', pol: 0.3, ref: 'lf:d1', devDay: D1 });
|
||||||
|
ok(gr.j.allowed === 0.3 && gr.j.freeUsed === 1.8, 'allowance: daily 0.3 -> allowed 0.3, 1.8 used', JSON.stringify(gr.j));
|
||||||
|
gr = await grant({ memberId: 0, email: LF, game: 'gemkingdom', kind: 'progress', pol: 1, ref: 'lf:boss:2', devDay: D1 });
|
||||||
|
ok(gr.j.allowed === 0.2 && gr.j.deferred === 0.8 && gr.j.lifetimeHit === true && gr.j.freeUsed === 2, 'allowance: progress 1 -> 0.2 allowed, 0.8 deferred, the allowance is used up', JSON.stringify(gr.j));
|
||||||
|
pl = await gameGet('/api/partner/player', { game: 'gemkingdom', m: 0, e: LF, devDay: D1 }, LF, GK);
|
||||||
|
ok(pl.j.caps.lifetime && pl.j.caps.lifetime.cap === 2 && pl.j.caps.lifetime.used === 2 && pl.j.caps.pending === 0.8, 'player caps carry the allowance: 2 of 2 used, 0.8 pending', JSON.stringify(pl.j.caps));
|
||||||
|
gr = await grant({ memberId: 0, email: LF, game: 'gemkingdom', kind: 'daily', pol: 0.2, ref: 'lf:d2', devDay: D2 });
|
||||||
|
ok(gr.j.allowed === 0 && gr.j.deferred === 0 && gr.j.lifetimeHit === true, 'allowance used: next day daily 0.2 -> nothing, dropped', JSON.stringify(gr.j));
|
||||||
|
gr = await grant({ memberId: 0, email: LF, game: 'gemkingdom', kind: 'progress', pol: 0.1, ref: 'lf:stage:9', devDay: D2 });
|
||||||
|
ok(gr.j.allowed === 0 && gr.j.deferred === 0.1 && gr.j.carried === 0, 'allowance used: next day progress 0.1 -> deferred, no carry paid either', JSON.stringify(gr.j));
|
||||||
|
await api('/api/admin/site', { method: 'PATCH', data: { capFreeLifetime: 1000 } }, adminH);
|
||||||
await sleep(1200);
|
await sleep(1200);
|
||||||
ok(fs.existsSync(path.join(DATA, 'gamepass-ledger.json')), 'cap ledger persisted to DATA_DIR/gamepass-ledger.json', fs.readdirSync(DATA).join(','));
|
ok(fs.existsSync(path.join(DATA, 'gamepass-ledger.json')), 'cap ledger persisted to DATA_DIR/gamepass-ledger.json', fs.readdirSync(DATA).join(','));
|
||||||
const ot = JSON.parse(fs.readFileSync(path.join(DATA, 'open-tokens.json'), 'utf8'));
|
const ot = JSON.parse(fs.readFileSync(path.join(DATA, 'open-tokens.json'), 'utf8'));
|
||||||
|
|||||||
@@ -0,0 +1,351 @@
|
|||||||
|
// Network hub sync (hubsync.js) against a REAL network-hub started in this process (JSON mode, throwaway DATA_DIR), with
|
||||||
|
// InstantAdPay's own accounts / lssync / lsinbound in JSON mode on another throwaway dir. Synthetic members only.
|
||||||
|
// Then the flag-off check: server.js started with and without HUB_ENABLED.
|
||||||
|
// node qa/hubsync.test.cjs (HUB_DIR = the network-hub checkout; needs /v1/resolve by {id})
|
||||||
|
'use strict';
|
||||||
|
const fs = require('fs');
|
||||||
|
const os = require('os');
|
||||||
|
const path = require('path');
|
||||||
|
const http = require('http');
|
||||||
|
const crypto = require('crypto');
|
||||||
|
const assert = require('assert');
|
||||||
|
const { spawn } = require('child_process');
|
||||||
|
|
||||||
|
const ROOT = path.join(__dirname, '..');
|
||||||
|
const HUB_DIR = process.env.HUB_DIR || ['..', path.join('..', '..')].flatMap(up => ['network-hub', 'network-hub-resolve-id'].map(d => path.join(ROOT, up, d))).find(d => fs.existsSync(path.join(d, 'server.js')));
|
||||||
|
let fails = 0, n = 0;
|
||||||
|
async function t(name, fn) { n++; try { await fn(); console.log('ok', name); } catch (e) { fails++; console.log('FAIL', name, '::', e && e.stack ? e.stack.split('\n').slice(0, 3).join(' | ') : e); } }
|
||||||
|
const IAP_SECRET = 'i'.repeat(40), CTB_SECRET = 'c'.repeat(40);
|
||||||
|
const W = k => '0x' + String(k).repeat(40).slice(0, 40);
|
||||||
|
const sig = (secret, ts, raw) => crypto.createHmac('sha256', secret).update(ts + '\n' + raw).digest('hex');
|
||||||
|
const listen = srv => new Promise(ok => srv.listen(0, '127.0.0.1', () => ok(srv.address().port)));
|
||||||
|
// mail audit (2026-11-14): every outbound request this process makes is recorded; only the local hub and site may be called.
|
||||||
|
// mailer.js sends with https.request (SendGrid), Telegram and Sendy go out over https too, so both doors are watched.
|
||||||
|
const outside = [];
|
||||||
|
{ const realFetch = global.fetch; global.fetch = (u, o) => { const s = String(u && u.url ? u.url : u); if (!/^http:[/][/]127[.]0[.]0[.]1:/.test(s)) outside.push(s); return realFetch(u, o); };
|
||||||
|
const https = require('https'); const realReq = https.request; https.request = function (...a) { outside.push('https ' + JSON.stringify((a[0] && a[0].hostname) || a[0])); return realReq.apply(this, a); }; }
|
||||||
|
|
||||||
|
delete process.env.DATABASE_URL; delete process.env.LS_SYNC_SECRET; // JSON stores, LinkSpin push off
|
||||||
|
const HUB_DATA = fs.mkdtempSync(path.join(os.tmpdir(), 'hubsync-hub-'));
|
||||||
|
const IAP_DATA = fs.mkdtempSync(path.join(os.tmpdir(), 'hubsync-iap-'));
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
// InstantAdPay's hook receiver: the same call server.js makes for POST /api/hub/events
|
||||||
|
let hubsync = null;
|
||||||
|
const iapSrv = http.createServer((req, res) => {
|
||||||
|
const chunks = []; req.on('data', c => chunks.push(c)); req.on('end', async () => {
|
||||||
|
const r = await hubsync.receive(req.headers, Buffer.concat(chunks).toString('utf8'));
|
||||||
|
res.writeHead(r.status, { 'Content-Type': 'application/json' }); res.end(JSON.stringify(r.body));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
const iapPort = await listen(iapSrv);
|
||||||
|
|
||||||
|
// the hub: iap gets hooks and sees emails (it needs them to make accounts); ctb is the other door
|
||||||
|
process.env.DATA_DIR = HUB_DATA;
|
||||||
|
process.env.HUB_SITES = JSON.stringify({ iap: { secret: IAP_SECRET, hook: 'http://127.0.0.1:' + iapPort + '/api/hub/events', seeEmails: true }, ctb: { secret: CTB_SECRET, seeEmails: true } });
|
||||||
|
const hubReq = m => require(path.join(HUB_DIR, m));
|
||||||
|
const hubConfig = hubReq('lib/config'); const hubStore = hubReq('lib/store'); const hooks = hubReq('lib/hooks');
|
||||||
|
const hubSrv = await hubReq('server').start(0); const hubPort = hubSrv.address().port;
|
||||||
|
const HUB = 'http://127.0.0.1:' + hubPort;
|
||||||
|
const deliver = () => hooks.deliver('iap', hubConfig.SITES.iap);
|
||||||
|
async function ctb(p, body) { // a call from another door
|
||||||
|
const raw = JSON.stringify(body), ts = String(Date.now());
|
||||||
|
const r = await fetch(HUB + p, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Hub-Site': 'ctb', 'X-Hub-Ts': ts, 'X-Hub-Sig': sig(CTB_SECRET, ts, raw) }, body: raw });
|
||||||
|
return r.json();
|
||||||
|
}
|
||||||
|
const hubPerson = email => hubReq('lib/people').byEmail(email);
|
||||||
|
|
||||||
|
// InstantAdPay's side, JSON mode
|
||||||
|
const accounts = require(path.join(ROOT, 'accounts.js')); accounts.init({ dataDir: IAP_DATA });
|
||||||
|
const lssync = require(path.join(ROOT, 'lssync.js')); const lsinbound = require(path.join(ROOT, 'lsinbound.js'));
|
||||||
|
lssync.init({ dataDir: IAP_DATA, accounts }); lsinbound.init({ dataDir: IAP_DATA, accounts, lssync });
|
||||||
|
const old = (await accounts.ensure('old.member@example.test', '', null, null)).account; // made before the flag went on
|
||||||
|
await accounts.setUsername(old.email, 'oldie');
|
||||||
|
await new Promise(r => setTimeout(r, 5));
|
||||||
|
process.env.HUB_ENABLED = '1'; process.env.HUB_URL = HUB; process.env.HUB_SECRET = IAP_SECRET; process.env.HUB_SITE = 'iap';
|
||||||
|
hubsync = require(path.join(ROOT, 'hubsync.js'));
|
||||||
|
hubsync.init({ dataDir: IAP_DATA, accounts, lsinbound });
|
||||||
|
accounts.onChange(e => { lssync.touch(e); hubsync.touch(e); }); accounts.onWalletLinked(e => hubsync.wallet(e)); // as server.js wires it
|
||||||
|
const settle = () => new Promise(r => setTimeout(r, 50));
|
||||||
|
const signed = (events, secret, ts) => { const raw = JSON.stringify({ events }); ts = ts || String(Date.now()); return { headers: { 'x-hub-ts': ts, 'x-hub-sig': sig(secret || IAP_SECRET, ts, raw) }, raw }; };
|
||||||
|
|
||||||
|
await t('hook signature: wrong secret and a stale timestamp are refused, a good one is accepted', async () => {
|
||||||
|
let s = signed([], 'z'.repeat(40)); assert.strictEqual((await hubsync.receive(s.headers, s.raw)).status, 401);
|
||||||
|
s = signed([], IAP_SECRET, String(Date.now() - 6 * 60000)); assert.strictEqual((await hubsync.receive(s.headers, s.raw)).status, 401);
|
||||||
|
s = signed([]); s.headers['x-hub-sig'] = s.headers['x-hub-sig'].replace(/^./, c => c === 'a' ? 'b' : 'a'); assert.strictEqual((await hubsync.receive(s.headers, s.raw)).status, 401);
|
||||||
|
s = signed([]); assert.strictEqual((await hubsync.receive(s.headers, s.raw)).status, 200);
|
||||||
|
});
|
||||||
|
|
||||||
|
let ann, bob;
|
||||||
|
await t('round trip: two CTB joins reach InstantAdPay as waiting accounts, sponsor line kept', async () => {
|
||||||
|
await ctb('/v1/join', { email: 'ann@example.test', username: 'annctb' });
|
||||||
|
await ctb('/v1/join', { email: 'bob@example.test', username: 'bobctb', ref: 'annctb' });
|
||||||
|
assert.strictEqual(await deliver(), 2);
|
||||||
|
ann = await accounts.byEmail('ann@example.test'); bob = await accounts.byEmail('bob@example.test');
|
||||||
|
assert.ok(ann && bob, 'both accounts exist');
|
||||||
|
assert.strictEqual(bob.joinedVia, 'hub'); assert.strictEqual(bob.joinedRef, 'hub:ctb');
|
||||||
|
assert.ok(accounts.isUnclaimedShell(bob), 'a waiting account, left out of the sweeps');
|
||||||
|
assert.strictEqual(bob.sponsorRef, ann.username || ann.code); assert.strictEqual(bob.username, 'bobctb');
|
||||||
|
assert.strictEqual((await accounts.listAll(100)).filter(a => a.joinedVia === 'hub').length, 0, 'listAll leaves the waiting accounts out');
|
||||||
|
assert.strictEqual(hubStore.cursor('iap'), hubStore.eventsAfter(0, 100).length, 'hub cursor moved after the 2xx');
|
||||||
|
});
|
||||||
|
|
||||||
|
await t('the same events delivered again change nothing', async () => {
|
||||||
|
const before = JSON.stringify(await accounts.listAll(100, { shells: true }));
|
||||||
|
const skipped = hubsync.adminView().skipped;
|
||||||
|
hubStore.setCursor('iap', 0); await hubStore.flush();
|
||||||
|
assert.strictEqual(await deliver(), 2);
|
||||||
|
assert.strictEqual(JSON.stringify(await accounts.listAll(100, { shells: true })), before);
|
||||||
|
assert.strictEqual(hubsync.adminView().skipped, skipped + 2);
|
||||||
|
});
|
||||||
|
|
||||||
|
await t('a sponsor not on InstantAdPay yet comes along (climbs the hub line)', async () => {
|
||||||
|
await ctb('/v1/join', { email: 'dee@example.test', username: 'deectb' });
|
||||||
|
await ctb('/v1/join', { email: 'carl@example.test', username: 'carlctb', ref: 'deectb' });
|
||||||
|
const evs = hubStore.eventsAfter(hubStore.cursor('iap'), 10); const carlEv = evs.find(e => e.personId === hubPerson('carl@example.test').id);
|
||||||
|
const s = signed([carlEv]); assert.strictEqual((await hubsync.receive(s.headers, s.raw)).status, 200); // carl's event alone, before dee's
|
||||||
|
const dee = await accounts.byEmail('dee@example.test'); const carl = await accounts.byEmail('carl@example.test');
|
||||||
|
assert.ok(dee && dee.joinedVia === 'hub', 'sponsor shell built'); assert.strictEqual(carl.sponsorRef, dee.username || dee.code);
|
||||||
|
await deliver(); // dee's own event later: already there, nothing new
|
||||||
|
assert.strictEqual((await accounts.listAll(100, { shells: true })).filter(a => a.email === 'dee@example.test').length, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
await t('an InstantAdPay sign-up is reported to the hub under its InstantAdPay sponsor; its own event is skipped', async () => {
|
||||||
|
await accounts.touchSeen(ann.email); // ann claimed her waiting account by signing in
|
||||||
|
const r = await accounts.ensure('erin@example.test', ann.username || ann.code, null, null); assert.ok(r.created);
|
||||||
|
await settle(); await hubsync.flush(true);
|
||||||
|
const p = hubPerson('erin@example.test'); assert.ok(p, 'hub has erin');
|
||||||
|
assert.strictEqual(p.door.site, 'iap'); assert.strictEqual(p.sponsorId, hubPerson('ann@example.test').id);
|
||||||
|
const applied = hubsync.adminView().applied; await deliver();
|
||||||
|
assert.strictEqual(hubsync.adminView().applied, applied, 'own join not applied back');
|
||||||
|
await accounts.setUsername('erin@example.test', 'erin_iap'); await settle(); await hubsync.flush(true);
|
||||||
|
assert.strictEqual(hubPerson('erin@example.test').aliases.iap, 'erin_iap', 'username follows');
|
||||||
|
});
|
||||||
|
|
||||||
|
await t('a wallet linked on InstantAdPay reaches the hub', async () => {
|
||||||
|
const x = await accounts.linkWallet('erin@example.test', W('e')); assert.ok(!x.error, x.error);
|
||||||
|
await settle(); await hubsync.flush(true);
|
||||||
|
assert.strictEqual(hubPerson('erin@example.test').wallet, W('e'));
|
||||||
|
});
|
||||||
|
|
||||||
|
await t('wallet.connected fills a waiting account, never a claimed one', async () => {
|
||||||
|
await ctb('/v1/wallet', { email: 'bob@example.test', wallet: W('b') });
|
||||||
|
await ctb('/v1/wallet', { email: 'ann@example.test', wallet: W('a') });
|
||||||
|
await deliver();
|
||||||
|
assert.strictEqual((await accounts.byEmail('bob@example.test')).address, W('b'));
|
||||||
|
assert.strictEqual((await accounts.byEmail('ann@example.test')).address, null, 'ann signed in: she links her own wallet here');
|
||||||
|
});
|
||||||
|
|
||||||
|
await t('an existing InstantAdPay account keeps its sponsor; the difference is recorded', async () => {
|
||||||
|
await accounts.setSponsorRef(old.email, ann.username || ann.code);
|
||||||
|
await ctb('/v1/join', { email: old.email, ref: 'bobctb' }); await deliver();
|
||||||
|
const a = await accounts.byEmail(old.email);
|
||||||
|
assert.strictEqual(a.sponsorRef, ann.username || ann.code, 'InstantAdPay sponsor stands');
|
||||||
|
assert.strictEqual(a.joinedVia, null, 'not turned into a waiting account');
|
||||||
|
const d = hubsync.adminView().disagreements.find(x => x.email === old.email);
|
||||||
|
assert.ok(d && d.iap === 'ann@example.test' && d.hub === 'bob@example.test', JSON.stringify(d));
|
||||||
|
assert.ok(!hubsync.adminView().disagreements.find(x => x.email === 'erin@example.test'), 'agreeing members are not listed');
|
||||||
|
});
|
||||||
|
|
||||||
|
await t('a hub that is down: the hook answers 503 (hub retries), the outbox keeps the join, sign-up is not blocked', async () => {
|
||||||
|
await ctb('/v1/join', { email: 'fay@example.test' });
|
||||||
|
process.env.HUB_URL = 'http://127.0.0.1:1';
|
||||||
|
await assert.rejects(deliver(), /503/);
|
||||||
|
assert.strictEqual(await accounts.byEmail('fay@example.test'), null);
|
||||||
|
const r = await accounts.ensure('gus@example.test', '', null, null); assert.ok(r.created, 'sign-up went through');
|
||||||
|
await settle(); await hubsync.flush(true);
|
||||||
|
const saved = JSON.parse(fs.readFileSync(path.join(IAP_DATA, 'hubsync.json'), 'utf8'));
|
||||||
|
assert.ok(saved.outbox.find(i => i.email === 'gus@example.test' && i.tries === 1), 'persisted with a retry count');
|
||||||
|
process.env.HUB_URL = HUB;
|
||||||
|
await deliver(); assert.ok(await accounts.byEmail('fay@example.test'), 'retried event applied');
|
||||||
|
await hubsync.flush(true); assert.ok(hubPerson('gus@example.test'), 'join sent once the hub is back');
|
||||||
|
assert.strictEqual(hubsync.adminView().outbox, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
await t('a refused call is final (409 wallet taken), not retried forever', async () => {
|
||||||
|
await accounts.ensure('hal@example.test', '', null, null); await settle(); await hubsync.flush(true);
|
||||||
|
await ctb('/v1/join', { email: 'ivy@example.test' }); await ctb('/v1/wallet', { email: 'ivy@example.test', wallet: W('9') });
|
||||||
|
await accounts.linkWallet('hal@example.test', W('9')); await settle(); await hubsync.flush(true);
|
||||||
|
const v = hubsync.adminView(); assert.strictEqual(v.outbox, 0); assert.ok(v.recent.find(l => l.type === 'out-refused' && l.code === 'wallet_taken'));
|
||||||
|
});
|
||||||
|
|
||||||
|
await t('rule 2: a paid Purchase on the InstantAdPay contract reaches the hub and moves the network sponsor to this contract (2026-11-14)', async () => {
|
||||||
|
// tureia2003's shape: locked on LinkSpin under silverstussy (activated only), then bound AND paid here under paidtowatch
|
||||||
|
await ctb('/v1/join', { email: 'ptw@example.test', username: 'ptw' }); await ctb('/v1/wallet', { email: 'ptw@example.test', wallet: W('d') });
|
||||||
|
await ctb('/v1/join', { email: 'sil@example.test', username: 'sil' }); await ctb('/v1/wallet', { email: 'sil@example.test', wallet: W('f') });
|
||||||
|
await ctb('/v1/join', { email: 'tur@example.test', ref: 'sil', username: 'tur' });
|
||||||
|
await ctb('/v1/contract-bind', { contract: 'linkspin', email: 'tur@example.test', wallet: W('7'), sponsorRef: W('f') });
|
||||||
|
assert.strictEqual(hubPerson('tur@example.test').sponsorId, hubPerson('sil@example.test').id);
|
||||||
|
const members = { 5: { account: W('d') }, 12: { account: W('7') } };
|
||||||
|
hubsync.init({ dataDir: IAP_DATA, accounts, lsinbound, chain: { member: async id => members[id] || null } });
|
||||||
|
hubsync.onChain({ type: 'MemberActivated', id: 12, account: W('7'), sponsorId: 5 });
|
||||||
|
hubsync.onChain({ type: 'Purchase', buyerId: 12, priceCents: 0, paidWei: '0', tx: '0xfree' }); // nothing paid in: not a spend
|
||||||
|
hubsync.onChain({ type: 'Purchase', buyerId: 12, priceCents: 3500, paidWei: '1000', tx: '0xpaid', ts: 1700000000000 });
|
||||||
|
hubsync.onChain({ type: 'Purchase', buyerId: 12, priceCents: 3500, paidWei: '1000', tx: '0xpaid', ts: 1700000000000 }); // seen twice
|
||||||
|
await settle(); await hubsync.flush(true);
|
||||||
|
const p = hubPerson('tur@example.test');
|
||||||
|
assert.strictEqual(p.bindings.iap.sponsorId, hubPerson('ptw@example.test').id);
|
||||||
|
assert.strictEqual(p.bindings.iap.spentCents, 3500, 'one purchase counted once');
|
||||||
|
assert.strictEqual(p.bindings.linkspin.sponsorId, hubPerson('sil@example.test').id, 'the LinkSpin lock keeps its sponsor');
|
||||||
|
assert.strictEqual(p.sponsorId, hubPerson('ptw@example.test').id, 'network sponsor = the contract with money spent');
|
||||||
|
assert.strictEqual(hubsync.adminView().outbox, 0);
|
||||||
|
hubsync.init({ dataDir: IAP_DATA, accounts, lsinbound });
|
||||||
|
});
|
||||||
|
|
||||||
|
await t('sponsor.changed and unknown event types are acknowledged and ignored', async () => {
|
||||||
|
const s = signed([{ seq: 99001, type: 'sponsor.changed', personId: hubPerson('bob@example.test').id, data: { by: 'admin' } }, { seq: 99002, type: 'member.blocked', personId: 'h_0000000000000000', data: {} }]);
|
||||||
|
assert.strictEqual((await hubsync.receive(s.headers, s.raw)).status, 200);
|
||||||
|
});
|
||||||
|
|
||||||
|
const HP = hubReq('lib/people');
|
||||||
|
await t('rule 2 on arrival: someone the InstantAdPay contract holds arrives under that lock sponsor, not the network sponsor; sponsor.changed never moves them', async () => {
|
||||||
|
await ctb('/v1/join', { email: 'lx@example.test', username: 'lockx' }); // their sponsor on the InstantAdPay contract
|
||||||
|
await ctb('/v1/join', { email: 'ly@example.test', username: 'locky' }); // their sponsor on LinkSpin, where the money was spent
|
||||||
|
await ctb('/v1/join', { email: 'lk@example.test', username: 'lockkid', ref: 'locky' });
|
||||||
|
HP.bindContract({ site: 'iap', contract: 'iap', email: 'lk@example.test', wallet: W('3'), sponsorRef: 'lockx', at: 1000 });
|
||||||
|
HP.bindContract({ site: 'linkspin', contract: 'linkspin', email: 'lk@example.test', wallet: W('3'), sponsorRef: 'locky', at: 2000, spentCents: 2500 });
|
||||||
|
await hubStore.flush();
|
||||||
|
const hp = hubPerson('lk@example.test');
|
||||||
|
assert.strictEqual(hp.sponsorId, hubPerson('ly@example.test').id, 'network sponsor = LinkSpin (money spent there)');
|
||||||
|
assert.strictEqual(hp.bindings.iap.sponsorId, hubPerson('lx@example.test').id);
|
||||||
|
await deliver();
|
||||||
|
const kid = await accounts.byEmail('lk@example.test'); const lx = await accounts.byEmail('lx@example.test');
|
||||||
|
assert.ok(kid && lx, 'both arrived');
|
||||||
|
assert.strictEqual(kid.sponsorRef, lx.username || lx.code, 'the InstantAdPay lock sponsor is written here');
|
||||||
|
const s = signed([{ seq: 99101, type: 'sponsor.changed', personId: hp.id, data: { by: 'contract', contract: 'linkspin' } }]);
|
||||||
|
assert.strictEqual((await hubsync.receive(s.headers, s.raw)).status, 200);
|
||||||
|
assert.strictEqual((await accounts.byEmail('lk@example.test')).sponsorRef, lx.username || lx.code, 'sponsor.changed is ignored');
|
||||||
|
// climbing: a lock sponsor not on InstantAdPay yet comes along before the member (their event alone)
|
||||||
|
await ctb('/v1/join', { email: 'lz@example.test', username: 'lockz' });
|
||||||
|
await ctb('/v1/join', { email: 'lk2@example.test', username: 'lockkid2', ref: 'locky' });
|
||||||
|
HP.bindContract({ site: 'iap', contract: 'iap', email: 'lk2@example.test', wallet: W('4'), sponsorRef: 'lockz', at: 3000, spentCents: 2000 });
|
||||||
|
HP.bindContract({ site: 'linkspin', contract: 'linkspin', email: 'lk2@example.test', wallet: W('4'), sponsorRef: 'locky', at: 1500, spentCents: 2000 }); // earlier spend: network = locky
|
||||||
|
await hubStore.flush();
|
||||||
|
assert.strictEqual(hubPerson('lk2@example.test').sponsorId, hubPerson('ly@example.test').id);
|
||||||
|
const ev = hubStore.eventsAfter(0, 1e6).find(e => e.type === 'member.joined' && e.personId === hubPerson('lk2@example.test').id);
|
||||||
|
const s2 = signed([ev]); assert.strictEqual((await hubsync.receive(s2.headers, s2.raw)).status, 200);
|
||||||
|
const lz = await accounts.byEmail('lz@example.test');
|
||||||
|
assert.ok(lz, 'the lock sponsor came along'); assert.strictEqual((await accounts.byEmail('lk2@example.test')).sponsorRef, lz.username || lz.code);
|
||||||
|
await deliver();
|
||||||
|
});
|
||||||
|
|
||||||
|
// the holding tank, as server.js wires it with HUB_ENABLED, with a mailer and messages that only record
|
||||||
|
const tank = require(path.join(ROOT, 'tank.js'));
|
||||||
|
const sent = [];
|
||||||
|
const mailer = { hasKey: () => true, send: async (...a) => { sent.push(['mail', a[0], a[1]]); } };
|
||||||
|
const messages = { sendChat: async (...a) => { sent.push(['chat', a[2]]); }, deliver: async (...a) => { sent.push(['notice', a[2]]); }, lastFrom: async () => Date.now() }; // every sponsor 'just wrote': rescue warnings are not what this checks
|
||||||
|
tank.init({ dataDir: IAP_DATA, accounts, chain: { recentEvents: () => [], member: async () => null }, messages, mailer,
|
||||||
|
hooks: { network: async (email, address) => (await hubsync.hubSponsor(email)) || lsinbound.networkSponsor(email, address), networkHeld: a => hubsync.heldAmong(a), networkLocked: e => hubsync.lockedAnywhere(e) } });
|
||||||
|
|
||||||
|
await t('rule 3: the tank never offers anyone locked on any network contract or sponsored in the hub; release refuses a locked member', async () => {
|
||||||
|
await ctb('/v1/join', { email: 'tk1@example.test', username: 'tk1ctb', ref: 'annctb' }); // the hub knows a sponsor
|
||||||
|
for (const e of ['tk1', 'tk2', 'tk3']) assert.ok((await accounts.ensure(e + '@example.test', '', null, null)).created); // signed up here, no sponsor
|
||||||
|
await settle(); await hubsync.flush(true);
|
||||||
|
HP.bindContract({ site: 'linkspin', contract: 'linkspin', email: 'tk2@example.test', wallet: W('5'), sponsorRef: '' }); await hubStore.flush(); // locked, top of that tree
|
||||||
|
hubsync._heldReset();
|
||||||
|
const held = await hubsync.heldAmong([await accounts.byEmail('tk1@example.test'), await accounts.byEmail('tk2@example.test'), await accounts.byEmail('tk3@example.test')]);
|
||||||
|
assert.deepStrictEqual([...held.entries()].sort(), [['tk1@example.test', 'sponsored'], ['tk2@example.test', 'locked']]);
|
||||||
|
const w = (await tank.waiting()).map(x => x.email);
|
||||||
|
assert.ok(w.includes('tk3@example.test'), 'a free member is offered');
|
||||||
|
assert.ok(!w.includes('tk1@example.test') && !w.includes('tk2@example.test'), 'sponsored and locked are not: ' + w.join(','));
|
||||||
|
// tk2 under erin here, not activated here: releasing them to the tank is refused, the hub's lock elsewhere stands
|
||||||
|
const erin = await accounts.byEmail('erin@example.test'); await accounts.setSponsorRef('tk2@example.test', erin.username || erin.code);
|
||||||
|
const r = await tank.release('erin@example.test', 'tk2@example.test');
|
||||||
|
assert.ok(r.error && /locked/.test(r.error), JSON.stringify(r));
|
||||||
|
assert.strictEqual((await accounts.byEmail('tk2@example.test')).sponsorRef, erin.username || erin.code);
|
||||||
|
// the 15-minute tick: with HUB_TANK_ALIGN off tk1 is only held; with it on, aligned to the sponsor the hub knows (ann has a real account here), quietly
|
||||||
|
await tank.readyTick(); assert.strictEqual((await accounts.byEmail('tk1@example.test')).sponsorRef || '', '', 'alignment from the hub is off by default');
|
||||||
|
process.env.HUB_TANK_ALIGN = 'on'; await tank.readyTick(); delete process.env.HUB_TANK_ALIGN;
|
||||||
|
assert.strictEqual((await accounts.byEmail('tk1@example.test')).sponsorRef, ann.username || ann.code, 'aligned to the hub sponsor');
|
||||||
|
});
|
||||||
|
|
||||||
|
await t('rule 3 fail-safe: hub unreachable past the 1-hour cache = nobody it was asked about is offered; back = offered again', async () => {
|
||||||
|
process.env.HUB_URL = 'http://127.0.0.1:1'; hubsync._heldAge(30 * 60000);
|
||||||
|
assert.ok((await tank.waiting()).map(x => x.email).includes('tk3@example.test'), 'within the hour the last answer stands');
|
||||||
|
hubsync._heldReset(); // nothing cached, hub down
|
||||||
|
assert.ok(!(await tank.waiting()).map(x => x.email).includes('tk3@example.test'), 'unknown = held');
|
||||||
|
assert.strictEqual(await hubsync.lockedAnywhere('tk3@example.test'), 'unknown');
|
||||||
|
process.env.HUB_URL = HUB; hubsync._heldReset();
|
||||||
|
assert.ok((await tank.waiting()).map(x => x.email).includes('tk3@example.test'));
|
||||||
|
});
|
||||||
|
|
||||||
|
await t('an adoption-window expiry (tank label expire) reaches the hub as a sponsor change by expiry (fix 2026-11-15)', async () => {
|
||||||
|
assert.strictEqual(hubsync._hubBy('expire'), 'expiry'); assert.strictEqual(hubsync._hubBy('adopt'), 'adopt');
|
||||||
|
const recs = new Map(); const follow = { get: e => recs.get(String(e).toLowerCase()) || null };
|
||||||
|
hubsync.init({ dataDir: IAP_DATA, accounts, lsinbound, follow }); // as server.js passes followStore
|
||||||
|
const erin = await accounts.byEmail('erin@example.test');
|
||||||
|
recs.set('tk3@example.test', { by: 'adopt', sponsorEmail: 'erin@example.test', at: Date.now() });
|
||||||
|
await accounts.setSponsorRef('tk3@example.test', erin.username || erin.code); await settle(); await hubsync.flush(true);
|
||||||
|
let hp = hubPerson('tk3@example.test'); assert.strictEqual(hp.sponsorId, hubPerson('erin@example.test').id, 'adopt reached the hub');
|
||||||
|
recs.set('tk3@example.test', { by: 'expire', sponsorEmail: '', at: Date.now() + 1 });
|
||||||
|
await accounts.setSponsorRef('tk3@example.test', ''); await settle(); await hubsync.flush(true);
|
||||||
|
hp = hubPerson('tk3@example.test'); const last = hp.sponsorHistory[hp.sponsorHistory.length - 1];
|
||||||
|
assert.strictEqual(hp.sponsorId, null, 'expiry cleared the hub sponsor'); assert.strictEqual(last.by, 'expiry', JSON.stringify(last));
|
||||||
|
hubsync.init({ dataDir: IAP_DATA, accounts, lsinbound }); // back as the other tests had it
|
||||||
|
});
|
||||||
|
|
||||||
|
await t('mail audit: hub arrivals (new, sponsor climbed, existing filled, wallet) and the tank ticks send no mail, chat, notice or outside call', async () => {
|
||||||
|
sent.length = 0; outside.length = 0;
|
||||||
|
await ctb('/v1/join', { email: 'ma@example.test', username: 'mailtop' }); await ctb('/v1/wallet', { email: 'ma@example.test', wallet: W('6') });
|
||||||
|
await ctb('/v1/join', { email: 'mb@example.test', username: 'mailkid', ref: 'mailtop' }); await ctb('/v1/wallet', { email: 'mb@example.test', wallet: W('8') });
|
||||||
|
process.env.HUB_ENABLED = ''; await accounts.ensure('mc@example.test', '', null, null); process.env.HUB_ENABLED = '1'; // here before the hub knew them
|
||||||
|
await ctb('/v1/join', { email: 'mc@example.test', username: 'mailfill' }); // an existing InstantAdPay account: empty fields filled
|
||||||
|
const evs = hubStore.eventsAfter(hubStore.cursor('iap'), 100);
|
||||||
|
const kid = evs.find(e => e.personId === hubPerson('mb@example.test').id && e.type === 'member.joined');
|
||||||
|
const s = signed([kid]); assert.strictEqual((await hubsync.receive(s.headers, s.raw)).status, 200); // the kid first: the sponsor climbs
|
||||||
|
await deliver();
|
||||||
|
assert.ok(await accounts.byEmail('ma@example.test') && await accounts.byEmail('mb@example.test'));
|
||||||
|
assert.strictEqual((await accounts.byEmail('mb@example.test')).address, W('8'));
|
||||||
|
assert.strictEqual((await accounts.byEmail('mc@example.test')).username, 'mailfill', 'filled');
|
||||||
|
await settle(); await hubsync.flush(true); await tank.readyTick(); await tank.sweep(); await settle(); await hubsync.flush(true);
|
||||||
|
assert.deepStrictEqual(JSON.parse(fs.readFileSync(path.join(IAP_DATA, 'hubsync.json'), 'utf8')).outbox, []);
|
||||||
|
assert.deepStrictEqual(sent, [], 'nothing sent');
|
||||||
|
assert.deepStrictEqual(outside, [], 'no outside call');
|
||||||
|
// the old direct LinkSpin sync never pushes a waiting account the hub made (LinkSpin's registry route would switch payouts
|
||||||
|
// on and email them); a member who signs up here still goes
|
||||||
|
const pushed = []; const lsStub = http.createServer((req, res) => { let d = ''; req.on('data', c => { d += c; }); req.on('end', () => { try { for (const r of JSON.parse(d).rows || []) pushed.push(r.email); } catch (e) {} res.writeHead(200, { 'Content-Type': 'application/json' }); res.end('{"ok":true,"proto":2}'); }); });
|
||||||
|
process.env.LS_URL = 'http://127.0.0.1:' + await listen(lsStub); process.env.LS_SYNC_SECRET = 's'.repeat(40);
|
||||||
|
try {
|
||||||
|
await lssync.tick(true);
|
||||||
|
assert.ok(pushed.length > 0, 'the sync ran');
|
||||||
|
for (const e of ['ma@example.test', 'mb@example.test', 'lk@example.test', 'bob@example.test']) assert.ok(!pushed.includes(e), e + ' (a hub waiting account) was pushed');
|
||||||
|
assert.ok(pushed.includes('erin@example.test'), 'an InstantAdPay sign-up still syncs');
|
||||||
|
} finally { delete process.env.LS_SYNC_SECRET; lsStub.close(); }
|
||||||
|
// and the hub path itself never loads a mail module
|
||||||
|
const loaded = Object.keys(require.cache).map(f => path.basename(f));
|
||||||
|
for (const m of ['mailer.js', 'sendy.js', 'messages.js', 'drip.js']) assert.ok(!loaded.includes(m), m + ' is loaded');
|
||||||
|
});
|
||||||
|
|
||||||
|
await t('flag off: the module answers 404 and reports nothing', async () => {
|
||||||
|
process.env.HUB_ENABLED = '';
|
||||||
|
const s = signed([]); assert.strictEqual((await hubsync.receive(s.headers, s.raw)).status, 404);
|
||||||
|
await accounts.ensure('jon@example.test', '', null, null); await settle();
|
||||||
|
assert.ok(!JSON.parse(fs.readFileSync(path.join(IAP_DATA, 'hubsync.json'), 'utf8')).outbox.length);
|
||||||
|
process.env.HUB_ENABLED = '1';
|
||||||
|
});
|
||||||
|
|
||||||
|
hubSrv.close(); iapSrv.close();
|
||||||
|
|
||||||
|
// server.js itself: without HUB_ENABLED the route does not exist and no hubsync file is written; with it, unsigned = 401
|
||||||
|
async function boot(env) {
|
||||||
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'hubsync-site-')); const port = 18000 + Math.floor(Math.random() * 2000);
|
||||||
|
const ch = spawn(process.execPath, ['server.js'], { cwd: ROOT, env: Object.assign({}, process.env, { PORT: String(port), DATA_DIR: dir, ADMIN_PASSWORD: 'localtest', HUB_ENABLED: '', HUB_URL: '', HUB_SECRET: '' }, env), stdio: 'ignore' });
|
||||||
|
for (let i = 0; i < 120; i++) { try { await fetch('http://127.0.0.1:' + port + '/'); break; } catch (e) { await new Promise(r => setTimeout(r, 250)); } }
|
||||||
|
return { ch, dir, url: 'http://127.0.0.1:' + port };
|
||||||
|
}
|
||||||
|
for (const [label, env, want] of [['off', {}, 'off'], ['on', { HUB_ENABLED: '1', HUB_URL: 'http://127.0.0.1:1', HUB_SECRET: IAP_SECRET }, 401]]) {
|
||||||
|
await t('server.js with the flag ' + label, async () => {
|
||||||
|
const b = await boot(env);
|
||||||
|
try {
|
||||||
|
const r = await fetch(b.url + '/api/hub/events', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: '{"events":[]}' });
|
||||||
|
const reg = await fetch(b.url + '/api/partner/registry', { method: 'POST', body: '{}' });
|
||||||
|
assert.strictEqual(reg.status, 503, 'LinkSpin route unchanged (no LS secret here)');
|
||||||
|
if (want === 'off') { assert.notStrictEqual(r.status, 401); assert.notStrictEqual(r.status, 200); assert.ok(!fs.existsSync(path.join(b.dir, 'hubsync.json')), 'no hubsync file'); }
|
||||||
|
else { assert.strictEqual(r.status, want); assert.ok(fs.existsSync(path.join(b.dir, 'hubsync.json'))); }
|
||||||
|
} finally { b.ch.kill(); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`\n${n - fails}/${n} passed`);
|
||||||
|
process.exit(fails ? 1 : 0);
|
||||||
|
})().catch(e => { console.error(e); process.exit(1); });
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
// My line: directs' email + origin + search (Marty, 2026-11-12). Boots a throwaway server, makes a sponsor and three directs who
|
||||||
|
// join through tagged links (?src=), then checks in a real browser that "Your line" shows each direct's email, where they came
|
||||||
|
// from and how they joined, that the Activity drop-down shows the same for a direct, and that the search box narrows the list.
|
||||||
|
// Screenshot in qa/out/line-origin.png. node qa/line-origin.mjs
|
||||||
|
import { spawn } from 'node:child_process';
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import os from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
const PW = process.env.PW || 'D:/Projects/MarketingAgent/qa-tester/node_modules/playwright/index.js';
|
||||||
|
const { chromium } = (await import('file:///' + PW.replace(/^\/+/, ''))).default;
|
||||||
|
const PORT = 8797, B = 'http://127.0.0.1:' + PORT;
|
||||||
|
const DATA = path.join(os.tmpdir(), 'iap-line-origin-' + Date.now()); fs.mkdirSync(DATA, { recursive: true });
|
||||||
|
const ok = [], bad = []; const t = (n, c, x) => (c ? ok : bad).push(n + (c || !x ? '' : ' -> ' + x));
|
||||||
|
const srv = spawn(process.execPath, ['server.js'], { env: { ...process.env, PORT: String(PORT), DATA_DIR: DATA, ADMIN_PASSWORD: 'localtest', ADMIN_EMAIL: 'admin@example.com', NODE_ENV: 'test', DATABASE_URL: '' }, stdio: 'ignore' });
|
||||||
|
const bye = c => { try { srv.kill(); } catch (e) {} setTimeout(() => { try { fs.rmSync(DATA, { recursive: true, force: true }); } catch (e) {} process.exit(c); }, 500); };
|
||||||
|
for (let i = 0; i < 60; i++) { try { if ((await fetch(B + '/api/stats')).ok) break; } catch (e) {} await new Promise(r => setTimeout(r, 500)); }
|
||||||
|
const DEV = 'c0ffee00c0ffee00c0ffee00c0ffee00';
|
||||||
|
const cookiesOf = r => (r.headers.getSetCookie ? r.headers.getSetCookie() : [r.headers.get('set-cookie')]).filter(Boolean).map(c => String(c).split(';')[0]);
|
||||||
|
const jf = async (p, body, cookie, extra) => { const r = await fetch(B + p, { method: body ? 'POST' : 'GET', redirect: 'manual', headers: Object.assign({ 'Content-Type': 'application/json', Cookie: cookie }, extra || {}), body: body ? JSON.stringify(body) : undefined }); let b = {}; try { b = await r.json(); } catch (e) {} return { r, b }; };
|
||||||
|
async function signIn(email, jarIn, dev, ip) { // each test person gets their own device id, or the one-account-per-person guard blocks them
|
||||||
|
const jar0 = ['iap.dev=' + (dev || DEV), ...(jarIn || [])].join('; ');
|
||||||
|
const xf = { 'X-Forwarded-For': ip || '203.0.113.1' }; // a different test address per person (the per-connection sign-up guard)
|
||||||
|
const st = await jf('/api/auth/email/start', { email, fts: Date.now() - 20000 }, jar0, xf);
|
||||||
|
const code = st.b.devCode || st.b.code; if (!code) { console.log('no dev code for', email, JSON.stringify(st.b)); bye(2); }
|
||||||
|
const vf = await jf('/api/auth/email/verify', { email, code }, jar0, xf);
|
||||||
|
if (vf.b && vf.b.error) console.log('verify', email, vf.b.error);
|
||||||
|
return [jar0, ...cookiesOf(vf.r)].join('; ');
|
||||||
|
}
|
||||||
|
const jar = await signIn('sponsor@example.com');
|
||||||
|
await jf('/api/my/profile', { username: 'sponsorone' }, jar);
|
||||||
|
const me = (await jf('/api/me', null, jar)).b; const tok = me.username || me.refCode; t('sponsor has a link token', !!tok, JSON.stringify(me).slice(0, 120));
|
||||||
|
const directs = [['ann@example.com', '?src=mailergold', 'https://mailer.gold/x'], ['bob@example.com', '?src=pam-mail', ''], ['cat@example.com', '', 'https://massifly.com/feed']];
|
||||||
|
for (const [email, q, ref] of directs) {
|
||||||
|
const j = await jf('/join/' + tok + q, null, '', Object.assign({ 'X-Forwarded-For': '198.51.100.' + (10 + directs.findIndex(d => d[0] === email)) }, ref ? { Referer: ref } : {}));
|
||||||
|
await signIn(email, cookiesOf(j.r), DEV.slice(0, 26) + String(directs.findIndex(d => d[0] === email)).padStart(6, '0'), '198.51.100.' + (10 + directs.findIndex(d => d[0] === email)));
|
||||||
|
}
|
||||||
|
const me2 = (await jf('/api/my/dashboard', null, jar)).b; t('the 3 directs are under the sponsor', (me2.referrals || []).length === 3, 'tok=' + tok + ' referrals=' + JSON.stringify(me2.referrals || []).slice(0, 300));
|
||||||
|
if ((me2.referrals || []).length !== 3) {
|
||||||
|
try { const d = JSON.parse(fs.readFileSync(path.join(DATA, 'accounts.json'), 'utf8')); console.log(JSON.stringify(Object.values(d.byEmail || {}).map(x => [x.email, x.username, x.sponsorRef, x.joinedRef, x.joinedVia]))); } catch (e) { console.log('no accounts.json', fs.readdirSync(DATA).join(',')); }
|
||||||
|
console.log(bad.join('\n')); bye(1);
|
||||||
|
}
|
||||||
|
const br = await chromium.launch(); const ctx = await br.newContext({ viewport: { width: 1280, height: 900 } });
|
||||||
|
await ctx.addCookies(jar.split('; ').map(kv => { const [name, ...v] = kv.split('='); return { name, value: v.join('='), url: B }; }));
|
||||||
|
await ctx.addInitScript(() => { try { sessionStorage.setItem('iap.welcome.v1', '1'); } catch (e) {} });
|
||||||
|
const page = await ctx.newPage();
|
||||||
|
await page.goto(B + '/my#line', { waitUntil: 'domcontentloaded' }); await page.waitForTimeout(4000);
|
||||||
|
for (const sel of ['#unameSkip', '[data-close]', '.modal .x']) { try { await page.click(sel, { timeout: 800 }); } catch (e) {} }
|
||||||
|
await page.evaluate(() => { document.querySelectorAll('.modal-back,.lgate,.iap-welcome').forEach(m => m.hidden = true); const b = document.querySelector('[data-pane="line"]'); if (b) b.click(); }); await page.waitForTimeout(1500);
|
||||||
|
const rows = await page.$$eval('#rosterWrap table.roster tr', xs => xs.map(x => x.innerText.replace(/\s+/g, ' ')));
|
||||||
|
t('Your line lists the 3 directs', rows.length === 3, rows.length);
|
||||||
|
t('each row shows the email', ['ann@', 'bob@', 'cat@'].every(e => rows.some(r => r.includes(e))), JSON.stringify(rows));
|
||||||
|
t('tagged link with referrer: from mailer.gold/mailergold', rows.some(r => r.includes('ann@') && r.includes('from mailer.gold/mailergold')), JSON.stringify(rows));
|
||||||
|
t('tagged link, no referrer: from pam-mail', rows.some(r => r.includes('bob@') && r.includes('from pam-mail')), JSON.stringify(rows));
|
||||||
|
t('untagged: from massifly.com', rows.some(r => r.includes('cat@') && r.includes('from massifly.com')), JSON.stringify(rows));
|
||||||
|
await (await page.$('#lineRosterCard')).screenshot({ path: 'qa/out/line-origin.png' });
|
||||||
|
await page.fill('#rosterWrap .lst-q', 'mailergold'); await page.waitForTimeout(600);
|
||||||
|
const after = await page.$$eval('#rosterWrap table.roster tr', xs => xs.filter(x => !x.hidden).map(x => x.innerText));
|
||||||
|
t('search by source narrows to 1', after.length === 1 && after[0].includes('ann@'), after.length);
|
||||||
|
const focused = await page.evaluate(() => document.activeElement && document.activeElement.classList.contains('lst-q'));
|
||||||
|
t('the search box keeps focus while typing', focused);
|
||||||
|
// Activity drop-down on a direct in the three-level card
|
||||||
|
const act = await page.$('#lineageWrap [data-act]');
|
||||||
|
if (act) { await act.click(); await page.waitForTimeout(1200); const box = await page.$eval('#lineageWrap .lin-act:not([hidden])', e => e.innerText).catch(() => ''); t('Activity shows Email + Came for a direct', /Email/.test(box) && /Came/.test(box) && /@example\.com/.test(box), box.slice(0, 200)); }
|
||||||
|
else t('three-level card has an Activity button', false, 'none');
|
||||||
|
const lv = await page.$eval('#lineageWrap', e => e.innerText).catch(() => ''); t('three-level card shows the origin line', /from (mailer\.gold\/mailergold|pam-mail|massifly\.com)/.test(lv), lv.slice(0, 200));
|
||||||
|
await br.close();
|
||||||
|
console.log(ok.map(x => ' ok ' + x).join('\n')); if (bad.length) console.log(bad.map(x => ' FAIL ' + x).join('\n'));
|
||||||
|
bye(bad.length ? 1 : 0);
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
// GET /api/admin/member-extra (2026-11-14): the network hub's member lookup reads opt-out, tank and hold state here. Read-only.
|
||||||
|
// Runs against LOCAL (bash qa/run.sh member starts it). Admin = Bearer localtest.
|
||||||
|
const B = process.env.LOCAL || 'http://127.0.0.1:8796';
|
||||||
|
let pass = 0, fail = 0; const ok = (c, m, x) => { if (c) pass++; else { fail++; console.log('[bug] member-extra ' + m + (x ? ' :: ' + x : '')); } };
|
||||||
|
const email = 'mx' + Date.now() + '@example.com'; const ip = '198.51.100.' + (20 + Math.floor(Math.random() * 200));
|
||||||
|
const H = { 'Content-Type': 'application/json', 'X-Forwarded-For': ip, 'User-Agent': 'Mozilla/5.0 MemberExtraQA' };
|
||||||
|
const post = (p, b) => fetch(B + p, { method: 'POST', headers: H, body: JSON.stringify(b) }).then(r => r.json().catch(() => ({})));
|
||||||
|
const get = (q, auth) => fetch(B + '/api/admin/member-extra?email=' + encodeURIComponent(q), { headers: auth ? { Authorization: 'Bearer ' + auth } : {} });
|
||||||
|
try {
|
||||||
|
ok((await get(email)).status === 401, 'no admin header is refused');
|
||||||
|
ok((await get(email, 'wrong')).status === 401, 'a wrong admin password is refused');
|
||||||
|
ok((await get(email, 'localtest')).status === 404, 'an unknown email is 404');
|
||||||
|
const st = await post('/api/auth/email/start', { email, fts: Date.now() - 8000, fage: 8000 });
|
||||||
|
if (st.devCode) await post('/api/auth/email/verify', { email, code: st.devCode });
|
||||||
|
const r = await get(email, 'localtest'); const j = await r.json().catch(() => null);
|
||||||
|
ok(r.status === 200 && j, 'a known account answers', r.status);
|
||||||
|
ok(j && j.tank && typeof j.tank.inTank === 'boolean', 'tank.inTank is a boolean', JSON.stringify(j));
|
||||||
|
ok(j && 'optedOut' in j, 'optedOut is present');
|
||||||
|
const w = await fetch(B + '/api/admin/member-extra?email=' + encodeURIComponent(email), { method: 'POST', headers: { Authorization: 'Bearer localtest' } });
|
||||||
|
ok(w.status !== 200 || !(await w.text()).includes('optedOut'), 'POST is not a route (read-only)');
|
||||||
|
} catch (e) { fail++; console.log('[bug] member-extra crashed :: ' + e.message); }
|
||||||
|
console.log('member-extra: ' + pass + ' passed, ' + fail + ' failed');
|
||||||
|
process.exit(fail ? 1 : 0);
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// QA only, loaded with node --require by qa/netconv.test.mjs: chain.js talks https to its RPC; a local mock RPC speaks plain http.
|
||||||
|
const https = require('https'), http = require('http');
|
||||||
|
const PORT = Number(process.env.QA_RPC_PORT);
|
||||||
|
const real = https.request;
|
||||||
|
https.request = function (opts, cb) {
|
||||||
|
if (opts && opts.hostname === '127.0.0.1') return http.request(Object.assign({}, opts, { port: PORT }), cb);
|
||||||
|
return real.apply(https, arguments);
|
||||||
|
};
|
||||||
@@ -0,0 +1,245 @@
|
|||||||
|
// Conversion linkage end to end (2026-11-07, reporting only). Boots a local InstantAdPay AND a local LinkSpin on throwaway data dirs
|
||||||
|
// (JSON stores, no DATABASE_URL, no mail key), pointed only at each other with a throwaway secret, and a mock Polygon RPC, so a real
|
||||||
|
// Purchase log goes through the real chain.js and the real event fan-out. Nothing touches production or a real member.
|
||||||
|
// node qa/netconv.test.mjs (or bash qa/run.sh netconv). Needs the LinkSpin repo beside this one (LS_SITE to override).
|
||||||
|
// The funnel: spin link -> /join?lsclk -> cookie -> sign-up -> join counted on LinkSpin; wallet link signed with a throwaway key ->
|
||||||
|
// wallet counted; Purchase on the mock chain, before member_id is stored -> purchase counted with its USD value, once, even when the
|
||||||
|
// mock serves the log to a second scan; Reports and the Campaigns card show them. Sponsor stays exactly what the join link set.
|
||||||
|
// Also: the page's own copy of the click (no cookie), own account not counted, LinkSpin down blocks nothing and the rows arrive later,
|
||||||
|
// duplicate delivery. Part 2: lsreport.js against a fake SQL layer, two app copies racing the same events.
|
||||||
|
import { spawn } from 'node:child_process';
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import os from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
import http from 'node:http';
|
||||||
|
import crypto from 'node:crypto';
|
||||||
|
import { createRequire } from 'node:module';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
const require = createRequire(import.meta.url);
|
||||||
|
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
const IAP_SITE = path.join(HERE, '..');
|
||||||
|
const LS_SITE = process.env.LS_SITE || path.join(IAP_SITE, '..', '..', 'linkspin', 'site');
|
||||||
|
const SECRET = 'qa-netconv-' + crypto.randomBytes(24).toString('hex');
|
||||||
|
const P = Number(process.env.NC_PORT || 8861), IAP = 'http://127.0.0.1:' + P, LS = 'http://127.0.0.1:' + (P + 1), RPC_PORT = P + 2;
|
||||||
|
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||||||
|
let pass = 0, fail = 0;
|
||||||
|
const ok = (c, name, extra) => { if (c) pass++; else fail++; console.log((c ? 'PASS ' : 'FAIL ') + name + (!c && extra !== undefined ? ' :: ' + (typeof extra === 'string' ? extra : JSON.stringify(extra)) : '')); };
|
||||||
|
async function waitFor(fn, ms) { const t0 = Date.now(); while (Date.now() - t0 < (ms || 20000)) { try { const v = await fn(); if (v) return v; } catch (e) {} await sleep(500); } return null; }
|
||||||
|
const hex = n => '0x' + BigInt(n).toString(16);
|
||||||
|
const w = n => BigInt(n).toString(16).padStart(64, '0');
|
||||||
|
|
||||||
|
// ---- mock RPC ----
|
||||||
|
const rpc = { block: 1000, logs: [], memberAcct: {} };
|
||||||
|
const PUR = '0x11dc109cafd0f24c81621f745383ec82be7f2947c650355791e27b56ac83bc8c';
|
||||||
|
const purchaseLog = (block, buyerId, cents, tx, li) => ({ address: '0x07786E664AAfc0641eEB5297766935763dbA2288', topics: [PUR, '0x' + w(buyerId), '0x' + w(1)], data: '0x' + w(1000000000000000000n) + w(cents) + w(0) + w(500), blockNumber: hex(block), transactionHash: tx, logIndex: hex(li) });
|
||||||
|
const rpcSrv = http.createServer((q, s) => { let d = ''; q.on('data', c => d += c); q.on('end', () => {
|
||||||
|
const b = JSON.parse(d || '{}'); let result = null;
|
||||||
|
if (b.method === 'eth_blockNumber') result = hex(rpc.block);
|
||||||
|
else if (b.method === 'eth_getLogs') { const f = parseInt(b.params[0].fromBlock, 16), t = parseInt(b.params[0].toBlock, 16); result = rpc.logs.filter(l => { const n = parseInt(l.blockNumber, 16); return n >= f && n <= t; }); }
|
||||||
|
else if (b.method === 'eth_call') { const data = b.params[0].data; if (data.startsWith('0x5f59bb40')) { const id = Number(BigInt('0x' + data.slice(10))); const a = rpc.memberAcct[id]; result = '0x' + w(a ? BigInt(a) : 0) + w(0) + w(0) + w(a ? 1 : 0) + w(0); } else result = '0x' + w(0).repeat(10); }
|
||||||
|
else result = '0x0';
|
||||||
|
s.writeHead(200, { 'Content-Type': 'application/json' }); s.end(JSON.stringify({ jsonrpc: '2.0', id: b.id, result }));
|
||||||
|
}); }).listen(RPC_PORT, '127.0.0.1');
|
||||||
|
|
||||||
|
// ---- two sites ----
|
||||||
|
const now = Date.now();
|
||||||
|
const acct = (email, username, o) => Object.assign({ email, pass: null, sponsorRef: '', code: ('c' + username).slice(0, 7), username, address: null, created: now - 20 * 86400000, lastSeen: now - 3600000, memberId: 0 }, o || {});
|
||||||
|
function seed(dir, list) { fs.mkdirSync(path.join(dir, 'uploads'), { recursive: true }); const db = { v: 2, byEmail: {}, byAddress: {}, byCode: {}, joins: 0, positions: {} }; for (const a of list) { db.byEmail[a.email] = a; db.byCode[a.code] = a.email; } fs.writeFileSync(path.join(dir, 'accounts.json'), JSON.stringify(db)); }
|
||||||
|
const iapDir = fs.mkdtempSync(path.join(os.tmpdir(), 'nc-iap-')), lsDir = fs.mkdtempSync(path.join(os.tmpdir(), 'nc-ls-'));
|
||||||
|
const OWNER = 'orlando@qa.test';
|
||||||
|
seed(iapDir, [acct(OWNER, 'qaorlando', { memberId: 2 })]); seed(lsDir, [acct(OWNER, 'qaorlando', { memberId: 2 })]);
|
||||||
|
fs.writeFileSync(path.join(iapDir, 'config.json'), JSON.stringify({ rpcs: ['https://127.0.0.1'], deployBlock: 990, telegramBotToken: '', adminEmail: 'admin@qa.test' }));
|
||||||
|
const env = (port, dir, extra) => { const e = {}; for (const k of ['PATH', 'Path', 'SystemRoot', 'SYSTEMROOT', 'TEMP', 'TMP', 'USERPROFILE', 'HOME', 'APPDATA', 'LOCALAPPDATA', 'COMSPEC', 'windir']) if (process.env[k]) e[k] = process.env[k]; return Object.assign(e, { PORT: String(port), DATA_DIR: dir, ADMIN_EMAIL: 'admin@qa.test', ADMIN_PASSWORD: 'localtest', LS_SYNC_SECRET: SECRET }, extra); };
|
||||||
|
const OUT = path.join(IAP_SITE, 'qa', 'out'); fs.mkdirSync(OUT, { recursive: true });
|
||||||
|
const procs = [];
|
||||||
|
function boot(site, port, dir, extra, log, args) { const fd = fs.openSync(log, 'a'); const p = spawn(process.execPath, (args || []).concat(['server.js']), { cwd: site, env: env(port, dir, extra), stdio: ['ignore', fd, fd] }); procs.push(p); return p; }
|
||||||
|
const bootLs = () => boot(LS_SITE, P + 1, lsDir, { IAP_URL: IAP, SITE_HOST: '127.0.0.1:' + (P + 1) }, path.join(OUT, 'netconv-ls.log'));
|
||||||
|
async function up(url) { for (let i = 0; i < 50; i++) { try { const r = await fetch(url + '/api/config', { signal: AbortSignal.timeout(2000) }); if (r.status < 500) return true; } catch (e) {} await sleep(500); } return false; }
|
||||||
|
|
||||||
|
// a client with its own cookie jar and its own address, so the sign-up guards see separate people
|
||||||
|
let ipN = 10;
|
||||||
|
function client() {
|
||||||
|
const jar = new Map(), ip = '198.51.100.' + (ipN++);
|
||||||
|
const call = async (url, o) => {
|
||||||
|
o = o || {}; const headers = Object.assign({ 'X-Forwarded-For': ip, 'User-Agent': 'Mozilla/5.0 NetconvQA ' + ip }, o.body ? { 'Content-Type': 'application/json' } : {}, jar.size ? { Cookie: [...jar].map(([k, v]) => k + '=' + v).join('; ') } : {});
|
||||||
|
const r = await fetch(url, { method: o.body ? 'POST' : 'GET', headers, body: o.body ? JSON.stringify(o.body) : undefined, redirect: 'manual' });
|
||||||
|
for (const c of r.headers.getSetCookie()) { const m = /^([^=]+)=([^;]*)/.exec(c); if (m) { if (/Max-Age=0/i.test(c) || m[2] === '') jar.delete(m[1]); else jar.set(m[1], m[2]); } }
|
||||||
|
const txt = await r.text(); let j = null; try { j = JSON.parse(txt); } catch (e) {} return { status: r.status, j, txt, headers: r.headers };
|
||||||
|
};
|
||||||
|
return { call, jar, ip };
|
||||||
|
}
|
||||||
|
async function signUp(c, base, email, extra) {
|
||||||
|
const st = await c.call(base + '/api/auth/email/start', { body: Object.assign({ email, fts: Date.now() - 8000, fage: 8000 }, extra || {}) });
|
||||||
|
if (!st.j || !st.j.devCode) throw new Error('no devCode: ' + st.txt.slice(0, 200));
|
||||||
|
return c.call(base + '/api/auth/email/verify', { body: Object.assign({ email, code: st.j.devCode }, extra || {}) });
|
||||||
|
}
|
||||||
|
const accountRow = async email => { const r = await fetch(IAP + '/api/admin/member?email=' + encodeURIComponent(email), { headers: { Authorization: 'Bearer localtest' } }); return r.json().catch(() => null); };
|
||||||
|
const ledger = () => { try { return fs.readFileSync(path.join(lsDir, 'netconv.jsonl'), 'utf8').trim().split('\n').filter(Boolean).map(l => JSON.parse(l)); } catch (e) { return []; } };
|
||||||
|
const iapState = () => { try { return JSON.parse(fs.readFileSync(path.join(iapDir, 'lsreport.json'), 'utf8')); } catch (e) { return { clicks: {}, events: [] }; } };
|
||||||
|
async function signed(pth, body) { const raw = JSON.stringify(body); const ts = String(Date.now()); const sig = crypto.createHmac('sha256', SECRET).update(ts + '\n' + raw).digest('hex'); const r = await fetch(LS + pth, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-LS-Ts': ts, 'X-LS-Sig': sig }, body: raw }); return r.json(); }
|
||||||
|
|
||||||
|
let lsProc = null;
|
||||||
|
try {
|
||||||
|
boot(IAP_SITE, P, iapDir, { LS_URL: LS, QA_RPC_PORT: String(RPC_PORT) }, path.join(OUT, 'netconv-iap.log'), ['--require', path.join(HERE, 'netconv-rpc-preload.cjs')]);
|
||||||
|
lsProc = bootLs();
|
||||||
|
ok(await up(IAP), 'local InstantAdPay up'); ok(await up(LS), 'local LinkSpin up');
|
||||||
|
|
||||||
|
// the owner's spin link, pointed straight at the join page, no goal set up
|
||||||
|
const own = client(); const so = await signUp(own, LS, OWNER); ok(so.status === 200, 'owner signed in on LinkSpin', so.txt.slice(0, 160));
|
||||||
|
const rot = (await own.call(LS + '/api/my/rotations', { body: { name: 'Bridge spin' } })).j.rotation;
|
||||||
|
await own.call(LS + '/api/my/rotations/' + rot.id + '/dest', { body: { url: 'https://instantadpay.com/join/qaorlando', weight: 1 } });
|
||||||
|
const clickFor = async c => { const r = await c.call(LS + '/r/' + rot.code); const loc = r.headers.get('location'); return new URL(loc).searchParams.get('lsclk'); };
|
||||||
|
|
||||||
|
// 1 sign-up with the cookie
|
||||||
|
const v1 = client(); const id1 = await clickFor(v1);
|
||||||
|
ok(/^[a-f0-9]{10}$/.test(id1 || ''), 'the spin link hands the visitor a click id', id1);
|
||||||
|
const land = await v1.call(IAP + '/join/qaorlando?lsclk=' + id1);
|
||||||
|
ok(land.status === 200 && v1.jar.get('iap.lsclk') === id1, 'arrival keeps the click in a first-party cookie', [...v1.jar.keys()]);
|
||||||
|
ok(v1.jar.get('iap.sponsor') === 'qaorlando', 'the sponsor cookie still lands beside it');
|
||||||
|
const r1 = await signUp(v1, IAP, 'lead1@qa.test');
|
||||||
|
ok(r1.status === 200 && r1.j.created, 'sign-up works', r1.txt.slice(0, 160));
|
||||||
|
ok(r1.j.account.sponsorRef === 'qaorlando', "the sponsor is the join link's, exactly", r1.j.account.sponsorRef);
|
||||||
|
ok(iapState().clicks['lead1@qa.test'] && iapState().clicks['lead1@qa.test'].click === id1 || await waitFor(() => (iapState().clicks['lead1@qa.test'] || {}).click === id1, 3000), 'the click is on the account');
|
||||||
|
ok(await waitFor(() => ledger().find(r => r.ev === 'join' && r.owner === OWNER && r.click === id1), 15000), 'LinkSpin counted the join for the click owner');
|
||||||
|
|
||||||
|
// 2 the control: no click, same sponsor path, nothing reported
|
||||||
|
const v0 = client(); await v0.call(IAP + '/join/qaorlando'); const r0 = await signUp(v0, IAP, 'plain@qa.test');
|
||||||
|
ok(r0.j.account.sponsorRef === 'qaorlando', 'a sign-up with no click gets the same sponsor');
|
||||||
|
await sleep(1000); ok(!iapState().clicks['plain@qa.test'], 'and nothing is kept or reported for it');
|
||||||
|
|
||||||
|
// 3 wallet link, signed with a throwaway key
|
||||||
|
const { Wallet } = require(path.join(IAP_SITE, 'node_modules', 'ethers'));
|
||||||
|
const wlt = Wallet.createRandom(); const addr = wlt.address;
|
||||||
|
const ch = await v1.call(IAP + '/api/auth/challenge', { body: { address: addr } });
|
||||||
|
const vf = await v1.call(IAP + '/api/auth/verify', { body: { address: addr, signature: await wlt.signMessage(ch.j.message) } });
|
||||||
|
ok(vf.status === 200 && vf.j.linked, 'wallet linked', vf.txt.slice(0, 200));
|
||||||
|
ok(await waitFor(() => ledger().find(r => r.ev === 'wallet' && r.click === id1), 15000), 'LinkSpin counted the wallet');
|
||||||
|
|
||||||
|
// 4 a Purchase log on the mock chain, member_id not stored yet: the buyer is found through the contract's wallet for that id
|
||||||
|
rpc.memberAcct[900] = addr; const TX = '0x' + 'ab'.repeat(32);
|
||||||
|
rpc.logs.push(purchaseLog(1001, 900, 2000, TX, 3)); rpc.block = 1002;
|
||||||
|
ok(await waitFor(() => ledger().find(r => r.ev === 'purchase' && r.tx === TX), 45000), 'a real Purchase event reached LinkSpin');
|
||||||
|
const pr = ledger().find(r => r.ev === 'purchase' && r.tx === TX);
|
||||||
|
ok(pr && pr.value === 20, 'value = the USD price on the chain event ($20.00)', pr && pr.value);
|
||||||
|
ok(pr && pr.owner === OWNER && pr.rot === rot.id, 'counted on the link and its owner');
|
||||||
|
// the same event a second time on its way to LinkSpin, plus a second package
|
||||||
|
const k = pr.k; const dupd = await signed('/api/partner/conv', { op: 'events', events: [{ k, ev: 'purchase', click: id1, email: 'lead1@qa.test', value: 20, ts: Date.now() }] });
|
||||||
|
ok(dupd.results[0].result === 'dup', 'the same purchase delivered again is a dup', dupd);
|
||||||
|
const TX2 = '0x' + 'cd'.repeat(32); rpc.logs.push(purchaseLog(1003, 900, 500, TX2, 1)); rpc.block = 1004;
|
||||||
|
ok(await waitFor(() => ledger().find(r => r.tx === TX2), 45000), 'a second package counts on its own');
|
||||||
|
ok(await waitFor(() => (iapState().events || []).filter(r => r.ev === 'purchase').length === 2, 4000), 'two purchase rows on InstantAdPay', iapState().events);
|
||||||
|
// a purchase by someone with no click reports nothing
|
||||||
|
const v9 = client(); await signUp(v9, IAP, 'other@qa.test');
|
||||||
|
const w9 = Wallet.createRandom(); const c9 = await v9.call(IAP + '/api/auth/challenge', { body: { address: w9.address } });
|
||||||
|
await v9.call(IAP + '/api/auth/verify', { body: { address: w9.address, signature: await w9.signMessage(c9.j.message) } });
|
||||||
|
rpc.memberAcct[901] = w9.address; rpc.logs.push(purchaseLog(1005, 901, 5000, '0x' + 'ef'.repeat(32), 1)); rpc.block = 1006;
|
||||||
|
await waitFor(() => JSON.parse(fs.readFileSync(path.join(iapDir, 'chain-index.json'), 'utf8')).lastBlock >= 1006, 45000); await sleep(1500);
|
||||||
|
ok(!ledger().some(r => r.value === 50), 'a buyer with no click reports nothing');
|
||||||
|
|
||||||
|
// 5 the page's own copy of the click: no cookie reached the server
|
||||||
|
const v2 = client(); const id2 = await clickFor(v2);
|
||||||
|
const r2 = await signUp(v2, IAP, 'lead2@qa.test', { ref: 'qaorlando', lsclk: id2 });
|
||||||
|
ok(r2.j.created && v2.jar.get('iap.lsclk') === undefined, 'sign-up with no cookie, the page sent its own copy');
|
||||||
|
ok(await waitFor(() => ledger().find(r => r.ev === 'join' && r.click === id2), 15000), 'the join still counts');
|
||||||
|
// code requested in one browser, finished in another
|
||||||
|
const v3a = client(), v3b = client(); const id3 = await clickFor(v3a);
|
||||||
|
const s3 = await v3a.call(IAP + '/api/auth/email/start', { body: { email: 'lead3@qa.test', fts: Date.now() - 8000, ref: 'qaorlando', lsclk: id3 } });
|
||||||
|
await sleep(400); const f3 = await v3b.call(IAP + '/api/auth/email/verify', { body: { email: 'lead3@qa.test', code: s3.j.devCode } });
|
||||||
|
ok(f3.j.created, 'code finished in a second browser');
|
||||||
|
ok(await waitFor(() => ledger().find(r => r.ev === 'join' && r.click === id3), 15000), 'the click travelled with the email');
|
||||||
|
// a bad click id is ignored everywhere
|
||||||
|
const v4 = client(); await v4.call(IAP + '/join/qaorlando?lsclk=../evil'); ok(!v4.jar.has('iap.lsclk'), 'a malformed click id sets nothing');
|
||||||
|
// lsid and non-join pages
|
||||||
|
const v5 = client(); await v5.call(IAP + '/?lsid=abcdef0123'); ok(v5.jar.get('iap.lsclk') === 'abcdef0123', 'lsid on any page is kept too');
|
||||||
|
|
||||||
|
// 6 the owner's own account
|
||||||
|
const v6 = client(); const id6 = await clickFor(v6); await v6.call(IAP + '/join/qaorlando?lsclk=' + id6);
|
||||||
|
const claim = await signUp(v6, IAP, 'orlando2@qa.test'); ok(claim.j.created, 'control account'); // (the seeded owner already has an account: an existing sign-in binds nothing)
|
||||||
|
const v7 = client(); const id7 = await clickFor(v7); await v7.call(IAP + '/join/qaorlando?lsclk=' + id7);
|
||||||
|
await signUp(v7, IAP, OWNER); await sleep(800);
|
||||||
|
ok(!iapState().clicks[OWNER] || !iapState().clicks[OWNER].bound, 'an existing account signing in binds no click');
|
||||||
|
const self = await signed('/api/partner/conv', { op: 'events', events: [{ k: 'join:selfcheck', ev: 'join', click: id7, email: OWNER, ts: Date.now() }] });
|
||||||
|
ok(self.results[0].result === 'self', "LinkSpin keeps the owner's own account as a test", self);
|
||||||
|
|
||||||
|
// 7 Reports and the Campaigns card
|
||||||
|
await waitFor(() => ledger().filter(r => r.ev === 'join').length >= 5, 8000);
|
||||||
|
const rep = (await own.call(LS + '/api/my/reports?days=30')).j;
|
||||||
|
const row = k2 => (rep.conversions || []).find(x => x.k === k2) || { n: 0, value: 0 };
|
||||||
|
const joins = ledger().filter(r => r.ev === 'join' && !r.self && r.owner === OWNER).length;
|
||||||
|
ok(row('join').n === joins && row('purchase').n === 2 && row('purchase').value === 25 && row('wallet').n === 1, 'Reports > Conversions: every join, 1 wallet, 2 purchases $25.00', rep.conversions);
|
||||||
|
ok(rep.totals.joins === joins && rep.totals.purchases === 1 && rep.totals.purchaseCount === 2, 'the tiles follow (1 buyer, 2 purchases)', rep.totals);
|
||||||
|
ok(rep.top[0].conv === joins + 3, 'Top links Conv. counts the same events', rep.top[0]);
|
||||||
|
const card = (await signUp(client(), IAP, OWNER)); const ownerIap = client(); await signUp(ownerIap, IAP, OWNER);
|
||||||
|
const cv = (await ownerIap.call(IAP + '/api/my/conversions?fresh=1')).j;
|
||||||
|
ok(cv && cv.ok && cv.network && (cv.network.rows.find(x => x.k === 'purchase') || {}).value === 25, 'InstantAdPay Campaigns card gets the same rows', cv && cv.network);
|
||||||
|
|
||||||
|
// the two screens themselves, in a browser
|
||||||
|
const PW = process.env.PW || 'D:/Projects/MarketingAgent/qa-tester/node_modules/playwright';
|
||||||
|
if (fs.existsSync(PW)) {
|
||||||
|
const pw = require(PW); const br = await pw.chromium.launch();
|
||||||
|
const open = async (jar, base, url) => { const ctx = await br.newContext({ viewport: { width: 1280, height: 900 } }); await ctx.addCookies([...jar].map(([name, value]) => ({ name, value, url: base }))); const p = await ctx.newPage(); const errs = []; p.on('pageerror', e => errs.push(e.message)); await p.goto(base + url, { waitUntil: 'domcontentloaded' }); return { p, errs }; };
|
||||||
|
const a = await open(own.jar, LS, '/reports');
|
||||||
|
await a.p.waitForFunction(() => /Purchases/.test((document.getElementById('convRows') || {}).textContent || ''), null, { timeout: 15000 }).catch(() => {});
|
||||||
|
const txt = await a.p.$eval('#convRows', e => e.textContent).catch(() => '');
|
||||||
|
ok(/Joins/.test(txt) && /Wallets/.test(txt) && /Purchases \u00b7 \$25\.00/.test(txt), 'LinkSpin Reports shows Joins, Wallets and Purchases with the value', txt);
|
||||||
|
ok(a.errs.length === 0, 'no script errors on Reports', a.errs);
|
||||||
|
await a.p.screenshot({ path: path.join(OUT, 'netconv-reports.png'), fullPage: false });
|
||||||
|
const b = await open(ownerIap.jar, IAP, '/my#campaigns');
|
||||||
|
await b.p.waitForFunction(() => { const e = document.getElementById('convNet'); return e && !e.hidden; }, null, { timeout: 20000 }).catch(() => {});
|
||||||
|
const nt = await b.p.$eval('#convNet', e => e.textContent).catch(() => '');
|
||||||
|
ok(/purchases \(\$25\.00\)/.test(nt), 'InstantAdPay Conversion tracking card shows the events', nt);
|
||||||
|
ok(b.errs.length === 0, 'no script errors on Campaigns', b.errs);
|
||||||
|
await br.close();
|
||||||
|
} else console.log('SKIP the two screens (no Playwright at ' + PW + ')');
|
||||||
|
|
||||||
|
// 8 LinkSpin down blocks nothing, rows arrive later
|
||||||
|
lsProc.kill(); await sleep(600);
|
||||||
|
const v8 = client(); await v8.call(IAP + "/join/qaorlando?lsclk=" + id1);
|
||||||
|
const t0 = Date.now(); const r8 = await signUp(v8, IAP, 'whiledown@qa.test'); const ms = Date.now() - t0;
|
||||||
|
ok(r8.status === 200 && r8.j.created, 'sign-up works with LinkSpin down'); ok(ms < 4000, 'and is not slowed by it', ms + ' ms');
|
||||||
|
ok(await waitFor(() => (iapState().events || []).find(r => r.email === 'whiledown@qa.test' && !r.pushed), 4000), 'the join waits in the queue');
|
||||||
|
const before = ledger().length;
|
||||||
|
lsProc = bootLs(); ok(await up(LS), 'LinkSpin back');
|
||||||
|
ok(await waitFor(() => (iapState().events || []).find(r => r.email === 'whiledown@qa.test' && r.pushed), 60000), 'the queue delivers it once LinkSpin is back', iapState().events.filter(r => r.email === 'whiledown@qa.test'));
|
||||||
|
const last = (iapState().events || []).find(r => r.email === 'whiledown@qa.test');
|
||||||
|
ok(last && last.outcome === 'other', "and id1's click already belongs to the first account, so it is refused, not counted", last);
|
||||||
|
ok(ledger().length === before, 'nothing added to the ledger for it');
|
||||||
|
} catch (e) { ok(false, 'crashed: ' + e.message, e.stack); } finally { for (const p of procs) { try { p.kill(); } catch (e) {} } rpcSrv.close(); }
|
||||||
|
|
||||||
|
// ---- part 2: two app copies against one SQL layer ----
|
||||||
|
{
|
||||||
|
const fake = () => { const clicks = new Map(), events = new Map();
|
||||||
|
const q = async (sql, a) => { await sleep(1 + Math.random() * 3);
|
||||||
|
if (/^SELECT click_id/.test(sql)) { const r = clicks.get(a[0]); return r ? [{ click_id: r.click, ts: r.ts, bound: r.bound }] : []; }
|
||||||
|
if (/^INSERT IGNORE INTO ls_account_clicks/.test(sql)) { if (clicks.has(a[0])) return { affectedRows: 0 }; clicks.set(a[0], { click: a[1], ts: a[2], bound: 0 }); return { affectedRows: 1 }; }
|
||||||
|
if (/^INSERT INTO ls_account_clicks/.test(sql)) { const r = clicks.get(a[0]); if (r && r.bound) return { affectedRows: 0 }; clicks.set(a[0], { click: a[1], ts: a[2], bound: 0 }); return { affectedRows: 1 }; }
|
||||||
|
if (/^UPDATE ls_account_clicks/.test(sql)) { const r = clicks.get(a[2]); if (!r || r.bound) return { affectedRows: 0 }; Object.assign(r, { click: a[0], ts: a[1], bound: 1 }); return { affectedRows: 1 }; }
|
||||||
|
if (/^INSERT IGNORE INTO ls_events/.test(sql)) { if (events.has(a[0])) return { affectedRows: 0 }; events.set(a[0], { k: a[0], ev: a[1], email: a[2], click_id: a[3], cents: a[4], ev_ts: a[5], tx: a[6], sk: a[7], pushed: 0 }); return { affectedRows: 1 }; }
|
||||||
|
if (/^SELECT k, ev/.test(sql)) return [...events.values()].filter(r => !r.pushed).slice(0, a[0]);
|
||||||
|
if (/^UPDATE ls_events/.test(sql)) { const r = events.get(a[1]); if (r) { r.pushed = 1; r.outcome = a[0]; } return { affectedRows: 1 }; }
|
||||||
|
return []; };
|
||||||
|
return { enabled: () => true, q, events, clicks }; };
|
||||||
|
process.env.LS_SYNC_SECRET = SECRET; process.env.LS_URL = 'http://127.0.0.1:' + (P + 5);
|
||||||
|
const load = db => { for (const k of Object.keys(require.cache)) if (/[\\/](lsreport|lsconv)\.js$/.test(k)) delete require.cache[k]; const m = require(path.join(IAP_SITE, 'lsreport.js')); m.init({ db, dataDir: os.tmpdir(), noTimers: true }); return m; };
|
||||||
|
const db = fake(); const A = load(db), B = load(db);
|
||||||
|
ok(A !== B, 'two copies of the module');
|
||||||
|
const bound = await Promise.all([A.signup('x@qa.test', 'abcdef0123'), B.signup('x@qa.test', 'abcdef0123')]);
|
||||||
|
ok(bound.filter(Boolean).length === 1, 'two copies binding the same sign-up: one wins', bound);
|
||||||
|
const ev = { type: 'Purchase', tx: '0x1', li: 4, priceCents: 500, ts: Date.now() };
|
||||||
|
const pu = await Promise.all([A.purchase(ev, 'x@qa.test'), B.purchase(ev, 'x@qa.test')]);
|
||||||
|
ok(pu.filter(Boolean).length === 1, 'two copies queueing the same purchase: one row', pu);
|
||||||
|
await Promise.all([A.wallet('x@qa.test'), B.wallet('x@qa.test')]);
|
||||||
|
ok([...db.events.keys()].sort().join() === [...new Set([...db.events.keys()])].sort().join() && db.events.size === 3, 'three rows: join, purchase, wallet', [...db.events.keys()]);
|
||||||
|
const got = []; const srv = http.createServer((q, s) => { let d = ''; q.on('data', c => d += c); q.on('end', () => { const b = JSON.parse(d); for (const e of b.events) got.push(e); s.writeHead(200, { 'Content-Type': 'application/json' }); s.end(JSON.stringify({ ok: true, results: b.events.map(e => ({ k: e.k, result: 'counted' })) })); }); }).listen(P + 5, '127.0.0.1');
|
||||||
|
await Promise.all([A.flush(), B.flush()]);
|
||||||
|
ok(got.length >= 3 && new Set(got.map(e => e.k)).size === 3, 'both copies may send a row; every row has one key, LinkSpin dedupes on it', got.length);
|
||||||
|
ok([...db.events.values()].every(r => r.pushed), 'all marked sent');
|
||||||
|
ok(got.find(e => e.ev === 'purchase').value === 5, 'the purchase value goes as dollars ($5.00)');
|
||||||
|
const late = { type: 'Purchase', tx: '0x2', li: 1, priceCents: 500, ts: Date.now() + 32 * 86400000 };
|
||||||
|
ok(!(await A.purchase(late, 'x@qa.test')), 'a purchase past the click window is not even queued');
|
||||||
|
ok(!(await A.purchase({ type: 'Purchase', tx: '0x3', li: 1, priceCents: 500, ts: Date.now() }, 'noclick@qa.test')), 'an account with no click queues nothing');
|
||||||
|
srv.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('\n' + pass + ' passed, ' + fail + ' failed');
|
||||||
|
process.exit(fail ? 1 : 0);
|
||||||
@@ -0,0 +1,219 @@
|
|||||||
|
// Network sign-in (InstantAdPay <-> LinkSpin, 2026-11-12) end to end: boots BOTH servers locally on throwaway DATA_DIRs and drives
|
||||||
|
// a real browser across them. Same file in both repos. node qa/networksso.e2e.mjs
|
||||||
|
// The other repo is found at NSSO_PEER_DIR, else ../../linkspin/site or ../../onchain-ad-membership/site from this site dir.
|
||||||
|
// InstantAdPay runs on http://127.0.0.1:<port> and LinkSpin on http://localhost:<port>: two hosts, so the two sites' cookies
|
||||||
|
// stay apart like instantadpay.com and linkspin.app do. No mail key on either copy (no email can leave), JSON stores, devCode.
|
||||||
|
// Proves: IAP -> LinkSpin and LinkSpin -> IAP arrive signed in without a code; the silent check on a sign-in page (signed in on
|
||||||
|
// the other site -> in; not -> the normal sign-in, one bounce only); signed out on the other site -> normal sign-in; a replayed or
|
||||||
|
// expired token is refused; an email not on the receiving site yet gets the email-code form prefilled, nothing created; sign-out
|
||||||
|
// stays per site; bots never bounce; no email-code request is made by any network sign-in.
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import os from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
import crypto from 'node:crypto';
|
||||||
|
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 || !fs.existsSync(path.join(IAP_DIR, 'networksso.js')) || !fs.existsSync(path.join(LS_DIR, 'networksso.js'))) {
|
||||||
|
console.log('SKIP network sign-in e2e: the other repo (with networksso.js) was not found. Set NSSO_PEER_DIR.'); process.exit(0);
|
||||||
|
}
|
||||||
|
const PW = process.env.PW || 'D:/Projects/MarketingAgent/qa-tester/node_modules/playwright';
|
||||||
|
const { chromium } = (await import(pathToFileURL(PW + '/index.js').href)).default;
|
||||||
|
const SECRET = crypto.randomBytes(24).toString('hex');
|
||||||
|
const IP = Number(process.env.NSSO_IAP_PORT || 8821), LP = Number(process.env.NSSO_LS_PORT || 8822);
|
||||||
|
const IAP = 'http://127.0.0.1:' + IP, LS = 'http://localhost:' + LP;
|
||||||
|
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));
|
||||||
|
const TMP = fs.mkdtempSync(path.join(os.tmpdir(), 'nsso-e2e-'));
|
||||||
|
// a request log on each server (method + path only), so "no email-code request was made" is checked on the server side
|
||||||
|
const SPY = path.join(TMP, 'reqlog.cjs');
|
||||||
|
fs.writeFileSync(SPY, "const http=require('http');const e=http.Server.prototype.emit;http.Server.prototype.emit=function(ev,req){if(ev==='request'&&req&&req.url)process.stdout.write('REQ '+req.method+' '+String(req.url).split('?')[0]+'\\n');return e.apply(this,arguments);};\n");
|
||||||
|
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: '', LS_SYNC_SECRET: '', NODE_OPTIONS: '--require ' + JSON.stringify(SPY).slice(1, -1) }, 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 });
|
||||||
|
const reqs = name => logs[name].split('\n').filter(l => l.startsWith('REQ '));
|
||||||
|
const codeReqs = () => reqs('iap').concat(reqs('ls')).filter(l => /\/api\/auth\/email\/(start|verify)$/.test(l)).length;
|
||||||
|
|
||||||
|
// sign in through the email code over plain HTTP (a separate client: its own IP via x-forwarded-for, its own device)
|
||||||
|
let ipN = 10;
|
||||||
|
async function codeSignIn(base, email) {
|
||||||
|
const h = { 'Content-Type': 'application/json', 'x-forwarded-for': '10.9.0.' + (ipN++), 'User-Agent': UA };
|
||||||
|
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 = (v.headers.getSetCookie ? v.headers.getSetCookie() : []).map(c => c.split(';')[0]).find(c => c.startsWith('iap.sid='));
|
||||||
|
if (!sid) throw new Error('code sign-in failed on ' + base + ' for ' + email + ': ' + JSON.stringify(sj) + ' / ' + v.status + ' ' + (await v.text()).slice(0, 200));
|
||||||
|
return sid.slice('iap.sid='.length);
|
||||||
|
}
|
||||||
|
const meOf = async (ctx, base) => { const r = await ctx.request.get(base + '/api/me', { headers: { Accept: 'application/json' } }); try { return await r.json(); } catch (e) { return {}; } };
|
||||||
|
async function newCtx(sessions) {
|
||||||
|
const ctx = await browser.newContext({ userAgent: UA });
|
||||||
|
const add = [];
|
||||||
|
if (sessions && sessions.iap) add.push({ name: 'iap.sid', value: sessions.iap, domain: '127.0.0.1', path: '/' });
|
||||||
|
if (sessions && sessions.ls) add.push({ name: 'iap.sid', value: sessions.ls, domain: 'localhost', path: '/' });
|
||||||
|
if (add.length) await ctx.addCookies(add);
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
|
let browser = null;
|
||||||
|
try {
|
||||||
|
for (let i = 0; i < 60; 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; await sleep(500); }
|
||||||
|
browser = await chromium.launch();
|
||||||
|
// members: A and B have accounts on both sites, C only on InstantAdPay, D only on LinkSpin
|
||||||
|
const A = 'nsso-a@example.com', B = 'nsso-b@example.com', C = 'nsso-c@example.com', D = 'nsso-d@example.com';
|
||||||
|
const aI = await codeSignIn(IAP, A); await codeSignIn(LS, A);
|
||||||
|
const bL = await codeSignIn(LS, B); await codeSignIn(IAP, B);
|
||||||
|
const cI = await codeSignIn(IAP, C);
|
||||||
|
const dL = await codeSignIn(LS, D);
|
||||||
|
const codes0 = codeReqs();
|
||||||
|
|
||||||
|
// 1. IAP -> LinkSpin through the /go hop
|
||||||
|
let ctx = await newCtx({ iap: aI }); let page = await ctx.newPage();
|
||||||
|
await page.goto(IAP + '/go/linkspin?to=' + encodeURIComponent('/ads'));
|
||||||
|
await page.waitForLoadState('domcontentloaded');
|
||||||
|
let me = await meOf(ctx, LS);
|
||||||
|
ok(page.url() === LS + '/ads' && me.signedIn && me.email === A, 'IAP -> LinkSpin: lands on /ads signed in as the same member, no code', page.url() + ' ' + JSON.stringify({ s: me.signedIn, e: me.email }));
|
||||||
|
ok((await meOf(ctx, IAP)).email === A, 'IAP session untouched');
|
||||||
|
// sign-out on LinkSpin stays on LinkSpin, and the silent check does not sign them straight back in
|
||||||
|
await ctx.request.post(LS + '/api/auth/logout', { headers: { 'Content-Type': 'application/json' }, data: {} });
|
||||||
|
await page.goto(LS + '/ads'); await page.waitForTimeout(2500);
|
||||||
|
me = await meOf(ctx, LS);
|
||||||
|
ok(!me.signedIn && page.url() === LS + '/ads', 'signed out on LinkSpin: stays signed out there (no automatic sign-in back)', page.url());
|
||||||
|
ok((await meOf(ctx, IAP)).email === A, 'signing out of LinkSpin leaves InstantAdPay signed in');
|
||||||
|
// a deliberate link from IAP still signs them in after the sign-out
|
||||||
|
await page.goto(IAP + '/go/linkspin?to=' + encodeURIComponent('/credits?from=iap&task=refuel#refuel')); await page.waitForLoadState('domcontentloaded');
|
||||||
|
me = await meOf(ctx, LS);
|
||||||
|
ok(me.email === A && page.url() === LS + '/credits?from=iap&task=refuel#refuel', 'after a sign-out, a link from InstantAdPay signs in again and keeps the query and hash', page.url());
|
||||||
|
await ctx.close();
|
||||||
|
|
||||||
|
// 2. LinkSpin -> IAP through the /go hop (dashboard gets ?welcome=1, the step a code sign-in takes for the login ad)
|
||||||
|
ctx = await newCtx({ ls: bL }); page = await ctx.newPage();
|
||||||
|
const navs = []; page.on('framenavigated', f => { if (f === page.mainFrame()) navs.push(f.url()); });
|
||||||
|
await page.goto(LS + '/go/iap?to=' + encodeURIComponent('/my#engine')); await page.waitForLoadState('domcontentloaded');
|
||||||
|
me = await meOf(ctx, IAP);
|
||||||
|
ok(me.signedIn && me.email === B && navs.some(u => u.startsWith(IAP + '/my?welcome=1#engine')), 'LinkSpin -> IAP: lands on /my#engine signed in as the same member, no code', navs.slice(-2).join(' , '));
|
||||||
|
await ctx.close();
|
||||||
|
|
||||||
|
// 3. silent check: signed in on IAP, open a LinkSpin screen directly
|
||||||
|
ctx = await newCtx({ iap: aI }); page = await ctx.newPage();
|
||||||
|
await page.goto(LS + '/links'); await page.waitForURL(u => String(u).startsWith(LS + '/links'), { timeout: 15000 }); await page.waitForTimeout(2500);
|
||||||
|
me = await meOf(ctx, LS);
|
||||||
|
ok(me.email === A && page.url() === LS + '/links', 'silent check: a LinkSpin screen opened directly signs in through IAP', page.url());
|
||||||
|
await ctx.close();
|
||||||
|
// and the other way: signed in on LinkSpin, open the IAP dashboard
|
||||||
|
ctx = await newCtx({ ls: bL }); page = await ctx.newPage();
|
||||||
|
await page.goto(IAP + '/my'); await page.waitForTimeout(4000);
|
||||||
|
me = await meOf(ctx, IAP);
|
||||||
|
ok(me.email === B && page.url().startsWith(IAP + '/my'), 'silent check: the IAP sign-in page signs in through LinkSpin', page.url());
|
||||||
|
await ctx.close();
|
||||||
|
|
||||||
|
// 4. silent check, signed in nowhere: one bounce, then the normal sign-in; no second bounce on reload
|
||||||
|
ctx = await newCtx(); page = await ctx.newPage();
|
||||||
|
const starts = []; page.on('request', r => { if (r.url().includes('/sso/start')) starts.push(r.url()); });
|
||||||
|
await page.goto(LS + '/ads'); await page.waitForTimeout(3000);
|
||||||
|
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)');
|
||||||
|
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();
|
||||||
|
|
||||||
|
// 5. expired / absent session on the provider: signed out on IAP, the /go link is a plain link and LinkSpin asks for the code
|
||||||
|
const aI2 = await codeSignIn(IAP, A);
|
||||||
|
ctx = await newCtx({ iap: aI2 }); page = await ctx.newPage();
|
||||||
|
await ctx.request.post(IAP + '/api/auth/logout', { headers: { 'Content-Type': 'application/json' }, data: {} });
|
||||||
|
await page.goto(IAP + '/go/linkspin?to=%2Fads'); await page.waitForTimeout(2500);
|
||||||
|
ok(!(await meOf(ctx, LS)).signedIn && page.url() === LS + '/ads', 'signed out on IAP: /go/linkspin is a plain link, LinkSpin shows its sign-in', page.url());
|
||||||
|
await ctx.close();
|
||||||
|
// a session that expired on the provider: the check answers none
|
||||||
|
ctx = await newCtx({ iap: 'f'.repeat(64) }); page = await ctx.newPage();
|
||||||
|
await page.goto(LS + '/sso/start?mode=go&to=%2Fads'); await page.waitForTimeout(1500);
|
||||||
|
ok(!(await meOf(ctx, LS)).signedIn && page.url().startsWith(IAP + '/my'), 'an expired IAP session on a deliberate tap: IAP asks for its own sign-in first (2026-11-14)', page.url());
|
||||||
|
ok((await ctx.cookies(IAP)).some(c => c.name === 'nsso.back'), 'IAP remembers the unfinished trip while the member signs in');
|
||||||
|
await ctx.close();
|
||||||
|
|
||||||
|
// 6. not on the receiving site yet: C (IAP only) going to LinkSpin, D (LinkSpin only) going to IAP
|
||||||
|
ctx = await newCtx({ iap: cI }); page = await ctx.newPage();
|
||||||
|
await page.goto(IAP + '/go/linkspin?to=%2Fads'); await page.waitForSelector('#siEmail', { timeout: 10000 }); await page.waitForTimeout(1500);
|
||||||
|
ok(!(await meOf(ctx, LS)).signedIn && (await page.inputValue('#siEmail')) === C && (await page.locator('#nssoNote').count()) === 1, 'IAP member not on LinkSpin yet: LinkSpin sign-in with the email filled in, nothing signed', await page.inputValue('#siEmail'));
|
||||||
|
ok(!fs.readFileSync(path.join(TMP, 'ls', 'accounts.json'), 'utf8').includes(C), 'no LinkSpin account was created by the network sign-in');
|
||||||
|
await ctx.close();
|
||||||
|
ctx = await newCtx({ ls: dL }); page = await ctx.newPage();
|
||||||
|
await page.goto(LS + '/go/iap?to=%2Fmy'); await page.waitForTimeout(4000);
|
||||||
|
ok(!(await meOf(ctx, IAP)).signedIn && page.url().startsWith(IAP + '/my') && (await page.inputValue('#mcEmail').catch(() => '')) === D, 'LinkSpin member not on IAP yet: IAP sign-in with the email filled in, nothing signed', page.url() + ' ' + (await page.inputValue('#mcEmail').catch(() => '?')));
|
||||||
|
await ctx.close();
|
||||||
|
|
||||||
|
// 7. replay: walk the hops by hand, spend the token once, then try it again with the state cookie put back
|
||||||
|
const aI3 = await codeSignIn(IAP, A);
|
||||||
|
ctx = await newCtx({ iap: aI3 });
|
||||||
|
const hop = async url => { const r = await ctx.request.get(url, { maxRedirects: 0, headers: { 'User-Agent': UA, 'sec-fetch-dest': 'document' } }); return r.headers()['location'] || ''; };
|
||||||
|
let loc = await hop(LS + '/sso/start?mode=go&to=%2Fads');
|
||||||
|
const st = (await ctx.cookies(LS)).find(c => c.name === 'nsso.st');
|
||||||
|
loc = await hop(loc.startsWith('http') ? loc : LS + loc);
|
||||||
|
ok(/^http:\/\/localhost:\d+\/sso\/in\?t=v1\./.test(loc), 'provider minted a token for LinkSpin', loc.slice(0, 60));
|
||||||
|
const tokUrl = loc;
|
||||||
|
let land = await hop(tokUrl);
|
||||||
|
ok(land === '/ads' && (await meOf(ctx, LS)).email === A, 'first use signs in');
|
||||||
|
await ctx.request.post(LS + '/api/auth/logout', { headers: { 'Content-Type': 'application/json' }, data: {} });
|
||||||
|
await ctx.addCookies([{ name: 'nsso.st', value: st.value, domain: 'localhost', path: '/' }]);
|
||||||
|
land = await hop(tokUrl);
|
||||||
|
ok(!(await meOf(ctx, LS)).signedIn && /token already used/.test(logs.ls), 'the same token again is refused (replay), even with the state cookie put back', land);
|
||||||
|
// a token from a different browser (state cookie missing) is refused: login CSRF
|
||||||
|
const ctx2 = await newCtx({ iap: aI3 });
|
||||||
|
const r2 = await ctx2.request.get(LS + '/sso/start?mode=go&to=%2Fads', { maxRedirects: 0, headers: { 'sec-fetch-dest': 'document' } });
|
||||||
|
const l2 = await ctx2.request.get(r2.headers()['location'], { maxRedirects: 0 });
|
||||||
|
const other = await newCtx(); const r3 = await other.request.get(l2.headers()['location'], { maxRedirects: 0 });
|
||||||
|
ok(!(await meOf(other, LS)).signedIn && /refused: state/.test(logs.ls), 'a token opened in another browser (no matching state) is refused', r3.headers()['location']);
|
||||||
|
await ctx2.close(); await other.close();
|
||||||
|
// an expired token (minted by hand with a past clock) is refused
|
||||||
|
const require = createRequire(import.meta.url); process.env.NETWORK_SSO_SECRET = SECRET;
|
||||||
|
const N = require(path.join(IAP_DIR, 'networksso.js'));
|
||||||
|
const st2 = crypto.randomBytes(16).toString('hex');
|
||||||
|
await ctx.addCookies([{ name: 'nsso.st', value: st2, domain: 'localhost', path: '/' }]);
|
||||||
|
const old = N.mint({ iss: 'iap', aud: 'linkspin', email: A, st: st2, to: '/ads', now: Date.now() - 120000 });
|
||||||
|
await hop(LS + '/sso/in?t=' + old);
|
||||||
|
ok(!(await meOf(ctx, LS)).signedIn && /refused: expired/.test(logs.ls), 'an expired token is refused');
|
||||||
|
const forged = N.mint({ iss: 'iap', aud: 'linkspin', email: A, st: st2, to: '/ads' }).replace(/.$/, c => c === 'A' ? 'B' : 'A');
|
||||||
|
await ctx.addCookies([{ name: 'nsso.st', value: st2, domain: 'localhost', path: '/' }]); await hop(LS + '/sso/in?t=' + forged);
|
||||||
|
ok(!(await meOf(ctx, LS)).signedIn && /refused: signature/.test(logs.ls), 'a tampered token is refused');
|
||||||
|
// open redirect: an off-site path never leaves the site
|
||||||
|
const ev = await hop(IAP + '/go/linkspin?to=' + encodeURIComponent('https://evil.example/x'));
|
||||||
|
ok(ev === LS + '/sso/start?mode=go&to=%2F', '/go with an off-site path stays on the network', ev);
|
||||||
|
const ev2 = await ctx.request.get(LS + '/sso/in?none=1&to=' + encodeURIComponent('//evil.example'), { maxRedirects: 0 });
|
||||||
|
ok(ev2.headers()['location'] === '/ads', '/sso/in never redirects off the site', ev2.headers()['location']);
|
||||||
|
await ctx.close();
|
||||||
|
|
||||||
|
// 8. bots and API calls never bounce
|
||||||
|
const bot = await fetch(LS + '/sso/start?to=%2Fads', { redirect: 'manual', headers: { 'User-Agent': 'Googlebot/2.1 (+http://www.google.com/bot.html)' } });
|
||||||
|
ok(bot.headers.get('location') === '/ads' && !(bot.headers.getSetCookie ? bot.headers.getSetCookie() : []).length, 'a crawler on /sso/start goes straight to the page');
|
||||||
|
const bs = await (await fetch(IAP + '/api/sso/status', { headers: { 'User-Agent': 'Googlebot/2.1' } })).json();
|
||||||
|
ok(bs.check === false, 'a crawler is never told to check');
|
||||||
|
|
||||||
|
// 9. no email-code request was made by any network sign-in (only the setup code sign-ins above)
|
||||||
|
const total = codeReqs();
|
||||||
|
ok(total === codes0 + 4, 'no email-code request made by any network sign-in (server request log: only the 2 later setup sign-ins, start + verify each)', 'before ' + codes0 + ', after ' + total);
|
||||||
|
ok(!/sendCode|sendgrid/i.test(logs.iap + logs.ls), 'no mail send attempted on either server');
|
||||||
|
ok(/network-sso signed in from InstantAdPay n\*\*\*@example\.com/.test(logs.ls) && /network-sso signed in from LinkSpin n\*\*\*@example\.com/.test(logs.iap), 'successes logged with the email masked');
|
||||||
|
ok(!logs.iap.includes(SECRET) && !logs.ls.includes(SECRET) && !/nsso-a@example\.com/.test((logs.iap + logs.ls).split('\n').filter(l => l.includes('network-sso')).join('\n')), 'no secret and no full email in the network sign-in log lines');
|
||||||
|
} catch (e) { console.log('FAIL exception', e && e.stack || e); fails++; }
|
||||||
|
finally {
|
||||||
|
try { if (browser) await browser.close(); } catch (e) {}
|
||||||
|
try { srvI.kill(); } catch (e) {} try { srvL.kill(); } 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 (network-sso / errors)\n' + logs[k].split('\n').filter(l => /network-sso|error|Error/.test(l)).slice(-25).join('\n')); }
|
||||||
|
console.log(fails ? '\n' + fails + ' FAILED' : '\nALL PASSED'); process.exit(fails ? 1 : 0);
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
// Network sign-in (InstantAdPay <-> LinkSpin, 2026-11-12): unit test of networksso.js. Same file in both repos. node qa/networksso.test.cjs
|
||||||
|
// Token sign/verify, expiry, clock skew, tamper, wrong audience, state binding, replay, the secret switch, open redirects,
|
||||||
|
// bots, and the route handler with fake requests (no server, no network, throwaway DATA_DIR).
|
||||||
|
'use strict';
|
||||||
|
const fs = require('fs'), os = require('os'), path = require('path'), crypto = require('crypto');
|
||||||
|
process.env.NETWORK_SSO_SECRET = 'u'.repeat(48);
|
||||||
|
const N = require('../networksso.js');
|
||||||
|
let fails = 0; const ok = (c, label, extra) => { console.log((c ? 'PASS ' : 'FAIL ') + label + (extra ? ' ' + extra : '')); if (!c) fails++; };
|
||||||
|
const DATA = fs.mkdtempSync(path.join(os.tmpdir(), 'nsso-unit-'));
|
||||||
|
const st = crypto.randomBytes(16).toString('hex');
|
||||||
|
const b64u = b => Buffer.from(b).toString('base64').replace(/=+$/, '').replace(/\+/g, '-').replace(/\//g, '_');
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
const sessions = { 'tok-a': { email: 'a@example.com' } };
|
||||||
|
const accounts = new Set(['a@example.com']);
|
||||||
|
const signedIn = [];
|
||||||
|
N.init({ self: 'iap', peer: 'linkspin', peerBase: () => 'https://ls.example', isProd: true, dataDir: DATA, db: null, defaultPath: '/my',
|
||||||
|
member: async req => sessions[(/sid=([^;]+)/.exec(req.headers.cookie || '') || [])[1]] || null,
|
||||||
|
accept: async e => accounts.has(e) ? { ok: true } : { fallback: 'no account here yet' },
|
||||||
|
signIn: async e => { signedIn.push(e); return 'iap.sid=new; Path=/; HttpOnly'; },
|
||||||
|
landing: to => to, signinPath: to => '/my' });
|
||||||
|
|
||||||
|
// ---- tokens ----
|
||||||
|
const t = N.mint({ iss: 'linkspin', aud: 'iap', email: 'A@Example.com', st, to: '/my#buy' });
|
||||||
|
let v = N.verify(t, { iss: 'linkspin', aud: 'iap', st });
|
||||||
|
ok(v.ok && v.email === 'a@example.com' && v.to === '/my#buy', 'round trip: email (lower-cased) and path come back', JSON.stringify(v));
|
||||||
|
ok(/^v1\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]{43}$/.test(t), 'token format v1.<payload>.<hmac>');
|
||||||
|
ok(N.verify(t, { iss: 'linkspin', aud: 'linkspin', st }).error === 'audience', 'wrong audience refused');
|
||||||
|
ok(N.verify(t, { iss: 'iap', aud: 'iap', st }).error === 'audience', 'wrong issuer refused');
|
||||||
|
ok(N.verify(t, { iss: 'linkspin', aud: 'iap', st, now: Date.now() + 61000 }).error === 'expired', 'expired after 60 s');
|
||||||
|
ok(N.verify(t, { iss: 'linkspin', aud: 'iap', st, now: Date.now() + 55000 }).ok, 'still good at 55 s');
|
||||||
|
const fut = N.mint({ iss: 'linkspin', aud: 'iap', email: 'a@example.com', st, to: '/', now: Date.now() + 120000 });
|
||||||
|
ok(N.verify(fut, { iss: 'linkspin', aud: 'iap', st }).error === 'expired', 'issued too far in the future refused');
|
||||||
|
ok(N.verify(t, { iss: 'linkspin', aud: 'iap', st: crypto.randomBytes(16).toString('hex') }).error === 'state', 'state from another browser refused');
|
||||||
|
ok(N.verify(t, { iss: 'linkspin', aud: 'iap', st: '' }).error === 'state', 'missing state cookie refused');
|
||||||
|
const [, body, mac] = t.split('.');
|
||||||
|
const pl = JSON.parse(Buffer.from(body.replace(/-/g, '+').replace(/_/g, '/'), 'base64').toString()); pl.email = 'evil@example.com';
|
||||||
|
ok(N.verify('v1.' + b64u(JSON.stringify(pl)) + '.' + mac, { iss: 'linkspin', aud: 'iap', st }).error === 'signature', 'payload tampered (email swapped) refused');
|
||||||
|
ok(N.verify('v1.' + body + '.' + (mac[0] === 'A' ? 'B' : 'A') + mac.slice(1), { iss: 'linkspin', aud: 'iap', st }).error === 'signature', 'signature tampered refused');
|
||||||
|
const longer = JSON.parse(JSON.stringify(pl)); longer.email = 'a@example.com'; longer.exp = longer.iat + 3600000;
|
||||||
|
const forged = 'v1.' + b64u(JSON.stringify(longer)) + '.' + b64u(crypto.createHmac('sha256', process.env.NETWORK_SSO_SECRET).update('nsso.v1.' + b64u(JSON.stringify(longer))).digest());
|
||||||
|
ok(N.verify(forged, { iss: 'linkspin', aud: 'iap', st }).error === 'expired', 'a validly signed token with a life over 60 s is refused');
|
||||||
|
ok(N.verify('garbage', { iss: 'linkspin', aud: 'iap', st }).error === 'malformed' && N.verify('', { iss: 'linkspin', aud: 'iap', st }).error === 'malformed', 'garbage refused');
|
||||||
|
process.env.NETWORK_SSO_SECRET = 'w'.repeat(48);
|
||||||
|
ok(N.verify(t, { iss: 'linkspin', aud: 'iap', st }).error === 'signature', 'another secret refused');
|
||||||
|
process.env.NETWORK_SSO_SECRET = 'short';
|
||||||
|
ok(!N.enabled() && N.verify(t, { iss: 'linkspin', aud: 'iap', st }).error === 'off', 'secret under 32 characters = switched off');
|
||||||
|
process.env.NETWORK_SSO_SECRET = 'u'.repeat(48);
|
||||||
|
|
||||||
|
// ---- replay ----
|
||||||
|
ok(await N.spend(v.n, v.exp) === true, 'first use of a nonce is spent');
|
||||||
|
ok(await N.spend(v.n, v.exp) === false, 'second use of the same nonce refused (replay)');
|
||||||
|
ok(JSON.parse(fs.readFileSync(path.join(DATA, 'network-sso-nonces.json'), 'utf8'))[v.n] > 0, 'spent nonce kept on disk (survives a restart inside the window)');
|
||||||
|
|
||||||
|
// ---- open redirects ----
|
||||||
|
const bad = ['https://evil.example/x', '//evil.example/x', '/\\evil.example', '\\\\evil.example', 'javascript:alert(1)', '/x\r\nSet-Cookie: a=b', ' /my', '/my\t', 'http:/evil.example', '/' + 'a'.repeat(700), '', null];
|
||||||
|
ok(bad.every(b => N.safePath(b, '/my') === '/my'), 'off-site, protocol-relative, backslash, script, header-injection and over-long paths fall back to the default', bad.map(b => N.safePath(b, '/my')).filter(x => x !== '/my').join(' | '));
|
||||||
|
ok(N.safePath('/credits?from=iap&task=refuel#refuel') === '/credits?from=iap&task=refuel#refuel' && N.safePath('/my#buy') === '/my#buy', 'same-site paths with query and hash pass');
|
||||||
|
ok(N.safePath('/%2F%2Fevil.example') === '/%2F%2Fevil.example', 'an encoded // stays a path on this site');
|
||||||
|
const t2 = N.mint({ iss: 'linkspin', aud: 'iap', email: 'a@example.com', st, to: 'https://evil.example/' });
|
||||||
|
ok(N.verify(t2, { iss: 'linkspin', aud: 'iap', st }).to === '/', 'a token carrying an off-site path lands on /');
|
||||||
|
|
||||||
|
// ---- bots ----
|
||||||
|
const R = (url, cookie, ua, extra) => ({ method: 'GET', url, headers: Object.assign({ cookie: cookie || '', 'user-agent': ua === undefined ? 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/130 Safari/537.36' : ua }, extra || {}) });
|
||||||
|
ok(N.isBot(R('/', '', 'Googlebot/2.1')) && N.isBot(R('/', '', 'facebookexternalhit/1.1')) && N.isBot(R('/', '', '')) && N.isBot(R('/', '', 'Mozilla/5.0 HeadlessChrome/120')) && !N.isBot(R('/')), 'bots, previews, headless and empty agents are bots; a browser is not');
|
||||||
|
|
||||||
|
// ---- the handler ----
|
||||||
|
const call = async req => { let code = 0, h = {}, body = ''; const res = { writeHead: (c, hh) => { code = c; h = hh || {}; }, end: b => { body = b || ''; } };
|
||||||
|
const handled = await N.handle(req, res, new URL(req.url, 'http://x')); const set = [].concat(h['Set-Cookie'] || []); return { handled, code, loc: h.Location, set, body }; };
|
||||||
|
let r = await call(R('/go/linkspin?to=/ads'));
|
||||||
|
ok(r.code === 302 && r.loc === 'https://ls.example/ads', '/go signed out: a plain link to the other site');
|
||||||
|
r = await call(R('/go/linkspin?to=//evil.example', 'sid=tok-a'));
|
||||||
|
ok(r.loc === 'https://ls.example/sso/start?mode=go&to=%2F', '/go never forwards an off-site path', r.loc);
|
||||||
|
r = await call(R('/go/linkspin?to=/ads%3Fx%3D1', 'sid=tok-a'));
|
||||||
|
ok(r.loc === 'https://ls.example/sso/start?mode=go&to=%2Fads%3Fx%3D1', '/go signed in: through the other site\'s /sso/start', r.loc);
|
||||||
|
r = await call(R('/sso/start?to=/my', '', 'Googlebot/2.1'));
|
||||||
|
ok(r.loc === '/my' && !r.set.length, 'bot on /sso/start: no bounce, no cookies');
|
||||||
|
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');
|
||||||
|
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);
|
||||||
|
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'));
|
||||||
|
ok(r.loc === 'https://ls.example/sso/in?none=1&to=%2Fads', 'provider, signed out: none');
|
||||||
|
r = await call(R('/sso/check?st=nothex&to=/ads', 'sid=tok-a'));
|
||||||
|
ok(r.loc.includes('none=1'), 'provider: a malformed state gets none, never a token');
|
||||||
|
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');
|
||||||
|
// 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));
|
||||||
|
ok(r.loc === '/my#buy' && r.set.includes('iap.sid=new; Path=/; HttpOnly') && signedIn.length === 1, 'receiver: valid token -> session cookie, redirect to the path');
|
||||||
|
const once = mk('a@example.com', '/my');
|
||||||
|
r = await call(R('/sso/in?t=' + once, 'nsso.st=' + st)); r = await call(R('/sso/in?t=' + once, 'nsso.st=' + st));
|
||||||
|
ok(signedIn.length === 2 && !r.set.some(c => c.startsWith('iap.sid=')), 'receiver: the same token twice signs in once (replay refused)');
|
||||||
|
r = await call(R('/sso/in?t=' + mk('a@example.com', '/my'), 'nsso.st=' + crypto.randomBytes(16).toString('hex')));
|
||||||
|
ok(signedIn.length === 2 && r.loc === '/my', 'receiver: a token pushed into another browser (login CSRF) is refused');
|
||||||
|
r = await call(R('/sso/in?t=' + issued, 'nsso.st=' + st));
|
||||||
|
ok(signedIn.length === 2, 'receiver: a token minted FOR the other site is refused here');
|
||||||
|
r = await call(R('/sso/in?t=' + mk('new@example.com', '/my'), 'nsso.st=' + st));
|
||||||
|
ok(signedIn.length === 2 && r.loc === '/my' && r.set.some(c => /^nsso\.hint=new%40example\.com;.*HttpOnly/.test(c)), 'receiver: not a member here yet -> normal sign-in with the email kept for the form, nothing created');
|
||||||
|
r = await call(R('/sso/in?none=1&to=https://evil.example', 'nsso.st=' + st));
|
||||||
|
ok(r.loc === '/my' && r.set.some(c => /^nsso\.st=;/.test(c)), 'receiver: none -> the sign-in page, never an off-site path');
|
||||||
|
r = await call(R('/api/sso/status', 'nsso.hint=new%40example.com; nsso.tried=1'));
|
||||||
|
let j = JSON.parse(r.body); ok(j.hint === 'new@example.com' && j.check === false && r.set.some(c => /^nsso\.hint=;/.test(c)), '/api/sso/status hands the hint over once and clears it');
|
||||||
|
j = JSON.parse((await call(R('/api/sso/status'))).body); ok(j.check === true && j.peer === 'LinkSpin', '/api/sso/status: signed out, fresh browser -> check');
|
||||||
|
j = JSON.parse((await call(R('/api/sso/status', 'sid=tok-a'))).body); ok(j.check === false, '/api/sso/status: signed in -> no check');
|
||||||
|
j = JSON.parse((await call(R('/api/sso/status', '', 'Googlebot/2.1'))).body); ok(j.check === false, '/api/sso/status: bot -> no check');
|
||||||
|
process.env.NETWORK_SSO_SECRET = '';
|
||||||
|
r = await call(R('/go/linkspin?to=/ads', 'sid=tok-a')); ok(r.loc === 'https://ls.example/ads', 'secret not set: /go is a plain link');
|
||||||
|
j = JSON.parse((await call(R('/api/sso/status'))).body); ok(j.check === false, 'secret not set: no silent check');
|
||||||
|
ok(N.offCookie().startsWith('nsso.off=1;') && /Max-Age=43200/.test(N.offCookie()), 'sign-out cookie pauses the silent check 12 hours');
|
||||||
|
ok(!(await call({ method: 'POST', url: '/sso/in', headers: {} })).handled, 'non-GET requests are not handled');
|
||||||
|
})().catch(e => { console.log('FAIL exception', e && e.stack || e); fails++; }).finally(() => {
|
||||||
|
try { fs.rmSync(DATA, { recursive: true, force: true }); } catch (e) {}
|
||||||
|
console.log(fails ? '\n' + fails + ' FAILED' : '\nALL PASSED'); process.exitCode = fails ? 1 : 0;
|
||||||
|
});
|
||||||
@@ -2,20 +2,24 @@
|
|||||||
# InstantAdPay QA harness runner. From the site dir:
|
# InstantAdPay QA harness runner. From the site dir:
|
||||||
# bash qa/run.sh public # live public pages only (no local server)
|
# bash qa/run.sh public # live public pages only (no local server)
|
||||||
# bash qa/run.sh member # local copy: member + admin walk
|
# bash qa/run.sh member # local copy: member + admin walk
|
||||||
|
# bash qa/run.sh sso # network sign-in InstantAdPay <-> LinkSpin: unit + both servers end to end (NSSO_PEER_DIR = the other repo's site dir if not side by side; also runs in member)
|
||||||
# bash qa/run.sh earn # local copy: earning flows end to end (~2-3 min)
|
# bash qa/run.sh earn # local copy: earning flows end to end (~2-3 min)
|
||||||
# bash qa/run.sh all # public + member + earn
|
# bash qa/run.sh all # public + member + earn
|
||||||
# bash qa/run.sh kb # chat knowledge base: retrieval unit test + chat endpoint e2e on a local copy with a mock OpenRouter
|
# bash qa/run.sh kb # chat knowledge base: retrieval unit test + chat endpoint e2e on a local copy with a mock OpenRouter
|
||||||
# bash qa/run.sh walletnudge # game wallet push (any linked wallet, activated or not) + no-wallet nudge copy against a mock game (also runs in member)
|
# bash qa/run.sh walletnudge # game wallet push (any linked wallet, activated or not) + no-wallet nudge copy against a mock game (also runs in member)
|
||||||
|
# bash qa/run.sh draft # 5xYourTeam The Draft partner routes: pool / adopt / release / status rules on the real tank.js (mocked clock, fake hub) + the signed HTTP routes on a local copy (also runs in member)
|
||||||
# bash qa/run.sh tankhold # holding-tank activation hold, 24-hour safety net (mocked clock) and LinkSpin alignment: unit + local copy (also runs in member)
|
# bash qa/run.sh tankhold # holding-tank activation hold, 24-hour safety net (mocked clock) and LinkSpin alignment: unit + local copy (also runs in member)
|
||||||
# bash qa/run.sh sponsorfollow # sponsor follow rule + network tank unit tests and the two-server e2e (local IAP + local LinkSpin, throwaway data)
|
# bash qa/run.sh sponsorfollow # sponsor follow rule + network tank unit tests and the two-server e2e (local IAP + local LinkSpin, throwaway data)
|
||||||
# bash qa/run.sh door # Spooky Doors door + costume shop flows on their own local copy (qa/door.mjs boots it)
|
# bash qa/run.sh door # Spooky Doors door + costume shop flows on their own local copy (qa/door.mjs boots it)
|
||||||
# bash qa/run.sh warpwares # Warp & Wares: Games card gating, the hand-off, a sponsor dock on the refuel rail (visit kind dock + its cap), chatbot gating (qa/warpwares.mjs boots a local copy + a mock game)
|
# bash qa/run.sh warpwares # Warp & Wares: Games card gating, the hand-off, a sponsor dock on the refuel rail (visit kind dock + its cap), chatbot gating (qa/warpwares.mjs boots a local copy + a mock game)
|
||||||
# bash qa/run.sh gamepass # Game Pass buy flow + account-wide POL caps (polgrant) on their own local copy (qa/gamepass.mjs boots it)
|
# bash qa/run.sh gamepass # Game Pass buy flow + account-wide POL caps (polgrant) on their own local copy (qa/gamepass.mjs boots it)
|
||||||
|
# bash qa/run.sh sov-passes # (+ qa/sov-heroes-store.cjs: Shards of Valor bonus heroes sold one time, also runs in member)
|
||||||
# bash qa/run.sh sov-passes # pass tiers (Explorer/Champion/Sovereign/Legend): store unit checks + admin buys Explorer + Sovereign with seeded purchased credits on a local copy (screenshots D:/tmp/sov-passes)
|
# bash qa/run.sh sov-passes # pass tiers (Explorer/Champion/Sovereign/Legend): store unit checks + admin buys Explorer + Sovereign with seeded purchased credits on a local copy (screenshots D:/tmp/sov-passes)
|
||||||
# bash qa/run.sh nas # Network Ad Space billing: served-count trap, stopped-ad restart (no phantom delivery), the 1/N network rate + PassiveDrip partner visits (stubbed NAS, throwaway data)
|
# bash qa/run.sh nas # Network Ad Space billing: served-count trap, stopped-ad restart (no phantom delivery), the 1/N network rate + PassiveDrip partner visits (stubbed NAS, throwaway data)
|
||||||
# bash qa/run.sh login-queue # prepaid login-ad line: JSON store end to end + the MySQL path's lease/guard logic against a fake SQL layer (no server, throwaway data)
|
# bash qa/run.sh login-queue # prepaid login-ad line: JSON store end to end + the MySQL path's lease/guard logic against a fake SQL layer (no server, throwaway data)
|
||||||
# bash qa/run.sh gamepass-games # the REAL games' polgrant.js + PolHunter's tournament payer against a local copy (needs the sibling game repos)
|
# bash qa/run.sh gamepass-games # the REAL games' polgrant.js + PolHunter's tournament payer against a local copy (needs the sibling game repos)
|
||||||
# bash qa/run.sh override # level-4 override: week math, hunt, house, dust carry, cap, balance, two concurrent payers (fake chain + signer, throwaway data)
|
# bash qa/run.sh override # level-4 override: week math, hunt, house, dust carry, cap, balance, two concurrent payers (fake chain + signer, throwaway data)
|
||||||
|
# bash qa/run.sh netconv # conversion linkage end to end: spin link -> join -> wallet -> a Purchase on a mock chain, local InstantAdPay + local LinkSpin, LinkSpin down, own account, two copies racing
|
||||||
# bash qa/run.sh convpixel # conversion pixel: lsclk click ids on /api/ads/click, signed push to a MOCK LinkSpin, own-click self flag, Campaigns > Conversion tracking + cost per goal, LinkSpin down (local copy, throwaway data)
|
# bash qa/run.sh convpixel # conversion pixel: lsclk click ids on /api/ads/click, signed push to a MOCK LinkSpin, own-click self flag, Campaigns > Conversion tracking + cost per goal, LinkSpin down (local copy, throwaway data)
|
||||||
# bash qa/run.sh fuel # Fuel Your Offers: refill notices, refuel streak, Refuel Kit, Engine Room (unit + two-copy tests, throwaway data)
|
# bash qa/run.sh fuel # Fuel Your Offers: refill notices, refuel streak, Refuel Kit, Engine Room (unit + two-copy tests, throwaway data)
|
||||||
# bash qa/run.sh policy # profile policy + link-farm scan: prohibited list, bio links, quarantine, 06:30 claim, walls of free/paying members, 404 walls (unit + local copy; also runs in member)
|
# bash qa/run.sh policy # profile policy + link-farm scan: prohibited list, bio links, quarantine, 06:30 claim, walls of free/paying members, 404 walls (unit + local copy; also runs in member)
|
||||||
@@ -59,18 +63,29 @@ syntax_gate
|
|||||||
if [ "$MODE" = "public" ]; then
|
if [ "$MODE" = "public" ]; then
|
||||||
node qa/walk.mjs public || status=1
|
node qa/walk.mjs public || status=1
|
||||||
node qa/chatbot-sync.mjs || status=1
|
node qa/chatbot-sync.mjs || status=1
|
||||||
|
elif [ "$MODE" = "sso" ]; then
|
||||||
|
node qa/networksso.test.cjs || status=1
|
||||||
|
node qa/networksso.e2e.mjs || status=1
|
||||||
elif [ "$MODE" = "member" ]; then
|
elif [ "$MODE" = "member" ]; then
|
||||||
start_local 8796 && { LOCAL=http://127.0.0.1:8796 node qa/walk.mjs member || status=1; }; stop_local 8796
|
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/tank-hold.mjs || status=1
|
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
|
node qa/walletnudge.test.cjs || status=1
|
||||||
node qa/bixpay.test.cjs || status=1
|
node qa/bixpay.test.cjs || status=1
|
||||||
node qa/profile-policy.test.cjs || status=1
|
node qa/profile-policy.test.cjs || status=1
|
||||||
|
node qa/sov-heroes-store.cjs || status=1
|
||||||
|
elif [ "$MODE" = "draft" ]; then
|
||||||
|
node qa/draft-partner.test.mjs || status=1
|
||||||
elif [ "$MODE" = "theme" ]; then
|
elif [ "$MODE" = "theme" ]; then
|
||||||
start_local 8797 && { LOCAL=http://127.0.0.1:8797 node qa/theme-contrast.mjs || status=1; }; stop_local 8797
|
start_local 8797 && { LOCAL=http://127.0.0.1:8797 node qa/theme-contrast.mjs || status=1; }; stop_local 8797
|
||||||
elif [ "$MODE" = "policy" ]; then
|
elif [ "$MODE" = "policy" ]; then
|
||||||
node qa/profile-policy.test.cjs || status=1
|
node qa/profile-policy.test.cjs || status=1
|
||||||
elif [ "$MODE" = "bixpay" ]; then
|
elif [ "$MODE" = "bixpay" ]; then
|
||||||
node qa/bixpay.test.cjs || status=1
|
node qa/bixpay.test.cjs || status=1
|
||||||
|
elif [ "$MODE" = "hub" ]; then
|
||||||
|
node qa/hubsync.test.cjs || status=1 # needs the network-hub checkout beside this repo (HUB_DIR to override)
|
||||||
elif [ "$MODE" = "walletnudge" ]; then
|
elif [ "$MODE" = "walletnudge" ]; then
|
||||||
node qa/walletnudge.test.cjs || status=1
|
node qa/walletnudge.test.cjs || status=1
|
||||||
elif [ "$MODE" = "tankhold" ]; then
|
elif [ "$MODE" = "tankhold" ]; then
|
||||||
@@ -89,6 +104,7 @@ elif [ "$MODE" = "gamepass" ]; then
|
|||||||
node qa/gamepass.mjs || status=1
|
node qa/gamepass.mjs || status=1
|
||||||
elif [ "$MODE" = "sov-passes" ]; then
|
elif [ "$MODE" = "sov-passes" ]; then
|
||||||
node qa/sov-passes-store.cjs || status=1
|
node qa/sov-passes-store.cjs || status=1
|
||||||
|
node qa/sov-heroes-store.cjs || status=1
|
||||||
node qa/sov-passes-local.mjs || status=1
|
node qa/sov-passes-local.mjs || status=1
|
||||||
elif [ "$MODE" = "nas" ]; then
|
elif [ "$MODE" = "nas" ]; then
|
||||||
node qa/nas-served.mjs || status=1
|
node qa/nas-served.mjs || status=1
|
||||||
@@ -97,6 +113,8 @@ elif [ "$MODE" = "nas" ]; then
|
|||||||
elif [ "$MODE" = "login-queue" ]; then
|
elif [ "$MODE" = "login-queue" ]; then
|
||||||
node qa/login-queue.cjs || status=1
|
node qa/login-queue.cjs || status=1
|
||||||
node qa/login-queue-sql.cjs || status=1
|
node qa/login-queue-sql.cjs || status=1
|
||||||
|
elif [ "$MODE" = "netconv" ]; then
|
||||||
|
node qa/netconv.test.mjs || status=1
|
||||||
elif [ "$MODE" = "convpixel" ]; then
|
elif [ "$MODE" = "convpixel" ]; then
|
||||||
node qa/convpixel.test.mjs || status=1
|
node qa/convpixel.test.mjs || status=1
|
||||||
elif [ "$MODE" = "fuel" ]; then
|
elif [ "$MODE" = "fuel" ]; then
|
||||||
|
|||||||
@@ -0,0 +1,103 @@
|
|||||||
|
// Shards of Valor bonus heroes (2026-11-05, Marty approved): unit checks of the gamepass.js hero store, no server.
|
||||||
|
// node qa/sov-heroes-store.cjs
|
||||||
|
// Sold ONE TIME, paid exactly like a pass: buy opens a waiting order; a FRESH package of at least the price, by one of the member's own
|
||||||
|
// positions, fulfils it. Covers: the heroSales switch (off refuses members, the admin test may buy), $20 each / $50 bundle (Valda, Morag,
|
||||||
|
// Roland by default), order -> fulfil -> ownership (permanent, no expiry), the bundle grants all three, no double charge (owned hero
|
||||||
|
// refused, a waiting order for an owned hero cancelled, each tx once, one package one order), packages bought before the order or too
|
||||||
|
// small, a pass order and a hero order side by side, settings (price 0 = free for everyone, bundle list), the hand-off claim (heroes,
|
||||||
|
// heroBundle, heroSale, heroBundleCap only when set), comp / revoke, stats, and that hero sales never touch the pass records.
|
||||||
|
// 2026-11-14 (Marty approved): Kestrel is free in the game at level 20, so she is never sold here (no buy, never in a bundle, a waiting
|
||||||
|
// Kestrel order is cancelled unpaid); a member who bought her before keeps her. Exit 1 on failure.
|
||||||
|
'use strict';
|
||||||
|
const fs = require('fs'); const os = require('os'); const path = require('path');
|
||||||
|
const gp = require('../gamepass');
|
||||||
|
let fails = 0; const ok = (c, label, extra) => { console.log((c ? 'PASS ' : 'FAIL ') + label + (extra ? ' ' + extra : '')); if (!c) fails++; };
|
||||||
|
const SC = { gamePassEnabled: '1', sovTiers: '0', heroSales: '0', capsStartDate: '2026-10-01' };
|
||||||
|
const maps = {};
|
||||||
|
gp.init({ dataDir: fs.mkdtempSync(path.join(os.tmpdir(), 'iap-heroes-')), siteConfig: () => Object.assign({}, SC), persistedMap: k => (maps[k] = maps[k] || new Map()), isProd: false,
|
||||||
|
accounts: { byMemberId: async () => null, byEmail: async () => null }, marks: { claim: async () => true }, polUsd: async () => 0.1, telegram: async () => {}, notify: async () => {} });
|
||||||
|
const passes = maps.gamepass, orders = maps.gporders;
|
||||||
|
const T0 = Date.parse('2026-11-05T19:00:00Z');
|
||||||
|
let txN = 0;
|
||||||
|
const pkg = (email, cents, at, tx) => gp.onEvent({ type: 'Purchase', priceCents: cents, tx: tx || ('0xhero' + (++txN)), ts: at, devEmail: email, devMinedAt: at, devNow: at });
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
// 1. defaults and the switch
|
||||||
|
const c = gp.cfg().heroes;
|
||||||
|
ok(c.sale === false && c.price.kestrel === 2000 && c.price.valda === 2000 && c.price.morag === 2000 && c.price.roland === 2000 && c.bundle.price === 5000 && c.bundle.heroes.join() === 'valda,morag,roland' && c.cap === null && c.free.length === 0,
|
||||||
|
'defaults: heroSales off, $20 each, $50 bundle of Valda + Morag + Roland, no bundle cap, nothing free', JSON.stringify(c));
|
||||||
|
let r = gp.buyHero('m@x.com', T0, 'kestrel'); ok(r.error === 'Bonus heroes are not on sale yet.', 'heroSales off: a member is refused', JSON.stringify(r));
|
||||||
|
ok(![...orders.values()].length, 'a refused buy opens no order');
|
||||||
|
let v = gp.view('m@x.com', T0).heroes; ok(v.show === false && v.items.every(i => !i.open), 'heroSales off: the member card hides the heroes', JSON.stringify(v.items.map(i => i.open)));
|
||||||
|
v = gp.view('admin@x.com', T0, { preview: true }).heroes; ok(v.show && v.preview && v.items.filter(i => !i.freeAt).every(i => i.open) && v.items.find(i => i.key === 'kestrel').freeAt === 20 && !v.items.find(i => i.key === 'kestrel').open && v.bundle.open && v.items.map(i => i.package).join() === '20,20,20,20' && v.bundle.package === 50, 'the admin preview: every sold hero open (Kestrel shown free at 20, not open), $20 packages, the bundle on the $50 package', JSON.stringify(v));
|
||||||
|
r = gp.buyHero('admin@x.com', T0, 'roland', { preview: true }); ok(r.needPay && r.price === 2000 && r.package === 20 && /Roland the Paladin joins you in Shards of Valor/.test(r.message) && !/—/.test(r.message), 'the admin test opens a $20 order', JSON.stringify(r));
|
||||||
|
r = gp.cancelHeroOrder('admin@x.com', 'roland'); ok(r.ok && r.order, 'the admin cancels the test order');
|
||||||
|
ok(!(await pkg('admin@x.com', 2000, T0 + 1000)), 'a cancelled order is never fulfilled later');
|
||||||
|
|
||||||
|
// 2. on sale: Kestrel is never sold (free at 20 in the game); a past Kestrel buyer keeps her; a waiting Kestrel order is cancelled unpaid
|
||||||
|
SC.heroSales = '1';
|
||||||
|
r = gp.buyHero('m@x.com', T0, 'kestrel'); ok(/Kestrel the Archer is free for every player at level 20 in Shards of Valor, so she is not for sale\./.test(r.error || '') && !/\u2014/.test(r.error), 'Kestrel is refused: free at level 20', JSON.stringify(r));
|
||||||
|
ok(![...orders.values()].some(o => o.hero === 'kestrel' && o.status === 'waiting'), 'no Kestrel order opened');
|
||||||
|
passes.set('k@x.com', { until: 0, bought: [], heroes: { kestrel: { ts: T0 - 86400000, via: 'package', tx: '0xoldkes', cents: 2000, usd: 20 } } });
|
||||||
|
ok(gp.heroesOwned('k@x.com').owned.join() === 'kestrel' && gp.heroClaim('k@x.com').heroes.join() === 'kestrel', 'a member who bought Kestrel before keeps her (the hand-off still says so)');
|
||||||
|
v = gp.view('k@x.com', T0).heroes; ok(v.items.find(i => i.key === 'kestrel').owned && v.show, 'her card says Yours for good');
|
||||||
|
orders.set('hero-oldkes', { status: 'waiting', kind: 'hero', hero: 'kestrel', email: 'w@x.com', ts: T0 });
|
||||||
|
ok(!(await pkg('w@x.com', 2000, T0 + 1000)), 'a Kestrel order from before the change is never fulfilled');
|
||||||
|
ok(orders.get('hero-oldkes').status === 'cancelled' && /free at level 20/.test(orders.get('hero-oldkes').why || ''), 'and it is cancelled unpaid', JSON.stringify(orders.get('hero-oldkes')));
|
||||||
|
ok(gp.heroesOwned('w@x.com').owned.length === 0, 'nothing granted for it');
|
||||||
|
// one sold hero: order then a fresh package
|
||||||
|
r = gp.buyHero('m@x.com', T0, 'roland'); ok(r.needPay && r.payUrl.includes('#buy') && r.usd === 20, 'on sale: buy opens a waiting order, no charge', JSON.stringify(r));
|
||||||
|
const r2 = gp.buyHero('m@x.com', T0 + 10, 'roland'); ok(r2.reused && r2.order === r.order, 'a second click reuses the same order');
|
||||||
|
ok(!(await pkg('m@x.com', 2000, T0 - 60000)), 'a package bought before the order does not fulfil it');
|
||||||
|
ok(!(await pkg('m@x.com', 1000, T0 + 1000)), 'a $10 package is too small');
|
||||||
|
let ev = await pkg('m@x.com', 2000, T0 + 2000, '0xrol1');
|
||||||
|
ok(ev && ev.hero === 'roland' && ev.heroes.join() === 'roland', 'a fresh $20 package fulfils it', JSON.stringify(ev));
|
||||||
|
ok(gp.heroesOwned('m@x.com').owned.join() === 'roland', 'Roland is owned');
|
||||||
|
ok(!(await pkg('m@x.com', 2000, T0 + 3000, '0xrol1')), 'the same tx never counts twice');
|
||||||
|
r = gp.buyHero('m@x.com', T0 + 4000, 'roland'); ok(/already have Roland/.test(r.error || ''), 'no double charge: an owned hero is refused', JSON.stringify(r));
|
||||||
|
const rec = passes.get('m@x.com'); ok(rec.heroes.roland.tx === '0xrol1' && rec.heroes.roland.via === 'package' && rec.heroes.roland.usd === 20 && !rec.heroes.roland.until && !(rec.bought || []).length && !rec.tiers, 'stored for good (no expiry), never as a pass sale', JSON.stringify(rec));
|
||||||
|
ok(gp.flag('m@x.com', T0).active === false, 'a hero is not a Game Pass');
|
||||||
|
ok(gp.heroesOwned('m@x.com').owned.includes('roland') && gp.heroesOwned('m@x.com', T0 + 3650 * 86400000).owned.includes('roland'), 'owned years later too');
|
||||||
|
|
||||||
|
// 3. the bundle: all three, and its refusals
|
||||||
|
r = gp.buyHero('k@x.com', T0, 'bundle'); ok(r.needPay && r.price === 5000 && r.package === 50 && /Valda the Barbarian, Morag the Druid, Roland the Paladin/.test(r.message), 'a Kestrel owner may buy the bundle (Kestrel is not in it)', JSON.stringify(r));
|
||||||
|
ok(!(await pkg('k@x.com', 2000, T0 + 5000)), 'a $20 package does not pay the $50 bundle');
|
||||||
|
ev = await pkg('k@x.com', 5000, T0 + 6000);
|
||||||
|
ok(ev && ev.hero === 'bundle' && ev.heroes.join() === 'valda,morag,roland', 'a $50 package fulfils the bundle: all three', JSON.stringify(ev));
|
||||||
|
ok(gp.heroesOwned('k@x.com').owned.join() === 'kestrel,valda,morag,roland' && gp.heroesOwned('k@x.com').bundle, 'four owned, bundle flag set');
|
||||||
|
r = gp.buyHero('k@x.com', T0, 'bundle'); ok(/already have/.test(r.error || ''), 'the bundle twice: refused');
|
||||||
|
r = gp.buyHero('n@x.com', T0, 'morag'); await pkg('n@x.com', 2000, T0 + 100); r = gp.buyHero('n@x.com', T0 + 200, 'bundle');
|
||||||
|
ok(/already have Morag the Druid, so the bundle is not for you/.test(r.error || ''), 'a member who owns one bundle hero is sent to buy the rest one at a time', JSON.stringify(r));
|
||||||
|
|
||||||
|
// 4. a waiting order made pointless by a bundle is cancelled (no second charge); one package fulfils one order
|
||||||
|
gp.buyHero('o@x.com', T0, 'valda'); gp.buyHero('o@x.com', T0 + 1, 'bundle');
|
||||||
|
ev = await pkg('o@x.com', 5000, T0 + 1000); ok(ev && ev.hero === 'bundle', 'a $50 package picks the highest-priced order it covers (the bundle)', JSON.stringify(ev));
|
||||||
|
ok(![...orders.values()].some(o => o.email === 'o@x.com' && o.status === 'waiting'), 'the Valda order is cancelled: Valda came with the bundle');
|
||||||
|
ok(!(await pkg('o@x.com', 2000, T0 + 2000)), 'a later package charges nothing more for her');
|
||||||
|
// a pass order and a hero order side by side: each package fulfils one
|
||||||
|
gp.buy('p@x.com', T0, 'weekly'); gp.buyHero('p@x.com', T0, 'roland');
|
||||||
|
const e1 = await pkg('p@x.com', 2000, T0 + 1000), e2 = await pkg('p@x.com', 500, T0 + 2000);
|
||||||
|
ok(e1 && e1.hero === 'roland' && e2 && e2.tier === 'weekly' && gp.flag('p@x.com', T0 + 3000).active, 'a $20 package pays the hero, a $5 package the weekly pass', JSON.stringify({ e1, e2 }));
|
||||||
|
|
||||||
|
// 5. settings: price 0 = free for every account; bundle list
|
||||||
|
SC.heroPriceRolandCents = '0';
|
||||||
|
ok(gp.heroesOwned('nobody@x.com').owned.join() === 'roland', 'Roland priced 0: owned by every account');
|
||||||
|
r = gp.buyHero('q@x.com', T0, 'roland'); ok(/free for everyone/.test(r.error || ''), 'a free hero is never sold');
|
||||||
|
let claim = gp.heroClaim('nobody@x.com'); ok(claim.heroes.join() === 'roland' && claim.heroSale.free.join() === 'roland' && claim.heroBundle === false && !('heroBundleCap' in claim), 'the hand-off says Roland is free (the game opens him for guests too)', JSON.stringify(claim));
|
||||||
|
delete SC.heroPriceRolandCents; SC.heroBundleHeroes = 'valda,morag';
|
||||||
|
ok(gp.cfg().heroes.bundle.heroes.join() === 'valda,morag', 'the bundle list is a setting');
|
||||||
|
SC.heroBundleHeroes = 'kestrel,valda,morag';
|
||||||
|
ok(gp.cfg().heroes.bundle.heroes.join() === 'valda,morag', 'a bundle setting naming Kestrel drops her (free at 20, never sold)');
|
||||||
|
delete SC.heroBundleHeroes;
|
||||||
|
|
||||||
|
// 6. the hand-off claim and the bundle cap (unset by default; only for bundle owners once set)
|
||||||
|
claim = gp.heroClaim('k@x.com'); ok(claim.heroes.join() === 'kestrel,valda,morag,roland' && claim.heroBundle === true && !('heroBundleCap' in claim) && claim.heroSale.bundle.join() === 'valda,morag,roland' && claim.heroSale.each === 20 && claim.heroSale.bundlePrice === 50, 'claim: owned heroes, bundle, sale; no cap', JSON.stringify(claim));
|
||||||
|
SC.heroBundleCap = '40'; ok(gp.heroClaim('k@x.com').heroBundleCap === 40 && !('heroBundleCap' in gp.heroClaim('n@x.com')), 'heroBundleCap set: only bundle owners carry it'); delete SC.heroBundleCap;
|
||||||
|
|
||||||
|
// 7. comp, revoke, stats
|
||||||
|
r = gp.compHero('z@x.com', 'valda', 'admin hero test'); ok(r.ok && gp.heroesOwned('z@x.com').owned.join() === 'valda', 'comp grants a hero');
|
||||||
|
r = gp.revokeHero('z@x.com', 'valda', 'admin hero test'); ok(r.ok && !gp.heroesOwned('z@x.com').owned.length, 'revoke takes it back (support only)');
|
||||||
|
const st = gp.heroStats(); ok(st.sold.kestrel === 1 && st.sold.valda === 2 && st.sold.morag === 3 && st.sold.roland === 4 && st.bundles === 2 && st.usd === 180 && st.comped === 0 && st.waiting === 0, 'stats: per hero, bundles, dollars (4 x $20 incl. the old Kestrel sale + 2 x $50 = $180), no waiting order', JSON.stringify(st));
|
||||||
|
const ps = gp.adminStats(T0 + 3000).passes; ok(ps.soldTotal === 1 && ps.usdTotal === 5, 'pass stats count only the weekly pass (no hero in the pass pool)', JSON.stringify(ps));
|
||||||
|
console.log(fails ? '\n' + fails + ' FAILED' : '\nALL PASSED'); process.exit(fails ? 1 : 0);
|
||||||
|
})().catch(e => { console.error(e); process.exit(1); });
|
||||||
@@ -123,7 +123,7 @@ try {
|
|||||||
await page.fill('#adEmail', ADMIN_EMAIL); await page.click('#adSend'); await page.waitForSelector('#adVerify:not([hidden])'); await page.click('#adVerify'); await sleep(1200);
|
await page.fill('#adEmail', ADMIN_EMAIL); await page.click('#adSend'); await page.waitForSelector('#adVerify:not([hidden])'); await page.click('#adVerify'); await sleep(1200);
|
||||||
const nav = await page.$('.bo-menu [data-pane="gamepass"]'); if (nav) { await nav.click(); await page.waitForSelector('#gpTest [data-gpt-buy="explorer"]', { timeout: 10000 }).catch(() => {}); }
|
const nav = await page.$('.bo-menu [data-pane="gamepass"]'); if (nav) { await nav.click(); await page.waitForSelector('#gpTest [data-gpt-buy="explorer"]', { timeout: 10000 }).catch(() => {}); }
|
||||||
let txt = await page.textContent('#gpTest').catch(() => '');
|
let txt = await page.textContent('#gpTest').catch(() => '');
|
||||||
ok(/Test \/ preview, admin only/.test(txt) && /hidden from members/.test(txt) && /Sovereign/.test(txt) && /Necromancer/.test(txt) && /Legend/.test(txt) && /\$250 /.test(txt) && /for 1 year/.test(txt) && /Archer/.test(txt) && /Druid/.test(txt) && /level cap 30/.test(txt) && /\$20 /.test(txt) && !/\.99/.test(txt) && /Shards of Valor > Passes/.test(txt) && !/\u2014/.test(txt) && errs.length === 0, 'Admin > Game Pass > Tier test and preview: labelled test/preview, all five tiers with what each includes, no em dashes', errs.join(' | ') || (nav ? '' : 'admin nav not found'));
|
ok(/Test \/ preview, admin only/.test(txt) && /hidden from members/.test(txt) && /Sovereign/.test(txt) && /Roland the Paladin/.test(txt) && /heroSales off/.test(txt) && /Legend/.test(txt) && /\$250 /.test(txt) && /for 1 year/.test(txt) && /Archer/.test(txt) && /Druid/.test(txt) && /level cap 30/.test(txt) && /\$20 /.test(txt) && !/\.99/.test(txt) && /Shards of Valor > Passes/.test(txt) && !/\u2014/.test(txt) && errs.length === 0, 'Admin > Game Pass > Tier test and preview: labelled test/preview, all five tiers with what each includes, no em dashes', errs.join(' | ') || (nav ? '' : 'admin nav not found'));
|
||||||
await page.locator('#gpTestCard').scrollIntoViewIfNeeded(); await sleep(300);
|
await page.locator('#gpTestCard').scrollIntoViewIfNeeded(); await sleep(300);
|
||||||
await page.locator('#gpTestCard').screenshot({ path: path.join(SHOTS, '3-admin-tier-test-panel.png') });
|
await page.locator('#gpTestCard').screenshot({ path: path.join(SHOTS, '3-admin-tier-test-panel.png') });
|
||||||
await page.click('#gpTest [data-gpt-buy="explorer"]'); await page.waitForSelector('#dlgOk', { timeout: 5000 });
|
await page.click('#gpTest [data-gpt-buy="explorer"]'); await page.waitForSelector('#dlgOk', { timeout: 5000 });
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const LS_SITE = process.env.LS_SITE || path.join(IAP_SITE, '..', '..', 'linkspin
|
|||||||
const SECRET = 'qa-sponsorfollow-' + 'x'.repeat(40);
|
const SECRET = 'qa-sponsorfollow-' + 'x'.repeat(40);
|
||||||
process.env.LS_SYNC_SECRET = SECRET;
|
process.env.LS_SYNC_SECRET = SECRET;
|
||||||
const SF = require(path.join(IAP_SITE, 'sponsorfollow.js'));
|
const SF = require(path.join(IAP_SITE, 'sponsorfollow.js'));
|
||||||
const IAP_PORT = 8811, LS_PORT = 8812, IAP = 'http://127.0.0.1:' + IAP_PORT, LS = 'http://127.0.0.1:' + LS_PORT;
|
const IAP_PORT = Number(process.env.SF_E2E_PORT || 8811), LS_PORT = IAP_PORT + 1, IAP = 'http://127.0.0.1:' + IAP_PORT, LS = 'http://127.0.0.1:' + LS_PORT;
|
||||||
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||||||
let pass = 0, fail = 0; const lines = [];
|
let pass = 0, fail = 0; const lines = [];
|
||||||
const ok = (cond, name, extra) => { if (cond) { pass++; lines.push('ok ' + name); } else { fail++; lines.push('FAIL ' + name + (extra ? '\n ' + extra : '')); } };
|
const ok = (cond, name, extra) => { if (cond) { pass++; lines.push('ok ' + name); } else { fail++; lines.push('FAIL ' + name + (extra ? '\n ' + extra : '')); } };
|
||||||
@@ -30,7 +30,7 @@ function seed(dir, list) {
|
|||||||
for (const a of list) { db.byEmail[a.email] = a; db.byCode[a.code] = a.email; }
|
for (const a of list) { db.byEmail[a.email] = a; db.byCode[a.code] = a.email; }
|
||||||
fs.writeFileSync(path.join(dir, 'accounts.json'), JSON.stringify(db));
|
fs.writeFileSync(path.join(dir, 'accounts.json'), JSON.stringify(db));
|
||||||
}
|
}
|
||||||
const base = () => [acct('adopter@qa.test', 'adopter', { memberId: 0 }), acct('old@qa.test', 'oldsponsor'), acct('lead1@qa.test', 'leadone'), acct('lead2@qa.test', 'leadtwo', { sponsorRef: 'oldsponsor' }), acct('lead4@qa.test', 'leadfour', { sponsorRef: 'oldsponsor' })];
|
const base = () => [acct('boss@qa.test', 'qaboss', { memberId: 77 }), acct('lead5@qa.test', 'leadfive'), acct('adopter@qa.test', 'adopter', { memberId: 0 }), acct('old@qa.test', 'oldsponsor'), acct('lead1@qa.test', 'leadone'), acct('lead2@qa.test', 'leadtwo', { sponsorRef: 'oldsponsor' }), acct('lead4@qa.test', 'leadfour', { sponsorRef: 'oldsponsor' })];
|
||||||
const iapDir = fs.mkdtempSync(path.join(os.tmpdir(), 'sf-e2e-iap-')), lsDir = fs.mkdtempSync(path.join(os.tmpdir(), 'sf-e2e-ls-'));
|
const iapDir = fs.mkdtempSync(path.join(os.tmpdir(), 'sf-e2e-iap-')), lsDir = fs.mkdtempSync(path.join(os.tmpdir(), 'sf-e2e-ls-'));
|
||||||
// lead3 is bound on InstantAdPay (memberId), lead4 joined LinkSpin under someone else (ordinary, already different)
|
// lead3 is bound on InstantAdPay (memberId), lead4 joined LinkSpin under someone else (ordinary, already different)
|
||||||
seed(iapDir, base().concat([acct('lead3@qa.test', 'leadthree', { memberId: 42, sponsorRef: 'oldsponsor' })]));
|
seed(iapDir, base().concat([acct('lead3@qa.test', 'leadthree', { memberId: 42, sponsorRef: 'oldsponsor' })]));
|
||||||
@@ -70,6 +70,17 @@ try {
|
|||||||
await sleep(6000);
|
await sleep(6000);
|
||||||
ok((await facts(IAP, 'lead3@qa.test')).sponsorEmail === 'old@qa.test', 'bound on InstantAdPay: sponsor there unchanged');
|
ok((await facts(IAP, 'lead3@qa.test')).sponsorEmail === 'old@qa.test', 'bound on InstantAdPay: sponsor there unchanged');
|
||||||
|
|
||||||
|
// 3b. Who invited you (2026-11-07): the member, signed in on InstantAdPay, names their sponsor; LinkSpin follows through the real sync
|
||||||
|
{ const st = await fetch(IAP + '/api/auth/email/start', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: 'lead5@qa.test', fts: Date.now() - 8000 }) }).then(x => x.json());
|
||||||
|
const v = await fetch(IAP + '/api/auth/email/verify', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: 'lead5@qa.test', code: st.devCode }) });
|
||||||
|
const cookie = (v.headers.getSetCookie ? v.headers.getSetCookie() : []).map(c => c.split(';')[0]).join('; ');
|
||||||
|
const inv = await fetch(IAP + '/api/my/tank/invited', { method: 'POST', headers: { 'Content-Type': 'application/json', Cookie: cookie }, body: JSON.stringify({ who: '@qaboss' }) }).then(x => x.json());
|
||||||
|
ok(inv.ok && inv.name === '@qaboss', 'lead5 names @qaboss on InstantAdPay', JSON.stringify({ inv, dev: !!st.devCode }));
|
||||||
|
ok(await waitFor(async () => (await facts(LS, 'lead5@qa.test')).sponsorEmail === 'boss@qa.test'), 'LinkSpin follows: lead5 under boss');
|
||||||
|
const f5 = await facts(LS, 'lead5@qa.test'); ok(f5 && f5.prov && f5.prov.by === 'invited' && f5.prov.origin === 'instantadpay', 'LinkSpin keeps the record (by invited, origin instantadpay)', JSON.stringify(f5 && f5.prov));
|
||||||
|
const a5 = await admin(IAP, '/api/admin/tank'); ok((a5.adoptions || []).some(x => x.adoptee === 'lead5@qa.test' && x.status === 'invited'), 'InstantAdPay admin tank shows the record');
|
||||||
|
}
|
||||||
|
|
||||||
// 4. ping-pong: let both ticks run; nothing keeps bouncing
|
// 4. ping-pong: let both ticks run; nothing keeps bouncing
|
||||||
const s1 = await admin(IAP, '/api/admin/lssync'), t1 = await admin(LS, '/api/admin/iapsync');
|
const s1 = await admin(IAP, '/api/admin/lssync'), t1 = await admin(LS, '/api/admin/iapsync');
|
||||||
await admin(IAP, '/api/admin/lssync/run', {}); await admin(LS, '/api/admin/iapsync/run', {}); await sleep(1500);
|
await admin(IAP, '/api/admin/lssync/run', {}); await admin(LS, '/api/admin/iapsync/run', {}); await sleep(1500);
|
||||||
|
|||||||
@@ -173,6 +173,31 @@ async function network() {
|
|||||||
assert.strictEqual(P.chats.length, 1); assert.strictEqual(Q.chats.length, 0, 'no chat on the quiet side');
|
assert.strictEqual(P.chats.length, 1); assert.strictEqual(Q.chats.length, 0, 'no chat on the quiet side');
|
||||||
const qr = await Q.tank.adopt('other@x.co', 'lead'); assert.ok(qr.error, 'cannot be adopted twice across the network');
|
const qr = await Q.tank.adopt('other@x.co', 'lead'); assert.ok(qr.error, 'cannot be adopted twice across the network');
|
||||||
});
|
});
|
||||||
|
await t('Who invited you: the member names a sponsor on one platform, the other follows and agrees (2026-11-07)', async () => {
|
||||||
|
const P = platform('instantadpay', 'linkspin'), Q = platform('linkspin', 'instantadpay'); people(P, Q);
|
||||||
|
const r = await P.tank.nameSponsor('lead@x.co', 'adopter'); assert.ok(r.ok, JSON.stringify(r));
|
||||||
|
assert.strictEqual(P.store.get('lead@x.co').by, 'invited');
|
||||||
|
const s = await settle(P, Q, ['lead@x.co', 'adopter@x.co']);
|
||||||
|
assert.strictEqual(s.moves, 1); assert.strictEqual(await spOf(Q, 'lead@x.co'), 'adopter@x.co');
|
||||||
|
assert.ok(!(await Q.tank.waiting()).some(w => w.email === 'lead@x.co'), 'gone from the other waiting list');
|
||||||
|
assert.strictEqual(Q.store.get('lead@x.co').by, 'invited'); assert.strictEqual(Q.store.get('lead@x.co').origin, 'instantadpay');
|
||||||
|
assert.ok((await Q.tank.adopt('other@x.co', 'lead')).error, 'nobody adopts them on the other side');
|
||||||
|
assert.ok((await Q.tank.nameSponsor('lead@x.co', 'otheradopter')).error, 'the other side refuses a second name');
|
||||||
|
});
|
||||||
|
await t('Who invited you: a bound member on the other platform keeps that sponsor; reported, not moved', async () => {
|
||||||
|
const P = platform('instantadpay', 'linkspin'), Q = platform('linkspin', 'instantadpay'); people(P, Q);
|
||||||
|
Q.bound.add('lead@x.co');
|
||||||
|
const r = await P.tank.nameSponsor('lead@x.co', 'adopter'); assert.ok(r.ok, JSON.stringify(r));
|
||||||
|
const { d } = await deliver(P, Q, 'lead@x.co');
|
||||||
|
assert.strictEqual(d.action, 'bound'); assert.strictEqual(await spOf(Q, 'lead@x.co'), null);
|
||||||
|
});
|
||||||
|
await t('sign-up grace holds on both platforms', async () => {
|
||||||
|
const P = platform('instantadpay', 'linkspin'), Q = platform('linkspin', 'instantadpay'); people(P, Q);
|
||||||
|
for (const X of [P, Q]) X.accounts.add('fresh@x.co', { username: 'fresh', created: Date.now() });
|
||||||
|
for (const X of [P, Q]) assert.ok(/less than 24 hours/.test((await X.tank.adopt('adopter@x.co', 'fresh')).error || ''), X.name);
|
||||||
|
assert.strictEqual(await spOf(P, 'fresh@x.co'), null); assert.strictEqual(await spOf(Q, 'fresh@x.co'), null);
|
||||||
|
});
|
||||||
|
|
||||||
await t('ping-pong guard: the applied change comes back as "same" and settles in one round trip', async () => {
|
await t('ping-pong guard: the applied change comes back as "same" and settles in one round trip', async () => {
|
||||||
const P = platform('instantadpay', 'linkspin'), Q = platform('linkspin', 'instantadpay'); people(P, Q);
|
const P = platform('instantadpay', 'linkspin'), Q = platform('linkspin', 'instantadpay'); people(P, Q);
|
||||||
await P.tank.adopt('adopter@x.co', 'lead');
|
await P.tank.adopt('adopter@x.co', 'lead');
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
// Stack POL page switch + Stack POL Pro (2026-11-09), end to end against a LOCAL copy. node qa/stackpro.mjs
|
||||||
|
// Boots server.js on its own port with a throwaway DATA_DIR (JSON store, devCode sign-in). Nothing touches production.
|
||||||
|
// Pro is NEW MONEY only: "Get Pro" opens a waiting order; only a package of $10 or more, mined after the order, by the member's own
|
||||||
|
// position, fulfils it; one package fulfils one order (a pass and Pro never ride the same purchase); credits never count.
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import os from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
import { spawn } from 'node:child_process';
|
||||||
|
|
||||||
|
const SITE = path.resolve(path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1')), '..');
|
||||||
|
const PORT = Number(process.env.SP_PORT || 8803);
|
||||||
|
const B = 'http://127.0.0.1:' + PORT;
|
||||||
|
const DATA = fs.mkdtempSync(path.join(os.tmpdir(), 'iap-stackpro-')); fs.mkdirSync(path.join(DATA, 'uploads'));
|
||||||
|
let fails = 0; const ok = (cond, label, extra) => { console.log((cond ? 'PASS ' : 'FAIL ') + label + (extra ? ' ' + extra : '')); if (!cond) fails++; };
|
||||||
|
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||||||
|
const srv = spawn(process.execPath, ['server.js'], { cwd: SITE, stdio: ['ignore', 'pipe', 'pipe'],
|
||||||
|
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' }) });
|
||||||
|
let log = ''; srv.stdout.on('data', d => log += d); srv.stderr.on('data', d => log += d);
|
||||||
|
async function api(p, o, headers) {
|
||||||
|
const opts = { method: (o && 'data' in o) ? 'POST' : 'GET', headers: Object.assign({ 'Content-Type': 'application/json' }, headers || {}) };
|
||||||
|
if (o && 'data' in o) opts.body = JSON.stringify(o.data);
|
||||||
|
const r = await fetch(B + p, opts); let j = null; try { j = await r.json(); } catch (e) {} return { status: r.status, j };
|
||||||
|
}
|
||||||
|
async function signIn(email, username) {
|
||||||
|
const s = await api('/api/auth/email/start', { data: { email, fts: Date.now() - 5000 } });
|
||||||
|
const v = await fetch(B + '/api/auth/email/verify', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email, code: s.j && s.j.devCode }) });
|
||||||
|
const cookie = (v.headers.getSetCookie ? v.headers.getSetCookie() : [v.headers.get('set-cookie')]).map(c => String(c).split(';')[0]).join('; ');
|
||||||
|
if (username) await api('/api/my/profile', { data: { username } }, { Cookie: cookie });
|
||||||
|
return { Cookie: cookie };
|
||||||
|
}
|
||||||
|
const buy = (email, cents, extra) => api('/api/dev/gamepass-purchase', { data: Object.assign({ email, cents }, extra || {}) });
|
||||||
|
const optin = () => { try { return JSON.parse(fs.readFileSync(path.join(DATA, 'stack-optin.json'), 'utf8')); } catch (e) { return {}; } };
|
||||||
|
try {
|
||||||
|
for (let i = 0; i < 40; i++) { try { if ((await fetch(B + '/api/config')).ok) break; } catch (e) {} await sleep(500); }
|
||||||
|
const A = 'sp-a@example.com', Bm = 'sp-b@example.com';
|
||||||
|
ok((await api('/api/my/stackpol')).status === 401, 'signed out: 401');
|
||||||
|
const ha = await signIn(A, 'stacka'), hb = await signIn(Bm, 'stackb');
|
||||||
|
let r = await api('/api/my/stackpol', null, ha); ok(r.status === 200 && r.j.on === true && r.j.url === 'https://stackpol.com/stacka' && r.j.pro && r.j.pro.pro === false, 'GET: on by default, url, not pro', JSON.stringify(r.j));
|
||||||
|
r = await api('/api/my/stackpol', { data: { on: true } }, ha); ok(r.j.on === true && optin().users.stacka === true, 'switch on writes stack-optin.json');
|
||||||
|
r = await api('/api/my/stackpol', { data: { on: false } }, ha); ok(r.j.on === false && optin().users.stacka === false, 'switch off');
|
||||||
|
// Marty 2026-11-09 evening: ANY $10+ package unlocks Pro, no order step; it rides along with whatever else the package fulfils
|
||||||
|
await buy(A, 500); r = await api('/api/my/stackpol', null, ha); ok(r.j.pro.pro === false, 'a $5 package does not unlock Pro');
|
||||||
|
const fx = await buy(A, 1000); r = await api('/api/my/stackpol', null, ha); ok(fx.j.order && fx.j.order.stackPro === true && r.j.pro.pro === true, 'a $10 package unlocks Pro with no order', JSON.stringify(fx.j));
|
||||||
|
ok(optin().pro && optin().pro.stacka === true, 'Pro owner lands in stack-optin.json for the indexer');
|
||||||
|
const again = await buy(A, 2000); ok(!(again.j.order && again.j.order.stackPro), 'a second package does not re-grant Pro');
|
||||||
|
// B: a Game Pass order waiting + a $20 package -> the pass starts AND Pro unlocks (Pro never takes the package from the pass)
|
||||||
|
const gp = await api('/api/my/gamepass/buy', { data: {} }, hb); const gpw = await api('/api/my/gamepass', null, hb);
|
||||||
|
const fb = await buy(Bm, 2000); r = await api('/api/my/stackpol', null, hb); const st = await api('/api/my/gamepass', null, hb);
|
||||||
|
ok(r.j.pro.pro === true, 'B: the $20 package unlocked Pro', JSON.stringify(fb.j));
|
||||||
|
ok(!gpw.j.enabled || st.j.active === true, 'B: the same package still started the waiting Game Pass', 'enabled=' + gpw.j.enabled + ' active=' + st.j.active);
|
||||||
|
r = await api('/api/my/stackpol', { data: { on: false } }, hb); ok(r.j.on === false && r.j.pro.pro === true, 'switching the page off keeps Pro');
|
||||||
|
} catch (e) { console.log('FAIL exception', e && e.stack || e); fails++; }
|
||||||
|
finally { try { srv.kill(); } catch (e) {} try { fs.rmSync(DATA, { recursive: true, force: true }); } catch (e) {} }
|
||||||
|
if (fails) console.log(log.split('\n').filter(l => /stack|gamepass|error/i.test(l)).slice(-15).join('\n'));
|
||||||
|
console.log(fails ? '\n' + fails + ' FAILED' : '\nALL PASSED'); process.exit(fails ? 1 : 0);
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
// InstantAdPay holding-tank adoption cap + BTC4Hits wording (2026-11-11). No server: the real tank.js with in-memory
|
||||||
|
// accounts, a fake chain and a capturing mailer/messages, on a throwaway dir. node qa/tank-cap.test.mjs
|
||||||
|
// Marty: an adopter may hold up to 10 people from the tank at one time (not yet switched on payouts), as a setting;
|
||||||
|
// a BTC4Hits import is told the truth (their BTC4Hits account came over), never "You joined InstantAdPay without a sponsor".
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import os from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
import { createRequire } from 'node:module';
|
||||||
|
const SITE = path.resolve(path.dirname(new URL(import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, '$1')), '..');
|
||||||
|
const require = createRequire(path.join(SITE, 'package.json'));
|
||||||
|
delete process.env.DATABASE_URL;
|
||||||
|
let fails = 0, passes = 0; const ok = (c, l, x) => { console.log((c ? 'PASS ' : 'FAIL ') + l + (x && !c ? ' ' + String(x).slice(0, 300) : '')); if (c) passes++; else fails++; };
|
||||||
|
const DAY = 86400000;
|
||||||
|
function bench(cap) {
|
||||||
|
delete require.cache[require.resolve(path.join(SITE, 'tank.js'))];
|
||||||
|
const tank = require(path.join(SITE, 'tank.js'));
|
||||||
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'iap-tankcap-'));
|
||||||
|
const by = new Map(); let n = 100; const pub = a => a ? Object.assign({}, a) : null; const find = f => { for (const a of by.values()) if (f(a)) return pub(a); return null; };
|
||||||
|
const accounts = { add(email, o) { by.set(email, Object.assign({ email, username: null, code: 'c' + (n++), sponsorRef: '', memberId: 0, address: null, created: Date.now() - 3 * DAY, lastSeen: Date.now() - 3600000, joinedVia: 'page', joinedRef: null }, o || {})); },
|
||||||
|
async byEmail(e) { return pub(by.get(String(e || '').toLowerCase())); }, async byUsername(u) { return find(a => a.username === String(u || '').toLowerCase()); }, async byCode(c) { return find(a => a.code === String(c || '').toLowerCase()); },
|
||||||
|
async byMemberId(id) { return find(a => Number(a.memberId) === Number(id) && id > 0); }, async setSponsorRef(e, ref) { const a = by.get(e); a.sponsorRef = String(ref || ''); return { ok: true }; },
|
||||||
|
async listAll() { return [...by.values()].map(pub); }, async sponsorOf() { return null; }, _by: by };
|
||||||
|
const events = []; const mails = []; const chats = [];
|
||||||
|
tank.init({ dataDir: dir, accounts, chain: { recentEvents: () => events.slice(), getConfig: () => ({ explorer: 'https://polygonscan.com' }) },
|
||||||
|
messages: { sendChat: async (id, from, to, text) => { chats.push({ to, text }); }, lastFrom: async () => 0 },
|
||||||
|
mailer: { hasKey: () => true, send: async (to, subject, text) => { mails.push({ to, subject, text }); } }, site: 'https://instantadpay.test',
|
||||||
|
capOpen: cap === undefined ? undefined : () => cap, hooks: {} });
|
||||||
|
accounts.add('adopter@x.co', { username: 'helper', memberId: 77, address: '0x' + '1'.repeat(40), joinedVia: null });
|
||||||
|
events.push({ type: 'Purchase', buyerId: 77, priceCents: 2000, block: 1 });
|
||||||
|
return { tank, accounts, mails, chats };
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const { tank, accounts, mails, chats } = bench();
|
||||||
|
for (let i = 0; i < 12; i++) accounts.add('m' + i + '@b4h.test', i < 6 ? { joinedVia: 'btc4hits', joinedRef: 'btc4hits' } : {});
|
||||||
|
ok(tank.capOpen() === 10, 'default cap is 10');
|
||||||
|
let n = 0; for (let i = 0; i < 10; i++) { const r = await tank.adopt('adopter@x.co', 'm' + i + '@b4h.test'); if (r.ok) n++; else console.log(' adopt ' + i + ': ' + r.error); }
|
||||||
|
ok(n === 10, 'adopts 10 in a row');
|
||||||
|
const r11 = await tank.adopt('adopter@x.co', 'm10@b4h.test');
|
||||||
|
ok(r11.error && /helping 10 people/.test(r11.error) && /10 at one time is the most/.test(r11.error) && !/—/.test(r11.error), 'the 11th is refused with a clear message', JSON.stringify(r11));
|
||||||
|
const v = await tank.view('adopter@x.co'); ok(v.cap === 10 && v.eligible === false, 'tank view shows cap 10, not eligible');
|
||||||
|
accounts._by.get('m3@b4h.test').memberId = 901;
|
||||||
|
ok((await tank.adopt('adopter@x.co', 'm10@b4h.test')).ok, 'a held member switching on payouts frees a slot right away');
|
||||||
|
ok((await tank.adopt('adopter@x.co', 'm11@b4h.test')).error, 'and the cap holds again');
|
||||||
|
const imp = mails.filter(m => m.to === 'm0@b4h.test'); const reg = mails.filter(m => m.to === 'm7@b4h.test');
|
||||||
|
ok(imp.length === 1 && reg.length === 1, 'exactly one email to each adoptee');
|
||||||
|
ok(/BTC4Hits has closed, and your BTC4Hits account came over to InstantAdPay/.test(imp[0].text) && !/You joined InstantAdPay/.test(imp[0].text), 'BTC4Hits import: email says the account came over', imp[0].text);
|
||||||
|
ok(/Your BTC4Hits account moved to InstantAdPay without a sponsor/.test((chats.find(c => c.to === 'm0@b4h.test') || {}).text || ''), 'BTC4Hits import: default first chat reads right');
|
||||||
|
ok(/^You joined InstantAdPay without a sponsor/.test(reg[0].text), 'ordinary tank member keeps the old wording');
|
||||||
|
ok(!mails.some(m => /—/.test(m.text + m.subject)), 'no em dash in any adoption email');
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const { tank, accounts } = bench(3);
|
||||||
|
for (let i = 0; i < 4; i++) accounts.add('s' + i + '@b4h.test');
|
||||||
|
for (let i = 0; i < 3; i++) await tank.adopt('adopter@x.co', 's' + i + '@b4h.test');
|
||||||
|
const r = await tank.adopt('adopter@x.co', 's3@b4h.test'); ok(r.error && /3 at one time/.test(r.error), 'tankAdoptCap setting is respected (3)', JSON.stringify(r));
|
||||||
|
ok(bench('junk').tank.capOpen() === 10, 'a bad setting falls back to 10');
|
||||||
|
}
|
||||||
|
console.log('\n' + passes + ' passed, ' + fails + ' failed'); process.exit(fails ? 1 : 0);
|
||||||
@@ -24,6 +24,7 @@ delete process.env.DATABASE_URL; // JSON stores only
|
|||||||
let fails = 0; const ok = (cond, label, extra) => { console.log((cond ? 'PASS ' : 'FAIL ') + label + (extra ? ' ' + extra : '')); if (!cond) fails++; };
|
let fails = 0; const ok = (cond, label, extra) => { console.log((cond ? 'PASS ' : 'FAIL ') + label + (extra ? ' ' + extra : '')); if (!cond) fails++; };
|
||||||
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||||||
const H = 3600000;
|
const H = 3600000;
|
||||||
|
const addr = () => '0x' + crypto.randomBytes(20).toString('hex');
|
||||||
|
|
||||||
// ---------------- Part A ----------------
|
// ---------------- Part A ----------------
|
||||||
function fakeAccounts() {
|
function fakeAccounts() {
|
||||||
@@ -118,6 +119,8 @@ async function partA() {
|
|||||||
for (const em of ['a@x.co', 'b@x.co', 'c@x.co']) accounts._by.get(em).lastSeen = env.now - H;
|
for (const em of ['a@x.co', 'b@x.co', 'c@x.co']) accounts._by.get(em).lastSeen = env.now - H;
|
||||||
const r4 = await tank.readyTick();
|
const r4 = await tank.readyTick();
|
||||||
ok(r4.assigned.length === 1 && r4.assigned[0].adopter === 'a@x.co', 'rotation wraps to the least recently assigned (A)', JSON.stringify(r4.assigned));
|
ok(r4.assigned.length === 1 && r4.assigned[0].adopter === 'a@x.co', 'rotation wraps to the least recently assigned (A)', JSON.stringify(r4.assigned));
|
||||||
|
// since 2026-11-11 the cap is people held at one time who have not switched on payouts (default 10): fill A up by hand
|
||||||
|
for (let i = 0; i < tank.capOpen(); i++) { accounts.add('fill' + i + '@x.co'); await tank.adopt('a@x.co', 'fill' + i + '@x.co'); }
|
||||||
// A now has 2 open adoptions (free + free4): full. Make B and C stale: nobody eligible
|
// A now has 2 open adoptions (free + free4): full. Make B and C stale: nobody eligible
|
||||||
accounts._by.get('b@x.co').lastSeen = env.now - 8 * 86400000; accounts._by.get('c@x.co').lastSeen = env.now - 8 * 86400000;
|
accounts._by.get('b@x.co').lastSeen = env.now - 8 * 86400000; accounts._by.get('c@x.co').lastSeen = env.now - 8 * 86400000;
|
||||||
accounts.add('free5@x.co', { address: '0x' + 'f'.repeat(40) });
|
accounts.add('free5@x.co', { address: '0x' + 'f'.repeat(40) });
|
||||||
@@ -222,12 +225,156 @@ async function partA() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---------------- Part B ----------------
|
// ---------------- Part B ----------------
|
||||||
|
// ---------------- Sign-up grace + "Who invited you?" (Marty approved 2026-11-07) ----------------
|
||||||
|
async function partGrace() {
|
||||||
|
console.log('-- Sign-up grace + Who invited you: tank.js with a mocked clock');
|
||||||
|
const M = 60000;
|
||||||
|
{ // hand adoption: blocked for 24 hours from created, open after, old members untouched
|
||||||
|
const B = bench(); const { tank, accounts, env } = B; const t0 = env.now;
|
||||||
|
B.buyer('ad@x.co', 11);
|
||||||
|
accounts.add('new@x.co', { created: t0 - H }); accounts.add('old@x.co');
|
||||||
|
const w = await tank.waiting(); const row = w.find(x => x.email === 'new@x.co');
|
||||||
|
ok(row && row.opensAt === t0 + 23 * H, 'waiting(): new sign-up carries opensAt = created + 24 h', JSON.stringify(row));
|
||||||
|
ok(w.find(x => x.email === 'old@x.co').opensAt === 0, 'waiting(): an old account is open now');
|
||||||
|
ok(w[w.length - 1].email === 'new@x.co', 'waiting(): grace members sort after the open ones');
|
||||||
|
ok((await tank.adoptable()).every(x => x.email !== 'new@x.co'), 'adoptable() leaves out grace members (Overview note, weekly email)');
|
||||||
|
const r = await tank.adopt('ad@x.co', 'new', 'hi');
|
||||||
|
ok(r.error && /less than 24 hours/.test(r.error) && /23 h 0 min/.test(r.error), 'grace blocks a hand adoption with a plain message', JSON.stringify(r));
|
||||||
|
ok(!(await accounts.byEmail('new@x.co')).sponsorRef, '...and writes no sponsor');
|
||||||
|
ok(!B.mails.length && !B.chats.length, '...and tells nobody');
|
||||||
|
env.now = t0 + 23 * H - M;
|
||||||
|
ok((await tank.adopt('ad@x.co', 'new', 'hi')).error, 'still blocked one minute before it opens');
|
||||||
|
env.now = t0 + 23 * H + M;
|
||||||
|
const r2 = await tank.adopt('ad@x.co', 'new', 'hi');
|
||||||
|
ok(r2.ok, 'opens after 24 hours', JSON.stringify(r2));
|
||||||
|
const r3 = await tank.adopt('ad@x.co', 'old', 'hi');
|
||||||
|
ok(r3.ok, 'an old account is adoptable at once (back in the tank later = no grace)', JSON.stringify(r3));
|
||||||
|
}
|
||||||
|
{ // wallet in the first hour: hand adoption opens at 24 h, the safety net keeps its own clock
|
||||||
|
const B = bench(); const { tank, accounts, env } = B; const t0 = env.now;
|
||||||
|
B.buyer('ad@x.co', 11); B.buyer('ad2@x.co', 12);
|
||||||
|
accounts.add('w@x.co', { created: t0 });
|
||||||
|
env.now = t0 + H; accounts._by.get('w@x.co').address = addr(); accounts._by.get('w@x.co').lastSeen = env.now;
|
||||||
|
const t1 = await tank.readyTick();
|
||||||
|
ok(t1.fresh.length === 0, 'wallet in the first hour: no "adopt them" notice during the grace', JSON.stringify(t1.fresh));
|
||||||
|
const h = await tank.holdFor(await accounts.byEmail('w@x.co'));
|
||||||
|
ok(h.hold.since === t0 + H && h.hold.until === t0 + 25 * H, 'the hold clock runs from the wallet link, not stretched by the grace', JSON.stringify(h.hold));
|
||||||
|
env.now = t0 + 23 * H; ok((await tank.readyTick()).fresh.length === 0, 'still no notice at 23 hours');
|
||||||
|
ok((await tank.adopt('ad@x.co', 'w', 'hi')).error, 'hand adoption refused at 23 hours');
|
||||||
|
env.now = t0 + 24 * H + M; for (const em of ['ad@x.co', 'ad2@x.co']) accounts._by.get(em).lastSeen = env.now;
|
||||||
|
const t2 = await tank.readyTick();
|
||||||
|
ok(t2.fresh.length === 1 && t2.fresh[0].until === t0 + 25 * H && !t2.assigned.length, 'grace over: notice once, with the real end of the hold', JSON.stringify(t2.fresh));
|
||||||
|
ok(tank.leftText(t2.fresh[0].until - env.now) === '59 min', 'the notice text can say the time really left', tank.leftText(t2.fresh[0].until - env.now));
|
||||||
|
ok((await tank.readyTick()).fresh.length === 0, '...and not twice');
|
||||||
|
env.now = t0 + 25 * H - 10 * M;
|
||||||
|
const t3 = await tank.readyTick();
|
||||||
|
ok(t3.assigned.length === 1 && t3.assigned[0].adoptee === 'w@x.co', 'the rotation takes them inside 24 hours of the wallet link', JSON.stringify(t3.assigned));
|
||||||
|
}
|
||||||
|
{ // wallet in the first minutes: the rotation fires just before the grace ends, no notice ever goes out
|
||||||
|
const B = bench(); const { tank, accounts, env } = B; const t0 = env.now;
|
||||||
|
B.buyer('ad@x.co', 11);
|
||||||
|
accounts.add('fast@x.co', { created: t0, address: addr() });
|
||||||
|
env.now = t0 + 5 * M; ok((await tank.readyTick()).fresh.length === 0, 'wallet in minute 5: no notice');
|
||||||
|
env.now = t0 + 24 * H - 5 * M; accounts._by.get('ad@x.co').lastSeen = env.now;
|
||||||
|
const t = await tank.readyTick();
|
||||||
|
ok(t.assigned.length === 1 && t.fresh.length === 0, 'auto path unaffected: assigned inside the grace (24 h from the wallet link), no adopt notice', JSON.stringify({ a: t.assigned, f: t.fresh }));
|
||||||
|
ok((await accounts.byEmail('fast@x.co')).sponsorRef === 'ad', 'the safety net wrote the sponsor');
|
||||||
|
}
|
||||||
|
{ // grace ends in the last tick of the hold: the safety net takes them, nobody is told to adopt someone already gone
|
||||||
|
const B = bench(); const { tank, accounts, env } = B; const t0 = env.now;
|
||||||
|
B.buyer('ad@x.co', 11);
|
||||||
|
accounts.add('mid@x.co', { created: t0 });
|
||||||
|
env.now = t0 + 10 * M; accounts._by.get('mid@x.co').address = addr(); await tank.readyTick();
|
||||||
|
env.now = t0 + 24 * H + M; accounts._by.get('ad@x.co').lastSeen = env.now; // 9 minutes of hold left: inside the last tick
|
||||||
|
const t = await tank.readyTick();
|
||||||
|
ok(t.assigned.length === 1 && t.fresh.length === 0, 'no notice for someone the rotation takes in the same tick', JSON.stringify({ a: t.assigned, f: t.fresh }));
|
||||||
|
}
|
||||||
|
{ // the arrivals post: announced when the grace ends
|
||||||
|
const B = bench(); const { tank, env } = B; const t0 = env.now;
|
||||||
|
const list = [{ email: 'a', joined: t0 - 24 * H - 5 * M }, { email: 'b', joined: t0 - 24 * H - 20 * M }, { email: 'c', joined: t0 - H }];
|
||||||
|
ok(tank.openedSince(list, t0 - 15 * M).map(x => x.email).join() === 'a', 'openedSince: only people whose grace ended since the last check');
|
||||||
|
}
|
||||||
|
{ // Who invited you: every refusal, nothing written
|
||||||
|
const B = bench(); const { tank, accounts, env } = B; const t0 = env.now;
|
||||||
|
B.buyer('boss@x.co', 21);
|
||||||
|
accounts.add('m@x.co', { username: 'mm1', created: t0 });
|
||||||
|
accounts.add('kid@x.co', { username: 'kid', sponsorRef: 'mm1' }); // joined under m: a loop
|
||||||
|
accounts.add('free@x.co', { username: 'free' }); // no payouts, nobody above them
|
||||||
|
accounts.add('under@x.co', { username: 'under', sponsorRef: 'boss' }); // no payouts, but boss above them
|
||||||
|
accounts.add('has@x.co', { username: 'hassp', sponsorRef: 'boss' });
|
||||||
|
accounts.add('bound@x.co', { username: 'bound1', memberId: 55 });
|
||||||
|
const say = async (e, who) => { const r = await tank.nameSponsor(e, who); return r.error || ''; };
|
||||||
|
ok(/Type the username/.test(await say('m@x.co', ' ')), 'refused: empty');
|
||||||
|
ok(/That is you/.test(await say('m@x.co', '@MM1')), 'refused: self (any case, leading @)');
|
||||||
|
ok(/No member here/.test(await say('m@x.co', 'nosuchname')), 'refused: unknown username');
|
||||||
|
ok(/No member here/.test(await say('m@x.co', 'bad name!')), 'refused: not a username');
|
||||||
|
ok(/already have a sponsor/.test(await say('has@x.co', 'boss')), 'refused: already sponsored');
|
||||||
|
ok(/locked on the contract/.test(await say('bound@x.co', 'boss')), 'refused: member id');
|
||||||
|
ok(/in your own line/.test(await say('m@x.co', 'kid')), 'refused: chain loop (inDownlineOf)');
|
||||||
|
ok(/nobody above them/.test(await say('m@x.co', 'free')), 'refused: nobody on the contract in that line (would fall to the company)');
|
||||||
|
B.blocked.add(21);
|
||||||
|
ok(/cannot take new members/.test(await say('m@x.co', 'boss')), 'refused: no-payout chain');
|
||||||
|
B.blocked.delete(21);
|
||||||
|
ok(!(await accounts.byEmail('m@x.co')).sponsorRef && !B.mails.length, 'no refusal wrote a sponsor or sent a notice');
|
||||||
|
const c = await tank.nameSponsor('m@x.co', 'boss', { check: true });
|
||||||
|
ok(c.ok && c.name === '@boss' && !(await accounts.byEmail('m@x.co')).sponsorRef && !B.mails.length, 'check mode validates and writes nothing', JSON.stringify(c));
|
||||||
|
ok((await tank.nameSponsor('m@x.co', 'under', { check: true })).ok, 'a sponsor with no payouts but someone above them on the contract is allowed');
|
||||||
|
B.net['m2@x.co'] = { sponsorEmail: 'boss@x.co', via: 'email' };
|
||||||
|
accounts.add('m2@x.co', { username: 'mm2' });
|
||||||
|
const al = await tank.nameSponsor('m2@x.co', 'under');
|
||||||
|
ok(al.error && al.aligned && (await accounts.byEmail('m2@x.co')).sponsorRef === 'boss', 'the sponsor the network already knows comes first', JSON.stringify(al));
|
||||||
|
}
|
||||||
|
{ // Who invited you: success
|
||||||
|
const B = bench(); const { tank, accounts, env } = B; const t0 = env.now;
|
||||||
|
B.buyer('boss@x.co', 21); B.buyer('ad@x.co', 22);
|
||||||
|
accounts.add('m@x.co', { username: 'mm1', created: t0 });
|
||||||
|
const m0 = await accounts.byEmail('m@x.co');
|
||||||
|
ok(tank.inviteAsk(m0) && tank.inviteAsk(m0).dismissed === false, 'inviteAsk: the card shows for a tank member');
|
||||||
|
ok(tank.inviteAsk(await accounts.byEmail('boss@x.co')) === null, 'inviteAsk: no card for a member with a sponsor line / member id');
|
||||||
|
tank.dismissInvite('m@x.co');
|
||||||
|
ok(tank.inviteAsk(m0).dismissed === true, 'Nobody invited me: card dismissed');
|
||||||
|
ok(!(await accounts.byEmail('m@x.co')).sponsorRef && (await tank.waiting()).some(w => w.email === 'm@x.co'), '...nothing else changes: still in the tank');
|
||||||
|
const r = await tank.nameSponsor('m@x.co', '@Boss');
|
||||||
|
ok(r.ok && r.name === '@boss', 'prompt success', JSON.stringify(r));
|
||||||
|
const a = await accounts.byEmail('m@x.co');
|
||||||
|
ok(a.sponsorRef === 'boss', 'sponsor written');
|
||||||
|
ok((await tank.holdFor(a)) === null && tank.inviteAsk(a) === null, 'hold gone, card gone');
|
||||||
|
ok(!(await tank.waiting()).some(w => w.email === 'm@x.co'), 'out of the waiting list');
|
||||||
|
ok(B.mails.length === 1 && B.mails[0].to === 'boss@x.co' && /new referral/.test(B.mails[0].subject), 'the named sponsor gets the notice, nobody else', JSON.stringify(B.mails.map(x => x.to)));
|
||||||
|
ok(!B.chats.length, 'no chat written in the sponsor\'s name');
|
||||||
|
const v = await tank.adminView(); const rec = v.adoptions.find(x => x.adoptee === 'm@x.co');
|
||||||
|
ok(rec && rec.status === 'invited' && rec.adopter === 'boss@x.co', 'admin record: status invited');
|
||||||
|
ok((await tank.summaryFor('m@x.co')) === null, 'not an adoption: nothing counts toward the two, nothing open on the other site');
|
||||||
|
const again = await tank.nameSponsor('m@x.co', 'ad');
|
||||||
|
ok(/already have a sponsor/.test(again.error || '') && (await accounts.byEmail('m@x.co')).sponsorRef === 'boss', 'a second name is refused');
|
||||||
|
env.now = t0 + 8 * 86400000; await tank.sweep();
|
||||||
|
ok((await accounts.byEmail('m@x.co')).sponsorRef === 'boss', 'no 7-day window: still theirs after a week');
|
||||||
|
}
|
||||||
|
{ // a ready member names someone: the hold record clears the way an adoption does, no auto-assign
|
||||||
|
const B = bench(); const { tank, accounts, env } = B; const t0 = env.now;
|
||||||
|
B.buyer('boss@x.co', 21); B.buyer('ad@x.co', 22);
|
||||||
|
accounts.add('r@x.co', { username: 'rr1', created: t0, address: addr() });
|
||||||
|
await tank.readyTick();
|
||||||
|
ok(tank.readyRec('r@x.co'), 'setup: on the 24-hour clock');
|
||||||
|
const r = await tank.nameSponsor('r@x.co', 'boss');
|
||||||
|
ok(r.ok && !tank.readyRec('r@x.co'), 'the hold record clears', JSON.stringify(r));
|
||||||
|
env.now = t0 + 24 * H;
|
||||||
|
for (const em of ['boss@x.co', 'ad@x.co']) accounts._by.get(em).lastSeen = env.now;
|
||||||
|
ok(!(await tank.readyTick()).assigned.length && (await accounts.byEmail('r@x.co')).sponsorRef === 'boss', 'the rotation leaves them alone');
|
||||||
|
ok(tank.payView().some(p => p.email === 'r@x.co' && p.adopter === 'boss@x.co'), 'the switch-on-payouts reminders track the named sponsor');
|
||||||
|
const B2 = bench(); B2.buyer('boss@x.co', 21); const w = '0x' + 'e'.repeat(40); B2.accounts.add('c@x.co', { username: 'cc1', address: w }); B2.onChain.add(w);
|
||||||
|
ok(/locked on the contract/.test((await B2.tank.nameSponsor('c@x.co', 'boss')).error || ''), 'refused: wallet already on the contract, member number not saved yet');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function partB() {
|
async function partB() {
|
||||||
console.log('-- Part B: local copy');
|
console.log('-- Part B: local copy');
|
||||||
const PORT = Number(process.env.TANKHOLD_PORT || 8799);
|
const PORT = Number(process.env.TANKHOLD_PORT || 8799);
|
||||||
const BASE = 'http://127.0.0.1:' + PORT; const ADMIN = 'localtest';
|
const BASE = 'http://127.0.0.1:' + PORT; const ADMIN = 'localtest';
|
||||||
const DATA = fs.mkdtempSync(path.join(os.tmpdir(), 'iap-tankhold-srv-')); fs.mkdirSync(path.join(DATA, 'uploads'));
|
const DATA = fs.mkdtempSync(path.join(os.tmpdir(), 'iap-tankhold-srv-')); fs.mkdirSync(path.join(DATA, 'uploads'));
|
||||||
const LSSECRET = crypto.randomBytes(24).toString('hex'); // throwaway
|
const LSSECRET = crypto.randomBytes(24).toString('hex'); // throwaway
|
||||||
|
{ const a = { email: 'qa-sponsor@example.com', pass: null, sponsorRef: '', code: 'cqasp1', username: 'qasponsor', address: null, created: Date.now() - 30 * 86400000, lastSeen: Date.now() - H, memberId: 42 }; // a member with a contract position, for the Who invited you checks
|
||||||
|
fs.writeFileSync(path.join(DATA, 'accounts.json'), JSON.stringify({ v: 2, byEmail: { [a.email]: a }, byAddress: {}, byCode: { [a.code]: a.email }, joins: 0, positions: {} })); }
|
||||||
const srv = spawn(process.execPath, ['server.js'], { cwd: SITE, stdio: ['ignore', 'pipe', 'pipe'],
|
const srv = spawn(process.execPath, ['server.js'], { cwd: SITE, stdio: ['ignore', 'pipe', 'pipe'],
|
||||||
env: Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: DATA, NODE_ENV: 'development', ADMIN_EMAIL: 'qa-admin@example.com', ADMIN_PASSWORD: ADMIN, LS_SYNC_SECRET: LSSECRET, LS_URL: 'http://127.0.0.1:1' }) });
|
env: Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: DATA, NODE_ENV: 'development', ADMIN_EMAIL: 'qa-admin@example.com', ADMIN_PASSWORD: ADMIN, LS_SYNC_SECRET: LSSECRET, LS_URL: 'http://127.0.0.1:1' }) });
|
||||||
let log = ''; srv.stdout.on('data', d => log += d); srv.stderr.on('data', d => log += d);
|
let log = ''; srv.stdout.on('data', d => log += d); srv.stderr.on('data', d => log += d);
|
||||||
@@ -354,6 +501,44 @@ async function partB() {
|
|||||||
ok(s5.act.length === 0 && s5.note === 'Step 1: link your wallet (one free signature). Then switching on payouts with member #21 starts by itself.', 'no wallet yet: asks to link first, nothing starts', JSON.stringify(s5));
|
ok(s5.act.length === 0 && s5.note === 'Step 1: link your wallet (one free signature). Then switching on payouts with member #21 starts by itself.', 'no wallet yet: asks to link first, nothing starts', JSON.stringify(s5));
|
||||||
await c.close(); }
|
await c.close(); }
|
||||||
ok(!errs.length, 'no page errors (one-tap link pages)', errs.join(' | ').slice(0, 200));
|
ok(!errs.length, 'no page errors (one-tap link pages)', errs.join(' | ').slice(0, 200));
|
||||||
|
{ // 6. Who invited you + the sign-up grace, on the real page (2026-11-07)
|
||||||
|
const nc = await signIn('qa-new@example.com', 'qanewone', null, '10.78.0.9');
|
||||||
|
const m0 = (await api('/api/me', null, { Cookie: nc })).j;
|
||||||
|
ok(m0 && m0.inviteAsk && m0.inviteAsk.dismissed === false, '/api/me: inviteAsk for a tank member', JSON.stringify(m0 && m0.inviteAsk));
|
||||||
|
const sc = await signIn('qa-sponsor@example.com', null, null, '10.78.0.10');
|
||||||
|
const tv = (await api('/api/my/tank', null, { Cookie: sc })).j; const row6 = tv && tv.waiting.find(w => w.email === 'qa-new@example.com');
|
||||||
|
ok(row6 && row6.opensAt > Date.now(), '/api/my/tank: a new sign-up is listed with opensAt', JSON.stringify(row6));
|
||||||
|
const bad = await api('/api/my/tank/invited', { who: 'nosuchname' }, { Cookie: nc });
|
||||||
|
ok(bad.status === 400 && /No member here/.test(bad.j.error), 'POST invited: unknown username refused', JSON.stringify(bad));
|
||||||
|
const self = await api('/api/my/tank/invited', { who: 'qanewone' }, { Cookie: nc });
|
||||||
|
ok(self.status === 400 && /That is you/.test(self.j.error), 'POST invited: self refused', JSON.stringify(self));
|
||||||
|
const anon = await api('/api/my/tank/invited', { who: 'qasponsor' });
|
||||||
|
ok(anon.status === 401, 'POST invited: signed out refused');
|
||||||
|
const { c, pg } = await actCtx(nc); await pg.goto(BASE + '/my#overview', { waitUntil: 'load' }); await pg.waitForTimeout(3500);
|
||||||
|
const vis = id => pg.evaluate(i => { const e = document.getElementById(i); return !!(e && !e.hidden); }, id);
|
||||||
|
ok(await vis('inviteCard'), 'Overview: Who invited you card shows');
|
||||||
|
await pg.screenshot({ path: path.join(SITE, 'qa/out/tank-invite-card.png') }).catch(() => {});
|
||||||
|
await pg.fill('#inviteWho', 'nosuchname'); await pg.click('#inviteGo'); await pg.waitForTimeout(700);
|
||||||
|
ok(/No member here/.test(await pg.textContent('#inviteMsg')), 'card: the refusal shows in the card', await pg.textContent('#inviteMsg'));
|
||||||
|
await pg.click('#inviteNo'); await pg.waitForTimeout(500);
|
||||||
|
ok(!(await vis('inviteCard')) && await vis('inviteSmall'), 'card: Nobody invited me hides it, the small link stays');
|
||||||
|
await pg.reload({ waitUntil: 'load' }); await pg.waitForTimeout(3000);
|
||||||
|
ok(!(await vis('inviteCard')) && await vis('inviteSmall'), 'card: stays dismissed after a reload');
|
||||||
|
await pg.click('#inviteBack'); await pg.fill('#inviteWho', '@qasponsor'); await pg.click('#inviteGo'); await pg.waitForSelector('#dlgCancel', { timeout: 8000 }).catch(async e => { throw new Error('no confirm box; card says: ' + await pg.textContent('#inviteMsg') + ' | ' + e.message.slice(0, 80)); });
|
||||||
|
await pg.click('#dlgCancel'); await pg.waitForTimeout(500);
|
||||||
|
ok(!(await api('/api/me', null, { Cookie: nc })).j.sponsorName, 'card: Not them writes nothing');
|
||||||
|
await pg.click('#inviteGo'); await pg.waitForSelector('#dlgOk', { timeout: 5000 }); await pg.click('#dlgOk'); await pg.waitForTimeout(2500);
|
||||||
|
const m1 = (await api('/api/me', null, { Cookie: nc })).j;
|
||||||
|
ok(m1 && m1.sponsorName === '@qasponsor' && !m1.inviteAsk, 'card: yes sets the sponsor, the card is gone', JSON.stringify({ n: m1 && m1.sponsorName, a: m1 && m1.inviteAsk }));
|
||||||
|
ok(!(await vis('inviteCard')) && !(await vis('inviteSmall')), 'card: nothing left on the Overview');
|
||||||
|
const adm6 = (await api('/api/admin/tank', null, adminH)).j;
|
||||||
|
ok(adm6.adoptions.some(a => a.adoptee === 'qa-new@example.com' && a.status === 'invited'), 'admin tank: the invited record shows');
|
||||||
|
await c.close();
|
||||||
|
const pc2 = await signIn('qa-kid2@example.com', 'qakidtwo', 'iap.sponsor=qasponsor', '10.78.0.11');
|
||||||
|
const m2 = (await api('/api/me', null, { Cookie: pc2 })).j;
|
||||||
|
ok(m2 && !m2.inviteAsk, 'a member who joined through a link never sees the card');
|
||||||
|
ok(!errs.length, 'no page errors (Who invited you)', errs.join(' | ').slice(0, 200));
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (browser) await browser.close().catch(() => {});
|
if (browser) await browser.close().catch(() => {});
|
||||||
try { srv.kill(); } catch (e) {}
|
try { srv.kill(); } catch (e) {}
|
||||||
@@ -363,6 +548,7 @@ async function partB() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await partA();
|
await partA();
|
||||||
|
await partGrace();
|
||||||
if (process.argv[2] !== 'unit') await partB();
|
if (process.argv[2] !== 'unit') await partB();
|
||||||
console.log(fails ? '\n' + fails + ' FAILED' : '\nall passed');
|
console.log(fails ? '\n' + fails + ' FAILED' : '\nall passed');
|
||||||
process.exit(fails ? 1 : 0);
|
process.exit(fails ? 1 : 0);
|
||||||
|
|||||||
@@ -229,6 +229,10 @@ async function record(p) {
|
|||||||
if (!out.repeat && out.kind === 'refuel' && X.feed && (!X.marks || await X.marks.claim('rffeed:' + tx))) {
|
if (!out.repeat && out.kind === 'refuel' && X.feed && (!X.marks || await X.marks.claim('rffeed:' + tx))) {
|
||||||
try { await X.feed(await feedLine(email, out)); } catch (e) { console.error('refuel feed', e.message); }
|
try { await X.feed(await feedLine(email, out)); } catch (e) { console.error('refuel feed', e.message); }
|
||||||
}
|
}
|
||||||
|
// a counted refuel of $50+ (either site) earns a Downline Banners spot, paid by the company (Marty 2026-11-13), once per tx
|
||||||
|
if (!out.repeat && out.kind === 'refuel' && cents >= 5000 && X.refuelSpot && (!X.marks || await X.marks.claim('rfspot:' + tx))) {
|
||||||
|
X.refuelSpot({ email, site, tx, cents }).catch(e => console.error('refuel spot', e.message));
|
||||||
|
}
|
||||||
await drainLocal().catch(e => console.error('refuel drain', e.message));
|
await drainLocal().catch(e => console.error('refuel drain', e.message));
|
||||||
if (out.kind && out.kind !== 'none') console.log('refuel:', site, out.kind, 'month', out.month, email.replace(/^(.).*(@.*)$/, '$1***$2'), String(tx).slice(0, 12));
|
if (out.kind && out.kind !== 'none') console.log('refuel:', site, out.kind, 'month', out.month, email.replace(/^(.).*(@.*)$/, '$1***$2'), String(tx).slice(0, 12));
|
||||||
return Object.assign({ on: true }, out);
|
return Object.assign({ on: true }, out);
|
||||||
|
|||||||
+2
-2
@@ -57,7 +57,7 @@ function renderPage() {
|
|||||||
const desc = 'What changed on InstantAdPay and what is coming next: release notes and the roadmap, updated as things ship.';
|
const desc = 'What changed on InstantAdPay and what is coming next: release notes and the roadmap, updated as things ship.';
|
||||||
let h = '<!doctype html><html lang="en"' + themehead.htmlAttr('dark') + '><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>What\'s new | InstantAdPay</title>'
|
let h = '<!doctype html><html lang="en"' + themehead.htmlAttr('dark') + '><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>What\'s new | InstantAdPay</title>'
|
||||||
+ '<meta name="description" content="' + esc(desc) + '"><link rel="canonical" href="' + SITE + '/whats-new"><meta property="og:title" content="What\'s new on InstantAdPay"><meta property="og:description" content="' + esc(desc) + '"><meta property="og:image" content="' + SITE + '/banners/iap-hero-1200x630.png"><meta name="twitter:card" content="summary_large_image">'
|
+ '<meta name="description" content="' + esc(desc) + '"><link rel="canonical" href="' + SITE + '/whats-new"><meta property="og:title" content="What\'s new on InstantAdPay"><meta property="og:description" content="' + esc(desc) + '"><meta property="og:image" content="' + SITE + '/banners/iap-hero-1200x630.png"><meta name="twitter:card" content="summary_large_image">'
|
||||||
+ '<link rel="icon" type="image/png" href="/logo-icon.png"><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">' + themehead.tag() + '<link rel="stylesheet" href="/assets/site.css?v=20261101th">'
|
+ '<link rel="icon" type="image/png" href="/logo-icon.png"><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">' + themehead.tag() + '<link rel="stylesheet" href="/assets/site.css?v=20261112ln">'
|
||||||
+ '<style>.wn{max-width:820px}.wn h1{margin:10px 0 6px}.wn .lead{margin:0 0 26px}.note{border-left:3px solid var(--mint);padding:4px 0 4px 18px;margin:0 0 26px}.note h2{font-size:21px;margin:0 0 4px}.note .when{color:var(--muted);font-size:13px;margin:0 0 8px}.note p,.note li{max-width:68ch}.note ul{margin:6px 0 0 20px}.tagc{display:inline-block;font-size:11px;letter-spacing:.08em;text-transform:uppercase;border-radius:999px;padding:2px 9px;margin-left:8px;vertical-align:middle;border:1px solid var(--line);color:var(--muted)}.tag-new{color:var(--mint);border-color:var(--mint-line-2)}.tag-improved{color:var(--cyan);border-color:var(--cyan-line)}.tag-fixed{color:var(--gold);border-color:var(--gold-line)}.rm{display:grid;gap:10px;margin:0 0 30px}.rmi{display:flex;gap:14px;align-items:flex-start;background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:12px 16px}.rmi b{display:block}.rmi span{color:var(--muted);font-size:14px}.st{flex:0 0 auto;font-size:11px;letter-spacing:.08em;text-transform:uppercase;border-radius:999px;padding:3px 10px;border:1px solid var(--line);color:var(--muted);margin-top:3px}.st-building{color:var(--mint);border-color:var(--mint-line-2)}.st-planned{color:var(--cyan);border-color:var(--cyan-line)}</style></head><body><div class="wrap wn">'
|
+ '<style>.wn{max-width:820px}.wn h1{margin:10px 0 6px}.wn .lead{margin:0 0 26px}.note{border-left:3px solid var(--mint);padding:4px 0 4px 18px;margin:0 0 26px}.note h2{font-size:21px;margin:0 0 4px}.note .when{color:var(--muted);font-size:13px;margin:0 0 8px}.note p,.note li{max-width:68ch}.note ul{margin:6px 0 0 20px}.tagc{display:inline-block;font-size:11px;letter-spacing:.08em;text-transform:uppercase;border-radius:999px;padding:2px 9px;margin-left:8px;vertical-align:middle;border:1px solid var(--line);color:var(--muted)}.tag-new{color:var(--mint);border-color:var(--mint-line-2)}.tag-improved{color:var(--cyan);border-color:var(--cyan-line)}.tag-fixed{color:var(--gold);border-color:var(--gold-line)}.rm{display:grid;gap:10px;margin:0 0 30px}.rmi{display:flex;gap:14px;align-items:flex-start;background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:12px 16px}.rmi b{display:block}.rmi span{color:var(--muted);font-size:14px}.st{flex:0 0 auto;font-size:11px;letter-spacing:.08em;text-transform:uppercase;border-radius:999px;padding:3px 10px;border:1px solid var(--line);color:var(--muted);margin-top:3px}.st-building{color:var(--mint);border-color:var(--mint-line-2)}.st-planned{color:var(--cyan);border-color:var(--cyan-line)}</style></head><body><div class="wrap wn">'
|
||||||
+ '<section class="hero" style="padding:56px 0 8px"><p class="eyebrow">Release notes and roadmap</p><h1>What\'s new, <em>and what\'s next</em>.</h1><p class="lead">' + esc(desc) + '</p></section>';
|
+ '<section class="hero" style="padding:56px 0 8px"><p class="eyebrow">Release notes and roadmap</p><h1>What\'s new, <em>and what\'s next</em>.</h1><p class="lead">' + esc(desc) + '</p></section>';
|
||||||
h += '<h2 style="font-size:24px;margin:0 0 12px">On the roadmap</h2>';
|
h += '<h2 style="font-size:24px;margin:0 0 12px">On the roadmap</h2>';
|
||||||
@@ -65,7 +65,7 @@ function renderPage() {
|
|||||||
h += '<h2 style="font-size:24px;margin:10px 0 16px">Release notes</h2>';
|
h += '<h2 style="font-size:24px;margin:10px 0 16px">Release notes</h2>';
|
||||||
h += v.notes.length ? v.notes.map(n => '<article class="note" id="' + esc(n.id) + '"><h2>' + esc(n.title) + n.tags.map(tagChip).join('') + '</h2><p class="when">' + fmt(n.date) + '</p>' + bodyHtml(n.body) + '</article>').join('') : '<p class="muted">No notes yet.</p>';
|
h += v.notes.length ? v.notes.map(n => '<article class="note" id="' + esc(n.id) + '"><h2>' + esc(n.title) + n.tags.map(tagChip).join('') + '</h2><p class="when">' + fmt(n.date) + '</p>' + bodyHtml(n.body) + '</article>').join('') : '<p class="muted">No notes yet.</p>';
|
||||||
h += '<p class="muted small" style="margin-top:30px">Suggestions and bug reports: the chat bubble on any page, or the InstantAdPay Telegram group.</p>';
|
h += '<p class="muted small" style="margin-top:30px">Suggestions and bug reports: the chat bubble on any page, or the InstantAdPay Telegram group.</p>';
|
||||||
h += '</div><script src="/assets/common.js?v=20261023ov"></script><script src="/assets/blog-page.js?v=20260914a"></script></body></html>';
|
h += '</div><script src="/assets/common.js?v=20261114ns"></script><script src="/assets/blog-page.js?v=20260914a"></script></body></html>';
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
module.exports = { init, notes, roadmap, saveNote, saveRoadmap, remove, publicView, renderPage, bodyHtml, TAGS, STATUSES };
|
module.exports = { init, notes, roadmap, saveNote, saveRoadmap, remove, publicView, renderPage, bodyHtml, TAGS, STATUSES };
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// Atomic JSON data files (2026-11-13 incident). Every store here saves with fs.writeFileSync(file.json, ...), which truncates
|
||||||
|
// the file and then writes it. During a deploy the old and new app copies share the volume for a few seconds; the new copy read
|
||||||
|
// rotator.json while the old one was half way through writing it, JSON.parse failed, the store fell back to EMPTY and its next
|
||||||
|
// save wrote that empty list over 294 spin links. This makes every .json write inside DATA_DIR atomic (write a temp file in the
|
||||||
|
// same folder, then rename it over the real one), so a reader only ever sees the old file or the new one, never half of one.
|
||||||
|
// The SAME file ships in InstantAdPay and LinkSpin; server.js installs it right after DATA_DIR is known.
|
||||||
|
'use strict';
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
let installed = false;
|
||||||
|
function install(dataDir) {
|
||||||
|
if (installed) return; installed = true;
|
||||||
|
const root = path.resolve(dataDir) + path.sep;
|
||||||
|
const orig = fs.writeFileSync;
|
||||||
|
fs.writeFileSync = function (file, data, opts) {
|
||||||
|
const flag = opts && typeof opts === 'object' ? opts.flag : null;
|
||||||
|
if (typeof file === 'string' && /\.json$/i.test(file) && (!flag || flag === 'w') && path.resolve(file).startsWith(root)) {
|
||||||
|
const tmp = file + '.tmp-' + process.pid + '-' + Math.random().toString(36).slice(2, 8);
|
||||||
|
try { orig.call(fs, tmp, data, opts); fs.renameSync(tmp, file); }
|
||||||
|
catch (e) { try { fs.unlinkSync(tmp); } catch (x) {} throw e; }
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return orig.apply(fs, arguments);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
module.exports = { install };
|
||||||
@@ -16,6 +16,8 @@ const { URL } = require('url');
|
|||||||
const chain = require('./chain');
|
const chain = require('./chain');
|
||||||
const auth = require('./auth');
|
const auth = require('./auth');
|
||||||
const accounts = require('./accounts');
|
const accounts = require('./accounts');
|
||||||
|
const forumsso = require('./forumsso'); // Earners Corner forum sign-in (DiscourseConnect, 2026-11-10)
|
||||||
|
const networksso = require('./networksso'); // network sign-in with LinkSpin (2026-11-12, Marty approved): see networksso.js
|
||||||
const themehead = require('./themehead'); // 2026-11-01 light/dark theme head script for server-rendered pages + its CSP hash
|
const themehead = require('./themehead'); // 2026-11-01 light/dark theme head script for server-rendered pages + its CSP hash
|
||||||
const ads = require('./ads');
|
const ads = require('./ads');
|
||||||
const mailer = require('./mailer');
|
const mailer = require('./mailer');
|
||||||
@@ -51,11 +53,45 @@ const sbcheck = require('./sbcheck');
|
|||||||
const reach = require('./reach');
|
const reach = require('./reach');
|
||||||
const lssync = require('./lssync');
|
const lssync = require('./lssync');
|
||||||
const lsconv = require('./lsconv'); // conversion tracking: ad click ids pushed to LinkSpin + the member's goals (2026-10-23)
|
const lsconv = require('./lsconv'); // conversion tracking: ad click ids pushed to LinkSpin + the member's goals (2026-10-23)
|
||||||
|
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 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 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)
|
const SF = require('./sponsorfollow'); // deliberate sponsor changes follow to LinkSpin until chain-bound + one network tank (2026-10-22)
|
||||||
const bixpay = require('./bixpay'); // BixPay Visa card: partner-link field, sponsor-follows resolver, tracked clicks (2026-10-29, gated by site config bixpayLive)
|
const bixpay = require('./bixpay'); // BixPay Visa card: partner-link field, sponsor-follows resolver, tracked clicks (2026-10-29, gated by site config bixpayLive)
|
||||||
let follow = null, followStore = null;
|
let follow = null, followStore = null;
|
||||||
const LS_BASE = () => String(process.env.LS_URL || 'https://linkspin.app').replace(/\/+$/, '');
|
const LS_BASE = () => String(process.env.LS_URL || 'https://linkspin.app').replace(/\/+$/, '');
|
||||||
|
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 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
|
||||||
|
// their network sponsor's wallet as sponsor. Signed with NETWORK_SSO_SECRET ('net.v1.' + ts + newline + raw body).
|
||||||
|
async function refuelSpotToBL({ email, site, tx, cents }) {
|
||||||
|
const a = await accounts.byEmail(email).catch(() => null);
|
||||||
|
const mask = String(email).replace(/^(.).*(@.*)$/, '$1***$2');
|
||||||
|
if (!a || !a.address) { console.log('refuel spot: no wallet linked, not sent', mask); return; }
|
||||||
|
const sp = await accounts.sponsorOf(email).catch(() => null);
|
||||||
|
const raw = JSON.stringify({ tx, site, cents, wallet: a.address, sponsorWallet: sp && sp.address ? sp.address : null });
|
||||||
|
const sec = String(process.env.NETWORK_SSO_SECRET || '').trim(); if (sec.length < 32) return;
|
||||||
|
for (let i = 0; i < 4; i++) {
|
||||||
|
const ts = String(Date.now()); const sig = crypto.createHmac('sha256', sec).update('net.v1.' + ts + '\n' + raw).digest('hex');
|
||||||
|
try {
|
||||||
|
const r = await fetch(BL_BASE() + '/api/partner/refuel-spot', { method: 'POST', body: raw, signal: AbortSignal.timeout(10000), headers: { 'Content-Type': 'application/json', 'X-Net-Ts': ts, 'X-Net-Sig': sig } });
|
||||||
|
const j = await r.json().catch(() => ({}));
|
||||||
|
if (r.ok) {
|
||||||
|
console.log('refuel spot queued on Downline Banners', mask, String(tx).slice(0, 12), j.repeat ? '(repeat)' : '');
|
||||||
|
if (!j.repeat) await messages.deliver(1, ADMIN_EMAIL || 'house@instantadpay.com', [a.email], 'Your refuel earned a Downline Banners spot',
|
||||||
|
'<p>Your $' + (cents / 100).toFixed(0) + ' refuel earned you a free spot on <a href="https://downlinebanners.com/my">Downline Banners</a>, the network banner board. It is being placed in the line for your wallet now.</p><p>Open <a href="https://downlinebanners.com/my">My Spots</a> to add your banner and link (or use one of your LinkSpin Banner Spins). Your InstantAdPay sign-in carries you in.</p>', 'notice').catch(() => {});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (r.status === 400 || r.status === 401) { console.error('refuel spot refused', r.status, j.error || '', mask); return; }
|
||||||
|
} catch (e) {}
|
||||||
|
await new Promise(ok => setTimeout(ok, 30000 * (i + 1)));
|
||||||
|
}
|
||||||
|
console.error('refuel spot: Downline Banners did not answer', mask, String(tx).slice(0, 12));
|
||||||
|
}
|
||||||
let activationCache = { at: 0, map: null };
|
let activationCache = { at: 0, map: null };
|
||||||
function activationByAddress() { // MemberActivated events by wallet, for the Sponsor check (when the contract bound the sponsor)
|
function activationByAddress() { // MemberActivated events by wallet, for the Sponsor check (when the contract bound the sponsor)
|
||||||
if (activationCache.map && Date.now() - activationCache.at < 60000) return activationCache.map;
|
if (activationCache.map && Date.now() - activationCache.at < 60000) return activationCache.map;
|
||||||
@@ -90,15 +126,18 @@ const supportbot = require('./supportbot'); // @CTBTickets_bot: ticket pings wit
|
|||||||
const tickets = require('./tickets'); // help desk: member Help pane, public /support, chatbot hand-off, admin Support pane (Marty, 2026-10-16)
|
const tickets = require('./tickets'); // help desk: member Help pane, public /support, chatbot hand-off, admin Support pane (Marty, 2026-10-16)
|
||||||
const pipeline = require('./pipeline'); // sponsor follow-up board (coming soon until site setting pipelineMode = on) (Marty, 2026-09-15)
|
const pipeline = require('./pipeline'); // sponsor follow-up board (coming soon until site setting pipelineMode = on) (Marty, 2026-09-15)
|
||||||
const videomaker = require('./videomaker'); // Circuit tool: promo videos with the member's own end card (ffmpeg in the image) // badge-gated promo toolkit + AI Copy Engine (Surge and up) (Marty, 2026-09-14) // referral contest: /leaderboard, Overview card, weekly + monthly winners (Marty, 2026-09-14) // release notes + roadmap: /whats-new, Overview card, Admin > Releases (Marty, 2026-09-14) // blog -> Blotato -> X + Instagram on publish (Marty, 2026-09-13) // admin member card: search, drilldown, edits (Marty, 2026-09-13) // admin-written coaching articles, server-rendered public /blog with SEO metadata (Marty, 2026-09-12)
|
const videomaker = require('./videomaker'); // Circuit tool: promo videos with the member's own end card (ffmpeg in the image) // badge-gated promo toolkit + AI Copy Engine (Surge and up) (Marty, 2026-09-14) // referral contest: /leaderboard, Overview card, weekly + monthly winners (Marty, 2026-09-14) // release notes + roadmap: /whats-new, Overview card, Admin > Releases (Marty, 2026-09-14) // blog -> Blotato -> X + Instagram on publish (Marty, 2026-09-13) // admin member card: search, drilldown, edits (Marty, 2026-09-13) // admin-written coaching articles, server-rendered public /blog with SEO metadata (Marty, 2026-09-12)
|
||||||
const TRAFFIC_PAGES = new Set(['/', '/ledger', '/contract', '/shorts', '/plays', '/wallets', '/launch', '/partners', '/earning', '/games', '/blog', '/whats-new', '/leaderboard', '/friday', '/wednesday', '/refuel', '/conversion-tracking', '/presentation', '/support', '/bixpay']);
|
const TRAFFIC_PAGES = new Set(['/chasing-unicorns', '/', '/ledger', '/contract', '/shorts', '/plays', '/wallets', '/launch', '/partners', '/earning', '/games', '/blog', '/whats-new', '/leaderboard', '/friday', '/wednesday', '/refuel', '/conversion-tracking', '/presentation', '/support', '/bixpay']);
|
||||||
let tankWaitCache = null; // dashboard: who is waiting for a sponsor (refreshed every minute)
|
let tankWaitCache = null; // dashboard: who is waiting for a sponsor (refreshed every minute)
|
||||||
const geo = require('./geo'); // viewer country -> tier (DB-IP lite), for campaign targeting
|
const geo = require('./geo'); // viewer country -> tier (DB-IP lite), for campaign targeting
|
||||||
|
const netsites = require('./netsites'); // footer network list from the hub (2026-11-14 trust pack)
|
||||||
const burner = require('./burner'); // automatic on-chain credit burns (inert without ENGINE_KEY)
|
const burner = require('./burner'); // automatic on-chain credit burns (inert without ENGINE_KEY)
|
||||||
|
|
||||||
const PORT = Number(process.env.PORT || 3000);
|
const PORT = Number(process.env.PORT || 3000);
|
||||||
const ROOT = __dirname;
|
const ROOT = __dirname;
|
||||||
const PUBLIC_DIR = path.join(ROOT, 'public');
|
const PUBLIC_DIR = path.join(ROOT, 'public');
|
||||||
const DATA_DIR = process.env.DATA_DIR || path.join(ROOT, 'data');
|
const DATA_DIR = process.env.DATA_DIR || path.join(ROOT, 'data');
|
||||||
|
require('./safefs').install(DATA_DIR); // every .json data file is written atomically (2026-11-13 rotator.json loss)
|
||||||
|
const docstore = require('./docstore'); docstore.install(DATA_DIR); // data documents live in MySQL when DOCSTORE_URL is set (2026-11-13, database is the standard)
|
||||||
const ADMIN_PASSWORD = process.env.ADMIN_PASSWORD || 'changeme';
|
const ADMIN_PASSWORD = process.env.ADMIN_PASSWORD || 'changeme';
|
||||||
const ADMIN_EMAIL = String(process.env.ADMIN_EMAIL || '').trim().toLowerCase();
|
const ADMIN_EMAIL = String(process.env.ADMIN_EMAIL || '').trim().toLowerCase();
|
||||||
// Admin portal sessions: email-code sign-in allowlisted to ADMIN_EMAIL, kept
|
// Admin portal sessions: email-code sign-in allowlisted to ADMIN_EMAIL, kept
|
||||||
@@ -107,7 +146,7 @@ const ADMIN_EMAIL = String(process.env.ADMIN_EMAIL || '').trim().toLowerCase();
|
|||||||
const ADMIN_SESS_FILE = path.join(DATA_DIR, 'admin-sessions.json');
|
const ADMIN_SESS_FILE = path.join(DATA_DIR, 'admin-sessions.json');
|
||||||
const ADMIN_TTL = 12 * 60 * 60 * 1000;
|
const ADMIN_TTL = 12 * 60 * 60 * 1000;
|
||||||
let adminSessions = {};
|
let adminSessions = {};
|
||||||
try { adminSessions = JSON.parse(fs.readFileSync(ADMIN_SESS_FILE, 'utf8')) || {}; } catch (e) { adminSessions = {}; }
|
if (!process.env.DOCSTORE_URL) { try { adminSessions = JSON.parse(fs.readFileSync(ADMIN_SESS_FILE, 'utf8')) || {}; } catch (e) { adminSessions = {}; } } // with MySQL: loaded right after docstore.init
|
||||||
function saveAdminSessions() {
|
function saveAdminSessions() {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
for (const k of Object.keys(adminSessions)) if (!adminSessions[k] || adminSessions[k].expires < now) delete adminSessions[k];
|
for (const k of Object.keys(adminSessions)) if (!adminSessions[k] || adminSessions[k].expires < now) delete adminSessions[k];
|
||||||
@@ -160,7 +199,7 @@ function loadOpenTokens() {
|
|||||||
const cutoff = Date.now() - 2 * 3600 * 1000; let n = 0;
|
const cutoff = Date.now() - 2 * 3600 * 1000; let n = 0;
|
||||||
// durable maps are balances and orders, not short-lived tokens: restore every entry whatever its age. Before 2026-10-10 the
|
// durable maps are balances and orders, not short-lived tokens: restore every entry whatever its age. Before 2026-10-10 the
|
||||||
// age filter silently dropped every PolyWarriors mint pass (no ts on the record) on each deploy; Orlando lost his.
|
// age filter silently dropped every PolyWarriors mint pass (no ts on the record) on each deploy; Orlando lost his.
|
||||||
const DURABLE = new Set(['pwpasses', 'pwprizes', 'pworders', 'gkorders', 'sdorders', 'gamepass', 'gporders', 'gpprizes']);
|
const DURABLE = new Set(['pwpasses', 'pwprizes', 'pworders', 'gkorders', 'sdorders', 'gamepass', 'gporders', 'gpprizes', 'stackpro']);
|
||||||
for (const [name, m] of Object.entries(persistedMaps)) {
|
for (const [name, m] of Object.entries(persistedMaps)) {
|
||||||
for (const [k, v] of Object.entries(saved[name] || {})) if (v && (DURABLE.has(name) || Number(v.ts || 0) > cutoff)) { Map.prototype.set.call(m, k, v); n++; }
|
for (const [k, v] of Object.entries(saved[name] || {})) if (v && (DURABLE.has(name) || Number(v.ts || 0) > cutoff)) { Map.prototype.set.call(m, k, v); n++; }
|
||||||
}
|
}
|
||||||
@@ -532,9 +571,16 @@ async function frameCheck(url, inGame) {
|
|||||||
}
|
}
|
||||||
async function boot() {
|
async function boot() {
|
||||||
await db.init({ dataDir: DATA_DIR }); // no-op without DATABASE_URL (JSON mode)
|
await db.init({ dataDir: DATA_DIR }); // no-op without DATABASE_URL (JSON mode)
|
||||||
|
await docstore.init({}); // before any module reads its data
|
||||||
|
process.on('SIGTERM', () => { docstore.drain(8000).finally(() => process.exit(0)); });
|
||||||
|
if (process.env.DOCSTORE_URL) { try { adminSessions = JSON.parse(fs.readFileSync(ADMIN_SESS_FILE, 'utf8')) || {}; } catch (e) { adminSessions = {}; } }
|
||||||
marks.init({ db });
|
marks.init({ db });
|
||||||
marks.ensureTable().catch(e => console.error('marks table', e.message));
|
marks.ensureTable().catch(e => console.error('marks table', e.message));
|
||||||
lsconv.init({ db, dataDir: DATA_DIR });
|
lsconv.init({ db, dataDir: DATA_DIR });
|
||||||
|
lsreport.init({ db, dataDir: DATA_DIR });
|
||||||
|
accounts.onWalletLinked(hubsync.enabled()
|
||||||
|
? e => { lsreport.wallet(e).catch(err => console.error('lsreport wallet', err.message)); hubsync.wallet(e); }
|
||||||
|
: e => { lsreport.wallet(e).catch(err => console.error('lsreport wallet', err.message)); });
|
||||||
auth.onSeen((email, req) => lsconv.noteSession(email, clientIp(req), req.headers['user-agent'])); // own-click tests on LinkSpin (2026-10-26)
|
auth.onSeen((email, req) => lsconv.noteSession(email, clientIp(req), req.headers['user-agent'])); // own-click tests on LinkSpin (2026-10-26)
|
||||||
setInterval(() => marks.prune().catch(() => {}), 6 * 3600 * 1000).unref();
|
setInterval(() => marks.prune().catch(() => {}), 6 * 3600 * 1000).unref();
|
||||||
chain.init({ onEvent: ev => {
|
chain.init({ onEvent: ev => {
|
||||||
@@ -550,21 +596,50 @@ async function boot() {
|
|||||||
starter.onEvent(ev).catch(e => console.error('starter bonus', e.message));
|
starter.onEvent(ev).catch(e => console.error('starter bonus', e.message));
|
||||||
pwMintOnEvent(ev).catch(e => console.error('polywarriors mint', e.message));
|
pwMintOnEvent(ev).catch(e => console.error('polywarriors mint', e.message));
|
||||||
// the Friday bonus and the pass order first, then the Friday pass perk, which needs both results (Marty 2026-10-23)
|
// the Friday bonus and the pass order first, then the Friday pass perk, which needs both results (Marty 2026-10-23)
|
||||||
Promise.all([friday.onEvent(ev).catch(e => { console.error('friday bonus', e.message); return null; }), gamepass.onEvent(ev).catch(e => { console.error('gamepass order', e.message); return null; })])
|
Promise.all([friday.onEvent(ev).catch(e => { console.error('friday bonus', e.message); return null; }), gamepass.onEvent(ev).then(r => { if (r && r.stackPro && r.email) stackProMark(r.email).catch(() => {}); return r; }).catch(e => { console.error('gamepass order', e.message); return null; })])
|
||||||
.then(([bonus, gp]) => fridayPassPerk(ev, bonus, gp)).catch(e => console.error('friday pass perk', e.message));
|
.then(([bonus, gp]) => fridayPassPerk(ev, bonus, gp)).catch(e => console.error('friday pass perk', e.message));
|
||||||
wednesday.onEvent(ev).catch(e => console.error('wednesday bonus', e.message));
|
wednesday.onEvent(ev).catch(e => console.error('wednesday bonus', e.message));
|
||||||
refuel.onIapPurchase(ev).catch(e => console.error('refuel streak', e.message)); // its own bonus, stacked on Friday/Wednesday; no-op while refuelStreak is off
|
refuel.onIapPurchase(ev).catch(e => console.error('refuel streak', e.message)); // its own bonus, stacked on Friday/Wednesday; no-op while refuelStreak is off
|
||||||
sponsorSyncOnEvent(ev).catch(e => console.error('sponsor sync', e.message));
|
sponsorSyncOnEvent(ev).catch(e => console.error('sponsor sync', e.message));
|
||||||
|
hubsync.onChain(ev); // network hub: payout switch-on -> contract bind (no-op unless HUB_ENABLED)
|
||||||
|
lsReportPurchase(ev).catch(e => console.error('lsreport purchase', e.message)); // reporting only: one local row, delivered in the background
|
||||||
}).catch(e => console.error('marks claim', e.message));
|
}).catch(e => console.error('marks claim', e.message));
|
||||||
} });
|
} });
|
||||||
auth.init({ dataDir: DATA_DIR, chain, isProd: IS_PROD, site: 'instantadpay.com' });
|
auth.init({ dataDir: DATA_DIR, chain, isProd: IS_PROD, site: 'instantadpay.com' });
|
||||||
|
// network sign-in (2026-11-12): a member signed in on LinkSpin arrives here signed in, and the other way round. Member sessions
|
||||||
|
// 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
|
||||||
|
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;
|
||||||
|
let email = s.email || null; if (!email && s.address) { try { const a = await accounts.byAddress(s.address); if (a && a.email) email = a.email; } catch (e) {} }
|
||||||
|
return email && !fraud.isSuspended(email) ? Object.assign({}, s, { email }) : null; },
|
||||||
|
accept: async email => {
|
||||||
|
const a = await accounts.byEmail(email);
|
||||||
|
if (!a) return { fallback: 'no account here yet' };
|
||||||
|
if (accounts.isUnclaimedShell(a)) return { fallback: 'waiting account, first sign-in needs the code' };
|
||||||
|
if (fraud.isSuspended(email) || fraud.isBlocked(email)) return { fallback: 'suspended or blocked' };
|
||||||
|
return { ok: true };
|
||||||
|
},
|
||||||
|
signIn: async (email, req) => { // the same session the email code makes (4 hours, same rights)
|
||||||
|
const a = await accounts.byEmail(email); let memberId = 0;
|
||||||
|
if (a && a.address) { try { memberId = await chain.memberIdByAccount(a.address); } catch (e) {} }
|
||||||
|
fraud.recordSeen(email, req).catch(() => {});
|
||||||
|
return auth.sessionCookie(await auth.mintSession({ email: a.email, address: a.address, memberId }));
|
||||||
|
},
|
||||||
|
// the dashboard runs the welcome tour / login ad after a sign-in (?welcome=1, the same step a code sign-in takes)
|
||||||
|
landing: to => { const x = new URL(to, 'http://x'); if (x.pathname === '/my') x.searchParams.set('welcome', '1'); return x.pathname + x.search + x.hash; },
|
||||||
|
signinPath: to => { const x = new URL(to, 'http://x'); return x.pathname === '/my' ? '/my' + x.hash : '/my'; } });
|
||||||
accounts.init({ dataDir: DATA_DIR });
|
accounts.init({ dataDir: DATA_DIR });
|
||||||
ads.init({ dataDir: DATA_DIR, chain, tiers: () => geo.tierLists(siteConfig()) });
|
ads.init({ dataDir: DATA_DIR, chain, tiers: () => geo.tierLists(siteConfig()) });
|
||||||
mailer.init({ dataDir: DATA_DIR });
|
mailer.init({ dataDir: DATA_DIR });
|
||||||
messages.init({ dataDir: DATA_DIR });
|
messages.init({ dataDir: DATA_DIR });
|
||||||
reports.init({ dataDir: DATA_DIR });
|
reports.init({ dataDir: DATA_DIR });
|
||||||
drip.init({ dataDir: DATA_DIR, mailer, accounts, chain, site: 'https://instantadpay.com' });
|
drip.init({ dataDir: DATA_DIR, mailer, accounts, chain, site: 'https://instantadpay.com' });
|
||||||
chatbot.init({ dataDir: DATA_DIR, chain, bixLive: () => bixpay.live(), gameLive: slug => String(siteConfig().gamesLive == null ? 'polhunter' : siteConfig().gamesLive).split(',').map(x => x.trim().toLowerCase()).includes(slug), refuelOn: () => refuel.cfg().on, passTiers: () => { const c = gamepass.cfg(); return { on: c.enabled && c.tierSales, rows: gamepass.TIER_DEFS.filter(d => d.key !== 'weekly').map(d => ({ name: d.name, perks: d.perks, price: c.tiers[d.key].price, usd: c.tiers[d.key].price / 100, days: c.tiers[d.key].days, sale: c.tiers[d.key].sale })) }; } }); // pass tiers fact follows sovTiers (2026-10-22)
|
chatbot.init({ dataDir: DATA_DIR, chain, bixLive: () => bixpay.live(), gameLive: slug => String(siteConfig().gamesLive == null ? 'polhunter' : siteConfig().gamesLive).split(',').map(x => x.trim().toLowerCase()).includes(slug), refuelOn: () => refuel.cfg().on, passTiers: () => { const c = gamepass.cfg(); return { on: c.enabled && c.tierSales, rows: gamepass.TIER_DEFS.filter(d => d.key !== 'weekly').map(d => ({ name: d.name, perks: d.perks, price: c.tiers[d.key].price, usd: c.tiers[d.key].price / 100, days: c.tiers[d.key].days, sale: c.tiers[d.key].sale })) }; },
|
||||||
|
heroSale: () => { const h = gamepass.cfg().heroes, N = Object.fromEntries(gamepass.HERO_DEFS.map(d => [d.key, d.name])); return { sale: h.sale, rows: gamepass.HERO_DEFS.map(d => ({ name: d.name, usd: h.price[d.key] / 100, free: h.price[d.key] === 0, freeAt: d.freeAt || null })), bundle: { names: h.bundle.heroes.map(k => N[k]), usd: h.bundle.price / 100 } }; } }); // pass tiers fact follows sovTiers (2026-10-22); bonus heroes follow heroSales (2026-11-05)
|
||||||
setTimeout(() => ads.dailySweep().catch(e => console.error('sweep', e.message)), 60 * 1000);
|
setTimeout(() => ads.dailySweep().catch(e => console.error('sweep', e.message)), 60 * 1000);
|
||||||
setInterval(() => ads.dailySweep().catch(e => console.error('sweep', e.message)), 60 * 60 * 1000);
|
setInterval(() => ads.dailySweep().catch(e => console.error('sweep', e.message)), 60 * 60 * 1000);
|
||||||
setInterval(() => ads.scheduleSweep().catch(e => console.error('schedule sweep', e.message)), 5 * 60 * 1000); // scheduled starts/ends
|
setInterval(() => ads.scheduleSweep().catch(e => console.error('schedule sweep', e.message)), 5 * 60 * 1000); // scheduled starts/ends
|
||||||
@@ -617,6 +692,7 @@ async function boot() {
|
|||||||
featuredPerDay: () => ads.rates().featuredPerDay || 40,
|
featuredPerDay: () => ads.rates().featuredPerDay || 40,
|
||||||
message: async (to, subject, html) => { await messages.deliver(1, ADMIN_EMAIL || 'house@instantadpay.com', [to], subject, html, 'notice'); },
|
message: async (to, subject, html) => { await messages.deliver(1, ADMIN_EMAIL || 'house@instantadpay.com', [to], subject, html, 'notice'); },
|
||||||
badge: (email, key) => postBadgeOnce(email, key, 'Monthly Refuel'),
|
badge: (email, key) => postBadgeOnce(email, key, 'Monthly Refuel'),
|
||||||
|
refuelSpot: refuelSpotToBL, // $50+ counted refuel -> one Downline Banners spot (2026-11-13)
|
||||||
feed: async text => { const sc = siteConfig(); if (!sc.telegramBotToken || !sc.telegramEchoChatId) return false; return telegramSend(sc.telegramEchoChatId, '\u{1F7E0} <b>InstantAdPay</b> \u00b7 ' + text, sc.telegramEchoTopicId); } });
|
feed: async text => { const sc = siteConfig(); if (!sc.telegramBotToken || !sc.telegramEchoChatId) return false; return telegramSend(sc.telegramEchoChatId, '\u{1F7E0} <b>InstantAdPay</b> \u00b7 ' + text, sc.telegramEchoTopicId); } });
|
||||||
kit.init({ dataDir: DATA_DIR, program: 'iap', publicDir: PUBLIC_DIR, siteUrl: 'https://instantadpay.com',
|
kit.init({ dataDir: DATA_DIR, program: 'iap', publicDir: PUBLIC_DIR, siteUrl: 'https://instantadpay.com',
|
||||||
entitled: async email => { const v = await refuel.view(email); return v && v.on ? { on: true, months: v.kits || {}, nextRefuel: v.refuelDayLabel || null, today: v.today || null } : { on: false }; },
|
entitled: async email => { const v = await refuel.view(email); return v && v.on ? { on: true, months: v.kits || {}, nextRefuel: v.refuelDayLabel || null, today: v.today || null } : { on: false }; },
|
||||||
@@ -654,9 +730,14 @@ async function boot() {
|
|||||||
sponsorAccount: em => accounts.byEmail(em),
|
sponsorAccount: em => accounts.byEmail(em),
|
||||||
wouldCycle: async (email, sp) => { let cur = sp; const seen = new Set(); for (let i = 0; cur && i < 60; i++) { if (cur.email === email || seen.has(cur.email)) return true; seen.add(cur.email); cur = await accounts.sponsorOf(cur.email); } return false; },
|
wouldCycle: async (email, sp) => { let cur = sp; const seen = new Set(); for (let i = 0; cur && i < 60; i++) { if (cur.email === email || seen.has(cur.email)) return true; seen.add(cur.email); cur = await accounts.sponsorOf(cur.email); } return false; },
|
||||||
activationOf: a => a.address ? activationByAddress().get(String(a.address).toLowerCase()) || null : null });
|
activationOf: a => a.address ? activationByAddress().get(String(a.address).toLowerCase()) || null : null });
|
||||||
tank.init({ dataDir: DATA_DIR, chain, accounts, messages, mailer, ads, site: 'https://instantadpay.com', follow, store: followStore,
|
tank.init({ capOpen: () => siteConfig().tankAdoptCap, dataDir: DATA_DIR, chain, accounts, messages, mailer, ads, site: 'https://instantadpay.com', follow, store: followStore,
|
||||||
// activation hold + 24-hour safety net (2026-10-27): a tank member is never bound under the fallback position
|
// activation hold + 24-hour safety net (2026-10-27): a tank member is never bound under the fallback position
|
||||||
hooks: { network: (email, address) => lsinbound.networkSponsor(email, address), isSuspended: em => fraud.isSuspended(em), excluded: em => fraud.excluded(em),
|
// network hub rule 3 (2026-11-14, only with HUB_ENABLED): the hub's sponsor comes first for alignment, and nobody it reports
|
||||||
|
// locked on a network contract or sponsored is offered, moved to the tank or auto-assigned (hubsync.js: cache + fail-safe)
|
||||||
|
hooks: { network: async (email, address) => (hubsync.enabled() ? await hubsync.hubSponsor(email).catch(() => null) : null) || lsinbound.networkSponsor(email, address),
|
||||||
|
networkHeld: hubsync.enabled() ? accts => hubsync.heldAmong(accts) : null, networkLocked: hubsync.enabled() ? email => hubsync.lockedAnywhere(email) : null,
|
||||||
|
isSuspended: em => fraud.isSuspended(em), excluded: em => fraud.excluded(em),
|
||||||
|
isDraftPick: id => draftpartner.isDraftPick(id), // a 5xYourTeam pick's adoption: draftpartner.js owns its 3-day window
|
||||||
payoutBlocked: id => payoutChainBlocked(id, 2), companyId: () => Number(siteConfig().defaultSponsorId) || 1,
|
payoutBlocked: id => payoutChainBlocked(id, 2), companyId: () => Number(siteConfig().defaultSponsorId) || 1,
|
||||||
assigned: r => { tankPickupPost(r.adopterName, r.adopteeName, true); }, adminAlert: text => tankAdminAlert(text),
|
assigned: r => { tankPickupPost(r.adopterName, r.adopteeName, true); }, adminAlert: text => tankAdminAlert(text),
|
||||||
// switch-on-payouts reminders after an assignment (2026-10-27): one send per key across both app copies (deploy overlap),
|
// switch-on-payouts reminders after an assignment (2026-10-27): one send per key across both app copies (deploy overlap),
|
||||||
@@ -666,6 +747,13 @@ async function boot() {
|
|||||||
// LinkSpin registry sync (2026-10-08): every account change is pushed to LinkSpin within seconds; a 2-minute reconcile catches the rest
|
// LinkSpin registry sync (2026-10-08): every account change is pushed to LinkSpin within seconds; a 2-minute reconcile catches the rest
|
||||||
lssync.init({ dataDir: DATA_DIR, accounts, follow: followStore, tank: () => tank }); accounts.onChange(email => lssync.touch(email));
|
lssync.init({ dataDir: DATA_DIR, accounts, follow: followStore, tank: () => tank }); accounts.onChange(email => lssync.touch(email));
|
||||||
lsinbound.init({ dataDir: DATA_DIR, accounts, lssync, follow, store: followStore });
|
lsinbound.init({ dataDir: DATA_DIR, accounts, lssync, follow, store: followStore });
|
||||||
|
// 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 }); 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({ dataDir: DATA_DIR, accounts, chain, tank, ads, requireHub: !(process.env.DRAFT_ALLOW_NO_HUB === '1' && process.env.NODE_ENV !== 'production'),
|
||||||
|
hooks: { hubInfo: email => (hubsync.enabled() ? hubsync.hubInfo(email) : null), resolvePerson: q => (hubsync.enabled() ? hubsync.resolvePerson(q) : null), networkOn: () => hubsync.enabled(),
|
||||||
|
excluded: em => fraud.excluded(em), spamEmails: () => (((spamscan.view() || {}).last || {}).candidates || []).map(c => c.email), suggestDomain: d => require('./emailcheck').suggestDomain(d) } }).catch(e => console.error('draftpartner init', e.message));
|
||||||
setTimeout(() => lssync.tick().catch(e => console.error('lssync', e.message)), 2 * 60 * 1000);
|
setTimeout(() => lssync.tick().catch(e => console.error('lssync', e.message)), 2 * 60 * 1000);
|
||||||
setInterval(() => lssync.tick().catch(e => console.error('lssync', e.message)), 2 * 60 * 1000);
|
setInterval(() => lssync.tick().catch(e => console.error('lssync', e.message)), 2 * 60 * 1000);
|
||||||
setInterval(() => follow.retryPending().catch(e => console.error('sponsorfollow retry', e.message)), 2 * 60 * 1000); // follows waiting on a chain read or a sponsor account
|
setInterval(() => follow.retryPending().catch(e => console.error('sponsorfollow retry', e.message)), 2 * 60 * 1000); // follows waiting on a chain read or a sponsor account
|
||||||
@@ -747,6 +835,7 @@ async function boot() {
|
|||||||
geo.init({ dataDir: DATA_DIR }).catch(e => console.error('geo init', e.message));
|
geo.init({ dataDir: DATA_DIR }).catch(e => console.error('geo init', e.message));
|
||||||
setInterval(() => geo.refresh().catch(e => console.error('geo refresh', e.message)), 24 * 3600 * 1000); // monthly file, checked daily
|
setInterval(() => geo.refresh().catch(e => console.error('geo refresh', e.message)), 24 * 3600 * 1000); // monthly file, checked daily
|
||||||
setInterval(() => tank.sweep().catch(e => console.error('tank sweep', e.message)), 60 * 60 * 1000); // adoptions past their 7-day window
|
setInterval(() => tank.sweep().catch(e => console.error('tank sweep', e.message)), 60 * 60 * 1000); // adoptions past their 7-day window
|
||||||
|
setInterval(() => draftpartner.sweep().then(r => { if (r.done || r.returned || r.kept || r.moved) console.log('draft sweep', JSON.stringify(r)); }).catch(e => console.error('draft sweep', e.message)), 60 * 60 * 1000); // 5xYourTeam picks: 3-day window
|
||||||
burner.init({ chain, ads, accounts });
|
burner.init({ chain, ads, accounts });
|
||||||
setTimeout(() => coach.nudgeTick().catch(e => console.error('coach', e.message)), 90 * 1000);
|
setTimeout(() => coach.nudgeTick().catch(e => console.error('coach', e.message)), 90 * 1000);
|
||||||
setInterval(() => coach.nudgeTick().catch(e => console.error('coach', e.message)), 60 * 60 * 1000);
|
setInterval(() => coach.nudgeTick().catch(e => console.error('coach', e.message)), 60 * 60 * 1000);
|
||||||
@@ -818,11 +907,12 @@ function siteConfig() {
|
|||||||
memberWeeklyEmail: '0', // 1 = the weekly 'Your week on InstantAdPay' email goes to every active member, not only sponsors with a line
|
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)
|
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)
|
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)
|
||||||
|
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>
|
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)
|
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)
|
||||||
geoTier2: '', // empty = built-in default (rest of Western/Central Europe, JP, KR, SG, HK, TW, IL, Gulf, ZA, BR, MX, AR, CL, CO ...); tier 3 = everything else
|
geoTier2: '', // empty = built-in default (rest of Western/Central Europe, JP, KR, SG, HK, TW, IL, Gulf, ZA, BR, MX, AR, CL, CO ...); tier 3 = everything else
|
||||||
// Game Pass (2026-10-16, docs/GAME-PASS.md): off until Marty flips it; caps apply from capsStartDate (Central), before it polgrant allows everything and only records
|
// Game Pass (2026-10-16, docs/GAME-PASS.md): off until Marty flips it; caps apply from capsStartDate (Central), before it polgrant allows everything and only records
|
||||||
gamePassEnabled: '0', gamePassPriceCredits: 500, gamePassDays: 7, capFreeDaily: 0.30, capFreeTotal: 2.0, capPassDaily: 1.50, capPassTotal: 5.0, capsStartDate: '', passTournamentPct: 5,
|
gamePassEnabled: '0', gamePassPriceCredits: 500, gamePassDays: 7, capFreeDaily: 0.30, capFreeTotal: 2.0, capFreeLifetime: 2.0, capPassDaily: 1.50, capPassTotal: 5.0, capsStartDate: '', passTournamentPct: 5,
|
||||||
// Explorer and Champion monthly passes beside the weekly one (2026-10-18, ultima-rpg docs/IAP-PASSES-SPEC.md): islands and looks
|
// Explorer and Champion monthly passes beside the weekly one (2026-10-18, ultima-rpg docs/IAP-PASSES-SPEC.md): islands and looks
|
||||||
// in Shards of Valor, never power, never more POL (same caps as the weekly pass). sovTiers = the sale switch for both (off: only ADMIN_EMAIL
|
// in Shards of Valor, never power, never more POL (same caps as the weekly pass). sovTiers = the sale switch for both (off: only ADMIN_EMAIL
|
||||||
// sees and can buy them, for testing; holders keep their pass). gamePass<Tier>Enabled '0' stops one tier alone. passTournamentTierSales '1'
|
// sees and can buy them, for testing; holders keep their pass). gamePass<Tier>Enabled '0' stops one tier alone. passTournamentTierSales '1'
|
||||||
@@ -832,13 +922,18 @@ function siteConfig() {
|
|||||||
// 2026-10-25 (Marty): prices = the one-click packages: Explorer $20, Champion $50, Sovereign $100, Legend $250 (cents below).
|
// 2026-10-25 (Marty): prices = the one-click packages: Explorer $20, Champion $50, Sovereign $100, Legend $250 (cents below).
|
||||||
sovTiers: '0', gamePassExplorerEnabled: '1', gamePassExplorerPriceCredits: 2000, gamePassExplorerDays: 30, gamePassChampionEnabled: '1', gamePassChampionPriceCredits: 5000, gamePassChampionDays: 30,
|
sovTiers: '0', gamePassExplorerEnabled: '1', gamePassExplorerPriceCredits: 2000, gamePassExplorerDays: 30, gamePassChampionEnabled: '1', gamePassChampionPriceCredits: 5000, gamePassChampionDays: 30,
|
||||||
gamePassSovereignEnabled: '1', gamePassSovereignPriceCredits: 10000, gamePassSovereignDays: 30, gamePassLegendEnabled: '1', gamePassLegendPriceCredits: 25000, gamePassLegendDays: 365, passTournamentTierSales: '0',
|
gamePassSovereignEnabled: '1', gamePassSovereignPriceCredits: 10000, gamePassSovereignDays: 30, gamePassLegendEnabled: '1', gamePassLegendPriceCredits: 25000, gamePassLegendDays: 365, passTournamentTierSales: '0',
|
||||||
|
// Shards of Valor bonus heroes (2026-11-05, Marty approved; gamepass.js HERO_DEFS): sold ONE TIME, paid by a fresh package like a pass.
|
||||||
|
// heroSales = the sale switch (OFF until Marty flips it; the admin tests from Admin > Game Pass). Prices in cents: 2000 = $20 (the
|
||||||
|
// Activation package); 0 = that hero is free for every account. heroBundleHeroes = the $50 bundle's list (default Valda, Morag,
|
||||||
|
// Roland). heroBundleCap = a level cap the bundle would raise to; leave EMPTY (Marty has not approved one: the bundle is heroes only).
|
||||||
|
heroSales: '0', heroPriceKestrelCents: 2000, heroPriceValdaCents: 2000, heroPriceMoragCents: 2000, heroPriceRolandCents: 2000, heroBundlePriceCents: 5000, heroBundleHeroes: 'valda,morag,roland', heroBundleCap: '',
|
||||||
supportTelegramChat: '1289244227', // help desk pings: Marty's PRIVATE chat only (a positive user id; group/channel ids are refused). Sent with telegramBotToken, Hermes bot as fallback
|
supportTelegramChat: '1289244227', // help desk pings: Marty's PRIVATE chat only (a positive user id; group/channel ids are refused). Sent with telegramBotToken, Hermes bot as fallback
|
||||||
supportTemplates: '', // help desk saved replies, JSON [{name, body}] (Admin > Support > Saved replies); empty = the built-in set
|
supportTemplates: '', // help desk saved replies, JSON [{name, body}] (Admin > Support > Saved replies); empty = the built-in set
|
||||||
telegramGamesChatId: '', telegramGamesTopicId: '661565', // Game Achievements topic for the weekly Pass Tournament post (chat blank = the shared echo chat)
|
telegramGamesChatId: '', telegramGamesTopicId: '661565', // Game Achievements topic for the weekly Pass Tournament post (chat blank = the shared echo chat)
|
||||||
// share-link domain (2026-10-20, Marty): member invite links go out as https://<shareDomain>/<username>, which 302s to
|
// share-link domain (2026-10-20, Marty): member invite links go out as https://<shareDomain>/<username>, which 302s to
|
||||||
// /join/<username> here, so shared links do not carry instantadpay.com (Spamhaus DBL). '' = old instantadpay.com/join links.
|
// /join/<username> here, so shared links do not carry instantadpay.com (Spamhaus DBL). '' = old instantadpay.com/join links.
|
||||||
// Switch to the spare (mylinehq.com) if one gets flagged. Old links keep working either way.
|
// Switch to the spare (mylinehq.com) if one gets flagged. Old links keep working either way.
|
||||||
shareDomain: 'ctbgo.com',
|
shareDomain: 'instantadpay.link',
|
||||||
// BixPay Visa card (2026-10-29, docs/BIXPAY-INTEGRATION.md): '0' = nothing shows anywhere (no Profile field, Wallet card,
|
// BixPay Visa card (2026-10-29, docs/BIXPAY-INTEGRATION.md): '0' = nothing shows anywhere (no Profile field, Wallet card,
|
||||||
// Overview card, promo tab, /bixpay guide, chatbot says coming soon). bixCompanyLink = the network fallback partner link
|
// Overview card, promo tab, /bixpay guide, chatbot says coming soon). bixCompanyLink = the network fallback partner link
|
||||||
// (Marty's own PARTNER link, IB12143793); bixpayLiveSince is stamped when the switch is flipped on (the Overview card runs a week).
|
// (Marty's own PARTNER link, IB12143793); bixpayLiveSince is stamped when the switch is flipped on (the Overview card runs a week).
|
||||||
@@ -852,7 +947,7 @@ const MIME = { '.html': 'text/html; charset=utf-8', '.css': 'text/css', '.js': '
|
|||||||
'.png': 'image/png', '.jpg': 'image/jpeg', '.svg': 'image/svg+xml', '.webp': 'image/webp',
|
'.png': 'image/png', '.jpg': 'image/jpeg', '.svg': 'image/svg+xml', '.webp': 'image/webp',
|
||||||
'.ico': 'image/x-icon', '.json': 'application/json', '.mp4': 'video/mp4', '.woff2': 'font/woff2',
|
'.ico': 'image/x-icon', '.json': 'application/json', '.mp4': 'video/mp4', '.woff2': 'font/woff2',
|
||||||
'.gif': 'image/gif', '.webm': 'video/webm', '.vtt': 'text/vtt; charset=utf-8', '.txt': 'text/plain; charset=utf-8', '.xml': 'application/xml; charset=utf-8' };
|
'.gif': 'image/gif', '.webm': 'video/webm', '.vtt': 'text/vtt; charset=utf-8', '.txt': 'text/plain; charset=utf-8', '.xml': 'application/xml; charset=utf-8' };
|
||||||
const CSP = "default-src 'self'; script-src 'self' https://cdn.jsdelivr.net https://www.networkadspace.com https://networkadspace.com https://polhunter.com 'sha256-NzvNrqk5jB9YZATwo5BF4JoRlJ02HsnFikbKXgEPdaQ=' " + themehead.CSP_HASH + "; worker-src 'self' blob:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: blob: https:; media-src 'self' https: blob:; connect-src 'self' https://polhunter.com https://*.walletconnect.com wss://*.walletconnect.com https://*.walletconnect.org wss://*.walletconnect.org https://*.reown.com wss://*.reown.com https://*.reown.org wss://*.reown.org https://*.web3modal.org https://*.drpc.org https://*.publicnode.com https://*.coinbase.com https://linkspin.app; font-src 'self' data: https://fonts.gstatic.com https://fonts.reown.com; form-action 'self'; frame-src https: http:";
|
const CSP = "default-src 'self'; script-src 'self' https://cdn.jsdelivr.net https://www.networkadspace.com https://networkadspace.com https://polhunter.com 'sha256-NzvNrqk5jB9YZATwo5BF4JoRlJ02HsnFikbKXgEPdaQ=' " + themehead.CSP_HASH + "; worker-src 'self' blob:; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: blob: https:; media-src 'self' https: blob:; connect-src 'self' https://polhunter.com https://*.walletconnect.com wss://*.walletconnect.com https://*.walletconnect.org wss://*.walletconnect.org https://*.reown.com wss://*.reown.com https://*.reown.org wss://*.reown.org https://*.web3modal.org https://*.drpc.org https://*.publicnode.com https://*.coinbase.com https://linkspin.app https://downlinebanners.com https://viralbannerblitz.com; font-src 'self' data: https://fonts.gstatic.com https://fonts.reown.com; form-action 'self'; frame-src https: http:";
|
||||||
function baseHeaders(extra) {
|
function baseHeaders(extra) {
|
||||||
return Object.assign({ 'Content-Security-Policy': CSP, 'X-Content-Type-Options': 'nosniff',
|
return Object.assign({ 'Content-Security-Policy': CSP, 'X-Content-Type-Options': 'nosniff',
|
||||||
'Referrer-Policy': 'strict-origin-when-cross-origin' }, extra || {});
|
'Referrer-Policy': 'strict-origin-when-cross-origin' }, extra || {});
|
||||||
@@ -888,6 +983,13 @@ function readRaw(req, maxBytes) {
|
|||||||
req.on('error', reject);
|
req.on('error', reject);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// Stack POL Pro paid (2026-11-09): mark the member in stack-optin.json so the stackpol.com indexer shows their LinkSpin links next run
|
||||||
|
async function stackProMark(email) {
|
||||||
|
const a = await accounts.byEmail(email); const un = String((a && a.username) || '').toLowerCase(); if (!un) return;
|
||||||
|
const F = path.join(DATA_DIR, 'stack-optin.json'); let so = { users: {} }; try { so = JSON.parse(fs.readFileSync(F, 'utf8')); } catch (e) {}
|
||||||
|
so.users = so.users || {}; so.pro = so.pro || {}; so.pro[un] = true; so.users[un] = true; so.updatedAt = Date.now();
|
||||||
|
const tmp = F + '.tmp'; fs.writeFileSync(tmp, JSON.stringify(so)); fs.renameSync(tmp, F);
|
||||||
|
}
|
||||||
function readBody(req) {
|
function readBody(req) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let d = ''; let n = 0;
|
let d = ''; let n = 0;
|
||||||
@@ -1050,6 +1152,15 @@ async function postWalkUp(buyerId, oldRef, toId, pur) {
|
|||||||
// The referral follows the money (Marty, 2026-09-16): when a position is created on-chain under a
|
// The referral follows the money (Marty, 2026-09-16): when a position is created on-chain under a
|
||||||
// different sponsor than the account's stored referrer (walk-up past an unactivated sponsor, or the
|
// different sponsor than the account's stored referrer (walk-up past an unactivated sponsor, or the
|
||||||
// catch-position fallback), move the account to the sponsor that actually got paid, #1 included.
|
// catch-position fallback), move the account to the sponsor that actually got paid, #1 included.
|
||||||
|
// a package Purchase, for the click on the buyer's account (lsreport.js, reporting only). The buyer's account: main member id, a linked
|
||||||
|
// position, or on a first purchase, when member_id is not stored yet, through the wallet the contract holds for that id.
|
||||||
|
async function lsReportPurchase(ev) {
|
||||||
|
if (!ev || ev.type !== 'Purchase' || !ev.buyerId) return;
|
||||||
|
let a = await accounts.byMemberId(ev.buyerId);
|
||||||
|
if (!a) { const pos = await accounts.positionByMember(ev.buyerId); if (pos && pos.email) a = { email: pos.email }; }
|
||||||
|
if (!a) { const m = await chain.member(ev.buyerId); if (m && m.account) { a = await accounts.byAddress(m.account); if (!a) { const pos = await accounts.positionOwner(m.account); if (pos && pos.email) a = { email: pos.email }; } } }
|
||||||
|
if (a && a.email) await lsreport.purchase(ev, a.email);
|
||||||
|
}
|
||||||
async function sponsorSyncOnEvent(ev) {
|
async function sponsorSyncOnEvent(ev) {
|
||||||
if (!ev || ev.type !== 'MemberActivated' || !ev.account) return;
|
if (!ev || ev.type !== 'MemberActivated' || !ev.account) return;
|
||||||
const acct = await accounts.byAddress(ev.account); if (!acct) return;
|
const acct = await accounts.byAddress(ev.account); if (!acct) return;
|
||||||
@@ -1506,12 +1617,17 @@ async function tankNotifyTick() {
|
|||||||
const f = path.join(DATA_DIR, 'tank-notify.json');
|
const f = path.join(DATA_DIR, 'tank-notify.json');
|
||||||
let st = { last: 0 }; try { st = JSON.parse(fs.readFileSync(f, 'utf8')); } catch (e) {}
|
let st = { last: 0 }; try { st = JSON.parse(fs.readFileSync(f, 'utf8')); } catch (e) {}
|
||||||
const since = st.last || (Date.now() - 24 * 3600 * 1000);
|
const since = st.last || (Date.now() - 24 * 3600 * 1000);
|
||||||
const fresh = (await tank.waiting()).filter(w => (w.joined || 0) > since);
|
// sign-up grace (2026-11-07): announced when they can be adopted, 24 hours after sign-up, not when they arrive. graceFrom =
|
||||||
|
// the first run of this rule: anyone who joined before it was already announced at sign-up.
|
||||||
|
const graceFrom = st.graceFrom || (st.graceFrom = st.last || Date.now());
|
||||||
|
const fresh = [];
|
||||||
|
const all = await tank.waiting(); // the running total goes in the post too (Marty 2026-11-14: "post those totals")
|
||||||
|
for (const w of tank.openedSince(all, since)) if ((w.joined || 0) > graceFrom && await marks.claim('tankopen:' + w.email + ':' + (w.joined || 0))) fresh.push(w);
|
||||||
st.last = Date.now(); fs.writeFileSync(f, JSON.stringify(st));
|
st.last = Date.now(); fs.writeFileSync(f, JSON.stringify(st));
|
||||||
if (!fresh.length) return;
|
if (!fresh.length) return;
|
||||||
const named = fresh.filter(w => w.username).map(w => '@' + w.username);
|
const named = fresh.filter(w => w.username).map(w => '@' + w.username);
|
||||||
const who = named.length ? ': ' + named.slice(0, 8).join(', ') + (named.length > 8 ? ' and ' + (named.length - 8) + ' more' : '') : '';
|
const who = named.length ? ': ' + named.slice(0, 8).join(', ') + (named.length > 8 ? ' and ' + (named.length - 8) + ' more' : '') : '';
|
||||||
const text = '\u{1FAA3} <b>InstantAdPay</b> \u00b7 ' + fresh.length + ' new member' + (fresh.length === 1 ? '' : 's') + ' waiting for a sponsor in the holding tank' + who
|
const text = '\u{1FAA3} <b>InstantAdPay</b> \u00b7 ' + fresh.length + ' new member' + (fresh.length === 1 ? '' : 's') + ' waiting for a sponsor in the holding tank' + who + ' (' + tank.adoptableOf(all).length + ' waiting in total)'
|
||||||
+ '\nAdopt from My line \u203a Holding tank: <a href="https://instantadpay.com/my#line">instantadpay.com/my</a>';
|
+ '\nAdopt from My line \u203a Holding tank: <a href="https://instantadpay.com/my#line">instantadpay.com/my</a>';
|
||||||
await telegramSend(sc.telegramEchoChatId, text, sc.telegramEchoTopicId);
|
await telegramSend(sc.telegramEchoChatId, text, sc.telegramEchoTopicId);
|
||||||
}
|
}
|
||||||
@@ -1549,11 +1665,11 @@ async function tankReadyTick() {
|
|||||||
// linked" with the last sign-in, so adopters can judge (Marty 2026-10-29: the old wording read as a live member)
|
// linked" with the last sign-in, so adopters can judge (Marty 2026-10-29: the old wording read as a live member)
|
||||||
const seen = ms => { try { return new Date(ms).toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'America/Chicago' }); } catch (e) { return ''; } };
|
const seen = ms => { try { return new Date(ms).toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'America/Chicago' }); } catch (e) { return ''; } };
|
||||||
for (const w of r.fresh) await telegramSend(sc.telegramEchoChatId, '\u{1F7E2} ' + (w.username ? '@' + clean(w.username) : 'A new member')
|
for (const w of r.fresh) await telegramSend(sc.telegramEchoChatId, '\u{1F7E2} ' + (w.username ? '@' + clean(w.username) : 'A new member')
|
||||||
+ (w.linkedNow ? ' linked a wallet and is ready to switch on payouts. Adopt them from the holding tank in the next 24 hours: '
|
+ (w.linkedNow ? ' linked a wallet and is ready to switch on payouts. Adopt them from the holding tank in the next ' + tank.leftText(w.until - Date.now()) + ': '
|
||||||
: ' is in the holding tank with a wallet already linked' + (w.lastSeen ? ' (last seen ' + seen(w.lastSeen) + ')' : '') + '. Adopt them in the next 24 hours: ') + link, sc.telegramEchoTopicId).catch(() => {});
|
: ' is in the holding tank with a wallet already linked' + (w.lastSeen ? ' (last seen ' + seen(w.lastSeen) + ')' : '') + '. Adopt them in the next ' + tank.leftText(w.until - Date.now()) + ': ') + link, sc.telegramEchoTopicId).catch(() => {});
|
||||||
} else { // first run after deploy (the members already linked) or a busy quarter hour: one digest, not a wall of posts
|
} else { // first run after deploy (the members already linked) or a busy quarter hour: one digest, not a wall of posts
|
||||||
const named = r.fresh.filter(w => w.username).map(w => '@' + clean(w.username));
|
const named = r.fresh.filter(w => w.username).map(w => '@' + clean(w.username));
|
||||||
await telegramSend(sc.telegramEchoChatId, '\u{1F7E2} ' + r.fresh.length + ' members in the holding tank have a wallet linked and are ready to switch on payouts' + (named.length ? ': ' + named.slice(0, 12).join(', ') + (named.length > 12 ? ' and ' + (named.length - 12) + ' more' : '') : '') + '. Adopt them from the holding tank in the next 24 hours: ' + link, sc.telegramEchoTopicId).catch(() => {});
|
await telegramSend(sc.telegramEchoChatId, '\u{1F7E2} ' + r.fresh.length + ' members in the holding tank have a wallet linked and are ready to switch on payouts' + (named.length ? ': ' + named.slice(0, 12).join(', ') + (named.length > 12 ? ' and ' + (named.length - 12) + ' more' : '') : '') + '. Adopt them from the holding tank in the next ' + tank.leftText(Math.min(...r.fresh.map(w => w.until)) - Date.now()) + ': ' + link, sc.telegramEchoTopicId).catch(() => {});
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@@ -1595,7 +1711,7 @@ async function telegramSendPhoto(chatId, jpeg, caption, threadId) {
|
|||||||
rq.on('error', () => resolve(false)); rq.on('timeout', () => { rq.destroy(); resolve(false); }); rq.end(body);
|
rq.on('error', () => resolve(false)); rq.on('timeout', () => { rq.destroy(); resolve(false); }); rq.end(body);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const BADGE_META = { payouts: ['Spark', 'payouts switched on'], firstBuyer: ['Surge', 'first qualifying buyer'], level2: ['Circuit', 'two qualifying buyers, level 2 open'], level3: ['Nexus', 'five qualifying buyers, fully qualified'], fridays: ['Five Fridays', 'five Five Dollar Fridays in a row'], gamepass: ['Game Pass', 'Game Pass holder'],
|
const BADGE_META = { payouts: ['Spark', 'payouts switched on'], firstBuyer: ['Surge', 'first qualifying buyer'], level2: ['Circuit', 'two qualifying buyers, level 2 open'], level3: ['Nexus', 'five qualifying buyers, fully qualified'], fridays: ['Five Fridays', 'five Five Dollar Fridays in a row'], gamepass: ['Game Pass', 'Game Pass holder'], stackpro: ['Stack POL Pro', 'Stack POL Pro page unlocked'],
|
||||||
refuelStart: ['Engine Started', 'first monthly refuel'], refuel3: ['Refueled 3 months', 'three monthly refuels in a row'], refuel6: ['Refueled 6 months', 'six monthly refuels in a row'], refuel12: ['Refueled 12 months', 'twelve monthly refuels in a row'] };
|
refuelStart: ['Engine Started', 'first monthly refuel'], refuel3: ['Refueled 3 months', 'three monthly refuels in a row'], refuel6: ['Refueled 6 months', 'six monthly refuels in a row'], refuel12: ['Refueled 12 months', 'twelve monthly refuels in a row'] };
|
||||||
const BADGE_LOG = () => path.join(DATA_DIR, 'badge-posts.json');
|
const BADGE_LOG = () => path.join(DATA_DIR, 'badge-posts.json');
|
||||||
function badgeLog() { try { return JSON.parse(fs.readFileSync(BADGE_LOG(), 'utf8')); } catch (e) { return {}; } }
|
function badgeLog() { try { return JSON.parse(fs.readFileSync(BADGE_LOG(), 'utf8')); } catch (e) { return {}; } }
|
||||||
@@ -1718,7 +1834,8 @@ const SOV_SECRET = () => String(process.env.SOV_SSO_SECRET || '').trim();
|
|||||||
const SOV_URL = () => String(process.env.SOV_URL || 'https://shardsofvalor.com').replace(/\/+$/, '');
|
const SOV_URL = () => String(process.env.SOV_URL || 'https://shardsofvalor.com').replace(/\/+$/, '');
|
||||||
const SOV_ALT = () => String(process.env.SOV_ALT_URLS || 'https://www.shardsofvalor.com,https://sov.saasy.top').split(',').map(x => x.trim().replace(/\/+$/, '')).filter(Boolean);
|
const SOV_ALT = () => String(process.env.SOV_ALT_URLS || 'https://www.shardsofvalor.com,https://sov.saasy.top').split(',').map(x => x.trim().replace(/\/+$/, '')).filter(Boolean);
|
||||||
const sovSign = p => drB64u(crypto.createHmac('sha256', SOV_SECRET()).update(p).digest());
|
const sovSign = p => drB64u(crypto.createHmac('sha256', SOV_SECRET()).update(p).digest());
|
||||||
function sovMint(claims, ttlMs) { const payload = JSON.stringify(Object.assign({ iat: Date.now(), exp: Date.now() + (ttlMs || 300000), nonce: crypto.randomBytes(12).toString('hex') }, claims, gpClaim(claims))); return drB64u(payload) + '.' + sovSign(payload); }
|
// 2026-11-05: the bonus heroes ride along too (gamepass.heroClaim: heroes owned, heroBundle, the current sale; heroBundleCap only if set)
|
||||||
|
function sovMint(claims, ttlMs) { const payload = JSON.stringify(Object.assign({ iat: Date.now(), exp: Date.now() + (ttlMs || 300000), nonce: crypto.randomBytes(12).toString('hex') }, claims, gpClaim(claims), claims && claims.email ? gamepass.heroClaim(claims.email) : {})); return drB64u(payload) + '.' + sovSign(payload); }
|
||||||
function seekOpen(token) {
|
function seekOpen(token) {
|
||||||
if (SEEK_SECRET().length < 32) return { error: 'ClutterHunt is not connected yet.' };
|
if (SEEK_SECRET().length < 32) return { error: 'ClutterHunt is not connected yet.' };
|
||||||
const [p, sig] = String(token || '').split('.'); if (!p || !sig) return { error: 'That link is not valid.' };
|
const [p, sig] = String(token || '').split('.'); if (!p || !sig) return { error: 'That link is not valid.' };
|
||||||
@@ -2043,6 +2160,9 @@ function GAMES() {
|
|||||||
// Turkey Drop (2026-10-28): the Thanksgiving season game, Nov 2 to 30 (hidden until gamesLive has 'turkeydrop'; gone after the season)
|
// Turkey Drop (2026-10-28): the Thanksgiving season game, Nov 2 to 30 (hidden until gamesLive has 'turkeydrop'; gone after the season)
|
||||||
{ slug: 'turkeydrop', name: 'Turkey Drop', tag: 'Thanksgiving · Nov 2 to 30', blurb: 'The WFWL 98.7 helicopter is dropping turkeys over the mall. Swing the net, catch them before they splat, and keep the station on the air. Score milestones pay POL the first time you reach them, and the weekly top 3 win a POL prize.',
|
{ slug: 'turkeydrop', name: 'Turkey Drop', tag: 'Thanksgiving · Nov 2 to 30', blurb: 'The WFWL 98.7 helicopter is dropping turkeys over the mall. Swing the net, catch them before they splat, and keep the station on the air. Score milestones pay POL the first time you reach them, and the weekly top 3 win a POL prize.',
|
||||||
art: 'https://coolify-saasytop.nyc3.cdn.digitaloceanspaces.com/game-banners/turkeydrop/og-turkeydrop-clean.jpg', play: '/api/my/turkeydrop', pays: 'POL for first score milestones and weekly top 3 prizes', season: { start: TD_SEASON.start, end: TD_SEASON.end } },
|
art: 'https://coolify-saasytop.nyc3.cdn.digitaloceanspaces.com/game-banners/turkeydrop/og-turkeydrop-clean.jpg', play: '/api/my/turkeydrop', pays: 'POL for first score milestones and weekly top 3 prizes', season: { start: TD_SEASON.start, end: TD_SEASON.end } },
|
||||||
|
// Shards of Valor (Marty 2026-11-06, Dallas ready for players): open for testing from the Games tab; pays no POL until a launch date is set
|
||||||
|
{ slug: 'shardsofvalor', name: 'Shards of Valor', tag: 'Open testing', blurb: 'A pixel adventure for many players at once. Lead three heroes across the islands, help their people, fight in the dungeons and recover the eight Shards of Valor. Open for testing now while we hunt bugs: nothing is live or paid out until we set a launch date, and all testing progress is wiped at launch.',
|
||||||
|
art: '/banners/og-shardsofvalor.jpg', play: '/api/my/shardsofvalor', pays: 'Nothing yet. No POL until we set a launch date' },
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
// each game's member perk (the $5 welcome offer, 2026-10-05) shown on its card
|
// each game's member perk (the $5 welcome offer, 2026-10-05) shown on its card
|
||||||
@@ -2058,6 +2178,7 @@ const STRIP = () => ({
|
|||||||
polybreak: { line: 'Break the glass jewel wall, catch the capsules and the purple Polygon gem. First clears pay POL.', open: PB_URL() + '/', host: PB_URL().replace(/^https?:\/\//, '') },
|
polybreak: { line: 'Break the glass jewel wall, catch the capsules and the purple Polygon gem. First clears pay POL.', open: PB_URL() + '/', host: PB_URL().replace(/^https?:\/\//, '') },
|
||||||
polminer: { line: 'Dig deep, beat the drill bosses, find the rare pink Polygon crystals. Crystals pay POL.', open: PM_URL() + '/', host: PM_URL().replace(/^https?:\/\//, '') },
|
polminer: { line: 'Dig deep, beat the drill bosses, find the rare pink Polygon crystals. Crystals pay POL.', open: PM_URL() + '/', host: PM_URL().replace(/^https?:\/\//, '') },
|
||||||
warpwares: { line: 'One galaxy, 30 days, 200 turns a day. Trade, hold sectors, build a base. Weekly prizes pay POL.', open: WW_URL() + '/', host: WW_URL().replace(/^https?:\/\//, '') },
|
warpwares: { line: 'One galaxy, 30 days, 200 turns a day. Trade, hold sectors, build a base. Weekly prizes pay POL.', open: WW_URL() + '/', host: WW_URL().replace(/^https?:\/\//, '') },
|
||||||
|
shardsofvalor: { line: 'Open testing. Lead three heroes across the islands and recover the Shards of Valor. No POL until launch day.', open: SOV_URL() + '/', host: SOV_URL().replace(/^https?:\/\//, '') },
|
||||||
turkeydrop: { line: 'Thanksgiving only. Catch the turkeys from the station helicopter before they splat. Score milestones pay POL.', open: TD_URL() + '/', host: TD_URL().replace(/^https?:\/\//, '') },
|
turkeydrop: { line: 'Thanksgiving only. Catch the turkeys from the station helicopter before they splat. Score milestones pay POL.', open: TD_URL() + '/', host: TD_URL().replace(/^https?:\/\//, '') },
|
||||||
spellwheel: { line: 'Swipe the letter wheel, fill the grid, solve the daily puzzle. Levels and dailies pay POL.', open: SW_URL() + '/', host: SW_URL().replace(/^https?:\/\//, '') },
|
spellwheel: { line: 'Swipe the letter wheel, fill the grid, solve the daily puzzle. Levels and dailies pay POL.', open: SW_URL() + '/', host: SW_URL().replace(/^https?:\/\//, '') },
|
||||||
polywarriors: { line: 'Recruit one-of-a-kind warriors, fight the arena, challenge members. First wins pay POL.', open: PW_URL() + '/', host: PW_URL().replace(/^https?:\/\//, '') },
|
polywarriors: { line: 'Recruit one-of-a-kind warriors, fight the arena, challenge members. First wins pay POL.', open: PW_URL() + '/', host: PW_URL().replace(/^https?:\/\//, '') },
|
||||||
@@ -2199,13 +2320,48 @@ async function gameAnswer(g, slug, acct) { // the game token (only once a userna
|
|||||||
return { ok: true, needUsername, username: acct.username || null, token: needUsername ? null : g.mint(acct, memberId), pass: gamePassMint(acct.email, slug) };
|
return { ok: true, needUsername, username: acct.username || null, token: needUsername ? null : g.mint(acct, memberId), pass: gamePassMint(acct.email, slug) };
|
||||||
}
|
}
|
||||||
|
|
||||||
const SHARE_HOSTS = String(process.env.SHARE_HOSTS || 'ctbgo.com,mylinehq.com').split(',').map(x => x.trim().toLowerCase()).filter(Boolean);
|
const SHARE_HOSTS = String(process.env.SHARE_HOSTS || 'instantadpay.link,ctbgo.com,mylinehq.com').split(',').map(x => x.trim().toLowerCase()).filter(Boolean);
|
||||||
|
|
||||||
|
// Short banner image URLs (2026-11-03; Michael Camire via Marty: the Spaces CDN URLs run about 105 characters and get cut off
|
||||||
|
// by exchange and safelist image fields, so the banners never show). /b/<slug>/<file> serves the same file from
|
||||||
|
// game-banners/<slug>/ on the Spaces CDN, bytes in place (no redirect: some sites only HEAD the URL), on the share hosts as
|
||||||
|
// well as here: https://instantadpay.link/b/turkeydrop/728x90.png. A bare <size>.<ext> expands to <slug>-<size>.<ext>. Small
|
||||||
|
// in-memory cache, 300 files, six hours, misses remembered one minute (a banner uploaded after someone asked for it shows up fast).
|
||||||
|
const BANNER_CDN = 'https://coolify-saasytop.nyc3.cdn.digitaloceanspaces.com/game-banners/';
|
||||||
|
const BANNER_TYPES = { png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', webp: 'image/webp', gif: 'image/gif' };
|
||||||
|
const bannerCache = new Map(); // cdn url -> { buf, type, at, miss }
|
||||||
|
async function serveBanner(req, res, p) {
|
||||||
|
const m = /^\/b\/([a-z0-9-]{2,30})\/([a-z0-9-]{1,60})\.(png|jpe?g|webp|gif)$/i.exec(p);
|
||||||
|
if (!m) return false;
|
||||||
|
const slug = m[1].toLowerCase(), ext = m[3].toLowerCase();
|
||||||
|
let name = m[2].toLowerCase(); if (/^\d{2,4}x\d{2,4}$/.test(name)) name = slug + '-' + name;
|
||||||
|
const url = BANNER_CDN + slug + '/' + name + '.' + ext;
|
||||||
|
let hit = bannerCache.get(url);
|
||||||
|
if (!hit || Date.now() - hit.at > (hit.miss ? 60e3 : 6 * 3600e3)) {
|
||||||
|
try {
|
||||||
|
const r = await fetch(url, { signal: AbortSignal.timeout(10000) });
|
||||||
|
if (r.ok) {
|
||||||
|
const buf = Buffer.from(await r.arrayBuffer());
|
||||||
|
hit = { buf, type: r.headers.get('content-type') || BANNER_TYPES[ext], at: Date.now() };
|
||||||
|
} else hit = { miss: r.status, at: Date.now() };
|
||||||
|
if (bannerCache.size >= 300) bannerCache.delete(bannerCache.keys().next().value);
|
||||||
|
bannerCache.set(url, hit);
|
||||||
|
} catch (e) { if (!hit) { res.writeHead(502, baseHeaders({ 'Content-Type': 'text/plain', 'Cache-Control': 'no-store' })); res.end('banner source unreachable'); return true; } }
|
||||||
|
}
|
||||||
|
if (hit.miss) { res.writeHead(404, baseHeaders({ 'Content-Type': 'text/plain', 'Cache-Control': 'no-store' })); res.end('no such banner'); return true; }
|
||||||
|
res.writeHead(200, baseHeaders({ 'Content-Type': hit.type, 'Content-Length': hit.buf.length, 'Cache-Control': 'public, max-age=86400', 'Access-Control-Allow-Origin': '*', 'X-Robots-Tag': 'noindex' }));
|
||||||
|
if (req.method === 'HEAD') res.end(); else res.end(hit.buf);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
const server = http.createServer(async (req, res) => {
|
const server = http.createServer(async (req, res) => {
|
||||||
{ const t0 = Date.now(); res.on('finish', () => { const ms = Date.now() - t0; if (ms > 3000) console.warn('slow request', req.method, String(req.url || '').split('?')[0].slice(0, 80), ms + 'ms', res.statusCode); }); } // visibility for member-felt delays (2026-10-12)
|
{ const t0 = Date.now(); res.on('finish', () => { const ms = Date.now() - t0; if (ms > 3000) console.warn('slow request', req.method, String(req.url || '').split('?')[0].slice(0, 80), ms + 'ms', res.statusCode); }); } // visibility for member-felt delays (2026-10-12)
|
||||||
try {
|
try {
|
||||||
const u = new URL(req.url, 'http://x');
|
const u = new URL(req.url, 'http://x');
|
||||||
const p = u.pathname;
|
const p = u.pathname;
|
||||||
// share-link domains (ctbgo.com, mylinehq.com): /<ref> goes to that member's join page, anything else to the same path
|
// short banner images, served on every host (share hosts included) before the share-host redirect
|
||||||
|
if ((req.method === 'GET' || req.method === 'HEAD') && p.startsWith('/b/') && await serveBanner(req, res, p)) return;
|
||||||
|
// share-link domains (instantadpay.link active since 2026-11-04; ctbgo.com and mylinehq.com still answer): /<ref> goes to that member's join page, anything else to the same path
|
||||||
// here. 302 (not 301) so links never get pinned in caches; the query (?v= angle, ?promo=) rides along.
|
// here. 302 (not 301) so links never get pinned in caches; the query (?v= angle, ?promo=) rides along.
|
||||||
{ const sh = String(req.headers.host || '').toLowerCase().replace(/:\d+$/, '').replace(/^www\./, '');
|
{ const sh = String(req.headers.host || '').toLowerCase().replace(/:\d+$/, '').replace(/^www\./, '');
|
||||||
if (SHARE_HOSTS.includes(sh)) {
|
if (SHARE_HOSTS.includes(sh)) {
|
||||||
@@ -2213,7 +2369,26 @@ const server = http.createServer(async (req, res) => {
|
|||||||
const to = 'https://instantadpay.com' + (p === '/' ? '/' : ref ? '/join/' + ref[1] : p) + (u.search || '');
|
const to = 'https://instantadpay.com' + (p === '/' ? '/' : ref ? '/join/' + ref[1] : p) + (u.search || '');
|
||||||
res.writeHead(302, { Location: to, 'Cache-Control': 'no-store', 'X-Robots-Tag': 'noindex' }); return res.end();
|
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' && (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).
|
||||||
|
if (req.method === 'GET' && p === '/api/network/member') {
|
||||||
|
let a = null; const un = String(u.searchParams.get('u') || '').trim().toLowerCase(), ad = String(u.searchParams.get('a') || '').trim().toLowerCase();
|
||||||
|
try { if (/^[a-z0-9_]{1,20}$/.test(un)) a = await accounts.byUsername(un); else if (/^0x[0-9a-f]{40}$/.test(ad)) a = await accounts.byAddress(ad); } catch (e) {}
|
||||||
|
const ok = a && a.address && a.username && !fraud.isSuspended(a.email);
|
||||||
|
return json(res, 200, ok ? { username: a.username, address: String(a.address).toLowerCase() } : { username: null, address: null }, { 'Cache-Control': 'public, max-age=300', 'Access-Control-Allow-Origin': '*' });
|
||||||
|
}
|
||||||
|
|
||||||
|
// a LinkSpin click arriving on any page (?lsclk= or ?lsid=): the first-party cookie, 30 days, last click wins (reporting only, lsreport.js).
|
||||||
|
// Added to whatever the page sends, like the viral-link cookies below.
|
||||||
|
if (req.method === 'GET' && !p.startsWith('/api/') && !p.startsWith('/admin') && !/\.[a-z0-9]{2,5}$/i.test(p)) {
|
||||||
|
const lsc = lsreport.fromUrl(u);
|
||||||
|
if (lsc) {
|
||||||
|
const ck = lsreport.cookieHeader(lsc, IS_PROD); const wh = res.writeHead.bind(res);
|
||||||
|
res.writeHead = function (code, h) { if (typeof h === 'string') return wh.apply(res, arguments); h = Object.assign({}, h || {}); h['Set-Cookie'] = [].concat(res.getHeader('Set-Cookie') || [], h['Set-Cookie'] || [], ck); return wh(code, h); };
|
||||||
|
}
|
||||||
|
}
|
||||||
// -- traffic log: public page views by referring domain (admin > Traffic)
|
// -- traffic log: public page views by referring domain (admin > Traffic)
|
||||||
if (req.method === 'GET' && ((TRAFFIC_PAGES.has(p) && !(p === '/refuel' && u.searchParams.has('t'))) || /^\/(join|from|wall|blog)\/[^/]+$/.test(p))) traffic.hit(p.startsWith('/blog/') ? '/blog/*' : p, req.headers.referer, req.headers['user-agent']);
|
if (req.method === 'GET' && ((TRAFFIC_PAGES.has(p) && !(p === '/refuel' && u.searchParams.has('t'))) || /^\/(join|from|wall|blog)\/[^/]+$/.test(p))) traffic.hit(p.startsWith('/blog/') ? '/blog/*' : p, req.headers.referer, req.headers['user-agent']);
|
||||||
// -- viral links (Marty, 2026-09-21): ANY public page + ?ref=<username|code|id> is that member's
|
// -- viral links (Marty, 2026-09-21): ANY public page + ?ref=<username|code|id> is that member's
|
||||||
@@ -2297,9 +2472,15 @@ const server = http.createServer(async (req, res) => {
|
|||||||
// pays a referral bounty only for people it actually sent, so that proof has to be reliable
|
// pays a referral bounty only for people it actually sent, so that proof has to be reliable
|
||||||
// rather than dependent on a header (Marty, 2026-09-24: "not just members that come on board
|
// rather than dependent on a header (Marty, 2026-09-24: "not just members that come on board
|
||||||
// IAP and work their way over to POL Hunter").
|
// IAP and work their way over to POL Hunter").
|
||||||
if (!cookies['iap.ref']) {
|
// A ?src= tag on the link (every mailer / traffic-source spin link carries one) is recorded with the host, so a sign-up
|
||||||
|
// says "mailer.gold/mailergold" or just "mailergold" when the referrer was stripped, and a tagged visit replaces an
|
||||||
|
// untagged "direct" first touch (Marty, 2026-11-12: "we need the source tag so we can know where these things come from").
|
||||||
|
const srcTag = String(u.searchParams.get('src') || '').toLowerCase().replace(/[^a-z0-9_.-]/g, '').slice(0, 30);
|
||||||
|
const prevRef = decodeURIComponent(cookies['iap.ref'] || '');
|
||||||
|
if (!prevRef || (srcTag && prevRef === 'direct')) {
|
||||||
const host = u.searchParams.get('from') === 'polhunter' ? 'polhunter.com' : u.searchParams.get('from') === 'driprunner' ? 'driprunner.saasy.top' : coach.refHost(req.headers.referer);
|
const host = u.searchParams.get('from') === 'polhunter' ? 'polhunter.com' : u.searchParams.get('from') === 'driprunner' ? 'driprunner.saasy.top' : coach.refHost(req.headers.referer);
|
||||||
set.push('iap.ref=' + encodeURIComponent(host) + cookieTail);
|
const fromGame = /^(polhunter|driprunner)$/.test(String(u.searchParams.get('from') || '')); // PolHunter's bounty proof reads the bare host: never tag it
|
||||||
|
set.push('iap.ref=' + encodeURIComponent(srcTag && !fromGame ? (host && host !== 'direct' ? host + '/' : '') + srcTag : host) + cookieTail);
|
||||||
}
|
}
|
||||||
return serveJoinPage(res, tok, ang ? angle : '', ang, set);
|
return serveJoinPage(res, tok, ang ? angle : '', ang, set);
|
||||||
}
|
}
|
||||||
@@ -2324,7 +2505,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
const r = await drip.unsubscribe(u.searchParams.get('e'), u.searchParams.get('t'));
|
const r = await drip.unsubscribe(u.searchParams.get('e'), u.searchParams.get('t'));
|
||||||
const msg = r.error ? r.error : 'Done. You will not get any more emails from InstantAdPay, apart from sign-in codes you ask for and receipts for payments to or from your account. Your account is unchanged.';
|
const msg = r.error ? r.error : 'Done. You will not get any more emails from InstantAdPay, apart from sign-in codes you ask for and receipts for payments to or from your account. Your account is unchanged.';
|
||||||
res.writeHead(r.error ? 400 : 200, baseHeaders({ 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-store' }));
|
res.writeHead(r.error ? 400 : 200, baseHeaders({ 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-store' }));
|
||||||
return res.end('<!doctype html><html' + themehead.htmlAttr('dark') + '><head><meta charset="utf-8"><title>InstantAdPay</title>' + themehead.tag() + '<link rel="stylesheet" href="/assets/site.css?v=20261101th"></head><body><div class="wrap" style="max-width:560px;padding:80px 22px"><a href="/"><img src="/logo.png" alt="InstantAdPay" style="height:34px"></a><h1 style="font-size:30px;margin:26px 0 12px">' + (r.error ? 'Hmm.' : 'Unsubscribed.') + '</h1><p>' + msg + '</p><p><a class="btn small sec" href="/my">Member area</a></p></div></body></html>');
|
return res.end('<!doctype html><html' + themehead.htmlAttr('dark') + '><head><meta charset="utf-8"><title>InstantAdPay</title>' + themehead.tag() + '<link rel="stylesheet" href="/assets/site.css?v=20261112ln"></head><body><div class="wrap" style="max-width:560px;padding:80px 22px"><a href="/"><img src="/logo.png" alt="InstantAdPay" style="height:34px"></a><h1 style="font-size:30px;margin:26px 0 12px">' + (r.error ? 'Hmm.' : 'Unsubscribed.') + '</h1><p>' + msg + '</p><p><a class="btn small sec" href="/my">Member area</a></p></div></body></html>');
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- public API
|
// -- public API
|
||||||
@@ -2349,6 +2530,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
try { for (const b of (await blog.listPublished()).slice(0, 40)) pages.push({ path: '/blog/' + b.slug, title: 'Article: ' + b.title, cover: b.cover || null }); } catch (e) {}
|
try { for (const b of (await blog.listPublished()).slice(0, 40)) pages.push({ path: '/blog/' + b.slug, title: 'Article: ' + b.title, cover: b.cover || null }); } catch (e) {}
|
||||||
return json(res, 200, { pages });
|
return json(res, 200, { pages });
|
||||||
}
|
}
|
||||||
|
if (p === '/api/network-sites' && req.method === 'GET') return netsites.handle(req, res);
|
||||||
if (p === '/api/config' && req.method === 'GET') {
|
if (p === '/api/config' && req.method === 'GET') {
|
||||||
const c = chain.getConfig();
|
const c = chain.getConfig();
|
||||||
// public copy of the site settings: never anything that looks like a credential
|
// public copy of the site settings: never anything that looks like a credential
|
||||||
@@ -2578,6 +2760,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
const r = await accounts.signup(b.email, b.password, ref);
|
const r = await accounts.signup(b.email, b.password, ref);
|
||||||
if (r.error) return json(res, 400, r);
|
if (r.error) return json(res, 400, r);
|
||||||
pendingSponsor.del(String(b.email || '').trim().toLowerCase());
|
pendingSponsor.del(String(b.email || '').trim().toLowerCase());
|
||||||
|
await lsreport.signup(r.account.email, lsreport.pick(b.lsclk, parseCookies(req)[lsreport.COOKIE]), lsconv.softKey(clientIp(req), req.headers['user-agent'])).catch(e => console.error('lsreport signup', e.message));
|
||||||
// sponsor is notified once the new member picks a username (onboarding),
|
// sponsor is notified once the new member picks a username (onboarding),
|
||||||
// so the email can name them — see /api/my/profile
|
// so the email can name them — see /api/my/profile
|
||||||
if (b.newsletter) sendy.subscribe(r.account.email, r.account.username || '').catch(() => {}); // pre-checked opt-in, silent
|
if (b.newsletter) sendy.subscribe(r.account.email, r.account.username || '').catch(() => {}); // pre-checked opt-in, silent
|
||||||
@@ -2609,7 +2792,8 @@ const server = http.createServer(async (req, res) => {
|
|||||||
const code = String(Math.floor(100000 + Math.random() * 900000));
|
const code = String(Math.floor(100000 + Math.random() * 900000));
|
||||||
emailCodes.set(e, { code, exp: Date.now() + 15 * 60 * 1000, tries: 0, nextAt: Date.now() + 60 * 1000 });
|
emailCodes.set(e, { code, exp: Date.now() + 15 * 60 * 1000, tries: 0, nextAt: Date.now() + 60 * 1000 });
|
||||||
{ const ck = parseCookies(req); const bound = pageTok(b.ref) || ck['iap.sponsor'] || '';
|
{ const ck = parseCookies(req); const bound = pageTok(b.ref) || ck['iap.sponsor'] || '';
|
||||||
if (bound && !(await accounts.byEmail(e))) pendingSponsor.set(e, { ref: bound, via: pageTok(b.ref) ? (String(b.angle || '').toLowerCase().slice(0, 20) || ck['iap.angle'] || 'page') : (ck['iap.angle'] || ''), joinedRef: decodeURIComponent(ck['iap.ref'] || '') || null }); }
|
if (bound && !(await accounts.byEmail(e))) pendingSponsor.set(e, { ref: bound, via: pageTok(b.ref) ? (String(b.angle || '').toLowerCase().slice(0, 20) || ck['iap.angle'] || 'page') : (ck['iap.angle'] || ''), joinedRef: decodeURIComponent(ck['iap.ref'] || '') || null });
|
||||||
|
const lsc = lsreport.pick(b.lsclk, ck[lsreport.COOKIE]); if (lsc) { const ex = await accounts.byEmail(e); if (!ex || accounts.isUnclaimedShell(ex)) lsreport.remember(e, lsc).catch(err => console.error('lsreport remember', err.message)); } } // the click travels with the email, like the sponsor
|
||||||
if (mailer.hasKey()) {
|
if (mailer.hasKey()) {
|
||||||
try { await mailer.sendCode(e, code); } catch (err) {
|
try { await mailer.sendCode(e, code); } catch (err) {
|
||||||
console.error('sendCode failed', err.message);
|
console.error('sendCode failed', err.message);
|
||||||
@@ -2651,6 +2835,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (r.error) return json(res, 400, r);
|
if (r.error) return json(res, 400, r);
|
||||||
if (r.created) pendingSponsor.del(e);
|
if (r.created) pendingSponsor.del(e);
|
||||||
if (claim) await claimShell(e, existing, ref);
|
if (claim) await claimShell(e, existing, ref);
|
||||||
|
if (r.created || claim) await lsreport.signup(e, lsreport.pick(b.lsclk, parseCookies(req)[lsreport.COOKIE]), lsconv.softKey(clientIp(req), req.headers['user-agent'])).catch(err => console.error('lsreport signup', err.message));
|
||||||
if (r.created || claim) { fraud.recordSignup(e, req, fraudFlags).catch(() => {}); if (fraudFlags.length) fraudAlert(e, { flags: fraudFlags, ip: fraud.ipOf(req) }, null, false); }
|
if (r.created || claim) { fraud.recordSignup(e, req, fraudFlags).catch(() => {}); if (fraudFlags.length) fraudAlert(e, { flags: fraudFlags, ip: fraud.ipOf(req) }, null, false); }
|
||||||
else fraud.recordSeen(e, req).catch(() => {});
|
else fraud.recordSeen(e, req).catch(() => {});
|
||||||
// the lead is in the door: queue the getting-started sequence (opt-in box is pre-checked on both forms)
|
// the lead is in the door: queue the getting-started sequence (opt-in box is pre-checked on both forms)
|
||||||
@@ -2684,7 +2869,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
let memberId = 0;
|
let memberId = 0;
|
||||||
if (r.account.address) { try { memberId = await chain.memberIdByAccount(r.account.address); } catch (err) {} }
|
if (r.account.address) { try { memberId = await chain.memberIdByAccount(r.account.address); } catch (err) {} }
|
||||||
const token = await auth.mintSession({ email: r.account.email, address: r.account.address, memberId });
|
const token = await auth.mintSession({ email: r.account.email, address: r.account.address, memberId });
|
||||||
return json(res, 200, { ok: true, account: r.account, created: !!r.created, next: ({ clutterhunt: '/api/my/clutterhunt', spellwheel: '/api/my/spellwheel', polybreak: '/api/my/polybreak', polminer: '/api/my/polminer', turkeydrop: '/api/my/turkeydrop', warpwares: '/api/my/warpwares', polywarriors: '/api/my/polywarriors', driprunner: '/api/my/driprunner', passivedrip: '/api/my/passivedrip', gemkingdom: '/api/my/gemkingdom', gkshop: '/gk/shop/resume', spookydoors: '/api/my/spookydoors', sdshop: '/sd/shop/resume' })[parseCookies(req)['iap.return']] || null }, { 'Set-Cookie': auth.sessionCookie(token) }); // next: Drip Runner sent them here to sign in (2026-09-30)
|
return json(res, 200, { ok: true, account: r.account, created: !!r.created, next: ({ clutterhunt: '/api/my/clutterhunt', spellwheel: '/api/my/spellwheel', polybreak: '/api/my/polybreak', polminer: '/api/my/polminer', turkeydrop: '/api/my/turkeydrop', warpwares: '/api/my/warpwares', polywarriors: '/api/my/polywarriors', driprunner: '/api/my/driprunner', passivedrip: '/api/my/passivedrip', gemkingdom: '/api/my/gemkingdom', gkshop: '/gk/shop/resume', spookydoors: '/api/my/spookydoors', sdshop: '/sd/shop/resume' })[parseCookies(req)['iap.return']] || (networksso.pendingBack(req) ? '/sso/resume' : null) }, { 'Set-Cookie': auth.sessionCookie(token) }); // next: Drip Runner sent them here to sign in (2026-09-30)
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- in-game sign-in (2026-10-03): see GAME_AUTH. Mirrors /api/auth/email/start + verify, minus cookies.
|
// -- in-game sign-in (2026-10-03): see GAME_AUTH. Mirrors /api/auth/email/start + verify, minus cookies.
|
||||||
@@ -2717,6 +2902,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
const ref = pageTok(b.ref);
|
const ref = pageTok(b.ref);
|
||||||
const srcTag = String(b.src || '').toLowerCase().replace(/[^a-z0-9_.-]/g, '').slice(0, 30); // paid-traffic source the game saw (2026-10-03)
|
const srcTag = String(b.src || '').toLowerCase().replace(/[^a-z0-9_.-]/g, '').slice(0, 30); // paid-traffic source the game saw (2026-10-03)
|
||||||
if (!(await accounts.byEmail(e))) pendingSponsor.set(e, { ref: ref || '', via: String(b.game), joinedRef: g.host() + (srcTag ? '/' + srcTag : '') });
|
if (!(await accounts.byEmail(e))) pendingSponsor.set(e, { ref: ref || '', via: String(b.game), joinedRef: g.host() + (srcTag ? '/' + srcTag : '') });
|
||||||
|
{ const lsc = lsreport.pick(b.lsclk, parseCookies(req)[lsreport.COOKIE]); if (lsc) { const ex = await accounts.byEmail(e); if (!ex || accounts.isUnclaimedShell(ex)) lsreport.remember(e, lsc).catch(err => console.error('lsreport remember', err.message)); } } // a game sends its own lsclk when it has one; no cookie crosses here
|
||||||
console.log('game-signin code', b.game, e.replace(/^(.).*(@.*)$/, '$1***$2'), ref ? 'ref ' + ref : '');
|
console.log('game-signin code', b.game, e.replace(/^(.).*(@.*)$/, '$1***$2'), ref ? 'ref ' + ref : '');
|
||||||
if (mailer.hasKey()) {
|
if (mailer.hasKey()) {
|
||||||
try { await mailer.sendCode(e, code); } catch (err) { console.error('sendCode failed', err.message); return json(res, 502, { error: 'Could not send the email. Try again in a minute.' }, cors); }
|
try { await mailer.sendCode(e, code); } catch (err) { console.error('sendCode failed', err.message); return json(res, 502, { error: 'Could not send the email. Try again in a minute.' }, cors); }
|
||||||
@@ -2753,6 +2939,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
}
|
}
|
||||||
const r = await accounts.ensure(e, ref, via, joinedRef); // first touch wins; existing accounts unchanged
|
const r = await accounts.ensure(e, ref, via, joinedRef); // first touch wins; existing accounts unchanged
|
||||||
if (r.error) return json(res, 400, r, cors);
|
if (r.error) return json(res, 400, r, cors);
|
||||||
|
if (r.created || claim) await lsreport.signup(e, lsreport.pick(b.lsclk, parseCookies(req)[lsreport.COOKIE]), lsconv.softKey(clientIp(req), req.headers['user-agent'])).catch(err => console.error('lsreport signup', err.message));
|
||||||
if (claim) { await claimShell(e, existing, ref); fraud.recordSignup(e, req, fraudFlags).catch(() => {}); if (fraudFlags.length) fraudAlert(e, { flags: fraudFlags, ip: fraud.ipOf(req) }, null, false); }
|
if (claim) { await claimShell(e, existing, ref); fraud.recordSignup(e, req, fraudFlags).catch(() => {}); if (fraudFlags.length) fraudAlert(e, { flags: fraudFlags, ip: fraud.ipOf(req) }, null, false); }
|
||||||
if (r.created) {
|
if (r.created) {
|
||||||
pendingSponsor.del(e);
|
pendingSponsor.del(e);
|
||||||
@@ -2853,7 +3040,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
}
|
}
|
||||||
if (p === '/api/auth/logout' && req.method === 'POST') {
|
if (p === '/api/auth/logout' && req.method === 'POST') {
|
||||||
await auth.logout(req);
|
await auth.logout(req);
|
||||||
return json(res, 200, { ok: true }, { 'Set-Cookie': auth.clearCookie() });
|
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
|
||||||
}
|
}
|
||||||
if (p === '/api/gas' && req.method === 'GET') {
|
if (p === '/api/gas' && req.method === 'GET') {
|
||||||
try { return json(res, 200, await chain.suggestedFees()); }
|
try { return json(res, 200, await chain.suggestedFees()); }
|
||||||
@@ -2885,9 +3072,10 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (tankHold) sponsorBlocked = 'tankHold';
|
if (tankHold) sponsorBlocked = 'tankHold';
|
||||||
else if (!sponsorId && memberId !== _defSpon) { sponsorId = _defSpon; sponsorFallback = true; } // orphan fallback → #1 (never self-sponsor)
|
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(() => {});
|
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'].includes(parseCookies(req)['iap.return']) ? parseCookies(req)['iap.return'] : null, sponsorBlocked, sponsorRouted, sponsorName: spdMe.name || null, email: s.email || (acct && acct.email) || null,
|
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,
|
||||||
address: s.address || (acct && acct.address) || null, memberId,
|
address: s.address || (acct && acct.address) || null, memberId,
|
||||||
username: (acct && acct.username) || null, theme: (acct && acct.theme) || null,
|
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)
|
||||||
refCode: (acct && acct.code) || null, sponsorId, tankHold, sponsorFallback,
|
refCode: (acct && acct.code) || null, sponsorId, tankHold, sponsorFallback,
|
||||||
// profile + line-banner fields so the Profile pane repopulates on reload (were being saved but not returned)
|
// profile + line-banner fields so the Profile pane repopulates on reload (were being saved but not returned)
|
||||||
avatarUrl: (acct && acct.avatarUrl) || null, bio: (acct && acct.bio) || null,
|
avatarUrl: (acct && acct.avatarUrl) || null, bio: (acct && acct.bio) || null,
|
||||||
@@ -2918,7 +3106,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
let tankWaiting = null; // top of every Overview: people waiting for a sponsor (Marty, 2026-09-12)
|
let tankWaiting = null; // top of every Overview: people waiting for a sponsor (Marty, 2026-09-12)
|
||||||
try {
|
try {
|
||||||
if (!tankWaitCache || Date.now() - tankWaitCache.ts > 60000) tankWaitCache = { ts: Date.now(), list: await tank.waiting() };
|
if (!tankWaitCache || Date.now() - tankWaitCache.ts > 60000) tankWaitCache = { ts: Date.now(), list: await tank.waiting() };
|
||||||
const tw = tankWaitCache.list;
|
const tw = tank.adoptableOf(tankWaitCache.list); // only people who can be adopted right now (sign-up grace, 2026-11-07)
|
||||||
tankWaiting = { count: tw.length, names: tw.slice(0, 6).map(w => w.name), eligible: !!(await tank.eligibility(s.email)).ok, ready: tw.filter(w => w.ready).length };
|
tankWaiting = { count: tw.length, names: tw.slice(0, 6).map(w => w.name), eligible: !!(await tank.eligibility(s.email)).ok, ready: tw.filter(w => w.ready).length };
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
const sc0 = siteConfig();
|
const sc0 = siteConfig();
|
||||||
@@ -2988,6 +3176,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (bc >= 5) reached.push('level3');
|
if (bc >= 5) reached.push('level3');
|
||||||
try { if (out.memberId && friday.earnedBadge(out.memberId)) reached.push('fridays'); } catch (e) {} // five Five Dollar Fridays in a row
|
try { if (out.memberId && friday.earnedBadge(out.memberId)) reached.push('fridays'); } catch (e) {} // five Five Dollar Fridays in a row
|
||||||
try { if (out.email && gamepass.flag(out.email).until) reached.push('gamepass'); } catch (e) {} // ever held a Game Pass (2026-10-22)
|
try { if (out.email && gamepass.flag(out.email).until) reached.push('gamepass'); } catch (e) {} // ever held a Game Pass (2026-10-22)
|
||||||
|
try { if (out.email && gamepass.stackPro(out.email)) reached.push('stackpro'); } catch (e) {} // owns Stack POL Pro (2026-11-09)
|
||||||
try { if (out.email) for (const k of await refuel.badgesOf(out.email)) if (!reached.includes(k)) reached.push(k); } catch (e) {} // Monthly Refuel badges (2026-10-24)
|
try { if (out.email) for (const k of await refuel.badgesOf(out.email)) if (!reached.includes(k)) reached.push(k); } catch (e) {} // Monthly Refuel badges (2026-10-24)
|
||||||
try { for (const k of await ads.milestonesOf(out.email)) if (!reached.includes(k)) reached.push(k); } catch (e) {} // a badge once earned stays earned
|
try { for (const k of await ads.milestonesOf(out.email)) if (!reached.includes(k)) reached.push(k); } catch (e) {} // a badge once earned stays earned
|
||||||
out.milestonesReached = reached;
|
out.milestonesReached = reached;
|
||||||
@@ -3003,6 +3192,9 @@ const server = http.createServer(async (req, res) => {
|
|||||||
const rTot = await ads.earnedTotals(joined.map(r => r.email)); // surf earnings per referral (Marty, 2026-09-29)
|
const rTot = await ads.earnedTotals(joined.map(r => r.email)); // surf earnings per referral (Marty, 2026-09-29)
|
||||||
out.referrals = joined.map(r => ({
|
out.referrals = joined.map(r => ({
|
||||||
name: r.username || r.email.replace(/^(.).*(@.*)$/, '$1***$2'), // username, else privacy mask
|
name: r.username || r.email.replace(/^(.).*(@.*)$/, '$1***$2'), // username, else privacy mask
|
||||||
|
// directs only (this list IS the member's directs): email, where they came from and how they joined, up front in
|
||||||
|
// "Your line" instead of buried in the three-level card (Marty, 2026-11-12)
|
||||||
|
email: r.email, src: r.joinedRef || null, via: r.joinedVia || null, ref: r.code || null,
|
||||||
joined: r.created,
|
joined: r.created,
|
||||||
lastSeen: r.lastSeen || 0,
|
lastSeen: r.lastSeen || 0,
|
||||||
wallet: !!r.address, activated: !!r.memberId,
|
wallet: !!r.address, activated: !!r.memberId,
|
||||||
@@ -3077,6 +3269,19 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (!a) return json(res, 404, { error: 'No member matches "' + q.slice(0, 60) + '".' });
|
if (!a) return json(res, 404, { error: 'No member matches "' + q.slice(0, 60) + '".' });
|
||||||
return json(res, 200, Object.assign(await adminMember.view(a.email), { pwPasses: pwPasses.get(String(a.email).toLowerCase()) || null })); // mint passes on the card (2026-10-10)
|
return json(res, 200, Object.assign(await adminMember.view(a.email), { pwPasses: pwPasses.get(String(a.email).toLowerCase()) || null })); // mint passes on the card (2026-10-10)
|
||||||
}
|
}
|
||||||
|
// -- admin: the network hub's member lookup (Marty 2026-11-14, read-only): what the member card leaves out. GET ?email=
|
||||||
|
if (p === '/api/admin/member-extra' && req.method === 'GET') {
|
||||||
|
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||||
|
const e = String(u.searchParams.get('email') || '').trim().toLowerCase();
|
||||||
|
const a = e ? await accounts.byEmail(e) : null;
|
||||||
|
if (!a) return json(res, 404, { error: 'no such account' });
|
||||||
|
const r = tank.readyRec(e);
|
||||||
|
return json(res, 200, {
|
||||||
|
optedOut: await drip.isUnsubscribed(e).catch(() => null), updatesOptIn: await updates.optedIn(e).catch(() => null),
|
||||||
|
tank: { inTank: !a.sponsorRef && !a.memberId, ready: r ? { readyAt: r.readyAt || null, holdUntil: r.readyAt ? r.readyAt + tank.READY_MS : null } : null, adoptions: await tank.summaryFor(e).catch(() => null) },
|
||||||
|
fraud: await fraud.get(e).then(f => f && { flags: f.flags || [], suspended: !!f.suspended, suspendedReason: f.suspendedReason || null }).catch(() => null)
|
||||||
|
});
|
||||||
|
}
|
||||||
if (p === '/api/admin/member' && req.method === 'PATCH') {
|
if (p === '/api/admin/member' && req.method === 'PATCH') {
|
||||||
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||||
const b = await readBody(req);
|
const b = await readBody(req);
|
||||||
@@ -3116,6 +3321,27 @@ const server = http.createServer(async (req, res) => {
|
|||||||
// -- link-farm scan (2026-10-30): last result + allowlist, run now (no Telegram), allow / unallow an email
|
// -- link-farm scan (2026-10-30): last result + allowlist, run now (no Telegram), allow / unallow an email
|
||||||
if (p === '/api/admin/spamscan' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, spamscan.view()); }
|
if (p === '/api/admin/spamscan' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, spamscan.view()); }
|
||||||
if (p === '/api/admin/spamscan/run' && req.method === 'POST') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); await spamscan.run({ manual: true, quiet: true }); return json(res, 200, spamscan.view()); }
|
if (p === '/api/admin/spamscan/run' && req.method === 'POST') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); await spamscan.run({ manual: true, quiet: true }); return json(res, 200, spamscan.view()); }
|
||||||
|
// admin -> one member: inbox message + email (Marty 2026-11-12: "no way to send them an inbox message that would email them as well")
|
||||||
|
if (p === '/api/admin/member/message' && req.method === 'POST') {
|
||||||
|
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||||
|
const b = await readBody(req); const e = String(b.email || '').trim().toLowerCase(); const acct = e && await accounts.byEmail(e);
|
||||||
|
if (!acct) return json(res, 404, { error: 'No such member.' });
|
||||||
|
const subject = String(b.subject || '').trim().slice(0, 150), text = String(b.text || '').trim().slice(0, 8000);
|
||||||
|
if (!subject || !text) return json(res, 400, { error: 'Subject and message are both needed.' });
|
||||||
|
const escH = s => String(s).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
||||||
|
const html = text.split(/\n{2,}/).map(par => '<p>' + escH(par).replace(/\n/g, '<br>') + '</p>').join('');
|
||||||
|
await messages.deliver(1, ADMIN_EMAIL || 'house@instantadpay.com', [e], subject, html, 'broadcast');
|
||||||
|
let emailed = false, emailSkipped = '';
|
||||||
|
if (!mailer.hasKey()) emailSkipped = 'mail is not set up on this server';
|
||||||
|
else {
|
||||||
|
const hello = acct.username ? 'Hi @' + acct.username + ',\n\n' : 'Hi,\n\n';
|
||||||
|
const tail = '\n\nYou can reply from your member inbox: https://instantadpay.com/my\n\nMarty Bostick, InstantAdPay';
|
||||||
|
try { emailed = (await mailer.send(e, subject, hello + text + tail, '<div style="font-family:Arial,sans-serif;font-size:15px;line-height:1.5">' + '<p>' + escH(hello.trim()) + '</p>' + html + '<p>You can reply from your member inbox: <a href="https://instantadpay.com/my">instantadpay.com/my</a></p><p>Marty Bostick, InstantAdPay</p></div>')) !== false; if (!emailed) emailSkipped = 'they unsubscribed from email'; }
|
||||||
|
catch (err) { emailSkipped = 'the mail service failed (' + String(err.message || err).slice(0, 80) + ')'; }
|
||||||
|
}
|
||||||
|
console.log('admin message', e.replace(/^(.).*(@.*)$/, '$1***$2'), 'inbox ok', emailed ? 'emailed' : 'email skipped: ' + emailSkipped);
|
||||||
|
return json(res, 200, { ok: true, inbox: true, emailed, emailSkipped });
|
||||||
|
}
|
||||||
if (p === '/api/admin/spamscan/allow' && req.method === 'POST') {
|
if (p === '/api/admin/spamscan/allow' && req.method === 'POST') {
|
||||||
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||||
const b = await readBody(req); const e = String(b.email || '').trim().toLowerCase(); if (!e) return json(res, 400, { error: 'Which email?' });
|
const b = await readBody(req); const e = String(b.email || '').trim().toLowerCase(); if (!e) return json(res, 400, { error: 'Which email?' });
|
||||||
@@ -3133,6 +3359,26 @@ const server = http.createServer(async (req, res) => {
|
|||||||
console.log('admin removed account', e);
|
console.log('admin removed account', e);
|
||||||
return json(res, 200, { ok: true });
|
return json(res, 200, { ok: true });
|
||||||
}
|
}
|
||||||
|
// -- quest-site checks (Marty 2026-11-04: Zealy first). Zealy POSTs { accounts: { email?, wallet? } } with X-Api-Key;
|
||||||
|
// 200 = the member may claim, 400 + message = shown to them. Read-only: looks members up, never changes anything.
|
||||||
|
const questM = p.match(/^\/api\/quest\/zealy\/(account|wallet|member|game|gamepass)$/);
|
||||||
|
if (questM && req.method === 'POST') {
|
||||||
|
const key = process.env.QUEST_API_KEY || '';
|
||||||
|
if (!key) return json(res, 503, { message: 'Quest checks are not switched on yet.' });
|
||||||
|
if (!gpSigOk(key, String(req.headers['x-api-key'] || ''))) return json(res, 401, { message: 'Bad API key.' });
|
||||||
|
const b = await readBody(req); const ac = (b && b.accounts) || {};
|
||||||
|
const em = String(ac.email || '').trim().toLowerCase(), w = String(ac.wallet || '').trim().toLowerCase();
|
||||||
|
let acct = em ? await accounts.byEmail(em) : null;
|
||||||
|
if (!acct && /^0x[0-9a-f]{40}$/.test(w)) { acct = await accounts.byAddress(w); if (!acct) { const pos = await accounts.positionByAddress(w); if (pos && pos.email) acct = await accounts.byEmail(pos.email); } }
|
||||||
|
const JOIN = 'https://instantadpay.com/join/martbost';
|
||||||
|
if (!acct) return json(res, 400, { message: em ? 'No InstantAdPay account uses ' + em + '. Join free at ' + JOIN + ' with this email, then claim again.' : 'No InstantAdPay account is linked to this wallet. Join free at ' + JOIN + ' and link this wallet in your dashboard, then claim again.' });
|
||||||
|
if (questM[1] === 'wallet' && !acct.address) return json(res, 400, { message: 'Your InstantAdPay account has no Polygon wallet linked yet. Sign in at instantadpay.com/my, link your wallet, then claim again.' });
|
||||||
|
if (questM[1] === 'member' && !acct.memberId) return json(res, 400, { message: 'Your InstantAdPay account is not an on-chain member yet. Get your first package at instantadpay.com/my, then claim again.' });
|
||||||
|
if (questM[1] === 'game' && !(gamepass.activity(acct.email).grants > 0)) return json(res, 400, { message: 'No game rewards on your InstantAdPay account yet. Open any network game from instantadpay.com/games, sign in with your InstantAdPay account and earn your first reward, then claim again.' });
|
||||||
|
if (questM[1] === 'gamepass' && !gamepass.flag(acct.email).active) return json(res, 400, { message: 'Your InstantAdPay account has no active Game Pass. Get one in your dashboard at instantadpay.com/my, then claim again.' });
|
||||||
|
console.log('quest check ok', questM[1], b && b.questId ? String(b.questId).slice(0, 40) : '');
|
||||||
|
return json(res, 200, { message: 'Verified on InstantAdPay. Thanks for joining!' });
|
||||||
|
}
|
||||||
// -- release notes + roadmap (public read; admin write) (Marty, 2026-09-14)
|
// -- release notes + roadmap (public read; admin write) (Marty, 2026-09-14)
|
||||||
if (p === '/api/releases' && req.method === 'GET') return json(res, 200, releases.publicView());
|
if (p === '/api/releases' && req.method === 'GET') return json(res, 200, releases.publicView());
|
||||||
// -- promo toolkit: tiers by badge + the AI Copy Engine (Surge+), credits beyond the free allowance
|
// -- promo toolkit: tiers by badge + the AI Copy Engine (Surge+), credits beyond the free allowance
|
||||||
@@ -3362,7 +3608,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||||
const b = await readBody(req); const key = String(b.key || ''); const a = await accounts.byEmail(String(b.email || '').toLowerCase());
|
const b = await readBody(req); const key = String(b.key || ''); const a = await accounts.byEmail(String(b.email || '').toLowerCase());
|
||||||
if (!a || !BADGE_META[key]) return json(res, 400, { error: 'Unknown member or badge.' });
|
if (!a || !BADGE_META[key]) return json(res, 400, { error: 'Unknown member or badge.' });
|
||||||
if (!(await ads.milestonesOf(a.email)).includes(key) && !(key === 'gamepass' && gamepass.flag(a.email).until)) return json(res, 400, { error: 'That member has not unlocked that badge.' }); // the Game Pass badge is earned by holding a pass, recorded or not yet
|
if (!(await ads.milestonesOf(a.email)).includes(key) && !(key === 'gamepass' && gamepass.flag(a.email).until) && !(key === 'stackpro' && gamepass.stackPro(a.email))) return json(res, 400, { error: 'That member has not unlocked that badge.' }); // the Game Pass badge is earned by holding a pass, recorded or not yet
|
||||||
const jpeg = await badge.render(key, a.username || ('member #' + a.memberId)); if (!jpeg) return json(res, 500, { error: 'Render failed.' });
|
const jpeg = await badge.render(key, a.username || ('member #' + a.memberId)); if (!jpeg) return json(res, 500, { error: 'Render failed.' });
|
||||||
const who = a.username ? '@' + a.username : 'member #' + a.memberId; const link = a.username ? 'instantadpay.com/join/' + a.username : 'instantadpay.com';
|
const who = a.username ? '@' + a.username : 'member #' + a.memberId; const link = a.username ? 'instantadpay.com/join/' + a.username : 'instantadpay.com';
|
||||||
const [label, sub] = BADGE_META[key];
|
const [label, sub] = BADGE_META[key];
|
||||||
@@ -3391,6 +3637,19 @@ const server = http.createServer(async (req, res) => {
|
|||||||
}
|
}
|
||||||
return json(res, r.error ? 400 : 200, r);
|
return json(res, r.error ? 400 : 200, r);
|
||||||
}
|
}
|
||||||
|
// "Who invited you?" (Marty approved 2026-11-07): the signed-in member names their own sponsor. check: validate only.
|
||||||
|
if (p === '/api/my/tank/invited' && req.method === 'POST') {
|
||||||
|
const s = await auth.fromRequest(req);
|
||||||
|
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||||
|
const b = await readBody(req);
|
||||||
|
const r = await tank.nameSponsor(s.email, b.who, { check: !!b.check });
|
||||||
|
return json(res, r.error ? 400 : 200, r);
|
||||||
|
}
|
||||||
|
if (p === '/api/my/tank/invited/dismiss' && req.method === 'POST') { // "Nobody invited me": hides the card, nothing else changes
|
||||||
|
const s = await auth.fromRequest(req);
|
||||||
|
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||||
|
return json(res, 200, tank.dismissInvite(s.email));
|
||||||
|
}
|
||||||
if (p === '/api/my/tank/release' && req.method === 'POST') {
|
if (p === '/api/my/tank/release' && req.method === 'POST') {
|
||||||
const s = await auth.fromRequest(req);
|
const s = await auth.fromRequest(req);
|
||||||
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||||
@@ -3424,7 +3683,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (p === '/api/admin/walletnudge' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, walletnudge.adminView()); }
|
if (p === '/api/admin/walletnudge' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, walletnudge.adminView()); }
|
||||||
if (p === '/api/admin/reach' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, reach.adminView()); }
|
if (p === '/api/admin/reach' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, reach.adminView()); }
|
||||||
if (p === '/api/admin/reach/run' && req.method === 'POST') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); const b = await readBody(req); return json(res, 200, await reach.run({ dry: !!(b && b.dry) })); }
|
if (p === '/api/admin/reach/run' && req.method === 'POST') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); const b = await readBody(req); return json(res, 200, await reach.run({ dry: !!(b && b.dry) })); }
|
||||||
if (p === '/api/admin/lssync' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, Object.assign(lssync.adminView(), { inbound: lsinbound.adminView(), conv: lsconv.adminView() })); }
|
if (p === '/api/admin/lssync' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, Object.assign(lssync.adminView(), { inbound: lsinbound.adminView(), conv: lsconv.adminView(), report: lsreport.adminView() })); }
|
||||||
if (p === '/api/admin/lsinbound' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, lsinbound.adminView()); }
|
if (p === '/api/admin/lsinbound' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, lsinbound.adminView()); }
|
||||||
// -- reverse registry sync from LinkSpin (2026-10-15): the same signed rows LinkSpin accepts from us (HMAC LS_SYNC_SECRET
|
// -- reverse registry sync from LinkSpin (2026-10-15): the same signed rows LinkSpin accepts from us (HMAC LS_SYNC_SECRET
|
||||||
// over ts + newline + raw body, 10-minute window). New people become waiting accounts with their LinkSpin line; existing
|
// over ts + newline + raw body, 10-minute window). New people become waiting accounts with their LinkSpin line; existing
|
||||||
@@ -3459,6 +3718,52 @@ const server = http.createServer(async (req, res) => {
|
|||||||
const rv = await refuel.view(email);
|
const rv = await refuel.view(email);
|
||||||
return json(res, 200, { ok: true, refuel: rv, facts: rv.on ? await engine.facts({ site: 'iap', adminMember, ads, coach }, email) : null });
|
return json(res, 200, { ok: true, refuel: rv, facts: rv.on ? await engine.facts({ site: 'iap', adminMember, ads, coach }, email) : null });
|
||||||
}
|
}
|
||||||
|
// -- network hub hooks (hubsync.js, 2026-11-12): signed with HUB_SECRET (X-Hub-Ts + X-Hub-Sig), 5-minute window. Only with HUB_ENABLED.
|
||||||
|
// -- personal notices (2026-11-13, first use: Marty's go on the Downline Banners wallet nudge to sponsors). Admin only. One
|
||||||
|
// message per member, each with its own text: InstantAdPay inbox (messages.deliver, kind notice) + email through the site
|
||||||
|
// mailer, which skips anyone who unsubscribed and adds the unsubscribe link. Once per member per batch (marks.claim
|
||||||
|
// 'nb:<batch>:<email>'), so a repeated call never mails anyone twice. Runs in the background, 400 ms apart;
|
||||||
|
// GET ?batch= reads the result (notice-batches.json).
|
||||||
|
if (p === '/api/admin/notice-batch' && (req.method === 'POST' || req.method === 'GET')) {
|
||||||
|
if (!isAdmin(req)) return json(res, 401, { error: 'Admin only.' });
|
||||||
|
const NB = path.join(DATA_DIR, 'notice-batches.json');
|
||||||
|
const readNB = () => { try { return JSON.parse(fs.readFileSync(NB, 'utf8')); } catch (e) { return {}; } };
|
||||||
|
if (req.method === 'GET') return json(res, 200, readNB()[String(u.searchParams.get('batch') || '')] || { error: 'No such batch.' });
|
||||||
|
const b = await readBody(req); // { batch, subject, html, text, items: [{ email, vars: { key: value } }] }, {{key}} filled per member
|
||||||
|
const batch = String(b.batch || '').replace(/[^a-z0-9-]/gi, '').slice(0, 60); const subjectT = String(b.subject || '').slice(0, 160);
|
||||||
|
const items = Array.isArray(b.items) ? b.items.slice(0, 5000) : [];
|
||||||
|
const fill = (t, v, html) => String(t || '').replace(/\{\{(\w+)\}\}/g, (m, k) => { const x = v && v[k] != null ? String(v[k]) : ''; return html ? x.replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c])) : x; });
|
||||||
|
const subject = subjectT;
|
||||||
|
if (!batch || !subject || !items.length) return json(res, 400, { error: 'batch, subject and items required' });
|
||||||
|
const all = readNB(); if (all[batch] && all[batch].running) return json(res, 409, { error: 'That batch is already running.' });
|
||||||
|
all[batch] = { subject, total: items.length, sent: 0, inbox: 0, optedOut: 0, noAccount: 0, repeat: 0, failed: 0, running: true, started: Date.now() };
|
||||||
|
fs.writeFileSync(NB, JSON.stringify(all));
|
||||||
|
json(res, 200, { ok: true, batch, total: items.length });
|
||||||
|
(async () => {
|
||||||
|
const st = all[batch];
|
||||||
|
for (const it of items) {
|
||||||
|
const e = String(it.email || '').trim().toLowerCase();
|
||||||
|
try {
|
||||||
|
const acct = await accounts.byEmail(e); if (!acct) { st.noAccount++; continue; }
|
||||||
|
if (!(await marks.claim('nb:' + batch + ':' + e))) { st.repeat++; continue; }
|
||||||
|
const subj = fill(subjectT, it.vars, false), html = fill(b.html, it.vars, true), text = fill(b.text, it.vars, false);
|
||||||
|
await messages.deliver(1, ADMIN_EMAIL || 'house@instantadpay.com', [e], subj, html, 'notice'); st.inbox++;
|
||||||
|
const ok = await mailer.send(e, subj, text, html);
|
||||||
|
if (ok === false) st.optedOut++; else st.sent++;
|
||||||
|
} catch (err) { st.failed++; console.error('notice-batch', batch, err.message); }
|
||||||
|
const cur = readNB(); cur[batch] = st; fs.writeFileSync(NB, JSON.stringify(cur));
|
||||||
|
await new Promise(r => setTimeout(r, 400));
|
||||||
|
}
|
||||||
|
st.running = false; st.finished = Date.now(); const cur = readNB(); cur[batch] = st; fs.writeFileSync(NB, JSON.stringify(cur));
|
||||||
|
console.log('notice-batch', batch, JSON.stringify(st));
|
||||||
|
})().catch(err => console.error('notice-batch', err.message));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (p === '/api/hub/events' && req.method === 'POST' && hubsync.enabled()) {
|
||||||
|
let raw; try { raw = (await readRaw(req, 2e6)).toString('utf8'); } catch (e) { return json(res, 413, { error: 'too big' }); }
|
||||||
|
const r = await hubsync.receive(req.headers, raw); return json(res, r.status, r.body);
|
||||||
|
}
|
||||||
|
if (p === '/api/admin/hub' && req.method === 'GET' && hubsync.enabled()) { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, hubsync.adminView()); }
|
||||||
if (p === '/api/partner/registry' && req.method === 'POST') {
|
if (p === '/api/partner/registry' && req.method === 'POST') {
|
||||||
const sg = await readLsSigned(req, 2e6); if (!sg.body) return json(res, sg.status, { error: sg.error });
|
const sg = await readLsSigned(req, 2e6); if (!sg.body) return json(res, sg.status, { error: sg.error });
|
||||||
const b = sg.body;
|
const b = sg.body;
|
||||||
@@ -3529,10 +3834,34 @@ const server = http.createServer(async (req, res) => {
|
|||||||
}
|
}
|
||||||
if (p === '/api/admin/lssync/run' && req.method === 'POST') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); const b = await readBody(req); return json(res, 200, await lssync.tick(!!(b && b.force))); }
|
if (p === '/api/admin/lssync/run' && req.method === 'POST') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); const b = await readBody(req); return json(res, 200, await lssync.tick(!!(b && b.force))); }
|
||||||
if (p === '/api/admin/walletnudge/run' && req.method === 'POST') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, await walletnudge.tick()); }
|
if (p === '/api/admin/walletnudge/run' && req.method === 'POST') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, await walletnudge.tick()); }
|
||||||
|
// -- 5xYourTeam The Draft (draftpartner.js, 2026-11-15): signed partner calls, DRAFT_PARTNER_SECRET as X-Draft-Ts + X-Draft-Sig
|
||||||
|
if (p.startsWith('/api/partner/draft/') && req.method === 'POST') {
|
||||||
|
const raw = await new Promise((ok, no) => { let d = ''; req.on('data', c => { d += c; if (d.length > 64000) { req.destroy(); no(new Error('too big')); } }); req.on('end', () => ok(d)); req.on('error', no); });
|
||||||
|
const sg = draftpartner.verify(req.headers, raw); if (!sg.body) return json(res, sg.status, { error: sg.error });
|
||||||
|
const op = p.slice('/api/partner/draft/'.length);
|
||||||
|
if (!['pool', 'adopt', 'release', 'status'].includes(op)) return json(res, 404, { error: 'unknown op' });
|
||||||
|
const r = await draftpartner.handle(op, sg.body);
|
||||||
|
return json(res, r.error ? 400 : 200, r);
|
||||||
|
}
|
||||||
|
if (p === '/api/admin/draft' && req.method === 'GET') {
|
||||||
|
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||||
|
return json(res, 200, await draftpartner.adminView());
|
||||||
|
}
|
||||||
if (p === '/api/admin/tank' && req.method === 'GET') {
|
if (p === '/api/admin/tank' && req.method === 'GET') {
|
||||||
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||||
return json(res, 200, await tank.adminView());
|
return json(res, 200, await tank.adminView());
|
||||||
}
|
}
|
||||||
|
// an adoption made for a member (Marty 2026-11-14: sponsors who lost people when the contract sponsor won get a few from the
|
||||||
|
// tank). The same tank.adopt as the member's own button: their eligibility and cap, the adoptee's email and chat. No payments-topic
|
||||||
|
// post per pickup (a batch would flood it).
|
||||||
|
if (p === '/api/admin/tank/adopt' && req.method === 'POST') {
|
||||||
|
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||||
|
const b = await readBody(req);
|
||||||
|
if (!b.adopter || !b.who) return json(res, 400, { error: 'adopter and who' });
|
||||||
|
if (fraud.excluded(b.adopter)) return json(res, 403, { error: 'Adoptions are not available on that account.' });
|
||||||
|
const r = await tank.adopt(String(b.adopter).toLowerCase(), b.who, b.note);
|
||||||
|
return json(res, r.error ? 400 : 200, r);
|
||||||
|
}
|
||||||
// -- admin Traffic tab: page views + join-page views + signups + $20 buyers, by referring
|
// -- admin Traffic tab: page views + join-page views + signups + $20 buyers, by referring
|
||||||
// domain / first-touch source, by landing page, by angle and by day (Marty, 2026-09-12)
|
// domain / first-touch source, by landing page, by angle and by day (Marty, 2026-09-12)
|
||||||
// login-ad showings per Central day, dashboard vs games (2026-10-18: a week of combined sign-ins before the cap decision)
|
// login-ad showings per Central day, dashboard vs games (2026-10-18: a week of combined sign-ins before the cap decision)
|
||||||
@@ -3813,6 +4142,61 @@ const server = http.createServer(async (req, res) => {
|
|||||||
const tok = wwMint({ memberId: Number((acct && acct.memberId) || s.memberId || 0), email: String(s.email).toLowerCase(), username: (acct && acct.username) || null, wallet: (acct && acct.address) || null, sponsorRef: (acct && acct.sponsorRef) || null });
|
const tok = wwMint({ memberId: Number((acct && acct.memberId) || s.memberId || 0), email: String(s.email).toLowerCase(), username: (acct && acct.username) || null, wallet: (acct && acct.address) || null, sponsorRef: (acct && acct.sponsorRef) || null });
|
||||||
res.writeHead(302, { Location: WW_URL() + '/auth?t=' + tok, 'Cache-Control': 'no-store', 'Set-Cookie': gkCookie('iap.return', '', 0) }); return res.end();
|
res.writeHead(302, { Location: WW_URL() + '/auth?t=' + tok, 'Cache-Control': 'no-store', 'Set-Cookie': gkCookie('iap.return', '', 0) }); return res.end();
|
||||||
}
|
}
|
||||||
|
// -- Earners Corner forum sign-in (2026-11-10): Discourse sends /forum/sso; a signed-out visitor signs in on /my first (the request
|
||||||
|
// rides in a 30-minute cookie) and /api/my/forum finishes the hand-back. See forumsso.js.
|
||||||
|
// -- Earners Corner invite + shared-thread credit (Marty 2026-11-10): /forum/join/<username>[?to=/path] sets the member as sponsor
|
||||||
|
// exactly like /join/<username> (30-day cookie, last touch wins, first-touch source recorded), then forwards to the forum. A
|
||||||
|
// visitor who later signs in on the forum creates their InstantAdPay account here, so the sponsor cookie is already in place.
|
||||||
|
// /forum/invite shows a signed-in member their own forum invite link.
|
||||||
|
m = /^\/forum\/join\/([A-Za-z0-9_]{1,20})$/.exec(p);
|
||||||
|
if (m && (req.method === 'GET' || req.method === 'HEAD')) {
|
||||||
|
const to = String(u.searchParams.get('to') || '/'); const path = /^\/(?!\/)[\w\-./?=&%]*$/.test(to) ? to : '/';
|
||||||
|
const a = await accounts.byUsername(m[1].toLowerCase());
|
||||||
|
const set = [];
|
||||||
|
if (a && a.username && !fraud.isSuspended(a.email)) {
|
||||||
|
const cookieTail = `; Path=/; SameSite=Lax; Max-Age=${30 * 24 * 3600}${IS_PROD ? '; Secure' : ''}`;
|
||||||
|
set.push('iap.sponsor=' + a.username + cookieTail); // last touch wins, same as /join/
|
||||||
|
if (!parseCookies(req)['iap.ref']) set.push('iap.ref=' + encodeURIComponent('earnerscorner.com') + cookieTail);
|
||||||
|
if (req.method === 'GET') coach.recordView(a.username, '', 'https://earnerscorner.com/');
|
||||||
|
}
|
||||||
|
res.writeHead(302, baseHeaders(Object.assign({ Location: forumsso.FORUM_URL() + path, 'Cache-Control': 'no-store' }, set.length ? { 'Set-Cookie': set } : {}))); return res.end();
|
||||||
|
}
|
||||||
|
// Earners Corner introduction reward (Marty 2026-11-10: 0.1 POL, ongoing, linked wallet + payouts switched on): the forum's reward
|
||||||
|
// service looks a member up here. Activated = an on-chain member id (the $20 start with payouts on); the address is the payout wallet.
|
||||||
|
if (p === '/api/forum/member' && req.method === 'GET') {
|
||||||
|
const email = String(u.searchParams.get('email') || '').toLowerCase();
|
||||||
|
if (!forumsso.verifyServer(email, req.headers['x-forum-ts'], req.headers['x-forum-sig'])) return json(res, 401, { error: 'auth' });
|
||||||
|
const a = await accounts.byEmail(email);
|
||||||
|
if (!a) return json(res, 200, { found: false });
|
||||||
|
return json(res, 200, { found: true, username: a.username || null, activated: Number(a.memberId) > 0, address: a.address || null, suspended: !!fraud.isSuspended(email) });
|
||||||
|
}
|
||||||
|
if (p === '/forum/invite' && req.method === 'GET') {
|
||||||
|
const s = await auth.fromRequest(req);
|
||||||
|
if (!s || !s.email) { res.writeHead(302, { Location: forumsso.FORUM_URL() + '/session/sso', 'Cache-Control': 'no-store' }); return res.end(); }
|
||||||
|
const a = await accounts.byEmail(s.email); const un = a && a.username;
|
||||||
|
const link = un ? 'https://instantadpay.com/forum/join/' + un : '';
|
||||||
|
const esc = x => String(x).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
||||||
|
const body = '<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Your Earners Corner invite link</title>'
|
||||||
|
+ '<style>body{margin:0;font:16px/1.55 system-ui,-apple-system,Segoe UI,sans-serif;background:#13101f;color:#efeafb;display:grid;place-items:center;min-height:100vh;padding:16px}'
|
||||||
|
+ '.c{max-width:560px;width:100%;background:#1c1830;border:1px solid #2f2947;border-radius:16px;padding:24px}h1{font-size:22px;margin:0 0 6px}p{color:#bdb5d6;margin:0 0 14px}'
|
||||||
|
+ 'input{width:100%;box-sizing:border-box;font:600 15px ui-monospace,Consolas,monospace;padding:12px;border-radius:10px;border:1px solid #6d28d9;background:#0f0c1a;color:#fff}'
|
||||||
|
+ 'a{color:#f5b74a}.s{font-size:13px;margin-top:14px}</style></head><body><div class="c"><h1>Your Earners Corner invite link</h1>'
|
||||||
|
+ (un ? '<p>Share this link. Anyone who joins the forum through it, or through a thread you share while signed in, signs up with you as their sponsor, exactly like your InstantAdPay referral link.</p>'
|
||||||
|
+ '<input readonly value="' + esc(link) + '" aria-label="Your invite link"><p class="s">Tap the box, select all and copy. To share one thread, use the share button under any post while you are signed in to the forum: those links carry your name too.</p>'
|
||||||
|
: '<p>Pick a username in your InstantAdPay profile first, then come back here for your invite link.</p><p><a href="/my#profile">Open your profile</a></p>')
|
||||||
|
+ '<p class="s"><a href="' + esc(forumsso.FORUM_URL()) + '/">Back to Earners Corner</a></p></div></body></html>';
|
||||||
|
res.writeHead(200, baseHeaders({ 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-store' })); return res.end(body);
|
||||||
|
}
|
||||||
|
if ((p === '/forum/sso' || p === '/api/my/forum') && req.method === 'GET') {
|
||||||
|
const raw = p === '/forum/sso' ? { sso: u.searchParams.get('sso'), sig: u.searchParams.get('sig') } : (() => { const c = String(parseCookies(req)['iap.forumsso'] || ''); const i = c.lastIndexOf('.'); return { sso: c.slice(0, i), sig: c.slice(i + 1) }; })();
|
||||||
|
const v = forumsso.verify(raw.sso, raw.sig);
|
||||||
|
if (v.error) { res.writeHead(302, { Location: forumsso.FORUM_URL() + '/', 'Cache-Control': 'no-store', 'Set-Cookie': gkCookie('iap.forumsso', '', 0) }); return res.end(); }
|
||||||
|
const s = await auth.fromRequest(req);
|
||||||
|
if (!s || !s.email) { res.writeHead(302, { Location: '/my', 'Cache-Control': 'no-store', 'Set-Cookie': [gkCookie('iap.return', 'forum', 1800), gkCookie('iap.forumsso', raw.sso + '.' + raw.sig, 1800)] }); return res.end(); }
|
||||||
|
const acct = (await accounts.byEmail(s.email)) || { email: s.email };
|
||||||
|
if (fraud.isSuspended(s.email)) { res.writeHead(302, { Location: forumsso.FORUM_URL() + '/', 'Cache-Control': 'no-store' }); return res.end(); }
|
||||||
|
res.writeHead(302, { Location: forumsso.redirectFor(v, Object.assign({ email: s.email }, acct), 'https://instantadpay.com'), 'Cache-Control': 'no-store', 'Set-Cookie': [gkCookie('iap.return', '', 0), gkCookie('iap.forumsso', '', 0)] }); return res.end();
|
||||||
|
}
|
||||||
if (p === '/api/my/polminer' && req.method === 'GET') { gamestats.handoff('polminer');
|
if (p === '/api/my/polminer' && req.method === 'GET') { gamestats.handoff('polminer');
|
||||||
const s = await auth.fromRequest(req);
|
const s = await auth.fromRequest(req);
|
||||||
if (!s || !s.email) { res.writeHead(302, { Location: '/my' + refQ(u), 'Set-Cookie': gkCookie('iap.return', 'polminer', 1800), 'Cache-Control': 'no-store' }); return res.end(); }
|
if (!s || !s.email) { res.writeHead(302, { Location: '/my' + refQ(u), 'Set-Cookie': gkCookie('iap.return', 'polminer', 1800), 'Cache-Control': 'no-store' }); return res.end(); }
|
||||||
@@ -3964,7 +4348,8 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (prev && (prev.status === 'paid' || (prev.status === 'paying' && Date.now() - prev.ts < 60000))) { res.writeHead(302, { Location: '/gk/shop?t=' + encodeURIComponent(t) }); return res.end(); }
|
if (prev && (prev.status === 'paid' || (prev.status === 'paying' && Date.now() - prev.ts < 60000))) { res.writeHead(302, { Location: '/gk/shop?t=' + encodeURIComponent(t) }); return res.end(); }
|
||||||
gkOrders.set(c.order, { status: 'paying', email: s.email, ts: Date.now() });
|
gkOrders.set(c.order, { status: 'paying', email: s.email, ts: Date.now() });
|
||||||
const { ids } = await myMemberIds(s);
|
const { ids } = await myMemberIds(s);
|
||||||
const out = await ads.gamePurchase(s.email, ids, c.credits, 'Gem Kingdom: ' + c.crowns + ' Crowns', GK_URL());
|
// paidOnly (Royal Charter, 2026-11-02): purchased credits only, the earned viewing pool is never touched, so a Charter is always real money
|
||||||
|
const out = await ads.gamePurchase(s.email, ids, c.credits, 'Gem Kingdom: ' + (c.paidOnly ? String(c.label || 'Royal Charter') : c.crowns + ' Crowns'), GK_URL(), c.paidOnly ? { purchasedOnly: true } : undefined);
|
||||||
if (out.error) { gkOrders.delete(c.order); if (out.error === 'short') { res.writeHead(302, { Location: '/gk/shop?t=' + encodeURIComponent(t) }); return res.end(); } return gkPage(res, 500, 'Order problem', '<h1>Something went wrong</h1><p class="sub">' + gkEsc(out.error) + '</p>'); }
|
if (out.error) { gkOrders.delete(c.order); if (out.error === 'short') { res.writeHead(302, { Location: '/gk/shop?t=' + encodeURIComponent(t) }); return res.end(); } return gkPage(res, 500, 'Order problem', '<h1>Something went wrong</h1><p class="sub">' + gkEsc(out.error) + '</p>'); }
|
||||||
gkOrders.set(c.order, { status: 'paid', email: s.email, campaignId: out.campaignId, paid: out.paid, ts: Date.now() });
|
gkOrders.set(c.order, { status: 'paid', email: s.email, campaignId: out.campaignId, paid: out.paid, ts: Date.now() });
|
||||||
console.log('gemkingdom crowns', s.email, c.crowns, 'for', c.credits, 'credits (' + out.paid + ' purchased), campaign', out.campaignId);
|
console.log('gemkingdom crowns', s.email, c.crowns, 'for', c.credits, 'credits (' + out.paid + ' purchased), campaign', out.campaignId);
|
||||||
@@ -4343,8 +4728,8 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (!gpSigOk(crypto.createHmac('sha256', chk.secret).update('player:' + (m > 0 ? String(m) : e) + ':' + ts).digest('hex'), sig)) return json(res, 401, { error: 'bad signature' });
|
if (!gpSigOk(crypto.createHmac('sha256', chk.secret).update('player:' + (m > 0 ? String(m) : e) + ':' + ts).digest('hex'), sig)) return json(res, 401, { error: 'bad signature' });
|
||||||
const r = await gpResolve(m, e); if (!r) return json(res, 404, { error: 'no such member', pass: { active: false, until: null, tier: null, tiers: { weekly: null, explorer: null, champion: null } } });
|
const r = await gpResolve(m, e); if (!r) return json(res, 404, { error: 'no such member', pass: { active: false, until: null, tier: null, tiers: { weekly: null, explorer: null, champion: null } } });
|
||||||
const now = gpDevNow(u.searchParams.get('devDay'));
|
const now = gpDevNow(u.searchParams.get('devDay'));
|
||||||
return json(res, 200, { ok: true, memberId: r.memberId, username: r.acct.username || null, wallet: r.acct.address || null, suspended: fraud.isSuspended(r.email),
|
return json(res, 200, Object.assign({ ok: true, memberId: r.memberId, username: r.acct.username || null, wallet: r.acct.address || null, suspended: fraud.isSuspended(r.email),
|
||||||
pass: gamepass.flag(r.email, now), caps: gamepass.capsFor(r.email, now, game), gamePassEnabled: gamepass.cfg().enabled });
|
pass: gamepass.flag(r.email, now), caps: gamepass.capsFor(r.email, now, game), gamePassEnabled: gamepass.cfg().enabled }, game === 'shardsofvalor' ? gamepass.heroClaim(r.email) : {}));
|
||||||
}
|
}
|
||||||
if ((p === '/api/partner/polgrant' || p === '/api/partner/polgrant/void' || p === '/api/partner/tournament/paid') && req.method === 'POST') {
|
if ((p === '/api/partner/polgrant' || p === '/api/partner/polgrant/void' || p === '/api/partner/tournament/paid') && req.method === 'POST') {
|
||||||
let raw; try { raw = (await readRaw(req, 16384)).toString('utf8'); } catch (e) { return json(res, 413, { error: 'too big' }); }
|
let raw; try { raw = (await readRaw(req, 16384)).toString('utf8'); } catch (e) { return json(res, 413, { error: 'too big' }); }
|
||||||
@@ -4388,6 +4773,42 @@ const server = http.createServer(async (req, res) => {
|
|||||||
const r = gamepass.buy(s.email, gpDevNow(b.devDay), b.tier);
|
const r = gamepass.buy(s.email, gpDevNow(b.devDay), b.tier);
|
||||||
return json(res, r.error ? 400 : 200, r);
|
return json(res, r.error ? 400 : 200, r);
|
||||||
}
|
}
|
||||||
|
// Shards of Valor bonus heroes (2026-11-05, Marty approved): sold one time. Buy only opens a waiting order; a FRESH package of at least the
|
||||||
|
// price ($20 hero = Activation, $50 bundle = Builder), bought by one of this member's own positions, fulfils it (gamepass.onEvent), so the
|
||||||
|
// sponsor line is paid as usual. Refused while heroSales is off (the admin tests from Admin > Game Pass).
|
||||||
|
if (p === '/api/my/heroes/buy' && req.method === 'POST') {
|
||||||
|
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||||
|
if (fraud.isSuspended(s.email)) return json(res, 403, { error: 'This account is suspended.' });
|
||||||
|
const b = await readBody(req); const r = gamepass.buyHero(s.email, Date.now(), b.hero);
|
||||||
|
return json(res, r.error ? 400 : 200, r);
|
||||||
|
}
|
||||||
|
// Admin > Game Pass hero test (2026-11-05): the admin's OWN account only, as the tier test below
|
||||||
|
if (['/api/admin/heroes/test-buy', '/api/admin/heroes/test-cancel', '/api/admin/heroes/test-comp', '/api/admin/heroes/test-revoke'].includes(p) && req.method === 'POST') {
|
||||||
|
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||||
|
const as = adminFromRequest(req); const me = String((as && as.email) || ADMIN_EMAIL || '').trim().toLowerCase();
|
||||||
|
if (!me) return json(res, 400, { error: 'No admin account email (ADMIN_EMAIL) is set.' });
|
||||||
|
const b = await readBody(req); const hero = String(b.hero || '').toLowerCase(); let r;
|
||||||
|
if (p === '/api/admin/heroes/test-buy') r = gamepass.buyHero(me, Date.now(), hero, { preview: true });
|
||||||
|
else if (p === '/api/admin/heroes/test-cancel') r = gamepass.cancelHeroOrder(me, hero);
|
||||||
|
else if (p === '/api/admin/heroes/test-comp') r = gamepass.compHero(me, hero, 'admin hero test');
|
||||||
|
else r = gamepass.revokeHero(me, hero || 'all', 'admin hero test');
|
||||||
|
if (!r.error) console.log('bonus heroes admin test', p.split('/').pop(), hero, me);
|
||||||
|
return json(res, r.error ? 400 : 200, Object.assign({ email: me, test: true, heroes: gamepass.heroView(me, Date.now(), { preview: true }) }, r));
|
||||||
|
}
|
||||||
|
// Admin: give Stack POL Pro for a package that was bought without a Pro order first (Marty 2026-11-09). The tx must be an on-chain
|
||||||
|
// Purchase of $10 or more by that member id; then the badge posts like any unlock.
|
||||||
|
if (p === '/api/admin/stackpro/grant' && req.method === 'POST') {
|
||||||
|
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||||
|
const b = await readBody(req); const id = Number(b.memberId), tx = String(b.tx || '').toLowerCase();
|
||||||
|
let ev = null; try { ev = (JSON.parse(fs.readFileSync(path.join(DATA_DIR, 'chain-index.json'), 'utf8')).events || []).find(e => e.type === 'Purchase' && String(e.tx || '').toLowerCase() === tx); } catch (e) {}
|
||||||
|
if (!ev || Number(ev.buyerId) !== id || Number(ev.priceCents) < gamepass.STACK_PRO_CENTS) return json(res, 400, { error: 'That tx is not a $10+ package bought by member #' + id + '.', ev });
|
||||||
|
const a = await accounts.byMemberId(id); if (!a || !a.email) return json(res, 404, { error: 'No account for member #' + id });
|
||||||
|
const r = gamepass.grantStackProForPackage(a.email, tx, Number(ev.priceCents), id, b.note);
|
||||||
|
try { await stackProMark(a.email); } catch (e) {}
|
||||||
|
let posted = 0; try { posted = await postBadgeOnce(a.email, 'stackpro'); } catch (e) { console.error('stackpro badge', e.message); }
|
||||||
|
return json(res, 200, Object.assign({ username: a.username, posted }, r));
|
||||||
|
}
|
||||||
|
if (p === '/api/admin/heroes/stats' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, gamepass.heroStats()); }
|
||||||
// Admin > Game Pass tier test (2026-10-25, Marty): every tier as members will see it, with the admin's OWN account's state, and a
|
// Admin > Game Pass tier test (2026-10-25, Marty): every tier as members will see it, with the admin's OWN account's state, and a
|
||||||
// test buy of a tier that is not on sale yet (opens the same waiting order a member gets; a fresh package on /my fulfils it).
|
// test buy of a tier that is not on sale yet (opens the same waiting order a member gets; a fresh package on /my fulfils it).
|
||||||
// Always the signed-in admin's own account (the bearer password falls back to ADMIN_EMAIL); never another member's.
|
// Always the signed-in admin's own account (the bearer password falls back to ADMIN_EMAIL); never another member's.
|
||||||
@@ -4494,6 +4915,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
name: m.username ? '@' + m.username : m.memberId ? 'member #' + m.memberId : 'member',
|
name: m.username ? '@' + m.username : m.memberId ? 'member #' + m.memberId : 'member',
|
||||||
ref: m.code || null, // opens the activity drop-down (Clinton's ask, 2026-09-14): any of the three levels
|
ref: m.code || null, // opens the activity drop-down (Clinton's ask, 2026-09-14): any of the three levels
|
||||||
email: L.level === 1 ? m.email : null, // directs only
|
email: L.level === 1 ? m.email : null, // directs only
|
||||||
|
src: L.level === 1 ? (m.joinedRef || null) : null, via: L.level === 1 ? (m.joinedVia || null) : null, // where a direct came from (2026-11-12)
|
||||||
joined: m.created,
|
joined: m.created,
|
||||||
lastSeen: m.lastSeen || 0,
|
lastSeen: m.lastSeen || 0,
|
||||||
wallet: !!m.address, activated: !!m.memberId,
|
wallet: !!m.address, activated: !!m.memberId,
|
||||||
@@ -4525,6 +4947,8 @@ const server = http.createServer(async (req, res) => {
|
|||||||
try { out.directs = ((await accounts.downline(a.email, 1))[0] || { members: [] }).members.length; } catch (e) { out.directs = 0; }
|
try { out.directs = ((await accounts.downline(a.email, 1))[0] || { members: [] }).members.length; } catch (e) { out.directs = 0; }
|
||||||
try { out.badges = await ads.milestonesOf(a.email); } catch (e) { out.badges = []; }
|
try { out.badges = await ads.milestonesOf(a.email); } catch (e) { out.badges = []; }
|
||||||
try { out.positions = (await accounts.positions(a.email)).length; } catch (e) { out.positions = 0; }
|
try { out.positions = (await accounts.positions(a.email)).length; } catch (e) { out.positions = 0; }
|
||||||
|
// your own directs: contact + origin (Marty, 2026-11-12). Levels 2 and 3 belong to someone else's direct relationship: no email.
|
||||||
|
try { if (await accounts.isDownlineOf(s.email, a.email, 1)) { out.direct = true; out.email = a.email; out.src = a.joinedRef || null; out.via = a.joinedVia || null; } } catch (e) {}
|
||||||
return json(res, 200, out);
|
return json(res, 200, out);
|
||||||
}
|
}
|
||||||
// -- broadcast a message to your downline (1/day), on-site inbox + email
|
// -- broadcast a message to your downline (1/day), on-site inbox + email
|
||||||
@@ -5017,6 +5441,25 @@ const server = http.createServer(async (req, res) => {
|
|||||||
return json(res, 200, Object.assign(r, { status: await ads.visitStatus(s.email) }));
|
return json(res, 200, Object.assign(r, { status: await ads.visitStatus(s.email) }));
|
||||||
}
|
}
|
||||||
// -- onsite solo ads: member inbox with read rewards
|
// -- onsite solo ads: member inbox with read rewards
|
||||||
|
// Stack POL page switch (Marty 2026-11-09): every member who has been paid has a public page at stackpol.com/<username> by
|
||||||
|
// default (Marty, same day: "Everyone's should be enabled by default"); only an explicit switch-off hides it. The list lives in
|
||||||
|
// DATA_DIR/stack-optin.json { users: { username: true|false } }; the Stack POL indexer on core reads it every 5 minutes.
|
||||||
|
if (p === '/api/my/stackpol' && (req.method === 'GET' || req.method === 'POST')) {
|
||||||
|
const s = await auth.fromRequest(req);
|
||||||
|
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||||
|
const acct = await accounts.byEmail(s.email); const un = String((acct && acct.username) || '').toLowerCase();
|
||||||
|
if (!un) return json(res, 400, { error: 'Pick a username first (Profile); your Stack POL page lives at stackpol.com/your-username.' });
|
||||||
|
const F = path.join(DATA_DIR, 'stack-optin.json'); let so = { users: {} }; try { so = JSON.parse(fs.readFileSync(F, 'utf8')); if (!so.users) so.users = {}; } catch (e) {}
|
||||||
|
let b = {}; if (req.method === 'POST') b = await readBody(req);
|
||||||
|
let buy = null;
|
||||||
|
if (req.method === 'POST' && b.pro === 'buy') buy = gamepass.buyStackPro(s.email); // Stack POL Pro: opens a waiting order, a $10+ package fulfils it
|
||||||
|
else if (req.method === 'POST' && b.pro === 'cancel') gamepass.cancelStackOrder(s.email);
|
||||||
|
else if (req.method === 'POST') so.users[un] = !!b.on;
|
||||||
|
// the indexer reads Pro owners from this same file, so the page knows who gets their LinkSpin links shown
|
||||||
|
so.pro = so.pro || {}; const pv = gamepass.stackProView(s.email); if (pv.pro) so.pro[un] = true; else delete so.pro[un];
|
||||||
|
if (req.method === 'POST' || !!so.pro[un] !== !!pv.pro || pv.pro) { so.updatedAt = Date.now(); const tmp = F + '.tmp'; fs.writeFileSync(tmp, JSON.stringify(so)); fs.renameSync(tmp, F); }
|
||||||
|
return json(res, 200, { on: so.users[un] !== false, username: un, url: 'https://stackpol.com/' + un, wallet: !!(acct && acct.address), pro: pv, buy });
|
||||||
|
}
|
||||||
if (p === '/api/my/inbox' && req.method === 'GET') {
|
if (p === '/api/my/inbox' && req.method === 'GET') {
|
||||||
const s = await auth.fromRequest(req);
|
const s = await auth.fromRequest(req);
|
||||||
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||||
@@ -5662,7 +6105,8 @@ const server = http.createServer(async (req, res) => {
|
|||||||
}
|
}
|
||||||
if (p === '/api/admin/snapshot/send' && req.method === 'POST') {
|
if (p === '/api/admin/snapshot/send' && req.method === 'POST') {
|
||||||
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
if (!isAdmin(req)) return json(res, 401, { error: 'auth' });
|
||||||
const r = await snapshot.post(); return json(res, r.error ? 400 : 200, r);
|
let target = ''; try { target = String(((await readBody(req)) || {}).target || '').trim(); } catch (e) {}
|
||||||
|
const r = target ? await snapshot.postTo(target) : await snapshot.post(); return json(res, r.error ? 400 : 200, r);
|
||||||
}
|
}
|
||||||
// -- 1,000-member drop: view, mode (off|dry|armed via site config), snapshot now, pay now, resend the missed-it notices, reset (only before any payment)
|
// -- 1,000-member drop: view, mode (off|dry|armed via site config), snapshot now, pay now, resend the missed-it notices, reset (only before any payment)
|
||||||
if (p === '/api/admin/milestone') {
|
if (p === '/api/admin/milestone') {
|
||||||
@@ -5854,6 +6298,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (p === '/partners') return sendFile(res, path.join(PUBLIC_DIR, 'partners.html')); // site-owner kit (Marty, 2026-09-12)
|
if (p === '/partners') return sendFile(res, path.join(PUBLIC_DIR, 'partners.html')); // site-owner kit (Marty, 2026-09-12)
|
||||||
if (p === '/earning') return sendFile(res, path.join(PUBLIC_DIR, 'earning.html'));
|
if (p === '/earning') return sendFile(res, path.join(PUBLIC_DIR, 'earning.html'));
|
||||||
if (p === '/games') return sendFile(res, path.join(PUBLIC_DIR, 'games.html'));
|
if (p === '/games') return sendFile(res, path.join(PUBLIC_DIR, 'games.html'));
|
||||||
|
if (p === '/chasing-unicorns') return sendFile(res, path.join(PUBLIC_DIR, 'chasing-unicorns.html')); // promo-tool lead magnet: a fake dashboard that teaches the red flags (Marty, 2026-11-12)
|
||||||
if (p === '/presentation') return sendFile(res, path.join(PUBLIC_DIR, 'presentation.html')); // narrated Build Wide presentation, captions in 6 languages (2026-10-15) // public games list (2026-10-10) // member guide: how earning works (2026-09-12)
|
if (p === '/presentation') return sendFile(res, path.join(PUBLIC_DIR, 'presentation.html')); // narrated Build Wide presentation, captions in 6 languages (2026-10-15) // public games list (2026-10-10) // member guide: how earning works (2026-09-12)
|
||||||
// -- badge share page + image: /b/<username>/<key> (OG preview = the member's composed badge) (Marty, 2026-09-13)
|
// -- badge share page + image: /b/<username>/<key> (OG preview = the member's composed badge) (Marty, 2026-09-13)
|
||||||
m = /^\/badge-img\/([a-z0-9_]{3,20})\/(payouts|firstBuyer|level2|level3)\.jpg$/.exec(p);
|
m = /^\/badge-img\/([a-z0-9_]{3,20})\/(payouts|firstBuyer|level2|level3)\.jpg$/.exec(p);
|
||||||
@@ -5873,11 +6318,11 @@ const server = http.createServer(async (req, res) => {
|
|||||||
+ '<meta name="description" content="' + esc(desc) + '"><link rel="canonical" href="' + url + '"><meta name="robots" content="noindex">'
|
+ '<meta name="description" content="' + esc(desc) + '"><link rel="canonical" href="' + url + '"><meta name="robots" content="noindex">'
|
||||||
+ '<meta property="og:type" content="website"><meta property="og:site_name" content="InstantAdPay"><meta property="og:title" content="' + esc(title) + '"><meta property="og:description" content="' + esc(desc) + '"><meta property="og:url" content="' + url + '"><meta property="og:image" content="' + img + '"><meta property="og:image:width" content="1024"><meta property="og:image:height" content="1024">'
|
+ '<meta property="og:type" content="website"><meta property="og:site_name" content="InstantAdPay"><meta property="og:title" content="' + esc(title) + '"><meta property="og:description" content="' + esc(desc) + '"><meta property="og:url" content="' + url + '"><meta property="og:image" content="' + img + '"><meta property="og:image:width" content="1024"><meta property="og:image:height" content="1024">'
|
||||||
+ '<meta name="twitter:card" content="summary_large_image"><meta name="twitter:title" content="' + esc(title) + '"><meta name="twitter:description" content="' + esc(desc) + '"><meta name="twitter:image" content="' + img + '">'
|
+ '<meta name="twitter:card" content="summary_large_image"><meta name="twitter:title" content="' + esc(title) + '"><meta name="twitter:description" content="' + esc(desc) + '"><meta name="twitter:image" content="' + img + '">'
|
||||||
+ '<link rel="icon" type="image/png" href="/logo-icon.png"><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">' + themehead.tag() + '<link rel="stylesheet" href="/assets/site.css?v=20261101th">'
|
+ '<link rel="icon" type="image/png" href="/logo-icon.png"><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&display=swap">' + themehead.tag() + '<link rel="stylesheet" href="/assets/site.css?v=20261112ln">'
|
||||||
+ '<style>.bp{max-width:560px;text-align:center;padding:40px 16px 60px}.bp img{width:100%;max-width:520px;border-radius:18px;border:1px solid var(--line);box-shadow:0 20px 60px rgba(0,0,0,.45)}.bp h1{font-size:clamp(24px,5vw,34px);margin:22px 0 8px}.bp p{color:var(--muted);max-width:44ch;margin:0 auto 20px}</style></head>'
|
+ '<style>.bp{max-width:560px;text-align:center;padding:40px 16px 60px}.bp img{width:100%;max-width:520px;border-radius:18px;border:1px solid var(--line);box-shadow:0 20px 60px rgba(0,0,0,.45)}.bp h1{font-size:clamp(24px,5vw,34px);margin:22px 0 8px}.bp p{color:var(--muted);max-width:44ch;margin:0 auto 20px}</style></head>'
|
||||||
+ '<body><div class="wrap bp"><img src="' + img + '" alt="' + esc(label) + ' badge for @' + esc(un) + '"><h1>@' + esc(un) + ' unlocked <em>' + label + '</em></h1><p>' + esc(sub.charAt(0).toUpperCase() + sub.slice(1)) + '. On InstantAdPay every ad package that sells pays the sponsor in the same transaction, straight to their wallet, on-chain.</p>'
|
+ '<body><div class="wrap bp"><img src="' + img + '" alt="' + esc(label) + ' badge for @' + esc(un) + '"><h1>@' + esc(un) + ' unlocked <em>' + label + '</em></h1><p>' + esc(sub.charAt(0).toUpperCase() + sub.slice(1)) + '. On InstantAdPay every ad package that sells pays the sponsor in the same transaction, straight to their wallet, on-chain.</p>'
|
||||||
+ '<a class="btn" href="/join/' + esc(un) + '">Join @' + esc(un) + '\u2019s line free</a><p class="small" style="margin-top:26px">Advertising with a performance referral program. Not an investment; no income is guaranteed.</p></div>'
|
+ '<a class="btn" href="/join/' + esc(un) + '">Join @' + esc(un) + '\u2019s line free</a><p class="small" style="margin-top:26px">Advertising with a performance referral program. Not an investment; no income is guaranteed.</p></div>'
|
||||||
+ '<script src="/assets/common.js?v=20261023ov"></script><script src="/assets/blog-page.js?v=20260921a"></script></body></html>';
|
+ '<script src="/assets/common.js?v=20261114ns"></script><script src="/assets/blog-page.js?v=20260921a"></script></body></html>';
|
||||||
res.writeHead(200, baseHeaders({ 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'public, max-age=300' }));
|
res.writeHead(200, baseHeaders({ 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'public, max-age=300' }));
|
||||||
return res.end(html);
|
return res.end(html);
|
||||||
}
|
}
|
||||||
@@ -5939,7 +6384,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
let a = await accounts.byUsername(tok); if (!a) a = await accounts.byCode(tok);
|
let a = await accounts.byUsername(tok); if (!a) a = await accounts.byCode(tok);
|
||||||
// a deleted or never-seen name is a real 404, never a bare "Banner wall" page at 200 (a soft 404 Google kept indexed, 2026-10-30)
|
// a deleted or never-seen name is a real 404, never a bare "Banner wall" page at 200 (a soft 404 Google kept indexed, 2026-10-30)
|
||||||
if (!a) {
|
if (!a) {
|
||||||
const nf = '<!doctype html><html lang="en"' + themehead.htmlAttr('dark') + '><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>No wall under that name | InstantAdPay</title><meta name="robots" content="noindex"><link rel="icon" type="image/png" href="/logo-icon.png">' + themehead.tag() + '<link rel="stylesheet" href="/assets/site.css?v=20261101th"></head><body><section><div class="wrap" style="max-width:720px;text-align:center;padding:60px 0"><h1>No wall under that name</h1><p class="muted">This member page does not exist or was removed.</p><p><a class="btn" href="/">Go to InstantAdPay</a></p></div></section></body></html>';
|
const nf = '<!doctype html><html lang="en"' + themehead.htmlAttr('dark') + '><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>No wall under that name | InstantAdPay</title><meta name="robots" content="noindex"><link rel="icon" type="image/png" href="/logo-icon.png">' + themehead.tag() + '<link rel="stylesheet" href="/assets/site.css?v=20261112ln"></head><body><section><div class="wrap" style="max-width:720px;text-align:center;padding:60px 0"><h1>No wall under that name</h1><p class="muted">This member page does not exist or was removed.</p><p><a class="btn" href="/">Go to InstantAdPay</a></p></div></section></body></html>';
|
||||||
res.writeHead(404, baseHeaders({ 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-cache', 'X-Robots-Tag': 'noindex' }));
|
res.writeHead(404, baseHeaders({ 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-cache', 'X-Robots-Tag': 'noindex' }));
|
||||||
return res.end(nf);
|
return res.end(nf);
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-3
@@ -104,11 +104,26 @@ async function post() {
|
|||||||
const s = await gather(); const text = compose(s, sc.telegramCtaUrl);
|
const s = await gather(); const text = compose(s, sc.telegramCtaUrl);
|
||||||
const targets = String(sc.snapshotTargets || 'feed,echo').split(',').map(x => x.trim());
|
const targets = String(sc.snapshotTargets || 'feed,echo').split(',').map(x => x.trim());
|
||||||
let sent = 0;
|
let sent = 0;
|
||||||
if (targets.includes('feed') && sc.telegramChatId) { if (await X.send(sc.telegramChatId, text, sc.telegramTopicId)) sent++; }
|
// Same three destinations as the milestone posts. 'support' was in the settings since 2026-09-24 but the daily
|
||||||
if (targets.includes('echo') && sc.telegramEchoChatId) { if (await X.send(sc.telegramEchoChatId, text, sc.telegramEchoTopicId)) sent++; }
|
// card only knew feed and echo, so the InstantAdPay support topic never saw it (Marty, 2026-11-02).
|
||||||
|
for (const [name, chat, thread] of [['feed', sc.telegramChatId, sc.telegramTopicId],
|
||||||
|
['support', sc.telegramSupportChatId, sc.telegramSupportTopicId],
|
||||||
|
['echo', sc.telegramEchoChatId, sc.telegramEchoTopicId]]) {
|
||||||
|
if (!targets.includes(name)) continue;
|
||||||
|
if (!chat) { console.warn('snapshot: target "' + name + '" is listed but has no chat id, nothing sent'); continue; }
|
||||||
|
if (await X.send(chat, text, thread)) sent++;
|
||||||
|
}
|
||||||
const st = state(); st.lastPost = Date.now(); st.lastDay = new Date().toISOString().slice(0, 10); setState(st);
|
const st = state(); st.lastPost = Date.now(); st.lastDay = new Date().toISOString().slice(0, 10); setState(st);
|
||||||
return { ok: true, sent, text };
|
return { ok: true, sent, text };
|
||||||
}
|
}
|
||||||
|
// one destination by name, for a one-off post (admin: POST /api/admin/snapshot/send with {target})
|
||||||
|
async function postTo(name) {
|
||||||
|
const sc = X.siteConfig(); if (!sc.telegramBotToken) return { error: 'No Telegram bot token set.' };
|
||||||
|
const map = { feed: [sc.telegramChatId, sc.telegramTopicId], support: [sc.telegramSupportChatId, sc.telegramSupportTopicId], echo: [sc.telegramEchoChatId, sc.telegramEchoTopicId] };
|
||||||
|
const t = map[name]; if (!t || !t[0]) return { error: 'No chat id for target ' + name + '.' };
|
||||||
|
const text = compose(await gather(), sc.telegramCtaUrl);
|
||||||
|
const ok = await X.send(t[0], text, t[1]); return { ok: !!ok, sent: ok ? 1 : 0, target: name, text };
|
||||||
|
}
|
||||||
|
|
||||||
// every 10 minutes: post once a day at or after snapshotHourUtc (a restart never double-posts)
|
// every 10 minutes: post once a day at or after snapshotHourUtc (a restart never double-posts)
|
||||||
async function tick() {
|
async function tick() {
|
||||||
@@ -203,4 +218,4 @@ async function milestoneTick() {
|
|||||||
}
|
}
|
||||||
async function previewMilestone(mark) { const sc = X.siteConfig(); return composeMilestone(Number(mark) || 500, await gather(), sc.telegramCtaUrl); }
|
async function previewMilestone(mark) { const sc = X.siteConfig(); return composeMilestone(Number(mark) || 500, await gather(), sc.telegramCtaUrl); }
|
||||||
|
|
||||||
module.exports = { init, gather, compose, post, tick, preview, milestoneTick, previewMilestone, composeMilestone, memberCount, MILESTONES, STEP };
|
module.exports = { init, gather, compose, post, postTo, tick, preview, milestoneTick, previewMilestone, composeMilestone, memberCount, MILESTONES, STEP };
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ const fs = require('fs');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
|
|
||||||
const DELIBERATE = ['adopt', 'rescue', 'release', 'expire', 'admin'];
|
const DELIBERATE = ['adopt', 'rescue', 'release', 'expire', 'admin', 'invited']; // invited = the member named who invited them (tank.js nameSponsor, 2026-11-07)
|
||||||
const WINDOW_MS = 15 * 60 * 1000;
|
const WINDOW_MS = 15 * 60 * 1000;
|
||||||
const PROTO = 2; // wire version: 2 = rows may carry sponsorSet* + tank, peers answer { proto: 2 }
|
const PROTO = 2; // wire version: 2 = rows may carry sponsorSet* + tank, peers answer { proto: 2 }
|
||||||
const n = v => String(v == null ? '' : v).trim().toLowerCase();
|
const n = v => String(v == null ? '' : v).trim().toLowerCase();
|
||||||
|
|||||||
@@ -11,16 +11,25 @@ const fs = require('fs');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const db = require('./db');
|
const db = require('./db');
|
||||||
|
|
||||||
const CAP_OPEN = 2; // open adoptions per adopter
|
// How many people an adopter may hold from the tank AT ONE TIME (Marty 2026-11-11, for the ~1,200 BTC4Hits imports, 6 then 10 the same day; was 2 open
|
||||||
|
// adoptions): open adoptions whose person has not switched payouts on yet (no member id). Activating frees the slot at once; the
|
||||||
|
// 7-day window closes the rest as before. Site setting tankAdoptCap, default 10.
|
||||||
|
const CAP_DEFAULT = 10; let capFn = () => CAP_DEFAULT;
|
||||||
|
const capOpen = () => { const n = Math.round(Number(capFn())); return n >= 1 && n <= 50 ? n : CAP_DEFAULT; };
|
||||||
|
async function holding(open) { const out = []; for (const ad of open || []) { const a = await accounts.byEmail(ad.adoptee); if (!(a && Number(a.memberId) > 0)) out.push(ad); } return out; }
|
||||||
const TTL_MS = 7 * 86400000; // an adoption's window to convert
|
const TTL_MS = 7 * 86400000; // an adoption's window to convert
|
||||||
const MAX_ADOPTIONS = 2; // per adoptee, lifetime (dropped adoptions count too, since 2026-09-13)
|
const MAX_ADOPTIONS = 2; // per adoptee, lifetime (dropped adoptions count too, since 2026-09-13)
|
||||||
const HOLD_MS = 3 * 24 * 3600 * 1000; // an adoption is a commitment: no releasing someone you picked up less than 3 days ago (Marty, 2026-09-13)
|
const HOLD_MS = 3 * 24 * 3600 * 1000; // an adoption is a commitment: no releasing someone you picked up less than 3 days ago (Marty, 2026-09-13)
|
||||||
// statuses that do not count toward a person's two adoptions: a release record, and the later side of a network race
|
// statuses that do not count toward a person's two adoptions: a release record, and the later side of a network race
|
||||||
// (both sites adopted the same person within minutes; the earlier adoption won on both, sponsorfollow.js)
|
// (both sites adopted the same person within minutes; the earlier adoption won on both, sponsorfollow.js), and a record of a
|
||||||
const NOT_COUNTED = ['released', 'conflict'];
|
// member naming who invited them (nobody adopted them; nameSponsor below)
|
||||||
|
const NOT_COUNTED = ['released', 'conflict', 'invited'];
|
||||||
const MIN_OWN_BUY_CENTS = 2000; // adopter must have bought a $20+ package themselves
|
const MIN_OWN_BUY_CENTS = 2000; // adopter must have bought a $20+ package themselves
|
||||||
const WARN_DAYS = 10; // dormant lead: sponsor warned after this many days without contact
|
const WARN_DAYS = 10; // dormant lead: sponsor warned after this many days without contact
|
||||||
const RESCUE_DAYS = 14; // ...and the lead moves to the tank after this many (warning at least 4 days old)
|
const RESCUE_DAYS = 14; // ...and the lead moves to the tank after this many (warning at least 4 days old)
|
||||||
|
const GRACE_MS = 24 * 3600 * 1000; // nobody adopts a new sign-up by hand for this long after `created`, so they can say who invited them (Marty 2026-11-07)
|
||||||
|
const BRAND = 'InstantAdPay';
|
||||||
|
const LINE_URL = () => siteUrl + '/my#line';
|
||||||
|
|
||||||
let DATA_DIR = '.', accounts, chain, messages, mailer, siteUrl = 'https://instantadpay.com';
|
let DATA_DIR = '.', accounts, chain, messages, mailer, siteUrl = 'https://instantadpay.com';
|
||||||
|
|
||||||
@@ -48,10 +57,10 @@ const D = {
|
|||||||
const rows = adopter ? await db.q("SELECT * FROM adoptions WHERE status='open' AND adopter=?", [adopter]) : await db.q("SELECT * FROM adoptions WHERE status='open'");
|
const rows = adopter ? await db.q("SELECT * FROM adoptions WHERE status='open' AND adopter=?", [adopter]) : await db.q("SELECT * FROM adoptions WHERE status='open'");
|
||||||
return rows.map(rowA);
|
return rows.map(rowA);
|
||||||
},
|
},
|
||||||
async countFor(adoptee) { const r = await db.q("SELECT COUNT(*) n FROM adoptions WHERE adoptee=? AND status NOT IN ('released','conflict')", [adoptee]); return Number(r[0].n); },
|
async countFor(adoptee) { const r = await db.q("SELECT COUNT(*) n FROM adoptions WHERE adoptee=? AND status NOT IN ('released','conflict','invited')", [adoptee]); return Number(r[0].n); },
|
||||||
async setStatus(id, status) { await db.q('UPDATE adoptions SET status=?, closed=? WHERE id=?', [status, Date.now(), Number(id)]); },
|
async setStatus(id, status) { await db.q('UPDATE adoptions SET status=?, closed=? WHERE id=?', [status, Date.now(), Number(id)]); },
|
||||||
async recent(n) { return (await db.q('SELECT * FROM adoptions ORDER BY id DESC LIMIT ?', [Number(n) || 100])).map(rowA); },
|
async recent(n) { return (await db.q('SELECT * FROM adoptions ORDER BY id DESC LIMIT ?', [Number(n) || 100])).map(rowA); },
|
||||||
async hasRecord(adoptee) { const r = await db.q("SELECT COUNT(*) n FROM adoptions WHERE adoptee=? AND status NOT IN ('released','conflict')", [adoptee]); return Number(r[0].n) > 0; },
|
async hasRecord(adoptee) { const r = await db.q("SELECT COUNT(*) n FROM adoptions WHERE adoptee=? AND status NOT IN ('released','conflict','invited')", [adoptee]); return Number(r[0].n) > 0; },
|
||||||
async all() { return (await db.q('SELECT * FROM adoptions ORDER BY id')).map(rowA); },
|
async all() { return (await db.q('SELECT * FROM adoptions ORDER BY id')).map(rowA); },
|
||||||
async mark(lead) { const r = await db.q('SELECT * FROM lead_marks WHERE `lead`=?', [lead]); return r[0] ? { sponsor: r[0].sponsor, contacted: Number(r[0].contacted_ts || 0), warned: Number(r[0].warned_ts || 0) } : null; },
|
async mark(lead) { const r = await db.q('SELECT * FROM lead_marks WHERE `lead`=?', [lead]); return r[0] ? { sponsor: r[0].sponsor, contacted: Number(r[0].contacted_ts || 0), warned: Number(r[0].warned_ts || 0) } : null; },
|
||||||
async setMark(lead, f) {
|
async setMark(lead, f) {
|
||||||
@@ -63,7 +72,7 @@ const rowA = r => ({ id: r.id, adoptee: r.adoptee, adopter: r.adopter, ts: Numbe
|
|||||||
const impl = () => db.enabled() ? D : J;
|
const impl = () => db.enabled() ? D : J;
|
||||||
|
|
||||||
let ads = null;
|
let ads = null;
|
||||||
function init(opts) { DATA_DIR = opts.dataDir; accounts = opts.accounts; chain = opts.chain; messages = opts.messages; mailer = opts.mailer; ads = opts.ads || null; if (opts.site) siteUrl = opts.site; follow = opts.follow || null; store = opts.store || null; J.load();
|
function init(opts) { DATA_DIR = opts.dataDir; accounts = opts.accounts; chain = opts.chain; messages = opts.messages; mailer = opts.mailer; ads = opts.ads || null; if (opts.site) siteUrl = opts.site; follow = opts.follow || null; store = opts.store || null; if (opts.capOpen) capFn = opts.capOpen; J.load();
|
||||||
hooks = opts.hooks || {}; RS.st = null; RS.load(); }
|
hooks = opts.hooks || {}; RS.st = null; RS.load(); }
|
||||||
// every sponsor change the tank makes is deliberate: recorded (when, how, the sponsor before) so it follows to LinkSpin
|
// every sponsor change the tank makes is deliberate: recorded (when, how, the sponsor before) so it follows to LinkSpin
|
||||||
// until the member is bound on a contract (sponsorfollow.js). Without the follow glue (tests) it is a plain write.
|
// until the member is bound on a contract (sponsorfollow.js). Without the follow glue (tests) it is a plain write.
|
||||||
@@ -77,20 +86,42 @@ const countAll = async email => (await impl().countFor(email)) + remoteCount(ema
|
|||||||
const mask = e => String(e || '').replace(/^(.).*(@.*)$/, '$1***$2');
|
const mask = e => String(e || '').replace(/^(.).*(@.*)$/, '$1***$2');
|
||||||
const nameOf = a => a.username ? '@' + a.username : (a.memberId ? 'member #' + a.memberId : mask(a.email));
|
const nameOf = a => a.username ? '@' + a.username : (a.memberId ? 'member #' + a.memberId : mask(a.email));
|
||||||
const inTank = a => !a.sponsorRef && !a.memberId; // arrived with no sponsor (or fell back), still free
|
const inTank = a => !a.sponsorRef && !a.memberId; // arrived with no sponsor (or fell back), still free
|
||||||
|
// Rule 3 (Marty 2026-11-14): never offer anyone locked on ANY network contract or whom the network hub already knows a sponsor
|
||||||
|
// for (hooks.networkHeld = hubsync.heldAmong, wired only with HUB_ENABLED). A hook that throws holds everyone it was asked
|
||||||
|
// about: the conservative side. No hook (flag off, tests) = nothing held, the tank as before.
|
||||||
|
const lc = v => String(v || '').trim().toLowerCase();
|
||||||
|
async function heldSet(accts) {
|
||||||
|
if (!hooks.networkHeld || !accts.length) return new Map();
|
||||||
|
try { return (await hooks.networkHeld(accts)) || new Map(); } catch (e) { console.error('tank networkHeld', e.message); return new Map(accts.map(a => [lc(a.email), 'unknown'])); }
|
||||||
|
}
|
||||||
|
// release / rescue / expiry: 'locked' | 'unknown' | null (hooks.networkLocked = hubsync.lockedAnywhere)
|
||||||
|
const HELD_WHY = { locked: 'they are locked on a network contract', sponsored: 'it already knows a sponsor for them', unknown: 'nothing (it is not answering)' };
|
||||||
|
async function lockedWhy(email) {
|
||||||
|
if (!hooks.networkLocked) return null;
|
||||||
|
try { return (await hooks.networkLocked(email)) || null; } catch (e) { return 'unknown'; }
|
||||||
|
}
|
||||||
|
|
||||||
// waiting list: newest sign-in first so a live one is easy to spot
|
// waiting list: newest sign-in first so a live one is easy to spot
|
||||||
async function waiting() {
|
async function waiting() {
|
||||||
const all = await accounts.listAll(5000);
|
// one network tank (Marty 2026-11-14: the InstantAdPay and LinkSpin tanks should show the same people): waiting accounts that
|
||||||
const rows = all.filter(a => inTank(a) && !remoteOpen(a.email)); // one network tank: someone adopted on LinkSpin is not waiting here
|
// never signed in here (BTC4Hits and LinkSpin arrivals) count too, as on LinkSpin; quiet accounts the hub made (joinedVia
|
||||||
|
// 'hub') count too since 2026-11-14 (Marty: the unsponsored old VBB / Downline Banners members go into the holding tank; adopting
|
||||||
|
// one sends the normal adoption email). Rule 3 still keeps out anyone the hub reports locked or sponsored. The weekly email
|
||||||
|
// only counts the tank, it never mails it.
|
||||||
|
const all = await accounts.listAll(1e6, { shells: true });
|
||||||
|
const cand = all.filter(a => inTank(a) && !remoteOpen(a.email)); // one network tank: someone adopted on LinkSpin is not waiting here
|
||||||
|
const held = await heldSet(cand); const rows = cand.filter(a => !held.has(lc(a.email))); // rule 3: locked or sponsored elsewhere
|
||||||
// what each of them has earned by surfing on their own, no sponsor (Marty, 2026-09-29), so an adopter can spot the workers
|
// what each of them has earned by surfing on their own, no sponsor (Marty, 2026-09-29), so an adopter can spot the workers
|
||||||
const tot = ads && ads.earnedTotals ? await ads.earnedTotals(rows.map(a => a.email)) : {};
|
const tot = ads && ads.earnedTotals ? await ads.earnedTotals(rows.map(a => a.email)) : {};
|
||||||
return rows.map(a => ({ email: a.email, name: nameOf(a), username: a.username || null, joined: a.created, lastSeen: a.lastSeen || 0,
|
return rows.map(a => ({ email: a.email, name: nameOf(a), username: a.username || null, joined: a.created, lastSeen: a.lastSeen || 0,
|
||||||
|
via: a.joinedVia || null, // the door they came in by (the 5xYourTeam draft card shows it)
|
||||||
wallet: !!a.address, activated: !!a.memberId, // in the tank "activated" is always false (payouts on = out of the tank); wallet can still be linked
|
wallet: !!a.address, activated: !!a.memberId, // in the tank "activated" is always false (payouts on = out of the tank); wallet can still be linked
|
||||||
earned: (tot[a.email] || {}).earned || 0, balance: (tot[a.email] || {}).balance || 0,
|
earned: (tot[a.email] || {}).earned || 0, balance: (tot[a.email] || {}).balance || 0,
|
||||||
// wallet linked = ready to switch on payouts, held for an adopter (24-hour clock, autoAssign after that)
|
// wallet linked = ready to switch on payouts, held for an adopter (24-hour clock, autoAssign after that)
|
||||||
|
opensAt: inGrace(a) ? graceEnd(a) : 0, // new sign-up: nobody can adopt them by hand before this (0 = open now)
|
||||||
...(() => { const r = a.address ? readyRec(a.email) : null; return r ? { ready: true, readyAt: r.readyAt, holdUntil: r.readyAt + READY_MS } : { ready: false }; })() }))
|
...(() => { const r = a.address ? readyRec(a.email) : null; return r ? { ready: true, readyAt: r.readyAt, holdUntil: r.readyAt + READY_MS } : { ready: false }; })() }))
|
||||||
// ready members first (least time left first), then newest sign-in
|
// open before the sign-up grace ones, ready members first (least time left first), then newest sign-in
|
||||||
.sort((a, b) => (b.ready ? 1 : 0) - (a.ready ? 1 : 0) || (a.ready && b.ready ? a.readyAt - b.readyAt : 0) || (b.lastSeen || b.joined) - (a.lastSeen || a.joined));
|
.sort((a, b) => (a.opensAt ? 1 : 0) - (b.opensAt ? 1 : 0) || (b.ready ? 1 : 0) - (a.ready ? 1 : 0) || (a.ready && b.ready ? a.readyAt - b.readyAt : 0) || (b.lastSeen || b.joined) - (a.lastSeen || a.joined));
|
||||||
}
|
}
|
||||||
|
|
||||||
// has this member bought a $20+ package themselves? (the qualifying-for-yourself buy)
|
// has this member bought a $20+ package themselves? (the qualifying-for-yourself buy)
|
||||||
@@ -104,8 +135,27 @@ async function eligibility(email) {
|
|||||||
if (!a) return { ok: false, reason: 'Sign in first.' };
|
if (!a) return { ok: false, reason: 'Sign in first.' };
|
||||||
if (!a.memberId) return { ok: false, reason: 'Switch on payouts and buy your first $20 package to adopt from the tank.' };
|
if (!a.memberId) return { ok: false, reason: 'Switch on payouts and buy your first $20 package to adopt from the tank.' };
|
||||||
if (!hasOwnBuy(a.memberId)) return { ok: false, reason: 'Buy your own $20 or more package first. Adopting is for members who have made that move themselves.' };
|
if (!hasOwnBuy(a.memberId)) return { ok: false, reason: 'Buy your own $20 or more package first. Adopting is for members who have made that move themselves.' };
|
||||||
const open = await impl().open(a.email);
|
const open = await impl().open(a.email); const held = await holding(open); const cap = capOpen();
|
||||||
if (open.length >= CAP_OPEN) return { ok: false, reason: 'You have ' + CAP_OPEN + ' open adoptions. Help one of them link a wallet or buy, and a slot frees up.', full: true };
|
if (held.length >= cap) return { ok: false, reason: 'You are already helping ' + held.length + ' people from the holding tank, and ' + cap + ' at one time is the most anyone can hold. A slot opens when one of them switches on payouts, or when their 7-day window ends.', full: true, cap, held: held.length };
|
||||||
|
return { ok: true, account: a, open };
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5xYourTeam coaches (Marty 2026-11-15: "not a fan of people adopting if they have nothing vested"; a $10 5x position qualifies,
|
||||||
|
// no IAP $20 package needed). draftpartner.js has already checked the signed claim from 5xYourTeam (p.positions); this is the
|
||||||
|
// InstantAdPay side of the same gate: a real account here with a wallet linked, not suspended or flagged, someone on THIS
|
||||||
|
// contract in their line (them or an upline with payouts on, else a pick who starts here would be walked up to the company, the
|
||||||
|
// one thing the tank exists to stop; the nameSponsor rule), and room under the same people-held-at-once cap as every adopter.
|
||||||
|
async function partnerEligibility(email, p) {
|
||||||
|
const a = await accounts.byEmail(email);
|
||||||
|
if (!a) return { ok: false, code: 'coach_unknown', reason: 'This coach has no InstantAdPay account yet. Sign in on InstantAdPay once (network sign-in) and link the same wallet.' };
|
||||||
|
if (!(Number(p && p.positions) >= 1)) return { ok: false, code: 'not_vested', reason: 'Only 5xYourTeam position holders can draft and coach.' };
|
||||||
|
if (!a.address) return { ok: false, code: 'no_wallet', reason: 'Link a wallet on InstantAdPay first. A coach needs a linked wallet.' };
|
||||||
|
const bar = hooks.excluded || hooks.isSuspended; if (bar && bar(a.email)) return { ok: false, code: 'excluded', reason: 'Adoptions are not available on this account.' };
|
||||||
|
const payee = await firstOnContract(a);
|
||||||
|
if (!payee) return { ok: false, code: 'no_contract_line', reason: 'Neither you nor anyone above you has switched on payouts on InstantAdPay, so a pick who starts there would land under the company. Switch on payouts on InstantAdPay first (one free transaction).' };
|
||||||
|
if (hooks.payoutBlocked && await Promise.resolve(hooks.payoutBlocked(Number(payee.memberId))).catch(() => true)) return { ok: false, code: 'payout_blocked', reason: 'Your line cannot take new members right now.' };
|
||||||
|
const open = await impl().open(a.email); const held = await holding(open); const cap = Math.min(capOpen(), Number(p.maxOpen) > 0 ? Number(p.maxOpen) : capOpen());
|
||||||
|
if (held.length >= cap) return { ok: false, code: 'full', reason: 'You are already helping ' + held.length + ' people from the holding tank, and ' + cap + ' at one time is the most anyone can hold.', full: true, cap, held: held.length };
|
||||||
return { ok: true, account: a, open };
|
return { ok: true, account: a, open };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,36 +167,47 @@ async function view(email) {
|
|||||||
const a = await accounts.byEmail(ad.adoptee);
|
const a = await accounts.byEmail(ad.adoptee);
|
||||||
mine.push({ id: ad.id, name: a ? nameOf(a) : mask(ad.adoptee), email: ad.adoptee, ts: ad.ts, expires: ad.expires, lastSeen: a ? (a.lastSeen || 0) : 0, wallet: !!(a && a.address), address: (a && a.address) || null, bought: !!(a && a.memberId) });
|
mine.push({ id: ad.id, name: a ? nameOf(a) : mask(ad.adoptee), email: ad.adoptee, ts: ad.ts, expires: ad.expires, lastSeen: a ? (a.lastSeen || 0) : 0, wallet: !!(a && a.address), address: (a && a.address) || null, bought: !!(a && a.memberId) });
|
||||||
}
|
}
|
||||||
return { eligible: el.ok, reason: el.ok ? '' : el.reason, cap: CAP_OPEN, ttlDays: TTL_MS / 86400000, holdHours: READY_MS / 3600000, waiting: await waiting(), mine };
|
return { eligible: el.ok, reason: el.ok ? '' : el.reason, cap: capOpen(), ttlDays: TTL_MS / 86400000, holdHours: READY_MS / 3600000, graceHours: GRACE_MS / 3600000, waiting: await waiting(), mine };
|
||||||
}
|
}
|
||||||
|
|
||||||
async function adopt(adopterEmail, who, note, opts) {
|
async function adopt(adopterEmail, who, note, opts) {
|
||||||
const auto = !!(opts && opts.auto); // the 24-hour safety net (autoAssign): same path, a different record note, both sides emailed
|
const auto = !!(opts && opts.auto); // the 24-hour safety net (autoAssign): same path, a different record note, both sides emailed
|
||||||
|
// partner = a 5xYourTeam draft pick (draftpartner.js, 2026-11-15): the coach qualifies by a 5x position instead of the $20 buy,
|
||||||
|
// the window is the pick's (3 days, partner.ttlMs), the hub is asked fresh that nobody locked is taken, no reminder mails
|
||||||
|
const partner = (opts && opts.partner) || null;
|
||||||
const e = String(adopterEmail || '').toLowerCase();
|
const e = String(adopterEmail || '').toLowerCase();
|
||||||
const el = await eligibility(e);
|
const el = partner ? await partnerEligibility(e, partner) : await eligibility(e);
|
||||||
if (!el.ok) return { error: el.reason };
|
if (!el.ok) return { error: el.reason, code: el.code || 'not_eligible' };
|
||||||
const me = el.account;
|
const me = el.account;
|
||||||
const key = String(who || '').trim().toLowerCase().replace(/^@/, '');
|
const key = String(who || '').trim().toLowerCase().replace(/^@/, '');
|
||||||
const list = await waiting();
|
const list = await waiting();
|
||||||
const target = list.find(w => (w.username && w.username.toLowerCase() === key) || w.email === key);
|
const target = list.find(w => (w.username && w.username.toLowerCase() === key) || w.email === key);
|
||||||
if (!target) return { error: 'That member is no longer in the tank.' };
|
if (!target) return { error: 'That member is no longer in the tank.', code: 'gone' };
|
||||||
if (target.email === e) return { error: 'That is you.' };
|
if (target.email === e) return { error: 'That is you.', code: 'self' };
|
||||||
if (remoteOpen(target.email)) return { error: 'That member was just picked up on ' + OTHER + ', so they are no longer in the tank.' };
|
if (!auto && target.opensAt > clock()) return { error: 'That member joined less than 24 hours ago, so they still have time to tell us who invited them. You can adopt them in ' + leftText(target.opensAt - clock()) + '.', code: 'grace' }; // the safety net is not held by this: it keeps its 24-hour clock from the wallet link
|
||||||
if (!auto && await countAll(target.email) >= MAX_ADOPTIONS) return { error: 'That member has been adopted twice already and stays where they are.' }; // the safety net never leaves anyone to the company
|
if (remoteOpen(target.email)) return { error: 'That member was just picked up on ' + OTHER + ', so they are no longer in the tank.', code: 'linkspin' };
|
||||||
|
if (!auto && await countAll(target.email) >= MAX_ADOPTIONS) return { error: 'That member has been adopted twice already and stays where they are.', code: 'adopted_twice' }; // the safety net never leaves anyone to the company
|
||||||
|
if (partner) { // never anyone locked on a network contract: asked fresh, a hub that does not answer refuses (the conservative side)
|
||||||
|
const lk = await lockedWhy(target.email);
|
||||||
|
if (lk) return { error: lk === 'locked' ? 'That member is locked to a sponsor on a network contract.' : 'The network record cannot be checked right now. Try again in a few minutes.', code: lk === 'locked' ? 'locked' : 'hub_unknown' };
|
||||||
|
if (await inDownlineOf(target.email, me)) return { error: 'That member is above you in your own line.', code: 'loop' };
|
||||||
|
}
|
||||||
const token = me.username || me.code || String(me.memberId);
|
const token = me.username || me.code || String(me.memberId);
|
||||||
const r = await setSponsor(target.email, token, 'adopt');
|
const r = await setSponsor(target.email, token, 'adopt');
|
||||||
if (r.error) return r;
|
if (r.error) return r;
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
const text = String(note || '').trim().slice(0, 600) || ('Hi, I am ' + nameOf(me) + '. You joined InstantAdPay without a sponsor, so I picked you up from the holding tank. I will walk you through the first three steps whenever you are ready. Reply here.');
|
const tgt0 = await accounts.byEmail(target.email); const b4h = !!(tgt0 && (tgt0.joinedVia === 'btc4hits' || tgt0.joinedRef === 'btc4hits')); // a BTC4Hits import (2026-11-11)
|
||||||
const ad = await impl().add({ adoptee: target.email, adopter: e, ts: now, expires: now + TTL_MS, status: 'open', note: (opts && opts.recordNote) || text });
|
const text = String(note || '').trim().slice(0, 600) || ('Hi, I am ' + nameOf(me) + (partner ? ', your coach from 5xYourTeam' : '') + '. ' + (b4h ? 'Your BTC4Hits account moved to InstantAdPay' : 'You joined InstantAdPay') + ' without a sponsor, so I picked you up from the holding tank' + (partner ? ' in The Draft' : '') + '. I will walk you through the first three steps whenever you are ready. Reply here.');
|
||||||
|
const ttl = partner && Number(partner.ttlMs) > 0 ? Number(partner.ttlMs) : TTL_MS;
|
||||||
|
const ad = await impl().add({ adoptee: target.email, adopter: e, ts: now, expires: now + ttl, status: 'open', note: (opts && opts.recordNote) || text });
|
||||||
{ const rr = RS.load().ready[target.email]; if (rr && !rr.done) { rr.done = now; rr.adoptedBy = e; RS.save(); } } // the hold lifts: their sponsor resolves now
|
{ const rr = RS.load().ready[target.email]; if (rr && !rr.done) { rr.done = now; rr.adoptedBy = e; RS.save(); } } // the hold lifts: their sponsor resolves now
|
||||||
payTrack(target.email, e, ad.id, auto); // switch-on-payouts reminders at 24 h and 72 h (payTick)
|
if (!partner) payTrack(target.email, e, ad.id, auto); // switch-on-payouts reminders at 24 h and 72 h (payTick); a draft pick gets the adoption email only (Marty 2026-11-15)
|
||||||
const link = activateLink();
|
const link = activateLink();
|
||||||
try { await messages.sendChat(me.memberId || 0, e, target.email, text + '\n\n' + chatPayLine(link)); } catch (err) {}
|
try { await messages.sendChat(me.memberId || 0, e, target.email, text + '\n\n' + chatPayLine(link)); } catch (err) {}
|
||||||
if (mailer && mailer.hasKey()) {
|
if (mailer && mailer.hasKey()) {
|
||||||
try {
|
try {
|
||||||
await mailer.send(target.email, nameOf(me) + ' is now your sponsor on InstantAdPay',
|
await mailer.send(target.email, nameOf(me) + ' is now your sponsor on InstantAdPay',
|
||||||
'You joined InstantAdPay without a sponsor. ' + nameOf(me) + ' has picked you up from the holding tank and is your sponsor now, which means a real person to walk you through the first steps.\n\nTheir message:\n\n' + text + '\n\n' + mailPayBlock(nameOf(me), link, !!target.wallet) + '\n\nReply in your member area: ' + siteUrl + '/my#messages\n\nInstantAdPay');
|
(b4h ? 'BTC4Hits has closed, and your BTC4Hits account came over to InstantAdPay with the same email. ' : 'You joined InstantAdPay without a sponsor. ') + nameOf(me) + ' has picked you up from the holding tank and is your sponsor now, which means a real person to walk you through the first steps.\n\nTheir message:\n\n' + text + '\n\n' + mailPayBlock(nameOf(me), link, !!target.wallet) + '\n\nReply in your member area: ' + siteUrl + '/my#messages\n\nInstantAdPay');
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
if (auto) {
|
if (auto) {
|
||||||
try {
|
try {
|
||||||
@@ -155,7 +216,7 @@ async function adopt(adopterEmail, who, note, opts) {
|
|||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { ok: true, auto, adoption: ad, name: target.name, adopterName: nameOf(me), adopteeName: target.name };
|
return { ok: true, auto, adoption: ad, name: target.name, adopterName: nameOf(me), adopteeName: target.name, adoptee: target.email };
|
||||||
}
|
}
|
||||||
|
|
||||||
// pay it forward: give one of your own free referrals to the tank
|
// pay it forward: give one of your own free referrals to the tank
|
||||||
@@ -166,6 +227,8 @@ async function release(ownerEmail, directEmail) {
|
|||||||
const toks = [owner.code, owner.username, owner.memberId ? String(owner.memberId) : null].filter(Boolean).map(String);
|
const toks = [owner.code, owner.username, owner.memberId ? String(owner.memberId) : null].filter(Boolean).map(String);
|
||||||
if (!toks.includes(String(direct.sponsorRef || ''))) return { error: 'That member is not in your line.' };
|
if (!toks.includes(String(direct.sponsorRef || ''))) return { error: 'That member is not in your line.' };
|
||||||
if (direct.memberId) return { error: 'That member has already bought; on-chain sponsorship cannot move.' };
|
if (direct.memberId) return { error: 'That member has already bought; on-chain sponsorship cannot move.' };
|
||||||
|
const lk = await lockedWhy(d); // rule 3: someone a network contract holds never goes to the tank
|
||||||
|
if (lk) return { error: lk === 'locked' ? nameOf(direct) + ' is locked to a sponsor on a network contract, so they cannot go to the holding tank.' : 'The network record for ' + nameOf(direct) + ' cannot be checked right now. Try again in a few minutes.' };
|
||||||
// picked up from the tank recently? then it is not theirs to drop yet (Bradley churned three in 80 seconds, 2026-09-13)
|
// picked up from the tank recently? then it is not theirs to drop yet (Bradley churned three in 80 seconds, 2026-09-13)
|
||||||
const openAds = (await impl().open(null)).filter(ad => ad.adoptee === d);
|
const openAds = (await impl().open(null)).filter(ad => ad.adoptee === d);
|
||||||
let young = openAds.find(ad => Date.now() - ad.ts < HOLD_MS);
|
let young = openAds.find(ad => Date.now() - ad.ts < HOLD_MS);
|
||||||
@@ -192,10 +255,14 @@ async function sweep() {
|
|||||||
let done = 0, back = 0, kept = 0;
|
let done = 0, back = 0, kept = 0;
|
||||||
for (const ad of await impl().open(null)) {
|
for (const ad of await impl().open(null)) {
|
||||||
if (ad.expires > now) continue;
|
if (ad.expires > now) continue;
|
||||||
|
if (hooks.isDraftPick && await Promise.resolve(hooks.isDraftPick(ad.id)).catch(() => true)) continue; // a 5xYourTeam pick: draftpartner.js owns its 3-day window (started = payouts on, not a wallet)
|
||||||
const a = await accounts.byEmail(ad.adoptee);
|
const a = await accounts.byEmail(ad.adoptee);
|
||||||
if (!a) { await impl().setStatus(ad.id, 'expired'); continue; }
|
if (!a) { await impl().setStatus(ad.id, 'expired'); continue; }
|
||||||
if (a.address || a.memberId) { await impl().setStatus(ad.id, 'done'); done++; continue; }
|
if (a.address || a.memberId) { await impl().setStatus(ad.id, 'done'); done++; continue; }
|
||||||
if (await impl().countFor(ad.adoptee) >= MAX_ADOPTIONS) { await impl().setStatus(ad.id, 'expired'); kept++; continue; }
|
if (await impl().countFor(ad.adoptee) >= MAX_ADOPTIONS) { await impl().setStatus(ad.id, 'expired'); kept++; continue; }
|
||||||
|
const lk = await lockedWhy(ad.adoptee); // rule 3: a person a network contract holds stays with the adopter, never back in the tank
|
||||||
|
if (lk === 'unknown') continue; // the hub is not answering: try again next hour
|
||||||
|
if (lk === 'locked') { await impl().setStatus(ad.id, 'expired'); kept++; continue; }
|
||||||
await setSponsor(ad.adoptee, '', 'expire', 'adoption window ended');
|
await setSponsor(ad.adoptee, '', 'expire', 'adoption window ended');
|
||||||
await impl().setStatus(ad.id, 'expired'); back++;
|
await impl().setStatus(ad.id, 'expired'); back++;
|
||||||
}
|
}
|
||||||
@@ -260,11 +327,14 @@ async function markContacted(sponsorEmail, leadEmail) {
|
|||||||
async function rescueSweep() {
|
async function rescueSweep() {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
let warned = 0, rescued = 0, dead = 0;
|
let warned = 0, rescued = 0, dead = 0;
|
||||||
for (const a of await accounts.listAll(5000)) {
|
const all = await accounts.listAll(5000);
|
||||||
|
await heldSet(all.filter(a => !a.memberId && !a.address && a.sponsorRef)); // one batched hub call warms the cache for lockedWhy below
|
||||||
|
for (const a of all) {
|
||||||
if (a.memberId || a.address || !a.sponsorRef) continue; // bound, wallet, or already in the tank
|
if (a.memberId || a.address || !a.sponsorRef) continue; // bound, wallet, or already in the tank
|
||||||
if (await impl().hasRecord(a.email)) continue; // adopted / rescued before: the tank's window rules
|
if (await impl().hasRecord(a.email)) continue; // adopted / rescued before: the tank's window rules
|
||||||
const pv = store && store.get(a.email);
|
const pv = store && store.get(a.email);
|
||||||
if (remoteCount(a.email) || (pv && pv.by !== 'admin')) continue; // adopted / released / rescued on LinkSpin: the tank's window rules there
|
if (remoteCount(a.email) || (pv && pv.by !== 'admin')) continue; // adopted / released / rescued on LinkSpin: the tank's window rules there
|
||||||
|
if (await lockedWhy(a.email)) continue; // rule 3: locked on a network contract (or the hub is not answering): no warning, no move
|
||||||
const sp = await sponsorOf(a);
|
const sp = await sponsorOf(a);
|
||||||
if (!sp) { // dead sponsor link: nobody can ever coach them, straight to the tank after a day
|
if (!sp) { // dead sponsor link: nobody can ever coach them, straight to the tank after a day
|
||||||
if (now - (a.created || 0) < 86400000) continue;
|
if (now - (a.created || 0) < 86400000) continue;
|
||||||
@@ -373,7 +443,7 @@ async function previousSponsors(email) {
|
|||||||
async function alignToNetwork(a) {
|
async function alignToNetwork(a) {
|
||||||
if (!a || !inTank(a) || !hooks.network) return null;
|
if (!a || !inTank(a) || !hooks.network) return null;
|
||||||
const e = String(a.email || '').toLowerCase(); if (!e) return null;
|
const e = String(a.email || '').toLowerCase(); if (!e) return null;
|
||||||
const n = hooks.network(e, a.address || null); if (!n || !n.sponsorEmail) return null;
|
const n = await Promise.resolve(hooks.network(e, a.address || null)).catch(() => null); if (!n || !n.sponsorEmail) return null; // the hub's answer is async
|
||||||
const spEmail = String(n.sponsorEmail).toLowerCase(); if (spEmail === e) return null;
|
const spEmail = String(n.sponsorEmail).toLowerCase(); if (spEmail === e) return null;
|
||||||
if ((await previousSponsors(e)).has(spEmail)) return null; // never back to someone they were released or rescued from
|
if ((await previousSponsors(e)).has(spEmail)) return null; // never back to someone they were released or rescued from
|
||||||
const sp = await accounts.byEmail(spEmail);
|
const sp = await accounts.byEmail(spEmail);
|
||||||
@@ -384,7 +454,7 @@ async function alignToNetwork(a) {
|
|||||||
for (let i = 0; cur && i < 60; i++) { if (cur.email === e || seen.has(cur.email)) return null; seen.add(cur.email); cur = await accounts.sponsorOf(cur.email); }
|
for (let i = 0; cur && i < 60; i++) { if (cur.email === e || seen.has(cur.email)) return null; seen.add(cur.email); cur = await accounts.sponsorOf(cur.email); }
|
||||||
const fresh = await accounts.byEmail(e); if (!fresh || !inTank(fresh)) return null;
|
const fresh = await accounts.byEmail(e); if (!fresh || !inTank(fresh)) return null;
|
||||||
const r = await accounts.setSponsorRef(e, token); if (r && r.error) return null;
|
const r = await accounts.setSponsorRef(e, token); if (r && r.error) return null;
|
||||||
const st = RS.load(); const why = 'aligned to network sponsor ' + nameOf(sp) + ' from LinkSpin (' + (n.via || 'email') + ')';
|
const st = RS.load(); const why = 'aligned to network sponsor ' + nameOf(sp) + (/hub/.test(n.via || '') ? ' (' + n.via + ')' : ' from LinkSpin (' + (n.via || 'email') + ')');
|
||||||
st.aligned.push({ email: e, to: sp.email, toName: nameOf(sp), via: n.via || 'email', at: clock(), why });
|
st.aligned.push({ email: e, to: sp.email, toName: nameOf(sp), via: n.via || 'email', at: clock(), why });
|
||||||
if (st.aligned.length > 300) st.aligned = st.aligned.slice(-300);
|
if (st.aligned.length > 300) st.aligned = st.aligned.slice(-300);
|
||||||
if (st.ready[e] && !st.ready[e].done) { st.ready[e].done = clock(); st.ready[e].aligned = sp.email; }
|
if (st.ready[e] && !st.ready[e].done) { st.ready[e].done = clock(); st.ready[e].aligned = sp.email; }
|
||||||
@@ -435,16 +505,22 @@ async function autoAssignRun() {
|
|||||||
due.push([e, rec, a]);
|
due.push([e, rec, a]);
|
||||||
}
|
}
|
||||||
due.sort((x, y) => x[1].readyAt - y[1].readyAt);
|
due.sort((x, y) => x[1].readyAt - y[1].readyAt);
|
||||||
|
const netHeld = await heldSet(due.map(x => x[2]));
|
||||||
let pool = null;
|
let pool = null;
|
||||||
for (const [e, rec, a] of due) {
|
for (const [e, rec, a] of due) {
|
||||||
|
if (netHeld.has(e)) { // rule 3: never auto-assigned; the admin hears once (their network sponsor has no usable account here yet, or the hub is not answering)
|
||||||
|
out.held++;
|
||||||
|
if (!rec.networkHeldAlerted) { rec.networkHeldAlerted = clock(); RS.save(); if (hooks.adminAlert) { try { await hooks.adminAlert(BRAND + ' holding tank: ' + nameOf(a) + ' (' + e + ') is held and NOT auto-assigned: the network hub says ' + (HELD_WHY[netHeld.get(e)] || netHeld.get(e)) + ', and that sponsor could not be used here. Set their sponsor in Admin if it should be someone here.'); } catch (err) {} } }
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!pool) pool = await rotation(e);
|
if (!pool) pool = await rotation(e);
|
||||||
let done = null;
|
let done = null;
|
||||||
for (const c of pool) {
|
for (const c of pool) {
|
||||||
if (c.a.email === e) continue;
|
if (c.a.email === e) continue;
|
||||||
if ((await impl().open(c.a.email)).length >= CAP_OPEN) continue;
|
if ((await holding(await impl().open(c.a.email))).length >= capOpen()) continue;
|
||||||
if (hooks.payoutBlocked && await Promise.resolve(hooks.payoutBlocked(Number(c.a.memberId))).catch(() => true)) continue; // no-payout chain: they would fall to the company after all
|
if (hooks.payoutBlocked && await Promise.resolve(hooks.payoutBlocked(Number(c.a.memberId))).catch(() => true)) continue; // no-payout chain: they would fall to the company after all
|
||||||
if (await inDownlineOf(e, c.a)) continue;
|
if (await inDownlineOf(e, c.a)) continue;
|
||||||
const msg = 'Hi, I am ' + nameOf(c.a) + '. You joined InstantAdPay without a sponsor and nobody picked you up from the holding tank within 24 hours, so you were matched with me. I will walk you through the first steps whenever you are ready. Reply here.';
|
const msg = 'Hi, I am ' + nameOf(c.a) + '. ' + ((a.joinedVia === 'btc4hits' || a.joinedRef === 'btc4hits') ? 'Your BTC4Hits account moved to InstantAdPay' : 'You joined InstantAdPay') + ' without a sponsor and nobody picked you up from the holding tank within 24 hours, so you were matched with me. I will walk you through the first steps whenever you are ready. Reply here.';
|
||||||
const r = await adopt(c.a.email, a.username || e, msg, { auto: true, recordNote: 'auto-assigned after 24 hours in the tank' });
|
const r = await adopt(c.a.email, a.username || e, msg, { auto: true, recordNote: 'auto-assigned after 24 hours in the tank' });
|
||||||
if (r && r.ok) { done = { adoptee: e, adopter: c.a.email, adopterName: r.adopterName, adopteeName: r.adopteeName }; break; }
|
if (r && r.ok) { done = { adoptee: e, adopter: c.a.email, adopterName: r.adopterName, adopteeName: r.adopteeName }; break; }
|
||||||
}
|
}
|
||||||
@@ -458,7 +534,7 @@ async function autoAssignRun() {
|
|||||||
out.held++;
|
out.held++;
|
||||||
if (!rec.noAdopterAlerted) {
|
if (!rec.noAdopterAlerted) {
|
||||||
rec.noAdopterAlerted = clock(); RS.save();
|
rec.noAdopterAlerted = clock(); RS.save();
|
||||||
if (hooks.adminAlert) { try { await hooks.adminAlert('InstantAdPay holding tank: ' + nameOf(a) + ' (' + e + ') linked a wallet ' + Math.round((now - rec.readyAt) / 3600000) + ' hours ago and nobody is eligible to take them (own $20+ package, fewer than ' + CAP_OPEN + ' open adoptions, signed in within 7 days, not suspended or on a no-payout chain). They stay on hold, never under the company. Adopt them from My line > Holding tank, or set their sponsor in Admin.'); } catch (err) {} }
|
if (hooks.adminAlert) { try { await hooks.adminAlert('InstantAdPay holding tank: ' + nameOf(a) + ' (' + e + ') linked a wallet ' + Math.round((now - rec.readyAt) / 3600000) + ' hours ago and nobody is eligible to take them (own $20+ package, fewer than ' + capOpen() + ' tank members held, signed in within 7 days, not suspended or on a no-payout chain). They stay on hold, never under the company. Adopt them from My line > Holding tank, or set their sponsor in Admin.'); } catch (err) {} }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -469,15 +545,19 @@ async function autoAssignRun() {
|
|||||||
// run the safety net. `fresh` = members who became ready and were not announced yet (server.js posts them).
|
// run the safety net. `fresh` = members who became ready and were not announced yet (server.js posts them).
|
||||||
async function readyTick() {
|
async function readyTick() {
|
||||||
const st = RS.load(); const fresh = []; let aligned = 0;
|
const st = RS.load(); const fresh = []; let aligned = 0;
|
||||||
for (const a of await accounts.listAll(5000)) {
|
const tankers = (await accounts.listAll(5000)).filter(inTank);
|
||||||
if (!inTank(a)) continue;
|
const netHeld = await heldSet(tankers); // one batched hub call; alignToNetwork below reads the same cache
|
||||||
|
for (const a of tankers) {
|
||||||
if (await alignToNetwork(a).catch(() => null)) { aligned++; continue; }
|
if (await alignToNetwork(a).catch(() => null)) { aligned++; continue; }
|
||||||
if (remoteOpen(a.email)) continue;
|
if (remoteOpen(a.email)) continue;
|
||||||
|
if (netHeld.has(lc(a.email))) continue; // rule 3: not announced, no 24-hour clock while the network holds them
|
||||||
const rec = markReady(a);
|
const rec = markReady(a);
|
||||||
// linkedNow: the member was on the site when they became ready, so they linked the wallet just now; otherwise the
|
// linkedNow: the member was on the site when they became ready, so they linked the wallet just now; otherwise the
|
||||||
// wallet predates this tank visit (e.g. a dormant member returned by a sponsor; Marty 2026-10-29: the notice read as a
|
// wallet predates this tank visit (e.g. a dormant member returned by a sponsor; Marty 2026-10-29: the notice read as a
|
||||||
// fresh link) and the notice says so, with their last sign-in
|
// fresh link) and the notice says so, with their last sign-in
|
||||||
if (rec && !rec.notified) { rec.notified = clock(); fresh.push({ email: a.email, name: nameOf(a), username: a.username || null, until: rec.readyAt + READY_MS, lastSeen: a.lastSeen || 0, linkedNow: (a.lastSeen || 0) >= rec.readyAt - 15 * 60 * 1000 }); }
|
// Sign-up grace (2026-11-07): no "adopt them" post for someone who cannot be adopted yet; announced when the grace ends,
|
||||||
|
// and not at all when the safety net takes them in this same tick (nothing left for anyone to do)
|
||||||
|
if (rec && !rec.notified && !inGrace(a)) { rec.notified = clock(); if (clock() < rec.readyAt + READY_MS - TICK_MS) fresh.push({ email: a.email, name: nameOf(a), username: a.username || null, until: rec.readyAt + READY_MS, lastSeen: a.lastSeen || 0, linkedNow: (a.lastSeen || 0) >= rec.readyAt - 15 * 60 * 1000 }); }
|
||||||
}
|
}
|
||||||
RS.save();
|
RS.save();
|
||||||
const auto = await autoAssign();
|
const auto = await autoAssign();
|
||||||
@@ -548,11 +628,95 @@ async function payTick() {
|
|||||||
function payView() { return Object.entries(RS.load().pay || {}).map(([email, r]) => Object.assign({ email }, r)).sort((x, y) => y.at - x.at).slice(0, 100); }
|
function payView() { return Object.entries(RS.load().pay || {}).map(([email, r]) => Object.assign({ email }, r)).sort((x, y) => y.at - x.at).slice(0, 100); }
|
||||||
function alignedRecent(n) { return RS.load().aligned.slice(-(n || 50)).reverse(); }
|
function alignedRecent(n) { return RS.load().aligned.slice(-(n || 50)).reverse(); }
|
||||||
|
|
||||||
|
// ── sign-up grace + "Who invited you?" (Marty approved 2026-11-07: "24-hour grace plus the prompt") ──
|
||||||
|
// Nov 2: @santoridaviss signed up with no referral at 10:35 PM, was adoptable at 2:24 AM and adopted at 3:36 AM, before he
|
||||||
|
// could say who invited him. So:
|
||||||
|
// GRACE: for 24 hours from the account's `created`, nobody can adopt the person BY HAND. They stay on the waiting list with
|
||||||
|
// opensAt set (the card shows "Opens in ...", no Adopt button). The dates are each site's own account dates. Only sign-up
|
||||||
|
// counts: someone back in the tank later (released, rescued, window ended) is past it.
|
||||||
|
// The safety net does not wait for the grace (opts.auto skips it): Marty's rule is a wallet-linked member is held for no
|
||||||
|
// longer than 24 hours, so autoAssign keeps its clock from the wallet link. Wallet linked in the first 15 minutes: the
|
||||||
|
// rotation can fire up to 15 minutes before the grace ends, and hand adoption never opens for them. Wallet linked in the
|
||||||
|
// first hour: hand adoption opens at 24 hours and the rotation takes them about an hour after that.
|
||||||
|
// Notices: readyTick announces a ready member only once they can be adopted, and only when time is left (adoptableOf and
|
||||||
|
// openedSince keep the Overview note, the arrivals post and the weekly email to people who are open too).
|
||||||
|
// PROMPT: a tank member can name who invited them. nameSponsor() goes through setSponsor like adopt(), so it follows to the
|
||||||
|
// other site and clears the hold the same way, but it is the member's own choice: only ever for the signed-in member,
|
||||||
|
// never an open adoption (no 7-day window, no fall-back, no count toward the two), recorded as status 'invited'.
|
||||||
|
function graceEnd(a) { return (Number(a && a.created) || 0) + GRACE_MS; }
|
||||||
|
function inGrace(a) { return graceEnd(a) > clock(); }
|
||||||
|
function leftText(ms) { const m = Math.max(1, Math.ceil(Number(ms) / 60000) || 1); const h = Math.floor(m / 60); return h ? h + ' h ' + (m % 60) + ' min' : m + ' min'; }
|
||||||
|
const adoptableOf = list => (list || []).filter(w => !(w.opensAt > clock()));
|
||||||
|
async function adoptable() { return adoptableOf(await waiting()); }
|
||||||
|
// people whose grace ended after `since` (the arrivals post: announced when they can be adopted, not when they sign up)
|
||||||
|
function openedSince(list, since) { const now = clock(); return (list || []).filter(w => { const t = (Number(w.joined) || 0) + GRACE_MS; return t > since && t <= now; }); }
|
||||||
|
// what the dashboard needs: null = no card. dismissed = they tapped "Nobody invited me" (a small link brings the card back).
|
||||||
|
function inviteAsk(a) {
|
||||||
|
if (!a || !inTank(a) || remoteOpen(a.email)) return null;
|
||||||
|
return { dismissed: !!(RS.load().noInvite || {})[String(a.email || '').toLowerCase()] };
|
||||||
|
}
|
||||||
|
function dismissInvite(email) { const st = RS.load(); st.noInvite = st.noInvite || {}; st.noInvite[String(email || '').toLowerCase()] = clock(); RS.save(); return { ok: true }; }
|
||||||
|
// someone in the named person's line (them first) already has a contract position? Otherwise the member would be walked up to
|
||||||
|
// the company at their first activation, the one thing the tank exists to stop
|
||||||
|
async function firstOnContract(sp) {
|
||||||
|
let cur = sp; const seen = new Set();
|
||||||
|
for (let i = 0; cur && i < 60; i++) { if (Number(cur.memberId) > 0) return cur; if (seen.has(cur.email)) return null; seen.add(cur.email); cur = await accounts.sponsorOf(cur.email); }
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// opts.check: every refusal, nothing written (the card asks "is this them?" before the real call)
|
||||||
|
async function nameSponsor(email, who, opts) {
|
||||||
|
const e = String(email || '').toLowerCase(); const check = !!(opts && opts.check);
|
||||||
|
const LOCKED = 'Your payouts are already on, so your sponsor is locked on the contract.';
|
||||||
|
let a = await accounts.byEmail(e);
|
||||||
|
if (!a) return { error: 'Sign in first.' };
|
||||||
|
if (Number(a.memberId) > 0) return { error: LOCKED };
|
||||||
|
if (a.sponsorRef) return { error: 'You already have a sponsor.' };
|
||||||
|
if (a.address) { // wallet on the contract already, member number not saved yet
|
||||||
|
if (hooks.bound) { const id = await Promise.resolve(hooks.bound(a)).catch(() => -1); if (id < 0) return { error: 'Could not check the contract just now. Try again in a minute.' }; if (id > 0) return { error: LOCKED }; }
|
||||||
|
else if (hooks.activated && await Promise.resolve(hooks.activated(a)).catch(() => false)) return { error: LOCKED };
|
||||||
|
}
|
||||||
|
if (remoteOpen(e)) return { error: 'You were just picked up on ' + OTHER + ', so you already have a sponsor.' };
|
||||||
|
const al = await alignToNetwork(a).catch(() => null); // one identity: the sponsor the network already knows comes first
|
||||||
|
if (al) return { error: 'You already have a sponsor on the network: ' + al.toName + '.', aligned: true };
|
||||||
|
const key = String(who || '').trim().toLowerCase().replace(/^@+/, '');
|
||||||
|
if (!key) return { error: 'Type the username of the person who invited you.' };
|
||||||
|
const sp = /^[a-z0-9_]{3,20}$/.test(key) ? await accounts.byUsername(key) : null;
|
||||||
|
if (!sp || (accounts.isUnclaimedShell && accounts.isUnclaimedShell(sp))) return { error: 'No member here has the username ' + key + '. Check the spelling with the person who invited you.' };
|
||||||
|
if (String(sp.email).toLowerCase() === e) return { error: 'That is you. Type the username of the person who invited you.' };
|
||||||
|
const bar = hooks.excluded || hooks.isSuspended;
|
||||||
|
if (bar && bar(sp.email)) return { error: nameOf(sp) + ' cannot take new members right now.' };
|
||||||
|
if (await inDownlineOf(e, sp)) return { error: nameOf(sp) + ' is in your own line, so they cannot be your sponsor.' };
|
||||||
|
const payee = await firstOnContract(sp);
|
||||||
|
if (!payee) return { error: nameOf(sp) + ' has not switched on payouts yet, and nobody above them has either, so you cannot go under them yet. Ask them to switch on payouts, then come back here.' };
|
||||||
|
if (hooks.payoutBlocked && await Promise.resolve(hooks.payoutBlocked(Number(payee.memberId))).catch(() => true)) return { error: nameOf(sp) + ' cannot take new members right now.' };
|
||||||
|
if (check) return { ok: true, check: true, name: nameOf(sp) };
|
||||||
|
a = await accounts.byEmail(e);
|
||||||
|
if (!a || !inTank(a)) return { error: 'You already have a sponsor.' };
|
||||||
|
const token = sp.username || sp.code || String(sp.memberId);
|
||||||
|
const r = await setSponsor(e, token, 'invited', 'named by the member on the Who invited you card');
|
||||||
|
if (r && r.error) return r;
|
||||||
|
const now = clock();
|
||||||
|
const ad = await impl().add({ adoptee: e, adopter: String(sp.email).toLowerCase(), ts: now, expires: now, status: 'invited', note: 'named by the member on the Who invited you card' });
|
||||||
|
{ const rr = RS.load().ready[e]; if (rr && !rr.done) { rr.done = now; rr.namedSponsor = sp.email; RS.save(); } } // the hold lifts: their sponsor resolves now
|
||||||
|
const name = nameOf(a);
|
||||||
|
payTrack(e, sp.email, ad.id, false); // the same switch-on-payouts reminders as an adoption (payTick)
|
||||||
|
const subject = 'You have a new referral on ' + BRAND;
|
||||||
|
const text = name + ' joined ' + BRAND + ' without a sponsor link and told us you invited them, so they are on your team from today. Say hello and help them with their first steps: ' + LINE_URL();
|
||||||
|
if (mailer && mailer.hasKey()) { try { await mailer.send(sp.email, subject, text + '\n\n' + BRAND); } catch (err) {} }
|
||||||
|
if (hooks.notify) { try { await hooks.notify(sp.email, subject, text); } catch (err) {} }
|
||||||
|
return { ok: true, name: nameOf(sp), sponsorEmail: sp.email, member: name };
|
||||||
|
}
|
||||||
|
|
||||||
|
// the open adoptions of one person (draftpartner.js checks a pick's adoption is still the open one), and closing one
|
||||||
|
async function openOf(email) { const e = String(email || '').toLowerCase(); return (await impl().open(null)).filter(ad => ad.adoptee === e); }
|
||||||
|
async function closeAdoption(id, status) { await impl().setStatus(id, status); }
|
||||||
|
|
||||||
async function adminView() {
|
async function adminView() {
|
||||||
const recent = await impl().recent(200);
|
const recent = await impl().recent(200);
|
||||||
const names = {};
|
const names = {};
|
||||||
for (const ad of recent) for (const em of [ad.adoptee, ad.adopter]) if (!(em in names)) { const a = await accounts.byEmail(em); names[em] = a ? nameOf(a) : em; }
|
for (const ad of recent) for (const em of [ad.adoptee, ad.adopter]) if (!(em in names)) { const a = await accounts.byEmail(em); names[em] = a ? nameOf(a) : em; }
|
||||||
return { waiting: await waiting(), adoptions: recent.map(ad => Object.assign({}, ad, { adopteeName: names[ad.adoptee], adopterName: names[ad.adopter] })), cap: CAP_OPEN, ttlDays: TTL_MS / 86400000, holdHours: READY_MS / 3600000, aligned: alignedRecent(30), payReminders: payView() };
|
return { waiting: await waiting(), adoptions: recent.map(ad => Object.assign({}, ad, { adopteeName: names[ad.adoptee], adopterName: names[ad.adopter] })), cap: capOpen(), ttlDays: TTL_MS / 86400000, holdHours: READY_MS / 3600000, aligned: alignedRecent(30), payReminders: payView() };
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { init, view, adopt, holdFor, markReady, readyRec, readyTick, autoAssign, payTick, payView, activateLink, PAY_R1_MS, PAY_R2_MS, alignToNetwork, alignedRecent, setClock, eligibility, READY_MS, release, sweep, rescueSweep, rescueInfo, markContacted, adminView, waiting, hasOwnBuy, recordGift, onFollow, summaryMap, summaryFor, historyMap, CAP_OPEN, TTL_MS, WARN_DAYS, RESCUE_DAYS, MAX_ADOPTIONS };
|
module.exports = { partnerEligibility, openOf, closeAdoption, countAll, remoteCount: email => remoteCount(String(email || '').toLowerCase()), lockedWhy, inTank, setSponsorDeliberate: (email, token, by, note) => setSponsor(email, token, by, note), HOLD_MS, NOT_COUNTED,
|
||||||
|
init, view, adopt, holdFor, markReady, readyRec, readyTick, autoAssign, payTick, payView, activateLink, PAY_R1_MS, PAY_R2_MS, alignToNetwork, alignedRecent, setClock, eligibility, READY_MS, release, sweep, rescueSweep, rescueInfo, markContacted, adminView, waiting, adoptable, adoptableOf, openedSince, leftText, inviteAsk, dismissInvite, nameSponsor, GRACE_MS, hasOwnBuy, recordGift, onFollow, summaryMap, summaryFor, historyMap, capOpen, TTL_MS, WARN_DAYS, RESCUE_DAYS, MAX_ADOPTIONS };
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
// Export the chatbot's canned answers (the code-checked official knowledge) as Markdown for other assistants, e.g. the
|
||||||
|
// Earners Corner forum assistant (Marty 2026-11-10). Usage: node tools/export-knowledge.js <out.md>
|
||||||
|
'use strict';
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const src = fs.readFileSync(path.join(__dirname, '..', 'chatbot.js'), 'utf8');
|
||||||
|
|
||||||
|
// read a single-quoted JS string literal starting at index i (the opening quote)
|
||||||
|
function str(i) { let s = ''; for (i++; i < src.length; i++) { const ch = src[i]; if (ch === '\\') { s += src[++i]; continue; } if (ch === "'") return { s, end: i }; s += ch; } return { s, end: i }; }
|
||||||
|
|
||||||
|
let out = '# InstantAdPay official knowledge\n\nSource: the InstantAdPay chatbot canned answers (code-checked). Exported ' + new Date().toISOString().slice(0, 10) + '.\n\n', n = 0;
|
||||||
|
const re = /\{ id: '([a-z0-9-]+)', title: '/g; let m;
|
||||||
|
while ((m = re.exec(src))) {
|
||||||
|
const title = str(m.index + m[0].length - 1);
|
||||||
|
const qStart = src.indexOf('q: [', title.end), qEnd = src.indexOf(']', qStart);
|
||||||
|
const qs = []; for (let i = src.indexOf("'", qStart); i > 0 && i < qEnd; i = src.indexOf("'", i + 1)) { const q = str(i); qs.push(q.s); i = q.end; }
|
||||||
|
const a = src.indexOf("a: '", qEnd); const ans = str(a + 3);
|
||||||
|
out += '## ' + title.s + '\n\nQuestions people ask: ' + qs.join(' | ') + '\n\n' + ans.s + '\n\n'; n++;
|
||||||
|
}
|
||||||
|
fs.writeFileSync(process.argv[2] || 'instantadpay-knowledge.md', out);
|
||||||
|
console.log('entries', n, 'chars', out.length);
|
||||||
Reference in New Issue
Block a user