Skip to content

Commit 8bbae09

Browse files
Merge pull request #17 from ipfs/master
[pull] master from ipfs:master
2 parents d15e232 + 6ae5eb7 commit 8bbae09

File tree

306 files changed

+4095
-2472
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

306 files changed

+4095
-2472
lines changed

.github/dependabot.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@ updates:
44
directory: "/"
55
schedule:
66
interval: daily
7-
time: "11:00"
7+
time: "10:00"
88
open-pull-requests-limit: 10
9+
commit-message:
10+
prefix: "deps"
11+
prefix-development: "deps(dev)"

.github/workflows/test.yml

+17-9
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
with:
5151
node-version: ${{ matrix.node }}
5252
- uses: ipfs/aegir/actions/cache-node-modules@master
53-
- run: npm run test:node -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1
53+
- run: npx lerna run test:node --since ${{ github.event.pull_request.base.sha }} --concurrency 1
5454
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
5555
with:
5656
flags: node
@@ -67,7 +67,7 @@ jobs:
6767
with:
6868
node-version: lts/*
6969
- uses: ipfs/aegir/actions/cache-node-modules@master
70-
- run: npm run test:chrome -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1
70+
- run: npx lerna run test:chrome --since ${{ github.event.pull_request.base.sha }} --concurrency 1
7171
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
7272
with:
7373
flags: chrome
@@ -84,7 +84,7 @@ jobs:
8484
with:
8585
node-version: lts/*
8686
- uses: ipfs/aegir/actions/cache-node-modules@master
87-
- run: npm run test:chrome-webworker -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1
87+
- run: npx lerna run test:chrome-webworker --since ${{ github.event.pull_request.base.sha }} --concurrency 1
8888
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
8989
with:
9090
flags: chrome-webworker
@@ -101,7 +101,7 @@ jobs:
101101
with:
102102
node-version: lts/*
103103
- uses: ipfs/aegir/actions/cache-node-modules@master
104-
- run: npm run test:firefox -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1
104+
- run: npx lerna run test:firefox --since ${{ github.event.pull_request.base.sha }} --concurrency 1
105105
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
106106
with:
107107
flags: firefox
@@ -119,7 +119,7 @@ jobs:
119119
node-version: lts/*
120120
- uses: ipfs/aegir/actions/cache-node-modules@master
121121
- run: npx playwright install --with-deps
122-
- run: npm run test:firefox-webworker -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1
122+
- run: npx lerna run test:firefox-webworker --since ${{ github.event.pull_request.base.sha }} --concurrency 1
123123
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
124124
with:
125125
flags: firefox-webworker
@@ -138,7 +138,7 @@ jobs:
138138
- uses: ipfs/aegir/actions/cache-node-modules@master
139139
- uses: GabrielBB/xvfb-action@v1
140140
with:
141-
run: npm run test:electron-main -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1 -- -- --bail
141+
run: npx lerna run test:electron-main --since ${{ github.event.pull_request.base.sha }} --concurrency 1 -- -- --bail
142142
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
143143
with:
144144
flags: electron-main
@@ -162,7 +162,7 @@ jobs:
162162
- uses: ipfs/aegir/actions/cache-node-modules@master
163163
- run: npm install
164164
- run: npm run build
165-
- run: npm run test:interop -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1 -- -- -- -t ${{ matrix.type }} --bail
165+
- run: npx lerna run test:interop --since ${{ github.event.pull_request.base.sha }} --concurrency 1 -- -- -t ${{ matrix.type }} --bail
166166
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
167167
with:
168168
flags: interop-${{ matrix.type }}
@@ -190,7 +190,7 @@ jobs:
190190
node-version: lts/*
191191
- run: npm install
192192
- run: npm run build
193-
- run: npm run ${{ matrix.suite }} -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1 -- -- -t ${{ matrix.type }}
193+
- run: npx lerna run ${{ matrix.suite }} --since ${{ github.event.pull_request.base.sha }} --concurrency 1 -- -t ${{ matrix.type }} --bail
194194
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
195195
with:
196196
flags: interface-${{ matrix.type }}
@@ -208,7 +208,7 @@ jobs:
208208
node-version: lts/*
209209
- uses: ipfs/aegir/actions/cache-node-modules@master
210210
- run: npx playwright install --with-deps
211-
- run: npm run test:interface:message-port-client -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1
211+
- run: npx lerna run test:interface:message-port-client --since ${{ github.event.pull_request.base.sha }} --concurrency 1 -- -- --bail
212212

213213
release:
214214
runs-on: ubuntu-latest
@@ -233,6 +233,14 @@ jobs:
233233
release-type: node
234234
manifest-file: .release-please-manifest.json
235235
config-file: .release-please.json
236+
changelog-types: |
237+
[
238+
{ "type": "feat", "section": "Features", "hidden": false },
239+
{ "type": "fix", "section": "Bug Fixes", "hidden": false },
240+
{ "type": "chore", "section": "Trivial Changes", "hidden": false },
241+
{ "type": "docs", "section": "Documentation", "hidden": false },
242+
{ "type": "deps", "section": "Dependencies", "hidden": false }
243+
]
236244
- uses: actions/checkout@v2
237245
with:
238246
fetch-depth: 0

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ tsconfig-types.aegir.json
88

99
# Coverage directory used by tools like istanbul
1010
coverage
11+
.coverage
1112
.nyc_output
1213
tests_output
1314
cache

.release-please-manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"packages/interface-ipfs-core":"0.155.2","packages/ipfs":"0.63.5","packages/ipfs-cli":"0.13.5","packages/ipfs-client":"0.8.3","packages/ipfs-core":"0.15.4","packages/ipfs-core-config":"0.4.1","packages/ipfs-core-types":"0.11.1","packages/ipfs-core-utils":"0.15.1","packages/ipfs-daemon":"0.13.5","packages/ipfs-grpc-client":"0.10.2","packages/ipfs-grpc-protocol":"0.6.0","packages/ipfs-grpc-server":"0.9.4","packages/ipfs-http-client":"57.0.3","packages/ipfs-http-gateway":"0.10.4","packages/ipfs-http-response":"3.0.4","packages/ipfs-http-server":"0.12.5","packages/ipfs-message-port-client":"0.12.4","packages/ipfs-message-port-protocol":"0.12.1","packages/ipfs-message-port-server":"0.12.1"}
1+
{"packages/interface-ipfs-core":"0.157.0","packages/ipfs":"0.65.0","packages/ipfs-cli":"0.15.0","packages/ipfs-client":"0.9.2","packages/ipfs-core":"0.17.0","packages/ipfs-core-config":"0.6.0","packages/ipfs-core-types":"0.13.0","packages/ipfs-core-utils":"0.17.0","packages/ipfs-daemon":"0.15.0","packages/ipfs-grpc-client":"0.12.0","packages/ipfs-grpc-protocol":"0.7.0","packages/ipfs-grpc-server":"0.11.0","packages/ipfs-http-client":"59.0.0","packages/ipfs-http-gateway":"0.12.0","packages/ipfs-http-response":"5.0.0","packages/ipfs-http-server":"0.14.0","packages/ipfs-message-port-client":"0.14.0","packages/ipfs-message-port-protocol":"0.14.0","packages/ipfs-message-port-server":"0.14.0"}

LICENSE

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This project is dual licensed under MIT and Apache-2.0.
2+
3+
MIT: https://www.opensource.org/licenses/mit
4+
Apache-2.0: https://www.apache.org/licenses/license-2.0

LICENSE-MIT

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1616
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1717
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1818
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19-
THE SOFTWARE.
19+
THE SOFTWARE.

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

docs/MIGRATION-TO-ASYNC-AWAIT.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const peerId = PeerId.createFromB58String(peerIdStr)
100100
You can get hold of the `PeerId` class using npm or in a script tag:
101101

102102
```js
103-
import { PeerId } from '@libp2p/interfaces/peer-id'
103+
import { PeerId } from '@libp2p/interface-peer-id'
104104
const peerId = PeerId.createFromB58String(peerIdStr)
105105
```
106106

@@ -128,7 +128,7 @@ You can get hold of the `PeerInfo` class using npm or in a script tag:
128128

129129
```js
130130
const PeerInfo = require('peer-info')
131-
import { PeerId } from '@libp2p/interfaces/peer-id'
131+
import { PeerId } from '@libp2p/interface-peer-id'
132132
const peerInfo = new PeerInfo(PeerId.createFromB58String(info.id))
133133
info.addrs.forEach(addr => peerInfo.multiaddrs.add(addr))
134134
```

docs/MODULE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Instead of a boolean, you may provide an object with custom initialization optio
102102
- `privateKey` (string/PeerId) A pre-generated private key to use. Can be either a base64 string or a [PeerId](https://github.com/libp2p/js-peer-id) instance. **NOTE: This overrides `bits`.**
103103
```js
104104
// Generating a Peer ID:
105-
import { PeerId } from '@libp2p/interfaces/peer-id'
105+
import { PeerId } from '@libp2p/interface-peer-id'
106106
// Generates a new Peer ID, complete with public/private keypair
107107
// See https://github.com/libp2p/js-peer-id
108108
const peerId = await PeerId.create({ bits: 2048 })

docs/core-api/OBJECT.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Object API <!-- omit in toc -->
22

3+
> ⚠️ Object API is [deprecated](https://github.com/ipfs/go-ipfs/issues/7936), use [FILES](FILES.md) and [DAG](DAG.md) APIs instead.
4+
35
- [`ipfs.object.new([options])`](#ipfsobjectnewoptions)
46
- [Parameters](#parameters)
57
- [Options](#options)

docs/core-api/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# IPFS Core API
22

3-
This directory contains the description of the core JS IPFS API. In order to be considered "valid", a JS IPFS core implementation must expose the API described here.
3+
This directory contains the description of the core JS IPFS API. In order to be considered "valid", a JS IPFS core implementation must expose the API described here.
44
This abstraction allows for different implementations including:
55
1. Full JavaScript native implementation
66
2. Delgate implementation that invokes another IPFS implementation (e.g., Kubo)
77

8-
You can use this loose spec as documentation for consuming the core APIs.
8+
You can use this loose spec as documentation for consuming the core APIs.
99

1010
It is broken up into the following sections:
1111

@@ -19,7 +19,7 @@ It is broken up into the following sections:
1919
* [KEY.md](KEY.md)
2020
* [MISCELLANEOUS.md](MISCELLANEOUS.md)
2121
* [NAME.md](NAME.md)
22-
* [OBJECT.md](OBJECT.md)
22+
* [OBJECT.md](OBJECT.md) ([deprecated](https://github.com/ipfs/go-ipfs/issues/7936), use the [DAG API](DAG.md) instead)
2323
* [PIN.md](PIN.md)
2424
* [PUBSUB.md](PUBSUB.md)
2525
* [REFS.md](REFS.md)

docs/upgrading/v0.62-v0.63.md

+46-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<!--Specify versions for migration below-->
22
# Migrating to ipfs@0.63 and ipfs-core@0.15 <!-- omit in toc -->
33

4-
> A migration guide for refactoring your application code from `ipfs@0.63.x` to `ipfs@0.64.x`
4+
> A migration guide for refactoring your application code from `ipfs@0.62.x` to `ipfs@0.63.x`
55
66
## Table of Contents <!-- omit in toc -->
77

88
- [ESM](#esm)
9-
- [libp2p@0.37.x](#libp2p037x)
9+
- [TypeScript and ESM](#typescript-and-esm)
10+
- [`libp2p@0.37.x`](#libp2p037x)
1011
- [PeerIds](#peerids)
1112
- [multiaddrs](#multiaddrs)
1213

@@ -34,11 +35,53 @@ async function loadIpfs () {
3435
}
3536
```
3637

38+
### TypeScript and ESM
39+
40+
When authoring typescript it can often look like you are writing ESM:
41+
42+
```ts
43+
import { create } from 'ipfs-core'
44+
45+
create()
46+
```
47+
48+
When this is transpiled to JavaScript the default settings will emit CJS which will fail at runtime:
49+
50+
```js
51+
"use strict";
52+
exports.__esModule = true;
53+
var ipfs_core_1 = require("ipfs-core");
54+
(0, ipfs_core_1.create)();
55+
```
56+
57+
You may also see errors about private identifiers:
58+
59+
```console
60+
node_modules/@libp2p/interfaces/dist/src/events.d.ts:19:5 - error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.
61+
62+
19 #private;
63+
~~~~~~~~
64+
```
65+
66+
To build correctly with ESM as a target, update your `tsconfig.json` to include the following:
67+
68+
```js
69+
{
70+
"module": "es2020", // ensures output is ESM
71+
"target": "es2020", // support modern features like private identifiers
72+
// other settings
73+
}
74+
```
75+
76+
They must both be set to `es2020` at least, more recent versions will also work.
77+
78+
If in doubt, examine the JavaScript files `tsc` emits and ensure that any `ipfs` modules are being loaded with `import` and not `require`.
79+
3780
## `libp2p@0.37.x`
3881

3982
`ipfs@0.63.x` upgrades to `libp2p@0.37.x`. This is a significant refactor that ports the entire stack to TypeScript and publishes all modules as ESM-only code.
4083

41-
Please see the [libp2p 0.37.x upgrade guide](https://github.com/libp2p/js-libp2p/blob/master/doc/migrations/v0.36-v.037.md) for how this may affect your application.
84+
Please see the [libp2p 0.37.x upgrade guide](https://github.com/libp2p/js-libp2p/blob/master/doc/migrations/v0.36-v0.37.md) for how this may affect your application.
4285

4386
## PeerIds
4487

docs/upgrading/v0.63-v0.64.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!--Specify versions for migration below-->
2+
# Migrating to ipfs@0.64 and ipfs-core@0.16 <!-- omit in toc -->
3+
4+
> A migration guide for refactoring your application code from `ipfs@0.63.x` to `ipfs@0.64.x`
5+
6+
## Table of Contents <!-- omit in toc -->
7+
8+
- [libp2p](#libp2p)
9+
10+
## libp2p
11+
12+
The upgrade to `ipfs@0.64.x` incorporates an update to `libp2p@0.38.x` but no API changes.
13+
14+
If your application uses only the default libp2p config there is nothing to do.
15+
16+
If you supply a custom `libp2p` instance to the `ipfs` factory function you should consult the [`libp2p@0.38.x` upgrade guide](https://github.com/libp2p/js-libp2p/blob/master/doc/migrations/v0.37-v0.38.md) for any changes you need to make.

0 commit comments

Comments
 (0)