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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@haven-chat-org/core

v1.0.3

Published

Haven shared core — crypto, networking, and types

Readme

haven-core

Shared TypeScript library providing cryptographic primitives, API client, and type definitions used by the web frontend (and any future clients).

Structure

src/
├── types.ts            # All shared TypeScript interfaces and types
├── index.ts            # Public API re-exports
├── crypto/
│   ├── utils.ts        # libsodium init, base64 helpers, key generation
│   ├── x3dh.ts         # X3DH key agreement (initiator + responder)
│   ├── double-ratchet.ts  # Double Ratchet session (DM encryption)
│   ├── sender-keys.ts  # Sender Keys protocol (group channel encryption)
│   ├── file-crypto.ts  # XChaCha20-Poly1305 file encryption
│   └── store.ts        # MemoryStore for key material (in-memory only)
├── net/
│   ├── api.ts          # HavenApi — type-safe REST client with JWT management
│   └── ws.ts           # HavenWs — WebSocket client with auto-reconnect
└── store/
    └── memory-store.ts # In-memory key/session storage

E2EE Model

DMs (X3DH + Double Ratchet)

  1. Initiator fetches recipient's key bundle (identity key + signed prekey + one-time prekey)
  2. X3DH key agreement produces a shared secret
  3. Double Ratchet session provides forward secrecy and break-in recovery
  4. Wire format: [0x01 or 0x02][encrypted payload]

Server Channels (Sender Keys)

  1. Each user generates a sender key per channel
  2. Sender Key Distribution Messages (SKDMs) are encrypted to each member's identity key via crypto_box_seal
  3. Wire format: [0x03][distributionId:16][chainIndex:4 LE][nonce:24][ciphertext+tag]

Files

  • XChaCha20-Poly1305 client-side encryption
  • Key and nonce embedded in the message payload (encrypted along with the message)
  • File sizes are padded to prevent type inference

Building

npm install
npm run build    # Compiles to dist/ via tsc

Important: The web frontend imports from dist/, not src/. You must rebuild haven-core after any changes for the frontend to pick them up.

Testing

npx vitest run    # 78 tests

API Client

The HavenApi class handles JWT token management, automatic PoW solving for registration, and typed request/response for every endpoint:

import { HavenApi } from '@haven/core';

const api = new HavenApi({ baseUrl: 'https://chat.example.com' });
await api.register({ username, password, ...keys });
await api.login({ username, password });
const servers = await api.listServers();

Covers all Haven API areas: auth, servers, channels, messages, sender keys, roles, friends, invites, voice (join/leave/participants/mute/deafen), attachments (upload/download), link previews, admin, and user management.