Skip to content

Commit

Permalink
fix!: rename connectionEncryption option to connectionEncrypters (#2691)
Browse files Browse the repository at this point in the history
To make the options more consistent, rename `connectionEncryption`
to `connectionEncrypters` in line with `streamMuxers`, `transports`,
etc.

BREAKING CHANGE: the `connectionEncryption` option has been renamed `connectionEncrypters`
  • Loading branch information
achingbrain committed Sep 10, 2024
1 parent a142bb6 commit 6d72709
Show file tree
Hide file tree
Showing 50 changed files with 191 additions and 157 deletions.
32 changes: 16 additions & 16 deletions doc/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ When [creating a libp2p node](https://github.com/libp2p/js-libp2p/blob/main/doc/
const modules = {
transports: [],
streamMuxers: [],
connectionEncryption: [],
connectionEncrypters: [],
contentRouting: [],
peerRouting: [],
peerDiscovery: [],
Expand Down Expand Up @@ -267,7 +267,7 @@ const node = await createLibp2p({
webSockets()
],
streamMuxers: [yamux(), mplex()],
connectionEncryption: [noise()],
connectionEncrypters: [noise()],
peerDiscovery: [MulticastDNS],
services: {
dht: kadDHT(),
Expand All @@ -290,7 +290,7 @@ import { bootstrap } from '@libp2p/bootstrap'
const node = await createLibp2p({
transports: [tcp()],
streamMuxers: [yamux(), mplex()],
connectionEncryption: [noise()],
connectionEncrypters: [noise()],
peerDiscovery: [
mdns({
interval: 1000
Expand Down Expand Up @@ -336,7 +336,7 @@ const node = await createLibp2p({
yamux(),
mplex()
],
connectionEncryption: [
connectionEncrypters: [
noise()
],
services: {
Expand Down Expand Up @@ -373,7 +373,7 @@ const node = await createLibp2p({
yamux(),
mplex()
],
connectionEncryption: [
connectionEncrypters: [
noise()
],
services: {
Expand Down Expand Up @@ -421,7 +421,7 @@ const node = await createLibp2p({
yamux(),
mplex()
],
connectionEncryption: [
connectionEncrypters: [
noise()
],
contentRouting: [
Expand Down Expand Up @@ -466,7 +466,7 @@ const node = await createLibp2p({
yamux(),
mplex()
],
connectionEncryption: [
connectionEncrypters: [
noise()
],
connectionGater: {
Expand Down Expand Up @@ -521,7 +521,7 @@ const node = await createLibp2p({
yamux(),
mplex()
],
connectionEncryption: [
connectionEncrypters: [
noise()
]
})
Expand Down Expand Up @@ -552,7 +552,7 @@ const node = await createLibp2p({
yamux(),
mplex()
],
connectionEncryption: [
connectionEncrypters: [
noise()
]
})
Expand Down Expand Up @@ -589,7 +589,7 @@ const node = await createLibp2p({
yamux(),
mplex()
],
connectionEncryption: [
connectionEncrypters: [
noise()
],
keychain: {
Expand Down Expand Up @@ -622,7 +622,7 @@ const node = await createLibp2p({
yamux(),
mplex()
],
connectionEncryption: [
connectionEncrypters: [
noise()
],
connectionManager: {
Expand Down Expand Up @@ -772,7 +772,7 @@ const node = await createLibp2p({
yamux(),
mplex()
],
connectionEncryption: [
connectionEncrypters: [
noise()
],
transportManager: {
Expand Down Expand Up @@ -810,7 +810,7 @@ const node = await createLibp2p({
yamux(),
mplex()
],
connectionEncryption: [
connectionEncrypters: [
noise()
],
metrics: {
Expand Down Expand Up @@ -860,7 +860,7 @@ const node = await createLibp2p({
yamux(),
mplex()
],
connectionEncryption: [
connectionEncrypters: [
noise()
],
peerStore: {
Expand Down Expand Up @@ -892,7 +892,7 @@ const node = await createLibp2p({
streamMuxers: [
yamux()
],
connectionEncryption: [
connectionEncrypters: [
noise()
]
})
Expand All @@ -917,7 +917,7 @@ const node = await createLibp2p({
streamMuxers: [
yamux()
],
connectionEncryption: [
connectionEncrypters: [
noise()
],
addresses: {
Expand Down
8 changes: 4 additions & 4 deletions doc/GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ import { noise } from '@chainsafe/libp2p-noise'

const node = await createLibp2p({
transports: [webSockets()],
connectionEncryption: [noise()]
connectionEncrypters: [noise()]
})
```

Expand Down Expand Up @@ -138,7 +138,7 @@ import { yamux } from '@chainsafe/libp2p-yamux'

const node = await createLibp2p({
transports: [webSockets()],
connectionEncryption: [noise()],
connectionEncrypters: [noise()],
streamMuxers: [yamux()]
})
```
Expand Down Expand Up @@ -168,7 +168,7 @@ const node = await createLibp2p({
listen: ['/ip4/127.0.0.1/tcp/8000/ws']
},
transports: [webSockets()],
connectionEncryption: [noise()],
connectionEncrypters: [noise()],
streamMuxers: [yamux()]
})

Expand Down Expand Up @@ -224,7 +224,7 @@ const bootstrapMultiaddrs = [

const node = await createLibp2p({
transports: [webSockets()],
connectionEncryption: [noise()],
connectionEncrypters: [noise()],
streamMuxers: [yamux()],
peerDiscovery: [
bootstrap({
Expand Down
34 changes: 34 additions & 0 deletions doc/migrations/v1.0.0-v2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ A migration guide for refactoring your application code from libp2p `v1.0.0` to
- [`localPeer` is no longer passed to Connection Encrypters](#localpeer-is-no-longer-passed-to-connection-encrypters)
- [The `.code` property has been removed from thrown errors, use `.name` instead](#the-code-property-has-been-removed-from-thrown-errors-use-name-instead)
- [pubsub, identify, circuit-relay v2 and record envelope sealing use `privateKey` component](#pubsub-identify-circuit-relay-v2-and-record-envelope-sealing-use-privatekey-component)
- [The `connectionEncryption` option has been renamed `connectionEncrypters`](#the-connectionencryption-option-has-been-renamed-connectionencrypters)

## The `PeerId` interface is now a union type

Expand Down Expand Up @@ -484,3 +485,36 @@ for use by libp2p services that contains the deserialized private key.

There are no migration instructions to take advantage of this other than
ensuring you have upgraded to the latest version of all libp2p services.

## The `connectionEncryption` option has been renamed `connectionEncrypters`

This makes it consistent with other options such as `streamMuxers`,
`transports`, etc.

**Before**

```ts
import { noise } from '@chainsafe/libp2p-noise'
import { tls } from '@libp2p/tls'
import { createLibp2p } from 'libp2p'

const node = await createLibp2p({
connectionEncryption: [
noise(), tls()
]
})
```

**After**

```ts
import { noise } from '@chainsafe/libp2p-noise'
import { tls } from '@libp2p/tls'
import { createLibp2p } from 'libp2p'

const node = await createLibp2p({
connectionEncrypters: [
noise(), tls()
]
})
```
4 changes: 2 additions & 2 deletions interop/test/fixtures/get-libp2p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export async function getLibp2p (): Promise<Libp2p<{ ping: PingService }>> {
skipMuxer = true
// Setup yamux and noise to connect to the relay node
options.streamMuxers = [yamux()]
options.connectionEncryption = [noise()]
options.connectionEncrypters = [noise()]
break
default:
// Do nothing
Expand All @@ -103,7 +103,7 @@ export async function getLibp2p (): Promise<Libp2p<{ ping: PingService }>> {
if (!skipSecureChannel) {
switch (SECURE_CHANNEL) {
case 'noise':
options.connectionEncryption = [noise()]
options.connectionEncrypters = [noise()]
break
default:
throw new Error(`Unknown secure channel: ${SECURE_CHANNEL ?? ''}`)
Expand Down
2 changes: 1 addition & 1 deletion interop/test/fixtures/relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function createRelay (): Promise<Libp2p> {
filter: filters.all
})
],
connectionEncryption: [noise()],
connectionEncrypters: [noise()],
streamMuxers: [yamux()],
services: {
identify: identify(),
Expand Down
2 changes: 1 addition & 1 deletion packages/connection-encrypter-plaintext/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { plaintext } from '@libp2p/plaintext'

const node = await createLibp2p({
// ...other options
connectionEncryption: [
connectionEncrypters: [
plaintext()
]
})
Expand Down
2 changes: 1 addition & 1 deletion packages/connection-encrypter-plaintext/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* const node = await createLibp2p({
* // ...other options
* connectionEncryption: [
* connectionEncrypters: [
* plaintext()
* ]
* })
Expand Down
2 changes: 1 addition & 1 deletion packages/connection-encrypter-tls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { tls } from '@libp2p/tls'

const node = await createLibp2p({
// ...other options
connectionEncryption: [
connectionEncrypters: [
tls()
]
})
Expand Down
2 changes: 1 addition & 1 deletion packages/connection-encrypter-tls/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* const node = await createLibp2p({
* // ...other options
* connectionEncryption: [
* connectionEncrypters: [
* tls()
* ]
* })
Expand Down
2 changes: 1 addition & 1 deletion packages/connection-encrypter-tls/src/tls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* const node = await createLibp2p({
* // ...other options
* connectionEncryption: [
* connectionEncrypters: [
* tls()
* ]
* })
Expand Down
2 changes: 1 addition & 1 deletion packages/integration-tests/.aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default {
yamux(),
mplex()
],
connectionEncryption: [
connectionEncrypters: [
noise(),
plaintext()
],
Expand Down
2 changes: 1 addition & 1 deletion packages/integration-tests/test/bootstrap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('bootstrap', () => {
]

libp2p = await createLibp2p({
connectionEncryption: [
connectionEncrypters: [
plaintext()
],
transports: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('circuit-relay discovery', () => {
streamMuxers: [
yamux()
],
connectionEncryption: [
connectionEncrypters: [
plaintext()
],
services: {
Expand Down Expand Up @@ -61,7 +61,7 @@ describe('circuit-relay discovery', () => {
streamMuxers: [
yamux()
],
connectionEncryption: [
connectionEncrypters: [
plaintext()
],
services: {
Expand Down Expand Up @@ -103,7 +103,7 @@ describe('circuit-relay discovery', () => {
streamMuxers: [
yamux()
],
connectionEncryption: [
connectionEncrypters: [
plaintext()
],
services: {
Expand All @@ -128,7 +128,7 @@ describe('circuit-relay discovery', () => {
streamMuxers: [
yamux()
],
connectionEncryption: [
connectionEncrypters: [
plaintext()
],
services: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('circuit-relay discovery', () => {
yamux(),
mplex()
],
connectionEncryption: [
connectionEncrypters: [
plaintext(),
noise()
],
Expand Down
4 changes: 2 additions & 2 deletions packages/integration-tests/test/circuit-relay.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function createClient (options: Libp2pOptions = {}): Promise<Libp2p> {
yamux(),
mplex()
],
connectionEncryption: [
connectionEncrypters: [
plaintext()
],
services: {
Expand All @@ -62,7 +62,7 @@ async function createRelay (options: Libp2pOptions = {}): Promise<Libp2p<{ relay
yamux(),
mplex()
],
connectionEncryption: [
connectionEncrypters: [
plaintext()
],
...options,
Expand Down
4 changes: 2 additions & 2 deletions packages/integration-tests/test/circuit-relay.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('circuit-relay', () => {
yamux(),
mplex()
],
connectionEncryption: [
connectionEncrypters: [
plaintext()
],
connectionGater: {
Expand All @@ -58,7 +58,7 @@ describe('circuit-relay', () => {
yamux(),
mplex()
],
connectionEncryption: [
connectionEncrypters: [
plaintext()
],
connectionGater: {
Expand Down
Loading

0 comments on commit 6d72709

Please sign in to comment.