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

Commit d574b7d

Browse files
authored
chore: update deps (#128)
BREAKING CHANGE: uses new peer id, multiaddr, etc
1 parent 24cca4e commit d574b7d

File tree

6 files changed

+32
-33
lines changed

6 files changed

+32
-33
lines changed

.aegir.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const pipe = require('it-pipe')
55
const { Multiaddr } = require('multiaddr')
66

77
const ma = new Multiaddr('/ip4/127.0.0.1/tcp/12345/http/p2p-webrtc-direct')
8-
let listener
98

109
const mockUpgrader = {
1110
upgradeInbound: maConn => maConn,
@@ -14,25 +13,28 @@ const mockUpgrader = {
1413

1514
function before () {
1615
const wd = new WebRTCDirect({ upgrader: mockUpgrader })
17-
18-
listener = wd.createListener((conn) => pipe(conn, conn))
16+
const listener = wd.createListener((conn) => pipe(conn, conn))
1917
listener.on('listening', () => {
2018
console.log('listener started on:', ma.toString())
2119
})
2220
listener.on('error', console.error)
23-
return listener.listen(ma)
21+
listener.listen(ma)
22+
23+
return {
24+
listener
25+
}
2426
}
2527

26-
async function after () {
27-
await listener.close()
28+
async function after (testOptions, beforeReturn) {
29+
await beforeReturn.listener.close()
2830
// TODO: Temporary fix per wrtc issue
2931
// https://github.com/node-webrtc/node-webrtc/issues/636
3032
process.exit(0)
3133
}
3234

3335
module.exports = {
34-
hooks: {
35-
pre: before,
36-
post: after
36+
test: {
37+
before,
38+
after
3739
}
3840
}

.github/dependabot.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,3 @@ updates:
66
interval: daily
77
time: "11:00"
88
open-pull-requests-limit: 10
9-
ignore:
10-
- dependency-name: aegir
11-
versions:
12-
- 31.0.0
13-
- 31.0.1
14-
- 31.0.3

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
"lint": "aegir lint",
1414
"build": "aegir build",
1515
"docs": "aegir docs",
16-
"test": "aegir test --target node --target browser",
17-
"test:node": "aegir test --target node",
18-
"test:browser": "aegir test --target browser",
16+
"test": "aegir test --target node --target browser --timeout 60000 -- --exit",
17+
"test:node": "aegir test --target node --timeout 60000 -- --exit",
18+
"test:browser": "aegir test --target browser --timeout 60000 -- --exit",
1919
"release": "aegir release --target node --target browser",
2020
"release-minor": "aegir release --type minor --target node --target browser",
2121
"release-major": "aegir release --type major --target node --target browser",
@@ -43,12 +43,13 @@
4343
"node": ">=14.0.0"
4444
},
4545
"devDependencies": {
46-
"aegir": "^30.3.0",
46+
"aegir": "^33.2.2",
4747
"chai": "^4.3.4",
4848
"dirty-chai": "^2.0.1",
4949
"it-pipe": "^1.1.0",
50-
"multiaddr": "^9.0.1",
51-
"streaming-iterables": "^5.0.3",
50+
"libp2p-interfaces-compliance-tests": "https://gitpkg.now.sh/libp2p/js-libp2p-interfaces/packages/compliance-tests?chore/skip-abort-while-reading-for-webrtc",
51+
"multiaddr": "^10.0.0",
52+
"streaming-iterables": "^6.0.0",
5253
"webrtcsupport": "^2.2.0"
5354
},
5455
"dependencies": {
@@ -58,11 +59,10 @@
5859
"debug": "^4.3.1",
5960
"detect-node": "^2.0.4",
6061
"err-code": "^3.0.0",
61-
"libp2p-interfaces": "libp2p/js-interfaces#chore/skip-abort-while-reading-for-webrtc",
62-
"libp2p-utils": "^0.3.0",
62+
"libp2p-utils": "^0.4.1",
6363
"libp2p-webrtc-peer": "^10.0.1",
64-
"mafmt": "^9.0.0",
65-
"multibase": "^4.0.4",
64+
"mafmt": "^10.0.0",
65+
"multiformats": "^9.2.0",
6666
"once": "^1.4.0",
6767
"request": "^2.88.0",
6868
"stream-to-it": "^0.2.2",

src/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ const wrtc = require('wrtc')
1010
const SimplePeer = require('libp2p-webrtc-peer')
1111
const isNode = require('detect-node')
1212
const mafmt = require('mafmt')
13-
const multibase = require('multibase')
13+
const { base58btc } = require('multiformats/bases/base58')
1414
const request = require('request')
1515
const withIs = require('class-is')
1616
const { AbortError } = require('abortable-iterator')
1717
const toString = require('uint8arrays/to-string')
18+
const fromString = require('uint8arrays/from-string')
1819

1920
const { CODE_CIRCUIT, CODE_P2P } = require('./constants')
2021
const toConnection = require('./socket-to-conn')
@@ -129,14 +130,15 @@ class WebRTCDirect {
129130
channel.on('signal', (signal) => {
130131
const signalStr = JSON.stringify(signal)
131132
const url = 'http://' + cOpts.host + ':' + cOpts.port
132-
const path = '/?signal=' + toString(multibase.encode('base58btc', new TextEncoder().encode(signalStr)))
133+
const path = '/?signal=' + base58btc.encode(fromString(signalStr))
134+
133135
const uri = url + path
134136

135137
request.get(uri, (err, res) => {
136138
if (err) {
137139
return reject(err)
138140
}
139-
const incSignalBuf = multibase.decode(res.body)
141+
const incSignalBuf = base58btc.decode(res.body)
140142
const incSignalStr = toString(incSignalBuf)
141143
const incSignal = JSON.parse(incSignalStr)
142144
channel.signal(incSignal)

src/listener.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ log.error = debug('libp2p:webrtcdirect:listener:error')
99
const isNode = require('detect-node')
1010
const wrtc = require('wrtc')
1111
const SimplePeer = require('libp2p-webrtc-peer')
12-
const multibase = require('multibase')
12+
const { base58btc } = require('multiformats/bases/base58')
1313
const toString = require('uint8arrays/to-string')
14+
const fromString = require('uint8arrays/from-string')
1415
const toMultiaddr = require('libp2p-utils/src/ip-port-to-multiaddr')
1516

1617
const toConnection = require('./socket-to-conn')
@@ -30,7 +31,7 @@ module.exports = ({ handler, upgrader }, options = {}) => {
3031

3132
const path = req.url
3233
const incSignalStr = path.split('?signal=')[1]
33-
const incSignalBuf = multibase.decode(incSignalStr)
34+
const incSignalBuf = base58btc.decode(incSignalStr)
3435
const incSignal = JSON.parse(toString(incSignalBuf))
3536

3637
options = {
@@ -54,8 +55,8 @@ module.exports = ({ handler, upgrader }, options = {}) => {
5455
})
5556
channel.on('signal', (signal) => {
5657
const signalStr = JSON.stringify(signal)
57-
const signalEncoded = multibase.encode('base58btc', new TextEncoder().encode(signalStr))
58-
res.end(toString(signalEncoded))
58+
const signalEncoded = base58btc.encode(fromString(signalStr))
59+
res.end(Buffer.from(signalEncoded))
5960
})
6061

6162
channel.signal(incSignal)

test/compliance.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-env mocha */
22
'use strict'
33

4-
const tests = require('libp2p-interfaces/src/transport/tests')
4+
const tests = require('libp2p-interfaces-compliance-tests/src/transport')
55
const { Multiaddr } = require('multiaddr')
66

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

0 commit comments

Comments
 (0)