From 0e528ae85422b371b6994c92a3ef778e9b42b66b Mon Sep 17 00:00:00 2001 From: martbost Date: Mon, 19 Oct 2026 17:26:15 -0500 Subject: [PATCH] Game sign-in kit: a remembered sign-in on this device opens on 'Continue as @name' (new POST /api/game/auth/resume turns the 29-day kit pass into a fresh hand-off token, no code; pass checked for this game, suspended accounts refused), 'Use a different account' falls back to email; Shards of Valor login ad uses the card view (frames: false) Co-Authored-By: Claude Opus 5.5 --- public/assets/game-signin.js | 24 ++++++++++++++++++++++-- server.js | 12 +++++++++++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/public/assets/game-signin.js b/public/assets/game-signin.js index 6b26e96..1963e3e 100644 --- a/public/assets/game-signin.js +++ b/public/assets/game-signin.js @@ -116,7 +116,7 @@ function err(m) { var e = el.querySelector('.err'); if (e) e.textContent = m || ''; } function busy(on) { var b = el.querySelector('.go'); if (b) { b.disabled = !!on; if (on) b.dataset.l = b.textContent, b.textContent = 'One moment…'; else if (b.dataset.l) b.textContent = b.dataset.l; } } function done(r) { - if (r.pass) ls(PASS_KEY, JSON.stringify({ p: r.pass, exp: Date.now() + 29 * 86400000, email: email })); + if (r.pass) { var prev = getPass(); ls(PASS_KEY, JSON.stringify({ p: r.pass, exp: Date.now() + 29 * 86400000, email: email || (prev && prev.email) || '', name: r.username || (prev && prev.name) || '' })); } if (r.needUsername) return stepName(r); if (r.token) { // a fresh sign-in: the login ad first (fails open to the hand-off) if (opt.loginAd === false) return onToken(r.token); @@ -200,7 +200,27 @@ }); setTimeout(function () { try { f.u.focus(); } catch (e) {} }, 50); } - stepEmail(); + // signed in on this device before (the 29-day pass): one tap, no code (Dallas 2026-10-19: "only a name and login with + // InstantAdPay, it should take care of the rest"). Remembered sign-ins skip the login ad, as before. + function stepResume(saved) { + var who = saved.name ? '@' + saved.name : (saved.email || 'your InstantAdPay account'); + el.innerHTML = '

' + esc(opt.title || 'Sign in to play') + '

You are signed in on this device as ' + esc(who) + '.

' + + '' + + '
'; + el.querySelector('[data-go]').addEventListener('click', function () { + err(''); busy(true); + post('/api/game/auth/resume', { game: game, pass: saved.p }).then(function (x) { + busy(false); + if (x.ok && x.pass) ls(PASS_KEY, JSON.stringify({ p: x.pass, exp: Date.now() + 29 * 86400000, email: saved.email || '', name: x.username || saved.name || '' })); + if (x.ok && x.needUsername) return stepName(x); + if (x.ok && x.token) return onToken(x.token); + ls(PASS_KEY, null); stepEmail(x.error || 'Your sign-in expired. Start again with your email.'); + }); + }); + el.querySelector('[data-other]').addEventListener('click', function () { ls(PASS_KEY, null); stepEmail(); }); + } + var saved = opt.resume === false ? null : getPass(); + if (saved) stepResume(saved); else stepEmail(); } // nudge: open InstantAdPay in a new tab already signed in (the pass posts in a form, never in a URL) diff --git a/server.js b/server.js index 68891ae..05f4bbb 100644 --- a/server.js +++ b/server.js @@ -1817,7 +1817,7 @@ const GAME_AUTH = { mint: (a, memberId) => swMint({ memberId: Number(memberId) || 0, email: String(a.email).toLowerCase(), username: a.username || null, wallet: a.address || null }) }, polywarriors: { name: 'PolyWarriors', origins: () => [PW_URL()].concat(PW_ALT()), host: () => PW_URL().replace(/^https?:\/\//, ''), mint: (a, memberId) => pwMint({ memberId: Number(memberId) || 0, email: String(a.email).toLowerCase(), username: a.username || null, wallet: a.address || null }) }, - shardsofvalor: { name: 'Shards of Valor', origins: () => [SOV_URL()].concat(SOV_ALT()), host: () => SOV_URL().replace(/^https?:\/\//, ''), + shardsofvalor: { name: 'Shards of Valor', frames: false, origins: () => [SOV_URL()].concat(SOV_ALT()), host: () => SOV_URL().replace(/^https?:\/\//, ''), mint: (a, memberId) => sovMint({ memberId: Number(memberId) || 0, email: String(a.email).toLowerCase(), username: a.username || null, wallet: a.address || null }) }, gemkingdom: { name: 'Gem Kingdom', origins: () => [GK_URL(), 'https://gemkingdom.saasy.top'], host: () => GK_URL().replace(/^https?:\/\//, ''), mint: (a, memberId) => gkMint({ memberId: Number(memberId) || 0, email: String(a.email).toLowerCase(), username: a.username || null, wallet: a.address || null }) }, @@ -2427,6 +2427,16 @@ const server = http.createServer(async (req, res) => { } return json(res, 200, await gameAnswer(g, b.game, await accounts.byEmail(pass.e)), cors); } + // remembered sign-in (2026-10-19): the kit's 29-day pass for this game becomes a fresh hand-off token, no code + if (p === '/api/game/auth/resume' && req.method === 'POST') { + const cors = gameCors(req); const b = await readBody(req); const g = gameOf(req, b.game); + if (!g) return json(res, 403, { error: 'This game is not connected to InstantAdPay.' }, cors); + const pass = gamePassOpen(b.pass); + if (!pass || (pass.g && pass.g !== b.game)) return json(res, 401, { error: 'Your sign-in expired. Start again with your email.' }, cors); + if (fraud.isSuspended(pass.e)) return json(res, 403, { error: 'This account is suspended. Contact support at instantadpay.com/support.' }, cors); + const acct = await accounts.byEmail(pass.e); if (!acct) return json(res, 404, { error: 'Account not found. Start again with your email.' }, cors); + return json(res, 200, await gameAnswer(g, b.game, acct), cors); + } // the game's nudges ("Add your wallet", "Level up") post the pass here in a new tab: signed in on arrival if (p === '/api/game/enter' && req.method === 'POST') { let f; try { f = new URLSearchParams((await readRaw(req, 4096)).toString('utf8')); } catch (e) { f = new URLSearchParams(); }