diff --git a/package.json b/package.json index 6b38531..0b3d08f 100644 --- a/package.json +++ b/package.json @@ -31,20 +31,19 @@ "dependencies": { "bl": "^4.0.0", "debug": "^4.1.1", - "it-buffer": "^0.1.1", - "it-length-prefixed": "^3.0.0", + "it-length-prefixed": "^3.0.1", "it-pair": "^1.0.0", "it-pb-rpc": "^0.1.4", "it-pipe": "^1.1.0", - "libp2p-crypto": "^0.17.1", + "libp2p-crypto": "^0.17.3", "libp2p-interfaces": "^0.2.1", "multiaddr": "^7.2.1", "multihashing-async": "^0.8.0", "peer-id": "^0.13.6", - "protons": "^1.1.0" + "protons": "^1.0.2" }, "devDependencies": { - "aegir": "^21.0.2", + "aegir": "^21.4.2", "benchmark": "^2.1.4", "chai": "^4.2.0", "dirty-chai": "^2.0.1", diff --git a/src/etm.js b/src/etm.js index 6645bba..e51dbc6 100644 --- a/src/etm.js +++ b/src/etm.js @@ -6,7 +6,7 @@ const { InvalidCryptoTransmissionError } = require('libp2p-interfaces/src/crypto exports.createBoxStream = (cipher, mac) => { return async function * (source) { for await (const chunk of source) { - const data = await cipher.encrypt(chunk) + const data = await cipher.encrypt(BufferList.isBufferList(chunk) ? chunk.slice() : chunk) const digest = await mac.digest(data) yield new BufferList([data, digest]) } diff --git a/src/handshake/crypto.js b/src/handshake/crypto.js index 91cd16c..73120f0 100644 --- a/src/handshake/crypto.js +++ b/src/handshake/crypto.js @@ -1,5 +1,6 @@ 'use strict' +const { Buffer } = require('buffer') const PeerId = require('peer-id') const crypto = require('libp2p-crypto') const debug = require('debug') diff --git a/src/handshake/finish.js b/src/handshake/finish.js index f356169..2997104 100644 --- a/src/handshake/finish.js +++ b/src/handshake/finish.js @@ -9,7 +9,6 @@ const pipe = require('it-pipe') const lp = require('it-length-prefixed') const Wrap = require('it-pb-rpc') const { int32BEEncode, int32BEDecode } = lp -const ensureBuffer = require('it-buffer') const etm = require('../etm') const crypto = require('./crypto') @@ -26,12 +25,10 @@ module.exports = async function finish (state, wrapped) { pipe( secure, // this is FROM the user - ensureBuffer, etm.createBoxStream(proto.local.cipher, proto.local.mac), lp.encode({ lengthEncoder: int32BEEncode }), network, // and gets piped INTO and FROM the network lp.decode({ lengthDecoder: int32BEDecode }), - ensureBuffer, etm.createUnboxStream(proto.remote.cipher, proto.remote.mac), secure // and gets piped TO the user ) diff --git a/src/support.js b/src/support.js index ca7ff15..5b1398b 100644 --- a/src/support.js +++ b/src/support.js @@ -1,5 +1,6 @@ 'use strict' +const { Buffer } = require('buffer') const mh = require('multihashing-async') const crypto = require('libp2p-crypto')