-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Phase 4 - Download & Decryption (Client-Side File Encryption) #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add 8 comprehensive tests for download & decryption - Test successful download and decrypt roundtrip - Test checksum verification after decryption - Test tampering detection (invalid checksum) - Test error handling (404, network, decryption errors) - Test original filename and MIME type restoration Part of: #176 (Phase 4 - Download & Decryption) Epic: #143 (Client-Side File Encryption)
- Create AttachmentList component with Catalyst UI - Support download, delete, and preview actions - File icons based on MIME type (image, video, audio, PDF, document) - Human-readable file sizes (B, KB, MB, GB) - Preview button only for previewable files (images, PDFs, text) - Loading states and accessibility (ARIA labels) - 11 comprehensive tests (all passing) Part of: #176 (Phase 4 - Download & Decryption) Epic: #143 (Client-Side File Encryption)
- Change 'secondary' to 'zinc' for preview/download buttons - Change 'destructive' to 'red' for delete button - Fix TypeScript errors in AttachmentList component TypeScript, ESLint, REUSE: all passing ✅
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements Phase 4 of the Client-Side File Encryption epic, adding download and decryption functionality for encrypted file attachments. The implementation maintains the zero-knowledge architecture where the backend cannot read file contents, with all encryption/decryption happening client-side using the Web Crypto API.
Key changes include:
- New
downloadAndDecryptAttachment()API function with full roundtrip encryption/decryption support AttachmentListReact component for displaying and managing encrypted file attachments- Comprehensive test coverage with 48 new tests (37 API tests + 11 component tests)
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/services/secretApi.ts | Adds downloadAndDecryptAttachment() function with Base64 decoding, AES-GCM decryption, and SHA-256 checksum verification |
| src/services/secretApi.test.ts | Comprehensive test suite covering roundtrip encryption/decryption, checksum verification, tampering detection, and error handling scenarios |
| src/components/AttachmentList.tsx | New component displaying file attachments with download/preview/delete actions, file type icons, human-readable sizes, and i18n support |
| src/components/AttachmentList.test.tsx | Component tests covering empty state, file rendering, button interactions, accessibility, loading states, and file size formatting |
- Use buffer.slice() for File construction (prevent extraneous bytes) - Change @lingui/react/macro to @lingui/macro (consistency) - Add bounds check in formatFileSize() (edge case > 1 PB) - Sanitize checksum error message in production (security) - Replace flex-shrink-0 with shrink-0 (Tailwind best practice)
- Create CRYPTO_ARCHITECTURE.md with complete encryption architecture * Key hierarchy and derivation (HKDF-SHA-256) * Encryption/decryption flows with sequence diagrams * Security guarantees and threat model * Performance benchmarks and API reference * Known limitations and future enhancements - Update README.md with File Encryption section * Zero-knowledge architecture overview * Usage examples and security documentation link * Implementation status (Phases 1-5) - Update CHANGELOG.md with all 5 phases * Phase 1: Crypto Utilities (PR #177, merged 19.11.2025) * Phase 2: ShareTarget Integration (PR #178, merged 19.11.2025) * Phase 3: Upload Integration (PR #187, merged 21.11.2025) * Phase 4: Download & Decryption (PR #188, merged 21.11.2025) * Phase 5: Security Audit & Documentation (Issue #174, in progress) Security Audit Checklist: ✅ No debug console.log in production code ✅ No TODO/FIXME comments in crypto code ✅ No hardcoded secrets or API keys ✅ CodeQL analysis configured (weekly scans) ✅ Test coverage verified (crypto code 42.85%, integration 60%+) Part of Epic #143 Client-Side File Encryption (Phase 5/5) Relates to #174
* docs: add comprehensive crypto architecture documentation (Phase 5.1) - Create CRYPTO_ARCHITECTURE.md with complete encryption architecture * Key hierarchy and derivation (HKDF-SHA-256) * Encryption/decryption flows with sequence diagrams * Security guarantees and threat model * Performance benchmarks and API reference * Known limitations and future enhancements - Update README.md with File Encryption section * Zero-knowledge architecture overview * Usage examples and security documentation link * Implementation status (Phases 1-5) - Update CHANGELOG.md with all 5 phases * Phase 1: Crypto Utilities (PR #177, merged 19.11.2025) * Phase 2: ShareTarget Integration (PR #178, merged 19.11.2025) * Phase 3: Upload Integration (PR #187, merged 21.11.2025) * Phase 4: Download & Decryption (PR #188, merged 21.11.2025) * Phase 5: Security Audit & Documentation (Issue #174, in progress) Security Audit Checklist: ✅ No debug console.log in production code ✅ No TODO/FIXME comments in crypto code ✅ No hardcoded secrets or API keys ✅ CodeQL analysis configured (weekly scans) ✅ Test coverage verified (crypto code 42.85%, integration 60%+) Part of Epic #143 Client-Side File Encryption (Phase 5/5) Relates to #174 * fix: markdownlint errors in crypto architecture docs - Add language specifier (text) to code block - Convert bold text to proper headings (h4) - Make duplicate headings unique: * 'Step-by-Step Process' -> 'Encryption/Decryption Step-by-Step Process' * 'Detailed Implementation' -> 'Encryption/Decryption Detailed Implementation' - Add missing blank lines around headings and code blocks - Fix bare URL with angle brackets (<security@secpal.app>) All markdownlint checks now passing (0 errors) Part of PR #190 (Phase 5 Security Audit) * fix: address Copilot review comments - Fix test coverage claims (100% → 42.85% for crypto utilities) - Fix typo: 'Processtep Process' → 'Decryption Process' - Fix capitalization: 'encrypted at REST' → 'encrypted at rest' - Clarify code example: Web Crypto API returns encrypted ArrayBuffer - Add PGP key placeholder (TBD, will be published on keys.openpgp.org) - Update Phase 5 status to reference PR #190 All berechtigte Copilot-Kommentare wurden behoben. Relates to #174
Description
Implements Phase 4: Download & Decryption of Epic #143 (Client-Side File Encryption for Zero-Knowledge Architecture).
This PR adds the ability to download encrypted file attachments and decrypt them client-side, maintaining the zero-knowledge architecture where the backend cannot read file contents.
Fixes: #176
Part of: #143
Depends on: #175 (Phase 3 - Upload Integration)
🎯 Implementation Summary
New Features
Download & Decrypt API Function (
secretApi.ts)downloadAndDecryptAttachment(): Downloads encrypted blob from backend, decrypts client-sideAttachmentList Component (
AttachmentList.tsx)Technical Details
Decryption Flow:
Security:
📊 Test Coverage
Test Results:
🔍 4-Pass Self-Review
✅ Pass 1: Functional Review
✅ Pass 2: Pattern Review
describe,it,expect)✅ Pass 3: Cleanup Review
✅ Pass 4: Security & Documentation
📝 Files Changed
src/services/secretApi.ts(+97 lines): NewdownloadAndDecryptAttachment()functionsrc/services/secretApi.test.ts(+323 lines): 8 comprehensive download/decrypt testssrc/components/AttachmentList.tsx(+221 lines): New component with file list UIsrc/components/AttachmentList.test.tsx(+278 lines): 11 component testsTotal: 919 lines added (4 new files)
🚀 Next Steps (Phase 5)
After this PR is merged, Phase 5 (Security Audit) remains:
Epic Progress: Phase 1 ✅ | Phase 2 ✅ | Phase 3 ✅ | Phase 4 🔄 (this PR) | Phase 5 ⏳
🎨 Screenshots
(Will add AttachmentList component screenshots after UI integration testing)
✅ Pre-PR Checklist
Branch:
feat/download-decryption-phase4Base:
mainStatus: Draft (waiting for CI + Copilot review)