New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

e2ee-chat

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

e2ee-chat

A simple realtime chat SDK for web and mobile apps using socket.io with support for end-to-end encryption and multi-tenant backend integration.

latest
Source
npmnpm
Version
1.6.0
Version published
Weekly downloads
40
233.33%
Maintainers
1
Weekly downloads
 
Created
Source

💬 Realtime Chat SDK (Node.js / React)

This SDK allows you to easily integrate end-to-end encrypted 1-to-1 realtime chat into your app using our hosted microservice.

🚀 Features

  • 🔒 End-to-end AES encrypted messages
  • ⚡️ Socket-based realtime messaging
  • 🧩 Multi-tenant DB support via apiKey
  • 👥 Role-based user handling (client, handler, admin)
  • 📥 Chat history via REST API
  • 🔄 Dynamic handler takeover logic
  • ✅ Works with Node.js, React.js, Next.js (App Router compatible)

📦 Installation

npm install e2ee-chat

🧪 Quick Start (React or Next.js)

"use client";

import React, { useState } from "react";
import useChat from "e2ee-chat/useChat";

export default function ChatBox() {
  const [input, setInput] = useState("");
  const { messages, sendMessage, joined } = useChat({
    serverUrl: "http://localhost:4000",
    roomId: "session_abc123",
    userId: "user1",
    userType: "client",
    secretKey: "shared-secret-123",
    apiKey: "your-api-key-here",
  });

  return (
    <div>
      <h2>Chat</h2>
      <ul>
        {messages.map((m, i) => (
          <li key={i}>
            <b>{m.senderId}</b>: {m.decryptedText}
          </li>
        ))}
      </ul>
      <input value={input} onChange={(e) => setInput(e.target.value)} />
      <button onClick={() => sendMessage(input, "user2")}>Send</button>
    </div>
  );
}

🧩 useChat Options

OptionTypeRequiredDescription
serverUrlstringYour hosted chat server URL
roomIdstringSession ID for the chat
userIdstringYour current user's ID
userTypestringclient, handler, or admin
secretKeystringAES secret used to encrypt/decrypt
apiKeystringAPI key to identify your org DB

📥 Accessing Chat History

Chat history is fetched automatically when the user joins. All messages are decrypted with your secretKey.

🔁 Admin Takeover Logic

You can trigger handler takeover:

const { takeover } = useChat(...);
takeover(); // Makes current user the new handler

🏗 Works in:

  • ✅ React.js
  • ✅ Next.js App Router
  • ✅ Node.js test scripts

📁 Server Setup (Hosted Microservice)

To host your own server, clone chat-server and set up .env:

PORT=4000
MONGO_URI=your-default-db-uri

🧠 Multi-Tenant Support

Register your apiKey and mongoUri in the Tenant collection to isolate DB access per organization.

📮 Support

For issues, contact: support@yourchatservice.com

⚖️ License

MIT

Keywords

chat

FAQs

Package last updated on 12 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts