Comparing version 2.1.5 to 2.1.6
{ | ||
"name": "mafmt", | ||
"version": "2.1.5", | ||
"version": "2.1.6", | ||
"description": "A multiaddr validator", | ||
@@ -36,3 +36,3 @@ "main": "src/index.js", | ||
"devDependencies": { | ||
"aegir": "^9.3.0", | ||
"aegir": "^9.3.3", | ||
"chai": "^3.5.0", | ||
@@ -42,3 +42,3 @@ "pre-commit": "^1.2.2" | ||
"dependencies": { | ||
"multiaddr": "^2.1.3" | ||
"multiaddr": "^2.2.0" | ||
}, | ||
@@ -45,0 +45,0 @@ "contributors": [ |
'use strict' | ||
var multiaddr = require('multiaddr') | ||
const multiaddr = require('multiaddr') | ||
var IP = or(base('ip4'), base('ip6')) | ||
var TCP = and(IP, base('tcp')) | ||
var UDP = and(IP, base('udp')) | ||
var UTP = and(UDP, base('utp')) | ||
var WebSockets = and(TCP, base('ws')) | ||
var HTTP = and(TCP, base('http')) | ||
var WebRTCStar = and(base('libp2p-webrtc-star'), WebSockets, base('ipfs')) | ||
var WebRTCDirect = and(base('libp2p-webrtc-direct'), HTTP) | ||
var Reliable = or(WebSockets, TCP, UTP) | ||
/* | ||
* Valid combinations | ||
*/ | ||
const DNS4 = base('dns4') | ||
const DNS6 = base('dns6') | ||
const DNS = or( | ||
base('dns'), | ||
DNS4, | ||
DNS6 | ||
) | ||
// required cause some transports are already IPFS aware (like WebRTCStar) | ||
var IPFS = { | ||
matches: function (args) { | ||
var IPFS = and(Reliable, base('ipfs')) | ||
return IPFS.matches(args) || WebRTCStar.matches(args) | ||
} | ||
} | ||
const IP = or(base('ip4'), base('ip6')) | ||
const TCP = and(IP, base('tcp')) | ||
const UDP = and(IP, base('udp')) | ||
const UTP = and(UDP, base('utp')) | ||
const WebSockets = or( | ||
and(TCP, base('ws')), | ||
and(DNS, base('ws')) | ||
) | ||
const WebSocketsSecure = or( | ||
and(TCP, base('wss')), | ||
and(DNS, base('wss')) | ||
) | ||
const HTTP = or( | ||
and(TCP, base('http')), | ||
and(DNS), | ||
and(DNS, base('http')) | ||
) | ||
const WebRTCStar = or( | ||
and(base('libp2p-webrtc-star'), WebSockets, base('ipfs')), | ||
and(base('libp2p-webrtc-star'), WebSocketsSecure, base('ipfs')) | ||
) | ||
const WebRTCDirect = and(base('libp2p-webrtc-direct'), HTTP) | ||
const Reliable = or( | ||
WebSockets, | ||
WebSocketsSecure, | ||
HTTP, | ||
WebRTCStar, | ||
WebRTCDirect, | ||
TCP, | ||
UTP | ||
) | ||
const IPFS = or( | ||
and(Reliable, base('ipfs')), | ||
WebRTCStar | ||
) | ||
exports.DNS = DNS | ||
exports.DNS4 = DNS4 | ||
exports.DNS6 = DNS6 | ||
exports.IP = IP | ||
@@ -29,2 +68,3 @@ exports.TCP = TCP | ||
exports.WebSockets = WebSockets | ||
exports.WebSocketsSecure = WebSocketsSecure | ||
exports.WebRTCStar = WebRTCStar | ||
@@ -35,4 +75,8 @@ exports.WebRTCDirect = WebRTCDirect | ||
/* | ||
* Validation funcs | ||
*/ | ||
function and () { | ||
var args = Array.from(arguments) | ||
const args = Array.from(arguments) | ||
@@ -43,3 +87,3 @@ function matches (a) { | ||
} | ||
var out = partialMatch(a.protoNames()) | ||
let out = partialMatch(a.protoNames()) | ||
if (out === null) { | ||
@@ -73,3 +117,3 @@ return false | ||
function or () { | ||
var args = Array.from(arguments) | ||
const args = Array.from(arguments) | ||
@@ -80,3 +124,3 @@ function matches (a) { | ||
} | ||
var out = partialMatch(a.protoNames()) | ||
const out = partialMatch(a.protoNames()) | ||
if (out === null) { | ||
@@ -89,5 +133,5 @@ return false | ||
function partialMatch (a) { | ||
var out = null | ||
let out = null | ||
args.some(function (arg) { | ||
var res = arg.partialMatch(a) | ||
const res = arg.partialMatch(a) | ||
if (res) { | ||
@@ -102,3 +146,3 @@ out = res | ||
var result = { | ||
const result = { | ||
toString: function () { return '{ ' + args.join(' ') + ' }' }, | ||
@@ -114,3 +158,3 @@ input: args, | ||
function base (n) { | ||
var name = n | ||
const name = n | ||
function matches (a) { | ||
@@ -121,3 +165,3 @@ if (typeof a === 'string') { | ||
var pnames = a.protoNames() | ||
const pnames = a.protoNames() | ||
if (pnames.length === 1 && pnames[0] === name) { | ||
@@ -124,0 +168,0 @@ return true |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
622592
8173
Updatedmultiaddr@^2.2.0