A production-ready, end-to-end encrypted messaging platform designed for maximum security, reliability, and performance.
- End-to-End Encryption: Zero-knowledge architecture using Ed25519 signatures, X25519 key exchange, and AES-256-GCM
- Replay Protection: Nonce tracking with LRU eviction (100k capacity, 5min TTL)
- Forward Secrecy: Double Ratchet protocol with per-message keys and sequence numbers
- Rate Limiting: Handshake (10/min) and message (100/min) limits per client
- Memory Safety: Bounded stores (10k sessions, 10k messages) with LRU eviction
- Identity Persistence: Server identity key saved with 0600 permissions
- Modern Mobile-First UI: Responsive glassmorphism design, touch-optimized, PWA-ready
- Production Hardening: CI/CD security enforcement, dependency auditing, zero TODOs
- Cryptography: @noble/curves (Ed25519, X25519), @noble/hashes (SHA-256), AES-256-GCM
- Replay Protection: NonceTracker with timestamp-based LRU eviction
- Rate Limiting: Per-client handshake and message rate limits
- Input Validation: Size limits, signature verification, sequence number checks
- Memory Bounds: Capped sessions and message stores prevent DoS
- Graceful Degradation: Bounded retries, connection timeouts, graceful shutdown
- Node.js >= 20.0.0
- npm >= 10.0.0
npm install
npm run build
npm run build:browsernpm run serverServer starts on ws://0.0.0.0:8080 with identity persisted to ./data/server-identity.key
-
Start the WebSocket server:
npm run server
Server starts on
ws://0.0.0.0:8080 -
Start the HTTP client server (in a new terminal):
npm run client
HTTP server starts on
http://localhost:3000
- Open your browser:
Navigate to
http://localhost:8000
787f4c79bb6d1c62d5eba8eebec8676cffcb7028
-
Mobile & Desktop Support:
- Responsive glassmorphism UI
- Touch-optimized controls (48px buttons)
- Sidebar slides out on mobile
- PWA-ready with theme colors
-
Connect:
- Server URL is pre-filled:
ws://localhost:8080 - Click "Connect" button
- Your identity is auto-generated on first load
- Add recipient public keys
- Start secure messaging with E2E encryption
- Server URL is pre-filled:
import { SecureMessengerClient, generateIdentityKeyPair } from './src/index.js';
const client = new SecureMessengerClient({
serverUrl: 'ws://localhost:8080',
identityKey: generateIdentityKeyPair(),
});
await client.connect();
await client.sendMessage(recipientId, 'Hello, secure world!');# Run all tests
npm test
# Security audit
npm run security:check
# Dependency audit
npm audit
# Lint with security rules
npm run lintThe project includes .github/workflows/security.yml with:
- Dependency vulnerability scanning
- TypeScript strict mode validation
- ESLint security plugin checks
- Cryptographic implementation tests
- Automated security gates
massanger/
βββ src/
β βββ client/ # Client implementation
β β βββ browser.ts # Browser entry point
β β βββ browser-websocket.ts # WebSocket adapter
β β βββ client.ts # Core client logic
β βββ server/ # Server implementation
β β βββ server.ts # Hardened server with all protections
β β βββ index.ts # Entry point with identity persistence
β βββ crypto/ # Cryptographic primitives
β β βββ primitives.ts # Ed25519, X25519, AES-256-GCM
β β βββ ratchet.ts # Double Ratchet with counters
β β βββ types.ts # Crypto type definitions
β βββ protocol/ # Protocol layer
β βββ message.ts # Message encoding/decoding
β βββ handshake.ts # Handshake protocol
β βββ nonce-tracker.ts # Replay protection
βββ client/ # Browser UI
β βββ index.html # PWA-ready HTML
β βββ styles.css # 744 lines of glassmorphism design
β βββ app.js # UI logic with mobile menu
β βββ bundle.js # Bundled client (generated)
βββ data/ # Server data
β βββ server-identity.key # Persisted server identity
βββ .github/workflows/ # CI/CD
β βββ security.yml # Security enforcement pipeline
βββ package.json # Exact dependency versions
- Glassmorphism Design: Backdrop blur with gradient accents
- Mobile-First Responsive: Breakpoints at 1024px and 640px
- Touch-Optimized: 48px buttons, no tap highlight, smooth animations
- iMessage-Style Bubbles: Rounded corners with tail design
- Sidebar Toggle: Slides out on mobile with backdrop overlay
- Custom Scrollbars: Styled with hover effects
- Performance: will-change transforms, optimized animations
- PWA Ready: Theme color, viewport settings, web app capable
{
port: 8080, // Server port
host: '0.0.0.0', // Bind address
maxSessions: 10000, // Max concurrent sessions
maxStoredMessages: 10000, // Max stored messages
handshakeRateLimit: 10, // Handshakes per minute
messageRateLimit: 100 // Messages per minute
}- Nonce TTL: 5 minutes
- Nonce capacity: 100,000
- Server identity persistence:
./data/server-identity.key - File permissions: 0600 (owner read/write only)
Before deploying to production:
- Review all security fixes in
src/server/server.ts - Configure rate limits based on expected load
- Set up monitoring for handshake/message metrics
- Enable HTTPS/WSS with valid certificates
- Run security audit:
npm run security:check - Test under load with production-like traffic
- Monitor memory usage with bounded stores
- Set up log aggregation for security events
Apache License Version 2.0 - See LICENSE file for details.
This project has been hardened with 23+ critical security fixes:
- β Browser Buffer polyfill (complete hex/base64 support)
- β Server identity persistence with proper file permissions
- β Nonce tracking for replay protection
- β Handshake rate limiting (10/min per client)
- β Message rate limiting (100/min per client)
- β Bounded memory stores (sessions and messages)
- β Sequence number validation
- β Server signature in handshake response
- β Input size validation
- β Graceful shutdown with cleanup
- β CI/CD security pipeline
- β Exact dependency versions
- β ESLint security rules
- β TypeScript strict mode
- β Mobile-first responsive UI
- β Touch-optimized controls
- β PWA support
- β Production-ready configuration
Status: Production-ready for public deployment
Contributions are welcome! Please ensure:
- All tests pass:
npm test - Security checks pass:
npm run security:check - Code follows existing patterns
- No new TODOs or placeholders
- Mobile UI remains responsive