"Use one of my spin links" on the text-ad form (Marty 2026-11-15): a member picks one of their own LinkSpin spin links as the ad link, so one free ad rotates clicks across every page they promote. Listed live from LinkSpin (GET /api/my/spins -> lstrack.spins, /api/partner/vab/links op 'spins'). A LinkSpin /r/<code> link on any LinkSpin host is accepted ONLY when LinkSpin confirms it is the signed-in member's own (lstrack.checkSpin): someone else's, a paused one, one with no active pages, or any while LinkSpin is not answering is refused; the network's fixed nw* links and /r/ links on other sites stay ordinary links; other shortener rules unchanged. A spin-link ad (ad.spin) never gets the "Track with LinkSpin" wrapper: /go/<ad> sends straight to the spin link, the checkbox is greyed with a note. LinkSpin hosts learned from every spins answer (warmed hourly by the sweep). Chatbot: CANNED spin-link + FACTS. my.js?v=7. Smoke 217 pass (14b2: foreign refused, own accepted), chatbot 206 pass

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-15 14:37:18 -06:00
parent 8630c9aa9a
commit 4dd1e5a07f
6 changed files with 130 additions and 14 deletions
+33 -1
View File
@@ -109,14 +109,17 @@ const TG = []; const TG_PORT = PORT + 4;
listen(TG_PORT, async (q, r, b) => { TG.push({ method: q.url.split('/').pop(), token: q.url.split('/')[1], body: JSON.parse(b || '{}') }); r.setHeader('Content-Type', 'application/json'); r.end('{"ok":true,"result":{}}'); });
// ---- stand-in LinkSpin partner endpoint /api/partner/vab/links (net.v1 signature). Starts DOWN (404, as before LinkSpin ships it). ----
const LS = { up: false, calls: [], badSig: 0, links: new Map(), known: new Set(['one', 'owner', 'four', 'five', 'six', 'seven', 'topdog', 'downline']), stats: {} }; const LS_PORT = PORT + 5;
const LS = { up: false, calls: [], badSig: 0, links: new Map(), known: new Set(['one', 'owner', 'four', 'five', 'six', 'seven', 'topdog', 'downline']), stats: {}, spins: { one: [{ code: 'onespin1', name: 'My three offers', destinations: 3, paused: false }, { code: 'onepaus1', name: 'Resting', destinations: 1, paused: true }, { code: 'oneempt1', name: 'Empty', destinations: 0, paused: false }], owner: [{ code: 'ownspin1', name: 'Owner rotator', destinations: 2, paused: false }] } }; const LS_PORT = PORT + 5;
listen(LS_PORT, async (q, r, b) => {
r.setHeader('Content-Type', 'application/json');
if (!LS.up || q.url !== '/api/partner/vab/links') { r.statusCode = 404; return r.end('{"error":"Not found"}'); }
const want = crypto.createHmac('sha256', SSO_SECRET).update('net.v1.' + q.headers['x-net-ts'] + '\n' + b).digest('hex');
if (q.headers['x-net-sig'] !== want) { LS.badSig++; r.statusCode = 401; return r.end('{"error":"unauthorized"}'); }
const j = JSON.parse(b || '{}'); LS.calls.push(j);
const SPIN_HOSTS = ['linkspin.app', 'qa-spin.net', 'qa-spare.net'];
if (j.op === 'spins' && !LS.known.has(String(j.username || '').toLowerCase())) return r.end(JSON.stringify({ account: false, hosts: SPIN_HOSTS }));
if (!LS.known.has(String(j.username || '').toLowerCase())) return r.end('{"account":false}');
if (j.op === 'spins') return r.end(JSON.stringify({ account: true, username: j.username, host: 'qa-spin.net', hosts: SPIN_HOSTS, spins: (LS.spins[j.username] || []).map(x => Object.assign({ url: 'https://qa-spin.net/r/' + x.code }, x)) }));
if (j.op === 'stats') return r.end(JSON.stringify({ account: true, stats: LS.stats[j.username] || {} }));
const links = {};
for (const x of j.links || []) { const k = j.username + ':' + x.id; let l = LS.links.get(k); if (!l) { l = { code: crypto.randomBytes(3).toString('hex'), url: x.url }; LS.links.set(k, l); } l.url = x.url; links[x.id] = { code: l.code, link: 'https://spin.test/r/' + l.code + '?s1=' + x.id + '&placement=' + x.id, created: false }; }
@@ -446,6 +449,35 @@ const mtop = await anon.json('/api/wire?page=member&u=topdog');
ok(q2.ok && q2.linkspin === 'no-account' && m2.linkspin.state === 'no-account', 'no LinkSpin account for the username: the ad works with its own link', m2.linkspin); }
{ const s2 = await anon.json('/api/admin/status', undefined, { 'x-admin-token': ADMIN }); ok(s2.linkspin && s2.linkspin.on === true && s2.linkspin.ensured >= 3 && s2.linkspin.failed >= 1 && !JSON.stringify(s2.linkspin).includes(SSO_SECRET), 'admin status: LinkSpin tracking counters, no secret', s2.linkspin); }
console.log('14b2. "Use one of my spin links" (the own LinkSpin spin link as the ad link)');
{ let sp = await M1.json('/api/my/spins');
ok(sp._status === 200 && sp.account === true && sp.spins.map(x => x.code).join(',') === 'onespin1,onepaus1,oneempt1' && sp.spins[0].url === 'https://qa-spin.net/r/onespin1' && sp.spins[0].destinations === 3 && sp.spins[1].paused === true, "the picker lists the member's own spin links from LinkSpin", sp);
const sc = LS.calls.filter(c => c.op === 'spins' && c.username === 'one'); ok(sc.length >= 1 && !sc.some(c => c.email) && LS.badSig === 0, 'the spins call: signed net.v1, network username only', sc.slice(-1));
sp = await STR.json('/api/my/spins'); ok(sp._status === 403 && !sp.spins, 'a non-member gets no spin list', sp);
pa = await M1.json('/api/my/ad', adBody(1, { link: 'https://qa-spin.net/r/ownspin1' })); ok(pa._status === 400 && /not one of yours/.test(pa.error), "someone else's spin link is refused", pa);
pa = await M1.json('/api/my/ad', adBody(1, { link: 'https://linkspin.app/r/ownspin1' })); ok(pa._status === 400 && /not one of yours/.test(pa.error), "someone else's spin link on the main LinkSpin host is refused too", pa);
pa = await M1.json('/api/my/ad', adBody(1, { link: 'https://qa-spare.net/r/zzzzzz9' })); ok(pa._status === 400 && /not one of yours/.test(pa.error), 'an unknown code on another LinkSpin link host is refused', pa);
pa = await M1.json('/api/my/ad', adBody(1, { link: 'https://qa-spin.net/r/onepaus1' })); ok(pa._status === 400 && /paused/.test(pa.error), "the member's own paused spin link is refused", pa);
pa = await M1.json('/api/my/ad', adBody(1, { link: 'https://qa-spin.net/r/oneempt1' })); ok(pa._status === 400 && /no active pages/.test(pa.error), 'a spin link with no active pages is refused', pa);
my = await M1.json('/api/my'); ok(my.ad.link === 'https://member-1.example-shop.com/third' && my.ad.spin === false, 'a refused spin link leaves the ad as it was', my.ad);
const ownBy = await OWN.json('/api/my/ad', adBody('own', { link: 'https://qa-spin.net/r/onespin1' })); ok(ownBy._status === 400 && /not one of yours/.test(ownBy.error), "the other way round: member one's link is refused for the owner", ownBy);
const n1 = LS.calls.length;
pa = await M1.json('/api/my/ad', adBody(1, { link: 'https://qa-spin.net/r/onespin1', track: true }));
r = await anon.req('/go/' + ad1 + '?p=ticker'); my = await M1.json('/api/my');
ok(pa.ok && pa.linkspin === 'spin' && my.ad.spin === true && my.ad.link === 'https://qa-spin.net/r/onespin1' && my.linkspin.state === 'spin', "the member's own spin link is accepted (LinkSpin confirmed it)", [pa, my.ad, my.linkspin]);
ok(r.status === 302 && r.headers.get('location') === 'https://qa-spin.net/r/onespin1', '/go/<ad> sends straight to the spin link, no tracked-link wrapper', r.headers.get('location'));
await sleep(900); ok(!LS.calls.slice(n1).some(c => c.op === 'ensure' && c.username === 'one'), 'no tracked link is made for a spin-link ad (the sweep leaves it alone)', LS.calls.slice(n1).map(c => c.op));
pa = await M1.json('/api/my/ad', adBody(1, { link: 'https://linkspin.app/r/nwiap?s1=one' })); ok(pa.ok && pa.linkspin !== 'spin', "the network's own fixed LinkSpin links stay allowed as before", pa);
pa = await M1.json('/api/my/ad', adBody(1, { link: 'https://member-1.example-shop.com/r/abcd12' })); ok(pa.ok && pa.linkspin !== 'spin', 'a /r/ link on any other site is an ordinary link', pa);
LS.up = false;
pa = await M1.json('/api/my/ad', adBody(1, { link: 'https://qa-spin.net/r/onespin1' })); ok(pa._status === 400 && /could not confirm/.test(pa.error), 'LinkSpin not answering: a spin link cannot be confirmed, so it is refused', pa);
sp = await M1.json('/api/my/spins'); ok(sp._status === 502 && /LinkSpin/.test(sp.error), 'LinkSpin not answering: the picker says so', sp);
LS.up = true;
pa = await M1.json('/api/my/ad', adBody(1, { link: 'https://member-1.example-shop.com/third', track: true }));
my = await M1.json('/api/my'); ok(pa.ok && pa.linkspin === 'tracked' && my.ad.spin === false && my.linkspin.state === 'tracked', 'back to an ordinary link: tracked with LinkSpin again', [pa, my.linkspin]);
const h = await (await anon.req('/my')).text(); const js = await (await anon.req('/assets/my.js?v=7')).text();
ok(/id="spinBtn"[^>]*>Use one of my spin links</.test(h) && /id="trackNote"/.test(h) && /my\.js\?v=7/.test(h) && /\/api\/my\/spins/.test(js), 'the ad form has "Use one of my spin links" and the tracking note'); }
console.log('14c. PolHunter mission (front page, How it works)');
{ const hr = await anon.req('/'); const hh = await hr.text(); const csp = hr.headers.get('content-security-policy') || '';
ok(/<script src="https:\/\/polhunter\.com\/embed\.js" data-slots="3" data-selector="\.steps \.step" async><\/script>/.test(hh) && (hh.match(/class="step"/g) || []).length === 3, 'front page carries the PolHunter embed on the 3 How it works steps');