From ad978f0ad815e546ca3b0615bcf43620b0216c5a Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Thu, 10 Dec 2020 16:11:31 +0100 Subject: [PATCH] chore: use 0.30 rc --- package.json | 590 ++++++++++-------- packages/ipfs-core/package.json | 2 +- packages/ipfs-core/src/components/index.js | 2 + .../ipfs-core/src/components/is-online.js | 2 +- .../ipfs-core/src/components/key/export.js | 5 +- .../ipfs-core/src/components/key/import.js | 5 +- packages/ipfs-core/src/components/key/info.js | 3 +- packages/ipfs-core/src/components/key/list.js | 13 +- .../ipfs-core/src/components/key/rename.js | 6 +- packages/ipfs-core/src/components/key/rm.js | 3 +- packages/ipfs-core/src/components/libp2p.js | 2 +- packages/ipfs-core/src/components/ping.js | 17 +- packages/ipfs-core/src/components/pubsub.js | 6 +- packages/ipfs-core/src/components/stats/bw.js | 6 +- packages/ipfs-core/src/components/storage.js | 10 +- .../ipfs-core/src/components/swarm/addrs.js | 2 +- .../ipfs-core/src/components/swarm/connect.js | 2 +- .../src/components/swarm/disconnect.js | 2 +- 18 files changed, 381 insertions(+), 297 deletions(-) diff --git a/package.json b/package.json index 4cb34c4ebe..0ab6fa8c55 100644 --- a/package.json +++ b/package.json @@ -1,256 +1,338 @@ { - "name": "js-ipfs", - "version": "1.0.0", - "description": "JavaScript implementation of the IPFS specification", - "scripts": { - "postinstall": "lerna bootstrap", - "link": "lerna link", - "reset": "lerna run clean && rimraf packages/*/node_modules node_modules", - "test": "lerna run test", - "test:node": "lerna run test:node", - "test:browser": "lerna run test:browser", - "test:webworker": "lerna run test:webworker", - "test:electron": "lerna run test:electron", - "test:electron-main": "lerna run test:electron-main", - "test:electron-renderer": "lerna run test:electron-renderer", - "test:external": "lerna run test:external", - "test:cli": "lerna run test:cli", - "test:interop": "lerna run test:interop", - "test:interface:core": "lerna run test:interface:core", - "test:interface:http-go": "lerna run test:interface:http-go", - "test:interface:http-js": "lerna run test:interface:http-js", - "test:interface:message-port-client": "lerna run test:interface:message-port-client", - "coverage": "lerna run coverage", - "build": "lerna run build", - "build:types": "lerna run build:types", - "clean": "lerna run clean", - "lint": "lerna run lint", - "dep-check": "lerna run dep-check", - "configure-examples": "run-s release:pre:add-examples release:pre:add-hoisted-modules release:pre:reinstall", - "release": "run-s release:pre:* release:publish docker:release release:post:*", - "release:pre:non-dirty-repo": "git diff --quiet", - "release:pre:update-contributors": "aegir release --lint=false --test=false --bump=false --build=false --changelog=false --commit=false --tag=false --push=false --ghrelease=false --docs=false --publish=false", - "release:pre:ignore-changes-to-lerna-config": "git update-index --assume-unchanged ./lerna.json", - "release:pre:build": "NODE_ENV=production npm run build -- --scope={ipfs-core,ipfs,ipfs-http-client,ipfs-message-port-*}", - "release:pre:add-examples": "json -I -f ./lerna.json -e \"this.packages.push('examples/*'); this.packages = [...new Set(this.packages)]\"", - "release:pre:add-hoisted-modules": "json -I -f ./lerna.json -e \"this.command.bootstrap.nohoist = ['ipfs-css', 'tachyons']; this.command.bootstrap.nohoist = [...new Set(this.command.bootstrap.nohoist)]\"", - "release:pre:reinstall": "rimraf node_modules */*/node_modules package-lock.json */*/package-lock.json && npm i && rimraf package-lock.json */*/package-lock.json", - "release:publish": "lerna publish", - "docker:release": "run-s docker:release:*", - "docker:release:build": "docker build . --no-cache --tag js-ipfs:latest --file ./Dockerfile.latest", - "docker:release:tag-latest": "docker tag js-ipfs:latest docker.io/ipfs/js-ipfs:latest", - "docker:release:tag-version": "docker tag js-ipfs:latest docker.io/ipfs/js-ipfs:v`npm show ipfs@latest version -q`", - "docker:release:push-latest": "docker push ipfs/js-ipfs:latest", - "docker:release:push-version": "docker push ipfs/js-ipfs:v`npm show ipfs@latest version -q`", - "release:post:remove-hoisted-modules": "json -I -f ./lerna.json -e \"delete this.command.bootstrap.nohoist\"", - "release:post:remove-examples": "json -I -f ./lerna.json -e \"this.packages = this.packages.filter(p => !p.includes('examples'))\"", - "release:post:revert-ignore-changes-to-lerna-config": "git update-index --no-assume-unchanged ./lerna.json", - "release:rc": "run-s release:pre:* release:canary release:post:*", - "release:canary": "lerna publish --canary --preid rc --dist-tag next --force-publish --yes", - "docker:rc": "run-s docker:rc:*", - "docker:rc:build": "docker build . --no-cache --tag js-ipfs:next --file ./Dockerfile.next", - "docker:rc:tag-next": "docker tag js-ipfs:next docker.io/ipfs/js-ipfs:next", - "docker:rc:tag-rc": "docker tag js-ipfs:next docker.io/ipfs/js-ipfs:v`npm show ipfs@next version -q`", - "docker:rc:push-next": "docker push ipfs/js-ipfs:next", - "docker:rc:push-rc": "docker push ipfs/js-ipfs:v`npm show ipfs@next version -q`" - }, - "devDependencies": { - "json": "^10.0.0", - "lerna": "^3.22.0", - "npm-run-all": "^4.1.5", - "rimraf": "^3.0.2" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/ipfs/js-ipfs.git" - }, - "private": true, - "contributors": [ - "David Dias ", - "Alan Shaw ", - "achingbrain ", - "Friedel Ziegelmayer ", - "Juan Batiz-Benet ", - "Hugo Dias ", - "Vasco Santos ", - "Henrique Dias ", - "Volker Mische ", - "ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ ", - "Stephen Whitmore ", - "Jacob Heun ", - "Francisco Baio Dias ", - "Matt Bell ", - "Marcin Rataj ", - "Richard Schneider ", - "Pedro Teixeira ", - "Travis Person ", - "Kristoffer Ström ", - "Dmitriy Ryajov ", - "nginnever ", - "Oli Evans ", - "Richard Littauer ", - "dirkmc ", - "Diogo Silva ", - "Irakli Gozalishvili ", - "Connor Keenan ", - "Pedro Santos ", - "Harlan T Wood ", - "Pascal Precht ", - "Andrew Nesbitt ", - "Maciej Krüger ", - "Michael Garvin ", - "Steven Allen ", - "Michael Muré ", - "João Antunes ", - "Christian Couder ", - "Enrico Marino ", - "Prabhakar Poudel ", - "Rob Brackett ", - "Mithgol ", - "Hector Sanjuan ", - "Gavin McDermott ", - "Sangwon Hong ", - "Jonathan ", - "Joonas Koivunen ", - "Mikeal Rogers ", - "Xmader ", - "Dzmitry Das ", - "haad ", - "Andrew de Andrade ", - "Paulo Rodrigues ", - "Ryan Bell ", - "RasmusErik Voel Jensen ", - "Alex Mingoia ", - "Marius Darila ", - "Yahya ", - "Matt Ober ", - "Jeromy ", - "Mark Robert Henderson ", - "Andrey ", - "Antonio Tenorio-Fornés ", - "Dan Ordille ", - "David Gilbertson ", - "Doug A ", - "Georgios Rassias ", - "Gorka Ludlow ", - "Jim Pick ", - "Jonybang ", - "Kevin Simper ", - "Kevin Wang ", - "0xflotus <0xflotus@gmail.com>", - "Maxime Lathuilière ", - "Nuno Nogueira ", - "Portia Burton ", - "Raoul Millais ", - "Sid Harder ", - "anders ", - "bluelovers ", - "samuli ", - "shunkin ", - "tcme ", - "Максим Ильин ", - "SeungWon ", - "Jason Papakostas ", - "noah the goodra ", - "Lars Gierth ", - "Lukas Drgon ", - "Holodisc ", - "Heo Sangmin ", - "Marcus Bernales ", - "Henry Rodrick ", - "Mat Kelly ", - "Matt Zumwalt ", - "priecint ", - "Michael Bradley ", - "Guilherme Pacheco ", - "Grant Herman ", - "Michelle Lee ", - "Mitar ", - "Giuseppe Bertone ", - "Mohamed Abdulaziz ", - "André Cruz ", - "Mounish Sai ", - "Nate Foss ", - "Nick Poulden ", - "Nicolás Santángelo ", - "Giles ", - "ron litzenberger ", - "Níckolas Goline ", - "Gabriel Garrido Calvo ", - "Orie Steele ", - "Oskar Nyberg ", - "Pau Ramon Revilla ", - "Paul Cowgill ", - "Filip Š ", - "Fil ", - "Felix Yan ", - "Faheel Ahmad ", - "Pete Thomas ", - "Alex North ", - "sarthak khandelwal ", - "Donatas Stundys ", - "Dominic Della Valle ", - "Dmitry Nikulin ", - "Dietrich Ayala ", - "Rod Keys ", - "Roman Khafizianov ", - "Davide Icardi ", - "David da Silva ", - "SidHarder ", - "Adam Uhlíř ", - "David Braun ", - "Subin Siby ", - "Tapasweni Pathak ", - "Tara Vancil ", - "Terence Pae ", - "David ", - "Thiago Delgado ", - "Thorsten Zoerner ", - "Timothé ", - "Danny ", - "Daniela Borges Matos de Carvalho ", - "Uroš Jurglič ", - "Daniel J. O'Quinn ", - "Daniel Constantin ", - "Victor Bjelkholm ", - "Daniel Buchner ", - "Vincent Martin ", - "Dafeng ", - "Vutsal Singhal ", - "Connor White ", - "Yole ", - "Zhiyuan Lin ", - "Christian Paul ", - "bitspill ", - "thattommyhall ", - "datafatmunger ", - "Chance Hudson ", - "Caio Gondim ", - "CHEVALAY JOSSELIN ", - "dmitriy ryajov ", - "elsehow ", - "ethers ", - "Bruno Zell ", - "Bruno Barbieri ", - "Brian Vander Schaaf ", - "Bernard Mordan ", - "hapsody ", - "isan_rivkin ", - "Ayush Mahajan ", - "kevingzhang ", - "Jeeyong Um ", - "Jessica Schilling ", - "leekt216 ", - "Joe Turgeon ", - "Joel Gustafson ", - "Johannes Wikner ", - "John Kane ", - "Jon Schlinkert ", - "Jonathan Commins ", - "Jason Carver ", - "Jorropo ", - "James Halliday ", - "Jade Meskill ", - "Jacob Karlsson " - ] + "name": "js-ipfs", + "version": "1.0.0", + "description": "JavaScript implementation of the IPFS specification", + "devDependencies": { + "json": "^10.0.0", + "lerna": "^3.22.0", + "npm-run-all": "^4.1.5", + "rimraf": "^3.0.2" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/ipfs/js-ipfs.git" + }, + "private": true, + "contributors": [ + "David Dias ", + "Alan Shaw ", + "achingbrain ", + "Friedel Ziegelmayer ", + "Juan Batiz-Benet ", + "Hugo Dias ", + "Vasco Santos ", + "Henrique Dias ", + "Volker Mische ", + "ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ ", + "Stephen Whitmore ", + "Jacob Heun ", + "Francisco Baio Dias ", + "Matt Bell ", + "Marcin Rataj ", + "Richard Schneider ", + "Pedro Teixeira ", + "Travis Person ", + "Kristoffer Ström ", + "Dmitriy Ryajov ", + "nginnever ", + "Oli Evans ", + "Richard Littauer ", + "dirkmc ", + "Diogo Silva ", + "Irakli Gozalishvili ", + "Connor Keenan ", + "Pedro Santos ", + "Harlan T Wood ", + "Pascal Precht ", + "Andrew Nesbitt ", + "Maciej Krüger ", + "Michael Garvin ", + "Steven Allen ", + "Michael Muré ", + "João Antunes ", + "Christian Couder ", + "Enrico Marino ", + "Prabhakar Poudel ", + "Rob Brackett ", + "Mithgol ", + "Hector Sanjuan ", + "Gavin McDermott ", + "Sangwon Hong ", + "Jonathan ", + "Joonas Koivunen ", + "Mikeal Rogers ", + "Xmader ", + "Dzmitry Das ", + "haad ", + "Andrew de Andrade ", + "Paulo Rodrigues ", + "Ryan Bell ", + "RasmusErik Voel Jensen ", + "Alex Mingoia ", + "Marius Darila ", + "Yahya ", + "Matt Ober ", + "Jeromy ", + "Mark Robert Henderson ", + "Andrey ", + "Antonio Tenorio-Fornés ", + "Dan Ordille ", + "David Gilbertson ", + "Doug A ", + "Georgios Rassias ", + "Gorka Ludlow ", + "Jim Pick ", + "Jonybang ", + "Kevin Simper ", + "Kevin Wang ", + "0xflotus <0xflotus@gmail.com>", + "Maxime Lathuilière ", + "Nuno Nogueira ", + "Portia Burton ", + "Raoul Millais ", + "Sid Harder ", + "anders ", + "bluelovers ", + "samuli ", + "shunkin ", + "tcme ", + "Максим Ильин ", + "SeungWon ", + "Jason Papakostas ", + "noah the goodra ", + "Lars Gierth ", + "Lukas Drgon ", + "Holodisc ", + "Heo Sangmin ", + "Marcus Bernales ", + "Henry Rodrick ", + "Mat Kelly ", + "Matt Zumwalt ", + "priecint ", + "Michael Bradley ", + "Guilherme Pacheco ", + "Grant Herman ", + "Michelle Lee ", + "Mitar ", + "Giuseppe Bertone ", + "Mohamed Abdulaziz ", + "André Cruz ", + "Mounish Sai ", + "Nate Foss ", + "Nick Poulden ", + "Nicolás Santángelo ", + "Giles ", + "ron litzenberger ", + "Níckolas Goline ", + "Gabriel Garrido Calvo ", + "Orie Steele ", + "Oskar Nyberg ", + "Pau Ramon Revilla ", + "Paul Cowgill ", + "Filip Š ", + "Fil ", + "Felix Yan ", + "Faheel Ahmad ", + "Pete Thomas ", + "Alex North ", + "sarthak khandelwal ", + "Donatas Stundys ", + "Dominic Della Valle ", + "Dmitry Nikulin ", + "Dietrich Ayala ", + "Rod Keys ", + "Roman Khafizianov ", + "Davide Icardi ", + "David da Silva ", + "SidHarder ", + "Adam Uhlíř ", + "David Braun ", + "Subin Siby ", + "Tapasweni Pathak ", + "Tara Vancil ", + "Terence Pae ", + "David ", + "Thiago Delgado ", + "Thorsten Zoerner ", + "Timothé ", + "Danny ", + "Daniela Borges Matos de Carvalho ", + "Uroš Jurglič ", + "Daniel J. O'Quinn ", + "Daniel Constantin ", + "Victor Bjelkholm ", + "Daniel Buchner ", + "Vincent Martin ", + "Dafeng ", + "Vutsal Singhal ", + "Connor White ", + "Yole ", + "Zhiyuan Lin ", + "Christian Paul ", + "bitspill ", + "thattommyhall ", + "datafatmunger ", + "Chance Hudson ", + "Caio Gondim ", + "CHEVALAY JOSSELIN ", + "dmitriy ryajov ", + "elsehow ", + "ethers ", + "Bruno Zell ", + "Bruno Barbieri ", + "Brian Vander Schaaf ", + "Bernard Mordan ", + "hapsody ", + "isan_rivkin ", + "Ayush Mahajan ", + "kevingzhang ", + "Jeeyong Um ", + "Jessica Schilling ", + "leekt216 ", + "Joe Turgeon ", + "Joel Gustafson ", + "Johannes Wikner ", + "John Kane ", + "Jon Schlinkert ", + "Jonathan Commins ", + "Jason Carver ", + "Jorropo ", + "James Halliday ", + "Jade Meskill ", + "Jacob Karlsson " + ], + "dependencies": { + "@hapi/ammo": "^5.0.1", + "@hapi/boom": "^9.1.0", + "@hapi/content": "^5.0.2", + "@hapi/hapi": "^20.0.0", + "@types/it-all": "^1.0.0", + "@types/yargs": "^15.0.9", + "aegir": "^29.2.2", + "any-signal": "^2.0.0", + "array-shuffle": "^1.0.1", + "bignumber.js": "^9.0.0", + "blob-to-it": "^1.0.1", + "browser-readablestream-to-it": "^1.0.1", + "byteman": "^1.3.5", + "cbor": "^5.1.0", + "chai": "^4.2.0", + "chai-as-promised": "^7.1.1", + "chai-subset": "^1.6.0", + "cid-tool": "^1.0.0", + "cids": "^1.0.0", + "class-is": "^1.1.0", + "cross-env": "^7.0.0", + "dag-cbor-links": "^2.0.0", + "datastore-core": "^2.0.0", + "datastore-pubsub": "^0.4.1", + "debug": "^4.1.1", + "delay": "^4.4.0", + "dirty-chai": "^2.0.1", + "dlv": "^1.1.3", + "electron-webrtc": "^0.3.0", + "err-code": "^2.0.3", + "execa": "^5.0.0", + "file-type": "^16.0.0", + "form-data": "^3.0.0", + "get-folder-size": "^2.0.1", + "go-ipfs": "^0.7.0", + "hamt-sharding": "^1.0.0", + "hapi-pino": "^8.3.0", + "hashlru": "^2.3.0", + "interface-datastore": "^2.0.0", + "ipfs-bitswap": "^4.0.0", + "ipfs-block-service": "^0.18.0", + "ipfs-http-response": "^0.6.0", + "ipfs-interop": "^3.0.0", + "ipfs-repo": "^7.0.0", + "ipfs-unixfs": "^2.0.3", + "ipfs-unixfs-exporter": "^3.0.4", + "ipfs-unixfs-importer": "^5.0.0", + "ipfs-utils": "^5.0.0", + "ipfsd-ctl": "^7.1.1", + "ipld": "^0.28.0", + "ipld-block": "^0.11.0", + "ipld-dag-cbor": "^0.17.0", + "ipld-dag-pb": "^0.20.0", + "ipld-git": "^0.6.1", + "ipld-raw": "^6.0.0", + "ipns": "^0.8.0", + "is-domain-name": "^1.0.1", + "is-ipfs": "^2.0.0", + "iso-random-stream": "^1.1.1", + "iso-url": "^1.0.0", + "it-all": "^1.0.4", + "it-buffer-stream": "^1.0.5", + "it-concat": "^1.0.1", + "it-drain": "^1.0.3", + "it-first": "^1.0.4", + "it-glob": "0.0.10", + "it-last": "^1.0.4", + "it-map": "^1.0.4", + "it-multipart": "^1.0.5", + "it-peekable": "^1.0.1", + "it-pipe": "^1.1.0", + "it-pushable": "^1.4.0", + "it-tar": "^1.2.2", + "it-to-buffer": "^1.0.2", + "it-to-stream": "^0.1.2", + "iterable-ndjson": "^1.1.0", + "joi": "^17.2.1", + "jsondiffpatch": "^0.4.1", + "just-safe-set": "^2.1.0", + "libp2p": "^0.29.3", + "libp2p-bootstrap": "^0.12.1", + "libp2p-crypto": "^0.18.0", + "libp2p-delegated-content-routing": "^0.8.0", + "libp2p-delegated-peer-routing": "^0.8.0", + "libp2p-floodsub": "^0.24.0", + "libp2p-gossipsub": "^0.7.0", + "libp2p-kad-dht": "^0.20.1", + "libp2p-mdns": "^0.15.0", + "libp2p-mplex": "^0.10.0", + "libp2p-noise": "^2.0.1", + "libp2p-record": "^0.9.0", + "libp2p-tcp": "^0.15.1", + "libp2p-webrtc-star": "^0.20.1", + "libp2p-websockets": "^0.15.0", + "mafmt": "^8.0.0", + "merge-options": "^2.0.0", + "mortice": "^2.0.0", + "multiaddr": "^8.0.0", + "multiaddr-to-uri": "^6.0.0", + "multibase": "^3.0.0", + "multicodec": "^2.0.1", + "multihashes": "^3.0.1", + "multihashing-async": "^2.0.1", + "nanoid": "^3.1.12", + "native-abort-controller": "~0.0.3", + "ncp": "^2.0.0", + "nock": "^13.0.2", + "node-fetch": "^2.6.1", + "p-map": "^4.0.0", + "p-queue": "^6.6.1", + "parse-duration": "^0.4.4", + "peer-id": "^0.14.1", + "pretty-bytes": "^5.4.1", + "progress": "^2.0.3", + "prom-client": "^12.0.0", + "prometheus-gc-stats": "^0.6.0", + "qs": "^6.9.4", + "readable-stream": "^3.4.0", + "semver": "^7.3.2", + "sinon": "^9.0.3", + "stream-to-it": "^0.2.2", + "stream-to-promise": "^3.0.0", + "streaming-iterables": "^5.0.2", + "string-argv": "^0.3.1", + "temp-write": "^4.0.0", + "timeout-abort-controller": "^1.1.1", + "typescript": "4.0.x", + "uint8arrays": "^1.1.0", + "update-notifier": "^5.0.0", + "uri-to-multiaddr": "^4.0.0", + "wrtc": "^0.4.6", + "yargs": "^16.0.3" + } } diff --git a/packages/ipfs-core/package.json b/packages/ipfs-core/package.json index d3db81af2f..1820f1f656 100644 --- a/packages/ipfs-core/package.json +++ b/packages/ipfs-core/package.json @@ -88,7 +88,7 @@ "it-first": "^1.0.4", "it-last": "^1.0.4", "it-pipe": "^1.1.0", - "libp2p": "libp2p/js-libp2p#0.30.x", + "libp2p": "libp2p/js-libp2p#fix/types-with-dist", "libp2p-bootstrap": "^0.12.1", "libp2p-crypto": "^0.18.0", "libp2p-floodsub": "^0.24.0", diff --git a/packages/ipfs-core/src/components/index.js b/packages/ipfs-core/src/components/index.js index f2d8b06759..4f02e91da8 100644 --- a/packages/ipfs-core/src/components/index.js +++ b/packages/ipfs-core/src/components/index.js @@ -70,6 +70,8 @@ class IPFS { }) const dns = createDNSAPI() const isOnline = createIsOnlineAPI({ network }) + // @ts-ignore This type check fails as options. + // libp2p can be a function, while IPNS router config expects libp2p config const ipns = new IPNSAPI(options) const dagReader = DagAPI.reader({ ipld, preload }) diff --git a/packages/ipfs-core/src/components/is-online.js b/packages/ipfs-core/src/components/is-online.js index 1e9593a0f8..9bb6467ef1 100644 --- a/packages/ipfs-core/src/components/is-online.js +++ b/packages/ipfs-core/src/components/is-online.js @@ -10,5 +10,5 @@ module.exports = ({ network }) => */ () => { const net = network.try() - return net != null && net.libp2p.isStarted() + return net != null && Boolean(net.libp2p.isStarted()) } diff --git a/packages/ipfs-core/src/components/key/export.js b/packages/ipfs-core/src/components/key/export.js index cbf432ed1c..b4ccc2f661 100644 --- a/packages/ipfs-core/src/components/key/export.js +++ b/packages/ipfs-core/src/components/key/export.js @@ -23,11 +23,10 @@ module.exports = ({ keychain }) => { * ``` * @param {string} name - The name of the key to export * @param {string} password - Password to set on the PEM output - * @param {import('.').AbortOptions} options * @returns {Promise} - The string representation of the key */ - const exportKey = (name, password, options) => - keychain.exportKey(name, password, options) + const exportKey = (name, password) => + keychain.exportKey(name, password) return withTimeoutOption(exportKey) } diff --git a/packages/ipfs-core/src/components/key/import.js b/packages/ipfs-core/src/components/key/import.js index 047ae4d5ce..35eebe224d 100644 --- a/packages/ipfs-core/src/components/key/import.js +++ b/packages/ipfs-core/src/components/key/import.js @@ -21,11 +21,10 @@ module.exports = ({ keychain }) => { * @param {string} name - The name of the key to import * @param {string} pem - The PEM encoded key * @param {string} password - The password that protects the PEM key - * @param {import('.').AbortOptions} options * @returns {Promise} - An object that describes the new key */ - const importKey = (name, pem, password, options) => { - return keychain.importKey(name, pem, password, options) + const importKey = (name, pem, password) => { + return keychain.importKey(name, pem, password) } return withTimeoutOption(importKey) diff --git a/packages/ipfs-core/src/components/key/info.js b/packages/ipfs-core/src/components/key/info.js index 491eed66b6..d585027a8c 100644 --- a/packages/ipfs-core/src/components/key/info.js +++ b/packages/ipfs-core/src/components/key/info.js @@ -9,10 +9,9 @@ const withTimeoutOption = require('ipfs-core-utils/src/with-timeout-option') module.exports = ({ keychain }) => { /** * @param {string} name - * @param {AbortOptions} [options] * @returns {Promise} */ - const info = (name, options = {}) => keychain.findKeyByName(name, options) + const info = (name) => keychain.findKeyByName(name) return withTimeoutOption(info) } diff --git a/packages/ipfs-core/src/components/key/list.js b/packages/ipfs-core/src/components/key/list.js index 379b388547..66e05baca5 100644 --- a/packages/ipfs-core/src/components/key/list.js +++ b/packages/ipfs-core/src/components/key/list.js @@ -23,18 +23,9 @@ module.exports = ({ keychain }) => { * // ] * ``` * - * @param {AbortOptions} [options] - * @returns {Promise} + * @returns {Promise} */ - const list = (options = {}) => keychain.listKeys(options) + const list = () => keychain.listKeys() return withTimeoutOption(list) } - -/** - * @typedef {Object} KeyEntry - * @property {string} name - The name of the key - * @property {string} hash - The hash of the key - * - * @typedef {import('.').AbortOptions} AbortOptions - */ diff --git a/packages/ipfs-core/src/components/key/rename.js b/packages/ipfs-core/src/components/key/rename.js index 26b49c807d..2012a81f87 100644 --- a/packages/ipfs-core/src/components/key/rename.js +++ b/packages/ipfs-core/src/components/key/rename.js @@ -22,11 +22,11 @@ module.exports = ({ keychain }) => { * ``` * @param {string} oldName - The current key name * @param {string} newName - The desired key name - * @param {AbortOptions} [options] * @returns {Promise} */ - const rename = async (oldName, newName, options = {}) => { - const key = await keychain.renameKey(oldName, newName, options) + const rename = async (oldName, newName) => { + const key = await keychain.renameKey(oldName, newName) + return { was: oldName, now: key.name, diff --git a/packages/ipfs-core/src/components/key/rm.js b/packages/ipfs-core/src/components/key/rm.js index 2004a6553b..a27dd8e091 100644 --- a/packages/ipfs-core/src/components/key/rm.js +++ b/packages/ipfs-core/src/components/key/rm.js @@ -20,10 +20,9 @@ module.exports = ({ keychain }) => { * ``` * * @param {string} name - The name of the key to remove - * @param {import('.').AbortOptions} options * @returns {Promise} - An object that describes the removed key */ - const rm = (name, options) => keychain.removeKey(name, options) + const rm = (name) => keychain.removeKey(name) return withTimeoutOption(rm) } diff --git a/packages/ipfs-core/src/components/libp2p.js b/packages/ipfs-core/src/components/libp2p.js index c985b5632f..f0437c0945 100644 --- a/packages/ipfs-core/src/components/libp2p.js +++ b/packages/ipfs-core/src/components/libp2p.js @@ -164,6 +164,6 @@ function getLibp2pOptions ({ options, config, datastore, keys, keychainConfig, p * @typedef {import('.').PeerId} PeerId * @typedef {import('.').Options} IPFSOptions * @typedef {import('libp2p')} LibP2P - * @typedef {import('libp2p').Options} Options + * @typedef {import('libp2p').Libp2pOptions} Options * @typedef {import('.').IPFSConfig} IPFSConfig */ diff --git a/packages/ipfs-core/src/components/ping.js b/packages/ipfs-core/src/components/ping.js index 077986d66d..295263085d 100644 --- a/packages/ipfs-core/src/components/ping.js +++ b/packages/ipfs-core/src/components/ping.js @@ -35,21 +35,28 @@ module.exports = ({ network }) => { peerId = PeerId.createFromCID(peerId) } - let peer = libp2p.peerStore.get(peerId) + const storedPeer = libp2p.peerStore.get(peerId) + let id = storedPeer && storedPeer.id - if (!peer) { + if (!id) { yield { ...basePacket, text: `Looking up peer ${peerId}` } - peer = await libp2p.peerRouting.findPeer(peerId) + const remotePeer = await libp2p.peerRouting.findPeer(peerId) + + id = remotePeer && remotePeer.id + } + + if (!id) { + throw new Error('Peer was not found') } - yield { ...basePacket, text: `PING ${peer.id.toB58String()}` } + yield { ...basePacket, text: `PING ${id.toB58String()}` } let packetCount = 0 let totalTime = 0 for (let i = 0; i < options.count; i++) { try { - const time = await libp2p.ping(peer.id) + const time = await libp2p.ping(id) totalTime += time packetCount++ yield { ...basePacket, time } diff --git a/packages/ipfs-core/src/components/pubsub.js b/packages/ipfs-core/src/components/pubsub.js index db671706f0..56b659477a 100644 --- a/packages/ipfs-core/src/components/pubsub.js +++ b/packages/ipfs-core/src/components/pubsub.js @@ -41,6 +41,7 @@ module.exports = ({ network, config }) => { */ async function subscribe (topic, handler, options) { const { libp2p } = await network.use(options) + // @ts-ignore Libp2p Pubsub is deprecating the handler, using the EventEmitter return libp2p.pubsub.subscribe(topic, handler, options) } @@ -75,6 +76,7 @@ module.exports = ({ network, config }) => { */ async function unsubscribe (topic, handler, options) { const { libp2p } = await network.use(options) + // @ts-ignore Libp2p Pubsub is deprecating the handler, using the EventEmitter libp2p.pubsub.unsubscribe(topic, handler, options) } @@ -111,7 +113,7 @@ module.exports = ({ network, config }) => { */ async function ls (options) { const { libp2p } = await network.use(options) - return libp2p.pubsub.getTopics(options) + return libp2p.pubsub.getTopics() } /** @@ -131,7 +133,7 @@ module.exports = ({ network, config }) => { */ async function peers (topic, options) { const { libp2p } = await network.use(options) - return libp2p.pubsub.getSubscribers(topic, options) + return libp2p.pubsub.getSubscribers(topic) } } diff --git a/packages/ipfs-core/src/components/stats/bw.js b/packages/ipfs-core/src/components/stats/bw.js index 5634bf029c..a418e0d688 100644 --- a/packages/ipfs-core/src/components/stats/bw.js +++ b/packages/ipfs-core/src/components/stats/bw.js @@ -13,7 +13,9 @@ const withTimeoutOption = require('ipfs-core-utils/src/with-timeout-option') function getBandwidthStats (libp2p, opts) { let stats - if (opts.peer) { + if (!libp2p.metrics) { + stats = undefined + } else if (opts.peer) { stats = libp2p.metrics.forPeer(opts.peer) } else if (opts.proto) { stats = libp2p.metrics.forProtocol(opts.proto) @@ -85,7 +87,7 @@ module.exports = ({ network }) => { /** * @typedef {Object} BWOptions - * @property {PeerId|CID|string} [peer] - Specifies a peer to print bandwidth for + * @property {PeerId} [peer] - Specifies a peer to print bandwidth for * @property {string} [proto] - Specifies a protocol to print bandwidth for * @property {boolean} [poll] - Is used to yield bandwidth info at an interval * @property {number|string} [interval=1000] - The time interval to wait between updating output, if `poll` is `true`. diff --git a/packages/ipfs-core/src/components/storage.js b/packages/ipfs-core/src/components/storage.js index 4152d3bd24..14efb7424d 100644 --- a/packages/ipfs-core/src/components/storage.js +++ b/packages/ipfs-core/src/components/storage.js @@ -43,6 +43,8 @@ class Storage { const { peerId, keychain, isNew } = await loadRepo(repo, options) + // TODO: throw error? + // @ts-ignore On start, keychain will always be available return new Storage(peerId, keychain, repo, print, isNew) } } @@ -52,7 +54,7 @@ module.exports = Storage * * @param {Repo} repo * @param {RepoOptions & InitOptions} options - * @returns {Promise<{peerId: PeerId, keychain:Keychain, isNew:boolean }>} + * @returns {Promise<{peerId: PeerId, keychain: Keychain | undefined, isNew:boolean }>} */ const loadRepo = async (repo, options) => { const openError = await openRepo(repo) @@ -96,7 +98,7 @@ const openRepo = async (repo) => { /** * @param {Repo} repo * @param {RepoOptions & InitOptions} options - * @returns {Promise<{peerId: PeerId, keychain:Keychain}>} + * @returns {Promise<{peerId: PeerId, keychain: Keychain | undefined}>} */ const initRepo = async (repo, options) => { // 1. Verify that repo does not exist yet (if it does and we could not @@ -197,7 +199,7 @@ const peerIdToIdentity = (peerId) => ({ * * @param {Repo} repo * @param {ConfigureOptions} options - * @returns {Promise<{peerId: PeerId, keychain:Keychain}>} + * @returns {Promise<{peerId: PeerId, keychain: Keychain | undefined}>} */ const configureRepo = async (repo, { config, profiles, pass }) => { const original = await repo.config.getAll() @@ -297,5 +299,5 @@ const applyProfiles = (config, profiles) => { * @typedef {import('.').IPFSConfig} IPFSConfig * @typedef {import('../interface/repo').Repo} Repo * @typedef {import('libp2p-crypto').KeyType} KeyType - * @typedef {import('libp2p').LibP2PKeychain} Keychain + * @typedef {import('libp2p/src/keychain')} Keychain */ diff --git a/packages/ipfs-core/src/components/swarm/addrs.js b/packages/ipfs-core/src/components/swarm/addrs.js index 03000ed58a..28ae132fd3 100644 --- a/packages/ipfs-core/src/components/swarm/addrs.js +++ b/packages/ipfs-core/src/components/swarm/addrs.js @@ -16,7 +16,7 @@ module.exports = ({ network }) => { async function addrs (options) { // eslint-disable-line require-await const peers = [] const { libp2p } = await network.use(options) - for (const [peerId, peer] of libp2p.peerStore.peers.entries(options)) { + for (const [peerId, peer] of libp2p.peerStore.peers.entries()) { peers.push({ id: peerId, addrs: peer.addresses.map((mi) => mi.multiaddr) diff --git a/packages/ipfs-core/src/components/swarm/connect.js b/packages/ipfs-core/src/components/swarm/connect.js index 306aba2487..49c078a3b8 100644 --- a/packages/ipfs-core/src/components/swarm/connect.js +++ b/packages/ipfs-core/src/components/swarm/connect.js @@ -16,7 +16,7 @@ module.exports = ({ network }) => { */ async function connect (addr, options) { const { libp2p } = await network.use(options) - return libp2p.dial(addr, options) + await libp2p.dial(addr, options) } return withTimeoutOption(connect) diff --git a/packages/ipfs-core/src/components/swarm/disconnect.js b/packages/ipfs-core/src/components/swarm/disconnect.js index 7bfdbbb839..6b4210c8bc 100644 --- a/packages/ipfs-core/src/components/swarm/disconnect.js +++ b/packages/ipfs-core/src/components/swarm/disconnect.js @@ -16,7 +16,7 @@ module.exports = ({ network }) => { */ async function disconnect (addr, options) { const { libp2p } = await network.use(options) - return libp2p.hangUp(addr, options) + return libp2p.hangUp(addr) } return withTimeoutOption(disconnect)