mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-14 06:40:50 +00:00
Merge v1.25.1: documents library backend — store-without-AI, optional extract, edit, list
# Conflicts: # docs/api/openapi.yaml # src/lib/documents/store.ts # src/lib/openapi/routes/documents.ts
This commit is contained in:
commit
cdd66b6620
12 files changed
+1820
-472
No files matched your search
@@ -36,10 +36,13 @@ export function encryptDocumentToBytes(bytes: Buffer): Uint8Array<ArrayBuffer> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt a stored document back to its raw bytes. Throws on a bad / missing
|
||||
* key id (fail-closed) — the caller must treat a throw as "cannot serve" and
|
||||
* never fall back to returning the ciphertext. The original document is PHI;
|
||||
* the only path that reads it is the owner-scoped download route.
|
||||
* Decrypt a stored document's `Bytes` payload back to its raw bytes. The exact
|
||||
* inverse of `encryptDocumentToBytes`: the column holds `encrypt()`-string
|
||||
* UTF-8 bytes whose plaintext is the base64 of the original binary. Throws on a
|
||||
* bad / missing key id (fail-closed) — the caller must treat a throw as "cannot
|
||||
* serve" and never fall back to returning the ciphertext. The original document
|
||||
* is PHI; the owner-scoped download route and the optional extraction action are
|
||||
* the only paths that read it.
|
||||
*/
|
||||
export function decryptDocumentFromBytes(buf: Uint8Array): Buffer {
|
||||
const base64 = decrypt(Buffer.from(buf).toString("utf8"));
|
||||
@@ -85,6 +88,7 @@ export function serialiseDocument(
|
||||
return {
|
||||
id: doc.id,
|
||||
kind: doc.kind as InboundDocumentKindValue,
|
||||
title: doc.title,
|
||||
filename: doc.filename,
|
||||
mimeType: doc.mimeType,
|
||||
byteSize: doc.byteSize,
|
||||
@@ -93,6 +97,9 @@ export function serialiseDocument(
|
||||
reportDate: doc.reportDate
|
||||
? doc.reportDate.toISOString().slice(0, 10)
|
||||
: null,
|
||||
documentDate: doc.documentDate
|
||||
? doc.documentDate.toISOString().slice(0, 10)
|
||||
: null,
|
||||
errorReason: doc.errorReason,
|
||||
factCount: counts.factCount,
|
||||
pendingCount: counts.pendingCount,
|
||||
|
||||
Reference in new issue
Block a user