TaxHacker
TaxHacker copied to clipboard
Working IMAP email ingest (builds on the scaffold)
Builds on the email scaffold in this branch and turns it into a working, tested IMAP fetcher. Ingest-only: attachments land in the existing unsorted bucket and flow through the normal Analyze → transaction review.
What it adds (vs. the scaffold)
- Real IMAP:
imap-simple+mailparser(replaces the mock client). - Reuses the upload pipeline: a shared
ingestUnsortedFilehelper writes attachments exactly like a manual upload (no hand-rolled file create). - Credentials encrypted at rest: AES-256-GCM, key derived from
BETTER_AUTH_SECRET; decrypted only at sync/test time. - Non-destructive dedup: per-server highest-UID watermark; mail is fetched read-only and never marked as read.
- Configurable first grab: a "fetch emails since" date (blank = entire mailbox).
- Per-server sync interval enforced on the cron run; manual "Sync Now" bypasses it.
- Tests: a
vitestsuite (19 tests) for encryption, filters, ingest orchestration.
Notes
- Adds
@langchain/coreas an explicit dependency (it was a missing peer that broke a cleannpm install). - Rotating
BETTER_AUTH_SECRETinvalidates stored mailbox passwords (re-enter them) — documented in the app README.
Test plan
- [ ] Configure a mailbox, drop a PDF in the inbox, run
npm run email:sync, confirm it appears in/unsortedand analyzes. - [ ] Re-run sync → 0 new (UID watermark); read state untouched.