diff --git a/catalog/traffic-sources.json b/catalog/traffic-sources.json index b1576a1..0369ac0 100644 --- a/catalog/traffic-sources.json +++ b/catalog/traffic-sources.json @@ -141,6 +141,24 @@ "verified": true, "source": "network" }, + { + "key": "videoappincome", + "name": "Video App Income", + "site": "videoappincome.com", + "costModel": "", + "params": [ + { + "key": "clickid", + "token": "{clickid}", + "label": "Click id", + "role": "externalId" + } + ], + "postbackUrl": "", + "notes": "Crypto Team Build Network video maker. Clicks that arrive from Video App Income carry ?src=videoappincome and are counted under this source automatically. Sign-ups, sponsor confirmations and credit purchases on Video App Income that follow one of your link clicks are reported back and show under Reports > Conversions.", + "verified": true, + "source": "network" + }, { "key": "viraladsource", "name": "ViralAdSource", diff --git a/netconv.js b/netconv.js index 190f2bc..ed6314e 100644 --- a/netconv.js +++ b/netconv.js @@ -19,6 +19,7 @@ const path = require('path'); const crypto = require('crypto'); const EVENTS = ['join', 'wallet', 'purchase']; +const SITE_NAMES = { vai: 'Video App Income' }; // events reported by another network site carry its id; none = InstantAdPay let FILE = null, C = null, R = null, B = null, P = null, M = null; let st = { size: -1, rows: [], keys: new Set(), byClick: new Map(), byRoot: new Map() }; const norm = e => String(e || '').trim().toLowerCase(); @@ -72,11 +73,12 @@ async function record(e) { const value = ev === 'purchase' ? C.cleanValue(e.value) : 0; const sk = /^s:[a-f0-9]{20}$/.test(String(e.sk || '')) ? String(e.sk) : ''; const tx = String(e.tx || '').slice(0, 80) || undefined; + const site = SITE_NAMES[String(e.site || '')] ? String(e.site) : undefined; const rows = owners.map(o => { const was = (prior || []).find(r => r.owner === o); const f = L ? factsOf(L, o) : { kind: was.kind, camp: was.camp, cname: was.cname, rot: was.rot, rcode: was.rcode, rname: was.rname, d: was.d, sr: was.sr, bcode: was.bcode, src: was.src, c: was.c, dv: was.dv, q: was.q }; const self = email === o || !!(was && was.self) || seen.some(r => r.owner === o && r.self) || (L ? C.selfFor(L, o, sk) : false); - const row = Object.assign({ k: owners.length > 1 ? k + '|' + o : k, ev, ts: at, rec: now, value, acct, click, root, clickTs, owner: o, tx, self: self ? 1 : undefined }, f); + const row = Object.assign({ k: owners.length > 1 ? k + '|' + o : k, ev, ts: at, rec: now, value, acct, click, root, clickTs, owner: o, tx, site, self: self ? 1 : undefined }, f); for (const x of Object.keys(row)) if (row[x] === undefined) delete row[x]; return row; }); @@ -100,7 +102,7 @@ async function fromLinkSpin(lsid, ev, facts) { } async function mirror(r) { const key = r.k.split('|')[0]; - if (r.rot) return R.convert(r.click, r.ev, { payout: r.value, label: r.ev === 'purchase' ? 'InstantAdPay' : undefined, key, ts: r.ts, bound: { r: r.rot, d: r.d, sr: r.sr } }); + if (r.rot) return R.convert(r.click, r.ev, { payout: r.value, label: r.ev === 'purchase' ? (SITE_NAMES[r.site] || 'InstantAdPay') : undefined, key, ts: r.ts, bound: { r: r.rot, d: r.d, sr: r.sr } }); if (r.kind === 'bspin' && r.click[0] === 'k') return R.convert(r.click, r.ev, { payout: r.value, key, ts: r.ts }); return null; } diff --git a/netlinks.js b/netlinks.js index be4add8..454eeef 100644 --- a/netlinks.js +++ b/netlinks.js @@ -14,6 +14,7 @@ const SITES = [ { id: 'viraladblitz', code: 'nwvab', name: 'ViralAdBlitz', url: 'https://viraladblitz.com/{s2}?ref={s1}' }, { id: 'viraladsource', code: 'nwvas', name: 'ViralAdSource', url: 'https://viraladsource.com/{s2}?ref={s1}' }, { id: 'yourprogrambuilder', code: 'nwypb', name: 'YourProgramBuilder', url: 'https://yourprogrambuilder.com/{s2}?ref={s1}' }, + { id: 'videoappincome', code: 'nwvai', name: 'Video App Income', url: 'https://videoappincome.com/{s2}?ref={s1}' }, // 2026-11-21: s2 = join for the invite page, empty = the sales page { id: 'fivex', code: 'nw5x', name: '5xYourTeam', url: 'https://5xyourteam.com/{s2}?ref={s1}' }, { id: 'downlinehydra', code: 'nwdh', name: 'DownlineHydra', url: 'https://downlinehydra.com/{s2}?ref={s1}' }, { id: 'stackpol', code: 'nwsp', name: 'Stack POL', url: 'https://stackpol.com/{s2}?ref={s1}' }, diff --git a/netsites.js b/netsites.js index 5977af9..d10283f 100644 --- a/netsites.js +++ b/netsites.js @@ -36,7 +36,7 @@ function list() { if (Date.now() - cache.at > TTL) refresh(); return cache.list; // entry also gets go = the LinkSpin network link for that site with ?src=, 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', viraladblitz: 'nwvab', viraladsource: 'nwvas', yourprogrambuilder: 'nwypb', fivex: 'nw5x', downlinehydra: 'nwdh', stackpol: 'nwsp', earnerscorner: 'nwec' }; +const CODES = { iap: 'nwiap', linkspin: 'nwls', dlb: 'nwdlb', vbb: 'nwvbb', viraladblitz: 'nwvab', viraladsource: 'nwvas', yourprogrambuilder: 'nwypb', videoappincome: 'nwvai', fivex: 'nw5x', downlinehydra: 'nwdh', 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) { diff --git a/qa/netsrc.test.mjs b/qa/netsrc.test.mjs index 59e25b4..6924951 100644 --- a/qa/netsrc.test.mjs +++ b/qa/netsrc.test.mjs @@ -28,14 +28,16 @@ const srcOf = (owner, tpl) => read('sources.json').items.find(x => x.owner === o try { await boot(); const rots = read('rotator.json').rotations.filter(r => r.owner === ADMIN); - ok(['nwiap', 'nwls', 'nwdlb', 'nwvbb', 'nwvab', 'nwvas', 'nwypb', 'nw5x', 'nwdh', 'nwsp', 'nwec'].every(c => rots.some(r => r.code === c)) && rots.length === 11, 'the admin account has the eleven network links', rots.map(r => r.code)); + ok(['nwiap', 'nwls', 'nwdlb', 'nwvbb', 'nwvab', 'nwvas', 'nwypb', 'nwvai', 'nw5x', 'nwdh', 'nwsp', 'nwec'].every(c => rots.some(r => r.code === c)) && rots.length === 12, 'the admin account has the twelve network links', rots.map(r => r.code)); const mineSrc = read('sources.json').items.filter(x => x.owner === ADMIN); - ok(['instantadpay', 'linkspin', 'downlinebanners', 'viralbannerblitz', 'viraladblitz', 'viraladsource', 'yourprogrambuilder', '5xyourteam', 'downlinehydra', 'stackpol', 'earnerscorner'].every(t => mineSrc.some(x => x.template === t)) && mineSrc.length === 11, 'and one source per network site', mineSrc.map(x => x.template)); + ok(['instantadpay', 'linkspin', 'downlinebanners', 'viralbannerblitz', 'viraladblitz', 'viraladsource', 'yourprogrambuilder', 'videoappincome', '5xyourteam', 'downlinehydra', 'stackpol', 'earnerscorner'].every(t => mineSrc.some(x => x.template === t)) && mineSrc.length === 12, 'and one source per network site', mineSrc.map(x => x.template)); let r = await go('/r/nwdlb?src=iap&s1=bob&s2=how'); ok(r.status === 302 && /^https:\/\/downlinebanners\.com\/how\?ref=bob$/.test(r.loc), 'nwdlb: lands on /how with ?ref=bob', r); r = await go('/r/nwiap?src=vbb&s1=amy'); ok(r.status === 302 && /^https:\/\/instantadpay\.com\/\?ref=amy&lsclk=[a-f0-9]{10}$/.test(r.loc), 'nwiap: home page with ?ref=amy and the click id (InstantAdPay reports joins against it)', r); + r = await go('/r/nwvai?src=iap&s1=amy&s2=join'); + ok(r.status === 302 && /^https:\/\/videoappincome\.com\/join\?ref=amy&lsclk=[a-f0-9]{10}$/.test(r.loc), 'nwvai: Video App Income join page with ?ref=amy and the click id (it reports sign-ups and purchases against it)', r); r = await go('/r/nwec?src=dlb'); ok(r.status === 302 && /^https:\/\/earnerscorner\.com\/(\?|$)/.test(r.loc), 'nwec: the forum home', r); r = await go('/r/nwdh?src=downlinehydra&s1=bob'); @@ -64,7 +66,7 @@ try { ok(read('sources.json').items.filter(x => x.owner === MEM).length === 2, 'an unknown src makes no source'); await stop(); await boot(); - ok(read('rotator.json').rotations.filter(x => x.owner === ADMIN).length === 11 && read('sources.json').items.filter(x => x.owner === ADMIN).length === 11, 'a reboot makes nothing twice'); + ok(read('rotator.json').rotations.filter(x => x.owner === ADMIN).length === 12 && read('sources.json').items.filter(x => x.owner === ADMIN).length === 12, 'a reboot makes nothing twice'); } catch (e) { fail++; console.error(e); } finally { await stop(); try { fs.rmSync(DATA, { recursive: true, force: true }); } catch (e) {} } console.log('\n' + pass + ' passed, ' + fail + ' failed'); process.exit(fail ? 1 : 0); diff --git a/server.js b/server.js index 1ecfadf..f4c102b 100644 --- a/server.js +++ b/server.js @@ -950,7 +950,7 @@ function readRaw(req, maxBytes) { // the image pixel cannot read the thank-you page's address, but a browser that sends the full referrer hands it to us function refClickId(req) { try { const r = new URL(String(req.headers.referer || '')); const v = r.searchParams.get('lsclk') || r.searchParams.get('lsid') || ''; return /^[a-z0-9]{6,24}$/i.test(v) ? v : ''; } catch (e) { return ''; } } // the sites of the network a click id may travel to (the landing tag's list, 2026-11-07): this site, InstantAdPay, its share domains -const NETWORK_HOSTS = String(process.env.NETWORK_HOSTS || 'instantadpay.com,instantadpay.link,ctbgo.com,mylinehq.com').split(',').map(x => x.trim().toLowerCase()).filter(Boolean); +const NETWORK_HOSTS = String(process.env.NETWORK_HOSTS || 'instantadpay.com,instantadpay.link,ctbgo.com,mylinehq.com,videoappincome.com,clickvidpro.com').split(',').map(x => x.trim().toLowerCase()).filter(Boolean); function networkHosts() { return [...new Set([String(SITE_HOST || '').toLowerCase().replace(/:\d+$/, '').replace(/^www\./, '')].concat(NETWORK_HOSTS))].filter(Boolean); } function clickCookie(id) { return 'ls.clk=' + id + '; Path=/; Max-Age=2592000; ' + (IS_PROD ? 'SameSite=None; Secure' : 'SameSite=Lax'); } // an ad click: record a click id for the campaign and append ?lsclk= to the target (existing params kept, an lsclk @@ -3279,6 +3279,25 @@ const server = http.createServer(async (req, res) => { const email = String(sg.body.email || '').trim().toLowerCase(); if (!email) return json(res, 400, { error: 'Which member?' }); return json(res, 200, { ok: true, facts: await engine.facts({ site: 'linkspin', adminMember, ads, coach, bannerspin, rotator, pages, convtrack }, email) }); } + // -- conversions reported by another network site (2026-11-21, first site: Video App Income). Reporting only, like the route below, + // but with the site's OWN secret (NETCONV_SECRET_VAI): the shared partner secret can move sponsors, this one can only add + // conversion events, and only ones keyed to that site. X-Net-Ts (ms) + X-Net-Sig = hex HMAC-SHA256(secret, 'netconv.v1.' + ts + '\n' + raw). + if (p === '/api/partner/netconv/vai' && req.method === 'POST') { + const secret = String(process.env.NETCONV_SECRET_VAI || '').trim(); if (secret.length < 32) return json(res, 503, { error: 'not configured' }); + let raw; try { 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); }); } catch (e) { return json(res, 413, { error: 'too big' }); } + const ts = String(req.headers['x-net-ts'] || ''), sig = String(req.headers['x-net-sig'] || ''); + if (!/^\d{13}$/.test(ts) || Math.abs(Date.now() - Number(ts)) > 5 * 60000) return json(res, 401, { error: 'stale' }); + const want = crypto.createHmac('sha256', secret).update('netconv.v1.' + ts + '\n' + raw).digest('hex'); + if (want.length !== sig.length || !crypto.timingSafeEqual(Buffer.from(want), Buffer.from(sig))) return json(res, 401, { error: 'bad signature' }); + let b; try { b = JSON.parse(raw || '{}'); } catch (e) { return json(res, 400, { error: 'bad json' }); } + const results = []; + for (const ev of (Array.isArray(b.events) ? b.events.slice(0, 200) : [])) { + let r = { result: 'bad' }; + if (ev && /^vai:/.test(String(ev.k || ''))) { try { r = await netconv.record(Object.assign({}, ev, { site: 'vai' })); } catch (e) { console.error('netconv vai', e.message); return json(res, 500, { error: 'not recorded' }); } } + results.push({ k: String(ev && ev.k || ''), result: r.result }); + } + return json(res, 200, { ok: true, results }); + } if (p === '/api/partner/conv' && req.method === 'POST') { const sg = await readPartnerSigned(req, 64000); if (!sg.body) return json(res, sg.status, { error: sg.error }); const b = sg.body; const email = String(b.email || '').trim().toLowerCase(); diff --git a/sources.js b/sources.js index a366234..c255127 100644 --- a/sources.js +++ b/sources.js @@ -143,7 +143,7 @@ function meta(owner) { const m = {}; for (const s of mine(owner)) m[s.id] = { na // source for that site, made from the network catalog template the first time it is needed. Only network templates qualify. const NET_SRC = { iap: 'instantadpay', instantadpay: 'instantadpay', linkspin: 'linkspin', dlb: 'downlinebanners', downlinebanners: 'downlinebanners', vbb: 'viralbannerblitz', viralbannerblitz: 'viralbannerblitz', stackpol: 'stackpol', earnerscorner: 'earnerscorner', - dh: 'downlinehydra', downlinehydra: 'downlinehydra', vab: 'viraladblitz', viraladblitz: 'viraladblitz', vas: 'viraladsource', viraladsource: 'viraladsource', ypb: 'yourprogrambuilder', yourprogrambuilder: 'yourprogrambuilder', fivex: '5xyourteam', '5xyourteam': '5xyourteam' }; + dh: 'downlinehydra', downlinehydra: 'downlinehydra', vab: 'viraladblitz', viraladblitz: 'viraladblitz', vas: 'viraladsource', viraladsource: 'viraladsource', ypb: 'yourprogrambuilder', yourprogrambuilder: 'yourprogrambuilder', fivex: '5xyourteam', '5xyourteam': '5xyourteam', vai: 'videoappincome', videoappincome: 'videoappincome' }; function networkTemplate(src) { const k = NET_SRC[String(src || '').trim().toLowerCase()]; const t = k ? template(k) : null; return t && t.source === 'network' ? t : null; } function networkSource(owner, src) { const t = networkTemplate(src); if (!t || !owner) return null;