Skip to content

Commit

Permalink
Merge pull request #17 from ipfs/master
Browse files Browse the repository at this point in the history
[pull] master from ipfs:master
  • Loading branch information
MarcelRaschke authored Nov 2, 2022
2 parents d15e232 + 6ae5eb7 commit 8bbae09
Show file tree
Hide file tree
Showing 306 changed files with 4,095 additions and 2,472 deletions.
5 changes: 4 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ updates:
directory: "/"
schedule:
interval: daily
time: "11:00"
time: "10:00"
open-pull-requests-limit: 10
commit-message:
prefix: "deps"
prefix-development: "deps(dev)"
26 changes: 17 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
with:
node-version: ${{ matrix.node }}
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run test:node -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1
- run: npx lerna run test:node --since ${{ github.event.pull_request.base.sha }} --concurrency 1
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
flags: node
Expand All @@ -67,7 +67,7 @@ jobs:
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run test:chrome -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1
- run: npx lerna run test:chrome --since ${{ github.event.pull_request.base.sha }} --concurrency 1
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
flags: chrome
Expand All @@ -84,7 +84,7 @@ jobs:
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run test:chrome-webworker -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1
- run: npx lerna run test:chrome-webworker --since ${{ github.event.pull_request.base.sha }} --concurrency 1
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
flags: chrome-webworker
Expand All @@ -101,7 +101,7 @@ jobs:
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run test:firefox -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1
- run: npx lerna run test:firefox --since ${{ github.event.pull_request.base.sha }} --concurrency 1
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
flags: firefox
Expand All @@ -119,7 +119,7 @@ jobs:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npx playwright install --with-deps
- run: npm run test:firefox-webworker -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1
- run: npx lerna run test:firefox-webworker --since ${{ github.event.pull_request.base.sha }} --concurrency 1
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
flags: firefox-webworker
Expand All @@ -138,7 +138,7 @@ jobs:
- uses: ipfs/aegir/actions/cache-node-modules@master
- uses: GabrielBB/xvfb-action@v1
with:
run: npm run test:electron-main -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1 -- -- --bail
run: npx lerna run test:electron-main --since ${{ github.event.pull_request.base.sha }} --concurrency 1 -- -- --bail
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
flags: electron-main
Expand All @@ -162,7 +162,7 @@ jobs:
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm install
- run: npm run build
- run: npm run test:interop -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1 -- -- -- -t ${{ matrix.type }} --bail
- run: npx lerna run test:interop --since ${{ github.event.pull_request.base.sha }} --concurrency 1 -- -- -t ${{ matrix.type }} --bail
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
flags: interop-${{ matrix.type }}
Expand Down Expand Up @@ -190,7 +190,7 @@ jobs:
node-version: lts/*
- run: npm install
- run: npm run build
- run: npm run ${{ matrix.suite }} -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1 -- -- -t ${{ matrix.type }}
- run: npx lerna run ${{ matrix.suite }} --since ${{ github.event.pull_request.base.sha }} --concurrency 1 -- -t ${{ matrix.type }} --bail
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
flags: interface-${{ matrix.type }}
Expand All @@ -208,7 +208,7 @@ jobs:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npx playwright install --with-deps
- run: npm run test:interface:message-port-client -- --since ${{ github.event.pull_request.base.sha }} --concurrency 1
- run: npx lerna run test:interface:message-port-client --since ${{ github.event.pull_request.base.sha }} --concurrency 1 -- -- --bail

release:
runs-on: ubuntu-latest
Expand All @@ -233,6 +233,14 @@ jobs:
release-type: node
manifest-file: .release-please-manifest.json
config-file: .release-please.json
changelog-types: |
[
{ "type": "feat", "section": "Features", "hidden": false },
{ "type": "fix", "section": "Bug Fixes", "hidden": false },
{ "type": "chore", "section": "Trivial Changes", "hidden": false },
{ "type": "docs", "section": "Documentation", "hidden": false },
{ "type": "deps", "section": "Dependencies", "hidden": false }
]
- uses: actions/checkout@v2
with:
fetch-depth: 0
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ tsconfig-types.aegir.json

# Coverage directory used by tools like istanbul
coverage
.coverage
.nyc_output
tests_output
cache
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -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"}
{"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"}
4 changes: 4 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This project is dual licensed under MIT and Apache-2.0.

MIT: https://www.opensource.org/licenses/mit
Apache-2.0: https://www.apache.org/licenses/license-2.0
2 changes: 1 addition & 1 deletion LICENSE-MIT
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
26 changes: 14 additions & 12 deletions docs/BROWSERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,29 @@
- [Code Examples](#code-examples)

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

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

## Limitations of the Browser Context

- 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).
- 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).

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

- 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.

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

- [DHT](https://en.wikipedia.org/wiki/Distributed_hash_table) is not available in JS IPFS yet.
- 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.

[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
relay servers, delegated peer/content routing and preload servers.
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.

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.


## Addressing Limitations
Expand All @@ -40,23 +41,24 @@ We provide a few additional components useful for running JS IPFS in the browser
- [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
- 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).
- Make sure to [run your own rendezvous server](https://github.com/libp2p/js-libp2p-webrtc-star#rendezvous-server-aka-signalling-server).
- [libp2p-webrtc-direct](https://github.com/libp2p/js-libp2p-webrtc-direct) - a WebRTC transport that doesn't require the set up a signalling server.
- [libp2p-webrtc-direct](https://github.com/libp2p/js-libp2p-webrtc-direct) - a WebRTC transport that doesn't require the set up a signaling server.
- Caveat: you can only establish Browser to Node.js and Node.js to Node.js connections.

**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).
**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).

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

## Best Practices

- Configure nodes for using self-hosted `*-star` signalling and transport service. When in doubt, use WebSockets ones.
- Configure nodes for using self-hosted `*-star` signalling and transport service. When in doubt, use WebSockets ones.
- Run your own instance of `*-star` signalling service.
The default ones are under high load and should be used only for tests and development.
- Make sure content added to js-ipfs running in the browser is persisted/cached somewhere on regular IPFS daemon
- 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/)
- Manually `pin` or preload CIDs of interest with `refs -r` beforehand.
- Preload content on the fly using [preload](https://github.com/ipfs/js-ipfs/blob/master/docs/MODULE.md#optionspreload) feature and/or
configure [delegated routing](https://github.com/ipfs/js-ipfs/blob/master/docs/DELEGATE_ROUTERS.md).
- 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).
- 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).
- 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/).

## Code Examples

Expand Down
4 changes: 2 additions & 2 deletions docs/MIGRATION-TO-ASYNC-AWAIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const peerId = PeerId.createFromB58String(peerIdStr)
You can get hold of the `PeerId` class using npm or in a script tag:

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

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

```js
const PeerInfo = require('peer-info')
import { PeerId } from '@libp2p/interfaces/peer-id'
import { PeerId } from '@libp2p/interface-peer-id'
const peerInfo = new PeerInfo(PeerId.createFromB58String(info.id))
info.addrs.forEach(addr => peerInfo.multiaddrs.add(addr))
```
Expand Down
2 changes: 1 addition & 1 deletion docs/MODULE.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Instead of a boolean, you may provide an object with custom initialization optio
- `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`.**
```js
// Generating a Peer ID:
import { PeerId } from '@libp2p/interfaces/peer-id'
import { PeerId } from '@libp2p/interface-peer-id'
// Generates a new Peer ID, complete with public/private keypair
// See https://github.com/libp2p/js-peer-id
const peerId = await PeerId.create({ bits: 2048 })
Expand Down
2 changes: 2 additions & 0 deletions docs/core-api/OBJECT.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Object API <!-- omit in toc -->

> ⚠️ Object API is [deprecated](https://github.com/ipfs/go-ipfs/issues/7936), use [FILES](FILES.md) and [DAG](DAG.md) APIs instead.
- [`ipfs.object.new([options])`](#ipfsobjectnewoptions)
- [Parameters](#parameters)
- [Options](#options)
Expand Down
6 changes: 3 additions & 3 deletions docs/core-api/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# IPFS Core API

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.
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.
This abstraction allows for different implementations including:
1. Full JavaScript native implementation
2. Delgate implementation that invokes another IPFS implementation (e.g., Kubo)

You can use this loose spec as documentation for consuming the core APIs.
You can use this loose spec as documentation for consuming the core APIs.

It is broken up into the following sections:

Expand All @@ -19,7 +19,7 @@ It is broken up into the following sections:
* [KEY.md](KEY.md)
* [MISCELLANEOUS.md](MISCELLANEOUS.md)
* [NAME.md](NAME.md)
* [OBJECT.md](OBJECT.md)
* [OBJECT.md](OBJECT.md) ([deprecated](https://github.com/ipfs/go-ipfs/issues/7936), use the [DAG API](DAG.md) instead)
* [PIN.md](PIN.md)
* [PUBSUB.md](PUBSUB.md)
* [REFS.md](REFS.md)
Expand Down
49 changes: 46 additions & 3 deletions docs/upgrading/v0.62-v0.63.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<!--Specify versions for migration below-->
# Migrating to ipfs@0.63 and ipfs-core@0.15 <!-- omit in toc -->

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

- [ESM](#esm)
- [libp2p@0.37.x](#libp2p037x)
- [TypeScript and ESM](#typescript-and-esm)
- [`libp2p@0.37.x`](#libp2p037x)
- [PeerIds](#peerids)
- [multiaddrs](#multiaddrs)

Expand Down Expand Up @@ -34,11 +35,53 @@ async function loadIpfs () {
}
```

### TypeScript and ESM

When authoring typescript it can often look like you are writing ESM:

```ts
import { create } from 'ipfs-core'

create()
```

When this is transpiled to JavaScript the default settings will emit CJS which will fail at runtime:

```js
"use strict";
exports.__esModule = true;
var ipfs_core_1 = require("ipfs-core");
(0, ipfs_core_1.create)();
```

You may also see errors about private identifiers:

```console
node_modules/@libp2p/interfaces/dist/src/events.d.ts:19:5 - error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.

19 #private;
~~~~~~~~
```

To build correctly with ESM as a target, update your `tsconfig.json` to include the following:

```js
{
"module": "es2020", // ensures output is ESM
"target": "es2020", // support modern features like private identifiers
// other settings
}
```

They must both be set to `es2020` at least, more recent versions will also work.

If in doubt, examine the JavaScript files `tsc` emits and ensure that any `ipfs` modules are being loaded with `import` and not `require`.

## `libp2p@0.37.x`

`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.

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.
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.

## PeerIds

Expand Down
16 changes: 16 additions & 0 deletions docs/upgrading/v0.63-v0.64.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!--Specify versions for migration below-->
# Migrating to ipfs@0.64 and ipfs-core@0.16 <!-- omit in toc -->

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

- [libp2p](#libp2p)

## libp2p

The upgrade to `ipfs@0.64.x` incorporates an update to `libp2p@0.38.x` but no API changes.

If your application uses only the default libp2p config there is nothing to do.

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.
Loading

0 comments on commit 8bbae09

Please sign in to comment.