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
+2
View File
@@ -59,6 +59,7 @@ function lobby() {
$('lChap').textContent = P.chapter; $('lDrips').textContent = P.bank.toLocaleString(); $('lPol').textContent = f3(BAL.unpaid);
$('lPool').innerHTML = 'POL pool <b>' + f3(POOL.available) + '</b> · today’s cap left <b>' + f3(POOL.capLeft) + '</b> · a chapter drip is <b>' + f3(POOL.dripPol) + '</b>';
$('lIap').href = IAP + '/my'; $('bLevel').href = IAP + '/my#buy'; tip('lTip');
try { if (BAL && BAL.unpaid > 0 && ME && !ME.wallet && !ME.guest && !sessionStorage.getItem('dr.walletnudge')) { sessionStorage.setItem('dr.walletnudge', '1'); toast(f3(BAL.unpaid) + ' POL is waiting. Link a wallet on InstantAdPay to get paid.'); } } catch (e) {}
$('lPerk').hidden = !ME_EXTRA.perk; $('lPerk').textContent = ME_EXTRA.perk || ''; // member perk (2026-10-05)
$('bHangar').textContent = P.freeUpgrades > 0 ? 'Hangar · ' + P.freeUpgrades + ' free' : 'Hangar';
// signed in through the game: these open InstantAdPay already signed in (in-game sign-in pass, 2026-10-03)
@@ -236,6 +237,7 @@ function balance() {
show('ovBal'); api('/api/balance').then(function (b) { BAL = b;
$('bPol').textContent = f3(b.unpaid); var pct = Math.min(100, b.unpaid / b.threshold * 100); $('bProg').style.width = pct + '%';
$('bNote').textContent = 'Pays to your wallet at ' + b.threshold + ' POL. ' + pct.toFixed(0) + '% of the way. Paid so far: ' + f3(b.paidTotal) + ' POL.';
if (b.unpaid > 0 && !(ME && ME.wallet)) { $('bWallet').innerHTML = '<b style="color:#f2b544">' + f3(b.unpaid) + ' POL is waiting.</b> No wallet is linked to your InstantAdPay account yet, so it cannot be paid out. <a href="' + IAP + '/my#wallet" target="_blank" rel="noopener" style="color:#f2b544">Link a wallet</a> (one free signature) and it pays out on the next sweep.'; }
var h = ''; if (!b.history.length) h = '<div class="led"><span>No drips yet. Clear a chapter.</span><span class="m">0.000</span></div>';
b.history.forEach(function (l) { var cls = l.kind === 'payout' ? (l.status === 'paid' ? 'm ok' : l.status === 'failed' ? 'm neg' : 'm') : (l.pol < 0 ? 'm neg' : 'm'); h += '<div class="led"><span>' + esc(l.label) + (l.tx ? ' · <a href="https://polygonscan.com/tx/' + esc(l.tx) + '" target="_blank" rel="noopener">tx</a>' : '') + '</span><span class="' + cls + '">' + (l.kind === 'payout' ? '' : (l.pol < 0 ? '' : '+')) + f3(l.pol) + '</span></div>'; });
$('ledger').innerHTML = h;
+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');