chore: update deps (#869)

This commit is contained in:
Vasco Santos 2021-01-27 09:45:31 +01:00 committed by GitHub
parent 748b552876
commit 037c965a67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 57 additions and 49 deletions

View File

@ -45,7 +45,7 @@ const after = async () => {
} }
module.exports = { module.exports = {
bundlesize: { maxSize: '225kB' }, bundlesize: { maxSize: '260kB' },
hooks: { hooks: {
pre: before, pre: before,
post: after post: after

View File

@ -52,41 +52,41 @@
}, },
"dependencies": { "dependencies": {
"abort-controller": "^3.0.0", "abort-controller": "^3.0.0",
"aggregate-error": "^3.0.1", "aggregate-error": "^3.1.0",
"any-signal": "^1.1.0", "any-signal": "^2.1.1",
"bignumber.js": "^9.0.0", "bignumber.js": "^9.0.1",
"cids": "^1.0.0", "cids": "^1.1.5",
"class-is": "^1.1.0", "class-is": "^1.1.0",
"debug": "^4.1.1", "debug": "^4.3.1",
"err-code": "^2.0.0", "err-code": "^2.0.0",
"events": "^3.1.0", "events": "^3.2.0",
"hashlru": "^2.3.0", "hashlru": "^2.3.0",
"interface-datastore": "^2.0.0", "interface-datastore": "^3.0.3",
"ipfs-utils": "^5.0.1", "ipfs-utils": "^6.0.0",
"it-all": "^1.0.1", "it-all": "^1.0.4",
"it-buffer": "^0.1.2", "it-buffer": "^0.1.2",
"it-drain": "^1.0.3", "it-drain": "^1.0.3",
"it-filter": "^1.0.1", "it-filter": "^1.0.1",
"it-first": "^1.0.4", "it-first": "^1.0.4",
"it-handshake": "^1.0.1", "it-handshake": "^1.0.2",
"it-length-prefixed": "^3.0.1", "it-length-prefixed": "^3.1.0",
"it-map": "^1.0.4", "it-map": "^1.0.4",
"it-merge": "1.0.0", "it-merge": "1.0.0",
"it-pipe": "^1.1.0", "it-pipe": "^1.1.0",
"it-protocol-buffers": "^0.2.0", "it-protocol-buffers": "^0.2.0",
"it-take": "1.0.0", "it-take": "1.0.0",
"libp2p-crypto": "^0.18.0", "libp2p-crypto": "^0.19.0",
"libp2p-interfaces": "^0.8.1", "libp2p-interfaces": "^0.8.1",
"libp2p-utils": "^0.2.2", "libp2p-utils": "^0.2.2",
"mafmt": "^8.0.0", "mafmt": "^8.0.0",
"merge-options": "^2.0.0", "merge-options": "^3.0.4",
"moving-average": "^1.0.0", "moving-average": "^1.0.0",
"multiaddr": "^8.1.0", "multiaddr": "^8.1.0",
"multicodec": "^2.0.0", "multicodec": "^2.1.0",
"multihashing-async": "^2.0.1", "multihashing-async": "^2.0.1",
"multistream-select": "^1.0.0", "multistream-select": "^1.0.0",
"mutable-proxy": "^1.0.0", "mutable-proxy": "^1.0.0",
"node-forge": "^0.9.1", "node-forge": "^0.10.0",
"p-any": "^3.0.0", "p-any": "^3.0.0",
"p-fifo": "^1.0.0", "p-fifo": "^1.0.0",
"p-settle": "^4.0.1", "p-settle": "^4.0.1",
@ -97,7 +97,7 @@
"set-delayed-interval": "^1.0.0", "set-delayed-interval": "^1.0.0",
"streaming-iterables": "^5.0.2", "streaming-iterables": "^5.0.2",
"timeout-abort-controller": "^1.1.1", "timeout-abort-controller": "^1.1.1",
"varint": "^5.0.0", "varint": "^6.0.0",
"xsalsa20": "^1.0.2" "xsalsa20": "^1.0.2"
}, },
"devDependencies": { "devDependencies": {
@ -106,20 +106,20 @@
"aegir": "^29.2.0", "aegir": "^29.2.0",
"chai-bytes": "^0.1.2", "chai-bytes": "^0.1.2",
"chai-string": "^1.5.0", "chai-string": "^1.5.0",
"delay": "^4.3.0", "delay": "^4.4.0",
"interop-libp2p": "^0.3.0", "interop-libp2p": "^0.3.0",
"into-stream": "^6.0.0", "into-stream": "^6.0.0",
"ipfs-http-client": "^47.0.1", "ipfs-http-client": "^48.2.2",
"it-concat": "^1.0.0", "it-concat": "^1.0.0",
"it-pair": "^1.0.0", "it-pair": "^1.0.0",
"it-pushable": "^1.4.0", "it-pushable": "^1.4.0",
"libp2p": ".", "libp2p": ".",
"libp2p-bootstrap": "^0.12.0", "libp2p-bootstrap": "^0.12.0",
"libp2p-delegated-content-routing": "^0.8.0", "libp2p-delegated-content-routing": "^0.9.0",
"libp2p-delegated-peer-routing": "^0.8.0", "libp2p-delegated-peer-routing": "^0.8.0",
"libp2p-floodsub": "^0.24.0", "libp2p-floodsub": "^0.24.0",
"libp2p-gossipsub": "^0.7.0", "libp2p-gossipsub": "^0.8.0",
"libp2p-kad-dht": "^0.20.0", "libp2p-kad-dht": "^0.20.5",
"libp2p-mdns": "^0.15.0", "libp2p-mdns": "^0.15.0",
"libp2p-mplex": "^0.10.1", "libp2p-mplex": "^0.10.1",
"libp2p-noise": "^2.0.0", "libp2p-noise": "^2.0.0",
@ -131,11 +131,11 @@
"nock": "^13.0.3", "nock": "^13.0.3",
"p-defer": "^3.0.0", "p-defer": "^3.0.0",
"p-times": "^3.0.0", "p-times": "^3.0.0",
"p-wait-for": "^3.1.0", "p-wait-for": "^3.2.0",
"promisify-es6": "^1.0.3", "promisify-es6": "^1.0.3",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"sinon": "^9.0.2", "sinon": "^9.2.4",
"uint8arrays": "^1.1.0" "uint8arrays": "^2.0.5"
}, },
"contributors": [ "contributors": [
"David Dias <daviddias.p@gmail.com>", "David Dias <daviddias.p@gmail.com>",

View File

@ -12,7 +12,7 @@ const TextEncoder = require('ipfs-utils/src/text-encoder')
* @returns {Promise<CID>} * @returns {Promise<CID>}
*/ */
module.exports.namespaceToCid = async (namespace) => { module.exports.namespaceToCid = async (namespace) => {
const bytes = new TextEncoder('utf8').encode(namespace) const bytes = new TextEncoder().encode(namespace)
const hash = await multihashing(bytes, 'sha2-256') const hash = await multihashing(bytes, 'sha2-256')
return new CID(hash) return new CID(hash)

View File

@ -5,8 +5,6 @@
* This code is based on `latency-monitor` (https://github.com/mlucool/latency-monitor) by `mlucool` (https://github.com/mlucool), available under Apache License 2.0 (https://github.com/mlucool/latency-monitor/blob/master/LICENSE) * This code is based on `latency-monitor` (https://github.com/mlucool/latency-monitor) by `mlucool` (https://github.com/mlucool), available under Apache License 2.0 (https://github.com/mlucool/latency-monitor/blob/master/LICENSE)
*/ */
/* global window */
const globalThis = require('ipfs-utils/src/globalthis')
/** @typedef {import('../types').EventEmitterFactory} Events */ /** @typedef {import('../types').EventEmitterFactory} Events */
/** @type Events */ /** @type Events */
const EventEmitter = require('events') const EventEmitter = require('events')
@ -74,9 +72,9 @@ class LatencyMonitor extends EventEmitter {
that.asyncTestFn = asyncTestFn // If there is no asyncFn, we measure latency that.asyncTestFn = asyncTestFn // If there is no asyncFn, we measure latency
// If process: use high resolution timer // If process: use high resolution timer
if (globalThis.process && globalThis.process.hrtime) { if (globalThis.process && globalThis.process.hrtime) { // eslint-disable-line no-undef
debug('Using process.hrtime for timing') debug('Using process.hrtime for timing')
that.now = globalThis.process.hrtime that.now = globalThis.process.hrtime // eslint-disable-line no-undef
that.getDeltaMS = (startTime) => { that.getDeltaMS = (startTime) => {
const hrtime = that.now(startTime) const hrtime = that.now(startTime)
return (hrtime[0] * 1000) + (hrtime[1] / 1000000) return (hrtime[0] * 1000) + (hrtime[1] / 1000000)

View File

@ -2,7 +2,7 @@
const errCode = require('err-code') const errCode = require('err-code')
const AbortController = require('abort-controller').default const AbortController = require('abort-controller').default
const anySignal = require('any-signal') const { anySignal } = require('any-signal')
const FIFO = require('p-fifo') const FIFO = require('p-fifo')
const pAny = require('p-any') const pAny = require('p-any')
@ -67,7 +67,7 @@ class DialRequest {
let conn let conn
try { try {
const signal = dialAbortControllers[i].signal const signal = dialAbortControllers[i].signal
conn = await this.dialAction(addr, { ...options, signal: anySignal([signal, options.signal]) }) conn = await this.dialAction(addr, { ...options, signal: options.signal ? anySignal([signal, options.signal]) : signal })
// Remove the successful AbortController so it is not aborted // Remove the successful AbortController so it is not aborted
dialAbortControllers.splice(i, 1) dialAbortControllers.splice(i, 1)
} finally { } finally {

View File

@ -7,7 +7,7 @@ const log = Object.assign(debug('libp2p:dialer'), {
const errCode = require('err-code') const errCode = require('err-code')
const multiaddr = require('multiaddr') const multiaddr = require('multiaddr')
const TimeoutController = require('timeout-abort-controller') const TimeoutController = require('timeout-abort-controller')
const anySignal = require('any-signal') const { anySignal } = require('any-signal')
const DialRequest = require('./dial-request') const DialRequest = require('./dial-request')
const { publicAddressesFirst } = require('libp2p-utils/src/address-sort') const { publicAddressesFirst } = require('libp2p-utils/src/address-sort')

View File

@ -7,7 +7,6 @@ const log = Object.assign(debug('libp2p'), {
/** @typedef {import('./types').EventEmitterFactory} Events */ /** @typedef {import('./types').EventEmitterFactory} Events */
/** @type Events */ /** @type Events */
const EventEmitter = require('events') const EventEmitter = require('events')
const globalThis = require('ipfs-utils/src/globalthis')
const errCode = require('err-code') const errCode = require('err-code')
const PeerId = require('peer-id') const PeerId = require('peer-id')
@ -243,7 +242,7 @@ class Libp2p extends EventEmitter {
// Attach private network protector // Attach private network protector
if (this._modules.connProtector) { if (this._modules.connProtector) {
this.upgrader.protector = this._modules.connProtector this.upgrader.protector = this._modules.connProtector
} else if (globalThis.process !== undefined && globalThis.process.env && globalThis.process.env.LIBP2P_FORCE_PNET) { } else if (globalThis.process !== undefined && globalThis.process.env && globalThis.process.env.LIBP2P_FORCE_PNET) { // eslint-disable-line no-undef
throw new Error('Private network is enforced, but no protector was provided') throw new Error('Private network is enforced, but no protector was provided')
} }

View File

@ -4,10 +4,9 @@
const sanitize = require('sanitize-filename') const sanitize = require('sanitize-filename')
const mergeOptions = require('merge-options') const mergeOptions = require('merge-options')
const crypto = require('libp2p-crypto') const crypto = require('libp2p-crypto')
const Datastore = require('interface-datastore') const { Key } = require('interface-datastore')
const CMS = require('./cms') const CMS = require('./cms')
const errcode = require('err-code') const errcode = require('err-code')
const { Number } = require('ipfs-utils/src/globalthis')
const uint8ArrayToString = require('uint8arrays/to-string') const uint8ArrayToString = require('uint8arrays/to-string')
const uint8ArrayFromString = require('uint8arrays/from-string') const uint8ArrayFromString = require('uint8arrays/from-string')
@ -15,7 +14,7 @@ require('node-forge/lib/sha512')
/** /**
* @typedef {import('peer-id')} PeerId * @typedef {import('peer-id')} PeerId
* @typedef {import('interface-datastore/src/key')} Key * @typedef {import('interface-datastore/src/types').Datastore} Datastore
*/ */
const keyPrefix = '/pkcs8/' const keyPrefix = '/pkcs8/'
@ -72,7 +71,7 @@ async function throwDelayed (err) {
* @private * @private
*/ */
function DsName (name) { function DsName (name) {
return new Datastore.Key(keyPrefix + name) return new Key(keyPrefix + name)
} }
/** /**
@ -83,7 +82,7 @@ function DsName (name) {
* @private * @private
*/ */
function DsInfoName (name) { function DsInfoName (name) {
return new Datastore.Key(infoPrefix + name) return new Key(infoPrefix + name)
} }
/** /**

View File

@ -63,9 +63,10 @@ module.exports.decodeV1PSK = (pskBuffer) => {
const metadata = uint8ArrayToString(pskBuffer).split(/(?:\r\n|\r|\n)/g) const metadata = uint8ArrayToString(pskBuffer).split(/(?:\r\n|\r|\n)/g)
const pskTag = metadata.shift() const pskTag = metadata.shift()
const codec = metadata.shift() const codec = metadata.shift()
const psk = uint8ArrayFromString(metadata.shift(), 'base16') const pskString = metadata.shift()
const psk = pskString && uint8ArrayFromString(pskString, 'base16')
if (psk.byteLength !== KEY_LENGTH) { if (!psk || psk.byteLength !== KEY_LENGTH) {
throw new Error(Errors.INVALID_PSK) throw new Error(Errors.INVALID_PSK)
} }

View File

@ -161,25 +161,36 @@ describe('content-routing', () => {
it('should be able to register as a provider', async () => { it('should be able to register as a provider', async () => {
const cid = new CID('QmU621oD8AhHw6t25vVyfYKmL9VV3PTgc52FngEhTGACFB') const cid = new CID('QmU621oD8AhHw6t25vVyfYKmL9VV3PTgc52FngEhTGACFB')
const mockApi = nock('http://0.0.0.0:60197') const provider = 'QmZNgCqZCvTsi3B4Vt7gsSqpkqDpE7M2Y9TDmEhbDb4ceF'
// mock the refs call
.post('/api/v0/refs') const mockBlockApi = nock('http://0.0.0.0:60197')
// mock the block/stat call
.post('/api/v0/block/stat')
.query(true) .query(true)
.reply(200, null, [ .reply(200, '{"Key":"QmU621oD8AhHw6t25vVyfYKmL9VV3PTgc52FngEhTGACFB","Size":"2169"}', [
'Content-Type', 'application/json',
'X-Chunked-Output', '1'
])
const mockDhtApi = nock('http://0.0.0.0:60197')
// mock the dht/provide call
.post('/api/v0/dht/provide')
.query(true)
.reply(200, `{"Extra":"","ID":"QmWKqWXCtRXEeCQTo3FoZ7g4AfnGiauYYiczvNxFCHicbB","Responses":[{"Addrs":["/ip4/0.0.0.0/tcp/0"],"ID":"${provider}"}],"Type":4}\n`, [
'Content-Type', 'application/json', 'Content-Type', 'application/json',
'X-Chunked-Output', '1' 'X-Chunked-Output', '1'
]) ])
await node.contentRouting.provide(cid) await node.contentRouting.provide(cid)
expect(mockApi.isDone()).to.equal(true) expect(mockBlockApi.isDone()).to.equal(true)
expect(mockDhtApi.isDone()).to.equal(true)
}) })
it('should handle errors when registering as a provider', async () => { it('should handle errors when registering as a provider', async () => {
const cid = new CID('QmU621oD8AhHw6t25vVyfYKmL9VV3PTgc52FngEhTGACFB') const cid = new CID('QmU621oD8AhHw6t25vVyfYKmL9VV3PTgc52FngEhTGACFB')
const mockApi = nock('http://0.0.0.0:60197') const mockApi = nock('http://0.0.0.0:60197')
// mock the refs call // mock the block/stat call
.post('/api/v0/refs') .post('/api/v0/block/stat')
.query(true) .query(true)
.reply(502, 'Bad Gateway', ['Content-Type', 'application/json']) .reply(502, 'Bad Gateway', ['Content-Type', 'application/json'])