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

Commit c6d03ec

Browse files
authoredSep 2, 2022
docs: clarify state of DHT in js-ipfs (#4181)
* clarify state of DHT in js-ipfs * corrections to browsers documentation Co-authored-by: Daniel N <2color@users.noreply.github.com>
1 parent cb3533a commit c6d03ec

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed
 

‎docs/BROWSERS.md

+14-12
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,29 @@
88
- [Code Examples](#code-examples)
99

1010
JS IPFS is the implementation of IPFS protocol in JavaScript. It can run on any
11-
evergreen browser, inside a service or web worker, browser extensions, Electron and in Node.js.
11+
evergreen browser, inside a service or web worker, browser extensions, Electron, and in Node.js.
1212

1313
**This document provides key information about running JS IPFS in the browser.
1414
Save time and get familiar with common caveats and limitations of the browser context.**
1515

1616
## Limitations of the Browser Context
1717

18-
- Transport options are limited to [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) and [WebRTC](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API).
18+
- Transport options are currently limited to [WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) and [WebRTC](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API).
1919

2020
This means JS IPFS running in the browser is limited to Web APIs available on a web page.
21-
There is no access to raw TCP sockets nor low level UDP, only WebSockets and WebRTC.
21+
There is no access to raw TCP sockets nor low-level UDP, only WebSockets, and WebRTC.
2222

2323
- Key [Web APIs](https://developer.mozilla.org/en-US/docs/Web/API) require or are restricted by [Secure Context](https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts) policies.
2424

2525
This means JS IPFS needs to run within Secure Context (HTTPS or localhost).
26-
JS IPFS running on HTTPS website requires Secure WebSockets (TLS) and won't work with unencrypted one.
26+
JS IPFS running on HTTPS website requires Secure WebSockets (TLS) and won't work with unencrypted ones.
2727
[Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) not being available at all.
2828

29-
- [DHT](https://en.wikipedia.org/wiki/Distributed_hash_table) is not available in JS IPFS yet.
29+
- JS IPFS comes with limited support for the [DHT](https://docs.ipfs.tech/concepts/dht/) in client mode which delegates content discovery requests to other DHT nodes.
3030

31-
[We are working on it](https://github.com/ipfs/js-ipfs/pull/1994). For now, the discovery and connectivity to other peers is achieved with a mix of rendezvous and
32-
relay servers, delegated peer/content routing and preload servers.
31+
However, it's worth noting that even though you'll get results from DHT queries, most nodes in the network are not dialable from browsers because they only support TCP and/or QUIC transports.
32+
33+
For now, the content discovery and connectivity to other peers are achieved with a mix of DHT client requests, rendezvous and relay servers, delegated peer/content routing, and preload servers.
3334

3435

3536
## Addressing Limitations
@@ -40,23 +41,24 @@ We provide a few additional components useful for running JS IPFS in the browser
4041
- [libp2p-webrtc-star](https://github.com/libp2p/js-libp2p-webrtc-star) - incorporates both a transport and a discovery service that is facilitated by the custom rendezvous server available in the repo
4142
- Instructions on enabling `webrtc-star` in js-ipfs config can be found [here](https://github.com/ipfs/js-ipfs/blob/master/docs/FAQ.md#how-to-enable-webrtc-support-for-js-ipfs-in-the-browser).
4243
- Make sure to [run your own rendezvous server](https://github.com/libp2p/js-libp2p-webrtc-star#rendezvous-server-aka-signalling-server).
43-
- [libp2p-webrtc-direct](https://github.com/libp2p/js-libp2p-webrtc-direct) - a WebRTC transport that doesn't require the set up a signalling server.
44+
- [libp2p-webrtc-direct](https://github.com/libp2p/js-libp2p-webrtc-direct) - a WebRTC transport that doesn't require the set up a signaling server.
4445
- Caveat: you can only establish Browser to Node.js and Node.js to Node.js connections.
4546

46-
**Note:** those are semi-centralized solutions. We are working towards replacing `*-star` with and ambient relays and [libp2p-rendezvous](https://github.com/libp2p/js-libp2p-rendezvous). Details and progress can be found [here](https://github.com/libp2p/js-libp2p/issues/385).
47+
**Note:** those are semi-centralized solutions. We are working towards replacing `*-star` with ambient relays and [libp2p-rendezvous](https://github.com/libp2p/js-libp2p-rendezvous). Details and progress can be found [here](https://github.com/libp2p/js-libp2p/issues/385).
4748

4849
You can find detailed information about running js-ipfs [here](https://github.com/ipfs/js-ipfs#table-of-contents).
4950

5051
## Best Practices
5152

52-
- Configure nodes for using self-hosted `*-star` signalling and transport service. When in doubt, use WebSockets ones.
53+
- Configure nodes for using self-hosted `*-star` signalling and transport service. When in doubt, use WebSockets ones.
5354
- Run your own instance of `*-star` signalling service.
5455
The default ones are under high load and should be used only for tests and development.
55-
- Make sure content added to js-ipfs running in the browser is persisted/cached somewhere on regular IPFS daemon
56+
- Make sure content added to js-ipfs running in the browser is persisted/cached somewhere on a regular long-running IPFS daemon, e.g. [kubo](https://github.com/ipfs/kubo/)
5657
- Manually `pin` or preload CIDs of interest with `refs -r` beforehand.
5758
- Preload content on the fly using [preload](https://github.com/ipfs/js-ipfs/blob/master/docs/MODULE.md#optionspreload) feature and/or
5859
configure [delegated routing](https://github.com/ipfs/js-ipfs/blob/master/docs/DELEGATE_ROUTERS.md).
59-
- Avoid public instances in production environment. Make sure preload and delegate nodes used in config are self-hosted and under your control (expose a subset of go-ipfs APIs via reverse proxy such as Nginx).
60+
- Avoid public instances in production environments. Make sure preload and delegate nodes used in config are self-hosted and under your control (expose a subset of [kubo](https://github.com/ipfs/kubo/) (formerly go-ipfs) APIs via reverse proxy such as Nginx).
61+
- If your main goal is to provide content and files to the IPFS network from a browser and you would like to avoid running infrastructure, consider using a pinning service like [Web3.storage](https://web3.storage/).
6062

6163
## Code Examples
6264

0 commit comments

Comments
 (0)
This repository has been archived.