{"bugs":{"url":"https://github.com/libp2p/js-libp2p/issues"},"dist":{"shasum":"3111737a3d61aa7ca9acfec0be2fbc5df11bfc59","tarball":"https://registry.npmjs.org/@libp2p/interface-connection-encrypter/-/interface-connection-encrypter-4.0.1-1c6702c8.tgz","fileCount":14,"integrity":"sha512-vDL8DYAxpcj8I+lhBSTqfpJGsleNa60lFheSqNc68si1M1kyuDFQVBctsnDBqXb1G2dp0wXROXHGU9K5+cp43w==","signatures":[{"sig":"MEUCIQDkDiDgUtYG/mFaMLj347OXcQ+gJxuiD5rYqX1ctXA6cAIgafxC0CPxToVHEu5xjh5rtn+q7dyWJBCA64k/UL3FIzM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16092},"name":"@libp2p/interface-connection-encrypter","type":"module","types":"./dist/src/index.d.ts","readme":"# @libp2p/interface-connection-encrypter <!-- omit in toc -->\n\n[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/)\n[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io)\n[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p)\n[![CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/main.yml?branch=master\\&style=flat-square)](https://github.com/libp2p/js-libp2p/actions/workflows/main.yml?query=branch%3Amaster)\n\n> Connection Encrypter interface for libp2p\n\n## Table of contents <!-- omit in toc -->\n\n- [Install](#install)\n- [API](#api)\n  - [Secure Inbound](#secure-inbound)\n  - [Secure Outbound](#secure-outbound)\n- [Crypto Errors](#crypto-errors)\n  - [Error Types](#error-types)\n- [API Docs](#api-docs)\n- [License](#license)\n- [Contribution](#contribution)\n\n## Install\n\n```console\n$ npm i @libp2p/interface-connection-encrypter\n```\n\n**Modules that implement the interface**\n\n- [@chainSafe/js-libp2p-noise](https://github.com/ChainSafe/js-libp2p-noise)\n- [js-libp2p-secio](https://github.com/NodeFactoryIo/js-libp2p-secio)\n\n## API\n\n- `Crypto`\n  - `protocol<string>`: The protocol id of the crypto module.\n  - `secureInbound<function(PeerId, duplex)>`: Secures inbound connections.\n  - `secureOutbound<function(PeerId, duplex, PeerId)>`: Secures outbound connections.\n\n### Secure Inbound\n\n- `const { conn, remotePeer } = await crypto.secureInbound(localPeer, duplex, [remotePeer])`\n\nSecures an inbound [streaming iterable duplex][iterable-duplex] connection. It returns an encrypted [streaming iterable duplex][iterable-duplex], as well as the [PeerId][peer-id] of the remote peer.\n\n**Parameters**\n\n- `localPeer` is the [PeerId][peer-id] of the receiving peer.\n- `duplex` is the [streaming iterable duplex][iterable-duplex] that will be encryption.\n- `remotePeer` is the optional [PeerId][peer-id] of the initiating peer, if known. This may only exist during transport upgrades.\n\n**Return Value**\n\n- `<object>`\n  - `conn<duplex>`: An encrypted [streaming iterable duplex][iterable-duplex].\n  - `remotePeer<PeerId>`: The [PeerId][peer-id] of the remote peer.\n\n### Secure Outbound\n\n- `const { conn, remotePeer } = await crypto.secureOutbound(localPeer, duplex, remotePeer)`\n\nSecures an outbound [streaming iterable duplex][iterable-duplex] connection. It returns an encrypted [streaming iterable duplex][iterable-duplex], as well as the [PeerId][peer-id] of the remote peer.\n\n**Parameters**\n\n- `localPeer` is the [PeerId][peer-id] of the receiving peer.\n- `duplex` is the [streaming iterable duplex][iterable-duplex] that will be encrypted.\n- `remotePeer` is the [PeerId][peer-id] of the remote peer. If provided, implementations **should** use this to validate the integrity of the remote peer.\n\n**Return Value**\n\n- `<object>`\n  - `conn<duplex>`: An encrypted [streaming iterable duplex][iterable-duplex].\n  - `remotePeer<PeerId>`: The [PeerId][peer-id] of the remote peer. This **should** match the `remotePeer` parameter, and implementations should enforce this.\n\n## Crypto Errors\n\nCommon crypto errors come with the interface, and can be imported directly. All Errors take an optional message.\n\n```js\nconst {\n  InvalidCryptoExchangeError,\n  InvalidCryptoTransmissionError,\n  UnexpectedPeerError\n} = require('libp2p-interfaces/src/crypto/errors')\n\nconst error = new UnexpectedPeerError('a custom error message')\nconsole.log(error.code === UnexpectedPeerError.code) // true\n```\n\n### Error Types\n\n- `InvalidCryptoExchangeError` - Should be thrown when a peer provides data that is insufficient to finish the crypto exchange.\n- `InvalidCryptoTransmissionError` - Should be thrown when an error occurs during encryption/decryption.\n- `UnexpectedPeerError` - Should be thrown when the expected peer id does not match the peer id determined via the crypto exchange.\n\n## API Docs\n\n- <https://libp2p.github.io/js-libp2p/modules/_libp2p_interface_connection_encrypter.html>\n\n## License\n\nLicensed under either of\n\n- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)\n- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)\n\n## Contribution\n\nUnless 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.\n\n[peer-id]: https://github.com/libp2p/js-peer-id\n\n[iterable-duplex]: https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9#duplex-it\n","exports":{".":{"types":"./dist/src/index.d.ts","import":"./dist/src/index.js"},"./errors":{"types":"./dist/src/errors.d.ts","import":"./dist/src/errors.js"}},"gitHead":"1c6702c8a48a25e97910c0821f748802edf9ac42","license":"Apache-2.0 OR MIT","release":{"plugins":[["@semantic-release/commit-analyzer",{"preset":"conventionalcommits","releaseRules":[{"release":"major","breaking":true},{"revert":true,"release":"patch"},{"type":"feat","release":"minor"},{"type":"fix","release":"patch"},{"type":"docs","release":"patch"},{"type":"test","release":"patch"},{"type":"deps","release":"patch"},{"scope":"no-release","release":false}]}],["@semantic-release/release-notes-generator",{"preset":"conventionalcommits","presetConfig":{"types":[{"type":"feat","section":"Features"},{"type":"fix","section":"Bug Fixes"},{"type":"chore","section":"Trivial Changes"},{"type":"docs","section":"Documentation"},{"type":"deps","section":"Dependencies"},{"type":"test","section":"Tests"}]}}],"@semantic-release/changelog","@semantic-release/npm","@semantic-release/github","@semantic-release/git"],"branches":["master"]},"scripts":{"lint":"aegir lint","build":"aegir build","clean":"aegir clean","release":"aegir release","dep-check":"aegir dep-check"},"typedoc":{"entryPoint":"./src/index.ts"},"_npmUser":{"name":"npm-service-account-libp2p","email":"npm-service-account+libp2p@protocol.ai"},"homepage":"https://github.com/libp2p/js-libp2p/tree/master/packages/interface-connection-encrypter#readme","keywords":["interface","libp2p"],"repository":{"url":"git+https://github.com/libp2p/js-libp2p.git","type":"git"},"_npmVersion":"8.19.4","description":"Connection Encrypter interface for libp2p","directories":{},"maintainers":[{"name":"jacobheun","email":"jacobheun@gmail.com"},{"name":"npm-service-account-libp2p","email":"npm-service-account+libp2p@protocol.ai"},{"name":"alanshaw","email":"alan138@gmail.com"},{"name":"vascosantos","email":"santos.vasco10@gmail.com"},{"name":"achingbrain","email":"alex@achingbrain.net"},{"name":"daviddias","email":"mail@daviddias.me"}],"_nodeVersion":"18.16.0","dependencies":{"it-stream-types":"^2.0.1","@libp2p/interface-peer-id":"2.0.2-1c6702c8"},"eslintConfig":{"extends":"ipfs","parserOptions":{"sourceType":"module"}},"typesVersions":{"*":{"*":["*","dist/*","dist/src/*","dist/src/*/index"],"src/*":["*","dist/*","dist/src/*","dist/src/*/index"]}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"aegir":"^39.0.5"},"_npmOperationalInternal":{"tmp":"tmp/interface-connection-encrypter_4.0.1-1c6702c8_1686816633990_0.41386870066157266","host":"s3://npm-registry-packages"},"_id":"@libp2p/interface-connection-encrypter@4.0.1-1c6702c8","version":"4.0.1-1c6702c8"}