# @arve.knudsen/libp2p-secio

> Secio implementation in JavaScript

Latest version **0.11.6** (published 2019-07-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install @arve.knudsen/libp2p-secio
pnpm add @arve.knudsen/libp2p-secio
yarn add @arve.knudsen/libp2p-secio
bun add @arve.knudsen/libp2p-secio
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.11.6 |
| Published | 2019-07-11 |
| First published | 2019-07-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 16 |
| Unpacked size | 35.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | arve.knudsen |
| Keywords | IPFS, libp2p, crypto, rsa |

## Links

- npm: https://www.npmjs.com/package/@arve.knudsen/libp2p-secio
- Repository: https://github.com/aknuds1/js-libp2p-secio
- Issues: https://github.com/aknuds1/js-libp2p-secio/issues
- npm.io page: https://npm.io/package/@arve.knudsen/libp2p-secio

## Dependencies (16)

- [once](https://npm.io/package/once.md) ^1.4.0
- [async](https://npm.io/package/async.md) ^2.6.2
- [debug](https://npm.io/package/debug.md) ^4.1.1
- [protons](https://npm.io/package/protons.md) ^1.0.1
- [multiaddr](https://npm.io/package/multiaddr.md) ^6.0.6
- [pull-defer](https://npm.io/package/pull-defer.md) ~0.2.3
- [multihashes](https://npm.io/package/multihashes.md) ^0.4.15
- [pull-stream](https://npm.io/package/pull-stream.md) ^3.6.9
- [safe-buffer](https://npm.io/package/safe-buffer.md) ^5.1.2
- [libp2p-crypto](https://npm.io/package/libp2p-crypto.md) ~0.16.1
- [pull-handshake](https://npm.io/package/pull-handshake.md) ^1.1.4
- [multihashing-async](https://npm.io/package/multihashing-async.md) ~0.6.0
- [interface-connection](https://npm.io/package/interface-connection.md) ~0.3.3
- [pull-length-prefixed](https://npm.io/package/pull-length-prefixed.md) ^1.3.2
- [@arve.knudsen/peer-id](https://npm.io/package/@arve.knudsen/peer-id.md) ~0.13.1
- [@arve.knudsen/peer-info](https://npm.io/package/@arve.knudsen/peer-info.md) ~0.15.1

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 0.11.6 (latest) — 2019-07-11
- 0.11.5 — 2019-07-11
- 0.11.4 — 2019-07-10
- 0.11.3 — 2019-07-09
- 0.11.2 — 2019-07-09

## README

# js-libp2p-secio

[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai)
[![](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)
[![](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p)
[![Discourse posts](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg)](https://discuss.libp2p.io)
[![](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-secio.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-secio)
[![](https://img.shields.io/travis/libp2p/js-libp2p-secio.svg?style=flat-square)](https://travis-ci.com/libp2p/js-libp2p-secio)
[![Dependency Status](https://david-dm.org/libp2p/js-libp2p-secio.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-secio)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
![](https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square)
![](https://img.shields.io/badge/Node.js-%3E%3D6.0.0-orange.svg?style=flat-square)


> SECIO implementation in JavaScript

This repo contains the JavaScript implementation of secio, an encryption protocol used in libp2p. This is based on this [go implementation](https://github.com/libp2p/go-libp2p-secio).

## Lead Maintainer

[Friedel Ziegelmayer](https://github.com/dignifiedquire/)

## Table of Contents

- [Install](#install)
- [Usage](#usage)
- [API](#api)
- [Contribute](#contribute)
- [License](#license)

## Install

```sh
npm install libp2p-secio
```

## Usage

```js
const secio = require('libp2p-secio')
```

## API

### `.tag`

The current `secio` tag, usable in `multistream`.

### `const encryptedConnection = secio.encrypt(localPeerId, plainTextConnection [, remotePeerId] [, callback])`

- `localPeerId: PeerId` - A PeerId object containing the Private, Public and Id of our node.
- `plainTextConnection: Connection` - The insecure connection to be secured.
- `remotePeerId: PeerId` - A PeerId object containing the Public and/or Id of the node we are doing the SECIO handshake with.
- `callback: Function` - Optional, Called if an error happens during the initialization.

Returns an encrypted [Connection object](https://github.com/libp2p/interface-connection) that is the upgraded `plainTextConnection` with now having every byte encripted.

Both plainTextConnection and encryptedConnection are at their base, PullStreams.

### This module uses `pull-streams`

We expose a streaming interface based on `pull-streams`, rather then on the Node.js core streams implementation (aka Node.js streams). `pull-streams` offers us a better mechanism for error handling and flow control guarantees. If you would like to know more about why we did this, see the discussion at this [issue](https://github.com/ipfs/js-ipfs/issues/362).

You can learn more about pull-streams at:

- [The history of Node.js streams, nodebp April 2014](https://www.youtube.com/watch?v=g5ewQEuXjsQ)
- [The history of streams, 2016](http://dominictarr.com/post/145135293917/history-of-streams)
- [pull-streams, the simple streaming primitive](http://dominictarr.com/post/149248845122/pull-streams-pull-streams-are-a-very-simple)
- [pull-streams documentation](https://pull-stream.github.io/)

#### Converting `pull-streams` to Node.js Streams

If you are a Node.js streams user, you can convert a pull-stream to a Node.js stream using the module [`pull-stream-to-stream`](https://github.com/pull-stream/pull-stream-to-stream), giving you an instance of a Node.js stream that is linked to the pull-stream. For example:

```js
const pullToStream = require('pull-stream-to-stream')

const nodeStreamInstance = pullToStream(pullStreamInstance)
// nodeStreamInstance is an instance of a Node.js Stream
```

To learn more about this utility, visit https://pull-stream.github.io/#pull-stream-to-stream.

## Contribute

Feel free to join in. All welcome. Open an [issue](https://github.com/libp2p/js-libp2p-secio/issues)!

This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).

[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/contributing.md)

## License

[MIT](LICENSE)

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