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

@codefusion-cc/realtime-p2p

v0.1.1

Published

Peer-to-peer data for realtime apps: a WebRTC mesh between the connections of one channel, negotiated through it, carrying messages and content-addressed files checked against their SHA-256

Readme

@codefusion-cc/realtime-p2p

Peer-to-peer data for realtime apps: a WebRTC mesh between the connections of one channel. The channel only passes their signals; messages and files go straight between the browsers and never through the server. It is how an app keeps content off its servers (Peerly's free tier) and still syncs it between whoever is online.

npm install @codefusion-cc/realtime-p2p
import { openDurableChannel } from '@codefusion-cc/realtime/browser'
import { createDataMesh } from '@codefusion-cc/realtime-p2p'

const channel = await openDurableChannel({ endpointPrefix: '/api/workspaces/', authorize, encryptionSecret, namespace: 'example' })
const mesh = createDataMesh({
  channel,                                   // any MeshChannel: connections, joins and leaves, an event sent `to` one
  iceServers: [{ urls: 'stun:stun.cloudflare.com:3478' }],   // add TURN when relays are allowed
  accept: (connectionId, { userId }) => !blocked.has(userId),
  onMessage: (message, from) => apply(message, from.userId),
  provide: async hash => files.get(hash) ?? null,            // what this device can share, by SHA-256
})
mesh.send({ type: 'hello' })                                 // to every open peer, or { to: connectionId }
const file = await mesh.fetchBlob(sha256Hex, { onProgress })  // from the first peer that has it, checked
  • Each pair negotiates with WebRTC's perfect negotiation through the channel event signalEvent (p2p, which the channel must allow); the channel encrypts signals when it encrypts its events, so the server cannot swap the DTLS fingerprints in them. A link that does not connect restarts ICE once, then counts as failed: refresh() tries again, and setIceServers(servers, true) restarts with relays once the app allows them.
  • Blobs are content-addressed. A peer that has one streams it in 16 KiB chunks with backpressure; the bytes count only once they hash to the id asked for, so a peer can neither poison a file nor replace it. A peer serves at most four at once; maxBlobBytes (100 MB) bounds what is served and accepted.
  • A peer that is not online cannot be reached: the app keeps what it must deliver later and sends it when the peer joins.

PeerLink is the single connection underneath, for an app that negotiates its own WebRTC through another channel (@codefusion-cc/realtime-media's calls do): connectMs (20 s) before ICE restarts once, restartMs (as long) before the link fails, disconnectedMs (8 s) a connection may stay down before it restarts. While a connection is down or restarting the link says connecting; one that connects again gets its own restart for the next drop. An offer of its own that the browser refuses fails the link, which stays failed while the connection is up: nothing would offer again. For media, setup(pc, forOffer) readies each connection the link makes and beforeAnswer(pc) puts the app's tracks on the transceivers an offer made; answerOnNewConnection answers a first offer that crossed this side's own on a new connection rather than roll it back (libwebrtc keeps a rolled-back offer's header extension ids and can refuse the next one), and forOffer starts a link that waits for the other side's offer and offers itself at the deadline if it never comes. A link with either makes its data channels in setup, so a new connection gets them too; createDataChannel throws there. When both sides offer at once on a new connection, the polite side takes the other's offer once its own has gathered a candidate (a second at most): Chromium never gathers on a connection whose first offer it rolled back before its network list came.

| Entry | Runs in | What it has | | --- | --- | --- | | @codefusion-cc/realtime-p2p | page | createDataMesh, PeerLink | | @codefusion-cc/realtime-p2p/protocol | both | parsePeerSignal and its limits: a server that passes signals on checks them as the links do | | @codefusion-cc/realtime-p2p/testing | tests | FakePeerConnection: negotiation without WebRTC, for tests in Node |