Forum reward lookup (Marty 2026-11-10: 1 POL for an introduction, ongoing, linked wallet + payouts on): GET /api/forum/member?email= signed with the forum secret (HMAC of email.ts, 5-minute window) returns found/username/activated (member id > 0)/address/suspended for the earnerscorner.com reward service. qa/forumsso 17/17.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-10 09:22:27 -06:00
parent 52eaa20171
commit 0013416af7
3 changed files with 26 additions and 1 deletions
+11 -1
View File
@@ -41,4 +41,14 @@ function redirectFor(v, acct, site) {
return v.returnUrl + (v.returnUrl.includes('?') ? '&' : '?') + 'sso=' + encodeURIComponent(out) + '&sig=' + sign(out);
}
module.exports = { verify, redirectFor, sign, SECRET, FORUM_URL };
// server-to-server: the forum's reward service asks "is this email an activated member, and where are payouts sent?" The request is
// signed with the same shared secret: header x-forum-sig = hex HMAC-SHA256 of "<email>.<unix seconds>", x-forum-ts = those seconds,
// valid for 5 minutes.
function verifyServer(email, ts, sig) {
if (SECRET().length < 32) return false;
const t = Number(ts); if (!(t > 0) || Math.abs(Date.now() / 1000 - t) > 300) return false;
const want = Buffer.from(sign(String(email || '').toLowerCase() + '.' + t), 'hex'), got = Buffer.from(String(sig || ''), 'hex');
return want.length === got.length && crypto.timingSafeEqual(want, got);
}
module.exports = { verify, verifyServer, redirectFor, sign, SECRET, FORUM_URL };
+6
View File
@@ -66,6 +66,12 @@ try {
const nck = (nv.headers.getSetCookie ? nv.headers.getSetCookie() : []).map(c => c.split(';')[0]).join('; ');
const nme = await api('/api/me', null, { Cookie: nck + '; iap.sponsor=forumfan' });
ok(nme.j && (nme.j.sponsorName === '@forumfan' || String(nme.j.sponsorRef || '').toLowerCase() === 'forumfan' || JSON.stringify(nme.j).includes('forumfan')), 'a new sign-up through the forum invite lands under the inviter', JSON.stringify(nme.j && { sponsorName: nme.j.sponsorName, sponsorRef: nme.j.sponsorRef }));
// reward-service lookup (2026-11-10)
const ts = Math.floor(Date.now() / 1000), msig = sig('fs-a@example.com.' + ts);
let lk = await fetch(B + '/api/forum/member?email=fs-a%40example.com', { headers: { 'x-forum-ts': String(ts), 'x-forum-sig': msig } }); let lj = await lk.json();
ok(lk.status === 200 && lj.found === true && lj.username === 'forumfan' && lj.activated === false, 'member lookup: signed request answers (free member = not activated)', JSON.stringify(lj));
lk = await fetch(B + '/api/forum/member?email=fs-a%40example.com', { headers: { 'x-forum-ts': String(ts), 'x-forum-sig': '0'.repeat(64) } }); ok(lk.status === 401, 'member lookup: bad signature refused');
const old = ts - 900; lk = await fetch(B + '/api/forum/member?email=fs-a%40example.com', { headers: { 'x-forum-ts': String(old), 'x-forum-sig': sig('fs-a@example.com.' + old) } }); ok(lk.status === 401, 'member lookup: stale signature refused');
} catch (e) { console.log('FAIL exception', e && e.stack || e); fails++; }
finally { try { srv.kill(); } catch (e) {} try { fs.rmSync(DATA, { recursive: true, force: true }); } catch (e) {} }
if (fails) console.log(log.split('\n').filter(l => /forum|error/i.test(l)).slice(-15).join('\n'));
+9
View File
@@ -3952,6 +3952,15 @@ const server = http.createServer(async (req, res) => {
}
res.writeHead(302, baseHeaders(Object.assign({ Location: forumsso.FORUM_URL() + path, 'Cache-Control': 'no-store' }, set.length ? { 'Set-Cookie': set } : {}))); return res.end();
}
// Earners Corner introduction reward (Marty 2026-11-10: 0.1 POL, ongoing, linked wallet + payouts switched on): the forum's reward
// service looks a member up here. Activated = an on-chain member id (the $20 start with payouts on); the address is the payout wallet.
if (p === '/api/forum/member' && req.method === 'GET') {
const email = String(u.searchParams.get('email') || '').toLowerCase();
if (!forumsso.verifyServer(email, req.headers['x-forum-ts'], req.headers['x-forum-sig'])) return json(res, 401, { error: 'auth' });
const a = await accounts.byEmail(email);
if (!a) return json(res, 200, { found: false });
return json(res, 200, { found: true, username: a.username || null, activated: Number(a.memberId) > 0, address: a.address || null, suspended: !!fraud.isSuspended(email) });
}
if (p === '/forum/invite' && req.method === 'GET') {
const s = await auth.fromRequest(req);
if (!s || !s.email) { res.writeHead(302, { Location: forumsso.FORUM_URL() + '/session/sso', 'Cache-Control': 'no-store' }); return res.end(); }