webapp/src/lib/encryption.ts
padreug 5eb46e96c3 refactor: improve nostr connection and message handling
- Add WebSocket manager class for better connection handling
- Split message handling into separate store
- Add encryption service class
- Create chat composable for reusable chat logic
- Add error handling service
- Add connection status indicators throughout app
- Add message persistence service
- Improve subscription reliability with EOSE handling
- Add connection state management
- Hide status text on mobile for better space usage

These changes improve code organization, reliability, and user experience by:
- Better separation of concerns
- More robust error handling
- Clearer connection status feedback
- Improved message persistence
- More maintainable WebSocket management
- Better mobile responsiveness

Breaking changes:
- Message handling moved to separate store
- WebSocket connections now managed through NostrWebSocketManager
- Encryption now handled through NostrEncryption service
2025-02-16 11:00:41 +01:00

9 lines
No EOL
342 B
TypeScript

export class NostrEncryption {
static async encrypt(privkey: string, pubkey: string, content: string) {
return await window.NostrTools.nip04.encrypt(privkey, pubkey, content)
}
static async decrypt(privkey: string, pubkey: string, content: string) {
return await window.NostrTools.nip04.decrypt(privkey, pubkey, content)
}
}