diff --git a/server.js b/server.js index 5e3d414..2353552 100644 --- a/server.js +++ b/server.js @@ -3082,7 +3082,7 @@ const server = http.createServer(async (req, res) => { if (have > 0) { const csrf = pwSign('pass:' + c.order + ':' + String(s.email).toLowerCase()); return gkPage(res, 200, 'Mint your warrior', '

PolyWarriors · Mint to your wallet

' + gkEsc(c.label || ('Warrior #' + c.serial)) + '

' + have + ' mint pass' + (have === 1 ? '' : 'es') + '
' - + '
' + + '
' + 'Cancel and go back

You earned these passes with your package purchases: one mint for every $5. The game pays the network fee.

'); } return gkPage(res, 200, 'Mint your warrior', '

PolyWarriors · Mint to your wallet

' + gkEsc(c.label || ('Warrior #' + c.serial)) + '

Comes with a $5 package
' @@ -3099,7 +3099,10 @@ const server = http.createServer(async (req, res) => { const want = pwSign('pass:' + c.order + ':' + e), got = String(f.get('csrf') || ''); if (want.length !== got.length || !crypto.timingSafeEqual(Buffer.from(want), Buffer.from(got))) return gkPage(res, 403, 'Mint problem', '

That form expired

Try again'); const o = pwOrders.get(c.order); - if (o && o.status === 'waiting' && pwPassN(e) > 0) { pwPassAdd(e, -1, 'mint:' + c.order); pwOrders.set(c.order, Object.assign({}, o, { status: 'paid', tx: 'pass', cents: 500, paidAt: Date.now() })); await pwDeliver(c.order); } + // the redirect goes out at once; the game is told in the background (and the GET below hands the member's own browser the + // receipt too, so the mint never waits on this callback). Marty's phone sat on this form on 2026-10-09 while the mint had + // already gone through. + if (o && o.status === 'waiting' && pwPassN(e) > 0) { pwPassAdd(e, -1, 'mint:' + c.order); pwOrders.set(c.order, Object.assign({}, o, { status: 'paid', tx: 'pass', cents: 500, paidAt: Date.now() })); pwDeliver(c.order).catch(() => {}); } res.writeHead(303, { Location: '/pw/mint?t=' + encodeURIComponent(t), 'Cache-Control': 'no-store' }); return res.end(); } if (p === '/pw/mint/resume' && req.method === 'GET') { const t = parseCookies(req)['iap.pwmint']; res.writeHead(302, { Location: t ? '/pw/mint?t=' + encodeURIComponent(t) : PW_URL() + '/play', 'Cache-Control': 'no-store', 'Set-Cookie': gkCookie('iap.return', '', 0) }); return res.end(); }