End-to-End Encryption

NexChat implements a public key infrastructure (PKI) for end-to-end encryption. Each user generates a public-private key pair. The public key is stored on the server and shared with other users, while the private key never leaves the client device.

How it works: When User A wants to send a message to User B, the client fetches User B's public key, encrypts the message locally, and sends only the ciphertext. Only User B's private key can decrypt it — the server never sees plaintext content.

Public keys can be saved and retrieved via the /api/users/public-key endpoints. In production, this enables true zero-knowledge encryption where even NexChat's infrastructure cannot read your messages.

Authentication & JWT Security

NexChat uses a dual-token JWT strategy for secure, session-based authentication:

The client-side Axios interceptor automatically detects 401 responses, queues concurrent failed requests, refreshes the token, and retries — all without interrupting the user experience.

OTP Verification

NexChat supports one-time password (OTP) verification via email (Resend API / Nodemailer SMTP) or SMS (Twilio). This can be configured as a mandatory step before registration and login.

Rate Limiting

NexChat uses express-rate-limit to protect the API from abuse:

Input Validation

Every request body, query parameter, and route parameter is strictly validated using Zod schemas before reaching the controller logic:

Zod validation prevents injection attacks, type confusion, and malformed payloads from reaching your database or business logic.

Security Headers

NexChat applies Helmet — a collection of 15+ middleware functions that set security-related HTTP headers:

Block & Report System

NexChat provides a comprehensive moderation system:

Infrastructure Security

NexChat follows security best practices at every layer — from input validation and authentication to infrastructure deployment. We recommend always running the latest version and using HTTPS in production.