diff --git a/packages/interface-ipfs-core/package.json b/packages/interface-ipfs-core/package.json index 4ac707d8ff..59b3aff956 100644 --- a/packages/interface-ipfs-core/package.json +++ b/packages/interface-ipfs-core/package.json @@ -73,7 +73,7 @@ "@libp2p/peer-id": "^1.1.10", "@libp2p/peer-id-factory": "^1.0.10", "@libp2p/websockets": "^3.0.0", - "@multiformats/multiaddr": "^10.4.0", + "@multiformats/multiaddr": "^11.0.0", "@types/node": "^18.0.0", "@types/pako": "^2.0.0", "@types/readable-stream": "^2.3.13", @@ -86,10 +86,10 @@ "err-code": "^3.0.1", "ipfs-core-types": "^0.12.0", "ipfs-unixfs": "^7.0.0", - "ipfs-unixfs-importer": "^10.0.1", + "ipfs-unixfs-importer": "^10.0.2", "ipfs-utils": "^9.0.6", "ipns": "^2.0.2", - "is-ipfs": "^6.0.1", + "is-ipfs": "^7.0.0", "iso-random-stream": "^2.0.2", "it-all": "^1.0.4", "it-buffer-stream": "^2.0.0", 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/miscellaneous/id.js b/packages/interface-ipfs-core/src/miscellaneous/id.js index 507cf19583..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() } }) diff --git a/packages/interface-ipfs-core/src/miscellaneous/resolve.js b/packages/interface-ipfs-core/src/miscellaneous/resolve.js index c013a61330..8ca3fd0eba 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' 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/ipfs-cli/package.json b/packages/ipfs-cli/package.json index d5179f8712..40afa618d6 100644 --- a/packages/ipfs-cli/package.json +++ b/packages/ipfs-cli/package.json @@ -73,7 +73,7 @@ "@libp2p/logger": "^2.0.0", "@libp2p/peer-id": "^1.1.10", "@multiformats/mafmt": "^11.0.2", - "@multiformats/multiaddr": "^10.4.0", + "@multiformats/multiaddr": "^11.0.0", "@multiformats/multiaddr-to-uri": "^9.0.1", "byteman": "^1.3.5", "execa": "^6.1.0", @@ -107,7 +107,7 @@ "@types/rimraf": "^3.0.1", "@types/yargs": "^17.0.10", "aegir": "^37.0.11", - "ipfs-repo": "^15.0.0", + "ipfs-repo": "^15.0.3", "it-all": "^1.0.4", "it-first": "^1.0.4", "it-to-buffer": "^2.0.0", 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/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-core-config/package.json b/packages/ipfs-core-config/package.json index f89645590f..5b66d7adad 100644 --- a/packages/ipfs-core-config/package.json +++ b/packages/ipfs-core-config/package.json @@ -107,9 +107,9 @@ "err-code": "^3.0.1", "hashlru": "^2.3.0", "interface-datastore": "^7.0.0", - "ipfs-repo": "^15.0.0", + "ipfs-repo": "^15.0.3", "ipfs-utils": "^9.0.6", - "is-ipfs": "^6.0.1", + "is-ipfs": "^7.0.0", "it-all": "^1.0.4", "it-drain": "^1.0.3", "it-foreach": "^0.1.1", 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-types/package.json b/packages/ipfs-core-types/package.json index 3c286e5d2c..ecb6b1b797 100644 --- a/packages/ipfs-core-types/package.json +++ b/packages/ipfs-core-types/package.json @@ -52,7 +52,7 @@ "@libp2p/interface-peer-id": "^1.0.4", "@libp2p/interface-peer-info": "^1.0.2", "@libp2p/interface-pubsub": "^2.0.0", - "@multiformats/multiaddr": "^10.4.0", + "@multiformats/multiaddr": "^11.0.0", "@types/node": "^18.0.0", "interface-datastore": "^7.0.0", "ipfs-unixfs": "^7.0.0", diff --git a/packages/ipfs-core-utils/package.json b/packages/ipfs-core-utils/package.json index 96e76dfc8d..30eadda87e 100644 --- a/packages/ipfs-core-utils/package.json +++ b/packages/ipfs-core-utils/package.json @@ -141,7 +141,7 @@ }, "dependencies": { "@libp2p/logger": "^2.0.0", - "@multiformats/multiaddr": "^10.4.0", + "@multiformats/multiaddr": "^11.0.0", "@multiformats/multiaddr-to-uri": "^9.0.1", "any-signal": "^3.0.0", "blob-to-it": "^1.0.1", 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/package.json b/packages/ipfs-core/package.json index b46970be74..4a8c0c3a17 100644 --- a/packages/ipfs-core/package.json +++ b/packages/ipfs-core/package.json @@ -96,7 +96,7 @@ "@libp2p/record": "^2.0.0", "@libp2p/websockets": "^3.0.0", "@multiformats/mafmt": "^11.0.2", - "@multiformats/multiaddr": "^10.4.0", + "@multiformats/multiaddr": "^11.0.0", "@multiformats/multiaddr-to-uri": "^9.0.1", "@multiformats/murmur3": "^1.1.1", "any-signal": "^3.0.0", @@ -116,14 +116,14 @@ "ipfs-core-types": "^0.12.0", "ipfs-core-utils": "^0.16.0", "ipfs-http-client": "^58.0.0", - "ipfs-repo": "^15.0.0", + "ipfs-repo": "^15.0.3", "ipfs-unixfs": "^7.0.0", - "ipfs-unixfs-exporter": "^8.0.4", - "ipfs-unixfs-importer": "^10.0.1", + "ipfs-unixfs-exporter": "^8.0.6", + "ipfs-unixfs-importer": "^10.0.2", "ipfs-utils": "^9.0.6", "ipns": "^2.0.2", "is-domain-name": "^1.0.1", - "is-ipfs": "^6.0.1", + "is-ipfs": "^7.0.0", "it-drain": "^1.0.3", "it-filter": "^1.0.2", "it-first": "^1.0.6", @@ -137,7 +137,7 @@ "it-tar": "^6.0.0", "it-to-buffer": "^2.0.0", "just-safe-set": "^4.0.2", - "libp2p": "^0.39.0", + "libp2p": "^0.39.2", "merge-options": "^3.0.4", "mortice": "^3.0.0", "multiformats": "^9.5.1", @@ -157,7 +157,7 @@ "go-ipfs": "^0.12.1", "interface-blockstore-tests": "^3.0.0", "interface-ipfs-core": "^0.156.0", - "ipfsd-ctl": "^12.0.0", + "ipfsd-ctl": "^12.0.3", "iso-url": "^1.0.0", "it-all": "^1.0.4", "nanoid": "^4.0.0", 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/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/id.js b/packages/ipfs-core/src/components/id.js index f1d89d859a..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' @@ -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/libp2p.js b/packages/ipfs-core/src/components/libp2p.js index ed38d78dd6..3ca9c8517b 100644 --- a/packages/ipfs-core/src/components/libp2p.js +++ b/packages/ipfs-core/src/components/libp2p.js @@ -5,7 +5,7 @@ import { routers } from 'ipfs-core-config/libp2p-pubsub-routers' 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' @@ -36,6 +36,7 @@ const mergeOptions = mergeOpts.bind({ ignoreUndefined: true, concatArrays: true * @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 */ /** @@ -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 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 7f083d15fd..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' @@ -24,6 +24,7 @@ import { BlockStorage } from '../block-storage.js' * @typedef {import('ipfs-bitswap').IPFSBitswap} Bitswap * @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 { @@ -109,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/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/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-daemon/package.json b/packages/ipfs-daemon/package.json index a58f60af50..38233d4eab 100644 --- a/packages/ipfs-daemon/package.json +++ b/packages/ipfs-daemon/package.json @@ -72,7 +72,7 @@ "ipfs-http-gateway": "^0.11.0", "ipfs-http-server": "^0.13.0", "ipfs-utils": "^9.0.6", - "libp2p": "^0.39.0" + "libp2p": "^0.39.2" }, "devDependencies": { "aegir": "^37.0.11", diff --git a/packages/ipfs-grpc-client/package.json b/packages/ipfs-grpc-client/package.json index 99dc9a5aec..7c9022c5a5 100644 --- a/packages/ipfs-grpc-client/package.json +++ b/packages/ipfs-grpc-client/package.json @@ -71,7 +71,7 @@ "@improbable-eng/grpc-web": "^0.15.0", "@libp2p/logger": "^2.0.0", "@libp2p/peer-id": "^1.1.10", - "@multiformats/multiaddr": "^10.4.0", + "@multiformats/multiaddr": "^11.0.0", "change-case": "^4.1.1", "err-code": "^3.0.1", "ipfs-core-types": "^0.12.0", 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-server/package.json b/packages/ipfs-grpc-server/package.json index c1e8b64350..c8cd5f42b1 100644 --- a/packages/ipfs-grpc-server/package.json +++ b/packages/ipfs-grpc-server/package.json @@ -66,7 +66,7 @@ "@grpc/grpc-js": "^1.1.8", "@libp2p/logger": "^2.0.0", "@libp2p/peer-id": "^1.1.10", - "@multiformats/multiaddr": "^10.4.0", + "@multiformats/multiaddr": "^11.0.0", "change-case": "^4.1.1", "coercer": "^1.1.2", "ipfs-core-types": "^0.12.0", 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-http-client/package.json b/packages/ipfs-http-client/package.json index 442d52086b..9a82824420 100644 --- a/packages/ipfs-http-client/package.json +++ b/packages/ipfs-http-client/package.json @@ -72,7 +72,7 @@ "@ipld/dag-pb": "^2.1.3", "@libp2p/logger": "^2.0.0", "@libp2p/peer-id": "^1.1.10", - "@multiformats/multiaddr": "^10.4.0", + "@multiformats/multiaddr": "^11.0.0", "any-signal": "^3.0.0", "dag-jose": "^2.0.1", "err-code": "^3.0.1", @@ -91,7 +91,7 @@ "aegir": "^37.0.11", "delay": "^5.0.0", "go-ipfs": "^0.12.1", - "ipfsd-ctl": "^12.0.0", + "ipfsd-ctl": "^12.0.3", "it-all": "^1.0.4", "it-first": "^1.0.4", "nock": "^13.0.2", 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 c08cd50f33..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/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: ??? } @@ -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/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/package.json b/packages/ipfs-http-gateway/package.json index 2f34368f8d..91e2b6a52b 100644 --- a/packages/ipfs-http-gateway/package.json +++ b/packages/ipfs-http-gateway/package.json @@ -71,16 +71,16 @@ "@hapi/boom": "^9.1.0", "@hapi/hapi": "^20.0.0", "@libp2p/logger": "^2.0.0", + "@multiformats/uri-to-multiaddr": "^7.0.0", "hapi-pino": "^8.5.0", "ipfs-core-types": "^0.12.0", "ipfs-http-response": "^4.0.0", - "is-ipfs": "^6.0.1", + "is-ipfs": "^7.0.0", "it-last": "^1.0.4", "it-to-stream": "^1.0.0", "joi": "^17.2.1", "multiformats": "^9.5.1", - "uint8arrays": "^3.0.0", - "uri-to-multiaddr": "^6.0.0" + "uint8arrays": "^3.0.0" }, "devDependencies": { "@types/hapi-pino": "^8.0.1", 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..e8f752cbe5 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' diff --git a/packages/ipfs-http-response/package.json b/packages/ipfs-http-response/package.json index bbe3898ae6..c1003a4a9c 100644 --- a/packages/ipfs-http-response/package.json +++ b/packages/ipfs-http-response/package.json @@ -84,7 +84,7 @@ "aegir": "^37.0.11", "get-stream": "^6.0.0", "ipfs-core": "^0.16.0", - "ipfsd-ctl": "^12.0.0", + "ipfsd-ctl": "^12.0.3", "it-all": "^1.0.4", "uint8arrays": "^3.0.0" }, diff --git a/packages/ipfs-http-server/package.json b/packages/ipfs-http-server/package.json index 4f59dc357a..f6ebb898a9 100644 --- a/packages/ipfs-http-server/package.json +++ b/packages/ipfs-http-server/package.json @@ -72,7 +72,8 @@ "@libp2p/interfaces": "^3.0.3", "@libp2p/logger": "^2.0.0", "@libp2p/peer-id": "^1.1.10", - "@multiformats/multiaddr": "^10.4.0", + "@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", @@ -96,8 +97,7 @@ "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": "^3.0.0" }, "devDependencies": { "@types/hapi-pino": "^8.0.1", 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/package.json b/packages/ipfs/package.json index ba89ea6b45..5781d9f66b 100644 --- a/packages/ipfs/package.json +++ b/packages/ipfs/package.json @@ -95,9 +95,9 @@ "ipfs-client": "^0.9.0", "ipfs-core-types": "^0.12.0", "ipfs-http-client": "^58.0.0", - "ipfs-interop": "^9.0.0", + "ipfs-interop": "ipfs/interop#deps/update-multiformats-multiaddr", "ipfs-utils": "^9.0.6", - "ipfsd-ctl": "^12.0.0", + "ipfsd-ctl": "^12.0.3", "iso-url": "^1.0.0", "merge-options": "^3.0.4", "mock-ipfs-pinning-service": "^0.4.2",