Legacy bridge /from/btc4hits: BTC4Hits is now LinkSpin sign-in page (angle b4h, sponsor cookie cleared, forced first-touch source legacy:btc4hits, no welcome-back credits), join.js?v=20261111b4h. qa/btc4hits-bridge.test.mjs 21/21
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
zones: { video: 'zones', eyebrow: 'Your site pays you', h: 'One script tag. <em>Ad credits for every viewable view.</em>', lead: 'A zone is an ad slot on your own site in any of nine sizes. Member campaigns show first, then network ads, then a house banner. Viewable impressions pay you ad credits you spend on your own campaigns.', points: ['Viewable = half the banner on screen for one second. Bots never count.', 'Paid ads only on the site you declared.', 'Credits spend on your own banner or text campaign.'], cta: 'Add a zone, paste the tag', sub: 'free account by email' },
|
||||
audiences: { video: 'audiences', eyebrow: 'Retargeting, built in', h: 'Reach your own visitors <em>again.</em>', lead: 'Everyone who views your pages or your zones is remembered for 30 days in an audience you own. Paste a pixel on any other site you control. Then show a campaign only to them, or never to them.', points: ['My visitors is automatic. Named audiences take one pixel line.', 'Show only to, or never show to, on any banner or text campaign.', 'Honest match: cookie plus a 24-hour fallback, nothing personal stored.'], cta: 'See your audiences', sub: 'free account by email' },
|
||||
stack: { video: 'stack', eyebrow: 'Three tools, zero dollars', h: 'A rotator, a page builder, an ad slot. <em>Free.</em>', lead: 'Join with just an email and the whole stack is yours: spin links, bridge pages and a zone for your site. View a few ads a day and you earn credits for your first campaign. Buy a package only if you want more.', points: ['No wallet, no card, nothing to install.', 'Spin links, pages and zones never need a package.', 'Packages from $10 when you want more reach.'], cta: 'Start with the free stack', sub: 'type your email, get a code, that is the whole signup' },
|
||||
b4h: { eyebrow: 'BTC4Hits is now LinkSpin', h: 'BTC4Hits is now <em>LinkSpin.</em>', lead: 'Your BTC4Hits account came with you. Sign in with the email you used there; an active rotator is already waiting as a LinkSpin spin link.', points: ['Sign in with your BTC4Hits email. We send a code, no password.', 'Active rotator links keep working and now forward through LinkSpin.', 'New here? The same box makes you a free account.'], cta: 'Sign in with your email', sub: 'same email as BTC4Hits, we send you a code', ctaBtn: 'Sign in with your BTC4Hits email' },
|
||||
adspend: { eyebrow: 'For marketers who buy traffic', h: 'You were buying <em>ads anyway.</em>', lead: 'Every ad dollar you ever spent went one direction: out. Here the ad spend in your line pays you, in the same transaction, on a public ledger. Banner, text and login ads, packages from $10.', points: ['Views are timed on the server, so a real person saw your ad.', 'Your ads run in the viewer, on member sites and across the partner network.', 'Rotate the pages you promote with one spin link, free.'], cta: 'Put your next ad dollar where it pays you back', sub: 'free account by email, see every rate before you buy' }
|
||||
};
|
||||
const v = (new URLSearchParams(location.search).get('v') || (document.cookie.match(/(?:^|; )iap\.angle=([^;]+)/) || [])[1] || '').toLowerCase();
|
||||
@@ -28,7 +29,7 @@
|
||||
$('jnPoints').innerHTML = a.points.map(t => '<li>' + esc(t) + '</li>').join(''); $('jnPoints').hidden = false;
|
||||
// the hook video (16:9 cut on Spaces) + a call to action that jumps to the email box
|
||||
if (a.video) { const VID = 'https://coolify-saasytop.nyc3.digitaloceanspaces.com/linkspin/promo/'; const v = $('jnVideo'); v.src = VID + a.video + '.mp4'; v.poster = VID + a.video + '.jpg'; $('jnVideoWrap').hidden = false; }
|
||||
$('jnCtaRow').hidden = false;
|
||||
$('jnCtaRow').hidden = false; if (a.ctaBtn) $('jnCta').textContent = a.ctaBtn;
|
||||
$('jnCta').addEventListener('click', e => { e.preventDefault(); const em = $('jnEmail'); em.scrollIntoView({ behavior: 'smooth', block: 'center' }); setTimeout(() => em.focus(), 450); });
|
||||
}
|
||||
// ?name=First personalises the page (site-owner links): letters, spaces, hyphens, apostrophes only, 30 chars
|
||||
|
||||
+1
-1
@@ -107,6 +107,6 @@ body.squeeze .card{position:sticky;top:16px}
|
||||
</div>
|
||||
</footer>
|
||||
<script src="/assets/common.js?v=20261107tg"></script>
|
||||
<script src="/assets/join.js?v=20261107nc"></script>
|
||||
<script src="/assets/join.js?v=20261111b4h"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
// BTC4Hits bridge + admin spin links (2026-11-11). Boots a throwaway LinkSpin (temp DATA_DIR, JSON stores, no mail key,
|
||||
// ADMIN_PASSWORD=localtest) and checks:
|
||||
// /from/btc4hits: 200, the sponsor cookie is cleared, angle b4h + forced first-touch source legacy:btc4hits, sign-in copy,
|
||||
// no em dash in the copy; a sign-up through it gets NO welcome-back credits (legacy grant rule is fw/t1 only)
|
||||
// /api/admin/rotations: POST with urls[] makes one spin link with every destination at weight 1, GET lists links + sources,
|
||||
// DELETE removes it; auth required.
|
||||
// node qa/btc4hits-bridge.test.mjs (B4H_PORT to move the port)
|
||||
import { spawn } from 'node:child_process';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
const SITE = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const PORT = Number(process.env.B4H_PORT || 8831), BASE = 'http://127.0.0.1:' + PORT;
|
||||
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||||
let pass = 0, fail = 0; const ok = (c, n, x) => { if (c) { pass++; console.log('ok ' + n); } else { fail++; console.log('FAIL ' + n + (x ? '\n ' + x : '')); } };
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'b4h-ls-')); fs.mkdirSync(path.join(dir, 'uploads'), { recursive: true });
|
||||
const now = Date.now();
|
||||
fs.writeFileSync(path.join(dir, 'accounts.json'), JSON.stringify({ v: 2, byEmail: { 'owner@qa.test': { email: 'owner@qa.test', pass: null, sponsorRef: '', code: 'cowner1', username: 'owner', address: null, created: now - 86400000, joinedVia: 'carried', joinedRef: 'network' } }, byAddress: {}, byCode: { cowner1: 'owner@qa.test' }, joins: 0, positions: {} }));
|
||||
const env = Object.assign({}, process.env, { PORT: String(PORT), DATA_DIR: dir, ADMIN_EMAIL: 'admin@qa.test', ADMIN_PASSWORD: 'localtest', DATABASE_URL: '', SENDGRID_API_KEY: '', SENDGRID_KEY: '', OUTBOUND: '', LS_SYNC_SECRET: '', ENGINE_KEY: '', ENGINE_KEY_FILE: '' });
|
||||
const log = path.join(dir, 'server.log');
|
||||
const proc = spawn(process.execPath, ['server.js'], { cwd: SITE, env, stdio: ['ignore', fs.openSync(log, 'w'), fs.openSync(log, 'a')] });
|
||||
const admin = (pth, method, body, auth = true) => fetch(BASE + pth, { method, headers: Object.assign({ 'Content-Type': 'application/json' }, auth ? { Authorization: 'Bearer localtest' } : {}), body: body ? JSON.stringify(body) : undefined });
|
||||
try {
|
||||
let up = false; for (let i = 0; i < 40 && !up; i++) { try { up = (await fetch(BASE + '/api/config', { signal: AbortSignal.timeout(2000) })).status < 500; } catch (e) { await sleep(1000); } }
|
||||
ok(up, 'local LinkSpin up');
|
||||
// 1. the bridge page
|
||||
const r = await fetch(BASE + '/from/btc4hits?src=splash', { headers: { Cookie: 'iap.sponsor=someone' } });
|
||||
const html = await r.text(); const ck = r.headers.getSetCookie ? r.headers.getSetCookie() : [];
|
||||
ok(r.status === 200, '/from/btc4hits answers 200', String(r.status));
|
||||
ok(ck.some(c => /^iap\.sponsor=;/.test(c) && /Max-Age=0/.test(c)), 'sponsor cookie cleared (no sponsor from the bridge itself)', ck.join(' | '));
|
||||
ok(ck.some(c => /^iap\.angle=b4h;/.test(c)), 'angle b4h remembered');
|
||||
ok(ck.some(c => c.startsWith('iap.ref=' + encodeURIComponent('legacy:btc4hits:splash') + ';')), 'forced first-touch source legacy:btc4hits', ck.join(' | '));
|
||||
ok(/<title>BTC4Hits is now LinkSpin\. \| LinkSpin<\/title>/.test(html) && html.includes('class="squeeze"'), 'title + squeeze layout');
|
||||
ok(html.includes('join.js?v=20261111b4h'), 'join.js version bumped');
|
||||
const js = fs.readFileSync(path.join(SITE, 'public', 'assets', 'join.js'), 'utf8'); const b4h = (js.match(/\n\s+b4h: \{[^\n]+/) || [''])[0];
|
||||
ok(b4h.includes('Sign in with your BTC4Hits email') && b4h.includes("cta: 'Sign in with your email'"), 'sign-in call to action in the b4h copy');
|
||||
ok(!/—/.test(b4h) && !/—/.test(html.match(/<title>[^<]*/)[0]), 'no em dash in the copy');
|
||||
// a brand-new sign-up arriving through the bridge: no welcome-back credits
|
||||
const st = await (await fetch(BASE + '/api/auth/email/start', { method: 'POST', headers: { 'Content-Type': 'application/json', Cookie: 'iap.angle=b4h; iap.ref=legacy%3Abtc4hits' }, body: JSON.stringify({ email: 'newb4h@qa.test', fts: Date.now() - 8000 }) })).json();
|
||||
if (st.devCode) {
|
||||
const v = await fetch(BASE + '/api/auth/email/verify', { method: 'POST', headers: { 'Content-Type': 'application/json', Cookie: 'iap.angle=b4h; iap.ref=legacy%3Abtc4hits' }, body: JSON.stringify({ email: 'newb4h@qa.test', code: st.devCode }) });
|
||||
ok(v.status === 200, 'sign-up through the bridge works', String(v.status));
|
||||
await sleep(300);
|
||||
ok(!fs.existsSync(path.join(dir, 'legacy-grants.json')) && !/legacy grant/.test(fs.readFileSync(log, 'utf8')), 'no welcome-back credits granted');
|
||||
const a = JSON.parse(fs.readFileSync(path.join(dir, 'accounts.json'), 'utf8')).byEmail['newb4h@qa.test'];
|
||||
ok(a && a.joinedVia === 'b4h' && a.joinedRef === 'legacy:btc4hits', 'account records angle b4h + source legacy:btc4hits', JSON.stringify(a && { v: a.joinedVia, r: a.joinedRef }));
|
||||
} else ok(false, 'dev sign-in code available', JSON.stringify(st));
|
||||
// 2. admin spin links
|
||||
ok((await admin('/api/admin/rotations?email=owner@qa.test', 'GET', null, false)).status === 401, 'GET needs admin');
|
||||
const urls = ['https://example.com/a', 'https://example.org/b', 'example.net/c'].map(u => ({ url: u, label: 'x' }));
|
||||
const p = await (await admin('/api/admin/rotations', 'POST', { email: 'owner@qa.test', source: { name: 'BTC4Hits', site: 'btc4hits.com' }, links: [{ name: 'BTC4Hits rotator #7', url: urls[0].url, fallback: urls[0].url, urls }] })).json();
|
||||
ok(p.ok && p.links[0].dests === 3 && p.links[0].code, 'POST makes one link with 3 destinations', JSON.stringify(p));
|
||||
const g = await (await admin('/api/admin/rotations?email=owner@qa.test', 'GET')).json();
|
||||
const rot = (g.rotations || []).find(x => x.name === 'BTC4Hits rotator #7');
|
||||
ok(rot && rot.destinations.length === 3 && rot.destinations.every(d => d.weight === 1 && d.active) && rot.destinations[2].url === 'https://example.net/c', 'GET lists it: 3 active destinations, weight 1, cleaned URLs');
|
||||
ok(rot && rot.sourceId && (g.sources || []).some(s => s.id === rot.sourceId && s.name === 'BTC4Hits'), 'attached to the BTC4Hits source');
|
||||
ok(typeof g.linkBase === 'string' && g.linkBase.endsWith('/r/'), 'linkBase given');
|
||||
const red = await fetch(BASE + '/r/' + rot.code, { redirect: 'manual', headers: { 'User-Agent': 'curl/8' } });
|
||||
ok(red.status >= 301 && red.status <= 308 && urls.some(u => red.headers.get('location').startsWith(u.url.startsWith('http') ? u.url : 'https://' + u.url)), '/r/<code> redirects to one of them', red.status + ' ' + red.headers.get('location'));
|
||||
const d = await admin('/api/admin/rotations?email=owner@qa.test&id=' + rot.id, 'DELETE');
|
||||
ok(d.status === 200, 'DELETE removes it');
|
||||
const g2 = await (await admin('/api/admin/rotations?email=owner@qa.test', 'GET')).json();
|
||||
ok(!(g2.rotations || []).length, 'gone after DELETE');
|
||||
ok((await admin('/api/admin/rotations?email=nobody@qa.test', 'GET')).status === 404, 'unknown member -> 404');
|
||||
} finally { proc.kill(); }
|
||||
console.log('\n' + pass + ' passed, ' + fail + ' failed');
|
||||
process.exit(fail ? 1 : 0);
|
||||
@@ -480,6 +480,7 @@ const JOIN_ANGLES = {
|
||||
'fw-adv': { t: 'Your next ad budget pays you back.', d: 'Faucet Wave closed. LinkSpin was built for the people who bought ads there: packages from $10, banner, text and login ads, every package in your line paid out on Polygon in the same transaction. Welcome-back credits waiting.', url: SITE_URL + '/from/faucetwave?seg=advertiser' },
|
||||
'fw-earn': { t: 'Same daily habit. Real payouts on-chain.', d: 'You viewed ads on Faucet Wave. Here you view ads to earn credits, run your own campaign free, and get paid in POL to your own wallet when your line buys ads. Welcome-back credits waiting.', url: SITE_URL + '/from/faucetwave' },
|
||||
't1-adv': { t: 'Your next ad budget pays you back.', d: 'Tier One Ads closed. LinkSpin was built for the people who bought ads there: packages from $10, banner, text and login ads, every package in your line paid out on Polygon in the same transaction. Welcome-back credits waiting.', url: SITE_URL + '/from/tieroneads?seg=advertiser' },
|
||||
'b4h': { t: 'BTC4Hits is now LinkSpin.', d: 'Your BTC4Hits account came with you. Sign in with the same email; an active rotator is already waiting as a LinkSpin spin link.', url: SITE_URL + '/from/btc4hits' },
|
||||
't1-earn': { t: 'Same daily habit. Real payouts on-chain.', d: 'You viewed ads on Tier One Ads. Here you view ads to earn credits, run your own campaign free, and get paid in POL to your own wallet when your line buys ads. Welcome-back credits waiting.', url: SITE_URL + '/from/tieroneads' },
|
||||
instant: { t: 'Paid before the page reloads.', d: 'A smart contract on Polygon splits every ad package the moment it sells. Same transaction, real wallets, public ledger. Join free by email.' },
|
||||
adspend: { t: 'You were buying ads anyway.', d: 'Here the ad spend in your line pays you, in the same transaction, on a public ledger. Banner, text and login ads, packages from $10. Join free.' },
|
||||
@@ -1587,10 +1588,12 @@ const server = http.createServer(async (req, res) => {
|
||||
// with brand copy, NO sponsor (the sponsor cookie is cleared so they land in the holding
|
||||
// tank for adoption), the angle remembered so the welcome-back grant fires at signup, and
|
||||
// a forced first-touch source so link stats / admin can see the legacy arrivals.
|
||||
m = /^\/from\/(faucetwave|tieroneads)$/.exec(p);
|
||||
// /from/btc4hits (2026-11-11): the closed BTC4Hits rotator site. Its members were imported as waiting accounts, so the
|
||||
// page is mostly a sign-in; angle 'b4h' is outside the fw/t1 grant rule, so no welcome-back credits are ever granted.
|
||||
m = /^\/from\/(faucetwave|tieroneads|btc4hits)$/.exec(p);
|
||||
if (m && (req.method === 'GET' || req.method === 'HEAD')) {
|
||||
const brand = m[1];
|
||||
const key = (brand === 'faucetwave' ? 'fw' : 't1') + (String(u.searchParams.get('seg') || '').toLowerCase().startsWith('adv') ? '-adv' : '-earn');
|
||||
const key = brand === 'btc4hits' ? 'b4h' : (brand === 'faucetwave' ? 'fw' : 't1') + (String(u.searchParams.get('seg') || '').toLowerCase().startsWith('adv') ? '-adv' : '-earn');
|
||||
const cookieTail = `; Path=/; SameSite=Lax; Max-Age=${30 * 24 * 3600}${IS_PROD ? '; Secure' : ''}`;
|
||||
const src = String(u.searchParams.get('src') || '').toLowerCase().replace(/[^a-z0-9.\-]/g, '').slice(0, 40); // e.g. the old domain's splash page
|
||||
const set = ['iap.sponsor=; Path=/; SameSite=Lax; Max-Age=0' + (IS_PROD ? '; Secure' : ''), 'iap.angle=' + key + cookieTail, 'iap.ref=' + encodeURIComponent('legacy:' + brand + (src ? ':' + src : '')) + cookieTail];
|
||||
|
||||
Reference in New Issue
Block a user