generated from coulomb/repo-seed
Implements all requirements from ProductRequirementsDocument.md: - PDF detection via Chrome Downloads API - Secure credential storage with AES-GCM encryption - Binect API integration for PDF uploads - Popup UI with Binect branding - Local transfer tracking (500 entry cap) - Help page with tracking view and CSV export - 60-day credential retention with auto-expiry - Accessibility compliance (WCAG 2.1 AA) Technical implementation: - Chrome Extension Manifest V3 - TypeScript with strict mode - Webpack build system - Jest test suite (22/22 passing) - ESLint configured (0 errors) Build output: 13 KB total (production minified) Test coverage: crypto, pdf-detector, tracker, binect-api Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
3.6 KiB
3.6 KiB
Chrome Extension Manifest V3 APIs Research
Key APIs for BinectChrome
1. Downloads API
Purpose: Detect PDF downloads
Key Methods:
chrome.downloads.onChanged: Listen for download state changeschrome.downloads.search(): Query downloadschrome.downloads.download(): Programmatically download (not needed for v1)
Implementation Notes:
- Listen for completed downloads with
.pdfextension - Filter by MIME type
application/pdf - Extract original URL for re-fetching
2. Storage API
Purpose: Store credentials, tracking data, configuration
Key Methods:
chrome.storage.local.set(): Store datachrome.storage.local.get(): Retrieve datachrome.storage.local.remove(): Delete datachrome.storage.local.clear(): Clear all data
Storage Limits:
storage.local: 10MB (sufficient for credentials + 500 tracking entries)- Data persists until extension is uninstalled
Security:
- Data encrypted at OS level by Chrome
- Accessible only to the extension
3. Runtime API
Purpose: Extension lifecycle, messaging
Key Methods:
chrome.runtime.onInstalled: Initialization on first installchrome.runtime.sendMessage(): Communication between componentschrome.runtime.onMessage: Receive messages
4. Tabs API
Purpose: Detect PDF views in browser tabs
Key Methods:
chrome.tabs.onUpdated: Detect navigation to PDFschrome.tabs.query(): Find tabs with specific URLs
Implementation Notes:
- Check for
Content-Type: application/pdfin tab navigation - Does not work reliably with blob URLs
5. Web Request API
Purpose: Inspect HTTP headers for Content-Type detection
Status: Limited in Manifest V3
declarativeNetRequestis the v3 replacement- Cannot inspect response headers dynamically
- Decision: Skip advanced PDF detection in v1, rely on Downloads API
6. Alarms API
Purpose: Check credential expiry (60-day policy)
Key Methods:
chrome.alarms.create(): Schedule periodic checkschrome.alarms.onAlarm: Handle alarm events
Implementation Notes:
- Create daily alarm to check last credential use
- Delete credentials if >60 days since last use
Service Worker Lifecycle
Key Constraints:
- Service workers are ephemeral (shut down when idle)
- No persistent state in memory
- All state must be in chrome.storage
- Event-driven architecture required
Implementation Strategy:
- Store all state in chrome.storage.local
- Service worker wakes on events (download, alarm, message)
- Popup communicates via chrome.runtime.sendMessage()
Permissions Required
Minimal set per PRD:
downloads: PDF detectionstorage: Credential and tracking storagealarms: Credential expiry checks (implicit, no permission needed)- Host permission:
https://api.binect.de/*for Binect API
Web Crypto API (for encryption)
Purpose: Encrypt credentials at rest
Key Methods:
crypto.subtle.generateKey(): Generate AES keycrypto.subtle.encrypt(): Encrypt datacrypto.subtle.decrypt(): Decrypt datacrypto.subtle.deriveBits(): PBKDF2 key derivation
Algorithm: AES-GCM (Galois/Counter Mode)
- Authenticated encryption
- Built-in integrity check
- Standard for web encryption
Testing Considerations
- Use
chrome-mockor similar for unit tests - Service worker can be tested with
chrome.testAPI - Integration tests require loading extension in test Chrome instance
References
- Chrome Extensions Documentation: https://developer.chrome.com/docs/extensions/
- Manifest V3 Migration: https://developer.chrome.com/docs/extensions/migrating/
- Web Crypto API: https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API