# @libp2p/peer-id-factory

> Create PeerId instances

Latest version **4.2.4** (published 2024-08-15) · Apache-2.0 OR MIT license · 0 weekly downloads

## Install

```sh
npm install @libp2p/peer-id-factory
pnpm add @libp2p/peer-id-factory
yarn add @libp2p/peer-id-factory
bun add @libp2p/peer-id-factory
```

## Health

**Score 50/100 (C)** — status: abandoned.

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

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 4.2.4 |
| Published | 2024-08-15 |
| First published | 2022-01-04 |
| Weekly downloads | 0 |
| License | Apache-2.0 OR MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 6 |
| Unpacked size | 173.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 2579 |
| Maintainers | jacobheun, npm-service-account-libp2p, alanshaw, vascosantos, achingbrain, daviddias |
| Keywords | IPFS |

## Links

- npm: https://www.npmjs.com/package/@libp2p/peer-id-factory
- Repository: https://github.com/libp2p/js-libp2p
- Homepage: https://github.com/libp2p/js-libp2p/tree/main/packages/peer-id-factory#readme
- Issues: https://github.com/libp2p/js-libp2p/issues
- npm.io page: https://npm.io/package/@libp2p/peer-id-factory

## Dependencies (6)

- [uint8arrays](https://npm.io/package/uint8arrays.md) ^5.1.0
- [@libp2p/crypto](https://npm.io/package/@libp2p/crypto.md) ^4.1.9
- [uint8arraylist](https://npm.io/package/uint8arraylist.md) ^2.4.8
- [@libp2p/peer-id](https://npm.io/package/@libp2p/peer-id.md) ^4.2.4
- [protons-runtime](https://npm.io/package/protons-runtime.md) ^5.4.0
- [@libp2p/interface](https://npm.io/package/@libp2p/interface.md) ^1.7.0

## Recent versions

- 4.2.4 (latest) — 2024-08-15
- 4.2.4-dd7b329c4 (next) — 2024-09-05
- 4.2.4-737b3ea5b — 2024-09-04
- 4.2.4-2265e59ba — 2024-09-04
- 4.2.4-1675adee2 — 2024-08-30
- 4.2.4-7655e5200 — 2024-08-29
- 4.2.4-50b897139 — 2024-08-29
- 4.2.4-e211b46cc — 2024-08-29
- 4.2.4-3c8dd5bbf — 2024-08-17
- 4.2.4-359265a3a — 2024-08-16
- 4.2.3-1dfb74e79 — 2024-08-15
- 4.2.3-7939dbd5c — 2024-08-14
- 4.2.3-c5dba70a9 — 2024-08-13
- 4.2.3-0edbfe7af — 2024-08-09
- 4.2.3 — 2024-08-02
- … 433 more at https://npm.io/package/@libp2p/peer-id-factory/versions

## README

# @libp2p/peer-id-factory

[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)
[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p)
[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/main.yml?branch=main\&style=flat-square)](https://github.com/libp2p/js-libp2p/actions/workflows/main.yml?query=branch%3Amain)

> Create PeerId instances

# About

<!--

!IMPORTANT!

Everything in this README between "# About" and "# Install" is automatically
generated and will be overwritten the next time the doc generator is run.

To make changes to this section, please update the @packageDocumentation section
of src/index.js or src/index.ts

To experiment with formatting, please run "npm run docs" from the root of this
repo and examine the changes made.

-->

Generate, import, and export PeerIDs.

A Peer ID is the SHA-256 [multihash](https://github.com/multiformats/multihash) of a public key.

The public key is a base64 encoded string of a protobuf containing an RSA DER buffer. This uses a node buffer to pass the base64 encoded public key protobuf to the multihash for ID generation.

## Example

```TypeScript
import { createEd25519PeerId } from '@libp2p/peer-id-factory'

const peerId = await createEd25519PeerId()
console.log(peerId.toString())
```

```bash
12D3KooWRm8J3iL796zPFi2EtGGtUJn58AG67gcqzMFHZnnsTzqD
```

# Install

```console
$ npm i @libp2p/peer-id-factory
```

## Browser `<script>` tag

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

```html
<script src="https://unpkg.com/@libp2p/peer-id-factory/dist/index.min.js"></script>
```

# API Docs

- <https://libp2p.github.io/js-libp2p/modules/_libp2p_peer_id_factory.html>

# License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](https://github.com/libp2p/js-libp2p/blob/main/packages/peer-id-factory/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](https://github.com/libp2p/js-libp2p/blob/main/packages/peer-id-factory/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/@libp2p/peer-id-factory · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
