Dashboard: wallet funded status only for the verified owner

Manson via Marty: do not show whether a position's wallet can cover its next
upgrade to anyone but that position's owner. The member endpoint strips
nextStep.funded unless the request carries a verified session (owning-wallet
signature or verified Telegram app) for that exact ID; owner responses are
private, no-store so the shared cache never serves them to anyone else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-26 09:03:24 -05:00
parent ed78aeb4a1
commit 687ecb7eb6
+11 -2
View File
@@ -700,6 +700,15 @@ async function handleApi(req,res,pathname){
res.writeHead(200,{'Content-Type':'text/calendar; charset=utf-8','Content-Disposition':(inline?'inline':'attachment')+'; filename="rm-circle-huddle.ics"','Cache-Control':'no-store'});
return res.end(ics);
}
// Wallet funding status is only for the position's own verified owner (Manson/Marty 2026-09-26):
// anyone else viewing /my/<id> gets the dashboard without the funded / not-funded badge.
// "Verified" = a session minted by signing with the owning wallet or via the verified Telegram app.
function memberView(req,id,data){
const s=messages.authFromCookie(req);
const owner=!!(s&&Number(s.id)===Number(id));
if(owner||!data||!data.nextStep||data.nextStep.funded==null)return {data,owner};
return {data:Object.assign({},data,{nextStep:Object.assign({},data.nextStep,{funded:null})}),owner};
}
if(req.method==='GET'&&pathname==='/api/public/member'){
const ip=String(req.headers['x-forwarded-for']||req.socket.remoteAddress||'').split(',')[0].trim();
if(memberLookupLimited(ip))return json(res,429,{error:'Too many lookups — give it a minute.'});
@@ -709,7 +718,7 @@ async function handleApi(req,res,pathname){
const cached=memberCache.get(id);
// fresh=1: the caller just completed their own transaction — bypass the
// cache once so the dashboard reflects it immediately
if(q0.get('fresh')!=='1'&&cached&&Date.now()-cached.ts<120000)return json(res,200,cached.data,{'Cache-Control':'public, max-age=15'});
if(q0.get('fresh')!=='1'&&cached&&Date.now()-cached.ts<120000){const v=memberView(req,id,cached.data);return json(res,200,v.data,{'Cache-Control':v.owner?'private, no-store':'public, max-age=15'});}
try{
const r=await Promise.race([chain.memberPublic(id),new Promise((_,rej)=>setTimeout(()=>rej(new Error('Blockchain lookup timed out — try again.')),20000))]);
if(r.registered)r.referralUrl=`${getConfig().dappReferralBaseUrl}${encodeURIComponent(id)}`;
@@ -791,7 +800,7 @@ async function handleApi(req,res,pathname){
const usd=await getPolUsd(); if(usd>0){r.polUsd=usd;r.polUsdAt=polPrice.at;}
memberCache.set(id,{data:r,ts:Date.now()});
if(memberCache.size>500)memberCache.delete(memberCache.keys().next().value);
return json(res,200,r,{'Cache-Control':'public, max-age=60'});
{const v=memberView(req,id,r);return json(res,200,v.data,{'Cache-Control':v.owner?'private, no-store':'public, max-age=60'});}
}catch(e){return json(res,502,{error:e.message||'Lookup failed'})}
}
if(req.method==='GET'&&pathname==='/api/public/payouts'){