mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 20:42:43 +00:00
The inbound-document store keeps the uploaded doctor letter encrypted at rest (InboundDocument.contentEncrypted, AES-256-GCM), but there was no way to read the original back — the decrypt helper had been dropped as unused. - Restore decryptDocumentFromBytes in the document store, fail-closed on a bad / missing key id. - Add GET /api/documents/inbound/[id]/original: owner-scoped (userId-narrowed query), module-gated, returns the decrypted bytes with the stored MIME type. A PDF / image is served inline so the browser can render it; other types download as an attachment. The filename is sanitised before it reaches the Content-Disposition header. The bytes are PHI — never logged, never served cross-user, and a decrypt error fails closed (500) rather than returning ciphertext. Cache-Control is private, no-store. - Surface a 'View original' action in the document review screen. - Document the route in the OpenAPI registry and regenerate the spec. - Cover the route with a test: owner-scoped success, attachment fallback, 404 for another user's document, and fail-closed on decrypt error. i18n: viewOriginal across all six locales.
857 KiB
857 KiB