PolyWarriors pass mint: visible 'Minting now' hand-back page with a Back to PolyWarriors button and a 2 s auto-return (a silent redirect chain left Zachary's iPad on the mint form)
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -1327,9 +1327,9 @@ function gkOpen(token) {
|
||||
}
|
||||
const gkOrders = persistedMap('gkorders'); // order -> { status: 'paying'|'paid', email, campaignId, ts }
|
||||
const gkEsc = s => String(s == null ? '' : s).replace(/[&<>"]/g, ch => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[ch]));
|
||||
function gkPage(res, code, title, inner) {
|
||||
function gkPage(res, code, title, inner, head) {
|
||||
res.writeHead(code, baseHeaders({ 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-store' }));
|
||||
res.end('<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>' + gkEsc(title) + ' | InstantAdPay</title>'
|
||||
res.end('<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>' + gkEsc(title) + ' | InstantAdPay</title>' + (head || '')
|
||||
+ '<style>body{margin:0;background:radial-gradient(ellipse 80% 50% at 50% 0%,#3B1E6E,#1B1026 70%);color:#3B1A0A;font:16px/1.5 system-ui,-apple-system,Segoe UI,sans-serif;min-height:100vh;display:grid;place-items:center;padding:24px 16px;box-sizing:border-box}'
|
||||
+ '.card{width:100%;max-width:440px;background:linear-gradient(180deg,#F1E2BF,#E3CC98);border-radius:12px;box-shadow:0 0 0 3px #6B4220,0 0 0 8px #3A2214,0 24px 60px rgba(0,0,0,.6);padding:26px 22px;text-align:center}'
|
||||
+ 'h1{font:700 26px/1.2 Georgia,serif;margin:0 0 6px}.sub{color:#5A3416;font-weight:700;margin:0 0 16px}.big{font:700 40px/1 Georgia,serif;color:#9A5A00;margin:8px 0}'
|
||||
@@ -3095,7 +3095,16 @@ const server = http.createServer(async (req, res) => {
|
||||
if (r.error) return gkPage(res, 400, 'Mint problem', '<h1>That mint did not work</h1><p class="sub">' + gkEsc(r.error) + '</p><a class="btn blue" href="' + PW_URL() + '/play">Back to PolyWarriors</a>');
|
||||
const c = r.claims; if (c.kind !== 'pw-mint' || !c.order || !(c.serial > 0)) return gkPage(res, 400, 'Mint problem', '<h1>That is not a mint order</h1>');
|
||||
const done = pwOrders.get(c.order);
|
||||
if (done && done.status === 'paid') { const rc = pwReceipt(c.order, done); res.writeHead(302, { Location: (pwIsGameUrl(done.ret) ? done.ret : PW_URL() + '/api/iap/mint-receipt') + '?t=' + rc, 'Cache-Control': 'no-store', 'Set-Cookie': gkCookie('iap.pwmint', '', 0) }); return res.end(); }
|
||||
if (done && done.status === 'paid') {
|
||||
// a visible hand-back instead of a silent redirect chain (Zachary's iPad sat on the mint form after a pass mint,
|
||||
// 2026-10-12): the page says the mint is done, returns to the game by itself, and keeps a button in case it does not.
|
||||
const rc = pwReceipt(c.order, done); const back = (pwIsGameUrl(done.ret) ? done.ret : PW_URL() + '/api/iap/mint-receipt') + '?t=' + rc;
|
||||
res.setHeader('Set-Cookie', gkCookie('iap.pwmint', '', 0));
|
||||
return gkPage(res, 200, 'Minted', '<p class="sub">PolyWarriors · Mint to your wallet</p><h1>' + gkEsc(done.label || ('Warrior #' + done.serial)) + '</h1><div class="big">Minting now</div>'
|
||||
+ '<p class="sub">Your warrior is on its way to the wallet on your InstantAdPay account. Taking you back to the game.</p>'
|
||||
+ '<a class="btn blue" href="' + gkEsc(back) + '">Back to PolyWarriors</a>'
|
||||
+ '<p class="fine">If this page stays, tap the button. The game shows the warrior as On Polygon once the transaction confirms, usually within a minute.</p>', '<meta http-equiv="refresh" content="2;url=' + gkEsc(back) + '">');
|
||||
}
|
||||
const s = await auth.fromRequest(req);
|
||||
if (!s || !s.email) { res.writeHead(302, { Location: '/my', 'Cache-Control': 'no-store', 'Set-Cookie': [gkCookie('iap.pwmint', t, PW_MINT_COOKIE_S), gkCookie('iap.return', 'pwmint', 1800)] }); return res.end(); }
|
||||
if (String(s.email).toLowerCase() !== String(c.email).toLowerCase()) return gkPage(res, 403, 'Different account', '<h1>Different account</h1><p class="sub">This mint was started by the PolyWarriors player ' + gkEsc(c.email) + ', but you are signed in to InstantAdPay as ' + gkEsc(s.email) + '. Sign in with the same account and tap Mint again.</p>');
|
||||
|
||||
Reference in New Issue
Block a user