``` npm install resilient-swarm ```
Last updated 3 years ago by mikeal .
Apache-2.0 · Original npm · Tarball · package.json
$ cnpm install resilient-swarm 
SYNC missed versions from official npm registry.


npm install resilient-swarm

ResilientSwarm is an efficient, secure, and reliable WebRTC swarm. The goal is to not rely on any single point of failure and to resist hostile networks.

The goal is also to be performant when some peers have poor network conditions by using the closest peer as a relay similar to how Skype's "Super Nodes."

Any peer can connect to the swarm given the public key of any node in the network.

let node1 = new Swarm()
let node2 = new Swarm()
let node3 = new Swarm()

// This will print 6 times, as each peer connects to both other peers.
node1.on('peer', peer => console.log('peer1 got', peer.publicKey))
node2.on('peer', peer => console.log('peer2 got', peer.publicKey))
node3.on('peer', peer => console.log('peer3 got', peer.publicKey)) // connect peers 1 and 2 together // connect peers 3 and 1 together
// This will end up connecting all three
// nodes together even though only two
// call each other through signal exchange.


  • Each Swarm instance generates an ECDH public/private keypair for its node.
    • Each node uses signal-exchange to register it's public key and await signals.
    • Another swarm node looks up the public key through the signaling mechanism to exchange initial offers.
      • Currently this is done via a central server but ideally this would be something more resilient like IPFS.
    • Once a connection is established (using SimplePeer) the data channel is multiplexed. The substeams are keyed with a type.
  • There are currently three types of substeams in the data channel that are ciphered.
    • db is a pouchdb database replication stream. Once established bi-directional replication is setup between each node's internal pouchdb instance.
    • dnode is an rpc steam for communication between peers using dnode.
    • relay Used to proxy data from one peer to another when the intermediate peer has better connectivity. The publicKey used to setup a Cipher stream so that the relaying node cannot read the traffic.
  • In addition to storing peer information the local database is replicated with every node in the network. This means that in order to join the swarm a user only needs to connect to one node in the swarm and will then be able to get signals to every other peer and share its active signal with every node in the swarm.

Current Tags

  • 0.3.0                                ...           latest (3 years ago)

3 Versions

  • 0.3.0                                ...           3 years ago
  • 0.2.0                                ...           3 years ago
  • 0.1.0                                ...           4 years ago
Maintainers (1)
Today 0
This Week 1
This Month 4
Last Day 0
Last Week 3
Last Month 1
Dependencies (14)
Dev Dependencies (2)
Dependents (0)

Copyright 2014 - 2016 © |