9c693fcf63
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
45 lines
4.2 KiB
Python
45 lines
4.2 KiB
Python
# In-game sign-in (Marty, 2026-10-03): /signin is our own page running the InstantAdPay kit; every sign-in link
|
|
# points there; the CSP admits instantadpay.com for the kit script, its API calls and the nudge form.
|
|
ROOT = 'D:/Projects/HighRisk/drip-runner/'
|
|
def edit(path, pairs):
|
|
b = open(ROOT + path, 'rb').read(); crlf = b.count(b'\r\n') > b.count(b'\n') // 2
|
|
s = b.decode('utf-8').replace('\r\n', '\n')
|
|
for a, r in pairs:
|
|
if s.count(a) != 1: raise SystemExit('%s anchor %d: %s' % (path, s.count(a), a[:70]))
|
|
s = s.replace(a, r)
|
|
if crlf: s = s.replace('\n', '\r\n')
|
|
open(ROOT + path, 'wb').write(s.encode('utf-8')); print('patched', path)
|
|
|
|
edit('server.js', [
|
|
("const CSP = \"default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data:; connect-src 'self'; frame-ancestors 'none'; form-action 'self'\";",
|
|
"// instantadpay.com: the in-game sign-in kit (script), its API (connect) and the signed-in nudge form (form-action), 2026-10-03\n"
|
|
"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:; connect-src 'self' \" + IAP + \"; frame-ancestors 'none'; form-action 'self' \" + IAP;"),
|
|
("function signinUrl(req) { const r = refCookie(req); return r ? IAP + '/join/' + encodeURIComponent(r) + '?from=driprunner' : IAP + '/api/my/driprunner'; }",
|
|
"function signinUrl(req) { return '/signin'; } // in-game sign-in (2026-10-03); the kit carries the dr.ref sponsor itself"),
|
|
(" if (p === '/play') return sendFile(res, path.join(PUBLIC_DIR, 'play.html'));\n",
|
|
" if (p === '/play') return sendFile(res, path.join(PUBLIC_DIR, 'play.html'));\n"
|
|
" if (p === '/signin') return sendFile(res, path.join(PUBLIC_DIR, 'signin.html')); // in-game sign-in (InstantAdPay kit)\n"),
|
|
("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>');",
|
|
"res, 400, 'Sign-in did not work', '<p>' + esc(r.error) + '</p><p><a class=\"btn\" href=\"/signin\">Try again</a></p>');"),
|
|
("return json(res, 401, { error: 'Sign in through InstantAdPay first.', iap: IAP + '/api/my/driprunner',",
|
|
"return json(res, 401, { error: 'Sign in with your InstantAdPay account first.', iap: '/signin',"),
|
|
])
|
|
edit('public/play.js', [
|
|
(" $('lIap').href = IAP + '/my'; $('bLevel').href = IAP + '/my#buy'; tip('lTip');",
|
|
" $('lIap').href = IAP + '/my'; $('bLevel').href = IAP + '/my#buy'; tip('lTip');\n"
|
|
" // signed in through the game: these open InstantAdPay already signed in (in-game sign-in pass, 2026-10-03)\n"
|
|
" [['lIap', 'overview'], ['bLevel', 'buy']].forEach(function (x) { var a = $(x[0]); if (a && !a.dataset.pass) { a.dataset.pass = 1; a.addEventListener('click', function (ev) { if (window.IAPSignin && IAPSignin.hasPass()) { ev.preventDefault(); IAPSignin.enter(x[1]); } }); } });"),
|
|
("$('bSignin').href = ME_EXTRA.signin || (IAP + '/api/my/driprunner');", "$('bSignin').href = ME_EXTRA.signin || '/signin';"),
|
|
("$('bClearSignin').href = ME_EXTRA.signin || (IAP + '/api/my/driprunner');", "$('bClearSignin').href = ME_EXTRA.signin || '/signin';"),
|
|
("location.href = ME_EXTRA.signin || (IAP + '/api/my/driprunner'); return; }", "location.href = ME_EXTRA.signin || '/signin'; return; }"),
|
|
("b.href = (r && (r.signin || r.iap)) || IAP + '/api/my/driprunner';", "b.href = (r && (r.signin || r.iap)) || '/signin';"),
|
|
])
|
|
edit('public/play.html', [
|
|
('<script src="/spawn.js"></script>', '<script src="https://instantadpay.com/assets/game-signin.js?v=20261003a" async></script>\n<script src="/spawn.js"></script>'),
|
|
])
|
|
b =open(ROOT + 'public/index.html', 'rb').read().decode('utf-8')
|
|
n = b.count('href="https://instantadpay.com/api/my/driprunner">Play with InstantAdPay</a>')
|
|
if n != 2: raise SystemExit('index anchors %d' % n)
|
|
open(ROOT + 'public/index.html', 'wb').write(b.replace('href="https://instantadpay.com/api/my/driprunner">Play with InstantAdPay</a>', 'href="/signin">Play with InstantAdPay</a>').encode('utf-8')); print('patched public/index.html')
|
|
print('ok')
|