From f1b37e0c4ac95e49d182403cfb041c98a989d861 Mon Sep 17 00:00:00 2001 From: martbost Date: Wed, 30 Sep 2026 14:01:47 -0500 Subject: [PATCH] Drip Runner return path: signed-out hand-off sets iap.return=driprunner and the email sign-in answers next=/api/my/driprunner (straight back into the game); refuel page dead ends keep a Back to Drip Runner button Co-Authored-By: Claude Fable 5.1 --- public/assets/my.js | 1 + public/assets/refuel.js | 6 ++++-- public/my.html | 2 +- public/refuel.html | 2 +- server.js | 6 +++--- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/public/assets/my.js b/public/assets/my.js index 71a41ec..cf8f520 100644 --- a/public/assets/my.js +++ b/public/assets/my.js @@ -2632,6 +2632,7 @@ $('mcVerifyBtn').addEventListener('click', busy($('mcVerifyBtn'), async () => { const r = await api('/api/auth/email/verify', { email: $('mcEmail').value, code: $('mcCode').value, newsletter: !!($('nlOptin') && $('nlOptin').checked) }); IAP.status('You are in.', 'ok'); + if (r.next && !r.created) { location.href = r.next; return; } // came from Drip Runner: straight back into the game if (r.created && !(r.account && r.account.username)) await showOnboard(); // pick a username first if (!(await showGauntlet())) await showLoginAd(); // welcome tour outranks the login ad await render(); diff --git a/public/assets/refuel.js b/public/assets/refuel.js index b553ca8..d9e83f9 100644 --- a/public/assets/refuel.js +++ b/public/assets/refuel.js @@ -3,9 +3,11 @@ 'use strict'; var $ = function (id) { return document.getElementById(id); }; var q = new URLSearchParams(location.search); var tok = q.get('t') || ''; - var nonce = ''; try { nonce = JSON.parse(atob(tok.split('.')[0].replace(/-/g, '+').replace(/_/g, '/'))).nonce || ''; } catch (e) {} + var nonce = '', tokRet = ''; try { var claims = JSON.parse(atob(tok.split('.')[0].replace(/-/g, '+').replace(/_/g, '/'))); nonce = claims.nonce || ''; tokRet = claims.ret || ''; } catch (e) {} + // every dead end on this page keeps a way back to the run (Marty, 2026-09-30) + var gameHome = tokRet ? tokRet.split('?')[0] : 'https://driprunner.saasy.top/play'; var ret = null, dwell = 8, left = 8, timer = null, done = false; - function msg(title, text, backUrl) { $('rfFrame').innerHTML = '

' + title + '

' + text + '

'; $('rfDone').hidden = true; $('rfCheck').hidden = true; if (backUrl) { var b = $('rfBack'); b.hidden = false; b.onclick = function () { location.href = backUrl; }; } } + function msg(title, text, backUrl) { $('rfFrame').innerHTML = '

' + title + '

' + text + '

'; $('rfDone').hidden = true; $('rfCheck').hidden = true; var b = $('rfBack'); b.hidden = false; var to = backUrl || gameHome; b.textContent = backUrl ? 'Back to the game' : 'Back to Drip Runner'; b.onclick = function () { location.href = to; }; } function esc(s) { return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) { return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]; }); } function api(p, body) { return fetch(p, body ? { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) } : {}).then(function (r) { return r.json(); }); } function ring() { $('rfN').textContent = left; $('rfRing').style.setProperty('--p', ((dwell - left) / dwell * 100) + '%'); } diff --git a/public/my.html b/public/my.html index f4fdbd7..5fed87e 100644 --- a/public/my.html +++ b/public/my.html @@ -1085,7 +1085,7 @@ - + diff --git a/public/refuel.html b/public/refuel.html index a114c2d..b86bb2d 100644 --- a/public/refuel.html +++ b/public/refuel.html @@ -37,6 +37,6 @@ a.rf-open{color:#8FF0FF;font-size:12px} - + diff --git a/server.js b/server.js index 1ab82ca..c75e233 100644 --- a/server.js +++ b/server.js @@ -1617,7 +1617,7 @@ const server = http.createServer(async (req, res) => { let memberId = 0; if (r.account.address) { try { memberId = await chain.memberIdByAccount(r.account.address); } catch (err) {} } const token = await auth.mintSession({ email: r.account.email, address: r.account.address, memberId }); - return json(res, 200, { ok: true, account: r.account, created: !!r.created }, { 'Set-Cookie': auth.sessionCookie(token) }); + return json(res, 200, { ok: true, account: r.account, created: !!r.created, next: parseCookies(req)['iap.return'] === 'driprunner' ? '/api/my/driprunner' : null }, { 'Set-Cookie': auth.sessionCookie(token) }); // next: Drip Runner sent them here to sign in (2026-09-30) } // -- wallet auth: link-to-account when an email session exists, or @@ -2428,12 +2428,12 @@ const server = http.createServer(async (req, res) => { // -- Drip Runner hand-off (2026-09-30): sign the member across, the game verifies with the shared secret if (p === '/api/my/driprunner' && req.method === 'GET') { const s = await auth.fromRequest(req); - if (!s || !s.email) { res.writeHead(302, { Location: '/my' }); return res.end(); } + if (!s || !s.email) { res.writeHead(302, { Location: '/my', 'Set-Cookie': 'iap.return=driprunner; Path=/; SameSite=Lax; Max-Age=1800' + (IS_PROD ? '; Secure' : ''), 'Cache-Control': 'no-store' }); return res.end(); } // sign in first, then straight back into the game if (DR_SECRET().length < 32) return json(res, 503, { error: 'Drip Runner is not connected yet.' }); const acct = await accounts.byEmail(s.email); const memberId = (acct && acct.memberId) || s.memberId || 0; const tok = drMint({ memberId: Number(memberId), email: s.email, wallet: (acct && acct.address) || s.address || null, username: (acct && acct.username) || null }); - res.writeHead(302, { Location: DR_URL() + '/auth?t=' + tok, 'Cache-Control': 'no-store' }); return res.end(); + res.writeHead(302, { Location: DR_URL() + '/auth?t=' + tok, 'Cache-Control': 'no-store', 'Set-Cookie': 'iap.return=; Path=/; SameSite=Lax; Max-Age=0' + (IS_PROD ? '; Secure' : '') }); return res.end(); } // -- Drip Runner refuel: a real verified visit (advertiser charged as usual); the player gets fuel, not credits if (p === '/api/refuel/open' && req.method === 'GET') {