Video App Income as a network site: fixed link nwvai + its traffic source (catalog, ?src=videoappincome), videoappincome.com and clickvidpro.com get the click id, and its own signed conversion route /api/partner/netconv/vai (NETCONV_SECRET_VAI, events keyed vai: only; reporting only). netconv rows carry the reporting site, so a purchase reads Video App Income in Reports (Marty 2026-11-21: loop Video App Income through LinkSpin tracking)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-21 07:17:06 -06:00
parent 61c0ccc48a
commit a6c36aeca1
7 changed files with 50 additions and 8 deletions
+20 -1
View File
@@ -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=<id> 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();