From edb367ae4d32217e286b5bd37168076a1687985a Mon Sep 17 00:00:00 2001 From: Irakli Gozalishvili Date: Tue, 20 Oct 2020 16:15:24 -0700 Subject: [PATCH] chore: update deps & remove obsolete ignores --- examples/traverse-ipld-graphs/package.json | 2 +- packages/interface-ipfs-core/package.json | 2 +- packages/ipfs-cli/package.json | 2 +- packages/ipfs-cli/src/daemon.js | 4 +--- packages/ipfs-core-utils/package.json | 4 ++-- packages/ipfs-core-utils/src/cid.js | 1 - packages/ipfs-core-utils/src/pins/normalise-input.js | 2 +- packages/ipfs-core/package.json | 2 +- packages/ipfs-core/src/components/block/put.js | 2 -- packages/ipfs-core/src/components/block/utils.js | 1 - packages/ipfs-core/src/components/init.js | 3 +-- packages/ipfs-core/src/components/pin/ls.js | 9 +++------ packages/ipfs-core/src/index.js | 2 +- packages/ipfs-core/src/ipns/index.js | 3 +-- packages/ipfs-core/src/utils.js | 1 - packages/ipfs-core/src/utils/tlru.js | 2 +- packages/ipfs-http-client/package.json | 2 +- packages/ipfs-http-client/src/bitswap/unwant.js | 5 ++++- .../ipfs-http-client/src/bitswap/wantlist-for-peer.js | 2 +- packages/ipfs-http-client/src/block/get.js | 1 - packages/ipfs-http-client/src/dag/put.js | 1 - packages/ipfs-http-client/src/lib/buffer-to-form-data.js | 8 +++++++- packages/ipfs-http-client/src/lib/core.js | 9 ++++++--- packages/ipfs-http-gateway/package.json | 2 +- packages/ipfs-http-server/package.json | 2 +- packages/ipfs-http-server/src/api/resources/shutdown.js | 3 +-- packages/ipfs-http-server/src/utils/joi.js | 2 +- packages/ipfs-message-port-client/package.json | 4 ++-- packages/ipfs-message-port-client/src/core.js | 2 -- packages/ipfs-message-port-protocol/package.json | 2 +- packages/ipfs-message-port-server/package.json | 2 +- 31 files changed, 42 insertions(+), 47 deletions(-) diff --git a/examples/traverse-ipld-graphs/package.json b/examples/traverse-ipld-graphs/package.json index f119b4befe..e9d4da3f9a 100644 --- a/examples/traverse-ipld-graphs/package.json +++ b/examples/traverse-ipld-graphs/package.json @@ -13,7 +13,7 @@ "test-ipfs-example": "^2.0.3" }, "dependencies": { - "cids": "^1.0.0", + "cids": "^1.0.2", "ipfs": "^0.50.1", "ipld-block": "^0.10.1", "ipld-dag-pb": "^0.20.0", diff --git a/packages/interface-ipfs-core/package.json b/packages/interface-ipfs-core/package.json index d7c8a82edd..8f55655bcf 100644 --- a/packages/interface-ipfs-core/package.json +++ b/packages/interface-ipfs-core/package.json @@ -34,7 +34,7 @@ "chai": "^4.2.0", "chai-as-promised": "^7.1.1", "chai-subset": "^1.6.0", - "cids": "^1.0.0", + "cids": "^1.0.2", "delay": "^4.4.0", "dirty-chai": "^2.0.1", "err-code": "^2.0.3", diff --git a/packages/ipfs-cli/package.json b/packages/ipfs-cli/package.json index 0d0e7c6c29..995939844b 100644 --- a/packages/ipfs-cli/package.json +++ b/packages/ipfs-cli/package.json @@ -32,7 +32,7 @@ "bignumber.js": "^9.0.0", "byteman": "^1.3.5", "cid-tool": "^1.0.0", - "cids": "^1.0.0", + "cids": "^1.0.2", "debug": "^4.1.1", "dlv": "^1.1.3", "electron-webrtc": "^0.3.0", diff --git a/packages/ipfs-cli/src/daemon.js b/packages/ipfs-cli/src/daemon.js index 30492473fe..fd142460e3 100644 --- a/packages/ipfs-cli/src/daemon.js +++ b/packages/ipfs-cli/src/daemon.js @@ -103,9 +103,7 @@ function getLibp2p ({ libp2pOptions, options, config, peerId }) { const delegateAddr = Multiaddr(delegateString).toOptions() const delegateApiOptions = { host: delegateAddr.host, - // port is a string atm, so we need to convert for the check - // @ts-ignore - parseInt(input:string) => number - protocol: parseInt(delegateAddr.port) === 443 ? 'https' : 'http', + protocol: parseInt(`${delegateAddr.port}`) === 443 ? 'https' : 'http', port: delegateAddr.port } diff --git a/packages/ipfs-core-utils/package.json b/packages/ipfs-core-utils/package.json index ee55e91ae5..d6f42a5f1c 100644 --- a/packages/ipfs-core-utils/package.json +++ b/packages/ipfs-core-utils/package.json @@ -38,8 +38,8 @@ "license": "MIT", "dependencies": { "blob-to-it": "0.0.2", - "browser-readablestream-to-it": "0.0.2", - "cids": "^1.0.0", + "browser-readablestream-to-it": "^1.0.1", + "cids": "^1.0.2", "err-code": "^2.0.3", "ipfs-utils": "^4.0.0", "it-all": "^1.0.4", diff --git a/packages/ipfs-core-utils/src/cid.js b/packages/ipfs-core-utils/src/cid.js index b0578d375c..b69dc62b20 100644 --- a/packages/ipfs-core-utils/src/cid.js +++ b/packages/ipfs-core-utils/src/cid.js @@ -21,7 +21,6 @@ exports.cidToString = (input, options = {}) => { const upgrade = options.upgrade !== false let cid = CID.isCID(input) ? input - // @ts-ignore - TS seems to get confused by the type defs in CID repo. : new CID(input) if (cid.version === 0 && options.base && options.base !== 'base58btc') { diff --git a/packages/ipfs-core-utils/src/pins/normalise-input.js b/packages/ipfs-core-utils/src/pins/normalise-input.js index fc4299b7ce..16c94198e9 100644 --- a/packages/ipfs-core-utils/src/pins/normalise-input.js +++ b/packages/ipfs-core-utils/src/pins/normalise-input.js @@ -50,7 +50,7 @@ module.exports = async function * normaliseInput (input) { // { cid: CID recursive, metadata } // @ts-ignore - it still could be iterable or async iterable if (input.cid != null || input.path != null) { - // @ts-ignore + // @ts-ignore - same as above return yield toPin(input) } diff --git a/packages/ipfs-core/package.json b/packages/ipfs-core/package.json index b461c8e81f..1468bad78b 100644 --- a/packages/ipfs-core/package.json +++ b/packages/ipfs-core/package.json @@ -58,7 +58,7 @@ "array-shuffle": "^1.0.1", "bignumber.js": "^9.0.0", "cbor": "^5.1.0", - "cids": "^1.0.0", + "cids": "^1.0.2", "class-is": "^1.1.0", "dag-cbor-links": "^2.0.0", "datastore-core": "^2.0.0", diff --git a/packages/ipfs-core/src/components/block/put.js b/packages/ipfs-core/src/components/block/put.js index 8303315b59..7269f2f06d 100644 --- a/packages/ipfs-core/src/components/block/put.js +++ b/packages/ipfs-core/src/components/block/put.js @@ -73,8 +73,6 @@ module.exports = ({ blockService, pin, gcLock, preload }) => { // Pick appropriate CID version cidVersion = mhtype === 'sha2-256' && format === 'dag-pb' ? 0 : 1 } else { - // @ts-ignore - options.version is a {number} but the CID constructor arg version is a {0|1} - // TODO: https://github.com/multiformats/js-cid/pull/129 cidVersion = options.version } diff --git a/packages/ipfs-core/src/components/block/utils.js b/packages/ipfs-core/src/components/block/utils.js index d384db759f..65bc7f5b38 100644 --- a/packages/ipfs-core/src/components/block/utils.js +++ b/packages/ipfs-core/src/components/block/utils.js @@ -14,7 +14,6 @@ exports.cleanCid = cid => { // CID constructor knows how to do the cleaning :) try { - // @ts-ignore - string|Uint8Array union seems to confuse CID typedefs. return new CID(cid) } catch (err) { throw errCode(err, 'ERR_INVALID_CID') diff --git a/packages/ipfs-core/src/components/init.js b/packages/ipfs-core/src/components/init.js index f8ef2a25f7..aff7b46003 100644 --- a/packages/ipfs-core/src/components/init.js +++ b/packages/ipfs-core/src/components/init.js @@ -309,7 +309,6 @@ function createPeerId ({ privateKey, algorithm = 'RSA', bits, print }) { } else { // Generate peer identity keypair + transform to desired format + add to config. print('generating %s-bit (rsa only) %s keypair...', bits, algorithm) - // @ts-ignore - expects "Ed25519" | "RSA" | "secp256k1" instoad of string return PeerId.create({ keyType: algorithm, bits }) } } @@ -551,7 +550,7 @@ function createApi ({ * @typedef {import('./config').IPFSConfig} IPFSConfig * @typedef {import('.').IPFSRepo} IPFSRepo * - * @typedef {'RSA' | 'ed25519' | 'secp256k1'} KeyType + * @typedef {import('libp2p-crypto').KeyType} KeyType * * @typedef {string|PeerId} PrivateKey * Can be either a base64 string or a [PeerId](https://github.com/libp2p/js-peer-id) diff --git a/packages/ipfs-core/src/components/pin/ls.js b/packages/ipfs-core/src/components/pin/ls.js index 179585d620..f7b8504622 100644 --- a/packages/ipfs-core/src/components/pin/ls.js +++ b/packages/ipfs-core/src/components/pin/ls.js @@ -28,7 +28,7 @@ module.exports = ({ pinManager, dag }) => { /** * List all the objects pinned to local storage * - * @param {LsOptions} [options] + * @param {LsOptions & AbortOptions} [options] * @returns {AsyncIterable} * @example * ```js @@ -106,8 +106,6 @@ module.exports = ({ pinManager, dag }) => { } if (type === PinTypes.indirect || type === PinTypes.all) { - // @ts-ignore - LsSettings & AbortOptions have no properties in common - // with type { preload?: boolean } for await (const cid of pinManager.indirectKeys(options)) { yield toPin(PinTypes.indirect, cid) } @@ -124,11 +122,10 @@ module.exports = ({ pinManager, dag }) => { } /** - * @typedef {LsSettings & AbortOptions} LsOptions - * - * @typedef {Object} LsSettings + * @typedef {Object} LsOptions * @property {string[]|CID[]} [paths] - CIDs or IPFS paths to search for in the pinset. * @property {PinQueryType} [type] - Filter by this type of pin ("recursive", "direct" or "indirect") + * @property {boolean} [preload] * * @typedef {Object} LsEntry * @property {CID} cid - CID of the pinned node diff --git a/packages/ipfs-core/src/index.js b/packages/ipfs-core/src/index.js index a32e7f5339..fe436f41c3 100644 --- a/packages/ipfs-core/src/index.js +++ b/packages/ipfs-core/src/index.js @@ -73,7 +73,7 @@ async function create (options = {}) { * @typedef {NonNullable} StartedAPI * @type {If, API>} */ - // @ts-ignore + // @ts-ignore - Will be fixed by https://github.com/ipfs/js-ipfs/issues/3285 const ipfs = startedApi || initializedApi || api return ipfs } diff --git a/packages/ipfs-core/src/ipns/index.js b/packages/ipfs-core/src/ipns/index.js index 87fd6b4970..551fb11c31 100644 --- a/packages/ipfs-core/src/ipns/index.js +++ b/packages/ipfs-core/src/ipns/index.js @@ -35,8 +35,7 @@ class IPNS { // // Add to cache const id = peerId.toB58String() - // @ts-ignore - parseFloat expects string - const ttEol = parseFloat(lifetime) + const ttEol = parseFloat(`${lifetime}`) const ttl = (ttEol < defaultRecordTtl) ? ttEol : defaultRecordTtl this.cache.set(id, value, ttl) diff --git a/packages/ipfs-core/src/utils.js b/packages/ipfs-core/src/utils.js index b14873723a..dc205b1474 100644 --- a/packages/ipfs-core/src/utils.js +++ b/packages/ipfs-core/src/utils.js @@ -80,7 +80,6 @@ const normalizeCidPath = (path) => { */ const resolvePath = async function (dag, ipfsPath, options = {}) { if (isIpfs.cid(ipfsPath)) { - // @ts-ignore - CID|string seems to confuse typedef return new CID(ipfsPath) } diff --git a/packages/ipfs-core/src/utils/tlru.js b/packages/ipfs-core/src/utils/tlru.js index 6f63f672a9..ff5a74fd4f 100644 --- a/packages/ipfs-core/src/utils/tlru.js +++ b/packages/ipfs-core/src/utils/tlru.js @@ -1,7 +1,7 @@ 'use strict' /** @type {typeof import('hashlru').default} */ -// @ts-ignore - hashlru has incorrect typedefs +// @ts-ignore - https://github.com/dominictarr/hashlru/pull/24 const hashlru = require('hashlru') /** diff --git a/packages/ipfs-http-client/package.json b/packages/ipfs-http-client/package.json index aee5887cff..065d67824f 100644 --- a/packages/ipfs-http-client/package.json +++ b/packages/ipfs-http-client/package.json @@ -51,7 +51,7 @@ "dependencies": { "any-signal": "^2.0.0", "bignumber.js": "^9.0.0", - "cids": "^1.0.0", + "cids": "^1.0.2", "debug": "^4.1.1", "form-data": "^3.0.0", "ipfs-core-utils": "^0.4.0", diff --git a/packages/ipfs-http-client/src/bitswap/unwant.js b/packages/ipfs-http-client/src/bitswap/unwant.js index 806827acf9..5fdbd7bccc 100644 --- a/packages/ipfs-http-client/src/bitswap/unwant.js +++ b/packages/ipfs-http-client/src/bitswap/unwant.js @@ -9,11 +9,14 @@ module.exports = configure(api => { * @type {import('..').Implements} */ async function unwant (cid, options = {}) { + if (Array.isArray(cid)) { + throw Error('cid argument must be CID or a string') + } + const res = await api.post('bitswap/unwant', { timeout: options.timeout, signal: options.signal, searchParams: toUrlSearchParams({ - // @ts-ignore - CID|string seems to confuse typedef arg: typeof cid === 'string' ? cid : new CID(cid).toString(), ...options }), diff --git a/packages/ipfs-http-client/src/bitswap/wantlist-for-peer.js b/packages/ipfs-http-client/src/bitswap/wantlist-for-peer.js index 973ce7c8eb..560fca5571 100644 --- a/packages/ipfs-http-client/src/bitswap/wantlist-for-peer.js +++ b/packages/ipfs-http-client/src/bitswap/wantlist-for-peer.js @@ -9,7 +9,7 @@ module.exports = configure(api => { * @type {import('..').Implements} */ async function wantlistForPeer (peerId, options = {}) { - // @ts-ignore - CID|string seems to confuse typedef + // @ts-ignore - CID doesn't take PeerId instance peerId = typeof peerId === 'string' ? peerId : new CID(peerId).toString() const res = await (await api.post('bitswap/wantlist', { diff --git a/packages/ipfs-http-client/src/block/get.js b/packages/ipfs-http-client/src/block/get.js index ea29369b38..394bdb2cd7 100644 --- a/packages/ipfs-http-client/src/block/get.js +++ b/packages/ipfs-http-client/src/block/get.js @@ -10,7 +10,6 @@ module.exports = configure(api => { * @type {import('..').Implements} */ async function get (cid, options = {}) { - // @ts-ignore - CID|string seems to confuse typedef cid = new CID(cid) const res = await api.post('block/get', { diff --git a/packages/ipfs-http-client/src/dag/put.js b/packages/ipfs-http-client/src/dag/put.js index dad5ccc231..8a0761c8f8 100644 --- a/packages/ipfs-http-client/src/dag/put.js +++ b/packages/ipfs-http-client/src/dag/put.js @@ -57,7 +57,6 @@ module.exports = configure((api, opts) => { if (!format) { if (opts && opts.ipld && opts.ipld.loadFormat) { - // @ts-ignore - loadFormat expect string but it could be a number format = await opts.ipld.loadFormat(settings.format) } diff --git a/packages/ipfs-http-client/src/lib/buffer-to-form-data.js b/packages/ipfs-http-client/src/lib/buffer-to-form-data.js index 695c052c2b..d24bc81bd5 100644 --- a/packages/ipfs-http-client/src/lib/buffer-to-form-data.js +++ b/packages/ipfs-http-client/src/lib/buffer-to-form-data.js @@ -4,7 +4,13 @@ const FormData = require('form-data') // TODO form data append doesnt have header option -// @ts-ignore +/** + * @param {Uint8Array} buf + * @param {Object} [options] + * @param {number|string} [options.mode] + * @param {number|string} [options.mtime] + * @param {number|string} [options.mtimeNsecs] + */ module.exports = (buf, { mode, mtime, mtimeNsecs } = {}) => { const headers = {} diff --git a/packages/ipfs-http-client/src/lib/core.js b/packages/ipfs-http-client/src/lib/core.js index 44f1774bae..4e5e22bcc7 100644 --- a/packages/ipfs-http-client/src/lib/core.js +++ b/packages/ipfs-http-client/src/lib/core.js @@ -114,7 +114,7 @@ const parseTimeout = (value) => { * @property {URL|string} [url] - Full API URL. * @property {object} [ipld] * @property {any[]} [ipld.formats] - An array of additional [IPLD formats](https://github.com/ipld/interface-ipld-format) to support - * @property {(format: string) => Promise} [ipld.loadFormat] - an async function that takes the name of an [IPLD format](https://github.com/ipld/interface-ipld-format) as a string and should return the implementation of that codec + * @property {(format: string|number) => Promise} [ipld.loadFormat] - an async function that takes the name of an [IPLD format](https://github.com/ipld/interface-ipld-format) as a string and should return the implementation of that codec */ class Client extends HTTP { /** @@ -127,10 +127,13 @@ class Client extends HTTP { headers: opts.headers, base: normalizeInput(opts.url).toString(), handleError: errorHandler, + /** + * @param {URLSearchParams} search + * @returns {URLSearchParams} + */ transformSearchParams: (search) => { const out = new URLSearchParams() - // @ts-ignore https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams for (const [key, value] of search) { if ( value !== 'undefined' && @@ -141,7 +144,7 @@ class Client extends HTTP { } // server timeouts are strings - if (key === 'timeout' && !isNaN(value)) { + if (key === 'timeout' && !isNaN(parseInt(value))) { out.append(kebabCase(key), value) } } diff --git a/packages/ipfs-http-gateway/package.json b/packages/ipfs-http-gateway/package.json index b51e996344..3311e06728 100644 --- a/packages/ipfs-http-gateway/package.json +++ b/packages/ipfs-http-gateway/package.json @@ -32,7 +32,7 @@ "@hapi/ammo": "^5.0.1", "@hapi/boom": "^9.1.0", "@hapi/hapi": "^20.0.0", - "cids": "^1.0.0", + "cids": "^1.0.2", "debug": "^4.1.1", "hapi-pino": "^8.3.0", "ipfs-core-utils": "^0.4.0", diff --git a/packages/ipfs-http-server/package.json b/packages/ipfs-http-server/package.json index 9fdd0a6897..dddb2e6f5c 100644 --- a/packages/ipfs-http-server/package.json +++ b/packages/ipfs-http-server/package.json @@ -32,7 +32,7 @@ "@hapi/boom": "^9.1.0", "@hapi/content": "^5.0.2", "@hapi/hapi": "^20.0.0", - "cids": "^1.0.0", + "cids": "^1.0.2", "debug": "^4.1.1", "dlv": "^1.1.3", "err-code": "^2.0.3", diff --git a/packages/ipfs-http-server/src/api/resources/shutdown.js b/packages/ipfs-http-server/src/api/resources/shutdown.js index 428c902226..df3d231279 100644 --- a/packages/ipfs-http-server/src/api/resources/shutdown.js +++ b/packages/ipfs-http-server/src/api/resources/shutdown.js @@ -8,8 +8,7 @@ */ module.exports = { handler: (_request, h) => { - // @ts-ignore - TS expects second argument - setImmediate(() => process.emit('SIGTERM')) + setImmediate(() => process.emit('SIGTERM', 'SIGTERM')) return h.response() } } diff --git a/packages/ipfs-http-server/src/utils/joi.js b/packages/ipfs-http-server/src/utils/joi.js index 80fb0347e0..223611d2b0 100644 --- a/packages/ipfs-http-server/src/utils/joi.js +++ b/packages/ipfs-http-server/src/utils/joi.js @@ -46,7 +46,7 @@ const reqiureIfRequired = (value, helpers) => { module.exports = Joi .extend( // @ts-ignore - according to typedfs coerce should always return - // { errors?: ErrorReport[], value?: any } + // { errors?: ErrorReport[], value?: any } but below undefined is returned. (joi) => { return { type: 'cid', diff --git a/packages/ipfs-message-port-client/package.json b/packages/ipfs-message-port-client/package.json index baab3962c1..10ba89bef7 100644 --- a/packages/ipfs-message-port-client/package.json +++ b/packages/ipfs-message-port-client/package.json @@ -41,8 +41,8 @@ "dep-check": "aegir dep-check" }, "dependencies": { - "browser-readablestream-to-it": "0.0.2", - "cids": "^1.0.0" + "browser-readablestream-to-it": "^1.0.1", + "cids": "^1.0.2" }, "devDependencies": { "aegir": "^28.0.0", diff --git a/packages/ipfs-message-port-client/src/core.js b/packages/ipfs-message-port-client/src/core.js index f2f096ca8c..3e656267ac 100644 --- a/packages/ipfs-message-port-client/src/core.js +++ b/packages/ipfs-message-port-client/src/core.js @@ -9,8 +9,6 @@ const { encodeIterable, encodeCallback } = require('ipfs-message-port-protocol/src/core') -/** @type {(stream:ReadableStream) => AsyncIterable} */ -// @ts-ignore - browser-stream-to-it has not types const iterateReadableStream = require('browser-readablestream-to-it') /** diff --git a/packages/ipfs-message-port-protocol/package.json b/packages/ipfs-message-port-protocol/package.json index 25d3fae790..11b546b983 100644 --- a/packages/ipfs-message-port-protocol/package.json +++ b/packages/ipfs-message-port-protocol/package.json @@ -41,7 +41,7 @@ "dep-check": "aegir dep-check" }, "dependencies": { - "cids": "^1.0.0", + "cids": "^1.0.2", "ipld-block": "^0.10.1" }, "devDependencies": { diff --git a/packages/ipfs-message-port-server/package.json b/packages/ipfs-message-port-server/package.json index c1a074f55c..d5c2df2f96 100644 --- a/packages/ipfs-message-port-server/package.json +++ b/packages/ipfs-message-port-server/package.json @@ -43,7 +43,7 @@ "dep-check": "aegir dep-check" }, "dependencies": { - "cids": "^1.0.0", + "cids": "^1.0.2", "it-all": "^1.0.4" }, "devDependencies": {