fix(security): derive consent-log IP from tRPC context, never client input
DONG-WEI-YANG+1: Claude Sonnet 5
beda5a1
consent.log accepted an optional client-supplied `ipAddress` field and
stored it verbatim into consent_logs — a table the app's own privacy
notice describes as retained as legal evidence of consent. Any caller
hitting the public endpoint directly (bypassing the frontend, which never
even populated this field) could write an arbitrary IP into that record.
Separately, record.create's automatic consent logging never captured an
IP at all — the column was always left null.
Added a real tRPC context: trpc.ts now uses initTRPC.context<Context>()
with `{ ip: string | null }`, and a new context.ts derives it from
Express's req.ip via createExpressMiddleware's createContext option.
index.ts already sets `trust proxy` (for express-rate-limit), so req.ip
correctly resolves through X-Forwarded-For behind Cloud Run/HF Spaces'
reverse proxy rather than returning the proxy's own address. Removed the
client-supplied ipAddress field from consent.log's input schema entirely
and wired ctx.ip into both c…