Skip to content
This repository was archived by the owner on Jun 26, 2023. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: libp2p/js-libp2p-interfaces
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: @libp2p/interface-connection-encrypter-v2.0.2
Choose a base ref
...
head repository: libp2p/js-libp2p-interfaces
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: @libp2p/interface-connection-encrypter-v3.0.0
Choose a head ref
  • 2 commits
  • 4 files changed
  • 2 contributors

Commits on Oct 4, 2022

  1. feat!: Add remoteExtensions to connection-encrypter (#293)

    * Add remoteExtensions to connection-encrypter
    
    * Use unknown instead of any
    
    * Remove remoteEarlyData
    
    * Make remoteExtensions optional
    
    * Lint
    MarcoPolo authored Oct 4, 2022
    Copy the full SHA
    501c684 View commit details
  2. chore(release): 3.0.0 [skip ci]

    ## [@libp2p/interface-connection-encrypter-v3.0.0](https://github.com/libp2p/js-libp2p-interfaces/compare/@libp2p/interface-connection-encrypter-v2.0.2...@libp2p/interface-connection-encrypter-v3.0.0) (2022-10-04)
    
    ### ⚠ BREAKING CHANGES
    
    * Add remoteExtensions to connection-encrypter (#293)
    
    ### Features
    
    * Add remoteExtensions to connection-encrypter ([#293](#293)) ([501c684](501c684))
    semantic-release-bot committed Oct 4, 2022
    Copy the full SHA
    1a85854 View commit details
11 changes: 11 additions & 0 deletions packages/interface-connection-encrypter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## [@libp2p/interface-connection-encrypter-v3.0.0](https://github.com/libp2p/js-libp2p-interfaces/compare/@libp2p/interface-connection-encrypter-v2.0.2...@libp2p/interface-connection-encrypter-v3.0.0) (2022-10-04)


### ⚠ BREAKING CHANGES

* Add remoteExtensions to connection-encrypter (#293)

### Features

* Add remoteExtensions to connection-encrypter ([#293](https://github.com/libp2p/js-libp2p-interfaces/issues/293)) ([501c684](https://github.com/libp2p/js-libp2p-interfaces/commit/501c684d792cd910de7cb9bfbda349db257ee2ca))

## [@libp2p/interface-connection-encrypter-v2.0.2](https://github.com/libp2p/js-libp2p-interfaces/compare/@libp2p/interface-connection-encrypter-v2.0.1...@libp2p/interface-connection-encrypter-v2.0.2) (2022-09-30)


2 changes: 1 addition & 1 deletion packages/interface-connection-encrypter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@libp2p/interface-connection-encrypter",
"version": "2.0.2",
"version": "3.0.0",
"description": "Connection Encrypter interface for libp2p",
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/interface-connection-encrypter#readme",
10 changes: 5 additions & 5 deletions packages/interface-connection-encrypter/src/index.ts
Original file line number Diff line number Diff line change
@@ -5,26 +5,26 @@ import type { Duplex } from 'it-stream-types'
* A libp2p connection encrypter module must be compliant to this interface
* to ensure all exchanged data between two peers is encrypted.
*/
export interface ConnectionEncrypter {
export interface ConnectionEncrypter<Extension = unknown> {
protocol: string

/**
* Encrypt outgoing data to the remote party. If the remote PeerId is known,
* pass it for extra verification, otherwise it will be determined during
* the handshake.
*/
secureOutbound: (localPeer: PeerId, connection: Duplex<Uint8Array>, remotePeer?: PeerId) => Promise<SecuredConnection>
secureOutbound: (localPeer: PeerId, connection: Duplex<Uint8Array>, remotePeer?: PeerId) => Promise<SecuredConnection<Extension>>

/**
* Decrypt incoming data. If the remote PeerId is known,
* pass it for extra verification, otherwise it will be determined during
* the handshake
*/
secureInbound: (localPeer: PeerId, connection: Duplex<Uint8Array>, remotePeer?: PeerId) => Promise<SecuredConnection>
secureInbound: (localPeer: PeerId, connection: Duplex<Uint8Array>, remotePeer?: PeerId) => Promise<SecuredConnection<Extension>>
}

export interface SecuredConnection {
export interface SecuredConnection<E> {
conn: Duplex<Uint8Array>
remoteEarlyData: Uint8Array
remoteExtensions?: E
remotePeer: PeerId
}
8 changes: 4 additions & 4 deletions packages/interface-mocks/src/connection-encrypter.ts
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ export function mockConnectionEncrypter () {
return {
conn: {
...wrapper[1],
close: async () => {},
close: async () => { },
localAddr: multiaddr('/ip4/127.0.0.1/tcp/4001'),
remoteAddr: multiaddr('/ip4/127.0.0.1/tcp/4002'),
timeline: {
@@ -63,7 +63,7 @@ export function mockConnectionEncrypter () {
conn: true
},
remotePeer,
remoteEarlyData: new Uint8Array(0)
remoteExtensions: {}
}
},
secureOutbound: async (localPeer, duplex, remotePeer) => {
@@ -95,7 +95,7 @@ export function mockConnectionEncrypter () {
return {
conn: {
...wrapper[1],
close: async () => {},
close: async () => { },
localAddr: multiaddr('/ip4/127.0.0.1/tcp/4001'),
remoteAddr: multiaddr('/ip4/127.0.0.1/tcp/4002'),
timeline: {
@@ -104,7 +104,7 @@ export function mockConnectionEncrypter () {
conn: true
},
remotePeer: peerIdFromBytes(remoteId.slice()),
remoteEarlyData: new Uint8Array(0)
remoteExtensions: {}
}
}
}