# @multiformats/mafmt

> A multiaddr validator

Latest version **12.1.6** (published 2023-08-02) · Apache-2.0 OR MIT license · 0 weekly downloads

## Install

```sh
npm install @multiformats/mafmt
pnpm add @multiformats/mafmt
yarn add @multiformats/mafmt
bun add @multiformats/mafmt
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 12.1.6 |
| Published | 2023-08-02 |
| First published | 2022-01-04 |
| Weekly downloads | 0 |
| License | Apache-2.0 OR MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 86.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Maintainers | npm-service-account-multiformats, alanshaw, vascosantos, achingbrain, lidel, rvagg, daviddias, vmx, mikeal, hugomrdias |
| Keywords | multiaddr |

## Links

- npm: https://www.npmjs.com/package/@multiformats/mafmt
- Repository: https://github.com/multiformats/js-mafmt
- Homepage: https://github.com/multiformats/js-mafmt#readme
- Issues: https://github.com/multiformats/js-mafmt/issues
- npm.io page: https://npm.io/package/@multiformats/mafmt

## Dependencies (1)

- [@multiformats/multiaddr](https://npm.io/package/@multiformats/multiaddr.md) ^12.0.0

## Recent versions

- 12.1.6 (latest) — 2023-08-02
- 12.1.5 — 2023-06-01
- 12.1.4 — 2023-06-01
- 12.1.3 — 2023-05-17
- 12.1.2 — 2023-05-15
- 12.1.1 — 2023-05-15
- 12.1.0 — 2023-04-03
- 12.0.0 — 2023-03-20
- 11.1.2 — 2023-03-17
- 11.1.1 — 2023-03-17
- 11.1.0 — 2023-02-28
- 11.0.4 — 2023-02-27
- 11.0.3 — 2022-09-21
- 11.0.2 — 2022-01-08
- 11.0.1 — 2022-01-06
- … 2 more at https://npm.io/package/@multiformats/mafmt/versions

## README

# @multiformats/mafmt <!-- omit in toc -->

[![multiformats.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://multiformats.io)
[![codecov](https://img.shields.io/codecov/c/github/multiformats/js-mafmt.svg?style=flat-square)](https://codecov.io/gh/multiformats/js-mafmt)
[![CI](https://img.shields.io/github/actions/workflow/status/multiformats/js-mafmt/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/multiformats/js-mafmt/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)

> A multiaddr validator

## Table of contents <!-- omit in toc -->

- [Install](#install)
  - [Browser `<script>` tag](#browser-script-tag)
- [Usage](#usage)
- [API](#api)
  - - [`mafmt.<FORMAT>.matches(multiaddr)`](#mafmtformatmatchesmultiaddr)
- [API Docs](#api-docs)
- [License](#license)
- [Contribution](#contribution)

## Install

```console
$ 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.

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

## Usage

```js
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` <br> `/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` <br> `/dnsaddr/ipfs.io/ws`                                                                                            |
| `WebSocketsSecure` | a "wss" over `TCP` or "wss" over `DNS` format multiaddr                                                                                                                                                                   | `/ip6/::/tcp/0/wss` <br> `/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` <br> `/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` <br> `/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` <br> `/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` <br> `/ip4/127.0.0.1/tcp/20008/ws/p2p/QmUjNmr8TgJCn1Ao7DvMy4cjoZU15b9bwSCBLE3vwXiwgj`      |

Where `multiaddr` may be:

- a [Multiaddr](https://www.npmjs.com/package/@multiformats/multiaddr)
- a String
- a [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)

Returns `true`/`false`

## API Docs

- <https://multiformats.github.io/js-mafmt>

## License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

## 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.

---
_Source: https://npm.io/package/@multiformats/mafmt · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
