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

Package detail

@multiformats/mafmt

multiformats150.3kApache-2.0 OR MIT12.1.6TypeScript support: included

A multiaddr validator

multiaddr

readme

@multiformats/mafmt

multiformats.io codecov CI

A multiaddr validator

Table of contents

Install

$ npm i @multiformats/mafmt

Browser <script> tag

Loading this module through a script tag will make it's exports available as MultiformatsMafmt in the global namespace.

<script src="https://unpkg.com/@multiformats/mafmt/dist/index.min.js"></script>

Usage

import * as mafmt from '@multiformats/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

API Docs

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

changelog

12.1.6 (2023-08-02)

Dependencies

  • dev: bump aegir from 39.0.13 to 40.0.8 (#160) (46d0b71)

12.1.5 (2023-06-01)

Bug Fixes

12.1.4 (2023-06-01)

Bug Fixes

  • match websocket addresses that include a peer id (#156) (080936f)

12.1.3 (2023-05-17)

Bug Fixes

12.1.2 (2023-05-15)

Dependencies

  • dev: bump aegir from 38.1.8 to 39.0.6 (#152) (72bdf8e)

12.1.1 (2023-05-15)

Bug Fixes

12.1.0 (2023-04-03)

Features

12.0.0 (2023-03-20)

⚠ BREAKING CHANGES

  • the existing WebRTCDirect multicodec name has been deprecated and renamed P2PWebRTCDirect. The new WebRTCDirect codec has been added but is not the same, please check your code before upgrading! Integer codes are unchanged.

Bug Fixes

  • Rename WebRTCDirect to P2PWebRTCDirect and deprecate (#146) (92f92d7)

11.1.2 (2023-03-17)

Dependencies

  • bump @multiformats/multiaddr from 11.6.1 to 12.0.0 (#145) (cb5c927)
  • dev: bump uint8arrays from 3.1.1 to 4.0.3 (#131) (60146ce)

11.1.1 (2023-03-17)

Dependencies

  • dev: bump aegir from 37.12.1 to 38.1.7 (#142) (83f55a9)

11.1.0 (2023-02-28)

Features

11.0.4 (2023-02-27)

Bug Fixes

11.0.3 (2022-09-21)

Trivial Changes

Dependencies

  • update @multiformats/multiaddr to 11.0.0 (#123) (dc5a87f)

11.0.2 (2022-01-08)

Trivial Changes

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)