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 <noreply@anthropic.com>
This commit is contained in:
@@ -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 = '<h2>' + esc(opt.title || 'Sign in to play') + '</h2><p>You are signed in on this device as <b>' + esc(who) + '</b>.</p>'
|
||||
+ '<div class="err" role="alert"></div><button class="go" type="button" data-go>Continue as ' + esc(who) + '</button>'
|
||||
+ '<div class="row"><button class="lk" type="button" data-other>Use a different account</button></div>';
|
||||
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)
|
||||
|
||||
@@ -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(); }
|
||||
|
||||
Reference in New Issue
Block a user