How NexChat protects your data, privacy, and communications at every layer.
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.
NexChat uses a dual-token JWT strategy for secure, session-based authentication:
Authorization: Bearer header.The client-side Axios interceptor automatically detects 401 responses, queues concurrent failed requests, refreshes the token, and retries — all without interrupting the user experience.
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.
NexChat uses express-rate-limit to protect the API from abuse:
429 Too Many Requests response with a clear error message.Every request body, query parameter, and route parameter is strictly validated using Zod schemas before reaching the controller logic:
validateBody() middleware parses and validates all req.body against a Zod schema.validateQuery() middleware validates URL query parameters.validateParams() middleware validates route parameters like conversation IDs.400 Validation Error response with field-level error details.Zod validation prevents injection attacks, type confusion, and malformed payloads from reaching your database or business logic.
NexChat applies Helmet — a collection of 15+ middleware functions that set security-related HTTP headers:
Content-Security-Policy — Prevents XSS attacks by controlling allowed content sources.X-Content-Type-Options — Prevents MIME type sniffing.X-Frame-Options — Prevents clickjacking by disabling iframe embedding.Strict-Transport-Security — Enforces HTTPS connections (when deployed with TLS).X-DNS-Prefetch-Control, X-Download-Options, and more.NexChat provides a comprehensive moderation system:
(blockerId, blockedId) ensuring no duplicate blocks.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.