Files
yaoweiprcandClaude Sonnet 5.5 ba1a737374 feat(insomnia-data): integrate field encryption into the database (phase 3)
Add the fieldEncryptionKey init option: the same encryption hooks are attached
to every datastore of a persistent instance, and in-memory instances ignore it.

init() now waits for every datastore to load before repairing the database, and
rejects with an AggregateError naming the datastores that failed, instead of
hanging at the first query on a datastore that never became ready. A failed
init discards the half-loaded datastores, forces autoload on, and installs a
no-op onload handler so NeDB does not also raise an unhandled rejection. With a
key, the encrypted path table is derived up front so a broken schema fails init.

The decryption failure report is created per init() and reconciled after the
load (a .db file holds several lines per document, so failures on lines that a
later line replaced or deleted are dropped). It is exposed to a
createNedbDatabase wrapper as getFieldDecryptionFailures().

Tests run real NeDB datastores in a temp directory. Update the design doc to
match, and replace the crypto mock in the hook tests with a fake key.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-03 15:33:40 +08:00
..