Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Latest commit

 

History

History
252 lines (185 loc) · 21.5 KB

README.md

File metadata and controls

252 lines (185 loc) · 21.5 KB

IPFS JavaScript Implementation

banner

Coverage Status Travis CI Circle CI Dependency Status js-standard-style standard-readme compliant

IPFS JavaScript implementation.

This repo contains the JavaScript implementation of the IPFS protocol, with feature parity to the Go implementation.

Project status

Consult the Roadmap for a complete state description of the project, or you can find in process updates in our Captain.log. A lot of components can be used currently, but it is a WIP, so beware of the Dragons.

Table of Contents

Install

npm

This project is available through npm. To install:

$ npm install ipfs --save

Use in Node.js

To include this project programmatically:

var IPFS = require('ipfs')

var node = new IPFS()

Through command line tool

In order to use js-ipfs as a CLI, you must install it with the global flag. Run the following (even if you have ipfs installed locally):

$ npm install ipfs --global

The CLI is available by using the command jsipfs in your terminal. This is aliased, instead of using ipfs, to make sure it does not conflict with the Go implementation.

Use in the browser with browserify, webpack or any bundler

The code published to npm that gets loaded on require is in fact a ES5 transpiled version with the right shims added. This means that you can require it and use with your favourite bundler without having to adjust the asset management process.

var ipfs = require('ipfs');

Use in a browser using a script tag

Loading this module in a browser (using a <script> tag) makes the Ipfs object available in the global namespace.

The last published version of the package becomes available on npmcdn and thus you may use it as the source:

  • loading the minified version

    <script src="https://npmcdn.com/ipfs/dist/index.min.js"></script>
  • loading the human-readable (not minified) version

    <script src="https://npmcdn.com/ipfs/dist/index.js"></script>

Usage

Examples

Will come soon

API

A complete API definition will come, meanwhile, you can learn how to you use js-ipfs throught he standard interface at

Project structure

┌───┐    ┌───────────────┐    ┌──────────────┐
│CLI│───▶│   HTTP API    ├───▶│IPFS Core Impl│
└───┘    └───────────────┘    └──────────────┘
  △              △                    △
  └──────────────└──────────┬─────────┘
                            │
                         ┌─────┐
                         │Tests│
                         └─────┘

IPFS Core implementation architecture

IPFS Core is divided into separate subsystems, each of them exist in their own repo/module. The dependencies between each subsystem is assured by injection at the IPFS Core level. IPFS Core exposes an API, defined by the IPFS API spec. libp2p is the networking layer used by IPFS, but out of scope in IPFS core, follow that project here

             ▶  ┌───────────────────────────────────────────────────────────────────────────────┐
                │                                   IPFS Core                                   │
             │  └───────────────────────────────────────────────────────────────────────────────┘
                                                        │
             │                                          │
                                                        │
             │            ┌──────────────┬──────────────┼────────────┬─────────────────┐
                          │              │              │            │                 │
             │            │              │              │            │                 │
                          ▼              │              ▼            │                 ▼
             │  ┌──────────────────┐     │    ┌──────────────────┐   │       ┌──────────────────┐
                │                  │     │    │                  │   │       │                  │
             │  │  Block Service   │     │    │   DAG Service    │   │       │    IPFS Repo     │
                │                  │     │    │                  │   │       │                  │
             │  └──────────────────┘     │    └──────────────────┘   │       └──────────────────┘
                          │              │              │            │
  IPFS Core  │            ▼              │         ┌────┴────┐       │
                     ┌────────┐          │         ▼         ▼       │
             │       │ Block  │          │    ┌────────┐┌────────┐   │
                     └────────┘          │    │DAG Node││DAG Link│   │
             │                           │    └────────┘└────────┘   │
                ┌──────────────────┐     │                           │       ┌──────────────────┐
             │  │                  │     │                           │       │                  │
                │    Bitswap       │◀────┤                           ├──────▶│    Importer      │
             │  │                  │     │                           │       │                  │
                └──────────────────┘     │                           │       └──────────────────┘
             │                           │                           │                 │
                                         │                           │            ┌────┴────┐
             │                           │                           │            ▼         ▼
                                         │                           │       ┌────────┐┌────────┐
             │  ┌──────────────────┐     │                           │       │ layout ││chunker │
                │                  │     │              ┌────────────┘       └────────┘└────────┘
             │  │    Files         │◀────┘              │
                │                  │                    │
             │  └──────────────────┘                    │
             ▶                                          │
                                                        ▼
                ┌───────────────────────────────────────────────────────────────────────────────┐
                │                                                                               │
                │                                                                               │
                │                                                                               │
                │                                 libp2p                                        │
                │                                                                               │
                │                                                                               │
                └───────────────────────────────────────────────────────────────────────────────┘

IPFS Core

IPFS Core is the entry point module for IPFS. It exposes an interface defined on IPFS Specs.

Block Service

Block Service uses IPFS Repo (local storage) and Bitswap (network storage) to store and fetch blocks. A block is a serialized MerkleDAG node.

DAG Service

DAG Service offers some graph language semantics on top of the MerkleDAG, composed by DAG Nodes (which can have DAG Links). It uses the Block Service as its storage and discovery service.

IPFS Repo

IPFS Repo is storage driver of IPFS, follows the IPFS Repo Spec and supports the storage of different types of files.

Bitswap

Bitswap is the exchange protocol used by IPFS to 'trade' blocks with other IPFS nodes.

Files

Files is the API that lets us work with IPFS objects (DAG Nodes) as if they were Unix Files.

Importer

Importer are a set of layouts (e.g. UnixFS) and chunkers (e.g: fixed-size, rabin, etc) that convert data to a MerkleDAG representation inside IPFS.

Packages

Package Version Dependencies DevDependencies
ipfs npm Dependency Status devDependency Status
ipfs-api npm Dependency Status devDependency Status
ipfs-unixfs-engine npm Dependency Status devDependency Status
ipfs-repo npm Dependency Status devDependency Status
ipfs-unixfs npm Dependency Status devDependency Status
ipfs-block-service npm Dependency Status devDependency Status
ipfs-block npm Dependency Status devDependency Status
peer-id npm Dependency Status devDependency Status
peer-info npm Dependency Status devDependency Status
ipfs-merkle-dag npm Dependency Status devDependency Status
ipfs-multipart npm Dependency Status devDependency Status
multiaddr npm Dependency Status devDependency Status
multihashing npm Dependency Status devDependency Status
multihashes npm Dependency Status devDependency Status
mafmt npm Dependency Status devDependency Status

In addition there is the libp2p module family that makes up the network layer, the full list can be found here

Contribute

IPFS implementation in JavaScript is a work in progress. As such, there's a few things you can do right now to help out:

  • Go through the modules below and check out existing issues. This would be especially useful for modules in active development. Some knowledge of IPFS may be required, as well as the infrastructure behind it - for instance, you may need to read up on p2p and more complex operations like muxing to be able to help technically.
  • Perform code reviews. More eyes will help a) speed the project along b) ensure quality and c) reduce possible future bugs.
  • Take a look at go-ipfs and some of the planning repositories or issues: for instance, the libp2p spec here. Contributions here that would be most helpful are top-level comments about how it should look based on our understanding. Again, the more eyes the better.
  • Add tests. There can never be enough tests.
  • Contribute to the FAQ repository with any questions you have about IPFS or any of the relevant technology. A good example would be asking, 'What is a merkledag tree?'. If you don't know a term, odds are, someone else doesn't either. Eventually, we should have a good understanding of where we need to improve communications and teaching together to make IPFS and IPN better.

Want to hack on IPFS?

License

MIT.