mirror of
https://github.com/fluencelabs/js-mafmt
synced 2025-04-25 15:22:38 +00:00
feat: Update to multiaddr v3.0.1 - refactor: websocket{s => }-star (#19)
* chore: Update to multiaddr v3.0.1 - refactor: websocket{s => }-star * fix: Some valid websocket-star addresses were filtered as invalid
This commit is contained in:
parent
41a8a85e6a
commit
2f336e3873
@ -38,7 +38,7 @@
|
|||||||
"pre-commit": "^1.2.2"
|
"pre-commit": "^1.2.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"multiaddr": "^3.0.0"
|
"multiaddr": "^3.0.1"
|
||||||
},
|
},
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"David Dias <daviddias.p@gmail.com>",
|
"David Dias <daviddias.p@gmail.com>",
|
||||||
@ -47,4 +47,4 @@
|
|||||||
"dignifiedquire <dignifiedquire@gmail.com>",
|
"dignifiedquire <dignifiedquire@gmail.com>",
|
||||||
"dmitriy ryajov <dryajov@dmitriys-MBP.HomeNET>"
|
"dmitriy ryajov <dryajov@dmitriys-MBP.HomeNET>"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
11
src/index.js
11
src/index.js
@ -44,10 +44,11 @@ const WebRTCStar = or(
|
|||||||
and(WebSocketsSecure, base('p2p-webrtc-star'), base('ipfs'))
|
and(WebSocketsSecure, base('p2p-webrtc-star'), base('ipfs'))
|
||||||
)
|
)
|
||||||
|
|
||||||
const WebSocketsStar = or(
|
const WebSocketStar = or(
|
||||||
and(WebSockets, base('p2p-websockets-star')),
|
and(WebSockets, base('p2p-websocket-star'), base('ipfs')),
|
||||||
and(WebSockets, base('p2p-websockets-star'), base('ipfs')),
|
and(WebSocketsSecure, base('p2p-websocket-star'), base('ipfs')),
|
||||||
and(WebSocketsSecure, base('p2p-websockets-star'), base('ipfs'))
|
and(WebSockets, base('p2p-websocket-star')),
|
||||||
|
and(WebSocketsSecure, base('p2p-websocket-star'))
|
||||||
)
|
)
|
||||||
|
|
||||||
const WebRTCDirect = and(HTTP, base('p2p-webrtc-direct'))
|
const WebRTCDirect = and(HTTP, base('p2p-webrtc-direct'))
|
||||||
@ -102,7 +103,7 @@ exports.UTP = UTP
|
|||||||
exports.HTTP = HTTP
|
exports.HTTP = HTTP
|
||||||
exports.WebSockets = WebSockets
|
exports.WebSockets = WebSockets
|
||||||
exports.WebSocketsSecure = WebSocketsSecure
|
exports.WebSocketsSecure = WebSocketsSecure
|
||||||
exports.WebSocketsStar = WebSocketsStar
|
exports.WebSocketStar = WebSocketStar
|
||||||
exports.WebRTCStar = WebRTCStar
|
exports.WebRTCStar = WebRTCStar
|
||||||
exports.WebRTCDirect = WebRTCDirect
|
exports.WebRTCDirect = WebRTCDirect
|
||||||
exports.Reliable = Reliable
|
exports.Reliable = Reliable
|
||||||
|
@ -84,9 +84,11 @@ describe('multiaddr validation', function () {
|
|||||||
'/ip6/::/tcp/0/http/p2p-webrtc-direct'
|
'/ip6/::/tcp/0/http/p2p-webrtc-direct'
|
||||||
]
|
]
|
||||||
|
|
||||||
const goodWebSocketsStar = [
|
const goodWebSocketStar = [
|
||||||
'/ip4/1.2.3.4/tcp/3456/ws/p2p-websockets-star',
|
'/ip4/1.2.3.4/tcp/3456/ws/p2p-websocket-star',
|
||||||
'/ip6/::/tcp/0/ws/p2p-websockets-star'
|
'/ip6/::/tcp/0/ws/p2p-websocket-star',
|
||||||
|
'/dns/localhost/ws/p2p-websocket-star/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4',
|
||||||
|
'/ip4/1.2.3.4/tcp/3456/ws/p2p-websocket-star/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4'
|
||||||
]
|
]
|
||||||
|
|
||||||
const badWS = [
|
const badWS = [
|
||||||
@ -186,9 +188,9 @@ describe('multiaddr validation', function () {
|
|||||||
assertMismatches(mafmt.WebSocketsSecure, goodIP, badWSS, goodUDP, badWS)
|
assertMismatches(mafmt.WebSocketsSecure, goodIP, badWSS, goodUDP, badWS)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('WebSocketsStar validation', function () {
|
it('WebSocketStar validation', function () {
|
||||||
assertMatches(mafmt.WebSocketsStar, goodWebSocketsStar)
|
assertMatches(mafmt.WebSocketStar, goodWebSocketStar)
|
||||||
assertMismatches(mafmt.WebSocketsStar, goodIP, goodUDP, badWS)
|
assertMismatches(mafmt.WebSocketStar, goodIP, goodUDP, badWS)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('WebRTCStar validation', function () {
|
it('WebRTCStar validation', function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user