pediatric-ai-scribe-v3/src/utils
Daniel ac0460b1fe fix(security): timing-safe forgot-password + redact log file writer
Two independent PHI-leak hardenings folded together:

1. forgot-password timing oracle
   The hit path previously did SELECT + token gen + UPDATE + SMTP send
   before responding; the miss path returned after the SELECT. An
   attacker could distinguish registered emails by response latency
   (SMTP RTT is hundreds of ms). Response is now sent immediately after
   Turnstile, with the DB and email work fired-and-forgotten in a
   background async block. Hit and miss take identical wall-clock time.

   Also hardened req.body.email to tolerate missing/non-string input
   instead of throwing 500.

2. logger.file redaction
   logger.info/warn/error wrote straight to /app/data/logs/YYYY-MM-DD.log
   without going through redact(). Current callers are metadata-only and
   safe, but any future caller writing logger.error('boom', req.body)
   would silently drop PHI to disk. Route both message and optional data
   through redact() — same helper the audit path already uses. Benign
   startup messages pass through unchanged; SSN/phone/email/DOB patterns
   are tokenised, long note-body-shaped text is truncated.
2026-04-22 01:01:00 +02:00
..
ai.js fix: auth/API logging to Loki, TTS voice auto-detection, STT ElevenLabs support 2026-04-19 21:26:49 +02:00
auditQueue.js Batch of security + scale fixes 2026-04-14 05:24:40 +02:00
config.js Feat: admin CMS, save/resume encounters, user templates, SSHADESS, well visit notes, sick visit, ROS/PE checklists, ICD-10 diagnoses 2026-03-22 16:43:39 -04:00
crypto.js Security hardening: PHI encryption, argon2, DOMPurify, SRI 2026-04-14 02:49:38 +02:00
embeddings.js feat: Add model search, testing, and TTS/STT/embedding management to admin 2026-04-03 19:55:11 +00:00
errors.js feat: neonatal calculator, DOCX/PPTX/ODT/EPUB support, gateway-agnostic URL helper, TTS/STT fixes 2026-04-19 02:17:06 +02:00
fileType.js Security hardening: PHI encryption, argon2, DOMPurify, SRI 2026-04-14 02:49:38 +02:00
logger.js fix(security): timing-safe forgot-password + redact log file writer 2026-04-22 01:01:00 +02:00
models.js Enforce server-side LLM model whitelist + scope idle timeout to writes 2026-04-14 05:15:55 +02:00
notify.js Add biometric auth, ntfy push notifications, mobile improvements 2026-04-11 02:35:07 +02:00
passwords.js Security hardening: PHI encryption, argon2, DOMPurify, SRI 2026-04-14 02:49:38 +02:00
platform.js Sliding 24h idle timeout (web) + persistent mobile + 2FA backup codes 2026-04-14 04:24:54 +02:00
prompts.js Expand ROS/PE: pertinent negatives for WNL, clinical descriptions for abnormal 2026-03-23 23:45:09 +01:00
promptSafe.js Batch of security + scale fixes 2026-04-14 05:24:40 +02:00
redact.js Security hardening: PHI encryption, argon2, DOMPurify, SRI 2026-04-14 02:49:38 +02:00
sessions.js Add node-pg-migrate for versioned schema changes + better mobile UA labels 2026-04-14 05:06:19 +02:00
transcribeAWS.js Revert chunk size to 8KB — larger sizes cause AWS deserialization errors 2026-03-29 01:21:43 +00:00
transcribeGoogle.js Add per-user voice preferences (STT model + TTS voice selection) 2026-03-31 14:47:00 +00:00
transcribeLocal.js v10: Local Whisper transcription, bigger text areas, flexible AI memory 2026-03-28 22:00:30 +00:00
ttsGoogle.js Add per-user voice preferences (STT model + TTS voice selection) 2026-03-31 14:47:00 +00:00