Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

fix: replace node buffers with uint8arrays #244

Merged
merged 4 commits into from
Aug 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,37 +49,37 @@
},
"homepage": "https://github.com/libp2p/js-libp2p-webrtc-star#readme",
"devDependencies": {
"aegir": "^23.0.0",
"aegir": "^25.1.0",
"chai": "^4.2.0",
"dirty-chai": "^2.0.1",
"electron-webrtc": "~0.3.0",
"libp2p-interfaces": "libp2p/js-interfaces#skip-abort-while-reading",
"libp2p-interfaces": "^0.4.0",
"p-wait-for": "^3.1.0",
"sinon": "^9.0.0",
"uint8arrays": "^1.1.0",
"wrtc": "^0.4.3"
},
"dependencies": {
"@hapi/hapi": "^18.4.0",
"@hapi/inert": "^5.2.2",
"abortable-iterator": "^3.0.0",
"buffer": "^5.6.0",
"class-is": "^1.1.0",
"debug": "^4.1.1",
"err-code": "^2.0.0",
"ipfs-utils": "^2.3.0",
"it-pipe": "^1.0.1",
"libp2p-utils": "^0.1.0",
"libp2p-webrtc-peer": "^9.7.2",
"mafmt": "^7.0.1",
"libp2p-utils": "^0.2.0",
"libp2p-webrtc-peer": "^10.0.1",
"mafmt": "^8.0.0",
"menoetius": "0.0.2",
"minimist": "^1.2.0",
"multiaddr": "^7.1.0",
"multiaddr": "^8.0.0",
"p-defer": "^3.0.0",
"peer-id": "~0.13.12",
"peer-id": "^0.14.0",
"prom-client": "^12.0.0",
"socket.io": "^2.3.0",
"socket.io-client": "^2.3.0",
"stream-to-it": "^0.2.0",
"stream-to-it": "^0.2.2",
"streaming-iterables": "^5.0.2"
},
"contributors": [
Expand Down
3 changes: 1 addition & 2 deletions src/socket-to-conn.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const abortable = require('abortable-iterator')
const toIterable = require('stream-to-it')
const { Buffer } = require('buffer')
const { CLOSE_TIMEOUT } = require('./constants')
const toMultiaddr = require('libp2p-utils/src/ip-port-to-multiaddr')

Expand Down Expand Up @@ -41,7 +40,7 @@ module.exports = (socket, options = {}) => {
await sink((async function * () {
for await (const chunk of source) {
// Convert BufferList to Buffer
yield Buffer.isBuffer(chunk) ? chunk : chunk.slice()
yield chunk instanceof Uint8Array ? chunk : chunk.slice()
}
})())
} catch (err) {
Expand Down
5 changes: 1 addition & 4 deletions test/sig-server.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/* eslint-env mocha */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const { expect } = require('aegir/utils/chai')
const io = require('socket.io-client')
const multiaddr = require('multiaddr')

Expand Down
8 changes: 3 additions & 5 deletions test/transport/dial.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@

'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const { expect } = require('aegir/utils/chai')
const multiaddr = require('multiaddr')
const pipe = require('it-pipe')
const { collect } = require('streaming-iterables')
const uint8ArrayFromString = require('uint8arrays/from-string')

module.exports = (create) => {
describe('dial', () => {
Expand Down Expand Up @@ -57,7 +55,7 @@ module.exports = (create) => {
this.timeout(20 * 1000)

const conn = await ws1.dial(ws2._signallingAddr)
const data = Buffer.from('some data')
const data = uint8ArrayFromString('some data')
const values = await pipe(
[data],
conn,
Expand Down
5 changes: 1 addition & 4 deletions test/transport/discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const { expect } = require('aegir/utils/chai')
const multiaddr = require('multiaddr')

module.exports = (create) => {
Expand Down
5 changes: 1 addition & 4 deletions test/transport/filter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/* eslint-env mocha */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const { expect } = require('aegir/utils/chai')

const multiaddr = require('multiaddr')

Expand Down
5 changes: 1 addition & 4 deletions test/transport/instance.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/* eslint-env mocha */
'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const { expect } = require('aegir/utils/chai')

const WebRTCStar = require('../../src')

Expand Down
5 changes: 1 addition & 4 deletions test/transport/listen.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const { expect } = require('aegir/utils/chai')
const multiaddr = require('multiaddr')

module.exports = (create) => {
Expand Down
5 changes: 1 addition & 4 deletions test/transport/reconnect.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const { expect } = require('aegir/utils/chai')
const multiaddr = require('multiaddr')
const sigServer = require('../../src/sig-server')

Expand Down
5 changes: 1 addition & 4 deletions test/transport/track.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const { expect } = require('aegir/utils/chai')
const multiaddr = require('multiaddr')
const pipe = require('it-pipe')
const pWaitFor = require('p-wait-for')
Expand Down
5 changes: 1 addition & 4 deletions test/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

'use strict'

const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const { expect } = require('aegir/utils/chai')
const multiaddr = require('multiaddr')
const { cleanMultiaddr } = require('../src/utils')
const { cleanUrlSIO } = require('../src/utils')
Expand Down