Workflow-App/Workflow/scripts/_verify_signed_now.py
sjcoetzeesj-coder 11d0178ab1 feat: commit Workflow app source; move CIPC credentials to env
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.
2026-10-18 15:21:45 +02:00

62 lines
No EOL
2.1 KiB
Python

"""Verify what is stored NOW, reading filenames from PocketBase rather than
hardcoding them. Confirms the signature images survived the upload.
"""
import io
import json
import urllib.parse
import urllib.request
from pathlib import Path
from pypdf import PdfReader
JEI = Path(r"C:\Users\SJ\.minimax-agent\projects\JEI")
env = {}
for line in (JEI / ".env.local").read_text(encoding="utf-8").splitlines():
line = line.strip()
if line and not line.startswith("#") and "=" in line:
k, v = line.split("=", 1)
env[k.strip()] = v.strip().strip('"').strip("'")
PB = env.get("NEXT_PUBLIC_PB_URL") or env["PB_URL"]
TOK = env["PB_TOKEN"]
SLOTS = [
("resolution.signed_letter", "pbc_266170881", "e0dbxprazb70rqx", "signed_letter"),
("resignation.letter", "ysterbaard_director_resignations", "8cfie18uhgy0n0o", "letter"),
("resignation.signature", "ysterbaard_director_resignations", "8cfie18uhgy0n0o", "signature"),
]
def api(path):
req = urllib.request.Request(f"{PB}{path}", headers={"Authorization": TOK})
with urllib.request.urlopen(req, timeout=120) as r:
return json.loads(r.read().decode())
def images(reader):
n = 0
for p in reader.pages:
try:
n += len(p.images)
except Exception:
pass
return n
for label, col, rid, field in SLOTS:
rec = api(f"/api/collections/{col}/records/{rid}")
fname = rec.get(field)
if not fname:
print(f"{label}: EMPTY")
continue
url = f"{PB}/api/files/{col}/{rid}/{urllib.parse.quote(fname)}"
req = urllib.request.Request(url, headers={"Authorization": TOK})
with urllib.request.urlopen(req, timeout=120) as r:
b = r.read()
rd = PdfReader(io.BytesIO(b))
txt = " ".join((p.extract_text() or "") for p in rd.pages).lower()
has_underscores = "_____" in " ".join((p.extract_text() or "") for p in rd.pages)
print(f"{label}")
print(f" file : {fname}")
print(f" size : {len(b)} B pages={len(rd.pages)}")
print(f" IMAGES : {images(rd)} <-- signature scans")
print(f" has blank signature rules: {has_underscores}")
print()