ipfs-coord

8.0.8 • Public • Published

ipfs-coord logo

ipfs-coord

This is a JavaScript npm library built on top of js-ipfs. It provides the following high-level features:

  • Subnets - Helps IPFS nodes create an on-the-fly subnetwork, using pubsub channels.
  • Peer Discovery - Allows new peers entering the subnetwork to find the other subnetwork peers.
  • E2EE - Creates end-to-end encrypted (e2ee) communication channels between peers.
  • Censorship Resistance - Allows automatic networking between peers, even if they are behind a firewall.
  • Payments - Allows peers to easily pay one another in cryptocurrency for access to web services.

This library will help IPFS peers discover one another, coordinate around a common interest, and then stay connected around that interest. It's main sub-components are:

  • IPFS pubsub channels for communication
  • OrbitDB for persistence and to prevent 'dropped messages'
  • Circuit Relays for censorship resistance and tunneling through firewalls
  • Bitcoin Cash for end-to-end encryption and payments.

This library will automatically track peers, connects to them through circuit-relays, and end-to-end encrypts all communication with each node. For more details, read the ipfs-coord specification.

Here are some use cases where IPFS node coordination is needed:

  • e2e encrypted chat
  • Circuit-relay as-a-service
  • Creating CoinJoin transactions
  • Decentralized exchange of currencies
  • Compute-as-a-service
  • Storage-as-a-service

The ultimate goal for this library is to be a building block for building a replacement to the conventional REST API. APIs like REST or gRPC are incredibly valuable, but suffer from the same censorship risks as the rest of the web (location-based addressing). An IPFS-based API, in a fully distributed network like IPFS, must have sophisticated coordination in order for it to function properly. ipfs-coord is that coordination library.

Here is some videos and blog posts that preceded this work:

Additional content that preceded this work:

A live demo of using this library to build an e2e encrypted chat app can be interacted with here:

Install

Install the npm library: npm install --save ipfs-coord

This library requires a peer dependency of:

Example in a node.js app:

Here is an example of adding ipfs-coord to your own node.js app:

const IPFS = require('ipfs')
const BCHJS = require('@psf/bch-js')
const IpfsCoord = require('ipfs-coord')

async function start() {
  // Create an instance of bch-js and IPFS.
  const bchjs = new BCHJS()
  const ipfs = await IPFS.create()

  // Pass bch-js and IPFS to ipfs-coord when instantiating it.
  const ipfsCoord = new IpfsCoord({
    ipfs,
    bchjs,
    type: 'node.js'
  })

  await ipfsCoord.start()
  console.log('IPFS and the coordination library is ready.')
}
start()

Example in a browser app:

This example is exactly the same, except when instantiating the ipfs-coord library, you want to specify the type as browser.

import IPFS from 'ipfs'
import BCHJS from '@psf/bch-js'
import IpfsCoord from 'ipfs-coord'

async function start() {
  // Create an instance of bch-js and IPFS.
  const bchjs = new BCHJS()
  const ipfs = await IPFS.create()

  // Pass bch-js and IPFS to ipfs-coord when instantiating it.
  const ipfsCoord = new IpfsCoord({
    ipfs,
    bchjs,
    type: 'browser'
  })

  await ipfsCoord.start()
  console.log('IPFS and the coordination library is ready.')
}
start()

Development Environment

Setup a development environment:

git clone https://github.com/christroutner/ipfs-coord
cd ipfs-coord
npm install
npm test

Licence

MIT

Package Sidebar

Install

npm i ipfs-coord

Weekly Downloads

7

Version

8.0.8

License

MIT

Unpacked Size

397 kB

Total Files

64

Last publish

Collaborators

  • chris.troutner