Signed /api/iap/unpaid feed for InstantAdPay's wallet-link nudges; balance screen and a one-time toast tell a player with POL waiting and no wallet how to get paid

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-07 10:35:15 -05:00
parent 3aa5698c8a
commit 7c2d6b7467
2 changed files with 13 additions and 0 deletions
+11
View File
@@ -164,6 +164,17 @@ async function creditRefuel(intent, nonce, info) {
// ---- server ------------------------------------------------------------------------------------
const server = http.createServer(async (req, res) => {
const u = new URL(req.url, 'http://x'); const p = u.pathname;
// InstantAdPay asks every hour which players have POL waiting and no wallet linked (wallet-link nudges,
// 2026-10-07). GET /api/iap/unpaid?ts=<ms>&sig=<hex HMAC-SHA256(shared secret, 'unpaid\n' + ts)>, 10-minute window.
if (p === '/api/iap/unpaid' && req.method === 'GET') {
const ts = String(u.searchParams.get('ts') || ''), sig = String(u.searchParams.get('sig') || '');
const sec = SECRET;
if (!sec || sec.length < 32 || !ts || Math.abs(Date.now() - Number(ts)) > 10 * 60000) return json(res, 401, { error: 'bad signature' });
const want = crypto.createHmac('sha256', sec).update('unpaid\n' + ts).digest('hex');
if (want.length !== sig.length || !crypto.timingSafeEqual(Buffer.from(want), Buffer.from(sig))) return json(res, 401, { error: 'bad signature' });
const accts = store.read('accounts', {}), players = store.read('players', {}); const rows = Object.entries(accts).filter(([k, a]) => Number(a.unpaid) > 0 && !a.wallet).map(([k, a]) => ({ memberId: Number(k), username: a.username || (players[k] || {}).username || null, email: (players[k] || {}).email || null, unpaid: Number(Number(a.unpaid).toFixed(4)) }));
return json(res, 200, { ok: true, game: 'driprunner', rows });
}
// frames (2026-10-03): public pages show inside traffic exchanges; admin and the sign-in hand-offs never do. A framed
// visit to the game itself lands on the landing page, whose buttons open the game in a new tab (cookies die in frames)
if (/^\/(admin|auth|signin|logout)(\/|$)/.test(p) || p.startsWith('/api/admin')) res.setHeader('X-Frame-Options', 'DENY');