From 547c7ba465cbc9861e4456d8ba95964e8e13fc3a Mon Sep 17 00:00:00 2001 From: martbost Date: Thu, 8 Oct 2026 06:16:12 -0500 Subject: [PATCH] Pre-launch whitelist LS_TESTERS: only listed emails/usernames can request or verify a sign-in code; public pages stay visible with the curtain down (Marty 2026-10-08) Co-Authored-By: Claude Fable 5.1 --- server.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index f9fc86e..6e84efe 100644 --- a/server.js +++ b/server.js @@ -89,6 +89,11 @@ const IS_PROD = process.env.NODE_ENV === 'production'; const OUTBOUND_MAIL = process.env.OUTBOUND === 'on'; const SIGNUPS_OPEN = process.env.SIGNUPS !== 'closed'; const SHUT = { error: 'LinkSpin is not accepting new accounts right now.' }; +// pre-launch whitelist (Marty 2026-10-08: public pages visible, nobody signs in unless whitelisted): LS_TESTERS = comma list of +// emails or usernames; empty = everyone with an account may sign in +const TESTERS = new Set(String(process.env.LS_TESTERS || '').split(',').map(x => x.trim().toLowerCase()).filter(Boolean)); +const TESTING = { error: 'LinkSpin is in testing. Members get in on launch day.' }; +const isTester = (email, acct) => !TESTERS.size || TESTERS.has(String(email || '').toLowerCase()) || TESTERS.has(String((acct && acct.username) || '').toLowerCase()); const SITE_FILE = path.join(DATA_DIR, 'site.json'); const db = require('./db'); @@ -1178,7 +1183,9 @@ const server = http.createServer(async (req, res) => { const e = String(b.email || '').trim().toLowerCase(); if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(e)) return json(res, 400, { error: 'That email address does not look right.' }); // closed sign-ups shut the door to NEW accounts only; members already here (incl. imported shells) still get their code - if (!SIGNUPS_OPEN && !(await accounts.byEmail(e))) return json(res, 403, SHUT); + const acct0 = await accounts.byEmail(e); + if (!SIGNUPS_OPEN && !acct0) return json(res, 403, SHUT); + if (!isTester(e, acct0)) return json(res, 403, TESTING); const prev = emailCodes.get(e); if (prev && Date.now() < prev.nextAt) { console.log('signup-guard cooldown', clientIp(req), e.replace(/^(.).*(@.*)$/, '$1***$2')); return json(res, 429, { error: 'Code already sent. Give it a minute, then try again.' }); } const guard = codeGuard(req, b); // honeypot, form age, per-IP + global limits, icon check once limited @@ -1209,6 +1216,7 @@ const server = http.createServer(async (req, res) => { const joinedRef = decodeURIComponent(parseCookies(req)['iap.ref'] || '') || null; // the code door creates an account on first use, so it is a sign-up door too if (!SIGNUPS_OPEN && !(await accounts.byEmail(e))) return json(res, 403, SHUT); + if (!isTester(e, await accounts.byEmail(e))) return json(res, 403, TESTING); const r = await accounts.ensure(e, ref, via, joinedRef); // first touch wins; existing accounts unchanged if (r.error) return json(res, 400, r); if (r.created) carry.onJoin(r.account, !!ref).catch(() => {}); // network sponsor carries over when no link was used (LinkSpin)