diff --git a/.aegir.js b/.aegir.js index 63eb11ed9..149fff948 100644 --- a/.aegir.js +++ b/.aegir.js @@ -6,7 +6,7 @@ const getPort = require('aegir/utils/get-port') /** @type {import('aegir').PartialOptions} */ module.exports = { build: { - bundlesizeMax: '106kB' + bundlesizeMax: '96KB' }, test: { async before (options) { diff --git a/package.json b/package.json index f00443eb6..98bcdeb06 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "form-data": "^4.0.0", "ipfs-core-types": "^0.3.1", "ipfs-core-utils": "^0.7.2", - "ipfs-unixfs": "^4.0.1", + "ipfs-unixfs": "^4.0.3", "ipfs-utils": "^6.0.4", "ipld": "^0.29.0", "ipld-block": "^0.11.0", @@ -60,26 +60,26 @@ "ipld-raw": "^7.0.0", "it-last": "^1.0.4", "it-map": "^1.0.4", - "it-tar": "^1.2.2", - "it-to-stream": "^0.1.2", + "it-tar": "^3.0.0", + "it-to-stream": "^1.0.0", "merge-options": "^3.0.4", - "multiaddr": "^8.0.0", + "multiaddr": "^9.0.1", "multibase": "^4.0.2", "multicodec": "^3.0.1", "multihashes": "^4.0.2", "nanoid": "^3.1.12", "native-abort-controller": "^1.0.3", - "parse-duration": "^0.4.4", + "parse-duration": "^1.0.0", "stream-to-it": "^0.2.2", "uint8arrays": "^2.1.3" }, "devDependencies": { - "aegir": "^32.1.0", + "aegir": "^33.0.0", "delay": "^5.0.0", "go-ipfs": "0.8.0", - "ipfsd-ctl": "^8.0.0", + "ipfsd-ctl": "^8.0.1", "it-all": "^1.0.4", - "it-concat": "^1.0.3", + "it-concat": "^2.0.0", "it-first": "^1.0.4", "nock": "^13.0.2", "rimraf": "^3.0.2" diff --git a/src/bootstrap/add.js b/src/bootstrap/add.js index 35afcc4bf..6caa170a8 100644 --- a/src/bootstrap/add.js +++ b/src/bootstrap/add.js @@ -2,7 +2,7 @@ const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') -const Multiaddr = require('multiaddr') +const { Multiaddr } = require('multiaddr') /** * @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions diff --git a/src/bootstrap/clear.js b/src/bootstrap/clear.js index 930b258bc..26355bbb5 100644 --- a/src/bootstrap/clear.js +++ b/src/bootstrap/clear.js @@ -2,7 +2,7 @@ const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') -const Multiaddr = require('multiaddr') +const { Multiaddr } = require('multiaddr') /** * @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions diff --git a/src/bootstrap/list.js b/src/bootstrap/list.js index 9c0ac38d7..aad38554b 100644 --- a/src/bootstrap/list.js +++ b/src/bootstrap/list.js @@ -2,7 +2,7 @@ const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') -const Multiaddr = require('multiaddr') +const { Multiaddr } = require('multiaddr') /** * @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions diff --git a/src/bootstrap/reset.js b/src/bootstrap/reset.js index 2959a5385..b958d7870 100644 --- a/src/bootstrap/reset.js +++ b/src/bootstrap/reset.js @@ -2,7 +2,7 @@ const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') -const Multiaddr = require('multiaddr') +const { Multiaddr } = require('multiaddr') /** * @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions diff --git a/src/bootstrap/rm.js b/src/bootstrap/rm.js index f09c15cb8..13cea8dbe 100644 --- a/src/bootstrap/rm.js +++ b/src/bootstrap/rm.js @@ -2,7 +2,7 @@ const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') -const Multiaddr = require('multiaddr') +const { Multiaddr } = require('multiaddr') /** * @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions diff --git a/src/dht/find-peer.js b/src/dht/find-peer.js index 6a70e9cc4..f4eabe537 100644 --- a/src/dht/find-peer.js +++ b/src/dht/find-peer.js @@ -1,7 +1,7 @@ 'use strict' const CID = require('cids') -const multiaddr = require('multiaddr') +const { Multiaddr } = require('multiaddr') const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') const { FinalPeer } = require('./response-types') @@ -31,7 +31,7 @@ module.exports = configure(api => { const { ID, Addrs } = data.Responses[0] return { id: ID, - addrs: (Addrs || []).map((/** @type {string} **/ a) => multiaddr(a)) + addrs: (Addrs || []).map((/** @type {string} **/ a) => new Multiaddr(a)) } } } diff --git a/src/dht/find-provs.js b/src/dht/find-provs.js index c5175a6cd..c431648ae 100644 --- a/src/dht/find-provs.js +++ b/src/dht/find-provs.js @@ -1,7 +1,7 @@ 'use strict' const CID = require('cids') -const multiaddr = require('multiaddr') +const { Multiaddr } = require('multiaddr') const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') const { Provider } = require('./response-types') @@ -31,7 +31,7 @@ module.exports = configure(api => { for (const { ID, Addrs } of message.Responses) { yield { id: ID, - addrs: (Addrs || []).map((/** @type {string} **/ a) => multiaddr(a)) + addrs: (Addrs || []).map((/** @type {string} **/ a) => new Multiaddr(a)) } } } diff --git a/src/dht/provide.js b/src/dht/provide.js index 9ef17a394..878880398 100644 --- a/src/dht/provide.js +++ b/src/dht/provide.js @@ -1,7 +1,7 @@ 'use strict' const CID = require('cids') -const multiaddr = require('multiaddr') +const { Multiaddr } = require('multiaddr') const toCamel = require('../lib/object-to-camel') const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') @@ -34,7 +34,7 @@ module.exports = configure(api => { if (message.responses) { message.responses = message.responses.map((/** @type {{ ID: string, Addrs: string[] }} */ { ID, Addrs }) => ({ id: ID, - addrs: (Addrs || []).map((/** @type {string} **/ a) => multiaddr(a)) + addrs: (Addrs || []).map((/** @type {string} **/ a) => new Multiaddr(a)) })) } else { message.responses = [] diff --git a/src/dht/put.js b/src/dht/put.js index 949bc3f44..d2b88aa89 100644 --- a/src/dht/put.js +++ b/src/dht/put.js @@ -1,7 +1,7 @@ 'use strict' const CID = require('cids') -const multiaddr = require('multiaddr') +const { Multiaddr } = require('multiaddr') const toCamel = require('../lib/object-to-camel') const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') @@ -42,7 +42,7 @@ module.exports = configure(api => { if (message.responses) { message.responses = message.responses.map((/** @type {{ ID: string, Addrs: string[] }} */ { ID, Addrs }) => ({ id: ID, - addrs: (Addrs || []).map(a => multiaddr(a)) + addrs: (Addrs || []).map(a => new Multiaddr(a)) })) } yield message diff --git a/src/dht/query.js b/src/dht/query.js index 4193970f9..429f487ef 100644 --- a/src/dht/query.js +++ b/src/dht/query.js @@ -1,7 +1,7 @@ 'use strict' const CID = require('cids') -const multiaddr = require('multiaddr') +const { Multiaddr } = require('multiaddr') const toCamel = require('../lib/object-to-camel') const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') @@ -31,7 +31,7 @@ module.exports = configure(api => { message.id = new CID(message.id) message.responses = (message.responses || []).map((/** @type {{ ID: string, Addrs: string[] }} */ { ID, Addrs }) => ({ id: ID, - addrs: (Addrs || []).map((/** @type {string} **/ a) => multiaddr(a)) + addrs: (Addrs || []).map((/** @type {string} **/ a) => new Multiaddr(a)) })) yield message } diff --git a/src/id.js b/src/id.js index c7d19610e..6b9c439d5 100644 --- a/src/id.js +++ b/src/id.js @@ -1,7 +1,7 @@ 'use strict' const toCamel = require('./lib/object-to-camel') -const multiaddr = require('multiaddr') +const { Multiaddr } = require('multiaddr') const configure = require('./lib/configure') const toUrlSearchParams = require('./lib/to-url-search-params') @@ -28,7 +28,7 @@ module.exports = configure(api => { } if (output.addresses) { - output.addresses = output.addresses.map((/** @type {string} */ ma) => multiaddr(ma)) + output.addresses = output.addresses.map((/** @type {string} */ ma) => new Multiaddr(ma)) } // @ts-ignore server output is not typed diff --git a/src/index.js b/src/index.js index 5172ceec2..c9c9551b2 100644 --- a/src/index.js +++ b/src/index.js @@ -2,7 +2,7 @@ /* eslint-env browser */ const CID = require('cids') -const multiaddr = require('multiaddr') +const { multiaddr } = require('multiaddr') const multibase = require('multibase') const multicodec = require('multicodec') const multihash = require('multihashes') diff --git a/src/lib/core.js b/src/lib/core.js index 2aafe8149..eb1340716 100644 --- a/src/lib/core.js +++ b/src/lib/core.js @@ -1,6 +1,6 @@ 'use strict' /* eslint-env browser */ -const Multiaddr = require('multiaddr') +const { Multiaddr } = require('multiaddr') const { isBrowser, isWebWorker, isNode } = require('ipfs-utils/src/env') const { default: parseDuration } = require('parse-duration') const log = require('debug')('ipfs-http-client:lib:error-handler') diff --git a/src/swarm/addrs.js b/src/swarm/addrs.js index acd024255..e0880e554 100644 --- a/src/swarm/addrs.js +++ b/src/swarm/addrs.js @@ -1,6 +1,6 @@ 'use strict' -const multiaddr = require('multiaddr') +const { Multiaddr } = require('multiaddr') const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') @@ -26,7 +26,7 @@ module.exports = configure(api => { return Object.keys(Addrs).map(id => ({ id, - addrs: (Addrs[id] || []).map(a => multiaddr(a)) + addrs: (Addrs[id] || []).map(a => new Multiaddr(a)) })) } return addrs diff --git a/src/swarm/localAddrs.js b/src/swarm/localAddrs.js index 55f3927b1..c1b3ae91b 100644 --- a/src/swarm/localAddrs.js +++ b/src/swarm/localAddrs.js @@ -1,6 +1,6 @@ 'use strict' -const multiaddr = require('multiaddr') +const { Multiaddr } = require('multiaddr') const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') @@ -24,7 +24,7 @@ module.exports = configure(api => { /** @type {{ Strings: string[] }} */ const { Strings } = await res.json() - return (Strings || []).map(a => multiaddr(a)) + return (Strings || []).map(a => new Multiaddr(a)) } return localAddrs }) diff --git a/src/swarm/peers.js b/src/swarm/peers.js index e85bbb3b0..cb68ac5c5 100644 --- a/src/swarm/peers.js +++ b/src/swarm/peers.js @@ -1,6 +1,6 @@ 'use strict' -const multiaddr = require('multiaddr') +const { Multiaddr } = require('multiaddr') const configure = require('../lib/configure') const toUrlSearchParams = require('../lib/to-url-search-params') @@ -26,7 +26,7 @@ module.exports = configure(api => { return (Peers || []).map(peer => { return { - addr: multiaddr(peer.Addr), + addr: new Multiaddr(peer.Addr), peer: peer.Peer, muxer: peer.Muxer, latency: peer.Latency, diff --git a/src/types.d.ts b/src/types.d.ts index 037fa68b0..b6d9e4552 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -2,7 +2,7 @@ import { Format as IPLDFormat } from 'interface-ipld-format' import { LoadFormatFn } from 'ipld' import { Agent as HttpAgent } from 'http' import { Agent as HttpsAgent } from 'https' -import Multiaddr from 'multiaddr' +import { Multiaddr } from 'multiaddr' export interface Options { host?: string diff --git a/test/constructor.spec.js b/test/constructor.spec.js index 1c74af9c6..c1f4a7f7c 100644 --- a/test/constructor.spec.js +++ b/test/constructor.spec.js @@ -1,7 +1,7 @@ /* eslint-env mocha, browser */ 'use strict' -const multiaddr = require('multiaddr') +const { Multiaddr } = require('multiaddr') const { expect } = require('aegir/utils/chai') const f = require('./utils/factory')() const { create: ipfsClient } = require('../src/index.js') @@ -75,7 +75,7 @@ describe('ipfs-http-client constructor tests', () => { it('multiaddr instance', () => { const host = 'ace.place' const port = '1001' - const addr = multiaddr(`/dns4/${host}/tcp/${port}`) + const addr = new Multiaddr(`/dns4/${host}/tcp/${port}`) const ipfs = ipfsClient(addr) expectConfig(ipfs, { host, port }) }) @@ -132,7 +132,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: multiaddr(addr) }) + const ipfs = ipfsClient({ url: new Multiaddr(addr) }) expectConfig(ipfs, { host, port, protocol }) }) @@ -141,7 +141,7 @@ describe('ipfs-http-client constructor tests', () => { const port = '1001' const protocol = 'https' const addr = `/dns4/${host}/tcp/${port}/https` - const ipfs = ipfsClient({ url: multiaddr(addr) }) + const ipfs = ipfsClient({ url: new Multiaddr(addr) }) expectConfig(ipfs, { host, port, protocol }) }) diff --git a/test/exports.spec.js b/test/exports.spec.js index 1cc99c946..b13008847 100644 --- a/test/exports.spec.js +++ b/test/exports.spec.js @@ -2,7 +2,7 @@ 'use strict' const CID = require('cids') -const multiaddr = require('multiaddr') +const { multiaddr } = require('multiaddr') const multibase = require('multibase') const multicodec = require('multicodec') const multihash = require('multihashes')