Traffic exchanges: public pages may be framed (admin/sign-in still refuse); a framed game or share link shows the landing, whose buttons open play in a new tab with the referral
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,3 +10,16 @@
|
|||||||
document.querySelectorAll('.sThresh').forEach(function (e) { if (s.thresholdPol) e.textContent = n(s.thresholdPol, 2); });
|
document.querySelectorAll('.sThresh').forEach(function (e) { if (s.thresholdPol) e.textContent = n(s.thresholdPol, 2); });
|
||||||
}).catch(function () { $('stats').hidden = true; });
|
}).catch(function () { $('stats').hidden = true; });
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
// shown inside someone else's frame (traffic exchanges, rotators; 2026-10-03): the game keeps progress and the sharer's
|
||||||
|
// referral in cookies that browsers drop inside a frame, so play and sign-in open in a new tab, carrying the share link
|
||||||
|
(function () {
|
||||||
|
var framed = false; try { framed = window.top !== window.self; } catch (e) { framed = true; }
|
||||||
|
if (!framed) return;
|
||||||
|
var q = new URLSearchParams(location.search), r = String(q.get('r') || q.get('ref') || '').replace(/[^A-Za-z0-9_.-]/g, '').slice(0, 40);
|
||||||
|
document.querySelectorAll('a[href]').forEach(function (a) {
|
||||||
|
if (a.getAttribute('href').charAt(0) === '#') return;
|
||||||
|
if (r && /^\/(play|signin)$/.test(a.pathname) && a.host === location.host) a.href = '/r/' + encodeURIComponent(r);
|
||||||
|
a.target = '_blank'; a.rel = 'noopener';
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|||||||
@@ -104,8 +104,8 @@ async function notify(kind, p) {
|
|||||||
// ---- helpers ---------------------------------------------------------------------------------
|
// ---- helpers ---------------------------------------------------------------------------------
|
||||||
const TYPES = { '.html': 'text/html; charset=utf-8', '.css': 'text/css', '.js': 'application/javascript', '.png': 'image/png', '.jpg': 'image/jpeg', '.svg': 'image/svg+xml', '.ico': 'image/x-icon', '.json': 'application/json', '.webp': 'image/webp', '.mp4': 'video/mp4' };
|
const TYPES = { '.html': 'text/html; charset=utf-8', '.css': 'text/css', '.js': 'application/javascript', '.png': 'image/png', '.jpg': 'image/jpeg', '.svg': 'image/svg+xml', '.ico': 'image/x-icon', '.json': 'application/json', '.webp': 'image/webp', '.mp4': 'video/mp4' };
|
||||||
// instantadpay.com: the in-game sign-in kit (script), its API (connect) and the signed-in nudge form (form-action), 2026-10-03
|
// instantadpay.com: the in-game sign-in kit (script), its API (connect) and the signed-in nudge form (form-action), 2026-10-03
|
||||||
const CSP = "default-src 'self'; script-src 'self' " + IAP + "; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https:; connect-src 'self' " + IAP + "; frame-ancestors 'none'; form-action 'self' " + IAP;
|
const CSP = "default-src 'self'; script-src 'self' " + IAP + "; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https:; connect-src 'self' " + IAP + "; form-action 'self' " + IAP;
|
||||||
const SEC = { 'X-Content-Type-Options': 'nosniff', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'X-Frame-Options': 'DENY', 'Content-Security-Policy': CSP };
|
const SEC = { 'X-Content-Type-Options': 'nosniff', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'Content-Security-Policy': CSP }; // frames: see the request handler
|
||||||
function json(res, code, body, extra) { res.writeHead(code, Object.assign({ 'Content-Type': 'application/json', 'Cache-Control': 'no-store' }, SEC, extra || {})); res.end(JSON.stringify(body)); }
|
function json(res, code, body, extra) { res.writeHead(code, Object.assign({ 'Content-Type': 'application/json', 'Cache-Control': 'no-store' }, SEC, extra || {})); res.end(JSON.stringify(body)); }
|
||||||
function sendFile(res, file, extra) {
|
function sendFile(res, file, extra) {
|
||||||
fs.readFile(file, (err, buf) => {
|
fs.readFile(file, (err, buf) => {
|
||||||
@@ -163,6 +163,13 @@ async function creditRefuel(intent, nonce, info) {
|
|||||||
// ---- server ------------------------------------------------------------------------------------
|
// ---- server ------------------------------------------------------------------------------------
|
||||||
const server = http.createServer(async (req, res) => {
|
const server = http.createServer(async (req, res) => {
|
||||||
const u = new URL(req.url, 'http://x'); const p = u.pathname;
|
const u = new URL(req.url, 'http://x'); const p = u.pathname;
|
||||||
|
// frames (2026-10-03): public pages show inside traffic exchanges; admin and the sign-in hand-offs never do. A framed
|
||||||
|
// visit to the game itself lands on the landing page, whose buttons open the game in a new tab (cookies die in frames)
|
||||||
|
if (/^\/(admin|auth|signin|logout)(\/|$)/.test(p) || p.startsWith('/api/admin')) res.setHeader('X-Frame-Options', 'DENY');
|
||||||
|
if (req.headers['sec-fetch-dest'] === 'iframe' && req.method === 'GET') {
|
||||||
|
const fr = /^\/r\/([A-Za-z0-9_.-]{1,40})$/.exec(p);
|
||||||
|
if (fr || p === '/play' || p === '/signin') { res.writeHead(302, { Location: '/' + (fr ? '?r=' + encodeURIComponent(fr[1]) : (u.search || '')), 'Cache-Control': 'no-store' }); return res.end(); }
|
||||||
|
}
|
||||||
// one home address (2026-10-01): pages on any other host we answer for (driprunner.saasy.top, www.) move to SITE_URL with the
|
// one home address (2026-10-01): pages on any other host we answer for (driprunner.saasy.top, www.) move to SITE_URL with the
|
||||||
// path and query intact, so key links keep working and a refuel never returns to a different origin than the run started on.
|
// path and query intact, so key links keep working and a refuel never returns to a different origin than the run started on.
|
||||||
// The API, the IAP callback, health and the badge art answer on every host.
|
// The API, the IAP callback, health and the badge art answer on every host.
|
||||||
|
|||||||
Reference in New Issue
Block a user