A secure, self-hosted messenger with end-to-end encryption, group chats, voice/video calls, file sharing, and full admin controls.
- 🔒 End-to-end Encryption - AES-256-GCM message encryption
- 👥 Group Chats - Create groups with admin controls
- 📞 Voice & Video Calls - WebRTC-based calling
- 📎 File Sharing - Upload and share files
- 👤 Role System - Admin, Moderator, User, Banned
- 🛡️ Admin Panel - Full server management dashboard
- ✉️ Email Verification - Optional email verification
- 🔑 Server Password - Password-protect your server
- 🤖 CAPTCHA - Bot protection
- 💾 SQLite Database - Zero-config database
- 🔐 JWT Authentication - Secure token-based auth
- ⚡ Real-time - WebSocket for instant messaging
- 📱 Responsive - Works on desktop and mobile
# In root directory
npm install
npm run buildcd server
npm installEdit server/config.json to customize:
- Server password
- Email verification (SMTP settings)
- CAPTCHA on/off
- File upload limits
- Encryption settings
- Default admin credentials
Option 1: From root directory (recommended)
node start-server.jsThis will automatically install dependencies if needed and start the server.
Option 2: From server directory
cd server
npm startOpen http://localhost:3000 in your browser.
| Section | Key | Description |
|---|---|---|
server |
port |
Server port (default: 3000) |
security |
serverPassword |
Password to access the server |
security |
jwtSecret |
Secret for JWT tokens (change this!) |
security |
encryptionEnabled |
Enable message encryption |
captcha |
enabled |
Enable CAPTCHA verification |
email |
verificationEnabled |
Require email verification |
email.smtp |
host, port, etc. |
SMTP server settings |
registration |
enabled |
Allow new registrations |
files |
maxSize |
Max file upload size (bytes) |
admin |
defaultAdminPassword |
Default admin password |
PORT=3000 # Override server port
HOST=0.0.0.0 # Override bind address- Server Password:
changeme123 - Admin Username:
admin - Admin Password:
admin123
4 Messenger uses Cloudflare Turnstile for CAPTCHA protection. Follow these steps to set it up:
If you don't have one, create a free account at cloudflare.com.
- Go to the Cloudflare Dashboard
- Navigate to Turnstile in the sidebar
- Click Add Widget
- Enter a name for your widget (e.g., "4 Messenger")
- Add your domain(s) where the messenger will be hosted
- For local development, add
localhost
- For local development, add
- Choose widget type:
- Managed (recommended) - Cloudflare decides when to show challenges
- Non-interactive - Invisible verification
- Invisible - Completely invisible
- Click Create
After creating the widget, you'll see:
- Site Key (public) - Goes in the frontend
- Secret Key (private) - Goes in the server config
Edit server/config.json:
{
"captcha": {
"enabled": true,
"type": "cloudflare",
"cloudflare": {
"siteKey": "0x4AAAAAAXXXXXXXXXXXXXXXXX",
"secretKey": "0x4AAAAAAXXXXXXXXXXXXXXXXX"
}
}
}Replace the placeholder keys with your actual keys from the Cloudflare dashboard.
- Restart the server
- Connect to your messenger
- You should see the Cloudflare Turnstile widget on the auth screen
- Widget not showing: Check that the site key is correct and the domain is whitelisted
- Verification failing: Check that the secret key is correct in config.json
- Console errors: Ensure CORS is properly configured for your domain
Before deploying to production:
- ✅ Change
jwtSecretin config.json - ✅ Change default admin password
- ✅ Change server password
- ✅ Enable HTTPS (use reverse proxy like nginx)
- ✅ Configure CORS origins
- ✅ Enable email verification if needed
- ✅ Set appropriate rate limits
- ✅ Review file upload settings
- ✅ Set up Cloudflare Turnstile (CAPTCHA)
POST /api/register- Register new userPOST /api/login- LoginPOST /api/logout- LogoutGET /api/me- Get current userGET /api/verify-email?token=...- Verify email
GET /api/server-info- Get server configurationPOST /api/verify-password- Verify server passwordGET /api/captcha- Get CAPTCHA challengePOST /api/captcha/verify- Verify CAPTCHA answer
GET /api/users- List all usersPUT /api/users/:id/role- Update user role (admin)POST /api/users/:id/ban- Ban user (mod+)POST /api/users/:id/unban- Unban user (mod+)DELETE /api/users/:id- Delete user (admin)
GET /api/chats- Get user's chatsPOST /api/chats/direct- Create direct chatPOST /api/chats/group- Create group chatPOST /api/chats/:id/members- Add memberDELETE /api/chats/:id/members/:userId- Remove memberPOST /api/chats/:id/leave- Leave group
GET /api/chats/:id/messages- Get messagesPOST /api/chats/:id/messages- Send messagePUT /api/messages/:id- Edit messageDELETE /api/messages/:id- Delete message
POST /api/upload- Upload file
GET /api/admin/stats- Dashboard statisticsGET /api/admin/config- Get server configPUT /api/admin/config- Update server config
auth- Authenticate WebSocket connectiontyping- Typing indicatormark_read- Mark messages as readcall_start- Initiate callcall_offer/call_answer- WebRTC signalingice_candidate- ICE candidate exchangecall_end- End call
- React 19 + TypeScript
- Vite
- Tailwind CSS 4
- Zustand (state management)
- Lucide React (icons)
- Node.js + Express
- WebSocket (ws)
- SQLite (sql.js - no native dependencies)
- JWT authentication
- bcryptjs (password hashing)
- AES-256-GCM encryption
MIT
Thank you for every one who use it!