From 0cee4a4c55767022584dcbade0b0b9b43326f9c9 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Mon, 24 Oct 2022 10:08:56 +0200 Subject: [PATCH] feat!: upgrade libp2p to 0.40.x (#4237) Upgrades all deps to support `libp2p@0.40.x`. BREAKING CHANGE: ipfs is now bundled with libp2p@0.40.x which has different config --- .github/workflows/test.yml | 18 +-- package.json | 2 +- packages/interface-ipfs-core/package.json | 36 ++--- .../src/miscellaneous/dns.js | 30 ++++- .../src/miscellaneous/resolve.js | 16 ++- .../interface-ipfs-core/src/name/resolve.js | 126 +++++++++++++++--- .../ipfs-options-websockets-filter-all.js | 4 +- .../interface-ipfs-core/src/utils/mocha.js | 1 - packages/ipfs-cli/package.json | 26 ++-- packages/ipfs-cli/src/commands/add.js | 2 +- packages/ipfs-cli/src/commands/block/put.js | 4 +- packages/ipfs-cli/src/commands/cid/format.js | 2 +- packages/ipfs-cli/src/commands/dag/put.js | 6 +- packages/ipfs-cli/src/commands/files/mkdir.js | 2 +- packages/ipfs-cli/src/commands/files/mv.js | 2 +- packages/ipfs-cli/src/commands/files/touch.js | 2 +- packages/ipfs-cli/src/commands/files/write.js | 2 +- .../src/commands/object/patch/append-data.js | 2 +- .../src/commands/object/patch/set-data.js | 2 +- packages/ipfs-cli/src/commands/object/put.js | 2 +- packages/ipfs-cli/test/object.spec.js | 6 +- packages/ipfs-core-config/package.json | 22 +-- .../src/libp2p-pubsub-routers.browser.js | 36 +++-- .../src/libp2p-pubsub-routers.js | 40 ++++-- .../ipfs-core-config/src/libp2p.browser.js | 6 +- packages/ipfs-core-config/src/libp2p.js | 8 +- packages/ipfs-core-types/package.json | 8 +- packages/ipfs-core-types/src/block/index.ts | 2 +- packages/ipfs-core-types/src/dag/index.ts | 2 +- packages/ipfs-core-types/src/files/index.ts | 2 +- packages/ipfs-core-types/src/root.ts | 2 +- packages/ipfs-core-utils/package.json | 16 +-- .../src/files/normalise-candidate-single.js | 1 - packages/ipfs-core/.aegir.js | 12 +- packages/ipfs-core/package.json | 84 ++++++------ .../ipfs-core/src/components/block/put.js | 2 +- .../ipfs-core/src/components/dag/export.js | 8 +- .../ipfs-core/src/components/files/chmod.js | 2 +- packages/ipfs-core/src/components/files/cp.js | 2 +- .../ipfs-core/src/components/files/mkdir.js | 2 +- packages/ipfs-core/src/components/files/mv.js | 2 +- packages/ipfs-core/src/components/files/rm.js | 2 +- .../ipfs-core/src/components/files/touch.js | 2 +- .../src/components/files/utils/add-link.js | 2 +- .../src/components/files/utils/create-node.js | 2 +- .../src/components/files/utils/dir-sharded.js | 2 +- .../src/components/files/utils/hamt-utils.js | 2 +- .../src/components/files/utils/persist.js | 2 +- .../src/components/files/utils/remove-link.js | 2 +- .../src/components/files/utils/update-tree.js | 2 +- .../ipfs-core/src/components/files/write.js | 2 +- packages/ipfs-core/src/components/libp2p.js | 46 ++++--- packages/ipfs-daemon/package.json | 4 +- packages/ipfs-daemon/src/index.js | 6 +- packages/ipfs-grpc-client/package.json | 10 +- packages/ipfs-grpc-server/package.json | 12 +- packages/ipfs-http-client/package.json | 22 +-- packages/ipfs-http-gateway/package.json | 8 +- packages/ipfs-http-response/package.json | 13 +- .../ipfs-http-response/src/dir-view/index.js | 2 +- packages/ipfs-http-response/src/index.js | 6 +- .../src/utils/content-type.js | 4 +- packages/ipfs-http-server/package.json | 28 ++-- packages/ipfs-message-port-client/.aegir.js | 12 +- .../ipfs-message-port-client/package.json | 8 +- .../ipfs-message-port-protocol/package.json | 4 +- .../ipfs-message-port-protocol/src/cid.js | 1 - .../ipfs-message-port-server/package.json | 4 +- packages/ipfs-message-port-server/src/core.js | 2 +- packages/ipfs/.aegir.js | 12 +- packages/ipfs/package.json | 9 +- packages/ipfs/test/utils/factory.js | 4 +- 72 files changed, 466 insertions(+), 323 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5c9436e3a6..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 diff --git a/package.json b/package.json index e9d95e8489..824f5a9ed5 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "docker:rc:push-rc": "docker push ipfs/js-ipfs:v`npm show ipfs@next version -q`" }, "devDependencies": { - "lerna": "^5.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" diff --git a/packages/interface-ipfs-core/package.json b/packages/interface-ipfs-core/package.json index b6fea6e411..350bdc6acd 100644 --- a/packages/interface-ipfs-core/package.json +++ b/packages/interface-ipfs-core/package.json @@ -64,15 +64,15 @@ "dep-check": "aegir dep-check -i ipfs-core-types -i copyfiles -i @libp2p/interfaces" }, "dependencies": { - "@ipld/car": "^4.1.0", - "@ipld/dag-cbor": "^7.0.0", - "@ipld/dag-pb": "^2.1.3", + "@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": "^3.0.0", + "@libp2p/websockets": "^5.0.0", "@multiformats/multiaddr": "^11.0.0", "@types/node": "^18.0.0", "@types/pako": "^2.0.0", @@ -80,30 +80,30 @@ "aegir": "^37.0.11", "blockstore-core": "^2.0.1", "copyfiles": "^2.4.1", - "dag-jose": "^2.0.1", + "dag-jose": "^3.0.1", "delay": "^5.0.0", "did-jwt": "^6.2.0", "err-code": "^3.0.1", "ipfs-core-types": "^0.12.1", - "ipfs-unixfs": "^7.0.0", - "ipfs-unixfs-importer": "^10.0.2", + "ipfs-unixfs": "^8.0.0", + "ipfs-unixfs-importer": "^11.0.0", "ipfs-utils": "^9.0.6", - "ipns": "^3.0.0", + "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.6", - "it-last": "^1.0.4", - "it-map": "^1.0.6", + "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": "^3.0.0", "it-tar": "^6.0.0", - "it-to-buffer": "^2.0.0", + "it-to-buffer": "^3.0.0", "merge-options": "^3.0.4", - "multiformats": "^9.5.1", + "multiformats": "^10.0.0", "nanoid": "^4.0.0", "p-defer": "^4.0.0", "p-map": "^5.3.0", @@ -112,7 +112,7 @@ "pako": "^2.0.4", "readable-stream": "^4.0.0", "sinon": "^14.0.0", - "uint8arrays": "^3.0.0" + "uint8arrays": "^4.0.2" }, "browser": { "fs": false, 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/resolve.js b/packages/interface-ipfs-core/src/miscellaneous/resolve.js index 8ca3fd0eba..49e004c4fa 100644 --- a/packages/interface-ipfs-core/src/miscellaneous/resolve.js +++ b/packages/interface-ipfs-core/src/miscellaneous/resolve.js @@ -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/resolve.js b/packages/interface-ipfs-core/src/name/resolve.js index f1fa281733..69deee2ff9 100644 --- a/packages/interface-ipfs-core/src/name/resolve.js +++ b/packages/interface-ipfs-core/src/name/resolve.js @@ -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/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/package.json b/packages/ipfs-cli/package.json index 5156fddad3..f13d967ba3 100644 --- a/packages/ipfs-cli/package.json +++ b/packages/ipfs-cli/package.json @@ -67,9 +67,9 @@ "build": "aegir build --no-bundle" }, "dependencies": { - "@ipld/dag-cbor": "^7.0.0", - "@ipld/dag-json": "^8.0.1", - "@ipld/dag-pb": "^2.1.3", + "@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", @@ -84,18 +84,18 @@ "ipfs-daemon": "^0.14.2", "ipfs-http-client": "^58.0.1", "ipfs-utils": "^9.0.6", - "it-concat": "^2.0.0", - "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-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": { @@ -106,11 +106,11 @@ "@types/rimraf": "^3.0.1", "@types/yargs": "^17.0.10", "aegir": "^37.0.11", - "ipfs-repo": "^15.0.3", - "it-all": "^1.0.4", - "it-first": "^1.0.4", - "it-map": "^1.0.6", - "it-to-buffer": "^2.0.0", + "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", 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/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/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 { 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-core-config/package.json b/packages/ipfs-core-config/package.json index ce76cd7e38..7d903f97a8 100644 --- a/packages/ipfs-core-config/package.json +++ b/packages/ipfs-core-config/package.json @@ -95,26 +95,26 @@ }, "dependencies": { "@chainsafe/libp2p-gossipsub": "^4.0.0", - "@libp2p/floodsub": "^3.0.0", - "@libp2p/logger": "^2.0.0", - "@libp2p/mdns": "^3.0.0", - "@libp2p/tcp": "^3.0.1", - "@libp2p/webrtc-star": "^3.0.0", - "blockstore-datastore-adapter": "^3.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": "^7.0.0", - "ipfs-repo": "^15.0.3", + "ipfs-repo": "^16.0.0", "ipfs-utils": "^9.0.6", "is-ipfs": "^7.0.0", - "it-all": "^1.0.4", - "it-drain": "^1.0.3", - "it-foreach": "^0.1.1", + "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", 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 d2749def9a..476df5b6c4 100644 --- a/packages/ipfs-core-config/src/libp2p-pubsub-routers.browser.js +++ b/packages/ipfs-core-config/src/libp2p-pubsub-routers.browser.js @@ -2,13 +2,33 @@ import { GossipSub } from '@chainsafe/libp2p-gossipsub' /** @typedef {import('@libp2p/interface-pubsub').PubSub} PubSub */ -/** @type {() => Record}>} */ +/** @type {() => Record PubSub>}>} */ export const routers = () => ({ - gossipsub: new GossipSub({ - allowPublishToZeroPeers: true, - fallbackToFloodsub: true, - emitSelf: true, - maxInboundStreams: 64, - maxOutboundStreams: 128 - }) + // @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 b21da2882a..1d5dd7cb5e 100644 --- a/packages/ipfs-core-config/src/libp2p-pubsub-routers.js +++ b/packages/ipfs-core-config/src/libp2p-pubsub-routers.js @@ -1,18 +1,38 @@ import { GossipSub } from '@chainsafe/libp2p-gossipsub' -import { FloodSub } from '@libp2p/floodsub' +import { floodsub } from '@libp2p/floodsub' /** @typedef {import('@libp2p/interface-pubsub').PubSub} PubSub */ -/** @type {() => Record}>} */ +/** @type {() => Record PubSub>}>} */ export const routers = () => ({ - gossipsub: new GossipSub({ - allowPublishToZeroPeers: true, - fallbackToFloodsub: true, - emitSelf: true, - maxInboundStreams: 64, - maxOutboundStreams: 128 - }), - 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-types/package.json b/packages/ipfs-core-types/package.json index 7a5daf7c69..6db01f2275 100644 --- a/packages/ipfs-core-types/package.json +++ b/packages/ipfs-core-types/package.json @@ -47,16 +47,16 @@ "build": "aegir build" }, "dependencies": { - "@ipld/dag-pb": "^2.1.3", + "@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": "^2.0.0", + "@libp2p/interface-pubsub": "^3.0.0", "@multiformats/multiaddr": "^11.0.0", "@types/node": "^18.0.0", "interface-datastore": "^7.0.0", - "ipfs-unixfs": "^7.0.0", - "multiformats": "^9.5.1" + "ipfs-unixfs": "^8.0.0", + "multiformats": "^10.0.0" }, "devDependencies": { "aegir": "^37.0.11" 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/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/root.ts b/packages/ipfs-core-types/src/root.ts index a761e201c2..c12ad0e832 100644 --- a/packages/ipfs-core-types/src/root.ts +++ b/packages/ipfs-core-types/src/root.ts @@ -1,5 +1,5 @@ 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/interface-peer-id' diff --git a/packages/ipfs-core-utils/package.json b/packages/ipfs-core-utils/package.json index 9fb748860d..521618280e 100644 --- a/packages/ipfs-core-utils/package.json +++ b/packages/ipfs-core-utils/package.json @@ -144,22 +144,22 @@ "@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.12.1", - "ipfs-unixfs": "^7.0.0", + "ipfs-unixfs": "^8.0.0", "ipfs-utils": "^9.0.6", - "it-all": "^1.0.4", - "it-map": "^1.0.6", - "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", + "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/.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/package.json b/packages/ipfs-core/package.json index 0b889bb92f..4f9ffcd02d 100644 --- a/packages/ipfs-core/package.json +++ b/packages/ipfs-core/package.json @@ -74,77 +74,77 @@ "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": "^8.0.0", - "@ipld/car": "^4.1.0", - "@ipld/dag-cbor": "^7.0.0", - "@ipld/dag-json": "^8.0.1", - "@ipld/dag-pb": "^2.1.3", - "@libp2p/bootstrap": "^2.0.0", + "@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": "^2.0.1", - "@libp2p/delegated-peer-routing": "^2.0.1", - "@libp2p/interface-dht": "^1.0.1", + "@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.4", - "@libp2p/interface-transport": "^1.0.2", + "@libp2p/interface-peer-id": "^1.0.5", + "@libp2p/interface-transport": "^2.0.0", "@libp2p/interfaces": "^3.0.3", - "@libp2p/kad-dht": "^3.0.0", - "@libp2p/logger": "^2.0.0", - "@libp2p/mplex": "^5.2.0", - "@libp2p/peer-id": "^1.1.10", - "@libp2p/peer-id-factory": "^1.0.10", - "@libp2p/record": "^2.0.0", - "@libp2p/websockets": "^3.0.0", + "@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": "^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": "^2.0.1", - "dag-jose": "^2.0.1", + "dag-jose": "^3.0.1", "datastore-core": "^8.0.1", - "datastore-pubsub": "^4.0.2", + "datastore-pubsub": "^6.0.0", "dlv": "^1.1.3", "err-code": "^3.0.1", "hamt-sharding": "^3.0.0", "hashlru": "^2.3.0", "interface-blockstore": "^3.0.0", "interface-datastore": "^7.0.0", - "ipfs-bitswap": "^12.0.3", + "ipfs-bitswap": "^13.0.0", "ipfs-core-config": "^0.5.1", "ipfs-core-types": "^0.12.1", "ipfs-core-utils": "^0.16.1", "ipfs-http-client": "^58.0.1", - "ipfs-repo": "^15.0.3", - "ipfs-unixfs": "^7.0.0", - "ipfs-unixfs-exporter": "^8.0.6", - "ipfs-unixfs-importer": "^10.0.2", + "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": "^3.0.0", + "ipns": "^4.0.0", "is-domain-name": "^1.0.1", "is-ipfs": "^7.0.0", - "it-drain": "^1.0.3", - "it-filter": "^1.0.2", - "it-first": "^1.0.6", - "it-last": "^1.0.4", - "it-map": "^1.0.6", - "it-merge": "^1.0.3", - "it-parallel": "^2.0.1", - "it-peekable": "^1.0.2", + "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": "^3.0.0", "it-tar": "^6.0.0", - "it-to-buffer": "^2.0.0", + "it-to-buffer": "^3.0.0", "just-safe-set": "^4.0.2", - "libp2p": "^0.39.2", + "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": "^4.0.0", @@ -152,14 +152,14 @@ "@types/pako": "^2.0.0", "@types/rimraf": "^3.0.1", "aegir": "^37.0.11", - "blockstore-datastore-adapter": "^3.0.0", + "blockstore-datastore-adapter": "^4.0.0", "delay": "^5.0.0", - "go-ipfs": "^0.12.1", + "go-ipfs": "^0.12.0", "interface-blockstore-tests": "^3.0.0", "interface-ipfs-core": "^0.156.1", "ipfsd-ctl": "^12.0.3", "iso-url": "^1.0.0", - "it-all": "^1.0.4", + "it-all": "^2.0.0", "nanoid": "^4.0.0", "p-defer": "^4.0.0", "rimraf": "^3.0.2", 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/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/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/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-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 9e81518b39..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 diff --git a/packages/ipfs-core/src/components/libp2p.js b/packages/ipfs-core/src/components/libp2p.js index 3ca9c8517b..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 { 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 }) @@ -125,13 +125,13 @@ function getLibp2pOptions ({ options, config, datastore, keychainConfig, peerId, peerDiscovery: [], transports: [], streamMuxers: [ - new Mplex({ + mplex({ maxInboundStreams: 256, maxOutboundStreams: 1024 }) ], connectionEncryption: [ - new Noise() + noise() ], relay: { enabled: get(options, 'relay.enabled', get(config, 'relay.enabled', true)), @@ -150,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: { @@ -166,7 +166,7 @@ function getLibp2pOptions ({ options, config, datastore, keychainConfig, peerId, if (boostrapNodes.length > 0) { libp2pOptions.peerDiscovery?.push( - new Bootstrap({ + bootstrap({ list: boostrapNodes }) ) @@ -207,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 }) } @@ -222,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-daemon/package.json b/packages/ipfs-daemon/package.json index 32c9cd255c..3ffddb23c5 100644 --- a/packages/ipfs-daemon/package.json +++ b/packages/ipfs-daemon/package.json @@ -64,7 +64,7 @@ }, "dependencies": { "@libp2p/logger": "^2.0.0", - "@libp2p/webrtc-star": "^3.0.0", + "@libp2p/webrtc-star": "^5.0.2", "@mapbox/node-pre-gyp": "^1.0.5", "ipfs-core": "^0.16.1", "ipfs-core-types": "^0.12.1", @@ -72,7 +72,7 @@ "ipfs-http-gateway": "^0.11.1", "ipfs-http-server": "^0.13.2", "ipfs-utils": "^9.0.6", - "libp2p": "^0.39.2" + "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/package.json b/packages/ipfs-grpc-client/package.json index 0978bfc1fe..7ba287b0e0 100644 --- a/packages/ipfs-grpc-client/package.json +++ b/packages/ipfs-grpc-client/package.json @@ -77,19 +77,19 @@ "ipfs-core-types": "^0.12.1", "ipfs-core-utils": "^0.16.1", "ipfs-grpc-protocol": "^0.7.0", - "ipfs-unixfs": "^7.0.0", - "it-first": "^1.0.6", + "ipfs-unixfs": "^8.0.0", + "it-first": "^2.0.0", "it-pushable": "^3.0.0", - "multiformats": "^9.5.1", + "multiformats": "^10.0.0", "p-defer": "^4.0.0", "protobufjs": "^7.0.0", - "uint8arrays": "^3.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" }, diff --git a/packages/ipfs-grpc-server/package.json b/packages/ipfs-grpc-server/package.json index 1f8fe443fd..f1be1b9bfb 100644 --- a/packages/ipfs-grpc-server/package.json +++ b/packages/ipfs-grpc-server/package.json @@ -71,22 +71,22 @@ "coercer": "^1.1.2", "ipfs-core-types": "^0.12.1", "ipfs-grpc-protocol": "^0.7.0", - "it-first": "^1.0.6", - "it-map": "^1.0.6", - "it-peekable": "^1.0.2", + "it-first": "^2.0.0", + "it-map": "^2.0.0", + "it-peekable": "^2.0.0", "it-pipe": "^2.0.3", "it-pushable": "^3.0.0", "nanoid": "^4.0.0", "protobufjs": "^7.0.0", - "uint8arrays": "^3.0.0", + "uint8arrays": "^4.0.2", "ws": "^8.5.0" }, "devDependencies": { "@types/ws": "^8.5.3", "aegir": "^37.0.11", "ipfs-core": "^0.16.1", - "it-all": "^1.0.4", - "it-drain": "^1.0.3", + "it-all": "^2.0.0", + "it-drain": "^2.0.0", "sinon": "^14.0.0" } } diff --git a/packages/ipfs-http-client/package.json b/packages/ipfs-http-client/package.json index 42ba926c9c..4f3ce60095 100644 --- a/packages/ipfs-http-client/package.json +++ b/packages/ipfs-http-client/package.json @@ -67,33 +67,33 @@ "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", + "@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": "^2.0.1", + "dag-jose": "^3.0.1", "err-code": "^3.0.1", "ipfs-core-types": "^0.12.1", "ipfs-core-utils": "^0.16.1", "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": "^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", + "go-ipfs": "^0.12.0", "ipfsd-ctl": "^12.0.3", - "it-all": "^1.0.4", - "it-first": "^1.0.4", + "it-all": "^2.0.0", + "it-first": "^2.0.0", "nock": "^13.0.2", "p-defer": "^4.0.0" }, diff --git a/packages/ipfs-http-gateway/package.json b/packages/ipfs-http-gateway/package.json index d3b1c0f41a..b3afa2a0cf 100644 --- a/packages/ipfs-http-gateway/package.json +++ b/packages/ipfs-http-gateway/package.json @@ -76,17 +76,17 @@ "ipfs-core-types": "^0.12.1", "ipfs-http-response": "^4.0.1", "is-ipfs": "^7.0.0", - "it-last": "^1.0.4", + "it-last": "^2.0.0", "it-to-stream": "^1.0.0", "joi": "^17.2.1", - "multiformats": "^9.5.1", - "uint8arrays": "^3.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-response/package.json b/packages/ipfs-http-response/package.json index 7fa2ca6d0e..60938387dd 100644 --- a/packages/ipfs-http-response/package.json +++ b/packages/ipfs-http-response/package.json @@ -68,11 +68,10 @@ "dependencies": { "@libp2p/logger": "^2.0.0", "ejs": "^3.1.6", - "file-type": "^17.1.1", - "filesize": "^9.0.11", - "it-buffer": "^0.1.1", - "it-concat": "^2.0.0", - "it-map": "^1.0.6", + "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", @@ -85,8 +84,8 @@ "get-stream": "^6.0.0", "ipfs-core": "^0.16.1", "ipfsd-ctl": "^12.0.3", - "it-all": "^1.0.4", - "uint8arrays": "^3.0.0" + "it-all": "^2.0.0", + "uint8arrays": "^4.0.2" }, "browser": { "file-type": "file-type/browser", 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 eff8d80a83..7f0c912d82 100644 --- a/packages/ipfs-http-response/src/utils/content-type.js +++ b/packages/ipfs-http-response/src/utils/content-type.js @@ -39,7 +39,9 @@ export const detectContentType = async (path, source) => { 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 diff --git a/packages/ipfs-http-server/package.json b/packages/ipfs-http-server/package.json index 4dd51c632b..381f6d1657 100644 --- a/packages/ipfs-http-server/package.json +++ b/packages/ipfs-http-server/package.json @@ -67,7 +67,7 @@ "@hapi/boom": "^9.1.0", "@hapi/content": "^5.0.2", "@hapi/hapi": "^20.0.0", - "@ipld/dag-pb": "^2.1.3", + "@ipld/dag-pb": "^3.0.0", "@libp2p/interface-dht": "^1.0.1", "@libp2p/interfaces": "^3.0.3", "@libp2p/logger": "^2.0.0", @@ -80,24 +80,24 @@ "ipfs-core-types": "^0.12.1", "ipfs-core-utils": "^0.16.1", "ipfs-http-gateway": "^0.11.1", - "ipfs-unixfs": "^7.0.0", - "it-all": "^1.0.4", - "it-drain": "^1.0.3", - "it-filter": "^1.0.2", - "it-last": "^1.0.4", - "it-map": "^1.0.6", - "it-merge": "^1.0.3", - "it-multipart": "^2.0.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": "^3.0.0", - "it-reduce": "^1.0.5", + "it-reduce": "^2.0.0", "joi": "^17.2.1", "just-safe-set": "^4.0.2", - "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" + "uint8arrays": "^4.0.2" }, "devDependencies": { "@types/hapi-pino": "^8.0.1", @@ -108,8 +108,8 @@ "form-data": "^4.0.0", "ipfs-http-client": "^58.0.1", "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-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/package.json b/packages/ipfs-message-port-client/package.json index 95a7a04465..1c468bce19 100644 --- a/packages/ipfs-message-port-client/package.json +++ b/packages/ipfs-message-port-client/package.json @@ -64,13 +64,13 @@ "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.12.1", "ipfs-message-port-protocol": "^0.13.1", - "ipfs-unixfs": "^7.0.0", - "it-peekable": "^1.0.2", - "multiformats": "^9.5.1" + "ipfs-unixfs": "^8.0.0", + "it-peekable": "^2.0.0", + "multiformats": "^10.0.0" }, "devDependencies": { "aegir": "^37.0.11", diff --git a/packages/ipfs-message-port-protocol/package.json b/packages/ipfs-message-port-protocol/package.json index 1a2b7c9535..531d955f25 100644 --- a/packages/ipfs-message-port-protocol/package.json +++ b/packages/ipfs-message-port-protocol/package.json @@ -88,10 +88,10 @@ }, "dependencies": { "ipfs-core-types": "^0.12.1", - "multiformats": "^9.5.1" + "multiformats": "^10.0.0" }, "devDependencies": { "aegir": "^37.0.11", - "uint8arrays": "^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/package.json b/packages/ipfs-message-port-server/package.json index 3ba12133cd..ccc9192a41 100644 --- a/packages/ipfs-message-port-server/package.json +++ b/packages/ipfs-message-port-server/package.json @@ -94,11 +94,11 @@ "dependencies": { "ipfs-core-types": "^0.12.1", "ipfs-message-port-protocol": "^0.13.1", - "it-all": "^1.0.4" + "it-all": "^2.0.0" }, "devDependencies": { "aegir": "^37.0.11", - "multiformats": "^9.5.1" + "multiformats": "^10.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/package.json b/packages/ipfs/package.json index 5f3f4281ca..77f19fc64a 100644 --- a/packages/ipfs/package.json +++ b/packages/ipfs/package.json @@ -70,7 +70,7 @@ "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/*" @@ -84,21 +84,22 @@ }, "devDependencies": { "@libp2p/webrtc-star-signalling-server": "^2.0.1", - "@libp2p/websockets": "^3.0.0", + "@libp2p/websockets": "^5.0.0", "@types/semver": "^7.3.4", "@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", + "go-ipfs": "^0.12.0", "interface-ipfs-core": "^0.156.1", "ipfs-client": "^0.9.1", "ipfs-core-types": "^0.12.1", "ipfs-http-client": "^58.0.1", - "ipfs-interop": "^9.0.1", + "ipfs-interop": "ipfs/interop#deps/update-multiformats", "ipfs-utils": "^9.0.6", "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", 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 }) ]