Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

mafmt

multiformats185.2kMIT10.0.0TypeScript support: included

A multiaddr validator

multiaddr

readme

js-mafmt

Dependency Status codecov

Javascript implementation of multiaddr validation

Lead Maintainer

Vasco Santos.

Install

npm install mafmt

Usage

const mafmt = require('mafmt')

mafmt.DNS.matches('/dns4/ipfs.io') // true

API

mafmt.<FORMAT>.matches(multiaddr)

Where <FORMAT> may be:

<FORMAT> Description Example(s)
DNS a "dns4" or "dns6" format multiaddr /dnsaddr/ipfs.io
DNS4 a "dns4" format multiaddr /dns4/ipfs.io
DNS6 a "dns6" format multiaddr /dns6/protocol.ai/tcp/80
IP an "ip4" or "ip6" format multiaddr /ip4/127.0.0.1
/ip6/fc00::
TCP a "tcp" over IP format multiaddr /ip4/0.0.7.6/tcp/1234
UDP a "udp" over IP format multiaddr /ip4/0.0.7.6/udp/1234
QUIC a "quic" over UDP format multiaddr /ip4/1.2.3.4/udp/1234/quic
UTP a "utp" over UDP format multiaddr /ip4/1.2.3.4/udp/3456/utp
Websockets a "ws" over TCP or "ws" over DNS format multiaddr /ip4/1.2.3.4/tcp/3456/ws
/dnsaddr/ipfs.io/ws
WebSocketsSecure a "wss" over TCP or "wss" over DNS format multiaddr /ip6/::/tcp/0/wss
/dnsaddr/ipfs.io/wss
HTTP a "http" over TCP or DNS or "http" over DNS format multiaddr /ip4/127.0.0.1/tcp/90/http
/dnsaddr/ipfs.io/http
HTTPS a "https" over TCP or DNS or "https" over DNS format multiaddr /ip4/127.0.0.1/tcp/90/https
/dnsaddr/ipfs.io/https
WebRTCStar a "p2p" over "p2p-webrtc-star" over Websockets or "p2p" over "p2p-webrtc-star" over WebSocketsSecure format multiaddr /dnsaddr/ipfs.io/wss/p2p-webrtc-star/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4
WebSocketStar a "p2p" over "p2p-websocket-star" over Websockets or "p2p" over "p2p-websocket-star" over WebSocketsSecure or "p2p-websocket-star" over Websockets or "p2p-websocket-star" over WebSocketsSecure format multiaddr /ip4/1.2.3.4/tcp/3456/ws/p2p-websocket-star
/dnsaddr/localhost/ws/p2p-websocket-star/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4
WebRTCDirect a "p2p-webrtc-direct" over HTTP or "p2p-webrtc-direct" over HTTPS format multiaddr /ip4/1.2.3.4/tcp/3456/http/p2p-webrtc-direct
Reliable a WebSockets or WebSocketsSecure or HTTP or HTTPS or WebRTCStar or WebRTCDirect or TCP or UTP or QUIC format multiaddr /dnsaddr/ipfs.io/wss
Circuit | /p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4/p2p-circuit/p2p/QmUjNmr8TgJCn1Ao7DvMy4cjoZU15b9bwSCBLE3vwXiwgj
P2P "p2p", aka "ipfs", over Reliable or WebRTCStar or "p2p" format multiaddr /p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4
/ip4/127.0.0.1/tcp/20008/ws/p2p/QmUjNmr8TgJCn1Ao7DvMy4cjoZU15b9bwSCBLE3vwXiwgj

Where multiaddr may be:

Returns true/false

changelog

10.0.0 (2021-07-07)

chore

BREAKING CHANGES

  • uses new major of multiaddr module

9.0.0 (2021-04-11)

8.0.4 (2021-01-13)

Features

8.0.3 (2021-01-11)

Bug Fixes

  • add webrtc direct with p2p as valid P2P multiaddr (#71) (c8430c1)

8.0.2 (2020-12-28)

8.0.1 (2020-10-27)

Bug Fixes

  • replace node buffers with uint8arrays (#59) (022ab87)

Features

BREAKING CHANGES

    • Now uses a version of multiaddr than has a .bytes property instead of .buffer

8.0.0 (2020-08-10)

Bug Fixes

  • replace node buffers with uint8arrays (#59) (022ab87)

BREAKING CHANGES

    • Now uses a version of multiaddr than has a .bytes property instead of .buffer

7.1.0 (2020-02-06)

Features

  • add typescript types + type tests (#48) (74830fa)

7.0.1 (2020-01-23)

Bug Fixes

  • webrtc-star should not require the p2p codec (#47) (7112ab7)

7.0.0 (2019-09-11)

6.0.10 (2019-09-11)

6.0.9 (2019-09-10)

6.0.8 (2019-08-08)

Features

6.0.7 (2019-02-26)

Features

6.0.6 (2019-02-07)

Features

6.0.5 (2019-01-25)

Bug Fixes

  • do not throw if multiaddr str is invalid, fixes #25 (#36) (5187d59)

6.0.4 (2019-01-08)

Bug Fixes

6.0.3 (2018-12-05)

6.0.2 (2018-09-12)

Features

6.0.1 (2018-08-28)

Features

  • adds HTTPS validation and HTTP(s) tests (87c4202)

6.0.0 (2018-04-05)

5.0.0 (2018-04-05)

4.0.0 (2018-02-12)

3.1.0 (2018-02-12)

Features

3.0.2 (2017-10-24)

3.0.1 (2017-09-06)

Features

  • Update to multiaddr v3.0.1 - refactor: websocket{s => }-star (#19) (2f336e3)

3.0.0 (2017-09-03)

Features

  • fix p2p addrs situation (5fbb424)

2.1.8 (2017-03-27)

Features

  • add support for recursive addresses (2e28d27)
  • adding support for ports in resolvable addresses (a1f9ccd)

2.1.7 (2017-03-22)

Bug Fixes

Features

  • adding circuit addresses (c05c1af)
  • adding support for ports in resolvable addresses (8c188dd)
  • allow p2p-circuit to come as an additional transport (2f604c3)

2.1.6 (2017-01-22)

Features

  • add support for dns validation, make IPFS validation much nicer, es6ify (ade442f)
  • rules for dns4 and dns6 (1d4aa10)
  • WebSocketsSecure (3b99a73)

2.1.5 (2017-01-16)

Bug Fixes

  • point to the right entry point, change due to aegir 9 (bd81b68)

2.1.4 (2017-01-16)

Features

  • add WebRTC Direct support for filtering (db00d97)

2.1.3 (2017-01-16)

2.1.2 (2016-08-22)

Features

2.1.1 (2016-05-28)

2.1.0 (2016-05-22)

2.0.2 (2016-05-21)

2.0.1 (2016-05-21)

2.0.0 (2016-05-17)