Podcast Commission Stack as a network site (2026-11-25): fixed link nwpcs, traffic source podcastcommissionstack, conversions at /api/partner/netconv/pcs (NETCONV_SECRET_PCS, events keyed pcs:), its hosts carry the click id

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-25 11:42:18 -06:00
parent 75569ed55c
commit a4ce9ff4cd
7 changed files with 32 additions and 10 deletions
+5 -4
View File
@@ -1009,7 +1009,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,videoappincome.com,clickvidpro.com,socialtube.club').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,socialtube.club,podcastcommissionstack.com,lstn.page').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
@@ -3401,8 +3401,9 @@ const server = http.createServer(async (req, res) => {
// -- 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' });
// second site 2026-11-25: Podcast Commission Stack at /api/partner/netconv/pcs with NETCONV_SECRET_PCS; its events are keyed pcs:...
if ((p === '/api/partner/netconv/vai' || p === '/api/partner/netconv/pcs') && req.method === 'POST') {
const nsite = p.slice(-3); const secret = String(process.env['NETCONV_SECRET_' + nsite.toUpperCase()] || '').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' });
@@ -3412,7 +3413,7 @@ const server = http.createServer(async (req, res) => {
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' }); } }
if (ev && String(ev.k || '').startsWith(nsite + ':')) { try { r = await netconv.record(Object.assign({}, ev, { site: nsite })); } catch (e) { console.error('netconv ' + nsite, 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 });