npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

e2ee-chat

v1.6.0

Published

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.

Downloads

286

Readme

💬 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

| Option | Type | Required | Description | | ----------- | ------ | -------- | ---------------------------------- | | serverUrl | string | ✅ | Your hosted chat server URL | | roomId | string | ✅ | Session ID for the chat | | userId | string | ✅ | Your current user's ID | | userType | string | ✅ | client, handler, or admin | | secretKey | string | ✅ | AES secret used to encrypt/decrypt | | apiKey | string | ✅ | API 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: [email protected]


⚖️ License

MIT