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

feat/no wrtc by default #884

Merged
merged 7 commits into from
Jun 29, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 40 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,28 @@
<h3 align="center">The JavaScript implementation of the IPFS protocol.</h3>

<p align="center">
<a href="http://ipn.io">
<img src="https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square" />
</a>
<a href="http://ipfs.io/">
<img src="https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square" />
</a>
<a href="http://webchat.freenode.net/?channels=%23ipfs">
<img src="https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square" />
</a>
<a href="http://ipn.io"><img src="https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square" /></a>
<a href="http://ipfs.io/"><img src="https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square" /></a>
<a href="http://webchat.freenode.net/?channels=%23ipfs"><img src="https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square" /></a>
<br>
<a href="https://waffle.io/ipfs/js-ipfs">
<img src="https://img.shields.io/badge/pm-waffle-blue.svg?style=flat-square" />
</a>
<a href="https://github.com/ipfs/interface-ipfs-core">
<img src="https://img.shields.io/badge/interface--ipfs--core-API%20Docs-blue.svg">
</a>
<a href="https://github.com/ipfs/interface-ipfs-core/issues/55">
<img src="https://img.shields.io/badge/interface--ipfs--core-Updates-blue.svg">
</a>
<a href="https://waffle.io/ipfs/js-ipfs"><img src="https://img.shields.io/badge/pm-waffle-blue.svg?style=flat-square" /></a>
<a href="https://github.com/ipfs/interface-ipfs-core"><img src="https://img.shields.io/badge/interface--ipfs--core-API%20Docs-blue.svg"></a>
<a href="https://github.com/ipfs/interface-ipfs-core/issues/55"><img src="https://img.shields.io/badge/interface--ipfs--core-Updates-blue.svg"></a>
</p>

<p align="center">
<a href="https://travis-ci.org/ipfs/js-ipfs">
<img src="https://travis-ci.org/ipfs/js-ipfs.svg?branch=master" />
</a>
<a href="https://circleci.com/gh/ipfs/js-ipfs">
<img src="https://circleci.com/gh/ipfs/js-ipfs.svg?style=svg" />
</a>
<a href="https://coveralls.io/github/ipfs/js-ipfs?branch=master">
<img src="https://coveralls.io/repos/github/ipfs/js-ipfs/badge.svg?branch=master">
</a>
<a href="https://travis-ci.org/ipfs/js-ipfs"><img src="https://travis-ci.org/ipfs/js-ipfs.svg?branch=master" /></a>
<a href="https://circleci.com/gh/ipfs/js-ipfs"><img src="https://circleci.com/gh/ipfs/js-ipfs.svg?style=svg" /></a>
<a href="https://coveralls.io/github/ipfs/js-ipfs?branch=master"><img src="https://coveralls.io/repos/github/ipfs/js-ipfs/badge.svg?branch=master"></a>
<br>
<a href="https://david-dm.org/ipfs/js-ipfs">
<img src="https://david-dm.org/ipfs/js-ipfs.svg?style=flat-square" />
</a>
<a href="https://github.com/feross/standard">
<img src="https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square">
</a>
<a href="https://github.com/RichardLitt/standard-readme">
<img src="https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square" />
</a>
<a href="">
<img src="https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square" />
</a>
<a href="">
<img src="https://img.shields.io/badge/Node.js-%3E%3D4.0.0-orange.svg?style=flat-square" />
</a>
<a href="https://david-dm.org/ipfs/js-ipfs"><img src="https://david-dm.org/ipfs/js-ipfs.svg?style=flat-square" /></a>
<a href="https://github.com/feross/standard"><img src="https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square"></a>
<a href="https://github.com/RichardLitt/standard-readme"><img src="https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square" /></a>
<a href=""><img src="https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square" /></a>
<a href=""><img src="https://img.shields.io/badge/Node.js-%3E%3D4.0.0-orange.svg?style=flat-square" /></a>
<br>
<!-- Hidding this until we have SauceLabs situation figured out, right now it is just misleading
<a href="https://saucelabs.com/u/js-ipfs">
<img src="https://saucelabs.com/browser-matrix/js-ipfs.svg" />
</a>
-->
<a href="https://saucelabs.com/u/js-ipfs"><img src="https://saucelabs.com/browser-matrix/js-ipfs.svg" /></a> -->
</p>

