Adds the full Next.js app (app/, components/, lib/, scripts/, assets/, docs/, Dockerfile, compose, configs) to version control. Security: - CIPC BizPortal customer-code logins (Login 1 + Login 3) now read CIPC_LOGIN1_CODE / CIPC_LOGIN1_PASSWORD / CIPC_LOGIN3_CODE / CIPC_LOGIN3_PASSWORD from .env.local instead of source. - BizPortal personal login in apply-bizportal route reads BIZPORTAL_ID_NO / BIZPORTAL_PASSWORD. - Added .env.example as the committed template. .gitignore excludes .env*, node_modules, .next, logs, sqlite, Playwright storage_state.json (live CIPC cookies), scratch dirs, client PDFs and debug screenshots.
24 lines
1.3 KiB
Python
24 lines
1.3 KiB
Python
import base64, subprocess, tempfile, json, os
|
|
|
|
AB = "C:\\Users\\SJ\\AppData\\Roaming\\npm\\agent-browser.cmd"
|
|
|
|
def run_ab(*args, timeout=30):
|
|
tmp = tempfile.NamedTemporaryFile(mode="w", delete=False, encoding="utf-8", errors="replace", prefix="ab_", suffix=".out")
|
|
tmp_path = tmp.name
|
|
tmp.close()
|
|
try:
|
|
result = subprocess.run([AB, *args], stdout=open(tmp_path, "w", encoding="utf-8", errors="replace"), stderr=subprocess.DEVNULL, timeout=timeout)
|
|
with open(tmp_path, "r", encoding="utf-8", errors="replace") as f:
|
|
out = f.read().strip()
|
|
finally:
|
|
try: os.unlink(tmp_path)
|
|
except OSError: pass
|
|
return out
|
|
|
|
# Single-line IIFE that returns JSON.stringify of { title, body, links }
|
|
js = """(() => { const ifr = document.querySelectorAll('iframe')[0]; const doc = ifr.contentDocument; const body = doc.body ? doc.body.innerText : ''; const links = Array.from(doc.querySelectorAll('a')).map(a => ({ text: a.textContent.trim().slice(0, 40), href: (a.href || '').slice(0, 100) })); return JSON.stringify({ title: doc.title, body: body.slice(0, 300), links: links.slice(0, 15) }); })()"""
|
|
b64 = base64.b64encode(js.encode("utf-8")).decode("ascii")
|
|
out = run_ab("eval", "-b", b64)
|
|
if out.startswith('"') and out.endswith('"'):
|
|
out = json.loads(out)
|
|
print(json.dumps(json.loads(out), indent=2))
|