You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: implement WebSocket real-time sync with HMAC message authentication
- Add WebSocket service with cryptographic message authentication (HMAC-SHA256)
- Implement secure logging system with production/development modes
- Add real-time note and folder synchronization across clients
- Create responsive panel hooks for desktop layout management
- Add WebSocket status indicators in editor status bar
- Update security documentation with real-time sync authentication details
Copy file name to clipboardExpand all lines: SECURITY.md
+75-4Lines changed: 75 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
## Overview
4
4
5
-
Typelets implements a **zero-knowledge encryption architecture**where all note encryption and decryption happens exclusively in your browser. We cannot read your notes - even if we wanted to. This document details our security implementation for transparency and verification.
5
+
Typelets implements a **zero-knowledge encryption architecture**with **cryptographic message authentication** for real-time sync. All note encryption and decryption happens exclusively in your browser, and all real-time communications are cryptographically authenticated. We cannot read your notes - even if we wanted to. This document details our complete security implementation for transparency and verification.
6
6
7
7
## Core Security Principles
8
8
@@ -18,6 +18,12 @@ Typelets implements a **zero-knowledge encryption architecture** where all note
18
18
- No master keys exist that could decrypt all user data
19
19
- Password reset means permanent data loss (by design)
20
20
21
+
### 3. Cryptographic Message Authentication
22
+
- Real-time WebSocket messages are HMAC-SHA256 signed
23
+
- Session secrets derived from JWT tokens prevent tampering
24
+
- Timestamp + nonce protection against replay attacks
25
+
- Message integrity verified on both client and server
- WebSocket message authentication requires backend support (graceful fallback without)
145
184
146
185
## User Experience & Security Flow
147
186
@@ -172,6 +211,21 @@ Login → Enter Master Password → Access Notes → Auto-lock on Session End
172
211
4. Verify `title` and `content` show as `[ENCRYPTED]`
173
212
5. Verify presence of `encryptedTitle`, `encryptedContent`, `iv`, `salt`
174
213
214
+
### Test Message Authentication
215
+
1. Open browser DevTools → Console tab
216
+
2. Look for "Message authentication initialized" on WebSocket connection
217
+
3. Edit a note in real-time
218
+
4. Check WebSocket messages for signature structure:
219
+
```json
220
+
{
221
+
"payload": { "type": "note_update", ... },
222
+
"signature": "base64_hmac_signature",
223
+
"timestamp": 1640995200000,
224
+
"nonce": "random_string"
225
+
}
226
+
```
227
+
5. Verify "Message signed successfully" in console logs
228
+
175
229
### Verify Zero-Knowledge
176
230
```sql
177
231
-- Even with database access, you see only:
@@ -230,7 +284,13 @@ SELECT encryptedTitle FROM notes;
230
284
**Security vs Performance balance.** This provides ~0.5 seconds of computation on modern devices while exceeding OWASP recommendations.
231
285
232
286
### Q: What about quantum computers?
233
-
**AES-256 is quantum-resistant** with effective 128-bit security against Grover's algorithm. We'll migrate to post-quantum algorithms when standardized.
287
+
**AES-256 is quantum-resistant** with effective 128-bit security against Grover's algorithm. HMAC-SHA256 is also quantum-resistant. We'll migrate to post-quantum algorithms when standardized.
288
+
289
+
### Q: How does WebSocket message authentication work?
290
+
**Each real-time message is cryptographically signed** using HMAC-SHA256 with a session secret derived from your JWT token. This prevents message tampering, replay attacks, and ensures authenticity of real-time updates.
291
+
292
+
### Q: What happens if message authentication fails?
293
+
**The message is rejected and logged as a security event.** Your app continues working normally, but you're protected from potentially malicious messages. The frontend gracefully handles authentication failures.
234
294
235
295
## Security Disclosure
236
296
@@ -251,4 +311,15 @@ For security-related questions:
251
311
252
312
---
253
313
254
-
**Remember**: True security means even we cannot access your data. Your privacy is not a feature - it's our foundation.
314
+
**Remember**: True security means even we cannot access your data AND cannot tamper with your real-time communications. Your privacy and data integrity are not features - they're our foundation.
315
+
316
+
## Security Summary
317
+
318
+
Typelets provides **defense-in-depth** with multiple layers of cryptographic protection:
319
+
320
+
1.**Storage Layer**: AES-256-GCM client-side encryption with zero-knowledge architecture
321
+
2.**Transport Layer**: HMAC-SHA256 message authentication for real-time sync integrity
322
+
3.**Session Layer**: JWT-based authentication with automatic token refresh
323
+
4.**Application Layer**: Memory-safe key management with automatic cleanup
324
+
325
+
This makes Typelets one of the most secure note-taking platforms available, with both **storage encryption** and **transport authentication** cryptographically protected.
0 commit comments