When we moved from Alby browser extension to local key import for Electron, multiple systems needed updates. This document tracks all the changes required and their current status.
- Authentication: Browser extension (Alby) via NIP-07
- Key Storage: Managed by browser extension
- User Tracking: Based on Alby public key
- API Headers: Only sent Alby pubkey
- Authentication: Dual support (Alby in browser, local import in Electron)
- Key Storage: Encrypted local storage with AES-256
- User Tracking: Works with both Alby and Electron keys
- API Headers: Sends pubkey from either source
-
Key Management (
/components/nostr/electron-key-manager.tsx)- Created new component for key import/management
- Added encryption with
KeyEncryptionclass - Proper nsec/hex format handling
-
Encryption (
/lib/crypto-utils.ts)- Implemented AES-256-GCM encryption
- Device-specific encryption keys
- Session storage for decrypted keys
-
Nostr Service (
/lib/nostr-electron.ts)- Created Electron-specific Nostr service
- Handles encrypted key loading
- Signs events locally
- Migration from old unencrypted format
-
API Client (
/lib/api-client.ts)- Updated to check Electron keys first
- Falls back to Alby if no Electron key
- Sends proper pubkey header for user tracking
-
Main Page (
/app/page.tsx)- Added
hasNostrAccessvariable (Alby OR Electron) - Updated all
isConnectedchecks - Fixed download form enablement
- Updated messaging for Electron
- Added
-
Content List (
/components/content/content-list.tsx)- Added Electron key detection
- Updated empty states with proper messaging
- Added "Back" button for key import navigation
- Fixed Nostr posting to use local signing
-
Gallery Page (
/app/gallery/page.tsx)- Uses updated ContentList with proper auth detection
-
Unified Auth Section (
/components/auth/unified-auth-section.tsx)- Shows ElectronKeyManager in Electron
- Shows Alby connection in browser
-
Nostr Context (
/context/nostr-context.tsx)- Added Electron detection and key checking
- Dual support for both auth methods
- Proper npub formatting for both
-
Connection Status (
/components/nostr/connection-status.tsx)- Different messaging for Electron ("Nostr Key Active")
- Hide disconnect button in Electron (keys managed differently)
-
API Routes (
/app/api/nostr/post/route.ts)- Accepts pre-signed events from Electron
- Publishes without needing server-side key
-
Other API Routes
- Check all routes properly handle Electron pubkey headers
- Ensure consistent user ID handling
-
Error Messages
- Review all error messages mentioning "Alby"
- Update to be platform-appropriate
-
Documentation
- Update user guides for Electron key import
- Document security model
- Key import works in Electron
- Encrypted storage verified
- Download form enables with imported key
- Gallery shows content with imported key
- API requests include proper pubkey header
- Content associated with user's pubkey
- Nostr posting works with imported key
- Full end-to-end test in production build
- Cross-platform testing (Windows, macOS, Linux)
-
Key Storage
- Keys encrypted with AES-256-GCM
- Device-specific encryption (not portable)
- Session storage for temporary decrypted access
-
Privacy
- Keys never sent to server
- All signing happens locally
- Clear messaging about security
- Always do comprehensive impact analysis when changing authentication systems
- User tracking systems need to be authentication-agnostic
- Dual support requires careful context checking throughout the app
- Clear messaging is critical when security models differ between platforms
- Consider unified key management interface
- Add key backup/export functionality
- Implement key rotation support
- Add multi-key support for advanced users