### Project status
Expand Down Expand Up @@ -138,18 +107,17 @@ In order to use js-ipfs as a CLI, you must install it with the `global` flag. Ru
$ 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 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](https://github.com/ipfs/go-ipfs).

You can find examples of how to do this bundling at: `https://github.com/ipfs/js-ipfs/tree/master/examples`. If you are using webpack, make sure to use version 2 or above, otherwise it won't work.
### Use in the browser

### Use in a browser using a script tag
##### With browserify, webpack or any bundler

Loading this module in a browser (using a `<script>` tag) makes the `Ipfs` object available in the global namespace.
Find examples of how to do this bundling at: `https://github.com/ipfs/js-ipfs/tree/master/examples`. If you are using webpack, make sure to use version 2 or above, otherwise it won't work.

The last published version of the package become [available for download](https://unpkg.com/ipfs/dist/) from [unpkg](https://unpkg.com/) and thus you may use it as the source:
##### With 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 become [available for download](https://unpkg.com/ipfs/dist/) from [unpkg](https://unpkg.com/) and thus you may use it as the source:

```html
<!-- loading the minified version -->
Expand Down Expand Up @@ -186,6 +154,14 @@ Commands:
- default API port: `5002`
- default Bootstrap is off, to enable it set `IPFS_BOOTSTRAP=1`

If you want to use WebRTC in your local daemon, you will need to install it separatly by installing globally one of the following modules:

- [wrtc](https://npmjs.org/wrtc)
- [electron-webrtc](https://npmjs.org/electron-webrtc)

This is a separate step because there isn't still a good open source WebRTC implementation for Node.js that runs in all the envinronments correctly.
Example: `npm install electron-webrtc --global`.

### HTTP-API

The HTTP-API exposed by the js-ipfs daemon follows the [`http-api-spec`](https://github.com/ipfs/http-api-spec). You can use any of the IPFS HTTP-API client libraries with it, such as: [js-ipfs-api](https://github.com/ipfs/js-ipfs-api).
Expand Down Expand Up @@ -220,6 +196,11 @@ When starting a node, you can:
// https://github.com/ipfs/js-ipfs-repo
const repo = <IPFS Repo instance or repo path>

// If you want to use the WebRTC transport in Node.js, you have to add it separately. Note, WebRTC comes out of the box in the Browser!
const wrtc = require('wrtc') // or require('electron-webrtc')()
const WStar = require('libp2p-webrtc-star')
const wstar = WStar({ wrtc: wrtc })

const node = new IPFS({
repo: repo,
init: true, // default
Expand All @@ -241,6 +222,12 @@ const node = new IPFS({
'/ip4/127.0.0.1/tcp/1337'
]
}
},
libp2p: { // add custom modules to the libp2p stack of your node
modules: { // here we show how to add WebRTC. Note, WebRTC comes out of the box in the Browser! You just need to do this for Node.js
transport: [wstar]
discovery: [wstar.discovery]
}
}
})

Expand Down
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ Let us know if you find any issue or if you want to contribute and add a new tut
- [Transfer files and connect to the to other nodes](./transfer-files)
- [Use IPFS to explore the Ethereum BlockChain](./explore-ethereum)
- [Create and resolve through graphs with the dag API](./dag)
- [Use js-ipfs in electron](./electron)
5 changes: 5 additions & 0 deletions examples/electron/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# js-ipfs in Electron

This example is heavily inspired by [electron-quick-start](https://github.com/electron/electron-quick-start).

Simply `npm install` and `npm start` to see it working.
Loading