Merge network sign-in (InstantAdPay <-> LinkSpin) into main for the Friday launch (Marty 2026-11-13: 'we need to get that done now'). Conflicts only in script version tags (kept today's newer assets, re-tagged ?v=20261113sso). networksso.test 'ALL PASSED' both repos, networksso.e2e ALL PASSED, iap-qa member ALL PASSED. NETWORK_SSO_SECRET set on both Coolify apps. Chatbot KNOWLEDGE_DATE 2026-11-13.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@ const { URL } = require('url');
|
||||
const chain = require('./chain');
|
||||
const auth = require('./auth');
|
||||
const accounts = require('./accounts');
|
||||
const networksso = require('./networksso'); // network sign-in with InstantAdPay (2026-11-12, Marty approved): see networksso.js
|
||||
const themehead = require('./themehead'); // 2026-11-01 light/dark theme head script for server-rendered pages
|
||||
const ads = require('./ads');
|
||||
const mailer = require('./mailer');
|
||||
@@ -632,6 +633,24 @@ async function boot() {
|
||||
if (ev && ev.type === 'Purchase' && ev.buyerId) accounts.byMemberId(Number(ev.buyerId)).then(a => { if (a) return postbacks.convertFor(a.email, 'purchase', { payout: (Number(ev.priceCents) || 0) / 100, currency: 'USD', txid: ev.tx || '' }); }).catch(() => {});
|
||||
if (ev && ev.type === 'Purchase') refuel.onPurchase(ev).catch(e => console.error('refuel report', e.message)); } }); // no-op while refuelStreak is off
|
||||
auth.init({ dataDir: DATA_DIR, chain, isProd: IS_PROD, site: SITE_HOST });
|
||||
// network sign-in (2026-11-12): a member signed in on InstantAdPay arrives here signed in, and the other way round. Member
|
||||
// sessions only (the admin portal is never shared). An email that is not here yet (the 2-minute sync has not run) or is not
|
||||
// let in (LS_TESTERS) gets the normal email-code sign-in with the email filled in; nothing is created by the network sign-in.
|
||||
networksso.init({ self: 'linkspin', peer: 'iap', peerBase: IAP_BASE, isProd: IS_PROD, dataDir: DATA_DIR, db, defaultPath: '/ads',
|
||||
member: async req => { const s = await auth.fromRequest(req); return s && s.email ? s : null; },
|
||||
accept: async email => {
|
||||
const a = await accounts.byEmail(email);
|
||||
if (!a) return { fallback: 'no account here yet' };
|
||||
if (!isTester(email, a)) return { fallback: 'not on the tester list' };
|
||||
return { ok: true };
|
||||
},
|
||||
signIn: async email => { // the same session the email code makes (4 hours, same rights)
|
||||
const a = await accounts.byEmail(email); let memberId = 0;
|
||||
if (a && a.address) { try { memberId = await chain.memberIdByAccount(a.address); } catch (e) {} }
|
||||
return auth.sessionCookie(await auth.mintSession({ email: a.email, address: a.address || null, memberId }));
|
||||
},
|
||||
landing: to => to,
|
||||
signinPath: to => (to === '/' ? '/ads' : to) }); // every Control Room screen shows the sign-in itself
|
||||
accounts.init({ dataDir: DATA_DIR });
|
||||
ads.init({ dataDir: DATA_DIR, chain });
|
||||
mailer.init({ dataDir: DATA_DIR });
|
||||
@@ -1397,6 +1416,8 @@ const server = http.createServer(async (req, res) => {
|
||||
const zonePath = p === '/z.js' || p === '/z/nas' || p === '/p.js' || p === '/p.gif' || p === '/t.js' || p === '/t.gif' || p === '/cv.gif' || p === '/cv.js' || p.startsWith('/u/pages/') || p.startsWith('/api/zone/') || p.startsWith('/banners/linkspin-') || p.startsWith('/art/house-') || /^\/(i|c|s)\/[a-z0-9]{5,12}(\.gif|\.js)?$/.test(p); // + Banner Spin image / click / script (2026-10-18)
|
||||
// support must reach everyone, invited or not (2026-10-16): someone locked out or not yet let in is exactly who needs it
|
||||
if (!zonePath && !supportOpen(p) && curtained(req, res, u)) return; // nothing below this line runs for an uninvited visitor
|
||||
// network sign-in with InstantAdPay (2026-11-12): /go/iap, /sso/start, /sso/check, /sso/in, /api/sso/status (app host only)
|
||||
if (req.method === 'GET' && (p === '/go/iap' || p.startsWith('/sso/') || p === '/api/sso/status') && !isPagesHost(req) && !isLinkHost(req) && await networksso.handle(req, res, u)) return;
|
||||
|
||||
// -- the rotator redirect: one hop, recorded, on any host (LinkSpin)
|
||||
let rm = /^\/r\/([a-z0-9]{4,12})$/i.exec(p);
|
||||
@@ -2025,7 +2046,7 @@ const server = http.createServer(async (req, res) => {
|
||||
}
|
||||
if (p === '/api/auth/logout' && req.method === 'POST') {
|
||||
await auth.logout(req);
|
||||
return json(res, 200, { ok: true }, { 'Set-Cookie': auth.clearCookie() });
|
||||
return json(res, 200, { ok: true }, { 'Set-Cookie': [auth.clearCookie(), networksso.offCookie()] }); // signed out stays signed out: no silent network sign-in here for 12 hours
|
||||
}
|
||||
if (p === '/api/gas' && req.method === 'GET') {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user