One-tap game links keep the inviter's ?ref for signed-out visitors (PolyWarriors, SpellWheel, ClutterHunt, Drip Runner, PassiveDrip; Gem Kingdom and Spooky Doors already did)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1509,6 +1509,9 @@ const GAME_AUTH = {
|
||||
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 }) },
|
||||
};
|
||||
// a game's one-tap link carries the inviter's ?ref to /my, where the viral-link rule sets the sponsor (2026-10-05: only Gem Kingdom and
|
||||
// Spooky Doors passed it before; signed-out visitors from the other games lost their sponsor)
|
||||
const refQ = u => { const r = String(u.searchParams.get('ref') || '').trim().toLowerCase().replace(/[^a-z0-9_]/g, '').slice(0, 20); return r ? '?ref=' + encodeURIComponent(r) : ''; };
|
||||
const devOrigin = o => !IS_PROD && /^http:\/\/(localhost|127\.0\.0\.1)(:\d+)?$/.test(o);
|
||||
function gameOf(req, slug) {
|
||||
const g = Object.prototype.hasOwnProperty.call(GAME_AUTH, String(slug || '')) ? GAME_AUTH[slug] : null; if (!g) return null;
|
||||
@@ -2828,7 +2831,7 @@ 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', '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 (!s || !s.email) { res.writeHead(302, { Location: '/my' + refQ(u), '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;
|
||||
@@ -2839,7 +2842,7 @@ const server = http.createServer(async (req, res) => {
|
||||
// -- PolyWarriors hand-off (2026-10-05): sign the member across; the game verifies with PW_SSO_SECRET
|
||||
if (p === '/api/my/polywarriors' && req.method === 'GET') {
|
||||
const s = await auth.fromRequest(req);
|
||||
if (!s || !s.email) { res.writeHead(302, { Location: '/my', 'Set-Cookie': gkCookie('iap.return', 'polywarriors', 1800), 'Cache-Control': 'no-store' }); return res.end(); }
|
||||
if (!s || !s.email) { res.writeHead(302, { Location: '/my' + refQ(u), 'Set-Cookie': gkCookie('iap.return', 'polywarriors', 1800), 'Cache-Control': 'no-store' }); return res.end(); }
|
||||
if (PW_SECRET().length < 32) return json(res, 503, { error: 'PolyWarriors is not connected yet.' });
|
||||
const acct = await accounts.byEmail(s.email);
|
||||
const tok = pwMint({ memberId: Number((acct && acct.memberId) || s.memberId || 0), email: String(s.email).toLowerCase(), username: (acct && acct.username) || null, wallet: (acct && acct.address) || null });
|
||||
@@ -2848,7 +2851,7 @@ const server = http.createServer(async (req, res) => {
|
||||
// -- SpellWheel hand-off (2026-10-04): sign the member across; the game verifies with SW_SSO_SECRET
|
||||
if (p === '/api/my/spellwheel' && req.method === 'GET') {
|
||||
const s = await auth.fromRequest(req);
|
||||
if (!s || !s.email) { res.writeHead(302, { Location: '/my', 'Set-Cookie': gkCookie('iap.return', 'spellwheel', 1800), 'Cache-Control': 'no-store' }); return res.end(); }
|
||||
if (!s || !s.email) { res.writeHead(302, { Location: '/my' + refQ(u), 'Set-Cookie': gkCookie('iap.return', 'spellwheel', 1800), 'Cache-Control': 'no-store' }); return res.end(); }
|
||||
if (SW_SECRET().length < 32) return json(res, 503, { error: 'SpellWheel is not connected yet.' });
|
||||
const acct = await accounts.byEmail(s.email);
|
||||
const tok = swMint({ memberId: Number((acct && acct.memberId) || s.memberId || 0), email: String(s.email).toLowerCase(), username: (acct && acct.username) || null, wallet: (acct && acct.address) || null });
|
||||
@@ -2857,7 +2860,7 @@ const server = http.createServer(async (req, res) => {
|
||||
// -- ClutterHunt hand-off (2026-10-03): sign the member across; the game verifies with SEEK_SSO_SECRET
|
||||
if (p === '/api/my/clutterhunt' && req.method === 'GET') {
|
||||
const s = await auth.fromRequest(req);
|
||||
if (!s || !s.email) { res.writeHead(302, { Location: '/my', 'Set-Cookie': gkCookie('iap.return', 'clutterhunt', 1800), 'Cache-Control': 'no-store' }); return res.end(); }
|
||||
if (!s || !s.email) { res.writeHead(302, { Location: '/my' + refQ(u), 'Set-Cookie': gkCookie('iap.return', 'clutterhunt', 1800), 'Cache-Control': 'no-store' }); return res.end(); }
|
||||
if (SEEK_SECRET().length < 32) return json(res, 503, { error: 'ClutterHunt is not connected yet.' });
|
||||
const acct = await accounts.byEmail(s.email);
|
||||
const tok = seekMint({ memberId: Number((acct && acct.memberId) || s.memberId || 0), email: String(s.email).toLowerCase(), username: (acct && acct.username) || null, wallet: (acct && acct.address) || null });
|
||||
@@ -3029,7 +3032,7 @@ const server = http.createServer(async (req, res) => {
|
||||
// wallet = the signature-verified main wallet (accounts.linkWallet runs only after /api/auth/verify), offered there, never imposed.
|
||||
if (p === '/api/my/passivedrip' && req.method === 'GET') {
|
||||
const s = await auth.fromRequest(req);
|
||||
if (!s || !s.email) { res.writeHead(302, { Location: '/my', 'Set-Cookie': 'iap.return=passivedrip; Path=/; SameSite=Lax; Max-Age=1800' + (IS_PROD ? '; Secure' : ''), 'Cache-Control': 'no-store' }); return res.end(); } // sign in first, then straight across
|
||||
if (!s || !s.email) { res.writeHead(302, { Location: '/my' + refQ(u), 'Set-Cookie': 'iap.return=passivedrip; Path=/; SameSite=Lax; Max-Age=1800' + (IS_PROD ? '; Secure' : ''), 'Cache-Control': 'no-store' }); return res.end(); } // sign in first, then straight across
|
||||
if (PD_SECRET().length < 32) return json(res, 503, { error: 'PassiveDrip is not connected yet.' });
|
||||
const acct = await accounts.byEmail(s.email);
|
||||
const memberId = (acct && acct.memberId) || s.memberId || 0;
|
||||
|
||||
Reference in New Issue
Block a user