Sign-in mode 'key': anyone whose browser holds the curtain pass (opened the key link) may play; tester list still honoured
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -25,7 +25,7 @@ const DEFAULTS = {
|
|||||||
itemPol: { shield: 0.05, slow: 0.03 }, // hangar items paid from the POL balance (the sink)
|
itemPol: { shield: 0.05, slow: 0.03 }, // hangar items paid from the POL balance (the sink)
|
||||||
itemDrips: { magnet: 250, ship: 600 }, // hangar items paid in drips (never money)
|
itemDrips: { magnet: 250, ship: 600 }, // hangar items paid in drips (never money)
|
||||||
testers: [], // emails or member ids allowed through the hand-off while signups = 'testers'
|
testers: [], // emails or member ids allowed through the hand-off while signups = 'testers'
|
||||||
signups: 'testers' // 'testers' | 'open' | 'closed'
|
signups: 'testers' // 'testers' | 'key' (tester list or the curtain pass) | 'open' | 'closed'
|
||||||
};
|
};
|
||||||
function settings() { return Object.assign({}, DEFAULTS, store.read('settings', {})); }
|
function settings() { return Object.assign({}, DEFAULTS, store.read('settings', {})); }
|
||||||
function setSettings(patch) { return store.update('settings', {}, s => Object.assign(s, patch)); }
|
function setSettings(patch) { return store.update('settings', {}, s => Object.assign(s, patch)); }
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@
|
|||||||
<div><label>USD per credit</label><input name="usdPerCredit" type="number" step="0.001" min="0"></div>
|
<div><label>USD per credit</label><input name="usdPerCredit" type="number" step="0.001" min="0"></div>
|
||||||
<div><label>USD per POL fallback</label><input name="usdPerPolFallback" type="number" step="0.001" min="0"></div>
|
<div><label>USD per POL fallback</label><input name="usdPerPolFallback" type="number" step="0.001" min="0"></div>
|
||||||
<div><label>Low balance alert (POL)</label><input name="lowBalancePol" type="number" step="0.1" min="0"></div>
|
<div><label>Low balance alert (POL)</label><input name="lowBalancePol" type="number" step="0.1" min="0"></div>
|
||||||
<div><label>Who may sign in</label><select name="signups"><option value="testers">testers only</option><option value="open">any IAP member</option><option value="closed">nobody</option></select></div>
|
<div><label>Who may sign in</label><select name="signups"><option value="key">anyone who opened the key link</option><option value="testers">testers list only</option><option value="open">any IAP member</option><option value="closed">nobody</option></select></div>
|
||||||
<div><label>Shield core (POL)</label><input name="item_shield" type="number" step="0.001" min="0"></div>
|
<div><label>Shield core (POL)</label><input name="item_shield" type="number" step="0.001" min="0"></div>
|
||||||
<div><label>Slow field (POL)</label><input name="item_slow" type="number" step="0.001" min="0"></div>
|
<div><label>Slow field (POL)</label><input name="item_slow" type="number" step="0.001" min="0"></div>
|
||||||
<div><label>Drip magnet (drips)</label><input name="item_magnet" type="number" step="1" min="0"></div>
|
<div><label>Drip magnet (drips)</label><input name="item_magnet" type="number" step="1" min="0"></div>
|
||||||
|
|||||||
@@ -86,11 +86,15 @@ function curtained(req, res, u) {
|
|||||||
}
|
}
|
||||||
function admin(req, u) { const k = req.headers['x-admin-key'] || u.searchParams.get('key'); return !!(ADMIN_KEY && k && k.length === ADMIN_KEY.length && crypto.timingSafeEqual(Buffer.from(k), Buffer.from(ADMIN_KEY))); }
|
function admin(req, u) { const k = req.headers['x-admin-key'] || u.searchParams.get('key'); return !!(ADMIN_KEY && k && k.length === ADMIN_KEY.length && crypto.timingSafeEqual(Buffer.from(k), Buffer.from(ADMIN_KEY))); }
|
||||||
// who may come through the hand-off
|
// who may come through the hand-off
|
||||||
function allowed(claims) {
|
// 'key' (Marty, 2026-09-30: "let anyone I send the link to with the key test"): the hand-off is accepted when the
|
||||||
|
// browser carries the curtain pass, i.e. the person opened the tester link with the key first. The list still works too.
|
||||||
|
function hasPass(req) { const m = /(?:^|;\s*)dr\.pass=([^;]+)/.exec(req.headers.cookie || ''); return !!(CURTAIN && m && decodeURIComponent(m[1]) === CURTAIN); }
|
||||||
|
function allowed(claims, req) {
|
||||||
const s = ledger.settings(); const mode = String(process.env.DR_SIGNUPS || s.signups || 'testers');
|
const s = ledger.settings(); const mode = String(process.env.DR_SIGNUPS || s.signups || 'testers');
|
||||||
if (mode === 'open') return true; if (mode === 'closed') return false;
|
if (mode === 'open') return true; if (mode === 'closed') return false;
|
||||||
const list = (s.testers || []).map(x => String(x).trim().toLowerCase()).filter(Boolean);
|
const list = (s.testers || []).map(x => String(x).trim().toLowerCase()).filter(Boolean);
|
||||||
return list.includes(String(claims.email || '').toLowerCase()) || list.includes(String(claims.memberId));
|
if (list.includes(String(claims.email || '').toLowerCase()) || list.includes(String(claims.memberId))) return true;
|
||||||
|
return mode === 'key' && req && hasPass(req);
|
||||||
}
|
}
|
||||||
// the IAP -> game callback is signed over the timestamp and the raw body with the shared secret
|
// the IAP -> game callback is signed over the timestamp and the raw body with the shared secret
|
||||||
function callbackOk(req, raw) {
|
function callbackOk(req, raw) {
|
||||||
@@ -119,8 +123,8 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (p === '/auth') {
|
if (p === '/auth') {
|
||||||
const r = sso.verify(u.searchParams.get('t'));
|
const r = sso.verify(u.searchParams.get('t'));
|
||||||
if (r.error) return page(res, 400, 'Sign-in did not work', '<p>' + esc(r.error) + '</p><p><a class="btn" href="' + IAP + '/api/my/driprunner">Try again from InstantAdPay</a></p>');
|
if (r.error) return page(res, 400, 'Sign-in did not work', '<p>' + esc(r.error) + '</p><p><a class="btn" href="' + IAP + '/api/my/driprunner">Try again from InstantAdPay</a></p>');
|
||||||
if (!allowed(r.claims)) { console.log('hand-off refused: not a tester', r.claims.memberId, r.claims.username || '', String(r.claims.email || '').replace(/^(.).*(@.*)$/, '$1***$2')); notify('refused', { memberId: r.claims.memberId, username: r.claims.username, email: r.claims.email }).catch(() => {}); }
|
if (!allowed(r.claims, req)) { console.log('hand-off refused: not a tester', r.claims.memberId, r.claims.username || '', String(r.claims.email || '').replace(/^(.).*(@.*)$/, '$1***$2')); notify('refused', { memberId: r.claims.memberId, username: r.claims.username, email: r.claims.email }).catch(() => {}); }
|
||||||
if (!allowed(r.claims)) return page(res, 403, 'Not on the tester list yet', '<p>Drip Runner is in a closed trial. Your InstantAdPay account (' + esc(r.claims.username ? '@' + r.claims.username : '#' + r.claims.memberId) + ') is not on the tester list. Ask Marty to add you.</p>');
|
if (!allowed(r.claims, req)) { const keyMode = String(process.env.DR_SIGNUPS || ledger.settings().signups) === 'key'; return page(res, 403, keyMode ? 'Open the tester link first' : 'Not on the tester list yet', keyMode ? '<p>Drip Runner is in a closed trial. Open the tester link Marty sent you (the one with the key) in this same browser, then tap Open Drip Runner again. Your InstantAdPay account is ' + esc(r.claims.username ? '@' + r.claims.username : '#' + r.claims.memberId) + '.</p>' : '<p>Drip Runner is in a closed trial. Your InstantAdPay account (' + esc(r.claims.username ? '@' + r.claims.username : '#' + r.claims.memberId) + ') is not on the tester list. Ask Marty to add you.</p>'); }
|
||||||
const existing = sso.fromRequest(req);
|
const existing = sso.fromRequest(req);
|
||||||
let sid;
|
let sid;
|
||||||
if (existing && existing.memberId === Number(r.claims.memberId)) { sso.refresh(existing.sid, r.claims); sid = existing.sid; }
|
if (existing && existing.memberId === Number(r.claims.memberId)) { sso.refresh(existing.sid, r.claims); sid = existing.sid; }
|
||||||
@@ -164,7 +168,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (p === '/api/admin/settings' && req.method === 'POST') {
|
if (p === '/api/admin/settings' && req.method === 'POST') {
|
||||||
const { body } = await readBody(req); const patch = {};
|
const { body } = await readBody(req); const patch = {};
|
||||||
for (const k of ['usdPerCredit', 'creditsPerVisit', 'poolSharePct', 'usdPerPolFallback', 'dripPol', 'dailyCapPol', 'thresholdPol', 'seedPol', 'lowBalancePol']) if (body[k] != null && body[k] !== '') patch[k] = Number(body[k]);
|
for (const k of ['usdPerCredit', 'creditsPerVisit', 'poolSharePct', 'usdPerPolFallback', 'dripPol', 'dailyCapPol', 'thresholdPol', 'seedPol', 'lowBalancePol']) if (body[k] != null && body[k] !== '') patch[k] = Number(body[k]);
|
||||||
if (body.signups && ['testers', 'open', 'closed'].includes(body.signups)) patch.signups = body.signups;
|
if (body.signups && ['testers', 'key', 'open', 'closed'].includes(body.signups)) patch.signups = body.signups;
|
||||||
if (Array.isArray(body.testers)) patch.testers = body.testers.map(x => String(x).trim().toLowerCase()).filter(Boolean).slice(0, 500);
|
if (Array.isArray(body.testers)) patch.testers = body.testers.map(x => String(x).trim().toLowerCase()).filter(Boolean).slice(0, 500);
|
||||||
if (body.itemPol && typeof body.itemPol === 'object') patch.itemPol = Object.assign({}, ledger.settings().itemPol, body.itemPol);
|
if (body.itemPol && typeof body.itemPol === 'object') patch.itemPol = Object.assign({}, ledger.settings().itemPol, body.itemPol);
|
||||||
if (body.itemDrips && typeof body.itemDrips === 'object') patch.itemDrips = Object.assign({}, ledger.settings().itemDrips, body.itemDrips);
|
if (body.itemDrips && typeof body.itemDrips === 'object') patch.itemDrips = Object.assign({}, ledger.settings().itemDrips, body.itemDrips);
|
||||||
|
|||||||
Reference in New Issue
Block a user