diff --git a/.github/dependabot.yml b/.github/dependabot.yml index de46e32616..0bc3b42de8 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -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)" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0d3100ce79..b16ab31931 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 }} @@ -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 }} @@ -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 @@ -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 diff --git a/.gitignore b/.gitignore index 12652bc725..7ebda0ab08 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ tsconfig-types.aegir.json # Coverage directory used by tools like istanbul coverage +.coverage .nyc_output tests_output cache diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 2b183f8348..6f9bc03873 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/LICENSE @@ -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 diff --git a/LICENSE-MIT b/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -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. \ No newline at end of file +THE SOFTWARE. diff --git a/docs/BROWSERS.md b/docs/BROWSERS.md index 25708df1d8..33366f26a7 100644 --- a/docs/BROWSERS.md +++ b/docs/BROWSERS.md @@ -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 @@ -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 diff --git a/docs/MIGRATION-TO-ASYNC-AWAIT.md b/docs/MIGRATION-TO-ASYNC-AWAIT.md index a30b3d8af3..718071a0d4 100644 --- a/docs/MIGRATION-TO-ASYNC-AWAIT.md +++ b/docs/MIGRATION-TO-ASYNC-AWAIT.md @@ -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) ``` @@ -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)) ``` diff --git a/docs/MODULE.md b/docs/MODULE.md index 67de596e13..23e612d708 100644 --- a/docs/MODULE.md +++ b/docs/MODULE.md @@ -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 }) diff --git a/docs/core-api/OBJECT.md b/docs/core-api/OBJECT.md index 3d5667e3d6..bc48225f91 100644 --- a/docs/core-api/OBJECT.md +++ b/docs/core-api/OBJECT.md @@ -1,5 +1,7 @@ # Object API +> ⚠️ 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) diff --git a/docs/core-api/README.md b/docs/core-api/README.md index 46c0987165..6b058fb8c7 100644 --- a/docs/core-api/README.md +++ b/docs/core-api/README.md @@ -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: @@ -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) diff --git a/docs/upgrading/v0.62-v0.63.md b/docs/upgrading/v0.62-v0.63.md index e931a9aa49..ed3dcb1c8e 100644 --- a/docs/upgrading/v0.62-v0.63.md +++ b/docs/upgrading/v0.62-v0.63.md @@ -1,12 +1,13 @@ # Migrating to ipfs@0.63 and ipfs-core@0.15 -> 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 - [ESM](#esm) -- [libp2p@0.37.x](#libp2p037x) + - [TypeScript and ESM](#typescript-and-esm) +- [`libp2p@0.37.x`](#libp2p037x) - [PeerIds](#peerids) - [multiaddrs](#multiaddrs) @@ -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 diff --git a/docs/upgrading/v0.63-v0.64.md b/docs/upgrading/v0.63-v0.64.md new file mode 100644 index 0000000000..cc685da864 --- /dev/null +++ b/docs/upgrading/v0.63-v0.64.md @@ -0,0 +1,16 @@ + +# Migrating to ipfs@0.64 and ipfs-core@0.16 + +> A migration guide for refactoring your application code from `ipfs@0.63.x` to `ipfs@0.64.x` + +## Table of Contents + +- [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. diff --git a/docs/upgrading/v0.64-v0.65.md b/docs/upgrading/v0.64-v0.65.md new file mode 100644 index 0000000000..b765f0c91b --- /dev/null +++ b/docs/upgrading/v0.64-v0.65.md @@ -0,0 +1,23 @@ + +# Migrating to ipfs@0.65 and ipfs-core@0.17 + +> A migration guide for refactoring your application code from `ipfs@0.64.x` to `ipfs@0.65.x` + +## Table of Contents + +- [libp2p](#libp2p) +- [multiformats](#multiformats) + +## libp2p + +The upgrade to `ipfs@0.65.x` incorporates an update to `libp2p@0.40.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.40.x` upgrade guide](https://github.com/libp2p/js-libp2p/blob/master/doc/migrations/v0.39-v0.40.md) for any changes you need to make. + +## multiformats + +`ipfs@0.65.x` now uses `multiformats@10.x.x`, this means instances of the `CID` class now come from that module and not `multiformats@9.x.x` so any `instanceof` checks your codebase has may break if instances are compare to the class loaded from a different module version. + +If your project also has a dependency on the `multiformats` module, it should be updated to `10.x.x` in line with js-ipfs. diff --git a/lerna.json b/lerna.json index 2b32098657..86c45bda4a 100644 --- a/lerna.json +++ b/lerna.json @@ -1,8 +1,6 @@ { "version": "independent", - "packages": [ - "packages/*" - ], + "useWorkspaces": true, "command": { "bootstrap": { "hoist": true diff --git a/package.json b/package.json index cbf0e34e92..824f5a9ed5 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,20 @@ "name": "js-ipfs", "version": "1.0.0", "description": "JavaScript implementation of the IPFS specification", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "private": true, "scripts": { "link": "lerna link", "reset": "lerna run clean && rimraf packages/*/node_modules node_modules package-lock.json packages/*/package-lock.json", @@ -44,268 +58,19 @@ "docker:rc:push-next": "docker push ipfs/js-ipfs:next", "docker:rc:push-rc": "docker push ipfs/js-ipfs:v`npm show ipfs@next version -q`" }, - "eslintConfig": { - "extends": "ipfs", - "ignorePatterns": [ - "!.aegir.js" - ] - }, "devDependencies": { - "lerna": "^4.0.0", + "lerna": "^6.0.1", "node-fetch": "npm:@achingbrain/node-fetch@^2.6.4", "npm-run-all": "^4.1.5", "rimraf": "^3.0.2" }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" + "eslintConfig": { + "extends": "ipfs", + "ignorePatterns": [ + "!.aegir.js" + ] }, - "private": true, "workspaces": [ "packages/*" - ], - "engines": { - "npm": ">=7.0.0" - }, - "contributors": [ - "David Dias ", - "achingbrain ", - "Alan Shaw ", - "Friedel Ziegelmayer ", - "Juan Batiz-Benet ", - "Vasco Santos ", - "Hugo Dias ", - "Henrique Dias ", - "Volker Mische ", - "ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ ", - "Marcin Rataj ", - "Stephen Whitmore ", - "Jacob Heun ", - "Francisco Baio Dias ", - "Matt Bell ", - "Richard Schneider ", - "Pedro Teixeira ", - "Travis Person ", - "Kristoffer Ström ", - "Dmitriy Ryajov ", - "Irakli Gozalishvili ", - "Oli Evans ", - "nginnever ", - "Richard Littauer ", - "dirkmc ", - "Diogo Silva ", - "Pedro Santos ", - "Connor Keenan ", - "kumavis ", - "Harlan T Wood ", - "Nitin Patel <31539366+niinpatel@users.noreply.github.com>", - "Pascal Precht ", - "Andrew Nesbitt ", - "Hector Sanjuan ", - "Maciej Krüger ", - "Michael Garvin ", - "Steven Allen ", - "Michael Muré ", - "Łukasz Magiera ", - "João Antunes ", - "Enrico Marino ", - "Teri Chadbourne ", - "Christian Couder ", - "Rob Brackett ", - "Prabhakar Poudel ", - "Mithgol ", - "Haad ", - "Jonathan ", - "Xmader ", - "Sangwon Hong ", - "Joonas Koivunen ", - "Gavin McDermott ", - "Mikeal Rogers ", - "Dzmitry Das ", - "Rod Vagg ", - "Andrew de Andrade ", - "Matt Ober ", - "Максим Ильин ", - "Ryan Bell ", - "Alex Mingoia ", - "RasmusErik Voel Jensen ", - "Marius Darila ", - "Yahya ", - "anders ", - "bluelovers ", - "Paulo Rodrigues ", - "haad ", - "Jeromy ", - "0xflotus <0xflotus@gmail.com>", - "Andrey ", - "André Cruz ", - "Antonio Tenorio-Fornés ", - "Dan Ordille ", - "Dan Shields <35669742+NukeManDan@users.noreply.github.com>", - "David Gilbertson ", - "Doug A ", - "Georgios Rassias ", - "Gorka Ludlow ", - "Jeff Downie ", - "Jim Pick ", - "Jonybang ", - "Kevin Simper ", - "Kevin Wang ", - "Ludwig <35169452+ludwigschubi@users.noreply.github.com>", - "Mark Robert Henderson ", - "Maxime Lathuilière ", - "Molly ", - "Nuno Nogueira ", - "Portia Burton ", - "Raoul Millais ", - "Sid Harder ", - "Vu Tien Khang ", - "reasv <7143787+reasv@users.noreply.github.com>", - "samuli ", - "shunkin ", - "tcme ", - "seungwon-kang ", - "Arpit Agarwal ", - "Jason Papakostas ", - "Ilya Kreymer ", - "Julien Malard ", - "phillmac ", - "Holodisc ", - "Lars Gierth ", - "priecint ", - "Lukas Drgon ", - "Heo Sangmin ", - "Manuel Spagnolo ", - "Henry Rodrick ", - "Marcus Bernales ", - "Harsh Vakharia ", - "Alen Siljak ", - "Mat Kelly ", - "Haoliang Yu ", - "Hannah Howard ", - "Matt Zumwalt ", - "robbsolter <35879806+robbsolter@users.noreply.github.com>", - "Michael Bradley ", - "Guilherme Pacheco ", - "Gregory Oakes ", - "Michelle Lee ", - "Grant Herman ", - "Mitar ", - "Gopalakrishna Palem ", - "Mohamed Abdulaziz ", - "ron litzenberger ", - "Mounish Sai ", - "My9Bot <34904312+My9Bot@users.noreply.github.com>", - "Nate Foss ", - "Adin Schmahmann ", - "Nick Poulden ", - "Nicolás Santángelo ", - "Giuseppe Bertone ", - "sarthak khandelwal ", - "Níckolas Goline ", - "Giles ", - "Olivério Sousa <47525443+oliveriosousa@users.noreply.github.com>", - "Orie Steele ", - "Oskar Nyberg ", - "Padmashree Jha ", - "George Shammas ", - "Pau Ramon Revilla ", - "Paul Cowgill ", - "Gabriel Garrido Calvo ", - "Filip Š ", - "Fil ", - "Pete Thomas ", - "Philipp Krüger ", - "Felix Yan ", - "Qmstream <51881352+Qmstream@users.noreply.github.com>", - "Adam Uhlíř ", - "Faheel Ahmad ", - "Revat Arora <70435319+CypherX7@users.noreply.github.com>", - "Donatas Stundys ", - "Dominic Della Valle ", - "Rod Keys ", - "Dmitry Nikulin ", - "Roman Khafizianov ", - "Dietrich Ayala ", - "Davide Icardi ", - "Sergey Ukustov ", - "swedneck <40505480+swedneck@users.noreply.github.com>", - "SidHarder ", - "A_A <21040751+Otto-AA@users.noreply.github.com>", - "David da Silva ", - "Steven Vandevelde ", - "Subin Siby ", - "TJKoury ", - "Tapasweni Pathak ", - "Tara Vancil ", - "Tejas Kumthekar <6154318+tk26@users.noreply.github.com>", - "Terence Pae ", - "David Braun ", - "Thiago Delgado ", - "Thorsten Zoerner ", - "Timothé ", - "David ", - "Danny ", - "thattommyhall ", - "Uroš Jurglič ", - "Daniela Borges Matos de Carvalho ", - "Daniel J. O'Quinn ", - "Victor Bjelkholm ", - "Daniel Constantin ", - "Vincent Martin ", - "Daniel Buchner ", - "Alex North ", - "Vutsal Singhal ", - "Xiao Liang ", - "Dafeng ", - "Connor White ", - "Yole ", - "Yusef Napora ", - "Zhiyuan Lin ", - "Clemo ", - "Christian Paul ", - "arjunraghurama ", - "bitspill ", - "Chirag Shinde ", - "datafatmunger ", - "Chance Hudson ", - "Caio Gondim ", - "CSDUMMI <31551856+CSDUMMI@users.noreply.github.com>", - "CHEVALAY JOSSELIN ", - "Bruno Zell ", - "dmitriy ryajov ", - "elsehow ", - "ethers ", - "Bruno Barbieri ", - "Brian Vander Schaaf ", - "Brandon ", - "Bernard Mordan ", - "hapsody ", - "imestin <34135450+imestin@users.noreply.github.com>", - "isan_rivkin ", - "javaskript <14116782+javaskript@users.noreply.github.com>", - "Ayush Mahajan ", - "jonahweissman <19804455+jonahweissman@users.noreply.github.com>", - "kevingzhang ", - "klueq <43359723+klueq@users.noreply.github.com>", - "James Halliday ", - "Jason Carver ", - "Jeeyong Um ", - "leekt216 ", - "nature hacker <30657227+z89@users.noreply.github.com>", - "Jessica Schilling ", - "Arkadiy Kukarkin ", - "Joe Turgeon ", - "Joel Gustafson ", - "Johannes Wikner ", - "John Kane ", - "Johnny <9611008+johnnymatthews@users.noreply.github.com>", - "Jon Schlinkert ", - "Jade Meskill ", - "Jonathan Commins ", - "noah the goodra ", - "Jacob Karlsson ", - "Jorropo ", - "João Santos " ] } diff --git a/packages/interface-ipfs-core/CHANGELOG.md b/packages/interface-ipfs-core/CHANGELOG.md index d2b0c1f2ec..a0bb3b192a 100644 --- a/packages/interface-ipfs-core/CHANGELOG.md +++ b/packages/interface-ipfs-core/CHANGELOG.md @@ -3,6 +3,62 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.157.0](https://www.github.com/ipfs/js-ipfs/compare/interface-ipfs-core-v0.156.1...interface-ipfs-core-v0.157.0) (2022-10-24) + + +### ⚠ BREAKING CHANGES + +* ipfs is now bundled with libp2p@0.40.x which has different config +* require IPNS V2 signatures (#4207) + +### Features + +* upgrade libp2p to 0.40.x ([#4237](https://www.github.com/ipfs/js-ipfs/issues/4237)) ([0cee4a4](https://www.github.com/ipfs/js-ipfs/commit/0cee4a4c55767022584dcbade0b0b9b43326f9c9)) + + +### Bug Fixes + +* require IPNS V2 signatures ([#4207](https://www.github.com/ipfs/js-ipfs/issues/4207)) ([d1b0a8a](https://www.github.com/ipfs/js-ipfs/commit/d1b0a8a71073b4ece0dbda5a5405d76dd8d5b358)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.12.1 to ^0.13.0 + +### [0.156.1](https://www.github.com/ipfs/js-ipfs/compare/interface-ipfs-core-v0.156.0...interface-ipfs-core-v0.156.1) (2022-09-21) + + +### Bug Fixes + +* update @multiformats/multiadd to 11.0.0 ([2a830bf](https://www.github.com/ipfs/js-ipfs/commit/2a830bf58a5929fcce51dede871c99f62192fbda)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.12.0 to ^0.12.1 + +## [0.156.0](https://www.github.com/ipfs/js-ipfs/compare/interface-ipfs-core-v0.155.2...interface-ipfs-core-v0.156.0) (2022-09-06) + + +### ⚠ BREAKING CHANGES + +* update to libp2p@0.38.x (#4151) + +### deps + +* update to libp2p@0.38.x ([#4151](https://www.github.com/ipfs/js-ipfs/issues/4151)) ([39dbf70](https://www.github.com/ipfs/js-ipfs/commit/39dbf708ec31b263115e44f420651fa4e056a89e)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.11.0 to ^0.12.0 + ### [0.155.2](https://www.github.com/ipfs/js-ipfs/compare/interface-ipfs-core-v0.155.1...interface-ipfs-core-v0.155.2) (2022-06-24) @@ -2395,4 +2451,4 @@ Signed-off-by: Alan Shaw ### Bug Fixes -* remove superfluous console.logs ([442ea74](https://github.com/ipfs/interface-ipfs-core/commit/442ea74)) +* remove superfluous console.logs ([442ea74](https://github.com/ipfs/interface-ipfs-core/commit/442ea74)) \ No newline at end of file diff --git a/packages/interface-ipfs-core/LICENSE b/packages/interface-ipfs-core/LICENSE index 7d37874703..20ce483c86 100644 --- a/packages/interface-ipfs-core/LICENSE +++ b/packages/interface-ipfs-core/LICENSE @@ -1,21 +1,4 @@ -The MIT License (MIT) +This project is dual licensed under MIT and Apache-2.0. -Copyright (c) 2018 Protocol Labs, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -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. +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/interface-ipfs-core/LICENSE-APACHE b/packages/interface-ipfs-core/LICENSE-APACHE new file mode 100644 index 0000000000..14478a3b60 --- /dev/null +++ b/packages/interface-ipfs-core/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/interface-ipfs-core/LICENSE-MIT b/packages/interface-ipfs-core/LICENSE-MIT new file mode 100644 index 0000000000..72dc60d84b --- /dev/null +++ b/packages/interface-ipfs-core/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +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. diff --git a/packages/interface-ipfs-core/README.md b/packages/interface-ipfs-core/README.md index 29dea01059..4e5b8b7989 100644 --- a/packages/interface-ipfs-core/README.md +++ b/packages/interface-ipfs-core/README.md @@ -1,20 +1,20 @@ # interface-ipfs-core -[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) -[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) -[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) -[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme) -[![Dependency Status](https://david-dm.org/ipfs/js-ipfs/status.svg?style=flat-square&path=packages/interface-ipfs-core)](https://david-dm.org/ipfs/js-ipfs?path=packages/interface-ipfs-core) +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -> A test suite and interface you can use to implement an IPFS core interface. +> A test suite and interface you can use to implement a IPFS core interface. -## Table of Contents +## Table of contents +- [Install](#install) - [Background](#background) - [Core API](#core-api) - [Modules that implement the interface](#modules-that-implement-the-interface) - [Badge](#badge) -- [Install](#install) - [Usage](#usage) - [Running tests](#running-tests) - [Running tests by command](#running-tests-by-command) @@ -22,9 +22,14 @@ - [Running only specific tests](#running-only-specific-tests) - [Skipping tests](#skipping-tests) - [Skipping specific tests](#skipping-specific-tests) -- [Contribute](#contribute) - - [Want to hack on IPFS?](#want-to-hack-on-ipfs) - [License](#license) +- [Contribute](#contribute) + +## Install + +```console +$ npm i interface-ipfs-core +``` ## Background @@ -54,10 +59,6 @@ Include this badge in your readme if you make a new module that implements inter [![IPFS Core API Compatible](https://cdn.rawgit.com/ipfs/interface-ipfs-core/master/img/badge.svg)](https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core) ``` -## Install - -In JavaScript land: - ```console $ npm install interface-ipfs-core ``` @@ -163,18 +164,23 @@ tests.repo(createCommon, { }) ``` -## Contribute +## License + +Licensed under either of -Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/js-ipfs/issues)! +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) -This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). +## Contribute -### Want to hack on IPFS? +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). -[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. -## License +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). -Copyright (c) Protocol Labs, Inc. under the **MIT License**. See [LICENSE.md](./LICENSE.md) for details. +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) [UnixFS]: https://github.com/ipfs/specs/tree/master/unixfs diff --git a/packages/interface-ipfs-core/package.json b/packages/interface-ipfs-core/package.json index 2416d78ab3..1ff79ce8e3 100644 --- a/packages/interface-ipfs-core/package.json +++ b/packages/interface-ipfs-core/package.json @@ -1,10 +1,25 @@ { "name": "interface-ipfs-core", - "version": "0.155.2", + "version": "0.157.0", "description": "A test suite and interface you can use to implement a IPFS core interface.", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, + "keywords": [ + "IPFS" + ], + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", "typesVersions": { "*": { "*": [ @@ -22,10 +37,17 @@ } }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./src/index.js" + } + }, "eslintConfig": { "extends": "ipfs", "parserOptions": { @@ -35,149 +57,66 @@ "test/fixtures/*" ] }, - "exports": { - ".": { - "import": "./src/index.js" - } - }, - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "browser": { - "fs": false, - "os": false, - "path": false - }, "scripts": { "clean": "aegir clean", "build": "aegir build && copyfiles './test/fixtures/**/*' ./dist", "lint": "aegir lint", - "dep-check": "aegir dep-check -i ipfs-core-types -i copyfiles" + "dep-check": "aegir dep-check -i ipfs-core-types -i copyfiles -i @libp2p/interfaces" }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" - }, - "keywords": [ - "IPFS" - ], - "license": "MIT", "dependencies": { - "@ipld/car": "^4.1.0", - "@ipld/dag-cbor": "^7.0.0", - "@ipld/dag-pb": "^2.1.3", - "@libp2p/crypto": "^0.22.9", - "@libp2p/interfaces": "^2.0.4", + "@ipld/car": "^5.0.0", + "@ipld/dag-cbor": "^8.0.0", + "@ipld/dag-pb": "^3.0.0", + "@libp2p/crypto": "^1.0.0", + "@libp2p/interface-peer-id": "^1.0.4", + "@libp2p/interfaces": "^3.0.3", "@libp2p/peer-id": "^1.1.10", "@libp2p/peer-id-factory": "^1.0.10", - "@libp2p/websockets": "^1.0.8", - "@multiformats/multiaddr": "^10.0.0", - "@types/pako": "^1.0.2", - "@types/readable-stream": "^2.3.11", + "@libp2p/websockets": "^5.0.0", + "@multiformats/multiaddr": "^11.0.0", + "@types/node": "^18.0.0", + "@types/pako": "^2.0.0", + "@types/readable-stream": "^2.3.13", "aegir": "^37.0.11", - "blockstore-core": "^1.0.2", + "blockstore-core": "^2.0.1", "copyfiles": "^2.4.1", - "dag-jose": "^1.0.0", + "dag-jose": "^3.0.1", "delay": "^5.0.0", - "did-jwt": "^5.12.1", + "did-jwt": "^6.2.0", "err-code": "^3.0.1", - "ipfs-core-types": "^0.11.1", - "ipfs-unixfs": "^6.0.3", - "ipfs-unixfs-importer": "^9.0.3", + "ipfs-core-types": "^0.13.0", + "ipfs-unixfs": "^8.0.0", + "ipfs-unixfs-importer": "^11.0.0", "ipfs-utils": "^9.0.6", - "ipns": "^1.0.0", - "is-ipfs": "^6.0.1", + "ipns": "^4.0.0", + "is-ipfs": "^7.0.0", "iso-random-stream": "^2.0.2", - "it-all": "^1.0.4", - "it-buffer-stream": "^2.0.0", - "it-concat": "^2.0.0", - "it-drain": "^1.0.3", - "it-first": "^1.0.4", - "it-last": "^1.0.4", - "it-map": "^1.0.4", + "it-all": "^2.0.0", + "it-buffer-stream": "^3.0.0", + "it-concat": "^3.0.1", + "it-drain": "^2.0.0", + "it-first": "^2.0.0", + "it-last": "^2.0.0", + "it-map": "^2.0.0", "it-pipe": "^2.0.3", - "it-pushable": "^2.0.1", - "it-tar": "^5.0.0", - "it-to-buffer": "^2.0.0", + "it-pushable": "^3.0.0", + "it-tar": "^6.0.0", + "it-to-buffer": "^3.0.0", "merge-options": "^3.0.4", - "multiformats": "^9.5.1", - "nanoid": "^3.1.23", + "multiformats": "^10.0.0", + "nanoid": "^4.0.0", "p-defer": "^4.0.0", "p-map": "^5.3.0", "p-retry": "^5.1.0", - "p-wait-for": "^4.1.0", + "p-wait-for": "^5.0.0", "pako": "^2.0.4", - "readable-stream": "^3.4.0", + "readable-stream": "^4.0.0", "sinon": "^14.0.0", - "uint8arrays": "^3.0.0" + "uint8arrays": "^4.0.2" }, - "contributors": [ - "Alan Shaw ", - "Alan Shaw ", - "Alex Potsides ", - "Andrey ", - "Dan Ordille ", - "Dan Shields <35669742+NukeManDan@users.noreply.github.com>", - "David Dias ", - "Dmitriy Ryajov ", - "Enrico Marino ", - "Friedel Ziegelmayer ", - "Giles ", - "Haad ", - "Henrique Dias ", - "Hugo Dias ", - "Hugo Dias ", - "Jacob Heun ", - "Jacob Karlsson ", - "Jason Papakostas ", - "Jim Pick ", - "Joel Gustafson ", - "Jonathan ", - "Kevin Simper ", - "Maciej Krüger ", - "Marcin Rataj ", - "Marius Darila ", - "Matt Ober ", - "Matt Zumwalt ", - "Michael Garvin ", - "Michael Muré ", - "Mikeal Rogers ", - "Nicolás Santángelo ", - "Nitin Patel <31539366+niinpatel@users.noreply.github.com>", - "Oli Evans ", - "Pascal Precht ", - "Pedro Santos ", - "Pedro Santos ", - "Pedro Teixeira ", - "Prabhakar Poudel ", - "Richard Littauer ", - "Richard Schneider ", - "Ryan Bell ", - "Sangwon Hong ", - "Stephen Whitmore ", - "Steven Allen ", - "Teri Chadbourne ", - "Thiago Delgado ", - "Travis Person ", - "Travis Person ", - "Vasco Santos ", - "Vasco Santos ", - "Volker Mische ", - "Vutsal Singhal ", - "dirkmc ", - "greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com>", - "greenkeeper[bot] ", - "greenkeeperio-bot ", - "haad ", - "isan_rivkin ", - "klueq <43359723+klueq@users.noreply.github.com>", - "kumavis ", - "nginnever ", - "reasv <7143787+reasv@users.noreply.github.com>", - "ron litzenberger ", - "shunkin ", - "tcme ", - "victorbjelkholm ", - "Łukasz Magiera ", - "Максим Ильин " - ] + "browser": { + "fs": false, + "os": false, + "path": false + } } diff --git a/packages/interface-ipfs-core/src/add.js b/packages/interface-ipfs-core/src/add.js index 154fac2303..38cd90175b 100644 --- a/packages/interface-ipfs-core/src/add.js +++ b/packages/interface-ipfs-core/src/add.js @@ -30,7 +30,7 @@ export function testAdd (factory, options) { const it = getIt(options) describe('.add', function () { - this.timeout(540 * 1000) + this.timeout(1080 * 1000) /** @type {import('ipfs-core-types').IPFS} */ let ipfs diff --git a/packages/interface-ipfs-core/src/bitswap/utils.js b/packages/interface-ipfs-core/src/bitswap/utils.js index 68957d217c..04a942e869 100644 --- a/packages/interface-ipfs-core/src/bitswap/utils.js +++ b/packages/interface-ipfs-core/src/bitswap/utils.js @@ -1,7 +1,7 @@ import delay from 'delay' /** - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId */ /** diff --git a/packages/interface-ipfs-core/src/bootstrap/add.js b/packages/interface-ipfs-core/src/bootstrap/add.js index e7d26343a0..c9069ebab9 100644 --- a/packages/interface-ipfs-core/src/bootstrap/add.js +++ b/packages/interface-ipfs-core/src/bootstrap/add.js @@ -2,10 +2,10 @@ import { expect } from 'aegir/chai' import { getDescribe, getIt } from '../utils/mocha.js' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr, isMultiaddr } from '@multiformats/multiaddr' const invalidArg = 'this/Is/So/Invalid/' -const validIp4 = new Multiaddr('/ip4/104.236.176.52/tcp/4001/p2p/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z') +const validIp4 = multiaddr('/ip4/104.236.176.52/tcp/4001/p2p/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z') /** * @typedef {import('ipfsd-ctl').Factory} Factory @@ -59,7 +59,7 @@ export function testAdd (factory, options) { }) it('add a peer to the bootstrap list', async () => { - const peer = new Multiaddr('/ip4/111.111.111.111/tcp/1001/p2p/QmXFX2P5ammdmXQgfqGkfswtEVFsZUJ5KeHRXQYCTdiTAb') + const peer = multiaddr('/ip4/111.111.111.111/tcp/1001/p2p/QmXFX2P5ammdmXQgfqGkfswtEVFsZUJ5KeHRXQYCTdiTAb') const res = await ipfs.bootstrap.add(peer) expect(res).to.be.eql({ Peers: [peer] }) @@ -67,7 +67,7 @@ export function testAdd (factory, options) { const list = await ipfs.bootstrap.list() expect(list.Peers).to.deep.include(peer) - expect(list.Peers.every(ma => Multiaddr.isMultiaddr(ma))).to.be.true() + expect(list.Peers.every(ma => isMultiaddr(ma))).to.be.true() }) }) } diff --git a/packages/interface-ipfs-core/src/bootstrap/clear.js b/packages/interface-ipfs-core/src/bootstrap/clear.js index bec9fe1d3b..d1b15261fd 100644 --- a/packages/interface-ipfs-core/src/bootstrap/clear.js +++ b/packages/interface-ipfs-core/src/bootstrap/clear.js @@ -2,7 +2,7 @@ import { expect } from 'aegir/chai' import { getDescribe, getIt } from '../utils/mocha.js' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr, isMultiaddr } from '@multiformats/multiaddr' /** * @typedef {import('ipfsd-ctl').Factory} Factory @@ -16,7 +16,7 @@ export function testClear (factory, options) { const describe = getDescribe(options) const it = getIt(options) - const validIp4 = new Multiaddr('/ip4/104.236.176.52/tcp/4001/p2p/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z') + const validIp4 = multiaddr('/ip4/104.236.176.52/tcp/4001/p2p/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z') describe('.bootstrap.clear', function () { this.timeout(100 * 1000) @@ -50,7 +50,7 @@ export function testClear (factory, options) { expect(removedPeers.sort()).to.deep.equal(addedPeers.sort()) - expect(removedPeers.every(ma => Multiaddr.isMultiaddr(ma))).to.be.true() + expect(removedPeers.every(ma => isMultiaddr(ma))).to.be.true() }) }) } diff --git a/packages/interface-ipfs-core/src/bootstrap/list.js b/packages/interface-ipfs-core/src/bootstrap/list.js index b82abecde5..3ebf4159d6 100644 --- a/packages/interface-ipfs-core/src/bootstrap/list.js +++ b/packages/interface-ipfs-core/src/bootstrap/list.js @@ -2,7 +2,7 @@ import { expect } from 'aegir/chai' import { getDescribe, getIt } from '../utils/mocha.js' -import { Multiaddr } from '@multiformats/multiaddr' +import { isMultiaddr } from '@multiformats/multiaddr' /** * @typedef {import('ipfsd-ctl').Factory} Factory @@ -31,7 +31,7 @@ export function testList (factory, options) { const peers = res.Peers expect(peers).to.be.an('Array') - expect(peers.every(ma => Multiaddr.isMultiaddr(ma))).to.be.true() + expect(peers.every(ma => isMultiaddr(ma))).to.be.true() }) }) } diff --git a/packages/interface-ipfs-core/src/bootstrap/reset.js b/packages/interface-ipfs-core/src/bootstrap/reset.js index d98f87dda8..3685d8e46d 100644 --- a/packages/interface-ipfs-core/src/bootstrap/reset.js +++ b/packages/interface-ipfs-core/src/bootstrap/reset.js @@ -2,7 +2,7 @@ import { expect } from 'aegir/chai' import { getDescribe, getIt } from '../utils/mocha.js' -import { Multiaddr } from '@multiformats/multiaddr' +import { isMultiaddr } from '@multiformats/multiaddr' /** * @typedef {import('ipfsd-ctl').Factory} Factory @@ -43,7 +43,7 @@ export function testReset (factory, options) { const removedPeers = rmRes.Peers expect(removedPeers.sort()).to.deep.equal(addedPeers.sort()) - expect(addedPeers.every(ma => Multiaddr.isMultiaddr(ma))).to.be.true() + expect(addedPeers.every(ma => isMultiaddr(ma))).to.be.true() }) }) } diff --git a/packages/interface-ipfs-core/src/bootstrap/rm.js b/packages/interface-ipfs-core/src/bootstrap/rm.js index 4768af9e66..02d28d3bd1 100644 --- a/packages/interface-ipfs-core/src/bootstrap/rm.js +++ b/packages/interface-ipfs-core/src/bootstrap/rm.js @@ -2,7 +2,7 @@ import { expect } from 'aegir/chai' import { getDescribe, getIt } from '../utils/mocha.js' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr, isMultiaddr } from '@multiformats/multiaddr' /** * @typedef {import('ipfsd-ctl').Factory} Factory @@ -17,7 +17,7 @@ export function testRm (factory, options) { const it = getIt(options) const invalidArg = 'this/Is/So/Invalid/' - const validIp4 = new Multiaddr('/ip4/104.236.176.52/tcp/4001/p2p/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z') + const validIp4 = multiaddr('/ip4/104.236.176.52/tcp/4001/p2p/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z') describe('.bootstrap.rm', function () { this.timeout(100 * 1000) @@ -47,7 +47,7 @@ export function testRm (factory, options) { }) it('removes a peer from the bootstrap list', async () => { - const peer = new Multiaddr('/ip4/111.111.111.111/tcp/1001/p2p/QmXFX2P5ammdmXQgfqGkfswtEVFsZUJ5KeHRXQYCTdiTAb') + const peer = multiaddr('/ip4/111.111.111.111/tcp/1001/p2p/QmXFX2P5ammdmXQgfqGkfswtEVFsZUJ5KeHRXQYCTdiTAb') await ipfs.bootstrap.add(peer) let list = await ipfs.bootstrap.list() expect(list.Peers).to.deep.include(peer) @@ -57,7 +57,7 @@ export function testRm (factory, options) { list = await ipfs.bootstrap.list() expect(list.Peers).to.not.deep.include(peer) - expect(res.Peers.every(ma => Multiaddr.isMultiaddr(ma))).to.be.true() + expect(res.Peers.every(ma => isMultiaddr(ma))).to.be.true() }) }) } diff --git a/packages/interface-ipfs-core/src/dag/get.js b/packages/interface-ipfs-core/src/dag/get.js index 2507baa480..607e47f6d7 100644 --- a/packages/interface-ipfs-core/src/dag/get.js +++ b/packages/interface-ipfs-core/src/dag/get.js @@ -105,7 +105,7 @@ export function testGet (factory, options) { await ipfs.dag.put(nodePb, { storeCodec: 'dag-pb', hashAlg: 'sha2-256' }) await ipfs.dag.put(nodeCbor, { storeCodec: 'dag-cbor', hashAlg: 'sha2-256' }) - const signer = ES256KSigner('278a5de700e29faae8e40e366ec5012b5ec63d36ec77e8a2417154cc1d25383f') + const signer = ES256KSigner(uint8ArrayFromString('278a5de700e29faae8e40e366ec5012b5ec63d36ec77e8a2417154cc1d25383f', 'hex')) nodeJose = await createJWS(base64url.encode(cidCbor.bytes).slice(1), signer) cidJose = CID.createV1(dagJOSE.code, await sha256.digest(dagJOSE.encode(nodeJose))) await ipfs.dag.put(nodeJose, { storeCodec: dagJOSE.name, hashAlg: 'sha2-256' }) diff --git a/packages/interface-ipfs-core/src/files/write.js b/packages/interface-ipfs-core/src/files/write.js index f3c7116ff2..4dedb4080b 100644 --- a/packages/interface-ipfs-core/src/files/write.js +++ b/packages/interface-ipfs-core/src/files/write.js @@ -204,7 +204,7 @@ export function testWrite (factory, options) { }) it('writes a small file using an HTML5 Blob (Browser only)', async function () { - if (!global.Blob) { + if (!global.Blob || !global.FileReader) { // @ts-expect-error this is mocha return this.skip() } diff --git a/packages/interface-ipfs-core/src/miscellaneous/dns.js b/packages/interface-ipfs-core/src/miscellaneous/dns.js index 36270e5e1d..3ca5b7d54f 100644 --- a/packages/interface-ipfs-core/src/miscellaneous/dns.js +++ b/packages/interface-ipfs-core/src/miscellaneous/dns.js @@ -29,8 +29,10 @@ export function testDns (factory, options) { after(() => factory.clean()) it('should non-recursively resolve ipfs.io', async function () { + const domain = 'ipfs.io' + try { - const res = await ipfs.dns('ipfs.io', { recursive: false }) + const res = await ipfs.dns(domain, { recursive: false }) // matches pattern /ipns/ expect(res).to.match(/\/ipns\/.+$/) @@ -40,13 +42,21 @@ export function testDns (factory, options) { return this.skip() } + // happens when running tests offline + if (err.message.includes(`ECONNREFUSED ${domain}`)) { + // @ts-expect-error this is mocha + return this.skip() + } + throw err } }) it('should recursively resolve ipfs.io', async function () { + const domain = 'ipfs.io' + try { - const res = await ipfs.dns('ipfs.io', { recursive: true }) + const res = await ipfs.dns(domain, { recursive: true }) // matches pattern /ipfs/ expect(res).to.match(/\/ipfs\/.+$/) @@ -56,13 +66,21 @@ export function testDns (factory, options) { return this.skip() } + // happens when running tests offline + if (err.message.includes(`ECONNREFUSED ${domain}`)) { + // @ts-expect-error this is mocha + return this.skip() + } + throw err } }) it('should resolve subdomain docs.ipfs.io', async function () { + const domain = 'docs.ipfs.io' + try { - const res = await ipfs.dns('docs.ipfs.io') + const res = await ipfs.dns(domain) // matches pattern /ipfs/ expect(res).to.match(/\/ipfs\/.+$/) @@ -72,6 +90,12 @@ export function testDns (factory, options) { return this.skip() } + // happens when running tests offline + if (err.message.includes(`ECONNREFUSED ${domain}`)) { + // @ts-expect-error this is mocha + return this.skip() + } + throw err } }) diff --git a/packages/interface-ipfs-core/src/miscellaneous/id.js b/packages/interface-ipfs-core/src/miscellaneous/id.js index 7b141bf91e..cd67e48ddf 100644 --- a/packages/interface-ipfs-core/src/miscellaneous/id.js +++ b/packages/interface-ipfs-core/src/miscellaneous/id.js @@ -2,7 +2,7 @@ import { expect } from 'aegir/chai' import { getDescribe, getIt } from '../utils/mocha.js' -import { Multiaddr } from '@multiformats/multiaddr' +import { isMultiaddr } from '@multiformats/multiaddr' import { isWebWorker } from 'ipfs-utils/src/env.js' import retry from 'p-retry' @@ -38,7 +38,7 @@ export function testId (factory, options) { expect(res).to.have.a.property('addresses').that.is.an('array') for (const ma of res.addresses) { - expect(Multiaddr.isMultiaddr(ma)).to.be.true() + expect(isMultiaddr(ma)).to.be.true() } }) @@ -48,17 +48,11 @@ export function testId (factory, options) { expect(res).to.have.a.property('protocols').that.is.an('array') expect(res.protocols).to.include.members([ - '/floodsub/1.0.0', - '/ipfs/bitswap/1.0.0', - '/ipfs/bitswap/1.1.0', '/ipfs/bitswap/1.2.0', '/ipfs/id/1.0.0', '/ipfs/id/push/1.0.0', '/ipfs/lan/kad/1.0.0', - '/ipfs/ping/1.0.0', - '/libp2p/circuit/relay/0.1.0', - '/meshsub/1.0.0', - '/meshsub/1.1.0' + '/ipfs/ping/1.0.0' ]) }) diff --git a/packages/interface-ipfs-core/src/miscellaneous/resolve.js b/packages/interface-ipfs-core/src/miscellaneous/resolve.js index c013a61330..49e004c4fa 100644 --- a/packages/interface-ipfs-core/src/miscellaneous/resolve.js +++ b/packages/interface-ipfs-core/src/miscellaneous/resolve.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' -import isIpfs from 'is-ipfs' +import * as isIpfs from 'is-ipfs' import { nanoid } from 'nanoid' import { base64url } from 'multiformats/bases/base64' import { expect } from 'aegir/chai' @@ -96,9 +96,21 @@ export function testResolve (factory, options) { it('should resolve an IPNS DNS link', async function () { // @ts-expect-error this is mocha this.retries(3) - const resolved = await ipfs.resolve('/ipns/ipfs.io') + const domain = 'ipfs.io' - expect(isIpfs.ipfsPath(resolved)).to.be.true() + try { + const resolved = await ipfs.resolve(`/ipns/${domain}`) + + expect(isIpfs.ipfsPath(resolved)).to.be.true() + } catch (/** @type {any} */ err) { + // happens when running tests offline + if (err.message.includes(`ECONNREFUSED ${domain}`)) { + // @ts-expect-error this is mocha + return this.skip() + } + + throw err + } }) it('should resolve IPNS link recursively by default', async function () { diff --git a/packages/interface-ipfs-core/src/name-pubsub/pubsub.js b/packages/interface-ipfs-core/src/name-pubsub/pubsub.js index c003794030..7849334951 100644 --- a/packages/interface-ipfs-core/src/name-pubsub/pubsub.js +++ b/packages/interface-ipfs-core/src/name-pubsub/pubsub.js @@ -25,7 +25,7 @@ const daemonsOptions = { /** * @typedef {import('ipfsd-ctl').Factory} Factory - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message * @typedef {import('@libp2p/interfaces/events').EventHandler} EventHandler */ @@ -126,7 +126,7 @@ export function testPubsub (factory, options) { const testAccountName = 'test-account' /** - * @type {import('@libp2p/interfaces/pubsub').Message} + * @type {import('@libp2p/interface-pubsub').Message} */ let publishedMessage @@ -162,8 +162,12 @@ export function testPubsub (factory, options) { const publishedMessageData = ipns.unmarshal(publishedMessage.data) - if (!publishedMessageData.pubKey) { - throw new Error('No public key found in message data') + if (publishedMessage.type !== 'signed') { + throw new Error('Message was not signed') + } + + if (publishedMessageData.pubKey == null) { + throw new Error('Public key was missing from published message data') } const messageKey = publishedMessage.from diff --git a/packages/interface-ipfs-core/src/name/publish.js b/packages/interface-ipfs-core/src/name/publish.js index 6bfb01b0e1..e44b806387 100644 --- a/packages/interface-ipfs-core/src/name/publish.js +++ b/packages/interface-ipfs-core/src/name/publish.js @@ -10,7 +10,7 @@ import { peerIdFromString } from '@libp2p/peer-id' /** * @typedef {import('ipfsd-ctl').Factory} Factory - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId */ /** diff --git a/packages/interface-ipfs-core/src/name/resolve.js b/packages/interface-ipfs-core/src/name/resolve.js index 3c3c41c835..69deee2ff9 100644 --- a/packages/interface-ipfs-core/src/name/resolve.js +++ b/packages/interface-ipfs-core/src/name/resolve.js @@ -10,7 +10,7 @@ import * as Digest from 'multiformats/hashes/digest' /** * @typedef {import('ipfsd-ctl').Factory} Factory - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId */ /** @@ -160,34 +160,106 @@ export function testResolve (factory, options) { after(() => factory.clean()) - it('should resolve /ipns/ipfs.io', async () => { - expect(await last(ipfs.name.resolve('/ipns/ipfs.io'))) - .to.match(/\/ipfs\/.+$/) + it('should resolve /ipns/ipfs.io', async function () { + const domain = 'ipfs.io' + + try { + expect(await last(ipfs.name.resolve(`/ipns/${domain}`))) + .to.match(/\/ipfs\/.+$/) + } catch (/** @type {any} */ err) { + // happens when running tests offline + if (err.message.includes(`ECONNREFUSED ${domain}`)) { + // @ts-expect-error this is mocha + return this.skip() + } + + throw err + } }) - it('should resolve /ipns/ipfs.io recursive === false', async () => { - expect(await last(ipfs.name.resolve('/ipns/ipfs.io', { recursive: false }))) - .to.match(/\/ipns\/.+$/) + it('should resolve /ipns/ipfs.io recursive === false', async function () { + const domain = 'ipfs.io' + + try { + expect(await last(ipfs.name.resolve(`/ipns/${domain}`, { recursive: false }))) + .to.match(/\/ipns\/.+$/) + } catch (/** @type {any} */ err) { + // happens when running tests offline + if (err.message.includes(`ECONNREFUSED ${domain}`)) { + // @ts-expect-error this is mocha + return this.skip() + } + + throw err + } }) - it('should resolve /ipns/ipfs.io recursive === true', async () => { - expect(await last(ipfs.name.resolve('/ipns/ipfs.io', { recursive: true }))) - .to.match(/\/ipfs\/.+$/) + it('should resolve /ipns/ipfs.io recursive === true', async function () { + const domain = 'ipfs.io' + + try { + expect(await last(ipfs.name.resolve(`/ipns/${domain}`, { recursive: true }))) + .to.match(/\/ipfs\/.+$/) + } catch (/** @type {any} */ err) { + // happens when running tests offline + if (err.message.includes(`ECONNREFUSED ${domain}`)) { + // @ts-expect-error this is mocha + return this.skip() + } + + throw err + } }) - it('should resolve /ipns/ipfs.io with remainder', async () => { - expect(await last(ipfs.name.resolve('/ipns/ipfs.io/images/ipfs-logo.svg'))) - .to.match(/\/ipfs\/.+\/images\/ipfs-logo.svg$/) + it('should resolve /ipns/ipfs.io with remainder', async function () { + const domain = 'ipfs.io' + + try { + expect(await last(ipfs.name.resolve(`/ipns/${domain}/images/ipfs-logo.svg`))) + .to.match(/\/ipfs\/.+\/images\/ipfs-logo.svg$/) + } catch (/** @type {any} */ err) { + // happens when running tests offline + if (err.message.includes(`ECONNREFUSED ${domain}`)) { + // @ts-expect-error this is mocha + return this.skip() + } + + throw err + } }) - it('should resolve /ipns/ipfs.io with remainder recursive === false', async () => { - expect(await last(ipfs.name.resolve('/ipns/ipfs.io/images/ipfs-logo.svg', { recursive: false }))) - .to.match(/\/ipns\/.+\/images\/ipfs-logo.svg$/) + it('should resolve /ipns/ipfs.io with remainder recursive === false', async function () { + const domain = 'ipfs.io' + + try { + expect(await last(ipfs.name.resolve(`/ipns/${domain}/images/ipfs-logo.svg`, { recursive: false }))) + .to.match(/\/ipns\/.+\/images\/ipfs-logo.svg$/) + } catch (/** @type {any} */ err) { + // happens when running tests offline + if (err.message.includes(`ECONNREFUSED ${domain}`)) { + // @ts-expect-error this is mocha + return this.skip() + } + + throw err + } }) - it('should resolve /ipns/ipfs.io with remainder recursive === true', async () => { - expect(await last(ipfs.name.resolve('/ipns/ipfs.io/images/ipfs-logo.svg', { recursive: true }))) - .to.match(/\/ipfs\/.+\/images\/ipfs-logo.svg$/) + it('should resolve /ipns/ipfs.io with remainder recursive === true', async function () { + const domain = 'ipfs.io' + + try { + expect(await last(ipfs.name.resolve(`/ipns/${domain}/images/ipfs-logo.svg`, { recursive: true }))) + .to.match(/\/ipfs\/.+\/images\/ipfs-logo.svg$/) + } catch (/** @type {any} */ err) { + // happens when running tests offline + if (err.message.includes(`ECONNREFUSED ${domain}`)) { + // @ts-expect-error this is mocha + return this.skip() + } + + throw err + } }) it('should fail to resolve /ipns/ipfs.a', async () => { @@ -198,9 +270,21 @@ export function testResolve (factory, options) { } }) - it('should resolve ipns path with hamt-shard recursive === true', async () => { - expect(await last(ipfs.name.resolve('/ipns/tr.wikipedia-on-ipfs.org/wiki/Anasayfa.html', { recursive: true }))) - .to.match(/\/ipfs\/.+$/) + it('should resolve ipns path with hamt-shard recursive === true', async function () { + const domain = 'tr.wikipedia-on-ipfs.org' + + try { + expect(await last(ipfs.name.resolve(`/ipns/${domain}/wiki/Anasayfa.html`, { recursive: true }))) + .to.match(/\/ipfs\/.+$/) + } catch (/** @type {any} */ err) { + // happens when running tests offline + if (err.message.includes(`ECONNREFUSED ${domain}`)) { + // @ts-expect-error this is mocha + return this.skip() + } + + throw err + } }) }) } diff --git a/packages/interface-ipfs-core/src/pubsub/subscribe.js b/packages/interface-ipfs-core/src/pubsub/subscribe.js index f4093ac196..bad06e4015 100644 --- a/packages/interface-ipfs-core/src/pubsub/subscribe.js +++ b/packages/interface-ipfs-core/src/pubsub/subscribe.js @@ -13,11 +13,11 @@ import { isWebWorker, isNode } from 'ipfs-utils/src/env.js' import sinon from 'sinon' import defer from 'p-defer' import pWaitFor from 'p-wait-for' -import { isPeerId } from '@libp2p/interfaces/peer-id' +import { isPeerId } from '@libp2p/interface-peer-id' /** * @typedef {import('ipfsd-ctl').Factory} Factory - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message * @typedef {import('it-pushable').Pushable} Pushable * @typedef {import('p-defer').DeferredPromise} DeferredMessagePromise */ @@ -84,6 +84,10 @@ export function testSubscribe (factory, options) { const msg = await deferred.promise + if (msg.type !== 'signed') { + throw new Error('Message was not signed') + } + expect(uint8ArrayToString(msg.data)).to.equal('hi') expect(msg).to.have.property('sequenceNumber') expect(msg.sequenceNumber).to.be.a('BigInt') @@ -93,7 +97,7 @@ export function testSubscribe (factory, options) { }) it('should subscribe to one topic with options', async () => { - const msgStream = pushable() + const msgStream = pushable({ objectMode: true }) await ipfs1.pubsub.subscribe(topic, msg => { msgStream.push(msg) @@ -153,7 +157,7 @@ export function testSubscribe (factory, options) { }) it('should allow discover option to be passed', async () => { - const msgStream = pushable() + const msgStream = pushable({ objectMode: true }) await ipfs1.pubsub.subscribe(topic, msg => { msgStream.push(msg) @@ -248,10 +252,20 @@ export function testSubscribe (factory, options) { await ipfs2.pubsub.publish(topic, uint8ArrayFromString(expectedString)) const sub1Msg = await msgStream1.promise + + if (sub1Msg.type !== 'signed') { + throw new Error('Message was not signed') + } + expect(uint8ArrayToString(sub1Msg.data)).to.be.eql(expectedString) expect(sub1Msg.from.toString()).to.eql(ipfs2Id.id.toString()) const sub2Msg = await msgStream2.promise + + if (sub2Msg.type !== 'signed') { + throw new Error('Message was not signed') + } + expect(uint8ArrayToString(sub2Msg.data)).to.be.eql(expectedString) expect(sub2Msg.from.toString()).to.eql(ipfs2Id.id.toString()) }) @@ -283,10 +297,20 @@ export function testSubscribe (factory, options) { await ipfs2.pubsub.publish(topic, uint8ArrayFromString(expectedString)) const sub1Msg = await msgStream1.promise + + if (sub1Msg.type !== 'signed') { + throw new Error('Message was not signed') + } + expect(uint8ArrayToString(sub1Msg.data)).to.be.eql(expectedString) expect(sub1Msg.from.toString()).to.eql(ipfs2Id.id.toString()) const sub2Msg = await msgStream2.promise + + if (sub2Msg.type !== 'signed') { + throw new Error('Message was not signed') + } + expect(uint8ArrayToString(sub2Msg.data)).to.be.eql(expectedString) expect(sub2Msg.from.toString()).to.eql(ipfs2Id.id.toString()) }) @@ -319,10 +343,20 @@ export function testSubscribe (factory, options) { await ipfs2.pubsub.publish(topic, buffer) const sub1Msg = await msgStream1.promise + + if (sub1Msg.type !== 'signed') { + throw new Error('Message was not signed') + } + expect(uint8ArrayToString(sub1Msg.data, 'base16')).to.be.eql(expectedHex) expect(sub1Msg.from.toString()).to.eql(ipfs2Id.id.toString()) const sub2Msg = await msgStream2.promise + + if (sub2Msg.type !== 'signed') { + throw new Error('Message was not signed') + } + expect(uint8ArrayToString(sub2Msg.data, 'base16')).to.be.eql(expectedHex) expect(sub2Msg.from.toString()).to.eql(ipfs2Id.id.toString()) }) @@ -330,8 +364,8 @@ export function testSubscribe (factory, options) { it('should receive multiple messages', async () => { const outbox = ['hello', 'world', 'this', 'is', 'pubsub'] - const msgStream1 = pushable() - const msgStream2 = pushable() + const msgStream1 = pushable({ objectMode: true }) + const msgStream2 = pushable({ objectMode: true }) let sub1Called = 0 /** @type {import('@libp2p/interfaces/events').EventHandler} */ @@ -377,7 +411,7 @@ export function testSubscribe (factory, options) { const msgBase = 'msg - ' const count = 100 - const msgStream = pushable() + const msgStream = pushable({ objectMode: true }) let subCalled = 0 /** @type {import('@libp2p/interfaces/events').EventHandler} */ @@ -426,8 +460,8 @@ export function testSubscribe (factory, options) { const topic = `pubsub-topic-${Math.random()}` topics.push(topic) - const msgStream1 = pushable() - const msgStream2 = pushable() + const msgStream1 = pushable({ objectMode: true }) + const msgStream2 = pushable({ objectMode: true }) msgStreams.push({ msgStream1, diff --git a/packages/interface-ipfs-core/src/pubsub/unsubscribe.js b/packages/interface-ipfs-core/src/pubsub/unsubscribe.js index 7746525414..5112e00e47 100644 --- a/packages/interface-ipfs-core/src/pubsub/unsubscribe.js +++ b/packages/interface-ipfs-core/src/pubsub/unsubscribe.js @@ -7,7 +7,7 @@ import waitFor from '../utils/wait-for.js' /** * @typedef {import('ipfsd-ctl').Factory} Factory - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message */ /** diff --git a/packages/interface-ipfs-core/src/pubsub/utils.js b/packages/interface-ipfs-core/src/pubsub/utils.js index cdf90788d1..540f6d4d1a 100644 --- a/packages/interface-ipfs-core/src/pubsub/utils.js +++ b/packages/interface-ipfs-core/src/pubsub/utils.js @@ -2,7 +2,7 @@ import { nanoid } from 'nanoid' import delay from 'delay' /** - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId */ /** diff --git a/packages/interface-ipfs-core/src/swarm/addrs.js b/packages/interface-ipfs-core/src/swarm/addrs.js index 6d2da0f3e4..279087bea7 100644 --- a/packages/interface-ipfs-core/src/swarm/addrs.js +++ b/packages/interface-ipfs-core/src/swarm/addrs.js @@ -1,6 +1,6 @@ /* eslint-env mocha */ -import { Multiaddr } from '@multiformats/multiaddr' +import { isMultiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' import { getDescribe, getIt } from '../utils/mocha.js' import { isWebWorker } from 'ipfs-utils/src/env.js' @@ -47,7 +47,7 @@ export function testAddrs (factory, options) { expect(peer).to.have.a.property('addrs').that.is.an('array') for (const ma of peer.addrs) { - expect(Multiaddr.isMultiaddr(ma)).to.be.true() + expect(isMultiaddr(ma)).to.be.true() } } }) diff --git a/packages/interface-ipfs-core/src/swarm/peers.js b/packages/interface-ipfs-core/src/swarm/peers.js index 5e1d46ed6e..1662a81641 100644 --- a/packages/interface-ipfs-core/src/swarm/peers.js +++ b/packages/interface-ipfs-core/src/swarm/peers.js @@ -1,6 +1,6 @@ /* eslint-env mocha */ -import { Multiaddr } from '@multiformats/multiaddr' +import { isMultiaddr } from '@multiformats/multiaddr' import delay from 'delay' import { isBrowser, isWebWorker } from 'ipfs-utils/src/env.js' import { expect } from 'aegir/chai' @@ -60,7 +60,7 @@ export function testPeers (factory, options) { const peer = peers[0] expect(peer).to.have.a.property('addr') - expect(Multiaddr.isMultiaddr(peer.addr)).to.equal(true) + expect(isMultiaddr(peer.addr)).to.equal(true) expect(peer).to.have.a.property('peer') expect(peer.peer).to.be.ok() expect(peer).to.not.have.a.property('latency') @@ -77,7 +77,7 @@ export function testPeers (factory, options) { const peer = peers[0] expect(peer).to.have.a.property('addr') - expect(Multiaddr.isMultiaddr(peer.addr)).to.equal(true) + expect(isMultiaddr(peer.addr)).to.equal(true) expect(peer).to.have.a.property('peer') expect(peer).to.have.a.property('latency') expect(peer.latency).to.match(/n\/a|[0-9]+[mµ]?s/) // n/a or 3ms or 3µs or 3s diff --git a/packages/interface-ipfs-core/src/utils/ipfs-options-websockets-filter-all.js b/packages/interface-ipfs-core/src/utils/ipfs-options-websockets-filter-all.js index 88bc5c0ac1..b41ac55df2 100644 --- a/packages/interface-ipfs-core/src/utils/ipfs-options-websockets-filter-all.js +++ b/packages/interface-ipfs-core/src/utils/ipfs-options-websockets-filter-all.js @@ -1,4 +1,4 @@ -import { WebSockets } from '@libp2p/websockets' +import { webSockets } from '@libp2p/websockets' import { all } from '@libp2p/websockets/filters' export function ipfsOptionsWebsocketsFilterAll () { @@ -6,7 +6,7 @@ export function ipfsOptionsWebsocketsFilterAll () { libp2p: { config: { transports: [ - new WebSockets({ + webSockets({ filter: all }) ] diff --git a/packages/interface-ipfs-core/src/utils/mocha.js b/packages/interface-ipfs-core/src/utils/mocha.js index df6b791a71..bd5e93941e 100644 --- a/packages/interface-ipfs-core/src/utils/mocha.js +++ b/packages/interface-ipfs-core/src/utils/mocha.js @@ -100,7 +100,6 @@ export function getIt (config) { /** * @param {string} name * @param {*} impl - * @returns */ const _it = (name, impl) => { if (Array.isArray(config.skip)) { diff --git a/packages/ipfs-cli/CHANGELOG.md b/packages/ipfs-cli/CHANGELOG.md index e5f4dd49e8..e747821246 100644 --- a/packages/ipfs-cli/CHANGELOG.md +++ b/packages/ipfs-cli/CHANGELOG.md @@ -3,6 +3,82 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.15.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-cli-v0.14.2...ipfs-cli-v0.15.0) (2022-10-24) + + +### ⚠ BREAKING CHANGES + +* ipfs is now bundled with libp2p@0.40.x which has different config + +### Features + +* upgrade libp2p to 0.40.x ([#4237](https://www.github.com/ipfs/js-ipfs/issues/4237)) ([0cee4a4](https://www.github.com/ipfs/js-ipfs/commit/0cee4a4c55767022584dcbade0b0b9b43326f9c9)) + + +### Bug Fixes + +* replace slice with subarray for increased performance ([#4210](https://www.github.com/ipfs/js-ipfs/issues/4210)) ([dfc43d4](https://www.github.com/ipfs/js-ipfs/commit/dfc43d4e9be67fdf25553677f469379d966ff806)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core bumped from ^0.16.1 to ^0.17.0 + * ipfs-core-types bumped from ^0.12.1 to ^0.13.0 + * ipfs-core-utils bumped from ^0.16.1 to ^0.17.0 + * ipfs-daemon bumped from ^0.14.2 to ^0.15.0 + * ipfs-http-client bumped from ^58.0.1 to ^59.0.0 + +### [0.14.2](https://www.github.com/ipfs/js-ipfs/compare/ipfs-cli-v0.14.1...ipfs-cli-v0.14.2) (2022-09-21) + + +### Bug Fixes + +* update @multiformats/multiadd to 11.0.0 ([2a830bf](https://www.github.com/ipfs/js-ipfs/commit/2a830bf58a5929fcce51dede871c99f62192fbda)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core bumped from ^0.16.0 to ^0.16.1 + * ipfs-core-types bumped from ^0.12.0 to ^0.12.1 + * ipfs-core-utils bumped from ^0.16.0 to ^0.16.1 + * ipfs-daemon bumped from ^0.14.1 to ^0.14.2 + * ipfs-http-client bumped from ^58.0.0 to ^58.0.1 + +### [0.14.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-cli-v0.14.0...ipfs-cli-v0.14.1) (2022-09-16) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-daemon bumped from ^0.14.0 to ^0.14.1 + +## [0.14.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-cli-v0.13.5...ipfs-cli-v0.14.0) (2022-09-06) + + +### ⚠ BREAKING CHANGES + +* update to libp2p@0.38.x (#4151) + +### deps + +* update to libp2p@0.38.x ([#4151](https://www.github.com/ipfs/js-ipfs/issues/4151)) ([39dbf70](https://www.github.com/ipfs/js-ipfs/commit/39dbf708ec31b263115e44f420651fa4e056a89e)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core bumped from ^0.15.0 to ^0.16.0 + * ipfs-core-types bumped from ^0.11.0 to ^0.12.0 + * ipfs-core-utils bumped from ^0.15.0 to ^0.16.0 + * ipfs-daemon bumped from ^0.13.0 to ^0.14.0 + * ipfs-http-client bumped from ^57.0.0 to ^58.0.0 + ### [0.13.5](https://www.github.com/ipfs/js-ipfs/compare/ipfs-cli-v0.13.4...ipfs-cli-v0.13.5) (2022-06-24) @@ -564,4 +640,4 @@ Co-authored-by: achingbrain ### Features * enable custom formats for dag put and get ([#3347](https://github.com/ipfs/js-ipfs/issues/3347)) ([3250ff4](https://github.com/ipfs/js-ipfs/commit/3250ff453a1d3275cc4ab746f59f9f70abd5cc5f)) -* type check & generate defs from jsdoc ([#3281](https://github.com/ipfs/js-ipfs/issues/3281)) ([bbcaf34](https://github.com/ipfs/js-ipfs/commit/bbcaf34111251b142273a5675f4754ff68bd9fa0)) +* type check & generate defs from jsdoc ([#3281](https://github.com/ipfs/js-ipfs/issues/3281)) ([bbcaf34](https://github.com/ipfs/js-ipfs/commit/bbcaf34111251b142273a5675f4754ff68bd9fa0)) \ No newline at end of file diff --git a/packages/ipfs-cli/LICENSE b/packages/ipfs-cli/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-cli/LICENSE @@ -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 diff --git a/packages/ipfs-cli/LICENSE-MIT b/packages/ipfs-cli/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/packages/ipfs-cli/LICENSE-MIT +++ b/packages/ipfs-cli/LICENSE-MIT @@ -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. \ No newline at end of file +THE SOFTWARE. diff --git a/packages/ipfs-cli/README.md b/packages/ipfs-cli/README.md index 08fee6dff8..1ec7e2843e 100644 --- a/packages/ipfs-cli/README.md +++ b/packages/ipfs-cli/README.md @@ -1,16 +1,24 @@ # ipfs-cli -> The implementation of the js-IPFS CLI +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -## Table of Contents +> JavaScript implementation of the IPFS specification + +## Table of contents - [Install](#install) -- [Want to hack on IPFS?](#want-to-hack-on-ipfs) - [License](#license) +- [Contribute](#contribute) ## Install -You probably don't need to install this module directly, use it by installing the `ipfs` module: +```console +$ npm i ipfs-cli +``` ```console $ npm install -g ipfs @@ -18,23 +26,21 @@ $ npm install -g ipfs $ jsipfs daemon ``` -## Want to hack on IPFS? +## License -[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) +Licensed under either of -The IPFS implementation in JavaScript needs your help! There are a few things you can do right now to help out: +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) -Read the [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md) and [JavaScript Contributing Guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md). +## Contribute -- **Check out existing issues** The [issue list](https://github.com/ipfs/js-ipfs/issues) has many that are marked as ['help wanted'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22) or ['difficulty:easy'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Adifficulty%3Aeasy) which make great starting points for development, many of which can be tackled with no prior IPFS knowledge -- **Look at the [IPFS Roadmap](https://github.com/ipfs/roadmap)** This are the high priority items being worked on right now -- **Perform code reviews** More eyes will help - a. speed the project along - b. ensure quality, and - c. reduce possible future bugs. -- **Add tests**. There can never be enough tests. -- **Join the [Weekly Core Implementations Call](https://github.com/ipfs/team-mgmt/issues/992)** it's where everyone discusses what's going on with IPFS and what's next +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). -## License +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. + +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs-cli/package.json b/packages/ipfs-cli/package.json index 79259e3a02..c7e36fa50c 100644 --- a/packages/ipfs-cli/package.json +++ b/packages/ipfs-cli/package.json @@ -1,16 +1,25 @@ { "name": "ipfs-cli", - "version": "0.13.5", + "version": "0.15.0", "description": "JavaScript implementation of the IPFS specification", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-cli#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "IPFS" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-cli#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", "typesVersions": { "*": { "*": [ @@ -28,27 +37,26 @@ } }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - } - }, "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" }, "./utils": { + "types": "./src/utils.d.ts", "import": "./src/utils.js" } }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } }, "scripts": { "lint": "aegir lint", @@ -59,51 +67,51 @@ "build": "aegir build --no-bundle" }, "dependencies": { - "@ipld/dag-cbor": "^7.0.0", - "@ipld/dag-json": "^8.0.1", - "@ipld/dag-pb": "^2.1.3", - "@libp2p/logger": "^1.1.4", + "@ipld/dag-cbor": "^8.0.0", + "@ipld/dag-json": "^9.0.0", + "@ipld/dag-pb": "^3.0.0", + "@libp2p/logger": "^2.0.0", "@libp2p/peer-id": "^1.1.10", "@multiformats/mafmt": "^11.0.2", - "@multiformats/multiaddr": "^10.0.0", + "@multiformats/multiaddr": "^11.0.0", "@multiformats/multiaddr-to-uri": "^9.0.1", "byteman": "^1.3.5", "execa": "^6.1.0", - "get-folder-size": "^3.1.0", - "ipfs-core": "^0.15.4", - "ipfs-core-types": "^0.11.1", - "ipfs-core-utils": "^0.15.1", - "ipfs-daemon": "^0.13.5", - "ipfs-http-client": "^57.0.3", + "get-folder-size": "^4.0.0", + "ipfs-core": "^0.17.0", + "ipfs-core-types": "^0.13.0", + "ipfs-core-utils": "^0.17.0", + "ipfs-daemon": "^0.15.0", + "ipfs-http-client": "^59.0.0", "ipfs-utils": "^9.0.6", - "it-concat": "^2.0.0", - "it-map": "^1.0.5", - "it-merge": "^1.0.3", + "it-concat": "^3.0.1", + "it-merge": "^2.0.0", "it-pipe": "^2.0.3", - "it-split": "^1.0.0", - "it-tar": "^5.0.0", + "it-split": "^2.0.0", + "it-tar": "^6.0.0", "jsondiffpatch": "^0.4.1", - "multiformats": "^9.5.1", + "multiformats": "^10.0.0", "parse-duration": "^1.0.0", "pretty-bytes": "^6.0.0", "progress": "^2.0.3", "stream-to-it": "^0.2.2", - "uint8arrays": "^3.0.0", + "uint8arrays": "^4.0.2", "yargs": "^17.4.0" }, "devDependencies": { - "@libp2p/crypto": "^0.22.9", + "@libp2p/crypto": "^1.0.0", "@types/get-folder-size": "^3.0.1", "@types/ncp": "^2.0.5", "@types/progress": "^2.0.3", "@types/rimraf": "^3.0.1", "@types/yargs": "^17.0.10", "aegir": "^37.0.11", - "ipfs-repo": "^14.0.1", - "it-all": "^1.0.4", - "it-first": "^1.0.4", - "it-to-buffer": "^2.0.0", - "nanoid": "^3.1.23", + "ipfs-repo": "^16.0.0", + "it-all": "^2.0.0", + "it-first": "^2.0.0", + "it-map": "^2.0.0", + "it-to-buffer": "^3.0.0", + "nanoid": "^4.0.0", "ncp": "^2.0.0", "pako": "^2.0.4", "rimraf": "^3.0.2", diff --git a/packages/ipfs-cli/src/commands/add.js b/packages/ipfs-cli/src/commands/add.js index e5c2434ae6..77f81e768b 100644 --- a/packages/ipfs-cli/src/commands/add.js +++ b/packages/ipfs-cli/src/commands/add.js @@ -86,7 +86,7 @@ async function * getSource (target, options = {}) { * @property {import('../types').Context} Argv.ctx * @property {boolean} Argv.trickle * @property {number} Argv.shardSplitThreshold - * @property {import('multiformats/cid').CIDVersion} Argv.cidVersion + * @property {import('multiformats/cid').Version} Argv.cidVersion * @property {boolean} Argv.rawLeaves * @property {boolean} Argv.onlyHash * @property {string} Argv.hash diff --git a/packages/ipfs-cli/src/commands/bitswap/wantlist.js b/packages/ipfs-cli/src/commands/bitswap/wantlist.js index 54132e31c1..a61bb33241 100644 --- a/packages/ipfs-cli/src/commands/bitswap/wantlist.js +++ b/packages/ipfs-cli/src/commands/bitswap/wantlist.js @@ -4,7 +4,7 @@ import { coercePeerId } from '../../utils.js' /** * @typedef {object} Argv * @property {import('../../types').Context} Argv.ctx - * @property {import('@libp2p/interfaces/peer-id').PeerId} Argv.peer + * @property {import('@libp2p/interface-peer-id').PeerId} Argv.peer * @property {string} Argv.cidBase * @property {number} Argv.timeout */ diff --git a/packages/ipfs-cli/src/commands/block/put.js b/packages/ipfs-cli/src/commands/block/put.js index 2f4b1607dc..8156286037 100644 --- a/packages/ipfs-cli/src/commands/block/put.js +++ b/packages/ipfs-cli/src/commands/block/put.js @@ -9,7 +9,7 @@ import parseDuration from 'parse-duration' * @property {string} Argv.format * @property {string} Argv.mhtype * @property {number} Argv.mhlen - * @property {import('multiformats/cid').CIDVersion} Argv.version + * @property {import('multiformats/cid').Version} Argv.version * @property {boolean} Argv.pin * @property {string} Argv.cidBase * @property {number} Argv.timeout @@ -62,7 +62,7 @@ const command = { if (block) { data = fs.readFileSync(block) } else { - data = (await concat(getStdin(), { type: 'buffer' })).slice() + data = (await concat(getStdin(), { type: 'buffer' })).subarray() } const cid = await ipfs.block.put(data, { diff --git a/packages/ipfs-cli/src/commands/cat.js b/packages/ipfs-cli/src/commands/cat.js index befdfd5105..da4163f79c 100644 --- a/packages/ipfs-cli/src/commands/cat.js +++ b/packages/ipfs-cli/src/commands/cat.js @@ -6,6 +6,7 @@ import parseDuration from 'parse-duration' * @property {string} Argv.ipfsPath * @property {number} Argv.offset * @property {number} Argv.length + * @property {boolean} Argv.preload * @property {number} Argv.timeout */ @@ -26,14 +27,19 @@ const command = { number: true, describe: 'Maximum number of bytes to read' }, + preload: { + boolean: true, + default: true, + describe: 'Preload this object when adding' + }, timeout: { string: true, coerce: parseDuration } }, - async handler ({ ctx: { ipfs, print }, ipfsPath, offset, length, timeout }) { - for await (const buf of ipfs.cat(ipfsPath, { offset, length, timeout })) { + async handler ({ ctx: { ipfs, print }, ipfsPath, offset, length, preload, timeout }) { + for await (const buf of ipfs.cat(ipfsPath, { offset, length, preload, timeout })) { print.write(buf) } } diff --git a/packages/ipfs-cli/src/commands/cid/format.js b/packages/ipfs-cli/src/commands/cid/format.js index 9e680d6bef..8a0f4984f1 100644 --- a/packages/ipfs-cli/src/commands/cid/format.js +++ b/packages/ipfs-cli/src/commands/cid/format.js @@ -6,7 +6,7 @@ import { CID } from 'multiformats/cid' * @property {import('../../types').Context} Argv.ctx * @property {string[]} [Argv.cids] * @property {string} [Argv.format] - * @property {import('multiformats/cid').CIDVersion} [Argv.cidVersion] + * @property {import('multiformats/cid').Version} [Argv.cidVersion] * @property {string} [Argv.base] */ diff --git a/packages/ipfs-cli/src/commands/dag/put.js b/packages/ipfs-cli/src/commands/dag/put.js index d6de5428ad..d82f7a83c1 100644 --- a/packages/ipfs-cli/src/commands/dag/put.js +++ b/packages/ipfs-cli/src/commands/dag/put.js @@ -24,7 +24,7 @@ const codecs = [dagCBOR, dagJSON, dagPB, raw].reduce((/** @type {Record map(source, buf => buf.slice()), toIterable.sink(fs.createWriteStream(outputPath)) ) } else if (header.type === 'directory') { diff --git a/packages/ipfs-cli/src/commands/id.js b/packages/ipfs-cli/src/commands/id.js index f9609f6c12..ac177a2bcb 100644 --- a/packages/ipfs-cli/src/commands/id.js +++ b/packages/ipfs-cli/src/commands/id.js @@ -6,7 +6,7 @@ import { coercePeerId } from '../utils.js' * @property {import('../types').Context} Argv.ctx * @property {string} Argv.format * @property {number} Argv.timeout - * @property {import('@libp2p/interfaces/peer-id').PeerId} [Argv.peerId] + * @property {import('@libp2p/interface-peer-id').PeerId} [Argv.peerId] */ /** @type {import('yargs').CommandModule} */ diff --git a/packages/ipfs-cli/src/commands/object/patch/append-data.js b/packages/ipfs-cli/src/commands/object/patch/append-data.js index fc66b8cd36..dbecf8d6eb 100644 --- a/packages/ipfs-cli/src/commands/object/patch/append-data.js +++ b/packages/ipfs-cli/src/commands/object/patch/append-data.js @@ -40,7 +40,7 @@ const command = { if (data) { buf = fs.readFileSync(data) } else { - buf = (await concat(getStdin(), { type: 'buffer' })).slice() + buf = (await concat(getStdin(), { type: 'buffer' })).subarray() } const cid = await ipfs.object.patch.appendData(root, buf, { diff --git a/packages/ipfs-cli/src/commands/object/patch/set-data.js b/packages/ipfs-cli/src/commands/object/patch/set-data.js index f3eaab9f72..af3aa08566 100644 --- a/packages/ipfs-cli/src/commands/object/patch/set-data.js +++ b/packages/ipfs-cli/src/commands/object/patch/set-data.js @@ -40,7 +40,7 @@ const command = { if (data) { buf = fs.readFileSync(data) } else { - buf = (await concat(getStdin(), { type: 'buffer' })).slice() + buf = (await concat(getStdin(), { type: 'buffer' })).subarray() } const cid = await ipfs.object.patch.setData(root, buf, { diff --git a/packages/ipfs-cli/src/commands/object/put.js b/packages/ipfs-cli/src/commands/object/put.js index e67a46db43..e3ef6e01ad 100644 --- a/packages/ipfs-cli/src/commands/object/put.js +++ b/packages/ipfs-cli/src/commands/object/put.js @@ -42,7 +42,7 @@ const command = { if (data) { buf = uint8ArrayFromString(data) } else { - buf = (await concat(getStdin(), { type: 'buffer' })).slice() + buf = (await concat(getStdin(), { type: 'buffer' })).subarray() } let node diff --git a/packages/ipfs-cli/src/commands/ping.js b/packages/ipfs-cli/src/commands/ping.js index b55a66c5f2..619b22a31a 100644 --- a/packages/ipfs-cli/src/commands/ping.js +++ b/packages/ipfs-cli/src/commands/ping.js @@ -5,7 +5,7 @@ import { coercePeerId } from '../utils.js' * @typedef {object} Argv * @property {import('../types').Context} Argv.ctx * @property {number} Argv.count - * @property {import('@libp2p/interfaces/peer-id').PeerId} Argv.peerId + * @property {import('@libp2p/interface-peer-id').PeerId} Argv.peerId * @property {number} Argv.timeout */ diff --git a/packages/ipfs-cli/src/commands/pubsub/sub.js b/packages/ipfs-cli/src/commands/pubsub/sub.js index 4c310ab6ef..b08eecbcb8 100644 --- a/packages/ipfs-cli/src/commands/pubsub/sub.js +++ b/packages/ipfs-cli/src/commands/pubsub/sub.js @@ -1,7 +1,7 @@ import parseDuration from 'parse-duration' /** - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message */ /** diff --git a/packages/ipfs-cli/src/commands/stats/bw.js b/packages/ipfs-cli/src/commands/stats/bw.js index cabbab6083..fb0b40adc5 100644 --- a/packages/ipfs-cli/src/commands/stats/bw.js +++ b/packages/ipfs-cli/src/commands/stats/bw.js @@ -4,7 +4,7 @@ import { coercePeerId } from '../../utils.js' /** * @typedef {object} Argv * @property {import('../../types').Context} Argv.ctx - * @property {import('@libp2p/interfaces/peer-id').PeerId} Argv.peer + * @property {import('@libp2p/interface-peer-id').PeerId} Argv.peer * @property {string} Argv.proto * @property {boolean} Argv.poll * @property {number} Argv.interval diff --git a/packages/ipfs-cli/src/commands/swarm/peers.js b/packages/ipfs-cli/src/commands/swarm/peers.js index 6212186cfa..c392ffca82 100644 --- a/packages/ipfs-cli/src/commands/swarm/peers.js +++ b/packages/ipfs-cli/src/commands/swarm/peers.js @@ -1,5 +1,5 @@ import { IPFS } from '@multiformats/mafmt' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' import parseDuration from 'parse-duration' /** @@ -31,7 +31,7 @@ const command = { }) result.forEach((item) => { - let ma = new Multiaddr(`${item.addr}`) + let ma = multiaddr(`${item.addr}`) if (!IPFS.matches(ma)) { ma = ma.encapsulate(`/ipfs/${item.peer}`) diff --git a/packages/ipfs-cli/src/utils.js b/packages/ipfs-cli/src/utils.js index c361207efb..eacf474cb5 100644 --- a/packages/ipfs-cli/src/utils.js +++ b/packages/ipfs-cli/src/utils.js @@ -7,7 +7,7 @@ import Progress from 'progress' import byteman from 'byteman' import { create } from 'ipfs-core' import { CID } from 'multiformats/cid' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { create as httpClient } from 'ipfs-http-client' import { peerIdFromString } from '@libp2p/peer-id' @@ -267,7 +267,7 @@ export const coerceMultiaddr = (value) => { return undefined } - return new Multiaddr(value) + return multiaddr(value) } /** diff --git a/packages/ipfs-cli/test/bootstrap.spec.js b/packages/ipfs-cli/test/bootstrap.spec.js index 13f1f6b96f..73d9982f65 100644 --- a/packages/ipfs-cli/test/bootstrap.spec.js +++ b/packages/ipfs-cli/test/bootstrap.spec.js @@ -3,10 +3,10 @@ import { expect } from 'aegir/chai' import { cli } from './utils/cli.js' import sinon from 'sinon' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' describe('bootstrap', () => { - const peer = new Multiaddr('/ip4/111.111.111.111/tcp/1001/p2p/QmcyFFKfLDGJKwufn2GeitxvhricsBQyNKTkrD14psikoD') + const peer = multiaddr('/ip4/111.111.111.111/tcp/1001/p2p/QmcyFFKfLDGJKwufn2GeitxvhricsBQyNKTkrD14psikoD') let ipfs before(() => { diff --git a/packages/ipfs-cli/test/cat.spec.js b/packages/ipfs-cli/test/cat.spec.js index 66996db78e..3b096ce664 100644 --- a/packages/ipfs-cli/test/cat.spec.js +++ b/packages/ipfs-cli/test/cat.spec.js @@ -9,7 +9,8 @@ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' const defaultOptions = { offset: undefined, length: undefined, - timeout: undefined + timeout: undefined, + preload: true } describe('cat', () => { @@ -81,4 +82,17 @@ describe('cat', () => { const out = await cli(`cat ${cid} --timeout=1s`, { ipfs, raw: true }) expect(out).to.deep.equal(buf) }) + + it('should cat a file without preloading', async () => { + const cid = CID.parse('QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB') + const buf = uint8ArrayFromString('hello world') + + ipfs.cat.withArgs(cid.toString(), { + ...defaultOptions, + preload: false + }).returns([buf]) + + const out = await cli(`cat ${cid} --preload=false`, { ipfs, raw: true }) + expect(out).to.deep.equal(buf) + }) }) diff --git a/packages/ipfs-cli/test/get.spec.js b/packages/ipfs-cli/test/get.spec.js index a3f7d22200..8101c81712 100644 --- a/packages/ipfs-cli/test/get.spec.js +++ b/packages/ipfs-cli/test/get.spec.js @@ -9,7 +9,6 @@ import sinon from 'sinon' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { pack } from 'it-tar' import { pipe } from 'it-pipe' -import map from 'it-map' import toBuffer from 'it-to-buffer' import { clean } from './utils/clean.js' import Pako from 'pako' @@ -27,11 +26,7 @@ const defaultOptions = { async function * tarballed (files) { yield * pipe( files, - pack(), - /** - * @param {AsyncIterable} source - */ - (source) => map(source, buf => buf.slice()) + pack() ) } diff --git a/packages/ipfs-cli/test/object.spec.js b/packages/ipfs-cli/test/object.spec.js index e2134879c1..bbe90cb882 100644 --- a/packages/ipfs-cli/test/object.spec.js +++ b/packages/ipfs-cli/test/object.spec.js @@ -216,7 +216,7 @@ describe('object', () => { const out = await cli('object put', { ipfs, getStdin: function * () { - yield Buffer.from('{}') + yield uint8ArrayFromString('{}') } }) @@ -431,7 +431,7 @@ describe('object', () => { it('append data from pipe', async () => { ipfs.bases.getBase.withArgs('base58btc').returns(base58btc) - const buf = Buffer.from('hello world') + const buf = uint8ArrayFromString('hello world') ipfs.object.patch.appendData.withArgs(cid, buf, defaultOptions).resolves( cid @@ -496,7 +496,7 @@ describe('object', () => { it('set-data from pipe', async () => { ipfs.bases.getBase.withArgs('base58btc').returns(base58btc) - const buf = Buffer.from('hello world') + const buf = uint8ArrayFromString('hello world') ipfs.object.patch.setData.withArgs(cid, buf, defaultOptions).resolves( cid diff --git a/packages/ipfs-cli/test/swarm.spec.js b/packages/ipfs-cli/test/swarm.spec.js index 2a99bc0817..f62c07e9a0 100644 --- a/packages/ipfs-cli/test/swarm.spec.js +++ b/packages/ipfs-cli/test/swarm.spec.js @@ -4,7 +4,7 @@ import { expect } from 'aegir/chai' import { cli, fail } from './utils/cli.js' import sinon from 'sinon' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' import { peerIdFromString } from '@libp2p/peer-id' describe('swarm', () => { @@ -28,33 +28,33 @@ describe('swarm', () => { } it('connect online', async () => { - const multiaddr = new Multiaddr('/ip4/123.123.123.123/tcp/482') + const ma = multiaddr('/ip4/123.123.123.123/tcp/482') - ipfs.swarm.connect.withArgs(multiaddr, defaultOptions).resolves() + ipfs.swarm.connect.withArgs(ma, defaultOptions).resolves() - const out = await cli(`swarm connect ${multiaddr}`, { ipfs, isDaemon: true }) - expect(out).to.equal(`${multiaddr}\n`) + const out = await cli(`swarm connect ${ma}`, { ipfs, isDaemon: true }) + expect(out).to.equal(`${ma}\n`) }) it('connect offline', async () => { - const multiaddr = new Multiaddr('/ip4/123.123.123.123/tcp/482') + const ma = multiaddr('/ip4/123.123.123.123/tcp/482') - const out = await fail(`swarm connect ${multiaddr}`, { ipfs, isDaemon: false }) + const out = await fail(`swarm connect ${ma}`, { ipfs, isDaemon: false }) expect(out).to.include('This command must be run in online mode') expect(ipfs.swarm.connect.called).to.be.false() }) it('connect with timeout', async () => { - const multiaddr = new Multiaddr('/ip4/123.123.123.123/tcp/482') + const ma = multiaddr('/ip4/123.123.123.123/tcp/482') - ipfs.swarm.connect.withArgs(multiaddr, { + ipfs.swarm.connect.withArgs(ma, { ...defaultOptions, timeout: 1000 }).resolves() - const out = await cli(`swarm connect ${multiaddr} --timeout=1s`, { ipfs, isDaemon: true }) - expect(out).to.equal(`${multiaddr}\n`) + const out = await cli(`swarm connect ${ma} --timeout=1s`, { ipfs, isDaemon: true }) + expect(out).to.equal(`${ma}\n`) }) }) @@ -110,7 +110,7 @@ describe('swarm', () => { ipfs.swarm.addrs.withArgs(defaultOptions).resolves([{ id: peer, addrs: [ - new Multiaddr(addr) + multiaddr(addr) ] }]) @@ -128,7 +128,7 @@ describe('swarm', () => { }).resolves([{ id: peer, addrs: [ - new Multiaddr(addr) + multiaddr(addr) ] }]) @@ -175,26 +175,26 @@ describe('swarm', () => { } it('disconnect online', async () => { - const multiaddr = new Multiaddr('/ip4/123.123.123.123/tcp/482') - ipfs.swarm.disconnect.withArgs(multiaddr, defaultOptions).resolves() - const out = await cli(`swarm disconnect ${multiaddr}`, { ipfs, isDaemon: true }) - expect(out).to.equal(`${multiaddr}\n`) + const ma = multiaddr('/ip4/123.123.123.123/tcp/482') + ipfs.swarm.disconnect.withArgs(ma, defaultOptions).resolves() + const out = await cli(`swarm disconnect ${ma}`, { ipfs, isDaemon: true }) + expect(out).to.equal(`${ma}\n`) }) it('disconnect offline', async () => { - const multiaddr = new Multiaddr('/ip4/123.123.123.123/tcp/482') - const out = await fail(`swarm disconnect ${multiaddr}`, { ipfs, isDaemon: false }) + const ma = multiaddr('/ip4/123.123.123.123/tcp/482') + const out = await fail(`swarm disconnect ${ma}`, { ipfs, isDaemon: false }) expect(out).to.include('This command must be run in online mode') }) it('disconnect with timeout', async () => { - const multiaddr = new Multiaddr('/ip4/123.123.123.123/tcp/482') - ipfs.swarm.disconnect.withArgs(multiaddr, { + const ma = multiaddr('/ip4/123.123.123.123/tcp/482') + ipfs.swarm.disconnect.withArgs(ma, { ...defaultOptions, timeout: 1000 }).resolves() - const out = await cli(`swarm disconnect ${multiaddr} --timeout=1s`, { ipfs, isDaemon: true }) - expect(out).to.equal(`${multiaddr}\n`) + const out = await cli(`swarm disconnect ${ma} --timeout=1s`, { ipfs, isDaemon: true }) + expect(out).to.equal(`${ma}\n`) }) }) }) diff --git a/packages/ipfs-cli/test/utils/match-peer-id.js b/packages/ipfs-cli/test/utils/match-peer-id.js index 35dfa56b13..5095c2de9a 100644 --- a/packages/ipfs-cli/test/utils/match-peer-id.js +++ b/packages/ipfs-cli/test/utils/match-peer-id.js @@ -1,7 +1,7 @@ import sinon from 'sinon' /** - * @param {import('@libp2p/interfaces/peer-id').PeerId} peerId + * @param {import('@libp2p/interface-peer-id').PeerId} peerId * @returns {import('sinon').SinonMatcher} */ export function matchPeerId (peerId) { diff --git a/packages/ipfs-client/CHANGELOG.md b/packages/ipfs-client/CHANGELOG.md index c1e910376e..7f40df6471 100644 --- a/packages/ipfs-client/CHANGELOG.md +++ b/packages/ipfs-client/CHANGELOG.md @@ -3,6 +3,45 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +### [0.9.2](https://www.github.com/ipfs/js-ipfs/compare/ipfs-client-v0.9.1...ipfs-client-v0.9.2) (2022-10-24) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-grpc-client bumped from ^0.11.1 to ^0.12.0 + * ipfs-http-client bumped from ^58.0.1 to ^59.0.0 + +### [0.9.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-client-v0.9.0...ipfs-client-v0.9.1) (2022-09-21) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-grpc-client bumped from ^0.11.0 to ^0.11.1 + * ipfs-http-client bumped from ^58.0.0 to ^58.0.1 + +## [0.9.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-client-v0.8.3...ipfs-client-v0.9.0) (2022-09-06) + + +### ⚠ BREAKING CHANGES + +* update to libp2p@0.38.x (#4151) + +### deps + +* update to libp2p@0.38.x ([#4151](https://www.github.com/ipfs/js-ipfs/issues/4151)) ([39dbf70](https://www.github.com/ipfs/js-ipfs/commit/39dbf708ec31b263115e44f420651fa4e056a89e)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-grpc-client bumped from ^0.10.0 to ^0.11.0 + * ipfs-http-client bumped from ^57.0.0 to ^58.0.0 + ### [0.8.3](https://www.github.com/ipfs/js-ipfs/compare/ipfs-client-v0.8.2...ipfs-client-v0.8.3) (2022-06-24) diff --git a/packages/ipfs-client/LICENSE b/packages/ipfs-client/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-client/LICENSE @@ -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 diff --git a/packages/ipfs-client/LICENSE-APACHE b/packages/ipfs-client/LICENSE-APACHE new file mode 100644 index 0000000000..14478a3b60 --- /dev/null +++ b/packages/ipfs-client/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/ipfs-client/LICENSE-MIT b/packages/ipfs-client/LICENSE-MIT new file mode 100644 index 0000000000..72dc60d84b --- /dev/null +++ b/packages/ipfs-client/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +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. diff --git a/packages/ipfs-client/README.md b/packages/ipfs-client/README.md index 4d1d37ff09..468fcc47aa 100644 --- a/packages/ipfs-client/README.md +++ b/packages/ipfs-client/README.md @@ -1,15 +1,33 @@ -# ipfs-client +# ipfs-client -> A client for [ipfs][] daemons +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -This module combines the [ipfs-grpc-client][] and [ipfs-http-client][] modules to give you a client that is capable of bidirectional streaming in the browser as well as node. +> A client library to talk to local IPFS daemons + +## Table of contents + +- [Install](#install) +- [API](#api) + - [`create([options])`](#createoptions) + - [Parameters](#parameters) + - [Options](#options) + - [Returns](#returns) + - [Example](#example) +- [License](#license) +- [Contribute](#contribute) ## Install ```console -$ npm install ipfs-client +$ npm i ipfs-client ``` +This module combines the [ipfs-grpc-client][] and [ipfs-http-client][] modules to give you a client that is capable of bidirectional streaming in the browser as well as node. + ## API The client object created by the `createClient` function supports the [IPFS Core API](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api), see the docs for more. @@ -24,16 +42,16 @@ None An optional object which may have the following keys: -| Name | Type | Default | Description | -| ---- | ---- | ------- | ----------- | -| grpc | `Multiaddr` or `string` or `URL` | `undefined` | The address of a [ipfs-grpc-server][] to connect to | -| http | `Multiaddr` or `string` or `URL` | `undefined` | The address of a [ipfs-http-server][] to connect to | +| Name | Type | Default | Description | +| ----- | -------------------------------------------------------------------- | ----------- | ----------------------------------------------------------------- | +| grpc | `Multiaddr` or `string` or `URL` | `undefined` | The address of a [ipfs-grpc-server][] to connect to | +| http | `Multiaddr` or `string` or `URL` | `undefined` | The address of a [ipfs-http-server][] to connect to | | agent | [http.Agent](https://nodejs.org/api/http.html#http_class_http_agent) | `undefined` | A http.Agent used to control HTTP client behaviour (node.js only) | ### Returns -| Type | Description | -| -------- | -------- | +| Type | Description | +| -------- | ------------------------- | | `object` | An instance of the client | ### Example @@ -49,8 +67,31 @@ const client = create({ const id = await client.id() ``` +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). + +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. + +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) + [ipfs]: https://www.npmjs.com/package/ipfs + [ipfs-grpc-client]: https://www.npmjs.com/package/ipfs-grpc-client + [ipfs-http-client]: https://www.npmjs.com/package/ipfs-http-client + [ipfs-grpc-server]: https://www.npmjs.com/package/ipfs-grpc-server + [ipfs-http-server]: https://www.npmjs.com/package/ipfs-http-server diff --git a/packages/ipfs-client/package.json b/packages/ipfs-client/package.json index 457c842aad..f22f85c30e 100644 --- a/packages/ipfs-client/package.json +++ b/packages/ipfs-client/package.json @@ -1,35 +1,58 @@ { "name": "ipfs-client", - "version": "0.8.3", + "version": "0.9.2", "description": "A client library to talk to local IPFS daemons", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-client#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "ipfs" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-client#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ], + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ] + } + }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - } - }, "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" } }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } }, "scripts": { "build": "aegir build", @@ -38,8 +61,8 @@ "dep-check": "aegir dep-check -i aegir" }, "dependencies": { - "ipfs-grpc-client": "^0.10.2", - "ipfs-http-client": "^57.0.3", + "ipfs-grpc-client": "^0.12.0", + "ipfs-http-client": "^59.0.0", "merge-options": "^3.0.4" }, "devDependencies": { diff --git a/packages/ipfs-client/tsconfig.json b/packages/ipfs-client/tsconfig.json index e6c324da5b..a5eb86d485 100644 --- a/packages/ipfs-client/tsconfig.json +++ b/packages/ipfs-client/tsconfig.json @@ -9,10 +9,10 @@ ], "references": [ { - "path": "../ipfs-http-client" + "path": "../ipfs-grpc-client" }, { - "path": "../ipfs-grpc-client" + "path": "../ipfs-http-client" } ] } diff --git a/packages/ipfs-core-config/CHANGELOG.md b/packages/ipfs-core-config/CHANGELOG.md index b73e37d17d..7a13703a7a 100644 --- a/packages/ipfs-core-config/CHANGELOG.md +++ b/packages/ipfs-core-config/CHANGELOG.md @@ -3,6 +3,56 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.6.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-core-config-v0.5.1...ipfs-core-config-v0.6.0) (2022-10-24) + + +### ⚠ BREAKING CHANGES + +* ipfs is now bundled with libp2p@0.40.x which has different config + +### Features + +* upgrade libp2p to 0.40.x ([#4237](https://www.github.com/ipfs/js-ipfs/issues/4237)) ([0cee4a4](https://www.github.com/ipfs/js-ipfs/commit/0cee4a4c55767022584dcbade0b0b9b43326f9c9)) + + +### Dependencies + +* The following workspace dependencies were updated + * devDependencies + * ipfs-core-utils bumped from ^0.16.1 to ^0.17.0 + +### [0.5.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-core-config-v0.5.0...ipfs-core-config-v0.5.1) (2022-09-21) + + +### Bug Fixes + +* update @multiformats/multiadd to 11.0.0 ([2a830bf](https://www.github.com/ipfs/js-ipfs/commit/2a830bf58a5929fcce51dede871c99f62192fbda)) + + +### Dependencies + +* The following workspace dependencies were updated + * devDependencies + * ipfs-core-utils bumped from ^0.16.0 to ^0.16.1 + +## [0.5.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-core-config-v0.4.1...ipfs-core-config-v0.5.0) (2022-09-06) + + +### ⚠ BREAKING CHANGES + +* update to libp2p@0.38.x (#4151) + +### deps + +* update to libp2p@0.38.x ([#4151](https://www.github.com/ipfs/js-ipfs/issues/4151)) ([39dbf70](https://www.github.com/ipfs/js-ipfs/commit/39dbf708ec31b263115e44f420651fa4e056a89e)) + + +### Dependencies + +* The following workspace dependencies were updated + * devDependencies + * ipfs-core-utils bumped from ^0.15.0 to ^0.16.0 + ### [0.4.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-core-config-v0.4.0...ipfs-core-config-v0.4.1) (2022-06-22) diff --git a/packages/ipfs-core-config/LICENSE b/packages/ipfs-core-config/LICENSE index 2c624782f3..20ce483c86 100644 --- a/packages/ipfs-core-config/LICENSE +++ b/packages/ipfs-core-config/LICENSE @@ -1,22 +1,4 @@ -The MIT License (MIT) - -Copyright (c) IPFS - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -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. +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 diff --git a/packages/ipfs-core-config/LICENSE-APACHE b/packages/ipfs-core-config/LICENSE-APACHE new file mode 100644 index 0000000000..14478a3b60 --- /dev/null +++ b/packages/ipfs-core-config/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/ipfs-core-config/LICENSE-MIT b/packages/ipfs-core-config/LICENSE-MIT new file mode 100644 index 0000000000..72dc60d84b --- /dev/null +++ b/packages/ipfs-core-config/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +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. diff --git a/packages/ipfs-core-config/README.md b/packages/ipfs-core-config/README.md index 661851a76d..14218e9c74 100644 --- a/packages/ipfs-core-config/README.md +++ b/packages/ipfs-core-config/README.md @@ -1,33 +1,40 @@ -# ipfs-core-utils +# ipfs-core-config -[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai) -[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) -[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) -[![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs)](https://travis-ci.com/ipfs/js-ipfs) -[![Codecov branch](https://img.shields.io/codecov/c/github/ipfs/js-ipfs/master.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) -[![Dependency Status](https://david-dm.org/ipfs/js-ipfs/status.svg?path=packages/ipfs-core-config)](https://david-dm.org/ipfs/js-ipfs?path=packages/ipfs-core-config) -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -> This package serves as a repository code shared between the core `ipfs` core implementation and the `ipfs-http-client` +> Package to store node and browser specific config for ipfs-core -## Table of Contents +## Table of contents - [Install](#install) -- [Contribute](#contribute) - [License](#license) +- [Contribute](#contribute) ## Install -```bash -$ npm install --save ipfs-core-utils +```console +$ npm i ipfs-core-config ``` +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + ## Contribute -Contributions welcome. Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). -Check out our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. -## License +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. -[MIT](LICENSE) © Protocol Labs Inc. +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs-core-config/package.json b/packages/ipfs-core-config/package.json index 36f0474c78..9d467a388d 100644 --- a/packages/ipfs-core-config/package.json +++ b/packages/ipfs-core-config/package.json @@ -1,13 +1,23 @@ { "name": "ipfs-core-config", - "version": "0.4.1", + "version": "0.6.0", "description": "Package to store node and browser specific config for ipfs-core", "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-core-config#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", "typesVersions": { "*": { "*": [ @@ -25,52 +35,57 @@ } }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - } - }, "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" }, "./config": { + "types": "./src/config.d.ts", "browser": "./src/config.browser.js", "import": "./src/config.js" }, "./dns": { + "types": "./src/dns.d.ts", "browser": "./src/dns.browser.js", "import": "./src/dns.js" }, "./init-assets": { + "types": "./src/init-assets.d.ts", "browser": "./src/init-assets.browser.js", "import": "./src/init-assets.js" }, "./libp2p": { + "types": "./src/libp2p.d.ts", "browser": "./src/libp2p.browser.js", "import": "./src/libp2p.js" }, "./libp2p-pubsub-routers": { + "types": "./src/libp2p-pubsub-routers.d.ts", "browser": "./src/libp2p-pubsub-routers.browser.js", "import": "./src/libp2p-pubsub-routers.js" }, "./preload": { + "types": "./src/preload.d.ts", "browser": "./src/preload.browser.js", "import": "./src/preload.js" }, "./repo": { + "types": "./src/repo.d.ts", "browser": "./src/repo.browser.js", "import": "./src/repo.js" } }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } }, "scripts": { "lint": "aegir lint", @@ -78,32 +93,31 @@ "dep-check": "aegir dep-check -i aegir -i ipfs-core-utils", "build": "aegir build" }, - "license": "MIT", "dependencies": { - "@chainsafe/libp2p-gossipsub": "^1.0.0", - "@libp2p/floodsub": "^1.0.2", - "@libp2p/logger": "^1.1.4", - "@libp2p/mdns": "^1.0.3", - "@libp2p/tcp": "^1.0.6", - "@libp2p/webrtc-star": "^1.0.6", - "blockstore-datastore-adapter": "^2.0.2", - "datastore-core": "^7.0.0", - "datastore-fs": "^7.0.0", - "datastore-level": "^8.0.0", + "@chainsafe/libp2p-gossipsub": "^4.0.0", + "@libp2p/floodsub": "^5.0.0", + "@libp2p/logger": "^2.0.2", + "@libp2p/mdns": "^5.0.0", + "@libp2p/tcp": "^5.0.0", + "@libp2p/webrtc-star": "^5.0.2", + "blockstore-datastore-adapter": "^4.0.0", + "datastore-core": "^8.0.1", + "datastore-fs": "^8.0.0", + "datastore-level": "^9.0.0", "err-code": "^3.0.1", "hashlru": "^2.3.0", - "interface-datastore": "^6.1.1", - "ipfs-repo": "^14.0.1", + "interface-datastore": "^7.0.0", + "ipfs-repo": "^16.0.0", "ipfs-utils": "^9.0.6", - "is-ipfs": "^6.0.1", - "it-all": "^1.0.4", - "it-drain": "^1.0.3", - "it-foreach": "^0.1.1", + "is-ipfs": "^7.0.0", + "it-all": "^2.0.0", + "it-drain": "^2.0.0", + "it-foreach": "^1.0.0", "p-queue": "^7.2.0", - "uint8arrays": "^3.0.0" + "uint8arrays": "^4.0.2" }, "devDependencies": { "aegir": "^37.0.11", - "ipfs-core-utils": "^0.15.1" + "ipfs-core-utils": "^0.17.0" } } diff --git a/packages/ipfs-core-config/src/dns.js b/packages/ipfs-core-config/src/dns.js index 9291653c5f..a869bbd9a0 100644 --- a/packages/ipfs-core-config/src/dns.js +++ b/packages/ipfs-core-config/src/dns.js @@ -1,5 +1,5 @@ import dns from 'dns' -import isIPFS from 'is-ipfs' +import * as isIPFS from 'is-ipfs' import errcode from 'err-code' import { promisify } from 'util' diff --git a/packages/ipfs-core-config/src/libp2p-pubsub-routers.browser.js b/packages/ipfs-core-config/src/libp2p-pubsub-routers.browser.js index 0dff8d6e33..476df5b6c4 100644 --- a/packages/ipfs-core-config/src/libp2p-pubsub-routers.browser.js +++ b/packages/ipfs-core-config/src/libp2p-pubsub-routers.browser.js @@ -1,12 +1,34 @@ import { GossipSub } from '@chainsafe/libp2p-gossipsub' -/** @typedef {import('@libp2p/interfaces/pubsub').PubSub} PubSub */ +/** @typedef {import('@libp2p/interface-pubsub').PubSub} PubSub */ -/** @type {() => Record}>} */ +/** @type {() => Record PubSub>}>} */ export const routers = () => ({ - gossipsub: new GossipSub({ - allowPublishToZeroPeers: true, - fallbackToFloodsub: true, - emitSelf: true - }) + // @ts-expect-error GossubSub is out of date + gossipsub: (/** @type {any} */ components) => { + const gossipsub = new GossipSub({ + allowPublishToZeroPeers: true, + fallbackToFloodsub: true, + emitSelf: true, + maxInboundStreams: 64, + maxOutboundStreams: 128 + }) + // @ts-expect-error GossubSub is out of date + gossipsub.init({ + getPeerId () { + return components.peerId + }, + getPeerStore () { + return components.peerStore + }, + getRegistrar () { + return components.registrar + }, + getConnectionManager () { + return components.connectionManager + } + }) + + return gossipsub + } }) diff --git a/packages/ipfs-core-config/src/libp2p-pubsub-routers.js b/packages/ipfs-core-config/src/libp2p-pubsub-routers.js index 0acbb0f49c..1d5dd7cb5e 100644 --- a/packages/ipfs-core-config/src/libp2p-pubsub-routers.js +++ b/packages/ipfs-core-config/src/libp2p-pubsub-routers.js @@ -1,16 +1,38 @@ import { GossipSub } from '@chainsafe/libp2p-gossipsub' -import { FloodSub } from '@libp2p/floodsub' +import { floodsub } from '@libp2p/floodsub' -/** @typedef {import('@libp2p/interfaces/pubsub').PubSub} PubSub */ +/** @typedef {import('@libp2p/interface-pubsub').PubSub} PubSub */ -/** @type {() => Record}>} */ +/** @type {() => Record PubSub>}>} */ export const routers = () => ({ - gossipsub: new GossipSub({ - allowPublishToZeroPeers: true, - fallbackToFloodsub: true, - emitSelf: true - }), - floodsub: new FloodSub({ + // @ts-expect-error GossubSub is out of date + gossipsub: (/** @type {any} */ components) => { + const gossipsub = new GossipSub({ + allowPublishToZeroPeers: true, + fallbackToFloodsub: true, + emitSelf: true, + maxInboundStreams: 64, + maxOutboundStreams: 128 + }) + // @ts-expect-error GossubSub is out of date + gossipsub.init({ + getPeerId () { + return components.peerId + }, + getPeerStore () { + return components.peerStore + }, + getRegistrar () { + return components.registrar + }, + getConnectionManager () { + return components.connectionManager + } + }) + + return gossipsub + }, + floodsub: floodsub({ emitSelf: true }) }) diff --git a/packages/ipfs-core-config/src/libp2p.browser.js b/packages/ipfs-core-config/src/libp2p.browser.js index 59de391ffd..f5f5d34225 100644 --- a/packages/ipfs-core-config/src/libp2p.browser.js +++ b/packages/ipfs-core-config/src/libp2p.browser.js @@ -1,12 +1,12 @@ -import { WebRTCStar } from '@libp2p/webrtc-star' +import { webRTCStar } from '@libp2p/webrtc-star' export function libp2pConfig () { - const webRtcStar = new WebRTCStar() + const webRtcStar = webRTCStar() /** @type {import('libp2p').Libp2pOptions} */ const options = { transports: [ - webRtcStar + webRtcStar.transport ], peerDiscovery: [ webRtcStar.discovery diff --git a/packages/ipfs-core-config/src/libp2p.js b/packages/ipfs-core-config/src/libp2p.js index 57032303da..01c4cb97f6 100644 --- a/packages/ipfs-core-config/src/libp2p.js +++ b/packages/ipfs-core-config/src/libp2p.js @@ -1,15 +1,15 @@ -import { TCP } from '@libp2p/tcp' -import { MulticastDNS } from '@libp2p/mdns' +import { tcp } from '@libp2p/tcp' +import { mdns } from '@libp2p/mdns' import os from 'os' export function libp2pConfig () { /** @type {import('libp2p').Libp2pOptions} */ const options = { transports: [ - new TCP() + tcp() ], peerDiscovery: [ - new MulticastDNS() + mdns() ], connectionManager: { maxParallelDials: 150, // 150 total parallel multiaddr dials diff --git a/packages/ipfs-core-config/tsconfig.json b/packages/ipfs-core-config/tsconfig.json index b3e9d0eb46..b32180efc4 100644 --- a/packages/ipfs-core-config/tsconfig.json +++ b/packages/ipfs-core-config/tsconfig.json @@ -10,7 +10,7 @@ ], "references": [ { - "path": "../ipfs-core-types" + "path": "../ipfs-core-utils" } ] } diff --git a/packages/ipfs-core-types/CHANGELOG.md b/packages/ipfs-core-types/CHANGELOG.md index 3e2233dc04..3448740886 100644 --- a/packages/ipfs-core-types/CHANGELOG.md +++ b/packages/ipfs-core-types/CHANGELOG.md @@ -4,6 +4,35 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.13.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-core-types-v0.12.1...ipfs-core-types-v0.13.0) (2022-10-24) + + +### ⚠ BREAKING CHANGES + +* ipfs is now bundled with libp2p@0.40.x which has different config + +### Features + +* upgrade libp2p to 0.40.x ([#4237](https://www.github.com/ipfs/js-ipfs/issues/4237)) ([0cee4a4](https://www.github.com/ipfs/js-ipfs/commit/0cee4a4c55767022584dcbade0b0b9b43326f9c9)) + +### [0.12.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-core-types-v0.12.0...ipfs-core-types-v0.12.1) (2022-09-21) + + +### Bug Fixes + +* update @multiformats/multiadd to 11.0.0 ([2a830bf](https://www.github.com/ipfs/js-ipfs/commit/2a830bf58a5929fcce51dede871c99f62192fbda)) + +## [0.12.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-core-types-v0.11.1...ipfs-core-types-v0.12.0) (2022-09-06) + + +### ⚠ BREAKING CHANGES + +* update to libp2p@0.38.x (#4151) + +### deps + +* update to libp2p@0.38.x ([#4151](https://www.github.com/ipfs/js-ipfs/issues/4151)) ([39dbf70](https://www.github.com/ipfs/js-ipfs/commit/39dbf708ec31b263115e44f420651fa4e056a89e)) + ### [0.11.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-core-types-v0.11.0...ipfs-core-types-v0.11.1) (2022-06-22) diff --git a/packages/ipfs-core-types/LICENSE b/packages/ipfs-core-types/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-core-types/LICENSE @@ -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 diff --git a/packages/ipfs-core-types/LICENSE-MIT b/packages/ipfs-core-types/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/packages/ipfs-core-types/LICENSE-MIT +++ b/packages/ipfs-core-types/LICENSE-MIT @@ -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. \ No newline at end of file +THE SOFTWARE. diff --git a/packages/ipfs-core-types/README.md b/packages/ipfs-core-types/README.md index 37a5abce74..74084e05de 100644 --- a/packages/ipfs-core-types/README.md +++ b/packages/ipfs-core-types/README.md @@ -1,24 +1,29 @@ # ipfs-core-types -[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) -[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) -[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) -[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme) -[![Dependency Status](https://david-dm.org/ipfs/js-ipfs/status.svg?style=flat-square&path=packages/ipfs-core-types)](https://david-dm.org/ipfs/js-ipfs?path=packages/ipfs-core-types) +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -> IPFS interface definitions used by implementations for API compatibility +> IPFS interface definitions used by implementations for API compatibility. -## Table of Contents +## Table of contents -- [Background](#background) - [Install](#install) +- [Background](#background) - [Usage](#usage) - [In JSDoc syntax](#in-jsdoc-syntax) - [In Typescript](#in-typescript) - [Validation](#validation) -- [Contribute](#contribute) - - [Want to hack on IPFS?](#want-to-hack-on-ipfs) - [License](#license) +- [Contribute](#contribute) + +## Install + +```console +$ npm i ipfs-core-types +``` ## Background @@ -26,10 +31,6 @@ The primary goal of this module is to define and ensure that IPFS core implement It offers a set of typescript interface definitions that define the IPFS core API. Once your implementation implements those APIs you can use the tests found in the [interface-ipfs-core](https://www.npmjs.com/package/interface-ipfs-core) module to validate your implementation. -## Install - -In JavaScript land: - ```console $ npm install ipfs-core-types ``` @@ -62,19 +63,21 @@ class MyImpl implements IPFS { In order to validate API compatibility you can run [typescript](https://www.typescriptlang.org/) over your implementation which will point out all the API compatibilities if there are some. +## License -## Contribute +Licensed under either of -Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/js-ipfs/issues)! +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) -This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). +## Contribute -### Want to hack on IPFS? +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). -[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. -## License +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. -[![](https://github.com/ipfs/js-ipfs/raw/master/ipfs-core-types/img/badge.png)](https://github.com/ipfs/js-ipfs/tree/master/ipfs-core-types) +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs-core-types/package.json b/packages/ipfs-core-types/package.json index 91cc7ab06c..fe6156f316 100644 --- a/packages/ipfs-core-types/package.json +++ b/packages/ipfs-core-types/package.json @@ -1,61 +1,64 @@ { "name": "ipfs-core-types", - "version": "0.11.1", + "version": "0.13.0", "description": "IPFS interface definitions used by implementations for API compatibility.", - "types": "dist/src/index.d.ts", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-core-types#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "scripts": { - "clean": "aegir clean", - "lint": "aegir lint", - "build": "aegir build" + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, + "keywords": [ + "API", + "IPFS", + "interface", + "types" + ], + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" }, + "type": "module", + "types": "./dist/src/index.d.ts", "files": [ - "dist", "src", + "dist/src", + "!dist/test", "!**/*.tsbuildinfo" ], - "typesVersions": { - "*": { - "*": [ - "*", - "dist/*", - "dist/src/*", - "dist/src/*/index" - ], - "src/*": [ - "*", - "dist/*", - "dist/src/*", - "dist/src/*/index" - ] + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./dist/src/index.js" } }, "eslintConfig": { - "extends": "ipfs" + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" + "scripts": { + "clean": "aegir clean", + "lint": "aegir lint", + "build": "aegir build" }, - "keywords": [ - "IPFS", - "types", - "interface", - "API" - ], - "license": "(Apache-2.0 OR MIT)", "dependencies": { - "@ipld/dag-pb": "^2.1.3", - "interface-datastore": "^6.1.1", - "ipfs-unixfs": "^6.0.9", - "@multiformats/multiaddr": "^10.0.0", - "multiformats": "^9.5.1" + "@ipld/dag-pb": "^3.0.0", + "@libp2p/interface-keychain": "^1.0.3", + "@libp2p/interface-peer-id": "^1.0.4", + "@libp2p/interface-peer-info": "^1.0.2", + "@libp2p/interface-pubsub": "^3.0.0", + "@multiformats/multiaddr": "^11.0.0", + "@types/node": "^18.0.0", + "interface-datastore": "^7.0.0", + "ipfs-unixfs": "^8.0.0", + "multiformats": "^10.0.0" }, "devDependencies": { "aegir": "^37.0.11" - }, - "contributors": [ - "Irakli Gozalishvili " - ] + } } diff --git a/packages/ipfs-core-types/src/bitswap/index.ts b/packages/ipfs-core-types/src/bitswap/index.ts index b239fac72e..3fa2123f58 100644 --- a/packages/ipfs-core-types/src/bitswap/index.ts +++ b/packages/ipfs-core-types/src/bitswap/index.ts @@ -1,6 +1,6 @@ import type { CID } from 'multiformats/cid' import type { AbortOptions } from '../utils' -import type { PeerId } from '@libp2p/interfaces/peer-id' +import type { PeerId } from '@libp2p/interface-peer-id' export interface API { /** diff --git a/packages/ipfs-core-types/src/block/index.ts b/packages/ipfs-core-types/src/block/index.ts index 9872bec152..5b0c7a9cef 100644 --- a/packages/ipfs-core-types/src/block/index.ts +++ b/packages/ipfs-core-types/src/block/index.ts @@ -1,5 +1,5 @@ import type { AbortOptions, PreloadOptions } from '../utils' -import type { CID, CIDVersion } from 'multiformats/cid' +import type { CID, Version as CIDVersion } from 'multiformats/cid' export interface API { /** diff --git a/packages/ipfs-core-types/src/dag/index.ts b/packages/ipfs-core-types/src/dag/index.ts index 875ea131cc..116ee95b33 100644 --- a/packages/ipfs-core-types/src/dag/index.ts +++ b/packages/ipfs-core-types/src/dag/index.ts @@ -1,5 +1,5 @@ import type { AbortOptions, PreloadOptions, IPFSPath } from '../utils' -import type { CID, CIDVersion } from 'multiformats/cid' +import type { CID, Version as CIDVersion } from 'multiformats/cid' export interface API { /** diff --git a/packages/ipfs-core-types/src/dht/index.ts b/packages/ipfs-core-types/src/dht/index.ts index fa25233fd2..55676c2fcf 100644 --- a/packages/ipfs-core-types/src/dht/index.ts +++ b/packages/ipfs-core-types/src/dht/index.ts @@ -1,7 +1,7 @@ import type { AbortOptions } from '../utils' import type { CID } from 'multiformats/cid' -import type { PeerId } from '@libp2p/interfaces/peer-id' -import type { PeerInfo } from '@libp2p/interfaces/peer-info' +import type { PeerId } from '@libp2p/interface-peer-id' +import type { PeerInfo } from '@libp2p/interface-peer-info' export interface API { /** diff --git a/packages/ipfs-core-types/src/files/index.ts b/packages/ipfs-core-types/src/files/index.ts index c30f59334f..d64614a74a 100644 --- a/packages/ipfs-core-types/src/files/index.ts +++ b/packages/ipfs-core-types/src/files/index.ts @@ -1,5 +1,5 @@ import type { AbortOptions, IPFSPath } from '../utils' -import type { CID, CIDVersion } from 'multiformats/cid' +import type { CID, Version as CIDVersion } from 'multiformats/cid' import type { Mtime, MtimeLike } from 'ipfs-unixfs' import type { AddProgressFn } from '../root' diff --git a/packages/ipfs-core-types/src/key/index.ts b/packages/ipfs-core-types/src/key/index.ts index a848196a8d..2d3f5698dd 100644 --- a/packages/ipfs-core-types/src/key/index.ts +++ b/packages/ipfs-core-types/src/key/index.ts @@ -1,5 +1,5 @@ import type { AbortOptions } from '../utils' -import type { KeyType } from '@libp2p/interfaces/keychain' +import type { KeyType } from '@libp2p/interface-keychain' export interface API { /** diff --git a/packages/ipfs-core-types/src/name/index.ts b/packages/ipfs-core-types/src/name/index.ts index 300c899f3c..de824e6cc6 100644 --- a/packages/ipfs-core-types/src/name/index.ts +++ b/packages/ipfs-core-types/src/name/index.ts @@ -1,7 +1,7 @@ import type { CID } from 'multiformats/cid' import type { AbortOptions } from '../utils' import type { API as PubsubAPI } from './pubsub' -import type { PeerId } from '@libp2p/interfaces/peer-id' +import type { PeerId } from '@libp2p/interface-peer-id' export interface API { /** diff --git a/packages/ipfs-core-types/src/pubsub/index.ts b/packages/ipfs-core-types/src/pubsub/index.ts index fbac8ed74b..6768cae695 100644 --- a/packages/ipfs-core-types/src/pubsub/index.ts +++ b/packages/ipfs-core-types/src/pubsub/index.ts @@ -1,6 +1,6 @@ import type { AbortOptions } from '../utils' -import type { PeerId } from '@libp2p/interfaces/peer-id' -import type { Message } from '@libp2p/interfaces/pubsub' +import type { PeerId } from '@libp2p/interface-peer-id' +import type { Message } from '@libp2p/interface-pubsub' import type { EventHandler } from '@libp2p/interfaces/events' export interface API { diff --git a/packages/ipfs-core-types/src/root.ts b/packages/ipfs-core-types/src/root.ts index 6ca27dcdc4..c12ad0e832 100644 --- a/packages/ipfs-core-types/src/root.ts +++ b/packages/ipfs-core-types/src/root.ts @@ -1,8 +1,8 @@ import type { AbortOptions, PreloadOptions, IPFSPath, ImportCandidateStream, ImportCandidate } from './utils' -import type { CID, CIDVersion } from 'multiformats/cid' +import type { CID, Version as CIDVersion } from 'multiformats/cid' import type { Mtime } from 'ipfs-unixfs' import type { Multiaddr } from '@multiformats/multiaddr' -import type { PeerId } from '@libp2p/interfaces/peer-id' +import type { PeerId } from '@libp2p/interface-peer-id' export interface API { /** @@ -260,7 +260,7 @@ export interface CatOptions extends AbortOptions, PreloadOptions { export interface GetOptions extends AbortOptions, PreloadOptions { archive?: boolean compress?: boolean - compressionLevel?: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6| 7 | 8| 9 + compressionLevel?: -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 } export interface ListOptions extends AbortOptions, PreloadOptions { diff --git a/packages/ipfs-core-types/src/stats/index.ts b/packages/ipfs-core-types/src/stats/index.ts index 43f69ce1e4..fba9aba2a9 100644 --- a/packages/ipfs-core-types/src/stats/index.ts +++ b/packages/ipfs-core-types/src/stats/index.ts @@ -1,7 +1,7 @@ import type { AbortOptions } from '../utils' import type { API as BitswapAPI } from '../bitswap' import type { API as RepoAPI } from '../repo' -import type { PeerId } from '@libp2p/interfaces/peer-id' +import type { PeerId } from '@libp2p/interface-peer-id' export interface API { bitswap: BitswapAPI['stat'] diff --git a/packages/ipfs-core-types/src/swarm/index.ts b/packages/ipfs-core-types/src/swarm/index.ts index 48849531e6..f8bbf4362f 100644 --- a/packages/ipfs-core-types/src/swarm/index.ts +++ b/packages/ipfs-core-types/src/swarm/index.ts @@ -1,6 +1,6 @@ import type { AbortOptions } from '../utils' import type { Multiaddr } from '@multiformats/multiaddr' -import type { PeerId } from '@libp2p/interfaces/peer-id' +import type { PeerId } from '@libp2p/interface-peer-id' export interface API { /** diff --git a/packages/ipfs-core-types/src/utils.ts b/packages/ipfs-core-types/src/utils.ts index 1833a70b04..ae7e726bb8 100644 --- a/packages/ipfs-core-types/src/utils.ts +++ b/packages/ipfs-core-types/src/utils.ts @@ -1,7 +1,7 @@ import type { CID } from 'multiformats/cid' import type { Mtime, MtimeLike } from 'ipfs-unixfs' -export type Entry|Blob> = +export type Entry | Blob> = | FileEntry | DirectoryEntry @@ -10,7 +10,7 @@ export interface BaseEntry { mode?: number mtime?: Mtime } -export interface FileEntry |Blob> extends BaseEntry { +export interface FileEntry | Blob> extends BaseEntry { content?: Content } @@ -119,7 +119,7 @@ export interface PreloadOptions { export type IPFSPath = CID | string export interface BufferStore { - put: (key: Uint8Array, value: Uint8Array) => Promise - get: (key: Uint8Array) => Promise + put: (key: Uint8Array, value: Uint8Array, options?: AbortOptions) => Promise + get: (key: Uint8Array, options?: AbortOptions) => Promise stores: any[] } diff --git a/packages/ipfs-core-types/tsconfig.json b/packages/ipfs-core-types/tsconfig.json index 8988b1e0a2..5fe8ea40d7 100644 --- a/packages/ipfs-core-types/tsconfig.json +++ b/packages/ipfs-core-types/tsconfig.json @@ -1,8 +1,7 @@ { "extends": "aegir/src/config/tsconfig.aegir.json", "compilerOptions": { - "outDir": "dist", - "emitDeclarationOnly": true + "outDir": "dist" }, "include": [ "src" diff --git a/packages/ipfs-core-utils/CHANGELOG.md b/packages/ipfs-core-utils/CHANGELOG.md index 352f83c5ee..ea41400734 100644 --- a/packages/ipfs-core-utils/CHANGELOG.md +++ b/packages/ipfs-core-utils/CHANGELOG.md @@ -4,6 +4,56 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.17.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-core-utils-v0.16.1...ipfs-core-utils-v0.17.0) (2022-10-24) + + +### ⚠ BREAKING CHANGES + +* ipfs is now bundled with libp2p@0.40.x which has different config + +### Features + +* upgrade libp2p to 0.40.x ([#4237](https://www.github.com/ipfs/js-ipfs/issues/4237)) ([0cee4a4](https://www.github.com/ipfs/js-ipfs/commit/0cee4a4c55767022584dcbade0b0b9b43326f9c9)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.12.1 to ^0.13.0 + +### [0.16.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-core-utils-v0.16.0...ipfs-core-utils-v0.16.1) (2022-09-21) + + +### Bug Fixes + +* update @multiformats/multiadd to 11.0.0 ([2a830bf](https://www.github.com/ipfs/js-ipfs/commit/2a830bf58a5929fcce51dede871c99f62192fbda)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.12.0 to ^0.12.1 + +## [0.16.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-core-utils-v0.15.1...ipfs-core-utils-v0.16.0) (2022-09-06) + + +### ⚠ BREAKING CHANGES + +* update to libp2p@0.38.x (#4151) + +### deps + +* update to libp2p@0.38.x ([#4151](https://www.github.com/ipfs/js-ipfs/issues/4151)) ([39dbf70](https://www.github.com/ipfs/js-ipfs/commit/39dbf708ec31b263115e44f420651fa4e056a89e)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.11.0 to ^0.12.0 + ### [0.15.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-core-utils-v0.15.0...ipfs-core-utils-v0.15.1) (2022-06-22) @@ -690,4 +740,4 @@ js-ipfs ### Bug Fixes -* use is-buffer ([bbf5baf](https://github.com/ipfs/js-ipfs-utils/commit/bbf5baf)) +* use is-buffer ([bbf5baf](https://github.com/ipfs/js-ipfs-utils/commit/bbf5baf)) \ No newline at end of file diff --git a/packages/ipfs-core-utils/LICENSE b/packages/ipfs-core-utils/LICENSE index 2c624782f3..20ce483c86 100644 --- a/packages/ipfs-core-utils/LICENSE +++ b/packages/ipfs-core-utils/LICENSE @@ -1,22 +1,4 @@ -The MIT License (MIT) - -Copyright (c) IPFS - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -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. +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 diff --git a/packages/ipfs-core-utils/LICENSE-APACHE b/packages/ipfs-core-utils/LICENSE-APACHE new file mode 100644 index 0000000000..14478a3b60 --- /dev/null +++ b/packages/ipfs-core-utils/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/ipfs-core-utils/LICENSE-MIT b/packages/ipfs-core-utils/LICENSE-MIT new file mode 100644 index 0000000000..72dc60d84b --- /dev/null +++ b/packages/ipfs-core-utils/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +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. diff --git a/packages/ipfs-core-utils/README.md b/packages/ipfs-core-utils/README.md index 0f3319d8d8..5a3d3c05b4 100644 --- a/packages/ipfs-core-utils/README.md +++ b/packages/ipfs-core-utils/README.md @@ -1,33 +1,40 @@ # ipfs-core-utils -[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai) -[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) -[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) -[![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs)](https://travis-ci.com/ipfs/js-ipfs) -[![Codecov branch](https://img.shields.io/codecov/c/github/ipfs/js-ipfs/master.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) -[![Dependency Status](https://david-dm.org/ipfs/js-ipfs/status.svg?path=packages/ipfs-core-utils)](https://david-dm.org/ipfs/js-ipfs?path=packages/ipfs-core-utils) -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -> This package serves as a repository code shared between the core `ipfs` core implementation and the `ipfs-http-client` +> Package to share code between ipfs and ipfs-http-client -## Table of Contents +## Table of contents - [Install](#install) -- [Contribute](#contribute) - [License](#license) +- [Contribute](#contribute) ## Install -```bash -$ npm install --save ipfs-core-utils +```console +$ npm i ipfs-core-utils ``` +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + ## Contribute -Contributions welcome. Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). -Check out our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. -## License +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. -[MIT](LICENSE) © Protocol Labs Inc. +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs-core-utils/package.json b/packages/ipfs-core-utils/package.json index 18c4759aa5..e032d1f6d5 100644 --- a/packages/ipfs-core-utils/package.json +++ b/packages/ipfs-core-utils/package.json @@ -1,13 +1,23 @@ { "name": "ipfs-core-utils", - "version": "0.15.1", + "version": "0.17.0", "description": "Package to share code between ipfs and ipfs-http-client", "author": "Alex Potsides ", + "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-core-utils#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", "typesVersions": { "*": { "*": [ @@ -25,80 +35,96 @@ } }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - } - }, "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" }, - "./files/normalise-input-single": { - "import": "./src/files/normalise-input-single.js" + "./agent": { + "types": "./src/agent.d.ts", + "browser": "./src/agent.browser.js", + "import": "./src/agent.js" }, - "./files/normalise-input-single.browser": { - "import": "./src/files/normalise-input-single.browser.js" + "./errors": { + "types": "./src/errors.d.ts", + "import": "./src/errors.js" }, - "./files/normalise-input-multiple": { - "import": "./src/files/normalise-input-multiple.js" + "./files/format-mode": { + "types": "./src/files/format-mode.d.ts", + "import": "./src/files/format-mode.js" }, - "./files/normalise-input-multiple.browser": { - "import": "./src/files/normalise-input-multiple.browser.js" + "./files/format-mtime": { + "types": "./src/files/format-mtime.d.ts", + "import": "./src/files/format-mtime.js" }, "./files/normalise-content": { + "types": "./src/files/normalise-content.d.ts", "import": "./src/files/normalise-content.js" }, "./files/normalise-content.browser": { + "types": "./src/files/normalise-content.browser.d.ts", "import": "./src/files/normalise-content.browser.js" }, - "./files/format-mode": { - "import": "./src/files/format-mode.js" + "./files/normalise-input-multiple": { + "types": "./src/files/normalise-input-multiple.d.ts", + "import": "./src/files/normalise-input-multiple.js" }, - "./files/format-mtime": { - "import": "./src/files/format-mtime.js" + "./files/normalise-input-multiple.browser": { + "types": "./src/files/normalise-input-multiple.browser.d.ts", + "import": "./src/files/normalise-input-multiple.browser.js" }, - "./pins/normalise-input": { - "import": "./src/pins/normalise-input.js" + "./files/normalise-input-single": { + "types": "./src/files/normalise-input-single.d.ts", + "import": "./src/files/normalise-input-single.js" }, - "./errors": { - "import": "./src/errors.js" + "./files/normalise-input-single.browser": { + "types": "./src/files/normalise-input-single.browser.d.ts", + "import": "./src/files/normalise-input-single.browser.js" }, "./multibases": { + "types": "./src/multibases.d.ts", "import": "./src/multibases.js" }, "./multicodecs": { + "types": "./src/multicodecs.d.ts", "import": "./src/multicodecs.js" }, "./multihashes": { + "types": "./src/multihashes.d.ts", "import": "./src/multihashes.js" }, + "./multipart-request": { + "types": "./src/multipart-request.d.ts", + "browser": "./src/multipart-request.browser.js", + "import": "./src/multipart-request.js" + }, + "./pins/normalise-input": { + "types": "./src/pins/normalise-input.d.ts", + "import": "./src/pins/normalise-input.js" + }, "./to-cid-and-path": { + "types": "./src/to-cid-and-path.d.ts", "import": "./src/to-cid-and-path.js" }, "./to-url-string": { + "types": "./src/to-url-string.d.ts", "import": "./src/to-url-string.js" }, "./with-timeout-option": { + "types": "./src/with-timeout-option.d.ts", "import": "./src/with-timeout-option.js" - }, - "./agent": { - "browser": "./src/agent.browser.js", - "import": "./src/agent.js" - }, - "./multipart-request": { - "browser": "./src/multipart-request.browser.js", - "import": "./src/multipart-request.js" } }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } }, "scripts": { "test": "aegir test", @@ -113,28 +139,27 @@ "dep-check": "aegir dep-check -i ipfs-core-types", "build": "aegir build" }, - "license": "MIT", "dependencies": { - "@libp2p/logger": "^1.1.4", - "@multiformats/multiaddr": "^10.0.0", + "@libp2p/logger": "^2.0.0", + "@multiformats/multiaddr": "^11.0.0", "@multiformats/multiaddr-to-uri": "^9.0.1", "any-signal": "^3.0.0", - "blob-to-it": "^1.0.1", - "browser-readablestream-to-it": "^1.0.1", + "blob-to-it": "^2.0.0", + "browser-readablestream-to-it": "^2.0.0", "err-code": "^3.0.1", - "ipfs-core-types": "^0.11.1", - "ipfs-unixfs": "^6.0.9", + "ipfs-core-types": "^0.13.0", + "ipfs-unixfs": "^8.0.0", "ipfs-utils": "^9.0.6", - "it-all": "^1.0.4", - "it-map": "^1.0.4", - "it-peekable": "^1.0.2", + "it-all": "^2.0.0", + "it-map": "^2.0.0", + "it-peekable": "^2.0.0", "it-to-stream": "^1.0.0", "merge-options": "^3.0.4", - "multiformats": "^9.5.1", - "nanoid": "^3.1.23", + "multiformats": "^10.0.0", + "nanoid": "^4.0.0", "parse-duration": "^1.0.0", "timeout-abort-controller": "^3.0.0", - "uint8arrays": "^3.0.0" + "uint8arrays": "^4.0.2" }, "devDependencies": { "@web-std/file": "^3.0.2", diff --git a/packages/ipfs-core-utils/src/files/normalise-candidate-single.js b/packages/ipfs-core-utils/src/files/normalise-candidate-single.js index 1616cde954..9be8814101 100644 --- a/packages/ipfs-core-utils/src/files/normalise-candidate-single.js +++ b/packages/ipfs-core-utils/src/files/normalise-candidate-single.js @@ -49,7 +49,6 @@ export async function * normaliseCandidateSingle (input, normaliseContent) { // Iterable if (Symbol.iterator in input || Symbol.asyncIterator in input) { - // @ts-expect-error it's (async)iterable const peekable = itPeekable(input) /** @type {any} value **/ diff --git a/packages/ipfs-core-utils/src/to-url-string.js b/packages/ipfs-core-utils/src/to-url-string.js index 088ad0a0fa..3ef8d2b56d 100644 --- a/packages/ipfs-core-utils/src/to-url-string.js +++ b/packages/ipfs-core-utils/src/to-url-string.js @@ -1,6 +1,10 @@ -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' import { multiaddrToUri } from '@multiformats/multiaddr-to-uri' +/** + * @typedef {import('@multiformats/multiaddr').Multiaddr} Multiaddr + */ + /** * @param {string|Multiaddr|URL} url - A string, multiaddr or URL to convert to a url string * @returns {string} @@ -8,7 +12,7 @@ import { multiaddrToUri } from '@multiformats/multiaddr-to-uri' export function toUrlString (url) { try { // @ts-expect-error - url = multiaddrToUri(new Multiaddr(url)) + url = multiaddrToUri(multiaddr(url)) } catch (/** @type {any} */ err) { } url = url.toString() diff --git a/packages/ipfs-core/.aegir.js b/packages/ipfs-core/.aegir.js index e54714d714..5e37662ad7 100644 --- a/packages/ipfs-core/.aegir.js +++ b/packages/ipfs-core/.aegir.js @@ -6,17 +6,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)) /** @type {import('aegir').Options["build"]["config"]} */ const esbuild = { - inject: [path.join(__dirname, '../../scripts/node-globals.js')], - plugins: [ - { - name: 'node built ins', - setup (build) { - build.onResolve({ filter: /^stream$/ }, () => { - return { path: require.resolve('readable-stream') } - }) - } - } - ] + inject: [path.join(__dirname, '../../scripts/node-globals.js')] } /** @type {import('aegir').PartialOptions} */ diff --git a/packages/ipfs-core/CHANGELOG.md b/packages/ipfs-core/CHANGELOG.md index 3a473d0279..214d8be095 100644 --- a/packages/ipfs-core/CHANGELOG.md +++ b/packages/ipfs-core/CHANGELOG.md @@ -3,6 +3,78 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.17.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-core-v0.16.1...ipfs-core-v0.17.0) (2022-10-24) + + +### ⚠ BREAKING CHANGES + +* ipfs is now bundled with libp2p@0.40.x which has different config +* require IPNS V2 signatures (#4207) + +### Features + +* upgrade libp2p to 0.40.x ([#4237](https://www.github.com/ipfs/js-ipfs/issues/4237)) ([0cee4a4](https://www.github.com/ipfs/js-ipfs/commit/0cee4a4c55767022584dcbade0b0b9b43326f9c9)) + + +### Bug Fixes + +* replace slice with subarray for increased performance ([#4210](https://www.github.com/ipfs/js-ipfs/issues/4210)) ([dfc43d4](https://www.github.com/ipfs/js-ipfs/commit/dfc43d4e9be67fdf25553677f469379d966ff806)) +* require IPNS V2 signatures ([#4207](https://www.github.com/ipfs/js-ipfs/issues/4207)) ([d1b0a8a](https://www.github.com/ipfs/js-ipfs/commit/d1b0a8a71073b4ece0dbda5a5405d76dd8d5b358)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-config bumped from ^0.5.1 to ^0.6.0 + * ipfs-core-types bumped from ^0.12.1 to ^0.13.0 + * ipfs-core-utils bumped from ^0.16.1 to ^0.17.0 + * ipfs-http-client bumped from ^58.0.1 to ^59.0.0 + * devDependencies + * interface-ipfs-core bumped from ^0.156.1 to ^0.157.0 + +### [0.16.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-core-v0.16.0...ipfs-core-v0.16.1) (2022-09-21) + + +### Bug Fixes + +* update @multiformats/multiadd to 11.0.0 ([2a830bf](https://www.github.com/ipfs/js-ipfs/commit/2a830bf58a5929fcce51dede871c99f62192fbda)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-config bumped from ^0.5.0 to ^0.5.1 + * ipfs-core-types bumped from ^0.12.0 to ^0.12.1 + * ipfs-core-utils bumped from ^0.16.0 to ^0.16.1 + * ipfs-http-client bumped from ^58.0.0 to ^58.0.1 + * devDependencies + * interface-ipfs-core bumped from ^0.156.0 to ^0.156.1 + +## [0.16.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-core-v0.15.4...ipfs-core-v0.16.0) (2022-09-06) + + +### ⚠ BREAKING CHANGES + +* update to libp2p@0.38.x (#4151) + +### deps + +* update to libp2p@0.38.x ([#4151](https://www.github.com/ipfs/js-ipfs/issues/4151)) ([39dbf70](https://www.github.com/ipfs/js-ipfs/commit/39dbf708ec31b263115e44f420651fa4e056a89e)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-config bumped from ^0.4.0 to ^0.5.0 + * ipfs-core-types bumped from ^0.11.0 to ^0.12.0 + * ipfs-core-utils bumped from ^0.15.0 to ^0.16.0 + * ipfs-http-client bumped from ^57.0.0 to ^58.0.0 + * devDependencies + * interface-ipfs-core bumped from ^0.155.0 to ^0.156.0 + ### [0.15.4](https://www.github.com/ipfs/js-ipfs/compare/ipfs-core-v0.15.3...ipfs-core-v0.15.4) (2022-06-24) diff --git a/packages/ipfs-core/LICENSE b/packages/ipfs-core/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-core/LICENSE @@ -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 diff --git a/packages/ipfs-core/LICENSE-MIT b/packages/ipfs-core/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/packages/ipfs-core/LICENSE-MIT +++ b/packages/ipfs-core/LICENSE-MIT @@ -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. \ No newline at end of file +THE SOFTWARE. diff --git a/packages/ipfs-core/README.md b/packages/ipfs-core/README.md index bf5157353e..d690536b65 100644 --- a/packages/ipfs-core/README.md +++ b/packages/ipfs-core/README.md @@ -1,3 +1,31 @@ +# ipfs-core + +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) + +> JavaScript implementation of the IPFS specification + +## Table of contents + +- - [Install](#install) +- [ipfs-core ](#ipfs-core----omit-in-toc---) + - [Getting Started](#getting-started) + - [Next Steps](#next-steps) + - [Browser CDN](#browser-cdn) + - [Browser bundle](#browser-bundle) + - [Want to hack on IPFS?](#want-to-hack-on-ipfs) + - [License](#license) + - [Contribute](#contribute) + +## Install + +```console +$ npm i ipfs-core +``` +

IPFS in JavaScript logo @@ -22,21 +50,10 @@ # ipfs-core -> The IPFS Core API - `ipfs-core` is the implementation of the IPFS Core API written in JavaScript without depending on other languages/implementations. It contains all you need to integrate IPFS into your application. If you want to run IPFS as a standalone daemon process, see the [ipfs](https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs) module. -## Table of Contents - -- [Getting Started](#getting-started) -- [Next Steps](#next-steps) - - [Browser CDN](#browser-cdn) - - [Browser bundle](#browser-bundle) -- [Want to hack on IPFS?](#want-to-hack-on-ipfs) -- [License](#license) - ## Getting Started The `ipfs-core` package contains all the features of `ipfs` but in a lighter package without the CLI or HTTP servers: @@ -58,12 +75,12 @@ console.info(cid) ## Next Steps -* Look into the [js-ipfs-examples](https://github.com/ipfs-examples/js-ipfs-examples) to learn how to spawn an IPFS node in Node.js and in the Browser -* Read the [Core API docs](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) to see what you can do with an IPFS node -* Head over to https://proto.school to take interactive tutorials that cover core IPFS APIs -* Check out https://docs.ipfs.io for tips, how-tos and more -* See https://blog.ipfs.io for news and more -* Need help? Please ask 'How do I?' questions on https://discuss.ipfs.io +- Look into the [js-ipfs-examples](https://github.com/ipfs-examples/js-ipfs-examples) to learn how to spawn an IPFS node in Node.js and in the Browser +- Read the [Core API docs](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) to see what you can do with an IPFS node +- Head over to to take interactive tutorials that cover core IPFS APIs +- Check out for tips, how-tos and more +- See for news and more +- Need help? Please ask 'How do I?' questions on ### Browser CDN @@ -104,15 +121,26 @@ Read the [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of - **Check out existing issues** The [issue list](https://github.com/ipfs/js-ipfs/issues) has many that are marked as ['help wanted'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22) or ['difficulty:easy'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Adifficulty%3Aeasy) which make great starting points for development, many of which can be tackled with no prior IPFS knowledge - **Perform code reviews** More eyes will help -a. speed the project along -b. ensure quality, and -c. reduce possible future bugs. + a. speed the project along + b. ensure quality, and + c. reduce possible future bugs. - **Add tests**. There can never be enough tests. -Find out about chat channels, the IPFS newsletter, the IPFS blog, and more in the [IPFS community space](https://docs.ipfs.io/community/). - ## License -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute -[![](https://github.com/ipfs/js-ipfs/raw/master/packages/interface-ipfs-core/img/badge.png)](https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core) +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). + +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. + +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs-core/package.json b/packages/ipfs-core/package.json index be48530838..36e6c546eb 100644 --- a/packages/ipfs-core/package.json +++ b/packages/ipfs-core/package.json @@ -1,16 +1,25 @@ { "name": "ipfs-core", - "version": "0.15.4", + "version": "0.17.0", "description": "JavaScript implementation of the IPFS specification", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-core#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "IPFS" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-core#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", "typesVersions": { "*": { "*": [ @@ -28,27 +37,26 @@ } }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - } - }, "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" }, "./config/profiles": { + "types": "./src/components/config/profiles.d.ts", "import": "./src/components/config/profiles.js" } }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } }, "scripts": { "build": "aegir build", @@ -63,92 +71,96 @@ "test:electron-main": "aegir test -t electron-main", "test:bootstrapers": "IPFS_TEST=bootstrapers aegir test -t browser -f test/bootstrappers.js", "clean": "aegir clean", - "dep-check": "aegir dep-check -i interface-ipfs-core -i ipfs-core-types --i interface-blockstore" + "dep-check": "aegir dep-check -i interface-ipfs-core -i ipfs-core-types --i interface-blockstore -i @libp2p/interface-dht -i @libp2p/interface-keys -i @libp2p/interface-transport -i @libp2p/interfaces" }, "dependencies": { - "@chainsafe/libp2p-noise": "^6.0.1", - "@ipld/car": "^4.0.0", - "@ipld/dag-cbor": "^7.0.0", - "@ipld/dag-json": "^8.0.1", - "@ipld/dag-pb": "^2.1.3", - "@libp2p/bootstrap": "^1.0.2", - "@libp2p/crypto": "^0.22.9", - "@libp2p/delegated-content-routing": "^1.0.3", - "@libp2p/delegated-peer-routing": "^1.0.3", - "@libp2p/interfaces": "^2.0.4", - "@libp2p/kad-dht": "^1.0.3", - "@libp2p/logger": "^1.1.4", - "@libp2p/mplex": "^1.0.5", - "@libp2p/peer-id": "^1.1.10", - "@libp2p/peer-id-factory": "^1.0.10", - "@libp2p/record": "^1.0.1", - "@libp2p/websockets": "^1.0.8", + "@chainsafe/libp2p-noise": "^10.0.0", + "@ipld/car": "^5.0.0", + "@ipld/dag-cbor": "^8.0.0", + "@ipld/dag-json": "^9.0.0", + "@ipld/dag-pb": "^3.0.0", + "@libp2p/bootstrap": "^5.0.0", + "@libp2p/crypto": "^1.0.0", + "@libp2p/delegated-content-routing": "^3.0.0", + "@libp2p/delegated-peer-routing": "^3.0.0", + "@libp2p/interface-dht": "^1.0.2", + "@libp2p/interface-keys": "^1.0.3", + "@libp2p/interface-peer-id": "^1.0.5", + "@libp2p/interface-transport": "^2.0.0", + "@libp2p/interfaces": "^3.0.3", + "@libp2p/kad-dht": "^5.0.1", + "@libp2p/logger": "^2.0.2", + "@libp2p/mplex": "^7.0.0", + "@libp2p/peer-id": "^1.1.16", + "@libp2p/peer-id-factory": "^1.0.19", + "@libp2p/record": "^2.0.3", + "@libp2p/websockets": "^5.0.0", "@multiformats/mafmt": "^11.0.2", - "@multiformats/multiaddr": "^10.1.8", + "@multiformats/multiaddr": "^11.0.0", "@multiformats/multiaddr-to-uri": "^9.0.1", - "@multiformats/murmur3": "^1.1.1", + "@multiformats/murmur3": "^2.0.0", "any-signal": "^3.0.0", "array-shuffle": "^3.0.0", - "blockstore-core": "^1.0.2", - "dag-jose": "^1.0.0", - "datastore-core": "^7.0.0", - "datastore-pubsub": "^3.0.0", + "blockstore-core": "^2.0.1", + "dag-jose": "^3.0.1", + "datastore-core": "^8.0.1", + "datastore-pubsub": "^6.0.0", "dlv": "^1.1.3", "err-code": "^3.0.1", - "hamt-sharding": "^2.0.1", + "hamt-sharding": "^3.0.0", "hashlru": "^2.3.0", - "interface-blockstore": "^2.0.3", - "interface-datastore": "^6.1.1", - "ipfs-bitswap": "^11.0.0", - "ipfs-core-config": "^0.4.1", - "ipfs-core-types": "^0.11.1", - "ipfs-core-utils": "^0.15.1", - "ipfs-http-client": "^57.0.3", - "ipfs-repo": "^14.0.1", - "ipfs-unixfs": "^6.0.9", - "ipfs-unixfs-exporter": "^7.0.11", - "ipfs-unixfs-importer": "^9.0.10", + "interface-blockstore": "^3.0.0", + "interface-datastore": "^7.0.0", + "ipfs-bitswap": "^13.0.0", + "ipfs-core-config": "^0.6.0", + "ipfs-core-types": "^0.13.0", + "ipfs-core-utils": "^0.17.0", + "ipfs-http-client": "^59.0.0", + "ipfs-repo": "^16.0.0", + "ipfs-unixfs": "^8.0.0", + "ipfs-unixfs-exporter": "^9.0.0", + "ipfs-unixfs-importer": "^11.0.0", "ipfs-utils": "^9.0.6", - "ipns": "^1.0.0", + "ipns": "^4.0.0", "is-domain-name": "^1.0.1", - "is-ipfs": "^6.0.1", - "it-drain": "^1.0.3", - "it-filter": "^1.0.2", - "it-first": "^1.0.4", - "it-last": "^1.0.4", - "it-map": "^1.0.4", - "it-merge": "^1.0.2", - "it-parallel": "^2.0.1", - "it-peekable": "^1.0.2", + "is-ipfs": "^7.0.0", + "it-drain": "^2.0.0", + "it-filter": "^2.0.0", + "it-first": "^2.0.0", + "it-last": "^2.0.0", + "it-map": "^2.0.0", + "it-merge": "^2.0.0", + "it-parallel": "^3.0.0", + "it-peekable": "^2.0.0", "it-pipe": "^2.0.3", - "it-pushable": "^2.0.1", - "it-tar": "^5.0.0", - "it-to-buffer": "^2.0.0", + "it-pushable": "^3.0.0", + "it-tar": "^6.0.0", + "it-to-buffer": "^3.0.0", "just-safe-set": "^4.0.2", - "libp2p": "^0.37.1", + "libp2p": "^0.40.0", "merge-options": "^3.0.4", "mortice": "^3.0.0", - "multiformats": "^9.5.1", + "multiformats": "^10.0.0", "pako": "^2.0.4", "parse-duration": "^1.0.0", "timeout-abort-controller": "^3.0.0", - "uint8arrays": "^3.0.0" + "uint8arrays": "^4.0.2" }, "devDependencies": { - "@chainsafe/libp2p-gossipsub": "^1.0.0", + "@chainsafe/libp2p-gossipsub": "^4.0.0", "@types/dlv": "^1.1.2", - "@types/pako": "^1.0.2", + "@types/pako": "^2.0.0", "@types/rimraf": "^3.0.1", "aegir": "^37.0.11", - "blockstore-datastore-adapter": "^2.0.2", + "blockstore-datastore-adapter": "^4.0.0", "delay": "^5.0.0", - "go-ipfs": "^0.12.1", - "interface-blockstore-tests": "^2.0.4", - "interface-ipfs-core": "^0.155.2", - "ipfsd-ctl": "^11.0.0", + "go-ipfs": "^0.12.0", + "interface-blockstore-tests": "^3.0.0", + "interface-ipfs-core": "^0.157.0", + "ipfsd-ctl": "^12.0.3", "iso-url": "^1.0.0", - "it-all": "^1.0.4", - "nanoid": "^3.1.23", + "it-all": "^2.0.0", + "nanoid": "^4.0.0", "p-defer": "^4.0.0", "rimraf": "^3.0.2", "sinon": "^14.0.0" diff --git a/packages/ipfs-core/src/block-storage.js b/packages/ipfs-core/src/block-storage.js index 19f93999db..f1adccc2ad 100644 --- a/packages/ipfs-core/src/block-storage.js +++ b/packages/ipfs-core/src/block-storage.js @@ -102,8 +102,8 @@ export class BlockStorage extends BaseBlockstore { * @param {AbortOptions} [options] */ async * getMany (cids, options = {}) { - const getFromBitswap = pushable() - const getFromChild = pushable() + const getFromBitswap = pushable({ objectMode: true }) + const getFromChild = pushable({ objectMode: true }) Promise.resolve().then(async () => { for await (const cid of cids) { diff --git a/packages/ipfs-core/src/components/bitswap/index.js b/packages/ipfs-core/src/components/bitswap/index.js index 75e07f045e..348ec28351 100644 --- a/packages/ipfs-core/src/components/bitswap/index.js +++ b/packages/ipfs-core/src/components/bitswap/index.js @@ -5,7 +5,7 @@ import { createStat } from './stat.js' /** * @typedef {import('../../types').NetworkService} NetworkService - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId * @typedef {import('multiformats/cid').CID} CID * @typedef {import('ipfs-core-types/src/utils').AbortOptions} AbortOptions */ diff --git a/packages/ipfs-core/src/components/block/put.js b/packages/ipfs-core/src/components/block/put.js index 1066790f44..54566cdef7 100644 --- a/packages/ipfs-core/src/components/block/put.js +++ b/packages/ipfs-core/src/components/block/put.js @@ -2,7 +2,7 @@ import { CID } from 'multiformats/cid' import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' /** - * @typedef {import('multiformats/cid').CIDVersion} CIDVersion + * @typedef {import('multiformats/cid').Version} CIDVersion */ /** diff --git a/packages/ipfs-core/src/components/bootstrap/clear.js b/packages/ipfs-core/src/components/bootstrap/clear.js index e261f446c2..51479be0c0 100644 --- a/packages/ipfs-core/src/components/bootstrap/clear.js +++ b/packages/ipfs-core/src/components/bootstrap/clear.js @@ -1,5 +1,5 @@ import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' /** * @param {object} config @@ -16,7 +16,7 @@ export function createClear ({ repo }) { await repo.config.replace(config) - return { Peers: removed.map(ma => new Multiaddr(ma)) } + return { Peers: removed.map(ma => multiaddr(ma)) } } return withTimeoutOption(clear) diff --git a/packages/ipfs-core/src/components/bootstrap/list.js b/packages/ipfs-core/src/components/bootstrap/list.js index 392224cf71..f262379c19 100644 --- a/packages/ipfs-core/src/components/bootstrap/list.js +++ b/packages/ipfs-core/src/components/bootstrap/list.js @@ -1,5 +1,5 @@ import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' /** * @param {object} config @@ -12,7 +12,7 @@ export function createList ({ repo }) { async function list (options = {}) { /** @type {string[]|null} */ const peers = (await repo.config.get('Bootstrap', options)) - return { Peers: (peers || []).map(ma => new Multiaddr(ma)) } + return { Peers: (peers || []).map(ma => multiaddr(ma)) } } return withTimeoutOption(list) diff --git a/packages/ipfs-core/src/components/bootstrap/reset.js b/packages/ipfs-core/src/components/bootstrap/reset.js index 6b1d3c1a88..11b1d5ceac 100644 --- a/packages/ipfs-core/src/components/bootstrap/reset.js +++ b/packages/ipfs-core/src/components/bootstrap/reset.js @@ -1,6 +1,6 @@ import defaultConfig from 'ipfs-core-config/config' import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' /** * @param {object} config @@ -17,7 +17,7 @@ export function createReset ({ repo }) { await repo.config.replace(config) return { - Peers: defaultConfig().Bootstrap.map(ma => new Multiaddr(ma)) + Peers: defaultConfig().Bootstrap.map(ma => multiaddr(ma)) } } diff --git a/packages/ipfs-core/src/components/dag/export.js b/packages/ipfs-core/src/components/dag/export.js index ad37aacb8a..5fc24ec7bc 100644 --- a/packages/ipfs-core/src/components/dag/export.js +++ b/packages/ipfs-core/src/components/dag/export.js @@ -25,7 +25,10 @@ const NO_LINKS_CODECS = [ /** * @template T - * @typedef {import('multiformats/block').Block} Block + * @template C + * @template A + * @template V + * @typedef {import('multiformats/block').Block} Block */ /** @@ -85,12 +88,11 @@ export function createExport ({ repo, preload, codecs }) { } /** - * @template T * @param {IPFSRepo} repo * @param {BlockWriter} writer * @param {AbortOptions} options * @param {import('ipfs-core-utils/multicodecs').Multicodecs} codecs - * @returns {(cid:CID)=>Promise|null>} + * @returns {(cid:CID)=>Promise|null>} */ function makeLoader (repo, writer, options, codecs) { return async (cid) => { diff --git a/packages/ipfs-core/src/components/dht.js b/packages/ipfs-core/src/components/dht.js index 97add61092..d4954b444b 100644 --- a/packages/ipfs-core/src/components/dht.js +++ b/packages/ipfs-core/src/components/dht.js @@ -9,9 +9,9 @@ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { peerIdFromString } from '@libp2p/peer-id' /** - * @typedef {import('@libp2p/interfaces/dht').QueryEvent} QueryEvent + * @typedef {import('@libp2p/interface-dht').QueryEvent} QueryEvent * @typedef {import('./network').Network} Network - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId */ const IPNS_PREFIX = '/ipns/' @@ -98,7 +98,7 @@ export function createDht ({ network, repo, peerId }) { throw errCode(new Error('dht not configured'), 'ERR_DHT_NOT_CONFIGURED') } - yield * libp2p.dht.put(dhtKey, value) + yield * libp2p.dht.put(dhtKey, value, options) }, /** diff --git a/packages/ipfs-core/src/components/files/chmod.js b/packages/ipfs-core/src/components/files/chmod.js index 76783e3c52..3806fd64f7 100644 --- a/packages/ipfs-core/src/components/files/chmod.js +++ b/packages/ipfs-core/src/components/files/chmod.js @@ -22,7 +22,7 @@ const mergeOptions = mergeOpts.bind({ ignoreUndefined: true }) const log = logger('ipfs:mfs:touch') /** - * @typedef {import('multiformats/cid').CIDVersion} CIDVersion + * @typedef {import('multiformats/cid').Version} CIDVersion * @typedef {import('@ipld/dag-pb').PBNode} PBNode * @typedef {import('./').MfsContext} MfsContext * diff --git a/packages/ipfs-core/src/components/files/cp.js b/packages/ipfs-core/src/components/files/cp.js index 607156c177..57b4ad88cb 100644 --- a/packages/ipfs-core/src/components/files/cp.js +++ b/packages/ipfs-core/src/components/files/cp.js @@ -16,7 +16,7 @@ const log = logger('ipfs:mfs:cp') /** * @typedef {import('@ipld/dag-pb').PBNode} DAGNode * @typedef {import('multiformats/cid').CID} CID - * @typedef {import('multiformats/cid').CIDVersion} CIDVersion + * @typedef {import('multiformats/cid').Version} CIDVersion * @typedef {import('ipfs-unixfs').Mtime} Mtime * @typedef {import('./utils/to-mfs-path').MfsPath} MfsPath * @typedef {import('./utils/to-trail').MfsTrail} MfsTrail diff --git a/packages/ipfs-core/src/components/files/index.js b/packages/ipfs-core/src/components/files/index.js index 2899243632..45b274068c 100644 --- a/packages/ipfs-core/src/components/files/index.js +++ b/packages/ipfs-core/src/components/files/index.js @@ -1,5 +1,5 @@ import { createLock } from './utils/create-lock.js' -import isIpfs from 'is-ipfs' +import * as isIpfs from 'is-ipfs' import { createStat } from './stat.js' import { createChmod } from './chmod.js' import { createCp } from './cp.js' diff --git a/packages/ipfs-core/src/components/files/mkdir.js b/packages/ipfs-core/src/components/files/mkdir.js index ec55f8e6e4..ec8164e992 100644 --- a/packages/ipfs-core/src/components/files/mkdir.js +++ b/packages/ipfs-core/src/components/files/mkdir.js @@ -16,7 +16,7 @@ const log = logger('ipfs:mfs:mkdir') /** * @typedef {import('@ipld/dag-pb').PBNode} PBNode * @typedef {import('multiformats/cid').CID} CID - * @typedef {import('multiformats/cid').CIDVersion} CIDVersion + * @typedef {import('multiformats/cid').Version} CIDVersion * @typedef {import('ipfs-unixfs').MtimeLike} MtimeLike * @typedef {import('./').MfsContext} MfsContext * @typedef {object} DefaultOptions diff --git a/packages/ipfs-core/src/components/files/mv.js b/packages/ipfs-core/src/components/files/mv.js index b972d251b4..1470b9d95e 100644 --- a/packages/ipfs-core/src/components/files/mv.js +++ b/packages/ipfs-core/src/components/files/mv.js @@ -6,7 +6,7 @@ import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' const mergeOptions = mergeOpts.bind({ ignoreUndefined: true }) /** - * @typedef {import('multiformats/cid').CIDVersion} CIDVersion + * @typedef {import('multiformats/cid').Version} CIDVersion * @typedef {import('./').MfsContext} MfsContext * @typedef {object} DefaultOptions * @property {boolean} parents diff --git a/packages/ipfs-core/src/components/files/rm.js b/packages/ipfs-core/src/components/files/rm.js index 33d5cb5e43..6321cac958 100644 --- a/packages/ipfs-core/src/components/files/rm.js +++ b/packages/ipfs-core/src/components/files/rm.js @@ -10,7 +10,7 @@ import mergeOpts from 'merge-options' const mergeOptions = mergeOpts.bind({ ignoreUndefined: true }) /** - * @typedef {import('multiformats/cid').CIDVersion} CIDVersion + * @typedef {import('multiformats/cid').Version} CIDVersion * @typedef {import('./').MfsContext} MfsContext * @typedef {object} DefaultOptions * @property {boolean} recursive diff --git a/packages/ipfs-core/src/components/files/touch.js b/packages/ipfs-core/src/components/files/touch.js index 41d5f6fba2..5530b9dd89 100644 --- a/packages/ipfs-core/src/components/files/touch.js +++ b/packages/ipfs-core/src/components/files/touch.js @@ -15,7 +15,7 @@ const mergeOptions = mergeOpts.bind({ ignoreUndefined: true }) const log = logger('ipfs:mfs:touch') /** - * @typedef {import('multiformats/cid').CIDVersion} CIDVersion + * @typedef {import('multiformats/cid').Version} CIDVersion * @typedef {import('ipfs-unixfs').MtimeLike} MtimeLike * @typedef {import('./').MfsContext} MfsContext * @typedef {object} DefaultOptions diff --git a/packages/ipfs-core/src/components/files/utils/add-link.js b/packages/ipfs-core/src/components/files/utils/add-link.js index 60a2772aea..7c1e16da7d 100644 --- a/packages/ipfs-core/src/components/files/utils/add-link.js +++ b/packages/ipfs-core/src/components/files/utils/add-link.js @@ -18,7 +18,7 @@ const log = logger('ipfs:mfs:core:utils:add-link') /** * @typedef {import('ipfs-unixfs').Mtime} Mtime - * @typedef {import('multiformats/cid').CIDVersion} CIDVersion + * @typedef {import('multiformats/cid').Version} CIDVersion * @typedef {import('hamt-sharding').Bucket} Bucket * @typedef {import('../').MfsContext} MfsContext * @typedef {import('@ipld/dag-pb').PBNode} PBNode diff --git a/packages/ipfs-core/src/components/files/utils/create-node.js b/packages/ipfs-core/src/components/files/utils/create-node.js index 09250a6e59..c2ff579f6c 100644 --- a/packages/ipfs-core/src/components/files/utils/create-node.js +++ b/packages/ipfs-core/src/components/files/utils/create-node.js @@ -4,7 +4,7 @@ import { CID } from 'multiformats/cid' /** * @typedef {import('ipfs-unixfs').MtimeLike} MtimeLike - * @typedef {import('multiformats/cid').CIDVersion} CIDVersion + * @typedef {import('multiformats/cid').Version} CIDVersion * @typedef {import('../').MfsContext} MfsContext */ diff --git a/packages/ipfs-core/src/components/files/utils/dir-sharded.js b/packages/ipfs-core/src/components/files/utils/dir-sharded.js index 81cd48043b..32a7511393 100644 --- a/packages/ipfs-core/src/components/files/utils/dir-sharded.js +++ b/packages/ipfs-core/src/components/files/utils/dir-sharded.js @@ -27,7 +27,7 @@ import { * @property {Mtime} [mtime] * @property {number} [mode] * @property {import('multiformats/codecs/interface').BlockCodec} [codec] - * @property {import('multiformats/cid').CIDVersion} [cidVersion] + * @property {import('multiformats/cid').Version} [cidVersion] * @property {boolean} [onlyHash] * @property {AbortSignal} [signal] */ diff --git a/packages/ipfs-core/src/components/files/utils/hamt-constants.js b/packages/ipfs-core/src/components/files/utils/hamt-constants.js index 9a3c4eabfb..0a8676c563 100644 --- a/packages/ipfs-core/src/components/files/utils/hamt-constants.js +++ b/packages/ipfs-core/src/components/files/utils/hamt-constants.js @@ -11,7 +11,7 @@ export async function hamtHashFn (buf) { // Murmur3 outputs 128 bit but, accidentally, IPFS Go's // implementation only uses the first 64, so we must do the same // for parity.. - .slice(0, 8) + .subarray(0, 8) // Invert buffer because that's how Go impl does it .reverse() } diff --git a/packages/ipfs-core/src/components/files/utils/hamt-utils.js b/packages/ipfs-core/src/components/files/utils/hamt-utils.js index f70907678d..e31940ca46 100644 --- a/packages/ipfs-core/src/components/files/utils/hamt-utils.js +++ b/packages/ipfs-core/src/components/files/utils/hamt-utils.js @@ -17,7 +17,7 @@ import { const log = logger('ipfs:mfs:core:utils:hamt-utils') /** - * @typedef {import('multiformats/cid').CIDVersion} CIDVersion + * @typedef {import('multiformats/cid').Version} CIDVersion * @typedef {import('ipfs-unixfs').Mtime} Mtime * @typedef {import('../').MfsContext} MfsContext * @typedef {import('@ipld/dag-pb').PBNode} PBNode diff --git a/packages/ipfs-core/src/components/files/utils/persist.js b/packages/ipfs-core/src/components/files/utils/persist.js index 0d8c6bbcc9..5617683655 100644 --- a/packages/ipfs-core/src/components/files/utils/persist.js +++ b/packages/ipfs-core/src/components/files/utils/persist.js @@ -6,7 +6,7 @@ import { sha256 } from 'multiformats/hashes/sha2' * @typedef {object} PersistOptions * @property {import('multiformats/codecs/interface').BlockCodec} [codec] * @property {import('multiformats/hashes/interface').MultihashHasher} [hasher] - * @property {import('multiformats/cid').CIDVersion} [cidVersion] + * @property {import('multiformats/cid').Version} [cidVersion] * @property {boolean} [onlyHash] * @property {AbortSignal} [signal] */ diff --git a/packages/ipfs-core/src/components/files/utils/remove-link.js b/packages/ipfs-core/src/components/files/utils/remove-link.js index 104cff1fa4..0d81494a48 100644 --- a/packages/ipfs-core/src/components/files/utils/remove-link.js +++ b/packages/ipfs-core/src/components/files/utils/remove-link.js @@ -13,7 +13,7 @@ const log = logger('ipfs:mfs:core:utils:remove-link') /** * @typedef {import('../').MfsContext} MfsContext - * @typedef {import('multiformats/cid').CIDVersion} CIDVersion + * @typedef {import('multiformats/cid').Version} CIDVersion * @typedef {import('hamt-sharding').Bucket} Bucket * @typedef {import('@ipld/dag-pb').PBNode} PBNode * diff --git a/packages/ipfs-core/src/components/files/utils/update-tree.js b/packages/ipfs-core/src/components/files/utils/update-tree.js index 26af608e75..eb504332a1 100644 --- a/packages/ipfs-core/src/components/files/utils/update-tree.js +++ b/packages/ipfs-core/src/components/files/utils/update-tree.js @@ -12,7 +12,7 @@ const defaultOptions = { /** * @typedef {import('multiformats/cid').CID} CID - * @typedef {import('multiformats/cid').CIDVersion} CIDVersion + * @typedef {import('multiformats/cid').Version} CIDVersion * @typedef {import('../').MfsContext} MfsContext * @typedef {import('./to-trail').MfsTrail} MfsTrail */ diff --git a/packages/ipfs-core/src/components/files/write.js b/packages/ipfs-core/src/components/files/write.js index a1eb9e9b14..3bca1e99fa 100644 --- a/packages/ipfs-core/src/components/files/write.js +++ b/packages/ipfs-core/src/components/files/write.js @@ -29,7 +29,7 @@ const mergeOptions = mergeOpts.bind({ ignoreUndefined: true }) const log = logger('ipfs:mfs:write') /** - * @typedef {import('multiformats/cid').CIDVersion} CIDVersion + * @typedef {import('multiformats/cid').Version} CIDVersion * @typedef {import('ipfs-unixfs').MtimeLike} MtimeLike * @typedef {import('./').MfsContext} MfsContext * @typedef {import('./utils/to-mfs-path').FilePath} FilePath @@ -334,7 +334,7 @@ const limitAsyncStreamBytes = (stream, limit) => { emitted += buf.length if (emitted > limit) { - yield buf.slice(0, limit - emitted) + yield buf.subarray(0, limit - emitted) return } @@ -353,7 +353,7 @@ const asyncZeroes = (count, chunkSize = MFS_MAX_CHUNK_SIZE) => { async function * _asyncZeroes () { while (true) { - yield buf.slice() + yield buf } } diff --git a/packages/ipfs-core/src/components/get.js b/packages/ipfs-core/src/components/get.js index b0318dff12..27f1606ea8 100644 --- a/packages/ipfs-core/src/components/get.js +++ b/packages/ipfs-core/src/components/get.js @@ -6,7 +6,6 @@ import { CID } from 'multiformats/cid' import { pack } from 'it-tar' import { pipe } from 'it-pipe' import Pako from 'pako' -import map from 'it-map' import toBuffer from 'it-to-buffer' // https://www.gnu.org/software/gzip/manual/gzip.html @@ -57,11 +56,7 @@ export function createGet ({ repo, preload }) { }, body: file.content() }], - pack(), - /** - * @param {AsyncIterable} source - */ - (source) => map(source, buf => buf.slice()) + pack() ) } else { args.push( @@ -126,11 +121,7 @@ export function createGet ({ repo, preload }) { yield output } }, - pack(), - /** - * @param {AsyncIterable} source - */ - (source) => map(source, buf => buf.slice()) + pack() ] if (options.compress) { diff --git a/packages/ipfs-core/src/components/id.js b/packages/ipfs-core/src/components/id.js index 2dc32c7df5..15e13e28cb 100644 --- a/packages/ipfs-core/src/components/id.js +++ b/packages/ipfs-core/src/components/id.js @@ -1,5 +1,5 @@ import { ipfsCore as pkgversion } from '../version.js' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' import { NotStartedError } from '../errors.js' @@ -11,12 +11,12 @@ const log = logger('ipfs:components:id') /** * @typedef {import('libp2p').Libp2p} Libp2p * @typedef {import('ipfs-core-types/src/utils').AbortOptions} AbortOptions - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId */ /** * @param {object} config - * @param {import('@libp2p/interfaces/peer-id').PeerId} config.peerId + * @param {import('@libp2p/interface-peer-id').PeerId} config.peerId * @param {import('../types').NetworkService} config.network */ export function createId ({ peerId, network }) { @@ -69,7 +69,7 @@ export function createId ({ peerId, network }) { return `${str}/p2p/${idStr}` }) .sort() - .map(ma => new Multiaddr(ma)), + .map(ma => multiaddr(ma)), agentVersion, protocolVersion, protocols: (peer.protocols || []).sort() diff --git a/packages/ipfs-core/src/components/index.js b/packages/ipfs-core/src/components/index.js index 2bba834e65..e3df15d948 100644 --- a/packages/ipfs-core/src/components/index.js +++ b/packages/ipfs-core/src/components/index.js @@ -12,6 +12,7 @@ import { bases, hashes, codecs } from 'multiformats/basics' import { initAssets } from 'ipfs-core-config/init-assets' import { AlreadyInitializedError } from '../errors.js' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' +import { TimeoutController } from 'timeout-abort-controller' import { createStart } from './start.js' import { createStop } from './stop.js' @@ -52,6 +53,8 @@ import { Multibases } from 'ipfs-core-utils/multibases' const mergeOptions = mergeOpts.bind({ ignoreUndefined: true }) const log = logger('ipfs') +const IPNS_INIT_KEYSPACE_TIMEOUT = 30000 + /** * @typedef {import('../types').Options} Options * @typedef {import('../types').Print} Print @@ -331,7 +334,14 @@ export async function create (options = {}) { throw errCode(new Error('Public key missing'), 'ERR_MISSING_PUBLIC_KEY') } - await ipfs.ipns.initializeKeyspace(storage.peerId, uint8ArrayFromString(`/ipfs/${cid}`)) + const timeoutController = new TimeoutController(IPNS_INIT_KEYSPACE_TIMEOUT) + try { + await ipfs.ipns.initializeKeyspace(storage.peerId, uint8ArrayFromString(`/ipfs/${cid}`), { + signal: timeoutController.signal + }) + } finally { + timeoutController.clear() + } } if (options.start !== false) { diff --git a/packages/ipfs-core/src/components/ipns.js b/packages/ipfs-core/src/components/ipns.js index 54c3b364ae..0d542fc524 100644 --- a/packages/ipfs-core/src/components/ipns.js +++ b/packages/ipfs-core/src/components/ipns.js @@ -7,7 +7,8 @@ import { logger } from '@libp2p/logger' const log = logger('ipfs:components:ipns') /** - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interfaces').AbortOptions} AbortOptions * * @typedef {object} ExperimentalOptions * @property {boolean} [ipnsPubsub] @@ -59,8 +60,8 @@ export class IPNSAPI { * * @param {object} config * @param {import('ipfs-repo').IPFSRepo} config.repo - * @param {import('@libp2p/interfaces/peer-id').PeerId} config.peerId - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-peer-id').PeerId} config.peerId + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain */ startOffline ({ repo, peerId, keychain }) { if (this.offline != null) { @@ -79,8 +80,8 @@ export class IPNSAPI { * @param {object} config * @param {import('libp2p').Libp2p} config.libp2p * @param {import('ipfs-repo').IPFSRepo} config.repo - * @param {import('@libp2p/interfaces/peer-id').PeerId} config.peerId - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-peer-id').PeerId} config.peerId + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain */ async startOnline ({ libp2p, repo, peerId, keychain }) { if (this.online != null) { @@ -106,15 +107,19 @@ export class IPNSAPI { * @param {PeerId} peerId * @param {Uint8Array} value * @param {number} lifetime + * @param {AbortOptions} [options] */ - publish (peerId, value, lifetime) { - return this.getIPNS().publish(peerId, value, lifetime) + publish (peerId, value, lifetime, options) { + return this.getIPNS().publish(peerId, value, lifetime, options) } /** * * @param {string} name - * @param {*} [options] + * @param {object} [options] + * @param {boolean} [options.nocache] + * @param {boolean} [options.recursive] + * @param {AbortSignal} [options.signal] */ resolve (name, options) { return this.getIPNS().resolve(name, options) @@ -123,8 +128,9 @@ export class IPNSAPI { /** * @param {PeerId} peerId * @param {Uint8Array} value + * @param {AbortOptions} [options] */ - initializeKeyspace (peerId, value) { - return this.getIPNS().initializeKeyspace(peerId, value) + initializeKeyspace (peerId, value, options) { + return this.getIPNS().initializeKeyspace(peerId, value, options) } } diff --git a/packages/ipfs-core/src/components/key/export.js b/packages/ipfs-core/src/components/key/export.js index 4e58e9861d..3bbdf66d50 100644 --- a/packages/ipfs-core/src/components/key/export.js +++ b/packages/ipfs-core/src/components/key/export.js @@ -2,7 +2,7 @@ import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' /** * @param {object} config - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain */ export function createExport ({ keychain }) { /** diff --git a/packages/ipfs-core/src/components/key/gen.js b/packages/ipfs-core/src/components/key/gen.js index 8640fd7247..e8525da9b4 100644 --- a/packages/ipfs-core/src/components/key/gen.js +++ b/packages/ipfs-core/src/components/key/gen.js @@ -5,7 +5,7 @@ const DEFAULT_KEY_SIZE = 2048 /** * @param {object} config - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain */ export function createGen ({ keychain }) { /** diff --git a/packages/ipfs-core/src/components/key/import.js b/packages/ipfs-core/src/components/key/import.js index 0a5711ea40..c73b84cb3c 100644 --- a/packages/ipfs-core/src/components/key/import.js +++ b/packages/ipfs-core/src/components/key/import.js @@ -2,7 +2,7 @@ import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' /** * @param {object} config - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain */ export function createImport ({ keychain }) { /** diff --git a/packages/ipfs-core/src/components/key/index.js b/packages/ipfs-core/src/components/key/index.js index c34521e838..12383d3f3d 100644 --- a/packages/ipfs-core/src/components/key/index.js +++ b/packages/ipfs-core/src/components/key/index.js @@ -7,7 +7,7 @@ import { createRename } from './rename.js' import { createRm } from './rm.js' /** - * @typedef {import('@libp2p/interfaces/keychain').KeyChain} Keychain + * @typedef {import('@libp2p/interface-keychain').KeyChain} Keychain */ export class KeyAPI { diff --git a/packages/ipfs-core/src/components/key/info.js b/packages/ipfs-core/src/components/key/info.js index 0059eca793..8e4c7fd670 100644 --- a/packages/ipfs-core/src/components/key/info.js +++ b/packages/ipfs-core/src/components/key/info.js @@ -2,7 +2,7 @@ import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' /** * @param {object} config - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain */ export function createInfo ({ keychain }) { /** diff --git a/packages/ipfs-core/src/components/key/list.js b/packages/ipfs-core/src/components/key/list.js index c7f6af6af0..cfee62a7a3 100644 --- a/packages/ipfs-core/src/components/key/list.js +++ b/packages/ipfs-core/src/components/key/list.js @@ -2,7 +2,7 @@ import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' /** * @param {object} config - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain */ export function createList ({ keychain }) { /** diff --git a/packages/ipfs-core/src/components/key/rename.js b/packages/ipfs-core/src/components/key/rename.js index 71ebef6d8f..98ffe84c03 100644 --- a/packages/ipfs-core/src/components/key/rename.js +++ b/packages/ipfs-core/src/components/key/rename.js @@ -2,7 +2,7 @@ import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' /** * @param {object} config - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain */ export function createRename ({ keychain }) { /** diff --git a/packages/ipfs-core/src/components/key/rm.js b/packages/ipfs-core/src/components/key/rm.js index 087eaaf2a8..3dd55e38c7 100644 --- a/packages/ipfs-core/src/components/key/rm.js +++ b/packages/ipfs-core/src/components/key/rm.js @@ -2,7 +2,7 @@ import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' /** * @param {object} config - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain */ export function createRm ({ keychain }) { /** diff --git a/packages/ipfs-core/src/components/libp2p.js b/packages/ipfs-core/src/components/libp2p.js index fa2d4f0d7a..1c1b57c29f 100644 --- a/packages/ipfs-core/src/components/libp2p.js +++ b/packages/ipfs-core/src/components/libp2p.js @@ -2,20 +2,20 @@ import get from 'dlv' import mergeOpts from 'merge-options' import errCode from 'err-code' import { routers } from 'ipfs-core-config/libp2p-pubsub-routers' -import { DelegatedPeerRouting } from '@libp2p/delegated-peer-routing' -import { DelegatedContentRouting } from '@libp2p/delegated-content-routing' +import { delegatedPeerRouting } from '@libp2p/delegated-peer-routing' +import { delegatedContentRouting } from '@libp2p/delegated-content-routing' import { create as ipfsHttpClient } from 'ipfs-http-client' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' import { ipfsCore as pkgversion } from '../version.js' import { libp2pConfig as getEnvLibp2pOptions } from 'ipfs-core-config/libp2p' import { createLibp2p as createNode } from 'libp2p' -import { KadDHT } from '@libp2p/kad-dht' -import { Bootstrap } from '@libp2p/bootstrap' +import { kadDHT } from '@libp2p/kad-dht' +import { bootstrap } from '@libp2p/bootstrap' import { ipnsValidator } from 'ipns/validator' import { ipnsSelector } from 'ipns/selector' -import { WebSockets } from '@libp2p/websockets' -import { Mplex } from '@libp2p/mplex' -import { NOISE } from '@chainsafe/libp2p-noise' +import { webSockets } from '@libp2p/websockets' +import { mplex } from '@libp2p/mplex' +import { noise } from '@chainsafe/libp2p-noise' const mergeOptions = mergeOpts.bind({ ignoreUndefined: true, concatArrays: true }) @@ -31,11 +31,12 @@ const mergeOptions = mergeOpts.bind({ ignoreUndefined: true, concatArrays: true * @property {DekOptions} [dek] * * @typedef {import('ipfs-repo').IPFSRepo} Repo - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId * @typedef {import('../types').Options} IPFSOptions * @typedef {import('libp2p').Libp2p} LibP2P * @typedef {import('libp2p').Libp2pOptions} Libp2pOptions * @typedef {import('ipfs-core-types/src/config').Config} IPFSConfig + * @typedef {import('@multiformats/multiaddr').Multiaddr} Multiaddr */ /** @@ -124,13 +125,13 @@ function getLibp2pOptions ({ options, config, datastore, keychainConfig, peerId, peerDiscovery: [], transports: [], streamMuxers: [ - new Mplex({ - // temporary fix until we can limit streams on a per-protocol basis - maxStreamsPerConnection: Infinity + mplex({ + maxInboundStreams: 256, + maxOutboundStreams: 1024 }) ], connectionEncryption: [ - NOISE + noise() ], relay: { enabled: get(options, 'relay.enabled', get(config, 'relay.enabled', true)), @@ -149,7 +150,7 @@ function getLibp2pOptions ({ options, config, datastore, keychainConfig, peerId, } if (get(config, 'Routing.Type', 'dhtclient') !== 'none') { - libp2pOptions.dht = new KadDHT({ + libp2pOptions.dht = kadDHT({ clientMode: get(config, 'Routing.Type', 'dht') !== 'dhtserver', kBucketSize: get(options, 'dht.kBucketSize', 20), validators: { @@ -165,7 +166,7 @@ function getLibp2pOptions ({ options, config, datastore, keychainConfig, peerId, if (boostrapNodes.length > 0) { libp2pOptions.peerDiscovery?.push( - new Bootstrap({ + bootstrap({ list: boostrapNodes }) ) @@ -195,7 +196,7 @@ function getLibp2pOptions ({ options, config, datastore, keychainConfig, peerId, if (delegateHosts.length > 0) { // Pick a random delegate host const delegateString = delegateHosts[Math.floor(Math.random() * delegateHosts.length)] - const delegateAddr = new Multiaddr(delegateString).toOptions() + const delegateAddr = multiaddr(delegateString).toOptions() const delegateApiOptions = { host: delegateAddr.host, // port is a string atm, so we need to convert for the check @@ -206,13 +207,20 @@ function getLibp2pOptions ({ options, config, datastore, keychainConfig, peerId, const delegateHttpClient = ipfsHttpClient(delegateApiOptions) - libp2pFinalConfig.contentRouters?.push(new DelegatedContentRouting(delegateHttpClient)) - libp2pFinalConfig.peerRouters?.push(new DelegatedPeerRouting(delegateHttpClient)) + libp2pFinalConfig.contentRouters?.push(delegatedContentRouting(delegateHttpClient)) + libp2pFinalConfig.peerRouters?.push(delegatedPeerRouting(delegateHttpClient)) } + // TODO: fixme if (!get(options, 'config.Discovery.MDNS.Enabled', get(config, 'Discovery.MDNS.Enabled', true))) { libp2pFinalConfig.peerDiscovery = libp2pFinalConfig.peerDiscovery?.filter(d => { - return d != null && d[Symbol.toStringTag] !== '@libp2p/mdns' + try { + if (typeof d === 'function') { + // @ts-expect-error not components + return d({})[Symbol.toStringTag] !== '@libp2p/mdns' + } + } catch {} + return true }) } @@ -221,8 +229,15 @@ function getLibp2pOptions ({ options, config, datastore, keychainConfig, peerId, } // add WebSocket transport if not overridden by user config - if (libp2pFinalConfig.transports.find(t => t[Symbol.toStringTag] === '@libp2p/websockets') == null) { - libp2pFinalConfig.transports.push(new WebSockets()) + if (libp2pFinalConfig.transports.find(t => { + try { + if (typeof t === 'function') { + return t({})[Symbol.toStringTag] === '@libp2p/websockets' + } + } catch {} + return false + }) == null) { + libp2pFinalConfig.transports.push(webSockets()) } return libp2pFinalConfig diff --git a/packages/ipfs-core/src/components/name/index.js b/packages/ipfs-core/src/components/name/index.js index 7e998e01f8..b4fdd65a58 100644 --- a/packages/ipfs-core/src/components/name/index.js +++ b/packages/ipfs-core/src/components/name/index.js @@ -6,12 +6,12 @@ export class NameAPI { /** * @param {object} config * @param {import('../ipns').IPNSAPI} config.ipns - * @param {import('@libp2p/interfaces/peer-id').PeerId} config.peerId + * @param {import('@libp2p/interface-peer-id').PeerId} config.peerId * @param {import('../../types').Options} config.options * @param {import('ipfs-repo').IPFSRepo} config.repo * @param {import('ipfs-core-utils/multicodecs').Multicodecs} config.codecs * @param {import('ipfs-core-types/src/root').API<{}>["isOnline"]} config.isOnline - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain * @param {import('ipfs-core-types/src/root').API<{}>["dns"]} config.dns */ constructor ({ dns, ipns, repo, codecs, peerId, isOnline, keychain, options }) { diff --git a/packages/ipfs-core/src/components/name/publish.js b/packages/ipfs-core/src/components/name/publish.js index be940978be..1a62727490 100644 --- a/packages/ipfs-core/src/components/name/publish.js +++ b/packages/ipfs-core/src/components/name/publish.js @@ -18,16 +18,16 @@ const log = logger('ipfs:name:publish') * @param {import('../ipns').IPNSAPI} config.ipns * @param {import('ipfs-repo').IPFSRepo} config.repo * @param {import('ipfs-core-utils/multicodecs').Multicodecs} config.codecs - * @param {import('@libp2p/interfaces/peer-id').PeerId} config.peerId + * @param {import('@libp2p/interface-peer-id').PeerId} config.peerId * @param {import('ipfs-core-types/src/root').API<{}>["isOnline"]} config.isOnline - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain */ export function createPublish ({ ipns, repo, codecs, peerId, isOnline, keychain }) { /** * @param {string} keyName */ const lookupKey = async keyName => { - /** @type {import('@libp2p/interfaces/keys').PrivateKey} */ + /** @type {import('@libp2p/interface-keys').PrivateKey} */ let privateKey if (keyName === 'self' && peerId.privateKey != null) { @@ -89,7 +89,7 @@ export function createPublish ({ ipns, repo, codecs, peerId, isOnline, keychain const bytes = uint8ArrayFromString(value) // Start publishing process - const result = await ipns.publish(results[0], bytes, pubLifetime) + const result = await ipns.publish(results[0], bytes, pubLifetime, options) return { name: result.name, diff --git a/packages/ipfs-core/src/components/name/utils.js b/packages/ipfs-core/src/components/name/utils.js index b1336e6f29..2e28d2d1f4 100644 --- a/packages/ipfs-core/src/components/name/utils.js +++ b/packages/ipfs-core/src/components/name/utils.js @@ -1,4 +1,4 @@ -import isIPFS from 'is-ipfs' +import * as isIPFS from 'is-ipfs' import { toCidAndPath } from 'ipfs-core-utils/to-cid-and-path' import drain from 'it-drain' import { resolve } from '../../utils.js' diff --git a/packages/ipfs-core/src/components/network.js b/packages/ipfs-core/src/components/network.js index ab473caaee..bed24db762 100644 --- a/packages/ipfs-core/src/components/network.js +++ b/packages/ipfs-core/src/components/network.js @@ -1,6 +1,6 @@ import { createBitswap } from 'ipfs-bitswap' import { createLibp2p } from './libp2p.js' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' import errCode from 'err-code' import { BlockStorage } from '../block-storage.js' @@ -22,8 +22,9 @@ import { BlockStorage } from '../block-storage.js' * @typedef {import('../types').Print} Print * @typedef {import('libp2p').Libp2p} libp2p * @typedef {import('ipfs-bitswap').IPFSBitswap} Bitswap - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId * @typedef {import('ipfs-core-types/src/utils').AbortOptions} AbortOptions + * @typedef {import('@multiformats/multiaddr').Multiaddr} Multiaddr */ export class Network { @@ -64,10 +65,6 @@ export class Network { keychainConfig: undefined }) - if (libp2p.keychain) { - await libp2p.loadKeychain() - } - await libp2p.start() for (const ma of libp2p.getMultiaddrs()) { @@ -76,7 +73,9 @@ export class Network { const bitswap = createBitswap(libp2p, repo.blocks, { statsEnabled: true, - hashLoader: hashers + hashLoader: hashers, + maxInboundStreams: 1024, + maxOutboundStreams: 1024 }) await bitswap.start() @@ -111,7 +110,7 @@ const readAddrs = (peerId, config) => { const addrs = [] const swarm = (config.Addresses && config.Addresses.Swarm) || [] for (const addr of swarm) { - let ma = new Multiaddr(addr) + let ma = multiaddr(addr) // Temporary error for users migrating using websocket-star multiaddrs for listenning on libp2p // websocket-star support was removed from ipfs and libp2p diff --git a/packages/ipfs-core/src/components/pubsub.js b/packages/ipfs-core/src/components/pubsub.js index 4f584e63aa..145af80186 100644 --- a/packages/ipfs-core/src/components/pubsub.js +++ b/packages/ipfs-core/src/components/pubsub.js @@ -4,7 +4,7 @@ import { NotEnabledError } from '../errors.js' import get from 'dlv' /** - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message * @typedef {import('@libp2p/interfaces/events').EventHandler>} EventHandler * @typedef {import('@libp2p/interfaces/events').EventHandler} MessageEventHandler */ diff --git a/packages/ipfs-core/src/components/resolve.js b/packages/ipfs-core/src/components/resolve.js index 41a14dc0c5..1580fe9fe7 100644 --- a/packages/ipfs-core/src/components/resolve.js +++ b/packages/ipfs-core/src/components/resolve.js @@ -1,4 +1,4 @@ -import isIpfs from 'is-ipfs' +import * as isIpfs from 'is-ipfs' import { CID } from 'multiformats/cid' import { peerIdFromString } from '@libp2p/peer-id' import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' diff --git a/packages/ipfs-core/src/components/start.js b/packages/ipfs-core/src/components/start.js index cab8c111cf..cdae78c1a3 100644 --- a/packages/ipfs-core/src/components/start.js +++ b/packages/ipfs-core/src/components/start.js @@ -3,13 +3,13 @@ import { Service } from '../utils/service.js' /** * @param {object} config * @param {import('../types').NetworkService} config.network - * @param {import('@libp2p/interfaces/peer-id').PeerId} config.peerId + * @param {import('@libp2p/interface-peer-id').PeerId} config.peerId * @param {import('ipfs-repo').IPFSRepo} config.repo * @param {import('../types').Print} config.print * @param {import('../types').Preload} config.preload * @param {import('../types').MfsPreload} config.mfsPreload * @param {import('./ipns').IPNSAPI} config.ipns - * @param {import('@libp2p/interfaces/keychain').KeyChain} config.keychain + * @param {import('@libp2p/interface-keychain').KeyChain} config.keychain * @param {import('ipfs-core-utils/multihashes').Multihashes} config.hashers * @param {import('../types').Options} config.options */ diff --git a/packages/ipfs-core/src/components/storage.js b/packages/ipfs-core/src/components/storage.js index d30006448f..416e7b0118 100644 --- a/packages/ipfs-core/src/components/storage.js +++ b/packages/ipfs-core/src/components/storage.js @@ -4,7 +4,7 @@ import getDefaultConfig from 'ipfs-core-config/config' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' import { peerIdFromKeys } from '@libp2p/peer-id' -import { isPeerId } from '@libp2p/interfaces/peer-id' +import { isPeerId } from '@libp2p/interface-peer-id' import mergeOpts from 'merge-options' import { profiles as configProfiles } from './config/profiles.js' import { NotEnabledError, NotInitializedError } from '../errors.js' @@ -13,6 +13,7 @@ import { ERR_REPO_NOT_INITIALIZED } from 'ipfs-repo/errors' import { createEd25519PeerId, createRSAPeerId } from '@libp2p/peer-id-factory' import errCode from 'err-code' import { unmarshalPrivateKey } from '@libp2p/crypto/keys' +import { Key } from 'interface-datastore/key' const mergeOptions = mergeOpts.bind({ ignoreUndefined: true }) const log = logger('ipfs:components:peer:storage') @@ -24,8 +25,8 @@ const log = logger('ipfs:components:peer:storage') * @typedef {import('../types').Print} Print * @typedef {import('ipfs-core-types/src/config').Config} IPFSConfig * @typedef {import('@libp2p/crypto/keys').KeyTypes} KeyType - * @typedef {import('@libp2p/interfaces/keychain').KeyChain} Keychain - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-keychain').KeyChain} Keychain + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId */ export class Storage { @@ -158,15 +159,15 @@ const initRepo = async (print, repo, options) => { keychainConfig }) - if (libp2p.keychain) { - await libp2p.loadKeychain() - - await repo.config.set('Keychain', { - // @ts-expect-error private field - DEK: libp2p.keychain.init.dek - }) + if (!(await repo.datastore.has(new Key('/info/self')))) { + await libp2p.keychain.importPeer('self', peerId) } + await repo.config.set('Keychain', { + // @ts-expect-error private field + DEK: libp2p.keychain.init.dek + }) + return { peerId, keychain: libp2p.keychain } } @@ -264,10 +265,6 @@ const configureRepo = async (repo, options) => { } }) - if (libp2p.keychain) { - await libp2p.loadKeychain() - } - return { peerId, keychain: libp2p.keychain } } diff --git a/packages/ipfs-core/src/ipns/index.js b/packages/ipfs-core/src/ipns/index.js index c851cd0d0a..aa43a14086 100644 --- a/packages/ipfs-core/src/ipns/index.js +++ b/packages/ipfs-core/src/ipns/index.js @@ -10,8 +10,9 @@ const log = logger('ipfs:ipns') const defaultRecordTtl = 60 * 1000 /** - * @typedef {import('@libp2p/interfaces/keys').PrivateKey} PrivateKey - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-keys').PrivateKey} PrivateKey + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interfaces').AbortOptions} AbortOptions */ export class IPNS { @@ -19,7 +20,7 @@ export class IPNS { * @param {import('ipfs-core-types/src/utils').BufferStore} routing * @param {import('interface-datastore').Datastore} datastore * @param {PeerId} peerId - * @param {import('@libp2p/interfaces/keychain').KeyChain} keychain + * @param {import('@libp2p/interface-keychain').KeyChain} keychain * @param {object} options * @param {string} options.pass * @param {number} [options.initialBroadcastInterval] @@ -39,10 +40,11 @@ export class IPNS { * @param {PeerId} peerId * @param {Uint8Array} value * @param {number} lifetime + * @param {AbortOptions} [options] */ - async publish (peerId, value, lifetime = IpnsPublisher.defaultRecordLifetime) { + async publish (peerId, value, lifetime = IpnsPublisher.defaultRecordLifetime, options) { try { - await this.publisher.publishWithEOL(peerId, value, lifetime) + await this.publisher.publishWithEOL(peerId, value, lifetime, options) log(`IPNS value ${uint8ArrayToString(value, 'base32')} was published correctly`) @@ -74,6 +76,7 @@ export class IPNS { * @param {object} options * @param {boolean} [options.nocache] * @param {boolean} [options.recursive] + * @param {AbortSignal} [options.signal] */ async resolve (name, options = {}) { if (typeof name !== 'string') { @@ -111,8 +114,9 @@ export class IPNS { * * @param {PeerId} peerId * @param {Uint8Array} value + * @param {AbortOptions} [options] */ - async initializeKeyspace (peerId, value) { // eslint-disable-line require-await - return this.publish(peerId, value, IpnsPublisher.defaultRecordLifetime) + async initializeKeyspace (peerId, value, options) { // eslint-disable-line require-await + return this.publish(peerId, value, IpnsPublisher.defaultRecordLifetime, options) } } diff --git a/packages/ipfs-core/src/ipns/publisher.js b/packages/ipfs-core/src/ipns/publisher.js index 64706cf92b..eb66b1e525 100644 --- a/packages/ipfs-core/src/ipns/publisher.js +++ b/packages/ipfs-core/src/ipns/publisher.js @@ -1,4 +1,4 @@ -import { isPeerId } from '@libp2p/interfaces/peer-id' +import { isPeerId } from '@libp2p/interface-peer-id' import { notFoundError } from 'datastore-core/errors' import errcode from 'err-code' import { logger } from '@libp2p/logger' @@ -9,10 +9,11 @@ import * as ipns from 'ipns' const log = logger('ipfs:ipns:publisher') /** - * @typedef {import('@libp2p/interfaces/keys').PrivateKey} PrivateKey - * @typedef {import('@libp2p/interfaces/keys').PublicKey} PublicKey + * @typedef {import('@libp2p/interface-keys').PrivateKey} PrivateKey + * @typedef {import('@libp2p/interface-keys').PublicKey} PublicKey * @typedef {import('ipns').IPNSEntry} IPNSEntry - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interfaces').AbortOptions} AbortOptions */ const ERR_NOT_FOUND = notFoundError().code @@ -35,11 +36,12 @@ export class IpnsPublisher { * @param {PeerId} peerId * @param {Uint8Array} value * @param {number} lifetime + * @param {AbortOptions} [options] */ - async publishWithEOL (peerId, value, lifetime) { - const record = await this._updateOrCreateRecord(peerId, value, lifetime) + async publishWithEOL (peerId, value, lifetime, options) { + const record = await this._updateOrCreateRecord(peerId, value, lifetime, options) - return this._putRecordToRouting(record, peerId) + return this._putRecordToRouting(record, peerId, options) } /** @@ -47,16 +49,18 @@ export class IpnsPublisher { * * @param {PeerId} peerId * @param {Uint8Array} value + * @param {AbortOptions} options */ - publish (peerId, value) { - return this.publishWithEOL(peerId, value, defaultRecordLifetime) + publish (peerId, value, options) { + return this.publishWithEOL(peerId, value, defaultRecordLifetime, options) } /** * @param {Uint8Array} record * @param {PeerId} peerId + * @param {AbortOptions} [options] */ - async _putRecordToRouting (record, peerId) { + async _putRecordToRouting (record, peerId, options) { if (!(isPeerId(peerId))) { const errMsg = 'peerId received is not valid' log.error(errMsg) @@ -70,7 +74,7 @@ export class IpnsPublisher { const routingKey = ipns.peerIdToRoutingKey(peerId) - await this._publishEntry(routingKey, record) + await this._publishEntry(routingKey, record, options) return record } @@ -78,11 +82,12 @@ export class IpnsPublisher { /** * @param {Uint8Array} key * @param {Uint8Array} entry + * @param {AbortOptions} [options] */ - async _publishEntry (key, entry) { + async _publishEntry (key, entry, options) { // Add record to routing (buffer key) try { - const res = await this._routing.put(key, entry) + const res = await this._routing.put(key, entry, options) log(`ipns record for ${uint8ArrayToString(key, 'base32')} was stored in the routing`) return res @@ -162,8 +167,9 @@ export class IpnsPublisher { * @param {PeerId} peerId * @param {Uint8Array} value * @param {number} lifetime + * @param {AbortOptions} [options] */ - async _updateOrCreateRecord (peerId, value, lifetime) { + async _updateOrCreateRecord (peerId, value, lifetime, options) { if (!(isPeerId(peerId))) { const errMsg = 'peerId received is not valid' log.error(errMsg) @@ -217,7 +223,7 @@ export class IpnsPublisher { const data = ipns.marshal(entryData) // Store the new record - await this._datastore.put(ipns.getLocalKey(peerId.toBytes()), data) + await this._datastore.put(ipns.getLocalKey(peerId.toBytes()), data, options) log(`ipns record for ${uint8ArrayToString(value, 'base32')} was stored in the datastore`) diff --git a/packages/ipfs-core/src/ipns/republisher.js b/packages/ipfs-core/src/ipns/republisher.js index a64162cea6..e9a1758b81 100644 --- a/packages/ipfs-core/src/ipns/republisher.js +++ b/packages/ipfs-core/src/ipns/republisher.js @@ -1,15 +1,17 @@ import * as ipns from 'ipns' import { importKey } from '@libp2p/crypto/keys' -import { isPeerId } from '@libp2p/interfaces/peer-id' +import { isPeerId } from '@libp2p/interface-peer-id' import errcode from 'err-code' import { logger } from '@libp2p/logger' import { peerIdFromKeys } from '@libp2p/peer-id' +import { TimeoutController } from 'timeout-abort-controller' const log = logger('ipfs:ipns:republisher') /** - * @typedef {import('@libp2p/interfaces/keys').PrivateKey} PrivateKey - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-keys').PrivateKey} PrivateKey + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interfaces').AbortOptions} AbortOptions */ const minute = 60 * 1000 @@ -23,7 +25,7 @@ export class IpnsRepublisher { * @param {import('./publisher').IpnsPublisher} publisher * @param {import('interface-datastore').Datastore} datastore * @param {PeerId} peerId - * @param {import('@libp2p/interfaces/keychain').KeyChain} keychain + * @param {import('@libp2p/interface-keychain').KeyChain} keychain * @param {object} options * @param {string} options.pass * @param {number} [options.initialBroadcastInterval] @@ -87,7 +89,17 @@ export class IpnsRepublisher { const { pass } = this._options let firstRun = true - republishHandle._task = () => this._republishEntries(this._peerId, pass) + republishHandle._task = async () => { + const timeoutController = new TimeoutController(30000) + + try { + await this._republishEntries(this._peerId, pass, { + signal: timeoutController.signal + }) + } finally { + timeoutController.clear() + } + } republishHandle.runPeriodically(() => { if (firstRun) { @@ -116,12 +128,13 @@ export class IpnsRepublisher { /** * @param {PeerId} peerId * @param {string} pass + * @param {AbortOptions} options */ - async _republishEntries (peerId, pass) { + async _republishEntries (peerId, pass, options) { // TODO: Should use list of published entries. // We can't currently *do* that because go uses this method for now. try { - await this._republishEntry(peerId) + await this._republishEntry(peerId, options) } catch (/** @type {any} */ err) { const errMsg = 'cannot republish entry for the node\'s private key' @@ -143,7 +156,7 @@ export class IpnsRepublisher { const privKey = await importKey(pem, pass) const peerIdKey = await peerIdFromKeys(privKey.public.bytes, privKey.bytes) - await this._republishEntry(peerIdKey) + await this._republishEntry(peerIdKey, options) } } catch (/** @type {any} */ err) { log.error(err) @@ -153,11 +166,12 @@ export class IpnsRepublisher { /** * @param {PeerId} peerId + * @param {AbortOptions} options */ - async _republishEntry (peerId) { + async _republishEntry (peerId, options) { try { const value = await this._getPreviousValue(peerId) - await this._publisher.publishWithEOL(peerId, value, defaultRecordLifetime) + await this._publisher.publishWithEOL(peerId, value, defaultRecordLifetime, options) } catch (/** @type {any} */ err) { if (err.code === 'ERR_NO_ENTRY_FOUND') { return diff --git a/packages/ipfs-core/src/ipns/resolver.js b/packages/ipfs-core/src/ipns/resolver.js index b06203b3a1..a0f3a4ff95 100644 --- a/packages/ipfs-core/src/ipns/resolver.js +++ b/packages/ipfs-core/src/ipns/resolver.js @@ -9,7 +9,8 @@ import * as Errors from 'datastore-core/errors' import { ipnsValidator } from 'ipns/validator' /** - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interfaces').AbortOptions} AbortOptions */ const log = logger('ipfs:ipns:resolver') @@ -28,8 +29,9 @@ export class IpnsResolver { /** * @param {string} name - * @param {object} options + * @param {object} [options] * @param {boolean} [options.recursive] + * @param {AbortSignal} [options.signal] */ async resolve (name, options = {}) { if (typeof name !== 'string') { @@ -53,7 +55,7 @@ export class IpnsResolver { depth = defaultMaximumRecursiveDepth } - const res = await this.resolver(key, depth) + const res = await this.resolver(key, depth, options) log(`${name} was locally resolved correctly`) return res @@ -64,9 +66,10 @@ export class IpnsResolver { * * @param {string} name * @param {number} depth + * @param {AbortOptions} options * @returns {Promise} */ - async resolver (name, depth) { + async resolver (name, depth, options) { // Exceeded recursive maximum depth if (depth === 0) { const errMsg = `could not resolve name (recursion limit of ${defaultMaximumRecursiveDepth} exceeded)` @@ -75,7 +78,7 @@ export class IpnsResolver { throw errcode(new Error(errMsg), 'ERR_RESOLVE_RECURSION_LIMIT') } - const res = await this._resolveName(name) + const res = await this._resolveName(name, options) const nameSegments = res.split('/') // If obtained a ipfs cid or recursive option is disabled @@ -84,21 +87,22 @@ export class IpnsResolver { } // continue recursively until depth equals 0 - return this.resolver(nameSegments[2], depth - 1) + return this.resolver(nameSegments[2], depth - 1, options) } /** * Resolve ipns entries from the provided routing * * @param {string} name + * @param {AbortOptions} options */ - async _resolveName (name) { + async _resolveName (name, options) { const peerId = peerIdFromString(name) const routingKey = ipns.peerIdToRoutingKey(peerId) let record try { - record = await this._routing.get(routingKey) + record = await this._routing.get(routingKey, options) } catch (/** @type {any} */ err) { log.error('could not get record from routing', err) diff --git a/packages/ipfs-core/src/ipns/routing/config.js b/packages/ipfs-core/src/ipns/routing/config.js index aabaf9b923..be4f1afa13 100644 --- a/packages/ipfs-core/src/ipns/routing/config.js +++ b/packages/ipfs-core/src/ipns/routing/config.js @@ -12,7 +12,7 @@ import { DHTDatastore } from './dht-datastore.js' * @param {object} arg * @param {import('libp2p').Libp2p} arg.libp2p * @param {import('ipfs-repo').IPFSRepo} arg.repo - * @param {import('@libp2p/interfaces/peer-id').PeerId} arg.peerId + * @param {import('@libp2p/interface-peer-id').PeerId} arg.peerId * @param {object} arg.options */ export function createRouting ({ libp2p, repo, peerId, options }) { diff --git a/packages/ipfs-core/src/ipns/routing/dht-datastore.js b/packages/ipfs-core/src/ipns/routing/dht-datastore.js index e137d64c96..62b08eadff 100644 --- a/packages/ipfs-core/src/ipns/routing/dht-datastore.js +++ b/packages/ipfs-core/src/ipns/routing/dht-datastore.js @@ -4,10 +4,14 @@ import { logger } from '@libp2p/logger' const log = logger('ipfs:ipns:dht-datastore') +/** + * @typedef {import('@libp2p/interfaces').AbortOptions} AbortOptions + */ + export class DHTDatastore { /** * - * @param {import('@libp2p/interfaces/dht').DHT} dht + * @param {import('@libp2p/interface-dht').DHT} dht */ constructor (dht) { this._dht = dht @@ -16,10 +20,11 @@ export class DHTDatastore { /** * @param {Uint8Array} key - identifier of the value. * @param {Uint8Array} value - value to be stored. + * @param {AbortOptions} [options] */ - async put (key, value) { + async put (key, value, options) { try { - await drain(this._dht.put(key, value)) + await drain(this._dht.put(key, value, options)) } catch (/** @type {any} */ err) { log.error(err) throw err @@ -28,9 +33,10 @@ export class DHTDatastore { /** * @param {Uint8Array} key - identifier of the value to be obtained. + * @param {AbortOptions} [options] */ - async get (key) { - for await (const event of this._dht.get(key)) { + async get (key, options) { + for await (const event of this._dht.get(key, options)) { if (event.name === 'VALUE') { return event.value } diff --git a/packages/ipfs-core/src/ipns/routing/offline-datastore.js b/packages/ipfs-core/src/ipns/routing/offline-datastore.js index 5ec0289e9d..bbc590b596 100644 --- a/packages/ipfs-core/src/ipns/routing/offline-datastore.js +++ b/packages/ipfs-core/src/ipns/routing/offline-datastore.js @@ -6,6 +6,10 @@ import { toString as uint8ArrayToString } from 'uint8arrays/to-string' const log = logger('ipfs:ipns:offline-datastore') +/** + * @typedef {import('@libp2p/interfaces').AbortOptions} AbortOptions + */ + // Offline datastore aims to mimic the same encoding as routing when storing records // to the local datastore export class OfflineDatastore { @@ -23,8 +27,9 @@ export class OfflineDatastore { * * @param {Uint8Array} key - identifier of the value. * @param {Uint8Array} value - value to be stored. + * @param {AbortOptions} [options] */ - async put (key, value) { // eslint-disable-line require-await + async put (key, value, options) { // eslint-disable-line require-await if (!(key instanceof Uint8Array)) { throw errcode(new Error('Offline datastore key must be a Uint8Array'), 'ERR_INVALID_KEY') } @@ -45,15 +50,16 @@ export class OfflineDatastore { // Marshal to libp2p record as the DHT does const record = new Libp2pRecord(key, value, new Date()) - await this._datastore.put(routingKey, record.serialize()) + await this._datastore.put(routingKey, record.serialize(), options) } /** * Get a value from the local datastore indexed by the received key properly encoded. * * @param {Uint8Array} key - identifier of the value to be obtained. + * @param {AbortOptions} [options] */ - async get (key) { + async get (key, options) { if (!(key instanceof Uint8Array)) { throw errcode(new Error('Offline datastore key must be a Uint8Array'), 'ERR_INVALID_KEY') } @@ -67,7 +73,7 @@ export class OfflineDatastore { throw errcode(new Error('Not possible to generate the routing key'), 'ERR_GENERATING_ROUTING_KEY') } - const res = await this._datastore.get(routingKey) + const res = await this._datastore.get(routingKey, options) // Unmarshal libp2p record as the DHT does let record diff --git a/packages/ipfs-core/src/ipns/routing/pubsub-datastore.js b/packages/ipfs-core/src/ipns/routing/pubsub-datastore.js index 2eb4999e44..e796cd6f91 100644 --- a/packages/ipfs-core/src/ipns/routing/pubsub-datastore.js +++ b/packages/ipfs-core/src/ipns/routing/pubsub-datastore.js @@ -11,12 +11,16 @@ import { peerIdFromString } from '@libp2p/peer-id' const log = logger('ipfs:ipns:pubsub') +/** + * @typedef {import('@libp2p/interfaces').AbortOptions} AbortOptions + */ + // Pubsub datastore aims to manage the pubsub subscriptions for IPNS export class IpnsPubsubDatastore { /** - * @param {import('@libp2p/interfaces/pubsub').PubSub} pubsub + * @param {import('@libp2p/interface-pubsub').PubSub} pubsub * @param {import('interface-datastore').Datastore} localDatastore - * @param {import('@libp2p/interfaces/peer-id').PeerId} peerId + * @param {import('@libp2p/interface-peer-id').PeerId} peerId */ constructor (pubsub, localDatastore, peerId) { /** @type {Record} */ @@ -33,10 +37,11 @@ export class IpnsPubsubDatastore { * * @param {Uint8Array} key - identifier of the value. * @param {Uint8Array} value - value to be stored. + * @param {AbortOptions} [options] */ - async put (key, value) { + async put (key, value, options) { try { - await this._pubsubDs.put(key, value) + await this._pubsubDs.put(key, value, options) } catch (/** @type {any} */ err) { log.error(err) throw err @@ -49,13 +54,14 @@ export class IpnsPubsubDatastore { * updated once new publishes occur. * * @param {Uint8Array} key - identifier of the value to be obtained. + * @param {AbortOptions} [options] */ - async get (key) { + async get (key, options) { let res let err try { - res = await this._pubsubDs.get(key) + res = await this._pubsubDs.get(key, options) } catch (/** @type {any} */ e) { err = e } diff --git a/packages/ipfs-core/src/types.ts b/packages/ipfs-core/src/types.ts index 9d09890a5e..6a02e5df69 100644 --- a/packages/ipfs-core/src/types.ts +++ b/packages/ipfs-core/src/types.ts @@ -1,14 +1,11 @@ -import type { KeyType } from '@libp2p/interfaces/keys' -import type { PeerId } from '@libp2p/interfaces/peer-id' +import type { KeyType } from '@libp2p/interface-keys' +import type { PeerId } from '@libp2p/interface-peer-id' import type { Config as IPFSConfig } from 'ipfs-core-types/src/config' import type { Libp2p, Libp2pOptions } from 'libp2p' - import type { IPFSRepo } from 'ipfs-repo' import type { ProgressCallback as MigrationProgressCallback } from 'ipfs-repo-migrations' import type { Network, Options as NetworkOptions } from './components/network' - import type { Datastore } from 'interface-datastore' - import type { Service } from './utils/service' import type { CID } from 'multiformats/cid' import type { BlockCodec } from 'multiformats/codecs/interface' diff --git a/packages/ipfs-core/src/utils.js b/packages/ipfs-core/src/utils.js index 7e473777f8..16ab3671f2 100644 --- a/packages/ipfs-core/src/utils.js +++ b/packages/ipfs-core/src/utils.js @@ -1,6 +1,6 @@ /* eslint-disable no-unreachable */ -import isIpfs from 'is-ipfs' +import * as isIpfs from 'is-ipfs' import { CID } from 'multiformats/cid' import { Key } from 'interface-datastore/key' import errCode from 'err-code' diff --git a/packages/ipfs-core/test/config.spec.js b/packages/ipfs-core/test/config.spec.js index 2542aec03b..642ce41eb9 100644 --- a/packages/ipfs-core/test/config.spec.js +++ b/packages/ipfs-core/test/config.spec.js @@ -2,7 +2,7 @@ /* eslint-env mocha */ import { expect } from 'aegir/chai' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' import { isBrowser, isWebWorker } from 'ipfs-utils/src/env.js' import createNode from './utils/create-node.js' import createConfig from 'ipfs-core-config/config' @@ -39,7 +39,7 @@ describe('config', function () { return acc } - const ma = new Multiaddr(curr) + const ma = multiaddr(curr) return ma.protos().some(proto => proto.name === 'wss' || proto.resolvable) }, true) diff --git a/packages/ipfs-core/test/libp2p.spec.js b/packages/ipfs-core/test/libp2p.spec.js index 5bf4a6398b..2a926908d0 100644 --- a/packages/ipfs-core/test/libp2p.spec.js +++ b/packages/ipfs-core/test/libp2p.spec.js @@ -2,43 +2,14 @@ import { expect } from 'aegir/chai' import { MemoryDatastore } from 'datastore-core/memory' -// import { createLibp2p } from 'libp2p' -// import { EventEmitter } from 'events' import { createLibp2p as libp2pComponent } from '../src/components/libp2p.js' -// import { NOISE as Crypto } from '@chainsafe/libp2p-noise' import { GossipSub } from '@chainsafe/libp2p-gossipsub' import { createEd25519PeerId } from '@libp2p/peer-id-factory' /** - * @type {import('@libp2p/interfaces/transport').Transport} + * @type {import('@libp2p/interface-transport').Transport} */ -/* -class DummyTransport { - get [Symbol.toStringTag] () { - return 'DummyTransport' - } - - filter () { - return [] - } -} - -class DummyDiscovery extends EventEmitter { - get [Symbol.toStringTag] () { - return 'DummyDiscovery' - } - - start () { - return Promise.resolve() - } - - stop () { - return Promise.resolve() - } -} -*/ - describe('libp2p customization', function () { // Provide some extra time for ci since we're starting libp2p nodes in each test this.timeout(25 * 1000) @@ -48,7 +19,7 @@ describe('libp2p customization', function () { */ let datastore /** - * @type {import('@libp2p/interfaces/peer-id').PeerId} + * @type {import('@libp2p/interface-peer-id').PeerId} */ let peerId /** @@ -88,131 +59,7 @@ describe('libp2p customization', function () { libp2p = null } }) - /* - describe('bundle', () => { - it('should allow for using a libp2p bundle', async () => { - libp2p = await libp2pComponent({ - options: { - libp2p: async (opts) => { - return createLibp2p({ - peerId: opts.peerId, - transports: [new DummyTransport()], - connectionEncryption: [Crypto], - relay: { enabled: false } - }) - } - }, - peerId, - // @ts-expect-error repo is not complete implementation - repo: { datastore }, - print: console.log, // eslint-disable-line no-console - config: testConfig - }) - - await libp2p.start() - - expect(libp2p._config.peerDiscovery).to.eql({ autoDial: true }) - const transports = Array.from(libp2p.transportManager.getTransports()) - expect(transports).to.have.length(1) - }) - - it('should pass libp2p options to libp2p bundle function', async () => { - libp2p = await libp2pComponent({ - options: { - libp2p: async (opts) => { - return createLibp2p({ - peerId: opts.peerId, - // @ts-expect-error DummyTransport is not complete implementation - modules: { transport: [DummyTransport], connEncryption: [Crypto] }, - config: { relay: { enabled: false } } - }) - } - }, - peerId, - // @ts-expect-error repo is not complete implementation - repo: { datastore }, - print: console.log, // eslint-disable-line no-console - config: testConfig - }) - - await libp2p.start() - - expect(libp2p._config.peerDiscovery).to.eql({ autoDial: true }) - const transports = Array.from(libp2p.transportManager.getTransports()) - expect(transports[0] instanceof DummyTransport).to.equal(true) - }) - }) - describe('options', () => { - it('should use options by default', async () => { - libp2p = await libp2pComponent({ - peerId, - // @ts-expect-error repo is not complete implementation - repo: { datastore }, - print: console.log, // eslint-disable-line no-console - config: testConfig - }) - - await libp2p.start() - - expect(libp2p._config).to.deep.include({ - peerDiscovery: { - autoDial: true, - bootstrap: { - enabled: true, - list: [] - }, - mdns: { - enabled: false - }, - webRTCStar: { - enabled: false - } - }, - pubsub: { - enabled: true, - emitSelf: true - } - }) - const transports = Array.from(libp2p.transportManager.getTransports()) - expect(transports).to.have.length(3) - }) - - it('should allow for overriding via options', async () => { - const annAddr = '/dns4/test.ipfs.io/tcp/443/wss' - - libp2p = await libp2pComponent({ - peerId, - // @ts-expect-error repo is not complete implementation - repo: { datastore }, - print: console.log, // eslint-disable-line no-console - config: testConfig, - options: { - libp2p: { - transports: [new DummyTransport()], - peerDiscovery: [new DummyDiscovery()], - relay: { enabled: false }, - addresses: { - announce: [annAddr] - } - } - } - }) - - await libp2p.start() - - const transports = Array.from(libp2p.transportManager.getTransports()) - expect(transports).to.have.length(1) - expect(transports[0] instanceof DummyTransport).to.be.true() - - const discoveries = Array.from(libp2p.discovery.values()) - expect(discoveries).to.have.length(1) - expect(discoveries[0] instanceof DummyDiscovery).to.be.true() - - expect(libp2p.getMultiaddrs().map(m => m.toString())).to.include(annAddr) - }) - }) -*/ describe('config', () => { it('should be able to specify Announce addresses', async () => { const annAddr = '/dns4/test.ipfs.io/tcp/443/wss' diff --git a/packages/ipfs-core/tsconfig.json b/packages/ipfs-core/tsconfig.json index cace6261fa..75c9db0632 100644 --- a/packages/ipfs-core/tsconfig.json +++ b/packages/ipfs-core/tsconfig.json @@ -10,6 +10,9 @@ "package.json" ], "references": [ + { + "path": "../interface-ipfs-core" + }, { "path": "../ipfs-core-config" }, diff --git a/packages/ipfs-daemon/CHANGELOG.md b/packages/ipfs-daemon/CHANGELOG.md index ad1a320bae..f464e2044e 100644 --- a/packages/ipfs-daemon/CHANGELOG.md +++ b/packages/ipfs-daemon/CHANGELOG.md @@ -3,6 +3,77 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.15.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-daemon-v0.14.2...ipfs-daemon-v0.15.0) (2022-10-24) + + +### ⚠ BREAKING CHANGES + +* ipfs is now bundled with libp2p@0.40.x which has different config + +### Features + +* upgrade libp2p to 0.40.x ([#4237](https://www.github.com/ipfs/js-ipfs/issues/4237)) ([0cee4a4](https://www.github.com/ipfs/js-ipfs/commit/0cee4a4c55767022584dcbade0b0b9b43326f9c9)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core bumped from ^0.16.1 to ^0.17.0 + * ipfs-core-types bumped from ^0.12.1 to ^0.13.0 + * ipfs-grpc-server bumped from ^0.10.1 to ^0.11.0 + * ipfs-http-gateway bumped from ^0.11.1 to ^0.12.0 + * ipfs-http-server bumped from ^0.13.2 to ^0.14.0 + +### [0.14.2](https://www.github.com/ipfs/js-ipfs/compare/ipfs-daemon-v0.14.1...ipfs-daemon-v0.14.2) (2022-09-21) + + +### Bug Fixes + +* update @multiformats/multiadd to 11.0.0 ([2a830bf](https://www.github.com/ipfs/js-ipfs/commit/2a830bf58a5929fcce51dede871c99f62192fbda)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core bumped from ^0.16.0 to ^0.16.1 + * ipfs-core-types bumped from ^0.12.0 to ^0.12.1 + * ipfs-grpc-server bumped from ^0.10.0 to ^0.10.1 + * ipfs-http-gateway bumped from ^0.11.0 to ^0.11.1 + * ipfs-http-server bumped from ^0.13.1 to ^0.13.2 + +### [0.14.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-daemon-v0.14.0...ipfs-daemon-v0.14.1) (2022-09-16) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-http-server bumped from ^0.13.0 to ^0.13.1 + +## [0.14.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-daemon-v0.13.5...ipfs-daemon-v0.14.0) (2022-09-06) + + +### ⚠ BREAKING CHANGES + +* update to libp2p@0.38.x (#4151) + +### deps + +* update to libp2p@0.38.x ([#4151](https://www.github.com/ipfs/js-ipfs/issues/4151)) ([39dbf70](https://www.github.com/ipfs/js-ipfs/commit/39dbf708ec31b263115e44f420651fa4e056a89e)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core bumped from ^0.15.0 to ^0.16.0 + * ipfs-core-types bumped from ^0.11.0 to ^0.12.0 + * ipfs-grpc-server bumped from ^0.9.0 to ^0.10.0 + * ipfs-http-gateway bumped from ^0.10.0 to ^0.11.0 + * ipfs-http-server bumped from ^0.12.0 to ^0.13.0 + ### [0.13.5](https://www.github.com/ipfs/js-ipfs/compare/ipfs-daemon-v0.13.4...ipfs-daemon-v0.13.5) (2022-06-24) @@ -477,4 +548,4 @@ Co-authored-by: Hugo Dias ## 0.3.2 (2020-12-16) -**Note:** Version bump only for package ipfs-daemon +**Note:** Version bump only for package ipfs-daemon \ No newline at end of file diff --git a/packages/ipfs-daemon/LICENSE b/packages/ipfs-daemon/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-daemon/LICENSE @@ -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 diff --git a/packages/ipfs-daemon/LICENSE-MIT b/packages/ipfs-daemon/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/packages/ipfs-daemon/LICENSE-MIT +++ b/packages/ipfs-daemon/LICENSE-MIT @@ -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. \ No newline at end of file +THE SOFTWARE. diff --git a/packages/ipfs-daemon/README.md b/packages/ipfs-daemon/README.md index f15fbd16a4..bff80307a2 100644 --- a/packages/ipfs-daemon/README.md +++ b/packages/ipfs-daemon/README.md @@ -1,16 +1,24 @@ # ipfs-daemon -> The implementation of the js-IPFS daemon +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -## Table of Contents +> JavaScript implementation of the IPFS specification + +## Table of contents - [Install](#install) -- [Want to hack on IPFS?](#want-to-hack-on-ipfs) - [License](#license) +- [Contribute](#contribute) ## Install -You probably don't need to install this module directly, use it by installing the `ipfs` module: +```console +$ npm i ipfs-daemon +``` ```console $ npm install -g ipfs @@ -18,23 +26,21 @@ $ npm install -g ipfs $ jsipfs daemon ``` -## Want to hack on IPFS? +## License -[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) +Licensed under either of -The IPFS implementation in JavaScript needs your help! There are a few things you can do right now to help out: +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) -Read the [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md) and [JavaScript Contributing Guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md). +## Contribute -- **Check out existing issues** The [issue list](https://github.com/ipfs/js-ipfs/issues) has many that are marked as ['help wanted'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22) or ['difficulty:easy'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Adifficulty%3Aeasy) which make great starting points for development, many of which can be tackled with no prior IPFS knowledge -- **Look at the [IPFS Roadmap](https://github.com/ipfs/roadmap)** This are the high priority items being worked on right now -- **Perform code reviews** More eyes will help - a. speed the project along - b. ensure quality, and - c. reduce possible future bugs. -- **Add tests**. There can never be enough tests. -- **Join the [Weekly Core Implementations Call](https://github.com/ipfs/team-mgmt/issues/992)** it's where everyone discusses what's going on with IPFS and what's next +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). -## License +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. + +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs-daemon/package.json b/packages/ipfs-daemon/package.json index 90564234ba..8bb7bf1a15 100644 --- a/packages/ipfs-daemon/package.json +++ b/packages/ipfs-daemon/package.json @@ -1,23 +1,50 @@ { "name": "ipfs-daemon", - "version": "0.13.5", + "version": "0.15.0", "description": "JavaScript implementation of the IPFS specification", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-daemon#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "IPFS" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-daemon#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ], + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ] + } + }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" } }, @@ -27,10 +54,6 @@ "sourceType": "module" } }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" - }, "scripts": { "lint": "aegir lint", "test": "aegir test -t node", @@ -40,16 +63,16 @@ "build": "aegir build --no-bundle" }, "dependencies": { - "@libp2p/logger": "^1.1.4", - "@libp2p/webrtc-star": "^1.0.6", + "@libp2p/logger": "^2.0.0", + "@libp2p/webrtc-star": "^5.0.2", "@mapbox/node-pre-gyp": "^1.0.5", - "ipfs-core": "^0.15.4", - "ipfs-core-types": "^0.11.1", - "ipfs-grpc-server": "^0.9.4", - "ipfs-http-gateway": "^0.10.4", - "ipfs-http-server": "^0.12.5", + "ipfs-core": "^0.17.0", + "ipfs-core-types": "^0.13.0", + "ipfs-grpc-server": "^0.11.0", + "ipfs-http-gateway": "^0.12.0", + "ipfs-http-server": "^0.14.0", "ipfs-utils": "^9.0.6", - "libp2p": "^0.37.1" + "libp2p": "^0.40.0" }, "devDependencies": { "aegir": "^37.0.11", diff --git a/packages/ipfs-daemon/src/index.js b/packages/ipfs-daemon/src/index.js index 5ccbe80093..fa92fd4357 100644 --- a/packages/ipfs-daemon/src/index.js +++ b/packages/ipfs-daemon/src/index.js @@ -1,5 +1,5 @@ import { logger } from '@libp2p/logger' -import { WebRTCStar } from '@libp2p/webrtc-star' +import { webRTCStar } from '@libp2p/webrtc-star' import { create } from 'ipfs-core' import { HttpApi } from 'ipfs-http-server' import { HttpGateway } from 'ipfs-http-gateway' @@ -97,11 +97,11 @@ async function getLibp2p ({ libp2pOptions }) { if (wrtc || electronWebRTC) { log(`Using ${wrtc ? 'wrtc' : 'electron-webrtc'} for webrtc support`) - const transport = new WebRTCStar({ + const transport = webRTCStar({ wrtc: wrtc ?? electronWebRTC }) - libp2pOptions.transports = [...libp2pOptions.transports ?? [], transport] + libp2pOptions.transports = [...libp2pOptions.transports ?? [], transport.transport] libp2pOptions.peerDiscovery = [...libp2pOptions.peerDiscovery ?? [], transport.discovery] } diff --git a/packages/ipfs-grpc-client/CHANGELOG.md b/packages/ipfs-grpc-client/CHANGELOG.md index d7d12f13e6..b7412886fa 100644 --- a/packages/ipfs-grpc-client/CHANGELOG.md +++ b/packages/ipfs-grpc-client/CHANGELOG.md @@ -4,6 +4,60 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.12.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-grpc-client-v0.11.1...ipfs-grpc-client-v0.12.0) (2022-10-24) + + +### ⚠ BREAKING CHANGES + +* ipfs is now bundled with libp2p@0.40.x which has different config + +### Features + +* upgrade libp2p to 0.40.x ([#4237](https://www.github.com/ipfs/js-ipfs/issues/4237)) ([0cee4a4](https://www.github.com/ipfs/js-ipfs/commit/0cee4a4c55767022584dcbade0b0b9b43326f9c9)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.12.1 to ^0.13.0 + * ipfs-core-utils bumped from ^0.16.1 to ^0.17.0 + +### [0.11.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-grpc-client-v0.11.0...ipfs-grpc-client-v0.11.1) (2022-09-21) + + +### Bug Fixes + +* update @multiformats/multiadd to 11.0.0 ([2a830bf](https://www.github.com/ipfs/js-ipfs/commit/2a830bf58a5929fcce51dede871c99f62192fbda)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.12.0 to ^0.12.1 + * ipfs-core-utils bumped from ^0.16.0 to ^0.16.1 + +## [0.11.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-grpc-client-v0.10.2...ipfs-grpc-client-v0.11.0) (2022-09-06) + + +### ⚠ BREAKING CHANGES + +* update to libp2p@0.38.x (#4151) + +### deps + +* update to libp2p@0.38.x ([#4151](https://www.github.com/ipfs/js-ipfs/issues/4151)) ([39dbf70](https://www.github.com/ipfs/js-ipfs/commit/39dbf708ec31b263115e44f420651fa4e056a89e)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.11.0 to ^0.12.0 + * ipfs-core-utils bumped from ^0.15.0 to ^0.16.0 + * ipfs-grpc-protocol bumped from ^0.6.0 to ^0.7.0 + ### [0.10.2](https://www.github.com/ipfs/js-ipfs/compare/ipfs-grpc-client-v0.10.1...ipfs-grpc-client-v0.10.2) (2022-06-24) @@ -384,4 +438,4 @@ Co-authored-by: achingbrain ### Features * add grpc server and client ([#3403](https://github.com/ipfs/js-ipfs/issues/3403)) ([a9027e0](https://github.com/ipfs/js-ipfs/commit/a9027e0ec0cea9a4f34b4f2f52e09abb35237384)), closes [#2519](https://github.com/ipfs/js-ipfs/issues/2519) [#2838](https://github.com/ipfs/js-ipfs/issues/2838) [#2943](https://github.com/ipfs/js-ipfs/issues/2943) [#2854](https://github.com/ipfs/js-ipfs/issues/2854) [#2864](https://github.com/ipfs/js-ipfs/issues/2864) -* allow passing a http.Agent to the grpc client ([#3477](https://github.com/ipfs/js-ipfs/issues/3477)) ([c5f0bc5](https://github.com/ipfs/js-ipfs/commit/c5f0bc5eeee15369b7d02901035b04184a8608d2)), closes [#3474](https://github.com/ipfs/js-ipfs/issues/3474) +* allow passing a http.Agent to the grpc client ([#3477](https://github.com/ipfs/js-ipfs/issues/3477)) ([c5f0bc5](https://github.com/ipfs/js-ipfs/commit/c5f0bc5eeee15369b7d02901035b04184a8608d2)), closes [#3474](https://github.com/ipfs/js-ipfs/issues/3474) \ No newline at end of file diff --git a/packages/ipfs-grpc-client/LICENSE b/packages/ipfs-grpc-client/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-grpc-client/LICENSE @@ -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 diff --git a/packages/ipfs-grpc-client/LICENSE-APACHE b/packages/ipfs-grpc-client/LICENSE-APACHE new file mode 100644 index 0000000000..14478a3b60 --- /dev/null +++ b/packages/ipfs-grpc-client/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/ipfs-grpc-client/LICENSE-MIT b/packages/ipfs-grpc-client/LICENSE-MIT new file mode 100644 index 0000000000..72dc60d84b --- /dev/null +++ b/packages/ipfs-grpc-client/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +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. diff --git a/packages/ipfs-grpc-client/README.md b/packages/ipfs-grpc-client/README.md index 6ba15bac9a..dc0af12833 100644 --- a/packages/ipfs-grpc-client/README.md +++ b/packages/ipfs-grpc-client/README.md @@ -1,6 +1,31 @@ -# ipfs-grpc-client +# ipfs-grpc-client -> A client for the [ipfs-grpc-server][] module +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) + +> A client library for the IPFS gRPC API + +## Table of contents + +- [Install](#install) +- [Why?](#why) +- [API](#api) + - [`create([options])`](#createoptions) + - [Parameters](#parameters) + - [Options](#options) + - [Returns](#returns) + - [Example](#example) +- [License](#license) +- [Contribute](#contribute) + +## Install + +```console +$ npm i ipfs-grpc-client +``` This module implements part of the [IPFS Core API](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) using gRPC over websockets to achieve the bidirectional streaming necessary to have full duplex streams running in the browser. @@ -14,12 +39,6 @@ This limits what we can do in browsers in terms of the API, for example streamin gPRC over websockets has no such limitations so allows us to harness the full power of a remote IPFS node in the browser without the need to work around browser behaviour. -## Install - -```console -$ npm install ipfs-grpc-client -``` - ## API ### `create([options])` @@ -32,15 +51,15 @@ None An optional object which may have the following keys: -| Name | Type | Default | Description | -| ---- | ---- | ------- | ----------- | -| url | `Multiaddr` or `string` or `URL` | `undefined` | The address of a [ipfs-grpc-server][] to connect to | +| Name | Type | Default | Description | +| ----- | -------------------------------------------------------------------- | ----------- | ----------------------------------------------------------------- | +| url | `Multiaddr` or `string` or `URL` | `undefined` | The address of a [ipfs-grpc-server][] to connect to | | agent | [http.Agent](https://nodejs.org/api/http.html#http_class_http_agent) | `undefined` | A http.Agent used to control HTTP client behaviour (node.js only) | ### Returns -| Type | Description | -| -------- | -------- | +| Type | Description | +| -------- | ------------------------- | | `object` | An instance of the client | ### Example @@ -55,4 +74,23 @@ const client = create({ const id = await client.id() ``` +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). + +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. + +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) + [ipfs-grpc-server]: https://www.npmjs.com/package/ipfs-grpc-server diff --git a/packages/ipfs-grpc-client/package.json b/packages/ipfs-grpc-client/package.json index d7ecd3d86d..be61046b25 100644 --- a/packages/ipfs-grpc-client/package.json +++ b/packages/ipfs-grpc-client/package.json @@ -1,23 +1,50 @@ { "name": "ipfs-grpc-client", - "version": "0.10.2", + "version": "0.12.0", "description": "A client library for the IPFS gRPC API", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-grpc-client#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "ipfs" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-grpc-client#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ], + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ] + } + }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" } }, @@ -27,14 +54,6 @@ "sourceType": "module" } }, - "browser": { - "./src/grpc/transport.js": "./src/grpc/transport.browser.js", - "./src/grpc/transport.node.js": "./src/grpc/transport.browser.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" - }, "scripts": { "build": "aegir build", "test": "aegir test", @@ -46,31 +65,36 @@ "test:electron-main": "aegir test -t electron-main", "lint": "aegir lint", "clean": "aegir clean", - "dep-check": "aegir dep-check -i aegir -i ipfs-grpc-protocol -i ipfs-core-types" + "dep-check": "aegir dep-check -i aegir -i ipfs-grpc-protocol -i ipfs-core-types -i protobufjs-cli" }, "dependencies": { "@improbable-eng/grpc-web": "^0.15.0", - "@libp2p/logger": "^1.1.4", + "@libp2p/logger": "^2.0.0", "@libp2p/peer-id": "^1.1.10", + "@multiformats/multiaddr": "^11.0.0", "change-case": "^4.1.1", "err-code": "^3.0.1", - "ipfs-core-types": "^0.11.1", - "ipfs-core-utils": "^0.15.1", - "ipfs-grpc-protocol": "^0.6.0", - "ipfs-unixfs": "^6.0.9", - "it-first": "^1.0.4", - "it-pushable": "^2.0.1", - "@multiformats/multiaddr": "^10.0.0", - "multiformats": "^9.5.1", + "ipfs-core-types": "^0.13.0", + "ipfs-core-utils": "^0.17.0", + "ipfs-grpc-protocol": "^0.7.0", + "ipfs-unixfs": "^8.0.0", + "it-first": "^2.0.0", + "it-pushable": "^3.0.0", + "multiformats": "^10.0.0", "p-defer": "^4.0.0", - "protobufjs": "^6.10.2", - "uint8arrays": "^3.0.0", - "wherearewe": "^1.0.0", + "protobufjs": "^7.0.0", + "uint8arrays": "^4.0.2", + "wherearewe": "^2.0.1", "ws": "^8.5.0" }, "devDependencies": { "aegir": "^37.0.11", - "it-all": "^1.0.4", + "it-all": "^2.0.0", + "protobufjs-cli": "^1.0.0", "sinon": "^14.0.0" + }, + "browser": { + "./src/grpc/transport.js": "./src/grpc/transport.browser.js", + "./src/grpc/transport.node.js": "./src/grpc/transport.browser.js" } } diff --git a/packages/ipfs-grpc-client/src/core-api/id.js b/packages/ipfs-grpc-client/src/core-api/id.js index 139c4a574d..3520522213 100644 --- a/packages/ipfs-grpc-client/src/core-api/id.js +++ b/packages/ipfs-grpc-client/src/core-api/id.js @@ -1,7 +1,7 @@ import { withTimeoutOption } from 'ipfs-core-utils/with-timeout-option' import { toHeaders } from '../utils/to-headers.js' import { unaryToPromise } from '../utils/unary-to-promise.js' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' /** * @param {import('@improbable-eng/grpc-web').grpc} grpc @@ -23,7 +23,7 @@ export function grpcId (grpc, service, opts) { return { ...res, - addresses: (res.addresses || []).map((/** @type {string} */ str) => new Multiaddr(str)) + addresses: (res.addresses || []).map((/** @type {string} */ str) => multiaddr(str)) } } diff --git a/packages/ipfs-grpc-client/src/core-api/pubsub/subscribe.js b/packages/ipfs-grpc-client/src/core-api/pubsub/subscribe.js index 64ae7a820d..bbd3d0145f 100644 --- a/packages/ipfs-grpc-client/src/core-api/pubsub/subscribe.js +++ b/packages/ipfs-grpc-client/src/core-api/pubsub/subscribe.js @@ -36,12 +36,25 @@ export function grpcPubsubSubscribe (grpc, service, opts) { deferred.resolve() } else { - /** @type {import('@libp2p/interfaces/pubsub').Message} */ - const msg = { - from: peerIdFromString(result.from), - sequenceNumber: result.sequenceNumber == null ? undefined : BigInt(`0x${uint8ArrayToString(result.sequenceNumber, 'base16')}`), - data: result.data, - topic: result.topic + /** @type {import('@libp2p/interface-pubsub').Message} */ + let msg + + if (result.type === 'signed') { + msg = { + type: 'signed', + from: peerIdFromString(result.from), + sequenceNumber: BigInt(`0x${uint8ArrayToString(result.sequenceNumber, 'base16')}`), + data: result.data, + topic: result.topic, + key: result.key, + signature: result.signature + } + } else { + msg = { + type: 'unsigned', + data: result.data, + topic: result.topic + } } if (typeof handler === 'function') { diff --git a/packages/ipfs-grpc-client/src/core-api/pubsub/subscriptions.js b/packages/ipfs-grpc-client/src/core-api/pubsub/subscriptions.js index 7406f50d44..603552ac59 100644 --- a/packages/ipfs-grpc-client/src/core-api/pubsub/subscriptions.js +++ b/packages/ipfs-grpc-client/src/core-api/pubsub/subscriptions.js @@ -1,6 +1,6 @@ /** - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message * @typedef {import('@libp2p/interfaces/events').EventHandler} Subscription */ diff --git a/packages/ipfs-grpc-client/src/utils/bidi-to-duplex.js b/packages/ipfs-grpc-client/src/utils/bidi-to-duplex.js index 22e4129695..158879abd0 100644 --- a/packages/ipfs-grpc-client/src/utils/bidi-to-duplex.js +++ b/packages/ipfs-grpc-client/src/utils/bidi-to-duplex.js @@ -28,8 +28,8 @@ async function sendMessages (service, client, source) { * @returns {{ source: AsyncIterable, sink: import('it-pushable').Pushable }} **/ export function bidiToDuplex (grpc, service, options) { - const source = pushable() - const sink = pushable() + const source = pushable({ objectMode: true }) + const sink = pushable({ objectMode: true }) const client = grpc.client(service, { ...options, diff --git a/packages/ipfs-grpc-client/tsconfig.json b/packages/ipfs-grpc-client/tsconfig.json index c90cd3a743..e74bc8d2b1 100644 --- a/packages/ipfs-grpc-client/tsconfig.json +++ b/packages/ipfs-grpc-client/tsconfig.json @@ -13,6 +13,9 @@ }, { "path": "../ipfs-core-utils" + }, + { + "path": "../ipfs-grpc-protocol" } ] } diff --git a/packages/ipfs-grpc-protocol/CHANGELOG.md b/packages/ipfs-grpc-protocol/CHANGELOG.md index a0b93d122e..b589a006d5 100644 --- a/packages/ipfs-grpc-protocol/CHANGELOG.md +++ b/packages/ipfs-grpc-protocol/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.7.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-grpc-protocol-v0.6.0...ipfs-grpc-protocol-v0.7.0) (2022-09-06) + + +### ⚠ BREAKING CHANGES + +* update to libp2p@0.38.x (#4151) + +### deps + +* update to libp2p@0.38.x ([#4151](https://www.github.com/ipfs/js-ipfs/issues/4151)) ([39dbf70](https://www.github.com/ipfs/js-ipfs/commit/39dbf708ec31b263115e44f420651fa4e056a89e)) + ## [0.6.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-grpc-protocol-v0.5.5...ipfs-grpc-protocol-v0.6.0) (2022-05-27) diff --git a/packages/ipfs-grpc-protocol/LICENSE b/packages/ipfs-grpc-protocol/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-grpc-protocol/LICENSE @@ -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 diff --git a/packages/ipfs-grpc-protocol/LICENSE-APACHE b/packages/ipfs-grpc-protocol/LICENSE-APACHE new file mode 100644 index 0000000000..14478a3b60 --- /dev/null +++ b/packages/ipfs-grpc-protocol/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/ipfs-grpc-protocol/LICENSE-MIT b/packages/ipfs-grpc-protocol/LICENSE-MIT new file mode 100644 index 0000000000..72dc60d84b --- /dev/null +++ b/packages/ipfs-grpc-protocol/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +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. diff --git a/packages/ipfs-grpc-protocol/README.md b/packages/ipfs-grpc-protocol/README.md index 75e7e478de..cb1a259a93 100644 --- a/packages/ipfs-grpc-protocol/README.md +++ b/packages/ipfs-grpc-protocol/README.md @@ -1,3 +1,40 @@ -# ipfs-grpc-protocol +# ipfs-grpc-protocol -Contains `.proto` files that define the IPFS gRPC interface. +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) + +> Protobuf definitions for the IPFS gRPC API + +## Table of contents + +- [Install](#install) +- [License](#license) +- [Contribute](#contribute) + +## Install + +```console +$ npm i ipfs-grpc-protocol +``` + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). + +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. + +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs-grpc-protocol/package.json b/packages/ipfs-grpc-protocol/package.json index a7ee626678..2da554a4c4 100644 --- a/packages/ipfs-grpc-protocol/package.json +++ b/packages/ipfs-grpc-protocol/package.json @@ -1,35 +1,58 @@ { "name": "ipfs-grpc-protocol", - "version": "0.6.0", + "version": "0.7.0", "description": "Protobuf definitions for the IPFS gRPC API", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-grpc-protocol#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "ipfs" ], + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ], + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ] + } + }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - } - }, "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" } }, - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-grpc-protocol#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } }, "scripts": { "clean": "aegir clean", @@ -39,6 +62,7 @@ "devDependencies": { "aegir": "^37.0.11", "mkdirp": "^1.0.4", - "protobufjs": "^6.10.2" + "protobufjs": "^7.0.0", + "protobufjs-cli": "^1.0.0" } } diff --git a/packages/ipfs-grpc-protocol/src/index.js b/packages/ipfs-grpc-protocol/src/index.js index 1886e5932c..5207bbfc9a 100644 --- a/packages/ipfs-grpc-protocol/src/index.js +++ b/packages/ipfs-grpc-protocol/src/index.js @@ -120,6 +120,18 @@ export default { topic: { type: 'string', id: 5 + }, + key: { + type: 'bytes', + id: 6 + }, + signature: { + type: 'bytes', + id: 7 + }, + type: { + type: 'string', + id: 8 } } }, diff --git a/packages/ipfs-grpc-protocol/src/pubsub.proto b/packages/ipfs-grpc-protocol/src/pubsub.proto index 438189ae63..5968aebdcc 100644 --- a/packages/ipfs-grpc-protocol/src/pubsub.proto +++ b/packages/ipfs-grpc-protocol/src/pubsub.proto @@ -19,6 +19,9 @@ message SubscribeResponse { bytes sequenceNumber = 3; bytes data = 4; string topic = 5; + bytes key = 6; + bytes signature = 7; + string type = 8; } message UnSubscribeRequest { diff --git a/packages/ipfs-grpc-server/CHANGELOG.md b/packages/ipfs-grpc-server/CHANGELOG.md index 4f27d05fdc..b2d30683e7 100644 --- a/packages/ipfs-grpc-server/CHANGELOG.md +++ b/packages/ipfs-grpc-server/CHANGELOG.md @@ -4,6 +4,68 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.11.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-grpc-server-v0.10.1...ipfs-grpc-server-v0.11.0) (2022-10-24) + + +### ⚠ BREAKING CHANGES + +* ipfs is now bundled with libp2p@0.40.x which has different config + +### Features + +* upgrade libp2p to 0.40.x ([#4237](https://www.github.com/ipfs/js-ipfs/issues/4237)) ([0cee4a4](https://www.github.com/ipfs/js-ipfs/commit/0cee4a4c55767022584dcbade0b0b9b43326f9c9)) + + +### Bug Fixes + +* replace slice with subarray for increased performance ([#4210](https://www.github.com/ipfs/js-ipfs/issues/4210)) ([dfc43d4](https://www.github.com/ipfs/js-ipfs/commit/dfc43d4e9be67fdf25553677f469379d966ff806)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.12.1 to ^0.13.0 + * devDependencies + * ipfs-core bumped from ^0.16.1 to ^0.17.0 + +### [0.10.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-grpc-server-v0.10.0...ipfs-grpc-server-v0.10.1) (2022-09-21) + + +### Bug Fixes + +* update @multiformats/multiadd to 11.0.0 ([2a830bf](https://www.github.com/ipfs/js-ipfs/commit/2a830bf58a5929fcce51dede871c99f62192fbda)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.12.0 to ^0.12.1 + * devDependencies + * ipfs-core bumped from ^0.16.0 to ^0.16.1 + +## [0.10.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-grpc-server-v0.9.4...ipfs-grpc-server-v0.10.0) (2022-09-06) + + +### ⚠ BREAKING CHANGES + +* update to libp2p@0.38.x (#4151) + +### deps + +* update to libp2p@0.38.x ([#4151](https://www.github.com/ipfs/js-ipfs/issues/4151)) ([39dbf70](https://www.github.com/ipfs/js-ipfs/commit/39dbf708ec31b263115e44f420651fa4e056a89e)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.11.0 to ^0.12.0 + * ipfs-grpc-protocol bumped from ^0.6.0 to ^0.7.0 + * devDependencies + * ipfs-core bumped from ^0.15.0 to ^0.16.0 + ### [0.9.4](https://www.github.com/ipfs/js-ipfs/compare/ipfs-grpc-server-v0.9.3...ipfs-grpc-server-v0.9.4) (2022-06-24) @@ -413,4 +475,4 @@ Co-authored-by: achingbrain ### Features -* add grpc server and client ([#3403](https://github.com/ipfs/js-ipfs/issues/3403)) ([a9027e0](https://github.com/ipfs/js-ipfs/commit/a9027e0ec0cea9a4f34b4f2f52e09abb35237384)), closes [#2519](https://github.com/ipfs/js-ipfs/issues/2519) [#2838](https://github.com/ipfs/js-ipfs/issues/2838) [#2943](https://github.com/ipfs/js-ipfs/issues/2943) [#2854](https://github.com/ipfs/js-ipfs/issues/2854) [#2864](https://github.com/ipfs/js-ipfs/issues/2864) +* add grpc server and client ([#3403](https://github.com/ipfs/js-ipfs/issues/3403)) ([a9027e0](https://github.com/ipfs/js-ipfs/commit/a9027e0ec0cea9a4f34b4f2f52e09abb35237384)), closes [#2519](https://github.com/ipfs/js-ipfs/issues/2519) [#2838](https://github.com/ipfs/js-ipfs/issues/2838) [#2943](https://github.com/ipfs/js-ipfs/issues/2943) [#2854](https://github.com/ipfs/js-ipfs/issues/2854) [#2864](https://github.com/ipfs/js-ipfs/issues/2864) \ No newline at end of file diff --git a/packages/ipfs-grpc-server/LICENSE b/packages/ipfs-grpc-server/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-grpc-server/LICENSE @@ -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 diff --git a/packages/ipfs-grpc-server/LICENSE-APACHE b/packages/ipfs-grpc-server/LICENSE-APACHE new file mode 100644 index 0000000000..14478a3b60 --- /dev/null +++ b/packages/ipfs-grpc-server/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/ipfs-grpc-server/LICENSE-MIT b/packages/ipfs-grpc-server/LICENSE-MIT new file mode 100644 index 0000000000..72dc60d84b --- /dev/null +++ b/packages/ipfs-grpc-server/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +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. diff --git a/packages/ipfs-grpc-server/README.md b/packages/ipfs-grpc-server/README.md index d2439f2f5c..8cf92e355b 100644 --- a/packages/ipfs-grpc-server/README.md +++ b/packages/ipfs-grpc-server/README.md @@ -1,6 +1,38 @@ -# ipfs-grpc-server - -> A gRPC server that runs over a websocket +# ipfs-grpc-server + +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) + +> A server library for the IPFS gRPC API + +## Table of contents + +- [Install](#install) +- [Why?](#why) +- [Protocol](#protocol) + - [1. Metadata](#1-metadata) + - [2. Messages](#2-messages) + - [Signal](#signal) + - [Header](#header) + - [Message data](#message-data) + - [Trailer](#trailer) +- [Handlers](#handlers) + - [Metadata](#metadata) + - [Unary](#unary) + - [Server streaming](#server-streaming) + - [Client streaming](#client-streaming) + - [Bidirectional streaming](#bidirectional-streaming) +- [License](#license) +- [Contribute](#contribute) + +## Install + +```console +$ npm i ipfs-grpc-server +``` ## Why? @@ -46,30 +78,30 @@ One ore more messages will be sent. Messages are sent as a single websocket mes Every message sent to or received from the server will have the following format: -| byte index | Notes | -|---|---| -| 0 | Signal | -| 1-5 | Header | -| n1-n2 | Message data | -| n3-n3+5 | Trailer +| byte index | Notes | +| ---------- | ------------ | +| 0 | Signal | +| 1-5 | Header | +| n1-n2 | Message data | +| n3-n3+5 | Trailer | #### Signal A one-byte field. -| Value | Meaning | -|---|---| -| 0 | START_SEND: Further messages will be sent as part of this context | -| 1 | FINISH_SEND: This is the final message, no further data will be sent | +| Value | Meaning | +| ----- | --------------------------------------------------------------------- | +| 0 | START\_SEND: Further messages will be sent as part of this context | +| 1 | FINISH\_SEND: This is the final message, no further data will be sent | #### Header A five-byte field that contains one byte signifying if it's a Header or a Trailer and four bytes that contain the length of the following data. -| byte index | Meaning | -|--------------|---| -| 0 | 0: This is a header, 128: This is a footer | -| 1-4 | An unsigned big-endian 32-bit integer that specifies the length of the message | +| byte index | Meaning | +| ---------- | ------------------------------------------------------------------------------ | +| 0 | 0: This is a header, 128: This is a footer | +| 1-4 | An unsigned big-endian 32-bit integer that specifies the length of the message | #### Message data @@ -79,10 +111,10 @@ A protocol buffer message, the length of which is defined in the header A five-byte field that contains one byte signifying if it's a Header or a Trailer and four bytes that contain the length of the following data. -| byte index | Meaning | -|--------------|---| -| 0 | 0: This is a header, 128: This is a footer | -| 1-4 | A big-endian 32-bit integer that specifies the length of the trailer | +| byte index | Meaning | +| ---------- | -------------------------------------------------------------------- | +| 0 | 0: This is a header, 128: This is a footer | +| 1-4 | A big-endian 32-bit integer that specifies the length of the trailer | The trailer contains [HTTP headers][] as a utf8 encoded string in the same way as invocation metadata. @@ -177,6 +209,27 @@ export function grpcFunction (ipfs, options = {}) { } ``` +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). + +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. + +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) + [HTTP headers]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers + [it-pushable]: https://www.npmjs.com/package/it-pushable + [AsyncIterator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator diff --git a/packages/ipfs-grpc-server/package.json b/packages/ipfs-grpc-server/package.json index 5556a176f5..b1ae97ea46 100644 --- a/packages/ipfs-grpc-server/package.json +++ b/packages/ipfs-grpc-server/package.json @@ -1,23 +1,50 @@ { "name": "ipfs-grpc-server", - "version": "0.9.4", + "version": "0.11.0", "description": "A server library for the IPFS gRPC API", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-grpc-server#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "ipfs" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-grpc-server#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ], + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ] + } + }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" } }, @@ -27,10 +54,6 @@ "sourceType": "module" } }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" - }, "scripts": { "lint": "aegir lint", "test": "aegir test -t node", @@ -41,29 +64,29 @@ }, "dependencies": { "@grpc/grpc-js": "^1.1.8", - "@libp2p/logger": "^1.1.4", + "@libp2p/logger": "^2.0.0", "@libp2p/peer-id": "^1.1.10", + "@multiformats/multiaddr": "^11.0.0", "change-case": "^4.1.1", "coercer": "^1.1.2", - "ipfs-core-types": "^0.11.1", - "ipfs-grpc-protocol": "^0.6.0", - "it-first": "^1.0.4", - "it-map": "^1.0.4", - "it-peekable": "^1.0.2", + "ipfs-core-types": "^0.13.0", + "ipfs-grpc-protocol": "^0.7.0", + "it-first": "^2.0.0", + "it-map": "^2.0.0", + "it-peekable": "^2.0.0", "it-pipe": "^2.0.3", - "it-pushable": "^2.0.1", - "@multiformats/multiaddr": "^10.0.0", - "nanoid": "^3.1.23", - "protobufjs": "^6.10.2", - "uint8arrays": "^3.0.0", + "it-pushable": "^3.0.0", + "nanoid": "^4.0.0", + "protobufjs": "^7.0.0", + "uint8arrays": "^4.0.2", "ws": "^8.5.0" }, "devDependencies": { "@types/ws": "^8.5.3", "aegir": "^37.0.11", - "ipfs-core": "^0.15.4", - "it-all": "^1.0.4", - "it-drain": "^1.0.3", + "ipfs-core": "^0.17.0", + "it-all": "^2.0.0", + "it-drain": "^2.0.0", "sinon": "^14.0.0" } } diff --git a/packages/ipfs-grpc-server/src/endpoints/add.js b/packages/ipfs-grpc-server/src/endpoints/add.js index cfbc72e61b..fcfe9e99b6 100644 --- a/packages/ipfs-grpc-server/src/endpoints/add.js +++ b/packages/ipfs-grpc-server/src/endpoints/add.js @@ -26,7 +26,7 @@ export function grpcAdd (ipfs, options = {}) { await pipe( async function * toInput () { - const fileInputStream = pushable() + const fileInputStream = pushable({ objectMode: true }) setTimeout(async () => { const streams = [] diff --git a/packages/ipfs-grpc-server/src/endpoints/pubsub/subscribe.js b/packages/ipfs-grpc-server/src/endpoints/pubsub/subscribe.js index 8ba85d0155..785dcb883f 100644 --- a/packages/ipfs-grpc-server/src/endpoints/pubsub/subscribe.js +++ b/packages/ipfs-grpc-server/src/endpoints/pubsub/subscribe.js @@ -3,7 +3,7 @@ import { nanoid } from 'nanoid' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' /** - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message */ /** @@ -27,7 +27,7 @@ export function grpcPubsubSubscribe (ipfs, options = {}) { onMessage: (message) => { let sequenceNumber - if (message.sequenceNumber != null) { + if (message.type === 'signed' && message.sequenceNumber != null) { let numberString = message.sequenceNumber.toString(16) if (numberString.length % 2 !== 0) { diff --git a/packages/ipfs-grpc-server/src/endpoints/pubsub/subscriptions.js b/packages/ipfs-grpc-server/src/endpoints/pubsub/subscriptions.js index 3b2a2a9559..4636ba4025 100644 --- a/packages/ipfs-grpc-server/src/endpoints/pubsub/subscriptions.js +++ b/packages/ipfs-grpc-server/src/endpoints/pubsub/subscriptions.js @@ -1,5 +1,5 @@ /** - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message * @typedef {object} Subscription * @property {import('@libp2p/interfaces/events').EventHandler} onMessage * @property {() => void} onUnsubscribe diff --git a/packages/ipfs-grpc-server/src/utils/web-socket-message-channel.js b/packages/ipfs-grpc-server/src/utils/web-socket-message-channel.js index d2ca764e96..e2da3046c2 100644 --- a/packages/ipfs-grpc-server/src/utils/web-socket-message-channel.js +++ b/packages/ipfs-grpc-server/src/utils/web-socket-message-channel.js @@ -51,8 +51,8 @@ export class WebSocketMessageChannel { serialize: (message) => Buffer.from([]) } - this.source = pushable() - this.sink = pushable() + this.source = pushable({ objectMode: true }) + this.sink = pushable({ objectMode: true }) ws.on('message', (buf) => { if (!(buf instanceof Uint8Array)) { @@ -77,7 +77,7 @@ export class WebSocketMessageChannel { return } - const header = buf.slice(offset, HEADER_SIZE + offset) + const header = buf.subarray(offset, HEADER_SIZE + offset) const length = header.readUInt32BE(1) offset += HEADER_SIZE @@ -85,7 +85,7 @@ export class WebSocketMessageChannel { return } - const message = buf.slice(offset, offset + length) + const message = buf.subarray(offset, offset + length) const deserialized = this.handler.deserialize(message) this.source.push(deserialized) }) diff --git a/packages/ipfs-grpc-server/src/utils/web-socket-server.js b/packages/ipfs-grpc-server/src/utils/web-socket-server.js index 6d475117ce..a3deb7366a 100644 --- a/packages/ipfs-grpc-server/src/utils/web-socket-server.js +++ b/packages/ipfs-grpc-server/src/utils/web-socket-server.js @@ -5,7 +5,7 @@ import { logger } from '@libp2p/logger' // @ts-expect-error - no types import coerce from 'coercer' import { camelCase } from 'change-case' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' const log = logger('ipfs:grpc-server:utils:web-socket-server') @@ -41,7 +41,7 @@ class Messages extends EventEmitter { this.info = { uri: '', - ma: new Multiaddr('/ip4/127.0.0.1/tcp/0/ws') + ma: multiaddr('/ip4/127.0.0.1/tcp/0/ws') } wss.on('connection', (ws, request) => { @@ -87,12 +87,12 @@ class Messages extends EventEmitter { // which is not how this server runs: https://nodejs.org/dist/latest-v15.x/docs/api/net.html#net_server_address this.info = { uri: info, - ma: new Multiaddr(info) + ma: multiaddr(info) } } else { this.info = { uri: `http://${info.address}:${info.port}`, - ma: new Multiaddr(`/ip4/${info.address}/tcp/${info.port}/ws`) + ma: multiaddr(`/ip4/${info.address}/tcp/${info.port}/ws`) } } diff --git a/packages/ipfs-grpc-server/test/utils/channel.js b/packages/ipfs-grpc-server/test/utils/channel.js index 95463b2006..8ce3bf7d18 100644 --- a/packages/ipfs-grpc-server/test/utils/channel.js +++ b/packages/ipfs-grpc-server/test/utils/channel.js @@ -3,10 +3,10 @@ import { pushable } from 'it-pushable' class MessageChannel { constructor () { - this.source = pushable() - this.sink = pushable() + this.source = pushable({ objectMode: true }) + this.sink = pushable({ objectMode: true }) - this.clientSink = pushable() + this.clientSink = pushable({ objectMode: true }) } sendMetadata (metadata) { diff --git a/packages/ipfs-grpc-server/tsconfig.json b/packages/ipfs-grpc-server/tsconfig.json index 5b011ba049..1adae043f7 100644 --- a/packages/ipfs-grpc-server/tsconfig.json +++ b/packages/ipfs-grpc-server/tsconfig.json @@ -8,8 +8,14 @@ "src" ], "references": [ + { + "path": "../ipfs-core" + }, { "path": "../ipfs-core-types" + }, + { + "path": "../ipfs-grpc-protocol" } ] } diff --git a/packages/ipfs-http-client/CHANGELOG.md b/packages/ipfs-http-client/CHANGELOG.md index 88bfd99268..db033b37cb 100644 --- a/packages/ipfs-http-client/CHANGELOG.md +++ b/packages/ipfs-http-client/CHANGELOG.md @@ -4,6 +4,59 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [59.0.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-http-client-v58.0.1...ipfs-http-client-v59.0.0) (2022-10-24) + + +### ⚠ BREAKING CHANGES + +* ipfs is now bundled with libp2p@0.40.x which has different config + +### Features + +* upgrade libp2p to 0.40.x ([#4237](https://www.github.com/ipfs/js-ipfs/issues/4237)) ([0cee4a4](https://www.github.com/ipfs/js-ipfs/commit/0cee4a4c55767022584dcbade0b0b9b43326f9c9)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.12.1 to ^0.13.0 + * ipfs-core-utils bumped from ^0.16.1 to ^0.17.0 + +### [58.0.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-http-client-v58.0.0...ipfs-http-client-v58.0.1) (2022-09-21) + + +### Bug Fixes + +* update @multiformats/multiadd to 11.0.0 ([2a830bf](https://www.github.com/ipfs/js-ipfs/commit/2a830bf58a5929fcce51dede871c99f62192fbda)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.12.0 to ^0.12.1 + * ipfs-core-utils bumped from ^0.16.0 to ^0.16.1 + +## [58.0.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-http-client-v57.0.3...ipfs-http-client-v58.0.0) (2022-09-06) + + +### ⚠ BREAKING CHANGES + +* update to libp2p@0.38.x (#4151) + +### deps + +* update to libp2p@0.38.x ([#4151](https://www.github.com/ipfs/js-ipfs/issues/4151)) ([39dbf70](https://www.github.com/ipfs/js-ipfs/commit/39dbf708ec31b263115e44f420651fa4e056a89e)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.11.0 to ^0.12.0 + * ipfs-core-utils bumped from ^0.15.0 to ^0.16.0 + ### [57.0.3](https://www.github.com/ipfs/js-ipfs/compare/ipfs-http-client-v57.0.2...ipfs-http-client-v57.0.3) (2022-06-24) @@ -2446,4 +2499,4 @@ Signed-off-by: Alan Shaw ### Bug Fixes -* new fixed aegir ([93ac472](https://github.com/ipfs/js-ipfs-http-client/commit/93ac472)) +* new fixed aegir ([93ac472](https://github.com/ipfs/js-ipfs-http-client/commit/93ac472)) \ No newline at end of file diff --git a/packages/ipfs-http-client/LICENSE b/packages/ipfs-http-client/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-http-client/LICENSE @@ -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 diff --git a/packages/ipfs-http-client/LICENSE-MIT b/packages/ipfs-http-client/LICENSE-MIT index 2b7661ee41..72dc60d84b 100644 --- a/packages/ipfs-http-client/LICENSE-MIT +++ b/packages/ipfs-http-client/LICENSE-MIT @@ -1,7 +1,5 @@ The MIT License (MIT) -Copyright (c) 2016 Protocol Labs, Inc. - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights @@ -9,14 +7,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 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. - +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/packages/ipfs-http-client/README.md b/packages/ipfs-http-client/README.md index 3f5a97697f..0b4d457a45 100644 --- a/packages/ipfs-http-client/README.md +++ b/packages/ipfs-http-client/README.md @@ -1,41 +1,20 @@ -

- IPFS http client lib logo -

- -

The JavaScript HTTP RPC API client library for IPFS implementations.

- -

- - - - -

+# ipfs-http-client -

- - - - -
- - - - - - - -
-

+[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -> A client library for the IPFS HTTP RPC API (`/api/v0/*`), implemented in JavaScript. This client library implements the IPFS [Core API](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) enabling applications to change between an embedded js-ipfs node and any remote IPFS node without having to change the code. In addition, this client library implements a set of utility functions. +> A client library for the IPFS HTTP API -## Table of Contents +## Table of contents +- [Install](#install) - [Getting Started](#getting-started) - - [Install](#install) - [Next Steps](#next-steps) - [Usage](#usage) - - [`create([options])`](#createoptions) + - - [`create([options])`](#createoptions) - [Parameters](#parameters) - [Options](#options) - [Returns](#returns) @@ -54,20 +33,52 @@ - [Importing the module and usage](#importing-the-module-and-usage) - [In a web browser](#in-a-web-browser) - [Custom Headers](#custom-headers) + - [Infura Header](#Infura-header) - [Global Timeouts](#global-timeouts) - [Development](#development) - [Testing](#testing) -- [Contribute](#contribute) - [Historical context](#historical-context) - [License](#license) +- [Contribute](#contribute) -## Getting Started +## Install -We've come a long way, but this project is still in Alpha, lots of development is happening, APIs might change, beware of 🐉.. +```console +$ npm i ipfs-http-client +``` -### Install +

+ IPFS http client lib logo +

-This module uses node.js, and can be installed through npm: +

The JavaScript HTTP RPC API client library for IPFS implementations.

+ +

+ + + + +

+ +

+ + + + +
+ + + + + + + +
+

+ +## Getting Started + +We've come a long way, but this project is still in Alpha, lots of development is happening, APIs might change, beware of 🐉.. ```bash npm install --save ipfs-http-client @@ -77,14 +88,14 @@ Both the Current and Active LTS versions of Node.js are supported. Please see [n ### Next Steps -* Read the [docs](https://github.com/ipfs/js-ipfs/tree/master/docs) -* Look into the [examples](https://github.com/ipfs-examples/js-ipfs-examples) to learn how to spawn an IPFS node in Node.js and in the Browser -* Consult the [Core API docs](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) to see what you can do with an IPFS node -* Visit https://dweb-primer.ipfs.io to learn about IPFS and the concepts that underpin it -* Head over to https://proto.school to take interactive tutorials that cover core IPFS APIs -* Check out https://docs.ipfs.io for tips, how-tos and more -* See https://blog.ipfs.io for news and more -* Need help? Please ask 'How do I?' questions on https://discuss.ipfs.io +- Read the [docs](https://github.com/ipfs/js-ipfs/tree/master/docs) +- Look into the [examples](https://github.com/ipfs-examples/js-ipfs-examples) to learn how to spawn an IPFS node in Node.js and in the Browser +- Consult the [Core API docs](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) to see what you can do with an IPFS node +- Visit to learn about IPFS and the concepts that underpin it +- Head over to to take interactive tutorials that cover core IPFS APIs +- Check out for tips, how-tos and more +- See for news and more +- Need help? Please ask 'How do I?' questions on ## Usage @@ -102,19 +113,19 @@ None Alternatively it can be an object which may have the following keys: -| Name | Type | Default | Description | -| ---- | ---- | ------- | ----------- | -| url | `String` or `URL` or `Multiaddr` | `'http://localhost:5001/api/v0'` | A URL that resolves to a running instance of the IPFS [HTTP RPC API](https://docs.ipfs.io/reference/http/api/) | -| protocol | `String` | `'http'` | The protocol to used (ignored if url is specified) | -| host | `String` | `'localhost'` | The host to used (ignored if url is specified) | -| port | `number` | `5001` | The port to used (ignored if url is specified) | -| path | `String` | `'api/v0'` | The path to used (ignored if url is specified) | -| agent | [http.Agent](https://nodejs.org/api/http.html#http_class_http_agent) | `http.Agent({ keepAlive: true, maxSockets: 6 })` | An `http.Agent` used to control client behaviour (node.js only) | +| Name | Type | Default | Description | +| -------- | -------------------------------------------------------------------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------- | +| url | `String` or `URL` or `Multiaddr` | `'http://localhost:5001/api/v0'` | A URL that resolves to a running instance of the IPFS [HTTP RPC API](https://docs.ipfs.io/reference/http/api/) | +| protocol | `String` | `'http'` | The protocol to used (ignored if url is specified) | +| host | `String` | `'localhost'` | The host to used (ignored if url is specified) | +| port | `number` | `5001` | The port to used (ignored if url is specified) | +| path | `String` | `'api/v0'` | The path to used (ignored if url is specified) | +| agent | [http.Agent](https://nodejs.org/api/http.html#http_class_http_agent) | `http.Agent({ keepAlive: true, maxSockets: 6 })` | An `http.Agent` used to control client behaviour (node.js only) | #### Returns -| Type | Description | -| ---- | ----------- | +| Type | Description | +| -------- | --------------------------------------------------------------------------------------------------------- | | `Object` | An object that conforms to the [IPFS Core API](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) | #### Example @@ -143,10 +154,10 @@ const { cid } = await client.add('Hello world!') ### Additional Options -All core API methods take _additional_ `options` specific to the HTTP API: +All core API methods take *additional* `options` specific to the HTTP API: -* `headers` - An object or [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) instance that can be used to set custom HTTP headers. Note that this option can also be [configured globally](#custom-headers) via the constructor options. -* `searchParams` - An object or [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) instance that can be used to add additional query parameters to the query string sent with each request. +- `headers` - An object or [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) instance that can be used to set custom HTTP headers. Note that this option can also be [configured globally](#custom-headers) via the constructor options. +- `searchParams` - An object or [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) instance that can be used to add additional query parameters to the query string sent with each request. ### Instance Utils @@ -299,9 +310,9 @@ To always request the latest version, use one of the following examples: For maximum security you may also decide to: -* reference a specific version of IPFS API (to prevent unexpected breaking changes when a newer latest version is published) -* [generate a SRI hash](https://www.srihash.org/) of that version and use it to ensure integrity. Learn more also at the [jsdelivr website](https://www.jsdelivr.com/using-sri-with-dynamic-files) -* set the [CORS settings attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes) to make anonymous requests to CDN +- reference a specific version of IPFS API (to prevent unexpected breaking changes when a newer latest version is published) +- [generate a SRI hash](https://www.srihash.org/) of that version and use it to ensure integrity. Learn more also at the [jsdelivr website](https://www.jsdelivr.com/using-sri-with-dynamic-files) +- set the [CORS settings attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes) to make anonymous requests to CDN Example: @@ -340,9 +351,26 @@ const ipfs = create({ }) ``` +### Infura Header + +If you wish to send infura headers with each request made by this library, for example, the Authorization header. You can use the config to do so: + +```js +const auth = + 'Basic ' + Buffer.from(INFURA_ID + ':' + INFURA_SECRET_KEY).toString('base64'); +const client = ipfsClient.create({ + host: 'ipfs.infura.io', + port: 5001, + protocol: 'https', + headers: { + authorization: auth, + }, +}); +``` + ### Global Timeouts -To set a global timeout for _all_ requests pass a value for the `timeout` option: +To set a global timeout for *all* requests pass a value for the `timeout` option: ```js // Timeout after 10 seconds @@ -358,24 +386,25 @@ const ipfs = create({ timeout: '2m' }) We run tests by executing `npm test` in a terminal window. This will run both Node.js and Browser tests, both in Chrome and PhantomJS. To ensure that the module conforms with the [`interface-ipfs-core`](https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core) spec, we run the batch of tests provided by the interface module, which can be found [here](https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core/src). -## Contribute +## Historical context -The js-ipfs-http-client is a work in progress. As such, there's a few things you can do right now to help out: +This module started as a direct mapping from the go-ipfs cli to a JavaScript implementation, although this was useful and familiar to a lot of developers that were coming to IPFS for the first time, it also created some confusion on how to operate the core of IPFS and have access to the full capacity of the protocol. After much consideration, we decided to create `interface-ipfs-core` with the goal of standardizing the interface of a core implementation of IPFS, and keep the utility functions the IPFS community learned to use and love, such as reading files from disk and storing them directly to IPFS. -- **[Check out the existing issues](https://github.com/ipfs/js-ipfs-http-client/issues)**! -- **Perform code reviews**. More eyes will help a) speed the project along b) ensure quality and c) reduce possible future bugs. -- **Add tests**. There can never be enough tests. Note that interface tests exist inside [`interface-ipfs-core`](https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core/src). +## License -**Want to hack on IPFS?** +Licensed under either of -[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) -## Historical context +## Contribute -This module started as a direct mapping from the go-ipfs cli to a JavaScript implementation, although this was useful and familiar to a lot of developers that were coming to IPFS for the first time, it also created some confusion on how to operate the core of IPFS and have access to the full capacity of the protocol. After much consideration, we decided to create `interface-ipfs-core` with the goal of standardizing the interface of a core implementation of IPFS, and keep the utility functions the IPFS community learned to use and love, such as reading files from disk and storing them directly to IPFS. +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). -## License +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. -[MIT](LICENSE) +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fipfs%2Fjs-ipfs-http-client.svg?type=large)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fipfs%2Fjs-ipfs-http-client?ref=badge_large) +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs-http-client/package.json b/packages/ipfs-http-client/package.json index 884466f151..961cd3fb72 100644 --- a/packages/ipfs-http-client/package.json +++ b/packages/ipfs-http-client/package.json @@ -1,22 +1,50 @@ { "name": "ipfs-http-client", - "version": "57.0.3", + "version": "59.0.0", "description": "A client library for the IPFS HTTP API", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-client#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "ipfs" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-client#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ], + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ] + } + }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" } }, @@ -26,17 +54,6 @@ "sourceType": "module" } }, - "browser": { - "ipfs-utils/src/files/glob-source": false, - "go-ipfs": false, - "ipfs-core-utils/src/files/normalise-input": "ipfs-core-utils/src/files/normalise-input/index.browser.js", - "http": false, - "https": false - }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" - }, "scripts": { "build": "aegir build", "test": "aegir test", @@ -50,141 +67,41 @@ "dep-check": "aegir dep-check -i ipfs-core -i ipfs-core-types" }, "dependencies": { - "@ipld/dag-cbor": "^7.0.0", - "@ipld/dag-json": "^8.0.1", - "@ipld/dag-pb": "^2.1.3", - "@libp2p/logger": "^1.1.4", + "@ipld/dag-cbor": "^8.0.0", + "@ipld/dag-json": "^9.0.0", + "@ipld/dag-pb": "^3.0.0", + "@libp2p/logger": "^2.0.0", "@libp2p/peer-id": "^1.1.10", + "@multiformats/multiaddr": "^11.0.0", "any-signal": "^3.0.0", - "dag-jose": "^1.0.0", + "dag-jose": "^3.0.1", "err-code": "^3.0.1", - "ipfs-core-types": "^0.11.1", - "ipfs-core-utils": "^0.15.1", + "ipfs-core-types": "^0.13.0", + "ipfs-core-utils": "^0.17.0", "ipfs-utils": "^9.0.6", - "it-first": "^1.0.6", - "it-last": "^1.0.4", + "it-first": "^2.0.0", + "it-last": "^2.0.0", "merge-options": "^3.0.4", - "@multiformats/multiaddr": "^10.0.0", - "multiformats": "^9.5.1", + "multiformats": "^10.0.0", "parse-duration": "^1.0.0", "stream-to-it": "^0.2.2", - "uint8arrays": "^3.0.0" + "uint8arrays": "^4.0.2" }, "devDependencies": { "aegir": "^37.0.11", "delay": "^5.0.0", - "go-ipfs": "^0.12.1", - "ipfsd-ctl": "^11.0.0", - "it-all": "^1.0.4", - "it-first": "^1.0.4", + "go-ipfs": "^0.12.0", + "ipfsd-ctl": "^12.0.3", + "it-all": "^2.0.0", + "it-first": "^2.0.0", "nock": "^13.0.2", "p-defer": "^4.0.0" }, - "engines": { - "node": ">=15.0.0", - "npm": ">=3.0.0" - }, - "contributors": [ - "Alan Shaw ", - "Alan Shaw ", - "Alex Mingoia ", - "Alex Potsides ", - "Antonio Tenorio-Fornés ", - "Bruno Barbieri ", - "Clemo ", - "Connor Keenan ", - "Daniel Constantin ", - "Danny ", - "David Braun ", - "David Dias ", - "Dietrich Ayala ", - "Diogo Silva ", - "Dmitriy Ryajov ", - "Dmitry Nikulin ", - "Donatas Stundys ", - "Fil ", - "Filip Š ", - "Francisco Baio Dias ", - "Friedel Ziegelmayer ", - "Gar ", - "Gavin McDermott ", - "Gopalakrishna Palem ", - "Greenkeeper ", - "Haad ", - "Harlan T Wood ", - "Harlan T Wood ", - "Henrique Dias ", - "Holodisc ", - "Hugo Dias ", - "Hugo Dias ", - "JGAntunes ", - "Jacob Heun ", - "James Halliday ", - "Jason Carver ", - "Jason Papakostas ", - "Jeff Downie ", - "Jeromy ", - "Jeromy ", - "Jim Pick ", - "Joe Turgeon ", - "Jonathan ", - "Juan Batiz-Benet ", - "Kevin Wang ", - "Kristoffer Ström ", - "Marcin Rataj ", - "Matt Bell ", - "Matt Ober ", - "Maxime Lathuilière ", - "Michael Bradley ", - "Michael Muré ", - "Michael Muré ", - "Mikeal Rogers ", - "Mitar ", - "Mithgol ", - "Mohamed Abdulaziz ", - "Nitin Patel <31539366+niinpatel@users.noreply.github.com>", - "Nuno Nogueira ", - "Níckolas Goline ", - "Oli Evans ", - "Orie Steele ", - "Paul Cowgill ", - "Pedro Santos ", - "Pedro Santos ", - "Pedro Teixeira ", - "Pete Thomas ", - "Richard Littauer ", - "Richard Schneider ", - "Roman Khafizianov ", - "SeungWon ", - "Stephen Whitmore ", - "Tara Vancil ", - "Teri Chadbourne ", - "Travis Person ", - "Travis Person ", - "Vasco Santos ", - "Vasco Santos ", - "Victor Bjelkholm ", - "Volker Mische ", - "Zhiyuan Lin ", - "dirkmc ", - "dmitriy ryajov ", - "elsehow ", - "ethers ", - "greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com>", - "greenkeeper[bot] ", - "haad ", - "kumavis ", - "leekt216 ", - "nginnever ", - "noah the goodra ", - "phillmac ", - "priecint ", - "samuli ", - "sarthak khandelwal ", - "shunkin ", - "victorbjelkholm ", - "Łukasz Magiera ", - "Łukasz Magiera ", - "Xmader " - ] + "browser": { + "ipfs-utils/src/files/glob-source": false, + "go-ipfs": false, + "ipfs-core-utils/src/files/normalise-input": "ipfs-core-utils/src/files/normalise-input/index.browser.js", + "http": false, + "https": false + } } diff --git a/packages/ipfs-http-client/src/bootstrap/add.js b/packages/ipfs-http-client/src/bootstrap/add.js index 7c07e48d35..ba0816d611 100644 --- a/packages/ipfs-http-client/src/bootstrap/add.js +++ b/packages/ipfs-http-client/src/bootstrap/add.js @@ -1,6 +1,6 @@ import { configure } from '../lib/configure.js' import { toUrlSearchParams } from '../lib/to-url-search-params.js' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' /** * @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions @@ -23,7 +23,7 @@ export const createAdd = configure(api => { const { Peers } = await res.json() - return { Peers: Peers.map((/** @type {string} */ ma) => new Multiaddr(ma)) } + return { Peers: Peers.map((/** @type {string} */ ma) => multiaddr(ma)) } } return add diff --git a/packages/ipfs-http-client/src/bootstrap/clear.js b/packages/ipfs-http-client/src/bootstrap/clear.js index e029343caf..b9cf0cbd01 100644 --- a/packages/ipfs-http-client/src/bootstrap/clear.js +++ b/packages/ipfs-http-client/src/bootstrap/clear.js @@ -1,6 +1,6 @@ import { configure } from '../lib/configure.js' import { toUrlSearchParams } from '../lib/to-url-search-params.js' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' /** * @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions @@ -23,7 +23,7 @@ export const createClear = configure(api => { const { Peers } = await res.json() - return { Peers: Peers.map((/** @type {string} */ ma) => new Multiaddr(ma)) } + return { Peers: Peers.map((/** @type {string} */ ma) => multiaddr(ma)) } } return clear diff --git a/packages/ipfs-http-client/src/bootstrap/list.js b/packages/ipfs-http-client/src/bootstrap/list.js index 79be9211f5..429c1994d0 100644 --- a/packages/ipfs-http-client/src/bootstrap/list.js +++ b/packages/ipfs-http-client/src/bootstrap/list.js @@ -1,6 +1,6 @@ import { configure } from '../lib/configure.js' import { toUrlSearchParams } from '../lib/to-url-search-params.js' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' /** * @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions @@ -20,7 +20,7 @@ export const createList = configure(api => { const { Peers } = await res.json() - return { Peers: Peers.map((/** @type {string} */ ma) => new Multiaddr(ma)) } + return { Peers: Peers.map((/** @type {string} */ ma) => multiaddr(ma)) } } return list diff --git a/packages/ipfs-http-client/src/bootstrap/reset.js b/packages/ipfs-http-client/src/bootstrap/reset.js index 30ac170330..c2e9c381cf 100644 --- a/packages/ipfs-http-client/src/bootstrap/reset.js +++ b/packages/ipfs-http-client/src/bootstrap/reset.js @@ -1,6 +1,6 @@ import { configure } from '../lib/configure.js' import { toUrlSearchParams } from '../lib/to-url-search-params.js' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' /** * @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions @@ -23,7 +23,7 @@ export const createReset = configure(api => { const { Peers } = await res.json() - return { Peers: Peers.map((/** @type {string} */ ma) => new Multiaddr(ma)) } + return { Peers: Peers.map((/** @type {string} */ ma) => multiaddr(ma)) } } return reset diff --git a/packages/ipfs-http-client/src/bootstrap/rm.js b/packages/ipfs-http-client/src/bootstrap/rm.js index d84b23d3dd..195f6a4c5e 100644 --- a/packages/ipfs-http-client/src/bootstrap/rm.js +++ b/packages/ipfs-http-client/src/bootstrap/rm.js @@ -1,6 +1,6 @@ import { configure } from '../lib/configure.js' import { toUrlSearchParams } from '../lib/to-url-search-params.js' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' /** * @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions @@ -23,7 +23,7 @@ export const createRm = configure(api => { const { Peers } = await res.json() - return { Peers: Peers.map((/** @type {string} */ ma) => new Multiaddr(ma)) } + return { Peers: Peers.map((/** @type {string} */ ma) => multiaddr(ma)) } } return rm diff --git a/packages/ipfs-http-client/src/dht/map-event.js b/packages/ipfs-http-client/src/dht/map-event.js index 7a8777759a..138b06f0c5 100644 --- a/packages/ipfs-http-client/src/dht/map-event.js +++ b/packages/ipfs-http-client/src/dht/map-event.js @@ -9,11 +9,12 @@ import { AddingPeer, DialingPeer } from './response-types.js' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' import { peerIdFromString } from '@libp2p/peer-id' /** - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId + * @typedef {import('@multiformats/multiaddr').Multiaddr} Multiaddr */ /** @@ -37,8 +38,8 @@ export const mapEvent = (event) => { messageType: 0, // TODO: how to infer this from the go-ipfs response messageName: 'PUT_VALUE', - closer: (event.Responses || []).map(({ ID, Addrs }) => ({ id: peerIdFromString(ID), multiaddrs: Addrs.map(addr => new Multiaddr(addr)), protocols: [] })), - providers: (event.Responses || []).map(({ ID, Addrs }) => ({ id: peerIdFromString(ID), multiaddrs: Addrs.map(addr => new Multiaddr(addr)), protocols: [] })) + closer: (event.Responses || []).map(({ ID, Addrs }) => ({ id: peerIdFromString(ID), multiaddrs: Addrs.map(addr => multiaddr(addr)), protocols: [] })), + providers: (event.Responses || []).map(({ ID, Addrs }) => ({ id: peerIdFromString(ID), multiaddrs: Addrs.map(addr => multiaddr(addr)), protocols: [] })) // TODO: how to infer this from the go-ipfs response // record: ??? } @@ -46,7 +47,7 @@ export const mapEvent = (event) => { if (event.Type === FinalPeer) { // dht.query ends with a FinalPeer event with no Responses - /** @type {import('@libp2p/interfaces/peer-info').PeerInfo} */ + /** @type {import('@libp2p/interface-peer-info').PeerInfo} */ let peer = { // @ts-expect-error go-ipfs does not return this id: event.ID ?? peerIdFromString(event.ID), @@ -59,7 +60,7 @@ export const mapEvent = (event) => { // dht.findPeer has the result in the Responses field peer = { id: peerIdFromString(event.Responses[0].ID), - multiaddrs: event.Responses[0].Addrs.map(addr => new Multiaddr(addr)), + multiaddrs: event.Responses[0].Addrs.map(addr => multiaddr(addr)), protocols: [] } } @@ -83,7 +84,7 @@ export const mapEvent = (event) => { return { name: 'PROVIDER', type: event.Type, - providers: event.Responses.map(({ ID, Addrs }) => ({ id: peerIdFromString(ID), multiaddrs: Addrs.map(addr => new Multiaddr(addr)), protocols: [] })) + providers: event.Responses.map(({ ID, Addrs }) => ({ id: peerIdFromString(ID), multiaddrs: Addrs.map(addr => multiaddr(addr)), protocols: [] })) } } diff --git a/packages/ipfs-http-client/src/id.js b/packages/ipfs-http-client/src/id.js index 00375d710e..05182af07c 100644 --- a/packages/ipfs-http-client/src/id.js +++ b/packages/ipfs-http-client/src/id.js @@ -1,5 +1,5 @@ import { objectToCamel } from './lib/object-to-camel.js' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' import { configure } from './lib/configure.js' import { toUrlSearchParams } from './lib/to-url-search-params.js' import { peerIdFromString } from '@libp2p/peer-id' @@ -31,7 +31,7 @@ export const createId = configure(api => { output.id = peerIdFromString(output.id) if (output.addresses) { - output.addresses = output.addresses.map((/** @type {string} */ ma) => new Multiaddr(ma)) + output.addresses = output.addresses.map((/** @type {string} */ ma) => multiaddr(ma)) } // @ts-expect-error server output is not typed diff --git a/packages/ipfs-http-client/src/index.js b/packages/ipfs-http-client/src/index.js index 2bc2340e71..6ed01a8ce5 100644 --- a/packages/ipfs-http-client/src/index.js +++ b/packages/ipfs-http-client/src/index.js @@ -148,6 +148,6 @@ export function create (options = {}) { } export { CID } from 'multiformats/cid' -export { Multiaddr as multiaddr } from '@multiformats/multiaddr' +export { multiaddr } from '@multiformats/multiaddr' export { default as urlSource } from 'ipfs-utils/src/files/url-source.js' export const globSource = globSourceImport diff --git a/packages/ipfs-http-client/src/lib/core.js b/packages/ipfs-http-client/src/lib/core.js index 326fcbf6e3..cc7590fb35 100644 --- a/packages/ipfs-http-client/src/lib/core.js +++ b/packages/ipfs-http-client/src/lib/core.js @@ -1,7 +1,7 @@ /* eslint-env browser */ -import { Multiaddr } from '@multiformats/multiaddr' +import { isMultiaddr } from '@multiformats/multiaddr' import { isBrowser, isWebWorker, isNode } from 'ipfs-utils/src/env.js' import parseDuration from 'parse-duration' import { logger } from '@libp2p/logger' @@ -20,6 +20,7 @@ const DEFAULT_PORT = isBrowser || isWebWorker ? location.port : '5001' /** * @typedef {import('ipfs-utils/src/types').HTTPOptions} HTTPOptions * @typedef {import('../types').Options} Options + * @typedef {import('@multiformats/multiaddr').Multiaddr} Multiaddr */ /** @@ -32,11 +33,11 @@ const normalizeOptions = (options = {}) => { let opts = {} let agent - if (typeof options === 'string' || Multiaddr.isMultiaddr(options)) { + if (typeof options === 'string' || isMultiaddr(options)) { url = new URL(toUrlString(options)) } else if (options instanceof URL) { url = options - } else if (typeof options.url === 'string' || Multiaddr.isMultiaddr(options.url)) { + } else if (typeof options.url === 'string' || isMultiaddr(options.url)) { url = new URL(toUrlString(options.url)) opts = options } else if (options.url instanceof URL) { diff --git a/packages/ipfs-http-client/src/pubsub/subscribe.js b/packages/ipfs-http-client/src/pubsub/subscribe.js index 8646747a2f..38fd85dce7 100644 --- a/packages/ipfs-http-client/src/pubsub/subscribe.js +++ b/packages/ipfs-http-client/src/pubsub/subscribe.js @@ -7,7 +7,7 @@ const log = logger('ipfs-http-client:pubsub:subscribe') /** * @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message * @typedef {(err: Error, fatal: boolean, msg?: Message) => void} ErrorHandlerFn * @typedef {import('ipfs-core-types/src/pubsub').API} PubsubAPI * @typedef {import('../types').Options} Options @@ -107,12 +107,23 @@ async function readMessages (response, { onMessage, onEnd, onError }) { continue } - onMessage({ - from: peerIdFromString(msg.from), - data: rpcToBytes(msg.data), - sequenceNumber: rpcToBigInt(msg.seqno), - topic: rpcToText(msg.topicIDs[0]) - }) + if (msg.from != null && msg.seqno != null) { + onMessage({ + type: 'signed', + from: peerIdFromString(msg.from), + data: rpcToBytes(msg.data), + sequenceNumber: rpcToBigInt(msg.seqno), + topic: rpcToText(msg.topicIDs[0]), + key: rpcToBytes(msg.key ?? 'u'), + signature: rpcToBytes(msg.signature ?? 'u') + }) + } else { + onMessage({ + type: 'unsigned', + data: rpcToBytes(msg.data), + topic: rpcToText(msg.topicIDs[0]) + }) + } } catch (/** @type {any} */ err) { err.message = `Failed to parse pubsub message: ${err.message}` onError(err, false, msg) // Not fatal diff --git a/packages/ipfs-http-client/src/pubsub/subscription-tracker.js b/packages/ipfs-http-client/src/pubsub/subscription-tracker.js index 3cc0dd5a0c..52bb1db9bf 100644 --- a/packages/ipfs-http-client/src/pubsub/subscription-tracker.js +++ b/packages/ipfs-http-client/src/pubsub/subscription-tracker.js @@ -1,6 +1,6 @@ /** - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message * @typedef {import('@libp2p/interfaces/events').EventHandler} MessageHandlerFn * * @typedef {object} Subscription diff --git a/packages/ipfs-http-client/src/swarm/addrs.js b/packages/ipfs-http-client/src/swarm/addrs.js index 468b6c95e4..530431905e 100644 --- a/packages/ipfs-http-client/src/swarm/addrs.js +++ b/packages/ipfs-http-client/src/swarm/addrs.js @@ -1,4 +1,4 @@ -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' import { configure } from '../lib/configure.js' import { toUrlSearchParams } from '../lib/to-url-search-params.js' import { peerIdFromString } from '@libp2p/peer-id' @@ -24,7 +24,7 @@ export const createAddrs = configure(api => { return Object.keys(Addrs).map(id => ({ id: peerIdFromString(id), - addrs: (Addrs[id] || []).map(a => new Multiaddr(a)) + addrs: (Addrs[id] || []).map(a => multiaddr(a)) })) } return addrs diff --git a/packages/ipfs-http-client/src/swarm/local-addrs.js b/packages/ipfs-http-client/src/swarm/local-addrs.js index aaac2e6278..a0e41a8631 100644 --- a/packages/ipfs-http-client/src/swarm/local-addrs.js +++ b/packages/ipfs-http-client/src/swarm/local-addrs.js @@ -1,4 +1,4 @@ -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' import { configure } from '../lib/configure.js' import { toUrlSearchParams } from '../lib/to-url-search-params.js' @@ -21,7 +21,7 @@ export const createLocalAddrs = configure(api => { /** @type {{ Strings: string[] }} */ const { Strings } = await res.json() - return (Strings || []).map(a => new Multiaddr(a)) + return (Strings || []).map(a => multiaddr(a)) } return localAddrs }) diff --git a/packages/ipfs-http-client/src/swarm/peers.js b/packages/ipfs-http-client/src/swarm/peers.js index 836bfa08c2..482907441c 100644 --- a/packages/ipfs-http-client/src/swarm/peers.js +++ b/packages/ipfs-http-client/src/swarm/peers.js @@ -1,4 +1,4 @@ -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' import { configure } from '../lib/configure.js' import { toUrlSearchParams } from '../lib/to-url-search-params.js' import { peerIdFromString } from '@libp2p/peer-id' @@ -24,7 +24,7 @@ export const createPeers = configure(api => { return (Peers || []).map(peer => { return { - addr: new Multiaddr(peer.Addr), + addr: multiaddr(peer.Addr), peer: peerIdFromString(peer.Peer), muxer: peer.Muxer, latency: peer.Latency, diff --git a/packages/ipfs-http-client/test/constructor.spec.js b/packages/ipfs-http-client/test/constructor.spec.js index 67525804fd..d83549e980 100644 --- a/packages/ipfs-http-client/test/constructor.spec.js +++ b/packages/ipfs-http-client/test/constructor.spec.js @@ -1,6 +1,6 @@ /* eslint-env mocha, browser */ -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' import { factory } from './utils/factory.js' import { create as ipfsClient } from '../src/index.js' @@ -76,7 +76,7 @@ describe('ipfs-http-client constructor tests', () => { it('multiaddr instance', () => { const host = 'ace.place' const port = '1001' - const addr = new Multiaddr(`/dns4/${host}/tcp/${port}`) + const addr = multiaddr(`/dns4/${host}/tcp/${port}`) const ipfs = ipfsClient(addr) expectConfig(ipfs, { host, port }) }) @@ -133,7 +133,7 @@ describe('ipfs-http-client constructor tests', () => { const port = '1001' const protocol = 'http' // default to http if not specified in multiaddr const addr = `/dns4/${host}/tcp/${port}` - const ipfs = ipfsClient({ url: new Multiaddr(addr) }) + const ipfs = ipfsClient({ url: multiaddr(addr) }) expectConfig(ipfs, { host, port, protocol }) }) @@ -142,7 +142,7 @@ describe('ipfs-http-client constructor tests', () => { const port = '1001' const protocol = 'https' const addr = `/dns4/${host}/tcp/${port}/https` - const ipfs = ipfsClient({ url: new Multiaddr(addr) }) + const ipfs = ipfsClient({ url: multiaddr(addr) }) expectConfig(ipfs, { host, port, protocol }) }) diff --git a/packages/ipfs-http-client/test/exports.spec.js b/packages/ipfs-http-client/test/exports.spec.js index 1f9791dd11..2637d251e9 100644 --- a/packages/ipfs-http-client/test/exports.spec.js +++ b/packages/ipfs-http-client/test/exports.spec.js @@ -1,13 +1,13 @@ /* eslint-env mocha, browser */ import { CID } from 'multiformats/cid' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' import * as IpfsHttpClient from '../src/index.js' describe('exports', () => { it('should export the expected types and utilities', () => { expect(IpfsHttpClient.CID).to.equal(CID) - expect(IpfsHttpClient.multiaddr).to.equal(Multiaddr) + expect(IpfsHttpClient.multiaddr).to.equal(multiaddr) }) }) diff --git a/packages/ipfs-http-gateway/CHANGELOG.md b/packages/ipfs-http-gateway/CHANGELOG.md index a92d2650d1..3ca7dff416 100644 --- a/packages/ipfs-http-gateway/CHANGELOG.md +++ b/packages/ipfs-http-gateway/CHANGELOG.md @@ -4,6 +4,64 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.12.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-http-gateway-v0.11.1...ipfs-http-gateway-v0.12.0) (2022-10-24) + + +### ⚠ BREAKING CHANGES + +* ipfs is now bundled with libp2p@0.40.x which has different config + +### Features + +* upgrade libp2p to 0.40.x ([#4237](https://www.github.com/ipfs/js-ipfs/issues/4237)) ([0cee4a4](https://www.github.com/ipfs/js-ipfs/commit/0cee4a4c55767022584dcbade0b0b9b43326f9c9)) + + +### Bug Fixes + +* replace slice with subarray for increased performance ([#4210](https://www.github.com/ipfs/js-ipfs/issues/4210)) ([dfc43d4](https://www.github.com/ipfs/js-ipfs/commit/dfc43d4e9be67fdf25553677f469379d966ff806)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.12.1 to ^0.13.0 + * ipfs-http-response bumped from ^4.0.1 to ^5.0.0 + +### [0.11.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-http-gateway-v0.11.0...ipfs-http-gateway-v0.11.1) (2022-09-21) + + +### Bug Fixes + +* update @multiformats/multiadd to 11.0.0 ([2a830bf](https://www.github.com/ipfs/js-ipfs/commit/2a830bf58a5929fcce51dede871c99f62192fbda)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.12.0 to ^0.12.1 + * ipfs-http-response bumped from ^4.0.0 to ^4.0.1 + +## [0.11.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-http-gateway-v0.10.4...ipfs-http-gateway-v0.11.0) (2022-09-06) + + +### ⚠ BREAKING CHANGES + +* update to libp2p@0.38.x (#4151) + +### deps + +* update to libp2p@0.38.x ([#4151](https://www.github.com/ipfs/js-ipfs/issues/4151)) ([39dbf70](https://www.github.com/ipfs/js-ipfs/commit/39dbf708ec31b263115e44f420651fa4e056a89e)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.11.0 to ^0.12.0 + * ipfs-http-response bumped from ^3.0.0 to ^4.0.0 + ### [0.10.4](https://www.github.com/ipfs/js-ipfs/compare/ipfs-http-gateway-v0.10.3...ipfs-http-gateway-v0.10.4) (2022-06-24) @@ -398,4 +456,4 @@ Co-authored-by: achingbrain ### Features -* type check & generate defs from jsdoc ([#3281](https://github.com/ipfs/js-ipfs/issues/3281)) ([bbcaf34](https://github.com/ipfs/js-ipfs/commit/bbcaf34111251b142273a5675f4754ff68bd9fa0)) +* type check & generate defs from jsdoc ([#3281](https://github.com/ipfs/js-ipfs/issues/3281)) ([bbcaf34](https://github.com/ipfs/js-ipfs/commit/bbcaf34111251b142273a5675f4754ff68bd9fa0)) \ No newline at end of file diff --git a/packages/ipfs-http-gateway/LICENSE b/packages/ipfs-http-gateway/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-http-gateway/LICENSE @@ -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 diff --git a/packages/ipfs-http-gateway/LICENSE-MIT b/packages/ipfs-http-gateway/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/packages/ipfs-http-gateway/LICENSE-MIT +++ b/packages/ipfs-http-gateway/LICENSE-MIT @@ -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. \ No newline at end of file +THE SOFTWARE. diff --git a/packages/ipfs-http-gateway/README.md b/packages/ipfs-http-gateway/README.md index 993805d32e..5d16ba119d 100644 --- a/packages/ipfs-http-gateway/README.md +++ b/packages/ipfs-http-gateway/README.md @@ -1,16 +1,24 @@ # ipfs-http-gateway -> A web server that bridges HTTP to IPFS +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -## Table of Contents +> JavaScript implementation of the IPFS specification + +## Table of contents - [Install](#install) -- [Want to hack on IPFS?](#want-to-hack-on-ipfs) - [License](#license) +- [Contribute](#contribute) ## Install -You probably don't need to install this module directly, use it by installing the `ipfs` module: +```console +$ npm i ipfs-http-gateway +``` ```console $ npm install -g ipfs @@ -19,24 +27,21 @@ $ jsipfs daemon $ curl http://localhost:9090/ipfs/Qmfoo ``` -## Want to hack on IPFS? +## License + +Licensed under either of -[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) -The IPFS implementation in JavaScript needs your help! There are a few things you can do right now to help out: +## Contribute -Read the [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md) and [JavaScript Contributing Guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md). +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). -- **Check out existing issues** The [issue list](https://github.com/ipfs/js-ipfs/issues) has many that are marked as ['help wanted'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22) or ['difficulty:easy'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Adifficulty%3Aeasy) which make great starting points for development, many of which can be tackled with no prior IPFS knowledge -- **Look at the [IPFS Roadmap](https://github.com/ipfs/roadmap)** This are the high priority items being worked on right now -- **Perform code reviews** More eyes will help - a. speed the project along - b. ensure quality, and - c. reduce possible future bugs. -- **Add tests**. There can never be enough tests. -- **Join the [Weekly Core Implementations Call](https://github.com/ipfs/team-mgmt/issues/992)** it's where everyone discusses what's going on with IPFS and what's next +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). -## License +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs-http-gateway/package.json b/packages/ipfs-http-gateway/package.json index 88c522a469..4e7cfae2ca 100644 --- a/packages/ipfs-http-gateway/package.json +++ b/packages/ipfs-http-gateway/package.json @@ -1,16 +1,25 @@ { "name": "ipfs-http-gateway", - "version": "0.10.4", + "version": "0.12.0", "description": "JavaScript implementation of the IPFS specification", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-gateway#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "IPFS" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-gateway#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", "typesVersions": { "*": { "*": [ @@ -28,15 +37,18 @@ } }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" }, "./resources/index": { + "types": "./src/resources/index.d.ts", "import": "./src/resources/index.js" } }, @@ -46,10 +58,6 @@ "sourceType": "module" } }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" - }, "scripts": { "lint": "aegir lint", "test": "aegir test -t node", @@ -62,23 +70,23 @@ "@hapi/ammo": "^5.0.1", "@hapi/boom": "^9.1.0", "@hapi/hapi": "^20.0.0", - "@libp2p/logger": "^1.1.4", + "@libp2p/logger": "^2.0.0", + "@multiformats/uri-to-multiaddr": "^7.0.0", "hapi-pino": "^8.5.0", - "ipfs-core-types": "^0.11.1", - "ipfs-http-response": "^3.0.4", - "is-ipfs": "^6.0.1", - "it-last": "^1.0.4", + "ipfs-core-types": "^0.13.0", + "ipfs-http-response": "^5.0.0", + "is-ipfs": "^7.0.0", + "it-last": "^2.0.0", "it-to-stream": "^1.0.0", "joi": "^17.2.1", - "multiformats": "^9.5.1", - "uint8arrays": "^3.0.0", - "uri-to-multiaddr": "^6.0.0" + "multiformats": "^10.0.0", + "uint8arrays": "^4.0.2" }, "devDependencies": { "@types/hapi-pino": "^8.0.1", "@types/hapi__hapi": "^20.0.5", "aegir": "^37.0.11", - "file-type": "^17.1.1", + "file-type": "^18.0.0", "sinon": "^14.0.0" } } diff --git a/packages/ipfs-http-gateway/src/index.js b/packages/ipfs-http-gateway/src/index.js index 8752646184..c2c432af8a 100644 --- a/packages/ipfs-http-gateway/src/index.js +++ b/packages/ipfs-http-gateway/src/index.js @@ -1,8 +1,7 @@ import Hapi from '@hapi/hapi' import Pino from 'hapi-pino' import { logger, enabled } from '@libp2p/logger' -// @ts-expect-error no types -import toMultiaddr from 'uri-to-multiaddr' +import toMultiaddr from '@multiformats/uri-to-multiaddr' import routes from './routes/index.js' const LOG = 'ipfs:http-gateway' diff --git a/packages/ipfs-http-gateway/src/resources/gateway.js b/packages/ipfs-http-gateway/src/resources/gateway.js index cfd2883c6b..a34183eeb0 100644 --- a/packages/ipfs-http-gateway/src/resources/gateway.js +++ b/packages/ipfs-http-gateway/src/resources/gateway.js @@ -6,7 +6,7 @@ import last from 'it-last' import { CID } from 'multiformats/cid' import { base32 } from 'multiformats/bases/base32' import { resolver, utils } from 'ipfs-http-response' -import isIPFS from 'is-ipfs' +import * as isIPFS from 'is-ipfs' // @ts-expect-error no types import toStream from 'it-to-stream' import * as PathUtils from '../utils/path.js' @@ -132,11 +132,7 @@ export const Gateway = { } const { source, contentType } = await detectContentType(ipfsPath, ipfs.cat(data.cid, catOptions)) - const responseStream = toStream.readable((async function * () { - for await (const chunk of source) { - yield chunk.slice() // Convert BufferList to Buffer - } - })()) + const responseStream = toStream.readable(source) const res = h.response(responseStream).code(rangeResponse ? 206 : 200) diff --git a/packages/ipfs-http-gateway/tsconfig.json b/packages/ipfs-http-gateway/tsconfig.json index 5b011ba049..2d28a2ad20 100644 --- a/packages/ipfs-http-gateway/tsconfig.json +++ b/packages/ipfs-http-gateway/tsconfig.json @@ -10,6 +10,9 @@ "references": [ { "path": "../ipfs-core-types" + }, + { + "path": "../ipfs-http-response" } ] } diff --git a/packages/ipfs-http-response/CHANGELOG.md b/packages/ipfs-http-response/CHANGELOG.md index aaf9abcad3..fbcc75134e 100644 --- a/packages/ipfs-http-response/CHANGELOG.md +++ b/packages/ipfs-http-response/CHANGELOG.md @@ -3,6 +3,61 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.0.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-http-response-v4.0.1...ipfs-http-response-v5.0.0) (2022-10-24) + + +### ⚠ BREAKING CHANGES + +* ipfs is now bundled with libp2p@0.40.x which has different config + +### Features + +* upgrade libp2p to 0.40.x ([#4237](https://www.github.com/ipfs/js-ipfs/issues/4237)) ([0cee4a4](https://www.github.com/ipfs/js-ipfs/commit/0cee4a4c55767022584dcbade0b0b9b43326f9c9)) + + +### Bug Fixes + +* replace slice with subarray for increased performance ([#4210](https://www.github.com/ipfs/js-ipfs/issues/4210)) ([dfc43d4](https://www.github.com/ipfs/js-ipfs/commit/dfc43d4e9be67fdf25553677f469379d966ff806)) + + +### Dependencies + +* The following workspace dependencies were updated + * devDependencies + * ipfs-core bumped from ^0.16.1 to ^0.17.0 + +### [4.0.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-http-response-v4.0.0...ipfs-http-response-v4.0.1) (2022-09-21) + + +### Bug Fixes + +* update @multiformats/multiadd to 11.0.0 ([2a830bf](https://www.github.com/ipfs/js-ipfs/commit/2a830bf58a5929fcce51dede871c99f62192fbda)) + + +### Dependencies + +* The following workspace dependencies were updated + * devDependencies + * ipfs-core bumped from ^0.16.0 to ^0.16.1 + +## [4.0.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-http-response-v3.0.4...ipfs-http-response-v4.0.0) (2022-09-06) + + +### ⚠ BREAKING CHANGES + +* update to libp2p@0.38.x (#4151) + +### deps + +* update to libp2p@0.38.x ([#4151](https://www.github.com/ipfs/js-ipfs/issues/4151)) ([39dbf70](https://www.github.com/ipfs/js-ipfs/commit/39dbf708ec31b263115e44f420651fa4e056a89e)) + + +### Dependencies + +* The following workspace dependencies were updated + * devDependencies + * ipfs-core bumped from ^0.15.0 to ^0.16.0 + ### [3.0.4](https://www.github.com/ipfs/js-ipfs/compare/ipfs-http-response-v3.0.3...ipfs-http-response-v3.0.4) (2022-06-24) @@ -344,4 +399,4 @@ case of some property names that are used by this module. ### Features * export resolver ([d9e56b8](https://github.com/ipfs/js-ipfs-http-response/commit/d9e56b8)) -* initial implementation ([d9d0c08](https://github.com/ipfs/js-ipfs-http-response/commit/d9d0c08)) +* initial implementation ([d9d0c08](https://github.com/ipfs/js-ipfs-http-response/commit/d9d0c08)) \ No newline at end of file diff --git a/packages/ipfs-http-response/LICENSE b/packages/ipfs-http-response/LICENSE index e4224df5b7..20ce483c86 100644 --- a/packages/ipfs-http-response/LICENSE +++ b/packages/ipfs-http-response/LICENSE @@ -1,21 +1,4 @@ -MIT License +This project is dual licensed under MIT and Apache-2.0. -Copyright (c) 2018 IPFS - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -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. +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/packages/ipfs-http-response/LICENSE-APACHE b/packages/ipfs-http-response/LICENSE-APACHE new file mode 100644 index 0000000000..14478a3b60 --- /dev/null +++ b/packages/ipfs-http-response/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/ipfs-http-response/LICENSE-MIT b/packages/ipfs-http-response/LICENSE-MIT new file mode 100644 index 0000000000..72dc60d84b --- /dev/null +++ b/packages/ipfs-http-response/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +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. diff --git a/packages/ipfs-http-response/README.md b/packages/ipfs-http-response/README.md index b726645fbf..640baa0551 100644 --- a/packages/ipfs-http-response/README.md +++ b/packages/ipfs-http-response/README.md @@ -1,19 +1,29 @@ -# js-ipfs-http-response +# ipfs-http-response -[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai) -[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) -[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) -[![standard-readme](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme) -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) > Creates an HTTP response from an IPFS Hash -### Installation +## Table of contents -> npm install ipfs-http-response +- [Install](#install) +- [Usage](#usage) + - [Creating HTTP Response](#creating-http-response) + - [Using protocol-agnostic resolver](#using-protocol-agnostic-resolver) +- [License](#license) +- [Contribute](#contribute) -## Usage +## Install + +```console +$ npm i ipfs-http-response +``` +## Usage ### Creating HTTP Response @@ -39,7 +49,6 @@ console.log(result) If `ipfsPath` points at a directory, `resolver.cid` will throw Error `This dag node is a directory` with a `cid` attribute that can be passed to `resolver.directory`: - ```js import { resolver } from 'ipfs-http-response' @@ -50,3 +59,22 @@ console.log(result) `result` will be either a `string` with HTML directory listing or an array with CIDs of `index` pages present in inspected directory. ![ipfs-http-response usage](docs/ipfs-http-response.png "ipfs-http-response usage") + +## License + +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute + +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). + +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. + +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs-http-response/package.json b/packages/ipfs-http-response/package.json index fe41a04a23..e5e2027264 100644 --- a/packages/ipfs-http-response/package.json +++ b/packages/ipfs-http-response/package.json @@ -1,10 +1,28 @@ { "name": "ipfs-http-response", - "version": "3.0.4", + "version": "5.0.0", "description": "Creates an HTTP response from an IPFS Hash", - "leadMaintainer": "Vasco Santos ", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "author": "Vasco Santos ", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-response#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, + "keywords": [ + "http", + "ipfs", + "response" + ], + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "type": "module", + "types": "./dist/src/index.d.ts", "typesVersions": { "*": { "*": [ @@ -21,18 +39,24 @@ ] } }, - "type": "module", + "files": [ + "src", + "dist", + "!dist/test", + "!**/*.tsbuildinfo" + ], + "exports": { + ".": { + "types": "./dist/src/index.d.ts", + "import": "./src/index.js" + } + }, "eslintConfig": { "extends": "ipfs", "parserOptions": { "sourceType": "module" } }, - "exports": { - ".": { - "import": "./src/index.js" - } - }, "scripts": { "lint": "aegir lint", "clean": "aegir clean", @@ -41,34 +65,14 @@ "test:node": "aegir test -t node --cov", "dep-check": "aegir dep-check -i global" }, - "browser": { - "file-type": "file-type/browser", - "fs": false - }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs-http-response.git" - }, - "keywords": [ - "ipfs", - "http", - "response" - ], - "author": "Vasco Santos ", - "license": "MIT", - "bugs": { - "url": "https://github.com/ipfs/js-ipfs-http-response/issues" - }, - "homepage": "https://github.com/ipfs/js-ipfs-http-response#readme", "dependencies": { - "@libp2p/logger": "^1.1.4", + "@libp2p/logger": "^2.0.0", "ejs": "^3.1.6", - "file-type": "^17.1.1", - "filesize": "^8.0.0", - "it-buffer": "^0.1.1", - "it-concat": "^2.0.0", - "it-map": "^1.0.6", - "it-reader": "^5.0.1", + "file-type": "^18.0.0", + "filesize": "^10.0.5", + "it-concat": "^3.0.1", + "it-map": "^2.0.0", + "it-reader": "^6.0.1", "it-to-stream": "^1.0.0", "mime-types": "^2.1.30", "p-try-each": "^1.0.1" @@ -78,19 +82,13 @@ "@types/mime-types": "^2.1.1", "aegir": "^37.0.11", "get-stream": "^6.0.0", - "ipfs-core": "^0.15.4", - "ipfsd-ctl": "^11.0.0", - "it-all": "^1.0.4", - "uint8arrays": "^3.0.0" + "ipfs-core": "^0.17.0", + "ipfsd-ctl": "^12.0.3", + "it-all": "^2.0.0", + "uint8arrays": "^4.0.2" }, - "contributors": [ - "Vasco Santos ", - "Alex Potsides ", - "Hector Sanjuan ", - "Marcin Rataj ", - "André Cruz ", - "Irakli Gozalishvili ", - "Alan Shaw ", - "Pedro Santos " - ] + "browser": { + "file-type": "file-type/browser", + "fs": false + } } diff --git a/packages/ipfs-http-response/src/dir-view/index.js b/packages/ipfs-http-response/src/dir-view/index.js index 61afe89410..8bd4e3a3a0 100644 --- a/packages/ipfs-http-response/src/dir-view/index.js +++ b/packages/ipfs-http-response/src/dir-view/index.js @@ -1,4 +1,4 @@ -import filesize from 'filesize' +import { filesize } from 'filesize' import style from './style.js' import { cidArray } from '../utils/path.js' import ejs from 'ejs' diff --git a/packages/ipfs-http-response/src/index.js b/packages/ipfs-http-response/src/index.js index 821dbaa202..6fb4994d2c 100644 --- a/packages/ipfs-http-response/src/index.js +++ b/packages/ipfs-http-response/src/index.js @@ -3,8 +3,6 @@ // @ts-expect-error no types import toStream from 'it-to-stream' import concat from 'it-concat' -// @ts-expect-error no types -import toBuffer from 'it-buffer' import { logger } from '@libp2p/logger' import * as ipfsResolver from './resolver.js' import * as pathUtils from './utils/path.js' @@ -73,7 +71,7 @@ export async function getResponse (ipfsNode, ipfsPath) { const { source, contentType } = await detectContentType(ipfsPath, ipfsNode.cat(resolvedData.cid)) if (typeof Blob === 'undefined') { - const responseStream = toStream.readable(toBuffer(source)) + const responseStream = toStream.readable(source) return contentType ? new Response(responseStream, getHeader(200, 'OK', { 'Content-Type': contentType })) @@ -82,7 +80,7 @@ export async function getResponse (ipfsNode, ipfsPath) { try { const data = await concat(source) - const blob = new Blob([data.slice()]) + const blob = new Blob([data.subarray()]) return contentType ? new Response(blob, getHeader(200, 'OK', { 'Content-Type': contentType })) diff --git a/packages/ipfs-http-response/src/utils/content-type.js b/packages/ipfs-http-response/src/utils/content-type.js index 0b5f7b2814..7f0c912d82 100644 --- a/packages/ipfs-http-response/src/utils/content-type.js +++ b/packages/ipfs-http-response/src/utils/content-type.js @@ -28,18 +28,20 @@ export const detectContentType = async (path, source) => { if (done) { return { - source: map(stream, (buf) => buf.slice()) + source: map(stream, (buf) => buf.subarray()) } } - fileSignature = await fileTypeFromBuffer(value.slice()) + fileSignature = await fileTypeFromBuffer(value.subarray()) output = (async function * () { // eslint-disable-line require-await yield value yield * stream })() } catch (/** @type {any} */ err) { - if (err.code !== 'ERR_UNDER_READ') throw err + if (err.code !== 'ERR_UNDER_READ') { + throw err + } // not enough bytes for sniffing, just yield the data output = (async function * () { // eslint-disable-line require-await @@ -62,7 +64,14 @@ export const detectContentType = async (path, source) => { } if (output != null) { - return { source: map(output, (buf) => buf.slice()), contentType } + return { + source: (async function * () { + for await (const list of output) { + yield * list + } + }()), + contentType + } } return { source, contentType } diff --git a/packages/ipfs-http-response/tsconfig.json b/packages/ipfs-http-response/tsconfig.json index 448e187c8c..882b188dfc 100644 --- a/packages/ipfs-http-response/tsconfig.json +++ b/packages/ipfs-http-response/tsconfig.json @@ -11,5 +11,10 @@ "exclude": [ "dist", "node_modules" + ], + "references": [ + { + "path": "../ipfs-core" + } ] } diff --git a/packages/ipfs-http-server/CHANGELOG.md b/packages/ipfs-http-server/CHANGELOG.md index b1949ee837..675af7d1a6 100644 --- a/packages/ipfs-http-server/CHANGELOG.md +++ b/packages/ipfs-http-server/CHANGELOG.md @@ -3,6 +3,75 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.14.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-http-server-v0.13.2...ipfs-http-server-v0.14.0) (2022-10-24) + + +### ⚠ BREAKING CHANGES + +* ipfs is now bundled with libp2p@0.40.x which has different config + +### Features + +* upgrade libp2p to 0.40.x ([#4237](https://www.github.com/ipfs/js-ipfs/issues/4237)) ([0cee4a4](https://www.github.com/ipfs/js-ipfs/commit/0cee4a4c55767022584dcbade0b0b9b43326f9c9)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.12.1 to ^0.13.0 + * ipfs-core-utils bumped from ^0.16.1 to ^0.17.0 + * ipfs-http-gateway bumped from ^0.11.1 to ^0.12.0 + * devDependencies + * ipfs-http-client bumped from ^58.0.1 to ^59.0.0 + +### [0.13.2](https://www.github.com/ipfs/js-ipfs/compare/ipfs-http-server-v0.13.1...ipfs-http-server-v0.13.2) (2022-09-21) + + +### Bug Fixes + +* update @multiformats/multiadd to 11.0.0 ([2a830bf](https://www.github.com/ipfs/js-ipfs/commit/2a830bf58a5929fcce51dede871c99f62192fbda)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.12.0 to ^0.12.1 + * ipfs-core-utils bumped from ^0.16.0 to ^0.16.1 + * ipfs-http-gateway bumped from ^0.11.0 to ^0.11.1 + * devDependencies + * ipfs-http-client bumped from ^58.0.0 to ^58.0.1 + +### [0.13.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-http-server-v0.13.0...ipfs-http-server-v0.13.1) (2022-09-16) + + +### Bug Fixes + +* add node memory stats to prometheus output ([#4209](https://www.github.com/ipfs/js-ipfs/issues/4209)) ([b545688](https://www.github.com/ipfs/js-ipfs/commit/b545688264a21a756e470bab022d53762d58562d)) + +## [0.13.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-http-server-v0.12.5...ipfs-http-server-v0.13.0) (2022-09-06) + + +### ⚠ BREAKING CHANGES + +* update to libp2p@0.38.x (#4151) + +### deps + +* update to libp2p@0.38.x ([#4151](https://www.github.com/ipfs/js-ipfs/issues/4151)) ([39dbf70](https://www.github.com/ipfs/js-ipfs/commit/39dbf708ec31b263115e44f420651fa4e056a89e)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.11.0 to ^0.12.0 + * ipfs-core-utils bumped from ^0.15.0 to ^0.16.0 + * ipfs-http-gateway bumped from ^0.10.0 to ^0.11.0 + * devDependencies + * ipfs-http-client bumped from ^57.0.0 to ^58.0.0 + ### [0.12.5](https://www.github.com/ipfs/js-ipfs/compare/ipfs-http-server-v0.12.4...ipfs-http-server-v0.12.5) (2022-06-24) diff --git a/packages/ipfs-http-server/LICENSE b/packages/ipfs-http-server/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-http-server/LICENSE @@ -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 diff --git a/packages/ipfs-http-server/LICENSE-MIT b/packages/ipfs-http-server/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/packages/ipfs-http-server/LICENSE-MIT +++ b/packages/ipfs-http-server/LICENSE-MIT @@ -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. \ No newline at end of file +THE SOFTWARE. diff --git a/packages/ipfs-http-server/README.md b/packages/ipfs-http-server/README.md index e75b94ac23..51f5921326 100644 --- a/packages/ipfs-http-server/README.md +++ b/packages/ipfs-http-server/README.md @@ -1,16 +1,24 @@ # ipfs-http-server -> The implementation of the IPFS RPC-over-HTTP API +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -## Table of Contents +> JavaScript implementation of the IPFS specification + +## Table of contents - [Install](#install) -- [Want to hack on IPFS?](#want-to-hack-on-ipfs) - [License](#license) +- [Contribute](#contribute) ## Install -You probably don't need to install this module directly, use it by installing the `ipfs` module: +```console +$ npm i ipfs-http-server +``` ```console $ npm install -g ipfs @@ -23,24 +31,21 @@ $ curl -X POST http://localhost:5002/api/v0/id | npx json ... ``` -## Want to hack on IPFS? +## License + +Licensed under either of -[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) -The IPFS implementation in JavaScript needs your help! There are a few things you can do right now to help out: +## Contribute -Read the [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md) and [JavaScript Contributing Guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md). +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). -- **Check out existing issues** The [issue list](https://github.com/ipfs/js-ipfs/issues) has many that are marked as ['help wanted'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22) or ['difficulty:easy'](https://github.com/ipfs/js-ipfs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Adifficulty%3Aeasy) which make great starting points for development, many of which can be tackled with no prior IPFS knowledge -- **Look at the [IPFS Roadmap](https://github.com/ipfs/roadmap)** This are the high priority items being worked on right now -- **Perform code reviews** More eyes will help - a. speed the project along - b. ensure quality, and - c. reduce possible future bugs. -- **Add tests**. There can never be enough tests. -- **Join the [Weekly Core Implementations Call](https://github.com/ipfs/team-mgmt/issues/992)** it's where everyone discusses what's going on with IPFS and what's next +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). -## License +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs-http-server/package.json b/packages/ipfs-http-server/package.json index f8271ef649..d53a1bb040 100644 --- a/packages/ipfs-http-server/package.json +++ b/packages/ipfs-http-server/package.json @@ -1,23 +1,50 @@ { "name": "ipfs-http-server", - "version": "0.12.5", + "version": "0.14.0", "description": "JavaScript implementation of the IPFS specification", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-server#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "IPFS" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-server#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ], + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ] + } + }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" } }, @@ -27,16 +54,12 @@ "sourceType": "module" } }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" - }, "scripts": { "lint": "aegir lint", "test": "aegir test -t node", "test:node": "aegir test -t node --cov", "clean": "aegir clean", - "dep-check": "aegir dep-check -i ipfs-http-client -i ipfs-core-types -i @libp2p/interfaces -i ipfs-unixfs", + "dep-check": "aegir dep-check -i ipfs-http-client -i ipfs-core-types -i @libp2p/interfaces -i ipfs-unixfs -i @libp2p/interface-dht", "build": "aegir build --no-bundle", "prepublishOnly": "node scripts/update-version.js" }, @@ -44,47 +67,49 @@ "@hapi/boom": "^9.1.0", "@hapi/content": "^5.0.2", "@hapi/hapi": "^20.0.0", - "@ipld/dag-pb": "^2.1.3", - "@libp2p/interfaces": "^2.0.4", - "@libp2p/logger": "^1.1.4", + "@ipld/dag-pb": "^3.0.0", + "@libp2p/interface-dht": "^1.0.1", + "@libp2p/interfaces": "^3.0.3", + "@libp2p/logger": "^2.0.0", "@libp2p/peer-id": "^1.1.10", + "@multiformats/multiaddr": "^11.0.0", + "@multiformats/uri-to-multiaddr": "^7.0.0", "any-signal": "^3.0.0", "dlv": "^1.1.3", "hapi-pino": "^8.5.0", - "ipfs-core-types": "^0.11.1", - "ipfs-core-utils": "^0.15.1", - "ipfs-http-gateway": "^0.10.4", - "ipfs-unixfs": "^6.0.9", - "it-all": "^1.0.4", - "it-drain": "^1.0.3", - "it-filter": "^1.0.2", - "it-last": "^1.0.4", - "it-map": "^1.0.4", - "it-merge": "^1.0.2", - "it-multipart": "^2.0.0", + "ipfs-core-types": "^0.13.0", + "ipfs-core-utils": "^0.17.0", + "ipfs-http-gateway": "^0.12.0", + "ipfs-unixfs": "^8.0.0", + "it-all": "^2.0.0", + "it-drain": "^2.0.0", + "it-filter": "^2.0.0", + "it-last": "^2.0.0", + "it-map": "^2.0.0", + "it-merge": "^2.0.0", + "it-multipart": "^3.0.0", "it-pipe": "^2.0.3", - "it-pushable": "^2.0.1", - "it-reduce": "^1.0.5", + "it-pushable": "^3.0.0", + "it-reduce": "^2.0.0", "joi": "^17.2.1", "just-safe-set": "^4.0.2", - "@multiformats/multiaddr": "^10.0.0", - "multiformats": "^9.5.1", + "multiformats": "^10.0.0", "parse-duration": "^1.0.0", "stream-to-it": "^0.2.2", "timeout-abort-controller": "^3.0.0", - "uint8arrays": "^3.0.0", - "uri-to-multiaddr": "^6.0.0" + "uint8arrays": "^4.0.2" }, "devDependencies": { "@types/hapi-pino": "^8.0.1", "@types/hapi__hapi": "^20.0.5", + "@types/node": "^18.0.0", "aegir": "^37.0.11", "err-code": "^3.0.1", "form-data": "^4.0.0", - "ipfs-http-client": "^57.0.3", + "ipfs-http-client": "^59.0.0", "iso-random-stream": "^2.0.2", - "it-first": "^1.0.4", - "it-to-buffer": "^2.0.0", + "it-first": "^2.0.0", + "it-to-buffer": "^3.0.0", "qs": "^6.9.4", "sinon": "^14.0.0", "stream-to-promise": "^3.0.0" diff --git a/packages/ipfs-http-server/src/api/resources/dht.js b/packages/ipfs-http-server/src/api/resources/dht.js index bb1a453f40..2a9df85b9d 100644 --- a/packages/ipfs-http-server/src/api/resources/dht.js +++ b/packages/ipfs-http-server/src/api/resources/dht.js @@ -9,7 +9,7 @@ import Boom from '@hapi/boom' /** * @typedef {import('ipfs-core-types/src/dht').QueryEvent} QueryEvent - * @typedef {import('@libp2p/interfaces/peer-id').PeerId} PeerId + * @typedef {import('@libp2p/interface-peer-id').PeerId} PeerId */ /** diff --git a/packages/ipfs-http-server/src/api/resources/pubsub.js b/packages/ipfs-http-server/src/api/resources/pubsub.js index 52cb8f7922..5cd38252b4 100644 --- a/packages/ipfs-http-server/src/api/resources/pubsub.js +++ b/packages/ipfs-http-server/src/api/resources/pubsub.js @@ -9,7 +9,7 @@ import { pushable } from 'it-pushable' import { base64url } from 'multiformats/bases/base64' /** - * @typedef {import('@libp2p/interfaces/pubsub').Message} Message + * @typedef {import('@libp2p/interface-pubsub').Message} Message */ const preDecodeTopicFromHttpRpc = { @@ -71,30 +71,35 @@ export const subscribeResource = { // request.raw.res.setHeader('Trailer', 'X-Stream-Error') return streamResponse(request, h, () => { - const output = pushable() + const output = pushable({ objectMode: true }) /** * @type {import('@libp2p/interfaces/events').EventHandler} */ const handler = (msg) => { - let sequenceNumber - - if (msg.sequenceNumber != null) { + if (msg.type === 'signed') { let numberString = msg.sequenceNumber.toString(16) if (numberString.length % 2 !== 0) { numberString = `0${numberString}` } - sequenceNumber = base64url.encode(uint8ArrayFromString(numberString, 'base16')) - } + const sequenceNumber = base64url.encode(uint8ArrayFromString(numberString, 'base16')) - output.push({ - from: msg.from, // TODO: switch to peerIdFromString(msg.from).toString() when go-ipfs defaults to CIDv1 - data: base64url.encode(msg.data), - seqno: sequenceNumber, - topicIDs: [base64url.encode(uint8ArrayFromString(msg.topic))] - }) + output.push({ + from: msg.from, // TODO: switch to peerIdFromString(msg.from).toString() when go-ipfs defaults to CIDv1 + data: base64url.encode(msg.data), + seqno: sequenceNumber, + topicIDs: [base64url.encode(uint8ArrayFromString(msg.topic))], + key: base64url.encode(msg.key), + signature: base64url.encode(msg.signature) + }) + } else { + output.push({ + data: base64url.encode(msg.data), + topicIDs: [base64url.encode(uint8ArrayFromString(msg.topic))] + }) + } } // js-ipfs-http-client needs a reply, and go-ipfs does the same thing diff --git a/packages/ipfs-http-server/src/api/resources/shutdown.js b/packages/ipfs-http-server/src/api/resources/shutdown.js index 0114d8a22f..9a8a6e0292 100644 --- a/packages/ipfs-http-server/src/api/resources/shutdown.js +++ b/packages/ipfs-http-server/src/api/resources/shutdown.js @@ -11,7 +11,7 @@ export const shutdownResource = { * @param {import('@hapi/hapi').ResponseToolkit} h */ handler: (_request, h) => { - setImmediate(() => process.emit('SIGTERM')) + setImmediate(() => process.emit('SIGTERM', 'SIGTERM')) return h.response() } } diff --git a/packages/ipfs-http-server/src/api/routes/debug.js b/packages/ipfs-http-server/src/api/routes/debug.js index 023dcc9dde..9c71514cd7 100644 --- a/packages/ipfs-http-server/src/api/routes/debug.js +++ b/packages/ipfs-http-server/src/api/routes/debug.js @@ -1,3 +1,5 @@ +/* eslint-disable max-depth */ + import client from 'prom-client' import Boom from '@hapi/boom' import { disable, enable } from '@libp2p/logger' @@ -6,7 +8,13 @@ import { disable, enable } from '@libp2p/logger' client.register.clear() /** @type {Record>} */ -const gauges = {} +const gauges = { + nodejs_memory_usage: new client.Gauge({ + name: 'nodejs_memory_usage', + help: 'nodejs_memory_usage', + labelNames: Object.keys(process.memoryUsage()) + }) +} // Endpoint for handling debug metrics export default [{ @@ -21,6 +29,10 @@ export default [{ throw Boom.notImplemented('Monitoring is disabled. Enable it by setting environment variable IPFS_MONITORING') } + Object.entries(process.memoryUsage()).forEach(([key, value]) => { + gauges.nodejs_memory_usage.set({ [key]: key }, value) + }) + const { ipfs } = request.server.app // @ts-expect-error libp2p does not exist on ipfs const metrics = ipfs.libp2p.metrics @@ -28,14 +40,36 @@ export default [{ if (metrics) { for (const [system, components] of metrics.getComponentMetrics().entries()) { for (const [component, componentMetrics] of components.entries()) { - for (const [metricName, metricValue] of componentMetrics.entries()) { + for (const [metricName, trackedMetric] of componentMetrics.entries()) { const name = `${system}-${component}-${metricName}`.replace(/-/g, '_') + const labelName = trackedMetric.label ?? metricName.replace(/-/g, '_') + const help = trackedMetric.help ?? metricName.replace(/-/g, '_') + + /** @type {client.GaugeConfiguration} */ + const gaugeOptions = { name, help } + const metricValue = await trackedMetric.calculate() - if (!gauges[name]) { // eslint-disable-line max-depth - gauges[name] = new client.Gauge({ name, help: name }) + if (typeof metricValue !== 'number') { + // metric group + gaugeOptions.labelNames = [ + labelName + ] } - gauges[name].set(metricValue) + if (!gauges[name]) { + // create metric if it's not been seen before + gauges[name] = new client.Gauge(gaugeOptions) + } + + if (typeof metricValue !== 'number') { + // metric group + Object.entries(metricValue).forEach(([key, value]) => { + gauges[name].set({ [labelName]: key }, value) + }) + } else { + // metric value + gauges[name].set(metricValue) + } } } } diff --git a/packages/ipfs-http-server/src/error-handler.js b/packages/ipfs-http-server/src/error-handler.js index 1c21274117..cca2fb48c5 100644 --- a/packages/ipfs-http-server/src/error-handler.js +++ b/packages/ipfs-http-server/src/error-handler.js @@ -34,16 +34,14 @@ export function errorHandler (server) { if (process.env.DEBUG || statusCode >= 500) { const { req } = request.raw const debug = { - method: req.method, - url: request.url, + method: req.method?.toString(), + url: request.url?.toString(), headers: req.headers, - info: request.info, payload: request.payload, response: res.output.payload } server.logger.error(debug) - server.logger.error(res) } const response = h.response({ diff --git a/packages/ipfs-http-server/src/index.js b/packages/ipfs-http-server/src/index.js index f09951c418..6caad03d38 100644 --- a/packages/ipfs-http-server/src/index.js +++ b/packages/ipfs-http-server/src/index.js @@ -1,9 +1,8 @@ import Hapi from '@hapi/hapi' import Pino from 'hapi-pino' import { logger, enabled } from '@libp2p/logger' -import { Multiaddr } from '@multiformats/multiaddr' -// @ts-expect-error no types -import toMultiaddr from 'uri-to-multiaddr' +import { multiaddr } from '@multiformats/multiaddr' +import toMultiaddr from '@multiformats/uri-to-multiaddr' import Boom from '@hapi/boom' import { routes } from './api/routes/index.js' import { errorHandler } from './error-handler.js' @@ -275,7 +274,7 @@ export class HttpApi { if (!this._apiServers || !this._apiServers.length) { throw new Error('API address unavailable - server is not started') } - return new Multiaddr('/ip4/127.0.0.1/tcp/' + this._apiServers[0].info.port) + return multiaddr('/ip4/127.0.0.1/tcp/' + this._apiServers[0].info.port) } async stop () { diff --git a/packages/ipfs-http-server/src/utils/joi.js b/packages/ipfs-http-server/src/utils/joi.js index a7371d86e3..60afd4bd57 100644 --- a/packages/ipfs-http-server/src/utils/joi.js +++ b/packages/ipfs-http-server/src/utils/joi.js @@ -1,6 +1,6 @@ import { CID } from 'multiformats/cid' import parseDuration from 'parse-duration' -import { Multiaddr } from '@multiformats/multiaddr' +import { multiaddr } from '@multiformats/multiaddr' import { toCidAndPath } from 'ipfs-core-utils/to-cid-and-path' import Joi from 'joi' import { peerIdFromString } from '@libp2p/peer-id' @@ -107,7 +107,7 @@ export default Joi return } - return { value: new Multiaddr(value).toString() } + return { value: multiaddr(value).toString() } } } }, diff --git a/packages/ipfs-http-server/test/inject/dht.js b/packages/ipfs-http-server/test/inject/dht.js index 4d182fa627..3f9ed0de40 100644 --- a/packages/ipfs-http-server/test/inject/dht.js +++ b/packages/ipfs-http-server/test/inject/dht.js @@ -11,7 +11,7 @@ import { allNdjson } from '../utils/all-ndjson.js' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' import FormData from 'form-data' import streamToPromise from 'stream-to-promise' -import { EventTypes } from '@libp2p/interfaces/dht' +import { EventTypes } from '@libp2p/interface-dht' describe('/dht', () => { const peerId = 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A' diff --git a/packages/ipfs-http-server/test/inject/object.js b/packages/ipfs-http-server/test/inject/object.js index d1c77bcf6a..5bb990fcb1 100644 --- a/packages/ipfs-http-server/test/inject/object.js +++ b/packages/ipfs-http-server/test/inject/object.js @@ -292,7 +292,7 @@ describe('/object', () => { ipfs.bases.getBase.withArgs('base58btc').returns(base58btc) const pbNode = { - Data: uint8ArrayFromString('another'), + Data: Uint8Array.from(uint8ArrayFromString('another')), Links: [{ Name: 'some link', Hash: CID.parse('QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39V'), @@ -341,7 +341,7 @@ describe('/object', () => { ipfs.bases.getBase.withArgs('base64').returns(base64) const pbNode = { - Data: uint8ArrayFromString('another'), + Data: Uint8Array.from(uint8ArrayFromString('another')), Links: [{ Name: 'some link', Hash: CID.parse('QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39V').toV1(), @@ -390,7 +390,7 @@ describe('/object', () => { ipfs.bases.getBase.withArgs('base58btc').returns(base58btc) const pbNode = { - Data: uint8ArrayFromString('another'), + Data: Uint8Array.from(uint8ArrayFromString('another')), Links: [{ Name: 'some link', Hash: CID.parse('QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39V'), diff --git a/packages/ipfs-http-server/tsconfig.json b/packages/ipfs-http-server/tsconfig.json index e6f92ccfd4..04be5d4ba1 100644 --- a/packages/ipfs-http-server/tsconfig.json +++ b/packages/ipfs-http-server/tsconfig.json @@ -15,6 +15,9 @@ { "path": "../ipfs-core-utils" }, + { + "path": "../ipfs-http-client" + }, { "path": "../ipfs-http-gateway" } diff --git a/packages/ipfs-message-port-client/.aegir.js b/packages/ipfs-message-port-client/.aegir.js index 5f0ca24907..1d3d9961be 100644 --- a/packages/ipfs-message-port-client/.aegir.js +++ b/packages/ipfs-message-port-client/.aegir.js @@ -7,17 +7,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)) /** @type {import('aegir').Options["build"]["config"]} */ const buildConfig = { - inject: [path.join(__dirname, '../../scripts/node-globals.js')], - plugins: [ - { - name: 'node built ins', - setup (build) { - build.onResolve({ filter: /^stream$/ }, () => { - return { path: require.resolve('readable-stream') } - }) - } - } - ] + inject: [path.join(__dirname, '../../scripts/node-globals.js')] } /** @type {import('aegir').PartialOptions} */ diff --git a/packages/ipfs-message-port-client/CHANGELOG.md b/packages/ipfs-message-port-client/CHANGELOG.md index a9f7936762..f5daada84f 100644 --- a/packages/ipfs-message-port-client/CHANGELOG.md +++ b/packages/ipfs-message-port-client/CHANGELOG.md @@ -3,6 +3,71 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.14.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-message-port-client-v0.13.1...ipfs-message-port-client-v0.14.0) (2022-10-24) + + +### ⚠ BREAKING CHANGES + +* ipfs is now bundled with libp2p@0.40.x which has different config + +### Features + +* upgrade libp2p to 0.40.x ([#4237](https://www.github.com/ipfs/js-ipfs/issues/4237)) ([0cee4a4](https://www.github.com/ipfs/js-ipfs/commit/0cee4a4c55767022584dcbade0b0b9b43326f9c9)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.12.1 to ^0.13.0 + * ipfs-message-port-protocol bumped from ^0.13.1 to ^0.14.0 + * devDependencies + * interface-ipfs-core bumped from ^0.156.1 to ^0.157.0 + * ipfs-core bumped from ^0.16.1 to ^0.17.0 + * ipfs-message-port-server bumped from ^0.13.1 to ^0.14.0 + +### [0.13.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-message-port-client-v0.13.0...ipfs-message-port-client-v0.13.1) (2022-09-21) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.12.0 to ^0.12.1 + * ipfs-message-port-protocol bumped from ^0.13.0 to ^0.13.1 + * devDependencies + * interface-ipfs-core bumped from ^0.156.0 to ^0.156.1 + * ipfs-core bumped from ^0.16.0 to ^0.16.1 + * ipfs-message-port-server bumped from ^0.13.0 to ^0.13.1 + +## [0.13.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-message-port-client-v0.12.4...ipfs-message-port-client-v0.13.0) (2022-09-06) + + +### ⚠ BREAKING CHANGES + +* update to libp2p@0.38.x (#4151) + +### Bug Fixes + +* query input types ([#4201](https://www.github.com/ipfs/js-ipfs/issues/4201)) ([83f9882](https://www.github.com/ipfs/js-ipfs/commit/83f9882eb6df25c5ce83f447a387e068ea917c0c)) + + +### deps + +* update to libp2p@0.38.x ([#4151](https://www.github.com/ipfs/js-ipfs/issues/4151)) ([39dbf70](https://www.github.com/ipfs/js-ipfs/commit/39dbf708ec31b263115e44f420651fa4e056a89e)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.11.0 to ^0.12.0 + * ipfs-message-port-protocol bumped from ^0.12.0 to ^0.13.0 + * devDependencies + * interface-ipfs-core bumped from ^0.155.0 to ^0.156.0 + * ipfs-core bumped from ^0.15.0 to ^0.16.0 + * ipfs-message-port-server bumped from ^0.12.0 to ^0.13.0 + ### [0.12.4](https://www.github.com/ipfs/js-ipfs/compare/ipfs-message-port-client-v0.12.3...ipfs-message-port-client-v0.12.4) (2022-06-24) @@ -535,4 +600,4 @@ Co-authored-by: achingbrain ### Features -* share IPFS node between browser tabs ([#3081](https://github.com/ipfs/js-ipfs/issues/3081)) ([1b8b1b8](https://github.com/ipfs/js-ipfs/commit/1b8b1b822a252498889c54972a1f57e1fedc39d0)), closes [#3022](https://github.com/ipfs/js-ipfs/issues/3022) +* share IPFS node between browser tabs ([#3081](https://github.com/ipfs/js-ipfs/issues/3081)) ([1b8b1b8](https://github.com/ipfs/js-ipfs/commit/1b8b1b822a252498889c54972a1f57e1fedc39d0)), closes [#3022](https://github.com/ipfs/js-ipfs/issues/3022) \ No newline at end of file diff --git a/packages/ipfs-message-port-client/LICENSE b/packages/ipfs-message-port-client/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-message-port-client/LICENSE @@ -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 diff --git a/packages/ipfs-message-port-client/LICENSE-MIT b/packages/ipfs-message-port-client/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/packages/ipfs-message-port-client/LICENSE-MIT +++ b/packages/ipfs-message-port-client/LICENSE-MIT @@ -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. \ No newline at end of file +THE SOFTWARE. diff --git a/packages/ipfs-message-port-client/README.md b/packages/ipfs-message-port-client/README.md index 42008f7221..dc26cc5566 100644 --- a/packages/ipfs-message-port-client/README.md +++ b/packages/ipfs-message-port-client/README.md @@ -1,27 +1,25 @@ # ipfs-message-port-client -[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai) -[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) -[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) -[![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs)](https://travis-ci.com/ipfs/js-ipfs) -[![Codecov branch](https://img.shields.io/codecov/c/github/ipfs/js-ipfs/master.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) -[![Dependency Status](https://david-dm.org/ipfs/js-ipfs/status.svg?path=packages/ipfs-message-port-client)](https://david-dm.org/ipfs/js-ipfs?path=packages/ipfs-message-port-client) -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -> A client library for the IPFS API over [message channel][]. This client library provides (subset) of [IPFS API](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) enabling applications to work with js-ipfs running in the different JS e.g. [SharedWorker][]. +> IPFS client library for accessing IPFS node over message port -## Table of Contentens +## Table of contents - [Install](#install) - [Usage](#usage) - [Notes on Performance](#notes-on-performance) -- [Contribute](#contribute) - [License](#license) +- [Contribute](#contribute) ## Install -```bash -$ npm install --save ipfs-message-port-client +```console +$ npm i ipfs-message-port-client ``` ## Usage @@ -42,7 +40,6 @@ goal of this library is to allow sharing a node across browsing contexts (tabs, iframes) and therefore most likely `ipfs-message-port-server` will be in a separate JS bundle and loaded in the [SharedWorker][]. - ```js import { IPFSClient } from 'ipfs-message-port-client' // URL to the script containing ipfs-message-port-server. @@ -121,21 +118,35 @@ const example = async (url) => { } ``` -[message channel]:https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel -[SharedWorker]:https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker -[`MessagePort`]:https://developer.mozilla.org/en-US/docs/Web/API/MessagePort -[structured cloning algorithm]:https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm -[Transferable]:https://developer.mozilla.org/en-US/docs/Web/API/Transferable -[Blob]:https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob -[File]:https://developer.mozilla.org/en-US/docs/Web/API/File +## License +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) ## Contribute -Contributions welcome. Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). -Check out our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. -## License +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) + +[message channel]: https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel + +[SharedWorker]: https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker + +[`MessagePort`]: https://developer.mozilla.org/en-US/docs/Web/API/MessagePort + +[structured cloning algorithm]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm + +[Transferable]: https://developer.mozilla.org/en-US/docs/Web/API/Transferable + +[Blob]: https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) +[File]: https://developer.mozilla.org/en-US/docs/Web/API/File diff --git a/packages/ipfs-message-port-client/package.json b/packages/ipfs-message-port-client/package.json index d343403c7e..a521670f6d 100644 --- a/packages/ipfs-message-port-client/package.json +++ b/packages/ipfs-message-port-client/package.json @@ -1,25 +1,52 @@ { "name": "ipfs-message-port-client", - "version": "0.12.4", + "version": "0.14.0", "description": "IPFS client library for accessing IPFS node over message port", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-message-port-client#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "ipfs", "message-port", "worker" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-message-port-client#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ], + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ] + } + }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" } }, @@ -29,11 +56,6 @@ "sourceType": "module" } }, - "browser": {}, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" - }, "scripts": { "build": "aegir build", "test:interface:message-port-client": "aegir test -t browser --bail -f ./test/interface-message-port-client.js", @@ -42,22 +64,18 @@ "dep-check": "aegir dep-check -i ipfs-core -i ipfs-core-types -i esbuild" }, "dependencies": { - "browser-readablestream-to-it": "^1.0.1", + "browser-readablestream-to-it": "^2.0.0", "err-code": "^3.0.1", - "ipfs-core-types": "^0.11.1", - "ipfs-message-port-protocol": "^0.12.1", - "ipfs-unixfs": "^6.0.9", - "it-peekable": "^1.0.2", - "multiformats": "^9.5.1" + "ipfs-core-types": "^0.13.0", + "ipfs-message-port-protocol": "^0.14.0", + "ipfs-unixfs": "^8.0.0", + "it-peekable": "^2.0.0", + "multiformats": "^10.0.0" }, "devDependencies": { "aegir": "^37.0.11", - "interface-ipfs-core": "^0.155.2", - "ipfs-core": "^0.15.4", - "ipfs-message-port-server": "^0.12.1" - }, - "engines": { - "node": ">=15.0.0", - "npm": ">=3.0.0" + "interface-ipfs-core": "^0.157.0", + "ipfs-core": "^0.17.0", + "ipfs-message-port-server": "^0.14.0" } } diff --git a/packages/ipfs-message-port-client/src/client/service.js b/packages/ipfs-message-port-client/src/client/service.js index f0b97ce1ce..abc4e40e91 100644 --- a/packages/ipfs-message-port-client/src/client/service.js +++ b/packages/ipfs-message-port-client/src/client/service.js @@ -2,6 +2,7 @@ import { Query } from './query.js' /** * @typedef {import('./transport').MessageTransport} MessageTransport + * @typedef {import('./query').QueryInput} QueryInput */ /** * @template T @@ -29,7 +30,7 @@ export class Service { for (const method of methods) { /** * @template I, O - * @param {I} input + * @param {QueryInput} input * @returns {Promise} */ api[method] = input => diff --git a/packages/ipfs-message-port-client/tsconfig.json b/packages/ipfs-message-port-client/tsconfig.json index d95a1d29d4..38f8d21175 100644 --- a/packages/ipfs-message-port-client/tsconfig.json +++ b/packages/ipfs-message-port-client/tsconfig.json @@ -9,13 +9,19 @@ ], "references": [ { - "path": "../ipfs-message-port-protocol" + "path": "../interface-ipfs-core" }, { - "path": "../ipfs-message-port-server" + "path": "../ipfs-core" }, { "path": "../ipfs-core-types" + }, + { + "path": "../ipfs-message-port-protocol" + }, + { + "path": "../ipfs-message-port-server" } ] } diff --git a/packages/ipfs-message-port-protocol/CHANGELOG.md b/packages/ipfs-message-port-protocol/CHANGELOG.md index a8aad7a39b..5512f5d061 100644 --- a/packages/ipfs-message-port-protocol/CHANGELOG.md +++ b/packages/ipfs-message-port-protocol/CHANGELOG.md @@ -3,6 +3,51 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.14.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-message-port-protocol-v0.13.1...ipfs-message-port-protocol-v0.14.0) (2022-10-24) + + +### ⚠ BREAKING CHANGES + +* ipfs is now bundled with libp2p@0.40.x which has different config + +### Features + +* upgrade libp2p to 0.40.x ([#4237](https://www.github.com/ipfs/js-ipfs/issues/4237)) ([0cee4a4](https://www.github.com/ipfs/js-ipfs/commit/0cee4a4c55767022584dcbade0b0b9b43326f9c9)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.12.1 to ^0.13.0 + +### [0.13.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-message-port-protocol-v0.13.0...ipfs-message-port-protocol-v0.13.1) (2022-09-21) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.12.0 to ^0.12.1 + +## [0.13.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-message-port-protocol-v0.12.1...ipfs-message-port-protocol-v0.13.0) (2022-09-06) + + +### ⚠ BREAKING CHANGES + +* update to libp2p@0.38.x (#4151) + +### deps + +* update to libp2p@0.38.x ([#4151](https://www.github.com/ipfs/js-ipfs/issues/4151)) ([39dbf70](https://www.github.com/ipfs/js-ipfs/commit/39dbf708ec31b263115e44f420651fa4e056a89e)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.11.0 to ^0.12.0 + ### [0.12.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-message-port-protocol-v0.12.0...ipfs-message-port-protocol-v0.12.1) (2022-06-22) @@ -377,4 +422,4 @@ Co-authored-by: achingbrain ### Features -* share IPFS node between browser tabs ([#3081](https://github.com/ipfs/js-ipfs/issues/3081)) ([1b8b1b8](https://github.com/ipfs/js-ipfs/commit/1b8b1b822a252498889c54972a1f57e1fedc39d0)), closes [#3022](https://github.com/ipfs/js-ipfs/issues/3022) +* share IPFS node between browser tabs ([#3081](https://github.com/ipfs/js-ipfs/issues/3081)) ([1b8b1b8](https://github.com/ipfs/js-ipfs/commit/1b8b1b822a252498889c54972a1f57e1fedc39d0)), closes [#3022](https://github.com/ipfs/js-ipfs/issues/3022) \ No newline at end of file diff --git a/packages/ipfs-message-port-protocol/LICENSE b/packages/ipfs-message-port-protocol/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-message-port-protocol/LICENSE @@ -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 diff --git a/packages/ipfs-message-port-protocol/LICENSE-MIT b/packages/ipfs-message-port-protocol/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/packages/ipfs-message-port-protocol/LICENSE-MIT +++ b/packages/ipfs-message-port-protocol/LICENSE-MIT @@ -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. \ No newline at end of file +THE SOFTWARE. diff --git a/packages/ipfs-message-port-protocol/README.md b/packages/ipfs-message-port-protocol/README.md index a0a51d1836..1163666874 100644 --- a/packages/ipfs-message-port-protocol/README.md +++ b/packages/ipfs-message-port-protocol/README.md @@ -1,16 +1,14 @@ # ipfs-message-port-protocol -[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai) -[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) -[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) -[![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs)](https://travis-ci.com/ipfs/js-ipfs) -[![Codecov branch](https://img.shields.io/codecov/c/github/ipfs/js-ipfs/master.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) -[![Dependency Status](https://david-dm.org/ipfs/js-ipfs/status.svg?path=packages/ipfs-message-port-protocol)](https://david-dm.org/ipfs/js-ipfs?path=packages/ipfs-message-port-protocol) -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -> This package serves as a repository code shared between the core `ipfs-message-port-client` and the `ipfs-message-port-server` +> IPFS client/server protocol over message port -## Table of Contentens +## Table of contents - [Install](#install) - [Usage](#usage) @@ -19,13 +17,13 @@ - [DAGNode](#dagnode) - [AsyncIterable](#asynciterable) - [Callback](#callback) -- [Contribute](#contribute) - [License](#license) +- [Contribute](#contribute) ## Install -```bash -$ npm install --save ipfs-message-port-protocol +```console +$ npm i ipfs-message-port-protocol ``` ## Usage @@ -97,7 +95,6 @@ all the IO coordination between two. It needs to be provided `encoder` / Unlike other encoders the `transfer` argument is mandatory (because async iterable is encoded to a [MessagePort][] that can only be transferred). - ```js import { encodeIterable, decodeIterable } from 'ipfs-message-port-protocol/core') @@ -163,22 +160,33 @@ port2.onmessage = ({data}) => { } ``` +## License -[structured cloning algorithm]:https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm -[message channel]:https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel -[MessagePort]:https://developer.mozilla.org/en-US/docs/Web/API/MessagePort -[Transferable]:https://developer.mozilla.org/en-US/docs/Web/API/Transferable - -[CID]:https://github.com/multiformats/js-cid +Licensed under either of -[async iterables]:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) ## Contribute -Contributions welcome. Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). -Check out our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. -## License +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) + +[structured cloning algorithm]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm + +[message channel]: https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel + +[MessagePort]: https://developer.mozilla.org/en-US/docs/Web/API/MessagePort + +[Transferable]: https://developer.mozilla.org/en-US/docs/Web/API/Transferable + +[CID]: https://github.com/multiformats/js-cid -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) +[async iterables]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of diff --git a/packages/ipfs-message-port-protocol/package.json b/packages/ipfs-message-port-protocol/package.json index 9247cad684..3cf972b5f1 100644 --- a/packages/ipfs-message-port-protocol/package.json +++ b/packages/ipfs-message-port-protocol/package.json @@ -1,16 +1,25 @@ { "name": "ipfs-message-port-protocol", - "version": "0.12.1", + "version": "0.14.0", "description": "IPFS client/server protocol over message port", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-message-port-protocol#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "ipfs" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-message-port-protocol#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", "typesVersions": { "*": { "*": [ @@ -28,40 +37,42 @@ } }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - } - }, "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" }, "./block": { + "types": "./src/block.d.ts", "import": "./src/block.js" }, "./cid": { + "types": "./src/cid.d.ts", "import": "./src/cid.js" }, "./core": { + "types": "./src/core.d.ts", "import": "./src/core.js" }, "./dag": { + "types": "./src/dag.d.ts", "import": "./src/dag.js" }, "./error": { + "types": "./src/error.d.ts", "import": "./src/error.js" } }, - "browser": {}, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } }, "scripts": { "build": "aegir build", @@ -76,15 +87,11 @@ "dep-check": "aegir dep-check -i ipfs-core-types" }, "dependencies": { - "ipfs-core-types": "^0.11.1", - "multiformats": "^9.5.1" + "ipfs-core-types": "^0.13.0", + "multiformats": "^10.0.0" }, "devDependencies": { "aegir": "^37.0.11", - "uint8arrays": "^3.0.0" - }, - "engines": { - "node": ">=15.0.0", - "npm": ">=3.0.0" + "uint8arrays": "^4.0.2" } } diff --git a/packages/ipfs-message-port-protocol/src/cid.js b/packages/ipfs-message-port-protocol/src/cid.js index 584dfcd238..99d64468dc 100644 --- a/packages/ipfs-message-port-protocol/src/cid.js +++ b/packages/ipfs-message-port-protocol/src/cid.js @@ -43,7 +43,6 @@ export const decodeCID = encodedCID => { }) } - // @ts-expect-error non-enumerable field that doesn't always get transferred if (!cid.asCID) { Object.defineProperty(cid, 'asCID', { get: () => cid diff --git a/packages/ipfs-message-port-server/CHANGELOG.md b/packages/ipfs-message-port-server/CHANGELOG.md index a10eb6a55a..e8c8d4f89b 100644 --- a/packages/ipfs-message-port-server/CHANGELOG.md +++ b/packages/ipfs-message-port-server/CHANGELOG.md @@ -3,6 +3,54 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.14.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-message-port-server-v0.13.1...ipfs-message-port-server-v0.14.0) (2022-10-24) + + +### ⚠ BREAKING CHANGES + +* ipfs is now bundled with libp2p@0.40.x which has different config + +### Features + +* upgrade libp2p to 0.40.x ([#4237](https://www.github.com/ipfs/js-ipfs/issues/4237)) ([0cee4a4](https://www.github.com/ipfs/js-ipfs/commit/0cee4a4c55767022584dcbade0b0b9b43326f9c9)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.12.1 to ^0.13.0 + * ipfs-message-port-protocol bumped from ^0.13.1 to ^0.14.0 + +### [0.13.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-message-port-server-v0.13.0...ipfs-message-port-server-v0.13.1) (2022-09-21) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.12.0 to ^0.12.1 + * ipfs-message-port-protocol bumped from ^0.13.0 to ^0.13.1 + +## [0.13.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-message-port-server-v0.12.1...ipfs-message-port-server-v0.13.0) (2022-09-06) + + +### ⚠ BREAKING CHANGES + +* update to libp2p@0.38.x (#4151) + +### deps + +* update to libp2p@0.38.x ([#4151](https://www.github.com/ipfs/js-ipfs/issues/4151)) ([39dbf70](https://www.github.com/ipfs/js-ipfs/commit/39dbf708ec31b263115e44f420651fa4e056a89e)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-core-types bumped from ^0.11.0 to ^0.12.0 + * ipfs-message-port-protocol bumped from ^0.12.0 to ^0.13.0 + ### [0.12.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-message-port-server-v0.12.0...ipfs-message-port-server-v0.12.1) (2022-06-22) @@ -423,4 +471,4 @@ Co-authored-by: achingbrain ### Features -* share IPFS node between browser tabs ([#3081](https://github.com/ipfs/js-ipfs/issues/3081)) ([1b8b1b8](https://github.com/ipfs/js-ipfs/commit/1b8b1b822a252498889c54972a1f57e1fedc39d0)), closes [#3022](https://github.com/ipfs/js-ipfs/issues/3022) +* share IPFS node between browser tabs ([#3081](https://github.com/ipfs/js-ipfs/issues/3081)) ([1b8b1b8](https://github.com/ipfs/js-ipfs/commit/1b8b1b822a252498889c54972a1f57e1fedc39d0)), closes [#3022](https://github.com/ipfs/js-ipfs/issues/3022) \ No newline at end of file diff --git a/packages/ipfs-message-port-server/LICENSE b/packages/ipfs-message-port-server/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs-message-port-server/LICENSE @@ -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 diff --git a/packages/ipfs-message-port-server/LICENSE-MIT b/packages/ipfs-message-port-server/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/packages/ipfs-message-port-server/LICENSE-MIT +++ b/packages/ipfs-message-port-server/LICENSE-MIT @@ -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. \ No newline at end of file +THE SOFTWARE. diff --git a/packages/ipfs-message-port-server/README.md b/packages/ipfs-message-port-server/README.md index 15cde10eeb..421259f484 100644 --- a/packages/ipfs-message-port-server/README.md +++ b/packages/ipfs-message-port-server/README.md @@ -1,28 +1,25 @@ # ipfs-message-port-server -[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai) -[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) -[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) -[![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs)](https://travis-ci.com/ipfs/js-ipfs) -[![Codecov branch](https://img.shields.io/codecov/c/github/ipfs/js-ipfs/master.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) -[![Dependency Status](https://david-dm.org/ipfs/js-ipfs/status.svg?path=packages/ipfs-message-port-server)](https://david-dm.org/ipfs/js-ipfs?path=packages/ipfs-message-port-server) -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) -> A library for providing IPFS node over [message channel][]. This library enables -applications running in the different JS context to use [IPFS API](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) (subset) via `ipfs-message-port-client`. +> IPFS server library for exposing IPFS node over message port -## Table of Contentens +## Table of contents - [Install](#install) - [Usage](#usage) - [Notes on Performance](#notes-on-performance) -- [Contribute](#contribute) - [License](#license) +- [Contribute](#contribute) ## Install -```bash -$ npm install --save ipfs-message-port-server +```console +$ npm i ipfs-message-port-server ``` ## Usage @@ -66,7 +63,6 @@ const main = async () => { main() ``` - ### Notes on Performance Since the data sent over the [message channel][] is copied via @@ -77,22 +73,35 @@ on the server side. This should not be a problem in general as IPFS node itself does not retain references to returned values, but is something to keep in mind when doing something custom. +## License -[message channel]:https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel -[SharedWorker]:https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker -[`MessagePort`]:https://developer.mozilla.org/en-US/docs/Web/API/MessagePort -[structured cloning algorithm]:https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm -[Transferable]:https://developer.mozilla.org/en-US/docs/Web/API/Transferable -[Blob]:https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob -[File]:https://developer.mozilla.org/en-US/docs/Web/API/File +Licensed under either of +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) ## Contribute -Contributions welcome. Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). -Check out our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. -## License +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) + +[message channel]: https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel + +[SharedWorker]: https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker + +[`MessagePort`]: https://developer.mozilla.org/en-US/docs/Web/API/MessagePort + +[structured cloning algorithm]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm + +[Transferable]: https://developer.mozilla.org/en-US/docs/Web/API/Transferable + +[Blob]: https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) +[File]: https://developer.mozilla.org/en-US/docs/Web/API/File diff --git a/packages/ipfs-message-port-server/package.json b/packages/ipfs-message-port-server/package.json index dec1de5482..371fa1f331 100644 --- a/packages/ipfs-message-port-server/package.json +++ b/packages/ipfs-message-port-server/package.json @@ -1,43 +1,76 @@ { "name": "ipfs-message-port-server", - "version": "0.12.1", + "version": "0.14.0", "description": "IPFS server library for exposing IPFS node over message port", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-message-port-server#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "ipfs", "message-port", "worker" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-message-port-server#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, "type": "module", - "main": "src/index.js", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", + "typesVersions": { + "*": { + "*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ], + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" + ] + } + }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" }, "./block": { + "types": "./src/block.d.ts", "import": "./src/block.js" }, "./core": { + "types": "./src/core.d.ts", "import": "./src/core.js" }, "./dag": { + "types": "./src/dag.d.ts", "import": "./src/dag.js" }, "./files": { + "types": "./src/files.d.ts", "import": "./src/files.js" }, "./server": { + "types": "./src/server.d.ts", "import": "./src/server.js" }, "./service": { + "types": "./src/service.d.ts", "import": "./src/service.js" } }, @@ -47,13 +80,6 @@ "sourceType": "module" } }, - "browser": { - "worker_threads": false - }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" - }, "scripts": { "build": "aegir build", "test": "aegir test", @@ -66,16 +92,15 @@ "dep-check": "aegir dep-check -i ipfs-core-types" }, "dependencies": { - "ipfs-core-types": "^0.11.1", - "ipfs-message-port-protocol": "^0.12.1", - "it-all": "^1.0.4" + "ipfs-core-types": "^0.13.0", + "ipfs-message-port-protocol": "^0.14.0", + "it-all": "^2.0.0" }, "devDependencies": { "aegir": "^37.0.11", - "multiformats": "^9.5.1" + "multiformats": "^10.0.0" }, - "engines": { - "node": ">=15.0.0", - "npm": ">=3.0.0" + "browser": { + "worker_threads": false } } diff --git a/packages/ipfs-message-port-server/src/core.js b/packages/ipfs-message-port-server/src/core.js index 50c8aa618e..5a2a39cee5 100644 --- a/packages/ipfs-message-port-server/src/core.js +++ b/packages/ipfs-message-port-server/src/core.js @@ -9,7 +9,7 @@ import { import { decodeCID, encodeCID } from 'ipfs-message-port-protocol/cid' /** - * @typedef {import('multiformats/cid').CIDVersion} CIDVersion + * @typedef {import('multiformats/cid').Version} CIDVersion * @typedef {import('ipfs-core-types').IPFS} IPFS * @typedef {import('ipfs-core-types/src/root').AddOptions} AddOptions * @typedef {import('ipfs-core-types/src/root').AddAllOptions} AddAllOptions diff --git a/packages/ipfs/.aegir.js b/packages/ipfs/.aegir.js index 4d424964be..768a934ce9 100644 --- a/packages/ipfs/.aegir.js +++ b/packages/ipfs/.aegir.js @@ -9,17 +9,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)) /** @type {import('aegir').Options["build"]["config"]} */ const esbuild = { - inject: [path.join(__dirname, '../../scripts/node-globals.js')], - plugins: [ - { - name: 'node built ins', - setup (build) { - build.onResolve({ filter: /^stream$/ }, () => { - return { path: require.resolve('readable-stream') } - }) - } - } - ] + inject: [path.join(__dirname, '../../scripts/node-globals.js')] } /** @type {import('aegir').PartialOptions} */ diff --git a/packages/ipfs/CHANGELOG.md b/packages/ipfs/CHANGELOG.md index cb6ff35580..7e4ba52a9e 100644 --- a/packages/ipfs/CHANGELOG.md +++ b/packages/ipfs/CHANGELOG.md @@ -4,6 +4,83 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.65.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-v0.64.2...ipfs-v0.65.0) (2022-10-24) + + +### ⚠ BREAKING CHANGES + +* ipfs is now bundled with libp2p@0.40.x which has different config + +### Features + +* upgrade libp2p to 0.40.x ([#4237](https://www.github.com/ipfs/js-ipfs/issues/4237)) ([0cee4a4](https://www.github.com/ipfs/js-ipfs/commit/0cee4a4c55767022584dcbade0b0b9b43326f9c9)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-cli bumped from ^0.14.2 to ^0.15.0 + * ipfs-core bumped from ^0.16.1 to ^0.17.0 + * devDependencies + * interface-ipfs-core bumped from ^0.156.1 to ^0.157.0 + * ipfs-client bumped from ^0.9.1 to ^0.9.2 + * ipfs-core-types bumped from ^0.12.1 to ^0.13.0 + * ipfs-http-client bumped from ^58.0.1 to ^59.0.0 + +### [0.64.2](https://www.github.com/ipfs/js-ipfs/compare/ipfs-v0.64.1...ipfs-v0.64.2) (2022-09-21) + + +### Bug Fixes + +* update @multiformats/multiadd to 11.0.0 ([2a830bf](https://www.github.com/ipfs/js-ipfs/commit/2a830bf58a5929fcce51dede871c99f62192fbda)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-cli bumped from ^0.14.1 to ^0.14.2 + * ipfs-core bumped from ^0.16.0 to ^0.16.1 + * devDependencies + * interface-ipfs-core bumped from ^0.156.0 to ^0.156.1 + * ipfs-client bumped from ^0.9.0 to ^0.9.1 + * ipfs-core-types bumped from ^0.12.0 to ^0.12.1 + * ipfs-http-client bumped from ^58.0.0 to ^58.0.1 + +### [0.64.1](https://www.github.com/ipfs/js-ipfs/compare/ipfs-v0.64.0...ipfs-v0.64.1) (2022-09-16) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-cli bumped from ^0.14.0 to ^0.14.1 + +## [0.64.0](https://www.github.com/ipfs/js-ipfs/compare/ipfs-v0.63.5...ipfs-v0.64.0) (2022-09-06) + + +### ⚠ BREAKING CHANGES + +* update to libp2p@0.38.x (#4151) + +### deps + +* update to libp2p@0.38.x ([#4151](https://www.github.com/ipfs/js-ipfs/issues/4151)) ([39dbf70](https://www.github.com/ipfs/js-ipfs/commit/39dbf708ec31b263115e44f420651fa4e056a89e)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * ipfs-cli bumped from ^0.13.0 to ^0.14.0 + * ipfs-core bumped from ^0.15.0 to ^0.16.0 + * devDependencies + * interface-ipfs-core bumped from ^0.155.0 to ^0.156.0 + * ipfs-client bumped from ^0.8.0 to ^0.9.0 + * ipfs-core-types bumped from ^0.11.0 to ^0.12.0 + * ipfs-http-client bumped from ^57.0.0 to ^58.0.0 + ### [0.63.5](https://www.github.com/ipfs/js-ipfs/compare/ipfs-v0.63.4...ipfs-v0.63.5) (2022-06-24) @@ -3011,4 +3088,4 @@ Signed-off-by: Alan Shaw -## 0.0.2 (2016-01-11) +## 0.0.2 (2016-01-11) \ No newline at end of file diff --git a/packages/ipfs/LICENSE b/packages/ipfs/LICENSE new file mode 100644 index 0000000000..20ce483c86 --- /dev/null +++ b/packages/ipfs/LICENSE @@ -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 diff --git a/packages/ipfs/LICENSE-MIT b/packages/ipfs/LICENSE-MIT index 749aa1ecd9..72dc60d84b 100644 --- a/packages/ipfs/LICENSE-MIT +++ b/packages/ipfs/LICENSE-MIT @@ -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. \ No newline at end of file +THE SOFTWARE. diff --git a/packages/ipfs/README.md b/packages/ipfs/README.md index 8d848afb73..37f6f857b2 100644 --- a/packages/ipfs/README.md +++ b/packages/ipfs/README.md @@ -1,3 +1,28 @@ +# ipfs + +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-ipfs.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-ipfs/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-ipfs/actions/workflows/js-test-and-release.yml) + +> JavaScript implementation of the IPFS specification + +## Table of contents + +- [Install](#install) +- [Getting Started](#getting-started) + - [Next Steps](#next-steps) +- [Want to hack on IPFS?](#want-to-hack-on-ipfs) +- [License](#license) +- [Contribute](#contribute) + +## Install + +```console +$ npm i ipfs +``` +

IPFS in JavaScript logo @@ -24,18 +49,8 @@ If you want to integrate IPFS into your application without including a CLI or HTTP server, see the [ipfs-core](https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-core) module. -## Table of Contents - -- [Getting Started](#getting-started) - - [Install](#install) - - [Next Steps](#next-steps) -- [Want to hack on IPFS?](#want-to-hack-on-ipfs) -- [License](#license) - ## Getting Started -### Install - Installing `ipfs` globally will give you the `jsipfs` command which you can use to start a daemon running: ```console @@ -58,13 +73,13 @@ added QmXXY5ZxbtuYj6DnfApLiGstzPN7fvSyigrRee3hDWPCaf hello-world.txt ### Next Steps -* Read the [docs](https://github.com/ipfs/js-ipfs/tree/master/docs) -* Look into the [examples](https://github.com/ipfs-examples/js-ipfs-examples) to learn how to spawn an IPFS node in Node.js and in the Browser -* Consult the [Core API docs](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) to see what you can do with an IPFS node -* Head over to https://proto.school to take interactive tutorials that cover core IPFS APIs -* Check out https://docs.ipfs.io for tips, how-tos and more -* See https://blog.ipfs.io for news and more -* Need help? Please ask 'How do I?' questions on https://discuss.ipfs.io +- Read the [docs](https://github.com/ipfs/js-ipfs/tree/master/docs) +- Look into the [examples](https://github.com/ipfs-examples/js-ipfs-examples) to learn how to spawn an IPFS node in Node.js and in the Browser +- Consult the [Core API docs](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api) to see what you can do with an IPFS node +- Head over to to take interactive tutorials that cover core IPFS APIs +- Check out for tips, how-tos and more +- See for news and more +- Need help? Please ask 'How do I?' questions on ## Want to hack on IPFS? @@ -85,6 +100,19 @@ Find out about chat channels, the IPFS newsletter, the IPFS blog, and more in th ## License -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fipfs%2Fjs-ipfs?ref=badge_large) +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) -[![](https://github.com/ipfs/js-ipfs/raw/master/packages/interface-ipfs-core/img/badge.png)](https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core) +## Contribute + +Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs/issues). + +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. + +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/ipfs/package.json b/packages/ipfs/package.json index 74cc6f9b0e..d80160a62a 100644 --- a/packages/ipfs/package.json +++ b/packages/ipfs/package.json @@ -1,15 +1,28 @@ { "name": "ipfs", - "version": "0.63.5", + "version": "0.65.0", "description": "JavaScript implementation of the IPFS specification", + "license": "Apache-2.0 OR MIT", + "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "bugs": { + "url": "https://github.com/ipfs/js-ipfs/issues" + }, "keywords": [ "IPFS" ], - "homepage": "https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs#readme", - "bugs": "https://github.com/ipfs/js-ipfs/issues", - "license": "(Apache-2.0 OR MIT)", + "engines": { + "node": ">=16.0.0", + "npm": ">=7.0.0" + }, + "bin": { + "jsipfs": "src/cli.js" + }, "type": "module", - "types": "dist/src/index.d.ts", + "types": "./dist/src/index.d.ts", "typesVersions": { "*": { "*": [ @@ -27,31 +40,27 @@ } }, "files": [ - "dist", "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], - "eslintConfig": { - "extends": "ipfs", - "parserOptions": { - "sourceType": "module" - } - }, "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" }, "./path": { + "types": "./src/path.d.ts", "browser": "./src/path.browser.js", "import": "./src/path.js" } }, - "bin": { - "jsipfs": "src/cli.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" + "eslintConfig": { + "extends": "ipfs", + "parserOptions": { + "sourceType": "module" + } }, "scripts": { "build": "aegir build", @@ -61,35 +70,36 @@ "test:interface:client": "aegir test -f test/interface-client.js", "test:interface:http-js": "aegir test -f test/interface-http-js.js", "test:interface:http-go": "aegir test -f test/interface-http-go.js", - "test:interop": "cross-env DEBUG=$DEBUG IPFS_LOGGING=$IPFS_LOGGING IPFS_JS_EXEC=$PWD/src/cli.js LIBP2P_TCP_REUSEPORT=false ipfs-interop", + "test:interop": "cross-env DEBUG=$DEBUG IPFS_LOGGING=$IPFS_LOGGING IPFS_JS_EXEC=$PWD/src/cli.js KUBO_RPC_MODULE=$PWD/../ipfs-http-client/src/index.js LIBP2P_TCP_REUSEPORT=false ipfs-interop", "test:external": "aegir test-dependant", "clean": "aegir clean", "dep-check": "aegir dep-check -i ipfs-core-types -i @types/*" }, "dependencies": { - "@libp2p/logger": "^1.1.4", - "ipfs-cli": "^0.13.5", - "ipfs-core": "^0.15.4", + "@libp2p/logger": "^2.0.0", + "ipfs-cli": "^0.15.0", + "ipfs-core": "^0.17.0", "semver": "^7.3.2", - "update-notifier": "^5.0.0" + "update-notifier": "^6.0.0" }, "devDependencies": { - "@libp2p/webrtc-star-signalling-server": "^1.0.3", - "@libp2p/websockets": "^1.0.8", + "@libp2p/webrtc-star-signalling-server": "^2.0.1", + "@libp2p/websockets": "^5.0.0", "@types/semver": "^7.3.4", - "@types/update-notifier": "^5.0.0", + "@types/update-notifier": "^6.0.1", "aegir": "^37.0.11", "cross-env": "^7.0.0", "electron-webrtc": "^0.3.0", - "go-ipfs": "^0.12.1", - "interface-ipfs-core": "^0.155.2", - "ipfs-client": "^0.8.3", - "ipfs-core-types": "^0.11.1", - "ipfs-http-client": "^57.0.3", - "ipfs-interop": "ipfs/interop#feat/upgrade-to-esm-libp2p", + "go-ipfs": "^0.12.0", + "interface-ipfs-core": "^0.157.0", + "ipfs-client": "^0.9.2", + "ipfs-core-types": "^0.13.0", + "ipfs-http-client": "^59.0.0", + "ipfs-interop": "ipfs/interop#deps/update-multiformats", "ipfs-utils": "^9.0.6", - "ipfsd-ctl": "^11.0.0", + "ipfsd-ctl": "^12.0.3", "iso-url": "^1.0.0", + "kubo-rpc-client": "^1.0.1", "merge-options": "^3.0.4", "mock-ipfs-pinning-service": "^0.4.2", "url": "^0.11.0", @@ -99,154 +109,5 @@ "./src/cli.js": false, "./src/path.js": "./src/path.browser.js", "go-ipfs": false - }, - "engines": { - "node": ">=15.0.0", - "npm": ">=6.0.0" - }, - "contributors": [ - "0xflotus <0xflotus@gmail.com>", - "A_A <21040751+Otto-AA@users.noreply.github.com>", - "Adam Uhlíř ", - "Alan Shaw ", - "Alan Shaw ", - "Alex North ", - "Alex Potsides ", - "Andrew Nesbitt ", - "Andrew de Andrade ", - "André Cruz ", - "Arkadiy Kukarkin ", - "Arpit Agarwal <93arpit@gmail.com>", - "Arpit Agarwal ", - "Ayush Mahajan ", - "Bernard Mordan ", - "Brian Vander Schaaf ", - "Bruno Zell ", - "CHEVALAY JOSSELIN ", - "Caio Gondim ", - "Chance Hudson ", - "Chirag Shinde ", - "Christian Couder ", - "Dafeng ", - "Dan Ordille ", - "Dan Shields <35669742+NukeManDan@users.noreply.github.com>", - "Daniel Buchner ", - "Daniel J. O'Quinn ", - "Daniela Borges Matos de Carvalho ", - "David Dias ", - "David Gilbertson ", - "David da Silva ", - "Diogo Silva ", - "Dmitriy Ryajov ", - "Dominic Della Valle ", - "Dzmitry Bachko ", - "Enrico Marino ", - "Faheel Ahmad ", - "Felix Yan ", - "Francisco Baio Dias ", - "Francisco Baio Dias ", - "Friedel Ziegelmayer ", - "Gabriel Garrido Calvo ", - "Gar ", - "Georgios Rassias ", - "Gorka Ludlow ", - "Grant Herman ", - "Greenkeeper ", - "Haad ", - "Haoliang Yu ", - "Harsh Vakharia ", - "Henrique Dias ", - "Henry Rodrick ", - "Heo Sangmin ", - "Hugo Dias ", - "Hugo Dias ", - "Irakli Gozalishvili ", - "Jacob Heun ", - "Jacob Heun ", - "Jade Meskill ", - "Jessica Schilling ", - "Johannes Wikner ", - "Jon Schlinkert ", - "Jonathan ", - "Jonybang ", - "Jorropo ", - "João Antunes ", - "João Santos ", - "Kevin Wang ", - "Lars Gierth ", - "Lukas Drgon ", - "Maciej Krüger ", - "Marcin Rataj ", - "Marcus Bernales ", - "Marius Darila ", - "Mark Robert Henderson ", - "Mat Kelly ", - "Michelle Lee ", - "Mikeal Rogers ", - "Mithgol ", - "Molly ", - "Mounish Sai ", - "My9Bot <34904312+My9Bot@users.noreply.github.com>", - "Nick Poulden ", - "Nitin Patel <31539366+niinpatel@users.noreply.github.com>", - "Nuno Nogueira ", - "Oli Evans ", - "Oskar Nyberg ", - "Pascal Precht ", - "Pau Ramon Revilla ", - "Paulo Rodrigues ", - "Pedro Santos ", - "Pedro Santos ", - "Pedro Teixeira ", - "Portia Burton ", - "Prabhakar Poudel ", - "Qmstream <51881352+Qmstream@users.noreply.github.com>", - "Raoul Millais ", - "RasmusErik Voel Jensen ", - "Richard Littauer ", - "Richard Schneider ", - "Rob Brackett ", - "Rod Keys ", - "Sangwon Hong ", - "Sid Harder ", - "SidHarder ", - "Stephen Whitmore ", - "Stephen Whitmore ", - "Steven Allen ", - "Tapasweni Pathak ", - "Terence Pae ", - "Teri Chadbourne ", - "Travis CI ", - "Uroš Jurglič ", - "Vasco Santos ", - "Vasco Santos ", - "Vincent Martin ", - "Volker Mische ", - "Xiao Liang ", - "Yahya ", - "Yole ", - "bitspill ", - "datafatmunger ", - "dirkmc ", - "dirkmc ", - "greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com>", - "greenkeeper[bot] ", - "haad ", - "hapsody ", - "jbenet ", - "jonahweissman <19804455+jonahweissman@users.noreply.github.com>", - "kevingzhang ", - "kumavis ", - "nginnever ", - "npmcdn-to-unpkg-bot ", - "reasv <7143787+reasv@users.noreply.github.com>", - "robbsolter <35879806+robbsolter@users.noreply.github.com>", - "seungwon-kang ", - "swedneck <40505480+swedneck@users.noreply.github.com>", - "tcme ", - "victorbjelkholm ", - "Łukasz Magiera ", - "Максим Ильин ", - "Xmader " - ] + } } diff --git a/packages/ipfs/test/utils/factory.js b/packages/ipfs/test/utils/factory.js index 9d3ec48789..eb435572cc 100644 --- a/packages/ipfs/test/utils/factory.js +++ b/packages/ipfs/test/utils/factory.js @@ -7,7 +7,7 @@ import * as ipfsModule from 'ipfs-core' import goIpfs from 'go-ipfs' import path, { dirname } from 'path' import { fileURLToPath } from 'url' -import { WebSockets } from '@libp2p/websockets' +import { webSockets } from '@libp2p/websockets' import { all as WebSocketsFiltersAll } from '@libp2p/websockets/filters' const merge = mergeOpts.bind({ ignoreUndefined: true }) @@ -29,7 +29,7 @@ const commonOptions = { dialTimeout: 60e3 // increase timeout because travis is slow }, transports: [ - new WebSockets({ + webSockets({ filter: WebSocketsFiltersAll }) ] diff --git a/packages/ipfs/tsconfig.json b/packages/ipfs/tsconfig.json index 2e5e453229..b66401b4d0 100644 --- a/packages/ipfs/tsconfig.json +++ b/packages/ipfs/tsconfig.json @@ -10,14 +10,23 @@ "package.json" ], "references": [ + { + "path": "../interface-ipfs-core" + }, { "path": "../ipfs-cli" }, + { + "path": "../ipfs-client" + }, { "path": "../ipfs-core" }, { "path": "../ipfs-core-types" + }, + { + "path": "../ipfs-http-client" } ] }