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

Commit 7334ce5

Browse files
authored
chore: update deps (#116)
1 parent 40df268 commit 7334ce5

File tree

8 files changed

+37
-37
lines changed

8 files changed

+37
-37
lines changed

.aegir.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
const WebRTCDirect = require('./src')
44
const pipe = require('it-pipe')
5-
const multiaddr = require('multiaddr')
5+
const { Multiaddr } = require('multiaddr')
66

7-
const ma = multiaddr('/ip4/127.0.0.1/tcp/12345/http/p2p-webrtc-direct')
7+
const ma = new Multiaddr('/ip4/127.0.0.1/tcp/12345/http/p2p-webrtc-direct')
88
let listener
99

1010
const mockUpgrader = {
1111
upgradeInbound: maConn => maConn,
1212
upgradeOutbound: maConn => maConn
1313
}
1414

15-
function boot () {
15+
function before () {
1616
const wd = new WebRTCDirect({ upgrader: mockUpgrader })
1717

1818
listener = wd.createListener((conn) => pipe(conn, conn))
@@ -23,7 +23,7 @@ function boot () {
2323
return listener.listen(ma)
2424
}
2525

26-
async function shutdown () {
26+
async function after () {
2727
await listener.close()
2828
// TODO: Temporary fix per wrtc issue
2929
// https://github.com/node-webrtc/node-webrtc/issues/636
@@ -32,7 +32,7 @@ async function shutdown () {
3232

3333
module.exports = {
3434
hooks: {
35-
pre: boot,
36-
post: shutdown
35+
pre: before,
36+
post: after
3737
}
3838
}

package.json

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
"release-major": "aegir release --type major --target node --target browser",
2222
"coverage": "nyc --reporter=text --reporter=lcov npm run test:node"
2323
},
24-
"pre-push": [
25-
"lint"
26-
],
2724
"repository": {
2825
"type": "git",
2926
"url": "git+https://github.com/libp2p/js-libp2p-webrtc-direct.git"
@@ -43,15 +40,14 @@
4340
},
4441
"homepage": "https://github.com/libp2p/js-libp2p-webrtc-direct#readme",
4542
"engines": {
46-
"node": ">=12.0.0",
47-
"npm": ">=6.0.0"
43+
"node": ">=14.0.0"
4844
},
4945
"devDependencies": {
5046
"aegir": "^30.3.0",
51-
"chai": "^4.2.0",
47+
"chai": "^4.3.4",
5248
"dirty-chai": "^2.0.1",
5349
"it-pipe": "^1.1.0",
54-
"multiaddr": "^8.1.1",
50+
"multiaddr": "^9.0.1",
5551
"streaming-iterables": "^5.0.3",
5652
"webrtcsupport": "^2.2.0"
5753
},
@@ -63,10 +59,10 @@
6359
"detect-node": "^2.0.4",
6460
"err-code": "^3.0.0",
6561
"libp2p-interfaces": "libp2p/js-interfaces#chore/skip-abort-while-reading-for-webrtc",
66-
"libp2p-utils": "^0.2.3",
62+
"libp2p-utils": "^0.3.0",
6763
"libp2p-webrtc-peer": "^10.0.1",
68-
"mafmt": "^8.0.1",
69-
"multibase": "^3.1.0",
64+
"mafmt": "^9.0.0",
65+
"multibase": "^4.0.4",
7066
"once": "^1.4.0",
7167
"request": "^2.88.0",
7268
"stream-to-it": "^0.2.2",

src/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ const createListener = require('./listener')
2222

2323
function noop () {}
2424

25+
/**
26+
* @typedef {import('multiaddr').Multiaddr} Multiaddr
27+
*/
28+
2529
class WebRTCDirect {
2630
/**
2731
* @class

src/listener.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ module.exports = ({ handler, upgrader }, options = {}) => {
102102
})
103103
}
104104

105-
listener.close = () => {
105+
listener.close = async () => {
106106
if (!server.listening) {
107107
return
108108
}
109109

110+
await Promise.all(listener.__connections.map(c => c.close()))
110111
return new Promise((resolve, reject) => {
111-
listener.__connections.forEach(maConn => maConn.close())
112112
server.close((err) => err ? reject(err) : resolve())
113113
})
114114
}

test/compliance.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
'use strict'
33

44
const tests = require('libp2p-interfaces/src/transport/tests')
5-
const multiaddr = require('multiaddr')
5+
const { Multiaddr } = require('multiaddr')
66

77
const WDirect = require('../src')
88

@@ -12,10 +12,10 @@ describe('interface-transport compliance', () => {
1212
const ws = new WDirect({ upgrader })
1313

1414
const addrs = [
15-
multiaddr('/ip4/127.0.0.1/tcp/22222/http/p2p-webrtc-direct'),
16-
multiaddr('/ip4/127.0.0.1/tcp/33333/http/p2p-webrtc-direct'),
17-
multiaddr('/ip4/127.0.0.1/tcp/44444/http/p2p-webrtc-direct'),
18-
multiaddr('/ip4/127.0.0.1/tcp/55555/http/p2p-webrtc-direct')
15+
new Multiaddr('/ip4/127.0.0.1/tcp/22222/http/p2p-webrtc-direct'),
16+
new Multiaddr('/ip4/127.0.0.1/tcp/33333/http/p2p-webrtc-direct'),
17+
new Multiaddr('/ip4/127.0.0.1/tcp/44444/http/p2p-webrtc-direct'),
18+
new Multiaddr('/ip4/127.0.0.1/tcp/55555/http/p2p-webrtc-direct')
1919
]
2020

2121
// Used by the dial tests to simulate a delayed connect

test/dial.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const dirtyChai = require('dirty-chai')
77
const expect = chai.expect
88
chai.use(dirtyChai)
99

10-
const multiaddr = require('multiaddr')
10+
const { Multiaddr } = require('multiaddr')
1111

1212
const pipe = require('it-pipe')
1313
const { collect } = require('streaming-iterables')
@@ -23,7 +23,7 @@ const mockUpgrader = {
2323
describe('dial', function () {
2424
this.timeout(20 * 1000)
2525

26-
const ma = multiaddr('/ip4/127.0.0.1/tcp/12345/http/p2p-webrtc-direct')
26+
const ma = new Multiaddr('/ip4/127.0.0.1/tcp/12345/http/p2p-webrtc-direct')
2727
let wd
2828

2929
before(() => {
@@ -44,7 +44,7 @@ describe('dial', function () {
4444
})
4545

4646
it('dial offline / non-existent node on IPv4, check callback', async () => {
47-
const maOffline = multiaddr('/ip4/127.0.0.1/tcp/55555/http/p2p-webrtc-direct')
47+
const maOffline = new Multiaddr('/ip4/127.0.0.1/tcp/55555/http/p2p-webrtc-direct')
4848

4949
try {
5050
await wd.dial(maOffline, { config: {} })

test/filter.spec.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const chai = require('chai')
55
const dirtyChai = require('dirty-chai')
66
const expect = chai.expect
77
chai.use(dirtyChai)
8-
const multiaddr = require('multiaddr')
8+
const { Multiaddr } = require('multiaddr')
99

1010
const WebRTCDirect = require('../src')
1111

@@ -18,11 +18,11 @@ describe('filter', () => {
1818
it('filters non valid webrtc-direct multiaddrs', () => {
1919
const wd = new WebRTCDirect({ upgrader: mockUpgrader })
2020
const maArr = [
21-
multiaddr('/ip4/1.2.3.4/tcp/3456/http/p2p-webrtc-direct'),
22-
multiaddr('/ip4/127.0.0.1/tcp/9090/ws'),
23-
multiaddr('/ip4/127.0.0.1/tcp/9090/ws/p2p-webrtc-direct/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo2'),
24-
multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4'),
25-
multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4' +
21+
new Multiaddr('/ip4/1.2.3.4/tcp/3456/http/p2p-webrtc-direct'),
22+
new Multiaddr('/ip4/127.0.0.1/tcp/9090/ws'),
23+
new Multiaddr('/ip4/127.0.0.1/tcp/9090/ws/p2p-webrtc-direct/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo2'),
24+
new Multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4'),
25+
new Multiaddr('/ip4/127.0.0.1/tcp/9090/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4' +
2626
'/p2p-circuit/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo5')
2727
]
2828

@@ -32,7 +32,7 @@ describe('filter', () => {
3232

3333
it('filter a single addr for this transport', () => {
3434
const wd = new WebRTCDirect({ upgrader: mockUpgrader })
35-
const ma = multiaddr('/ip4/127.0.0.1/tcp/9090/http/p2p-webrtc-direct')
35+
const ma = new Multiaddr('/ip4/127.0.0.1/tcp/9090/http/p2p-webrtc-direct')
3636

3737
const filtered = wd.filter(ma)
3838
expect(filtered.length).to.equal(1)

test/listen.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const dirtyChai = require('dirty-chai')
77
const expect = chai.expect
88
chai.use(dirtyChai)
99

10-
const multiaddr = require('multiaddr')
10+
const { Multiaddr } = require('multiaddr')
1111
const pipe = require('it-pipe')
1212

1313
const WebRTCDirect = require('../src')
@@ -20,7 +20,7 @@ const mockUpgrader = {
2020
describe('listen', () => {
2121
let wd
2222

23-
const ma = multiaddr('/ip4/127.0.0.1/tcp/20123/http/p2p-webrtc-direct')
23+
const ma = new Multiaddr('/ip4/127.0.0.1/tcp/20123/http/p2p-webrtc-direct')
2424

2525
before(() => {
2626
wd = new WebRTCDirect({ upgrader: mockUpgrader })
@@ -78,7 +78,7 @@ describe('listen', () => {
7878
it('should untrack conn after being closed', async function () {
7979
this.timeout(20e3)
8080

81-
const ma1 = multiaddr('/ip4/127.0.0.1/tcp/12346/http/p2p-webrtc-direct')
81+
const ma1 = new Multiaddr('/ip4/127.0.0.1/tcp/12346/http/p2p-webrtc-direct')
8282

8383
const wd1 = new WebRTCDirect({ upgrader: mockUpgrader })
8484
const listener1 = wd1.createListener((conn) => pipe(conn, conn))
@@ -104,7 +104,7 @@ describe('listen', () => {
104104
it('should have remoteAddress in listener connection', async function () {
105105
this.timeout(20e3)
106106

107-
const ma1 = multiaddr('/ip4/127.0.0.1/tcp/12346/http/p2p-webrtc-direct')
107+
const ma1 = new Multiaddr('/ip4/127.0.0.1/tcp/12346/http/p2p-webrtc-direct')
108108

109109
const wd1 = new WebRTCDirect({ upgrader: mockUpgrader })
110110
const listener1 = wd1.createListener((conn) => {

0 commit comments

Comments
 (0)