Skip to content

Commit 6d72709

Browse files
authored
fix!: rename connectionEncryption option to connectionEncrypters (#2691)
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`
1 parent a142bb6 commit 6d72709

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+191
-157
lines changed

doc/CONFIGURATION.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ When [creating a libp2p node](https://github.com/libp2p/js-libp2p/blob/main/doc/
207207
const modules = {
208208
transports: [],
209209
streamMuxers: [],
210-
connectionEncryption: [],
210+
connectionEncrypters: [],
211211
contentRouting: [],
212212
peerRouting: [],
213213
peerDiscovery: [],
@@ -267,7 +267,7 @@ const node = await createLibp2p({
267267
webSockets()
268268
],
269269
streamMuxers: [yamux(), mplex()],
270-
connectionEncryption: [noise()],
270+
connectionEncrypters: [noise()],
271271
peerDiscovery: [MulticastDNS],
272272
services: {
273273
dht: kadDHT(),
@@ -290,7 +290,7 @@ import { bootstrap } from '@libp2p/bootstrap'
290290
const node = await createLibp2p({
291291
transports: [tcp()],
292292
streamMuxers: [yamux(), mplex()],
293-
connectionEncryption: [noise()],
293+
connectionEncrypters: [noise()],
294294
peerDiscovery: [
295295
mdns({
296296
interval: 1000
@@ -336,7 +336,7 @@ const node = await createLibp2p({
336336
yamux(),
337337
mplex()
338338
],
339-
connectionEncryption: [
339+
connectionEncrypters: [
340340
noise()
341341
],
342342
services: {
@@ -373,7 +373,7 @@ const node = await createLibp2p({
373373
yamux(),
374374
mplex()
375375
],
376-
connectionEncryption: [
376+
connectionEncrypters: [
377377
noise()
378378
],
379379
services: {
@@ -421,7 +421,7 @@ const node = await createLibp2p({
421421
yamux(),
422422
mplex()
423423
],
424-
connectionEncryption: [
424+
connectionEncrypters: [
425425
noise()
426426
],
427427
contentRouting: [
@@ -466,7 +466,7 @@ const node = await createLibp2p({
466466
yamux(),
467467
mplex()
468468
],
469-
connectionEncryption: [
469+
connectionEncrypters: [
470470
noise()
471471
],
472472
connectionGater: {
@@ -521,7 +521,7 @@ const node = await createLibp2p({
521521
yamux(),
522522
mplex()
523523
],
524-
connectionEncryption: [
524+
connectionEncrypters: [
525525
noise()
526526
]
527527
})
@@ -552,7 +552,7 @@ const node = await createLibp2p({
552552
yamux(),
553553
mplex()
554554
],
555-
connectionEncryption: [
555+
connectionEncrypters: [
556556
noise()
557557
]
558558
})
@@ -589,7 +589,7 @@ const node = await createLibp2p({
589589
yamux(),
590590
mplex()
591591
],
592-
connectionEncryption: [
592+
connectionEncrypters: [
593593
noise()
594594
],
595595
keychain: {
@@ -622,7 +622,7 @@ const node = await createLibp2p({
622622
yamux(),
623623
mplex()
624624
],
625-
connectionEncryption: [
625+
connectionEncrypters: [
626626
noise()
627627
],
628628
connectionManager: {
@@ -772,7 +772,7 @@ const node = await createLibp2p({
772772
yamux(),
773773
mplex()
774774
],
775-
connectionEncryption: [
775+
connectionEncrypters: [
776776
noise()
777777
],
778778
transportManager: {
@@ -810,7 +810,7 @@ const node = await createLibp2p({
810810
yamux(),
811811
mplex()
812812
],
813-
connectionEncryption: [
813+
connectionEncrypters: [
814814
noise()
815815
],
816816
metrics: {
@@ -860,7 +860,7 @@ const node = await createLibp2p({
860860
yamux(),
861861
mplex()
862862
],
863-
connectionEncryption: [
863+
connectionEncrypters: [
864864
noise()
865865
],
866866
peerStore: {
@@ -892,7 +892,7 @@ const node = await createLibp2p({
892892
streamMuxers: [
893893
yamux()
894894
],
895-
connectionEncryption: [
895+
connectionEncrypters: [
896896
noise()
897897
]
898898
})
@@ -917,7 +917,7 @@ const node = await createLibp2p({
917917
streamMuxers: [
918918
yamux()
919919
],
920-
connectionEncryption: [
920+
connectionEncrypters: [
921921
noise()
922922
],
923923
addresses: {

doc/GETTING_STARTED.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ import { noise } from '@chainsafe/libp2p-noise'
107107

108108
const node = await createLibp2p({
109109
transports: [webSockets()],
110-
connectionEncryption: [noise()]
110+
connectionEncrypters: [noise()]
111111
})
112112
```
113113

@@ -138,7 +138,7 @@ import { yamux } from '@chainsafe/libp2p-yamux'
138138

139139
const node = await createLibp2p({
140140
transports: [webSockets()],
141-
connectionEncryption: [noise()],
141+
connectionEncrypters: [noise()],
142142
streamMuxers: [yamux()]
143143
})
144144
```
@@ -168,7 +168,7 @@ const node = await createLibp2p({
168168
listen: ['/ip4/127.0.0.1/tcp/8000/ws']
169169
},
170170
transports: [webSockets()],
171-
connectionEncryption: [noise()],
171+
connectionEncrypters: [noise()],
172172
streamMuxers: [yamux()]
173173
})
174174

@@ -224,7 +224,7 @@ const bootstrapMultiaddrs = [
224224

225225
const node = await createLibp2p({
226226
transports: [webSockets()],
227-
connectionEncryption: [noise()],
227+
connectionEncrypters: [noise()],
228228
streamMuxers: [yamux()],
229229
peerDiscovery: [
230230
bootstrap({

doc/migrations/v1.0.0-v2.0.0.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ A migration guide for refactoring your application code from libp2p `v1.0.0` to
1717
- [`localPeer` is no longer passed to Connection Encrypters](#localpeer-is-no-longer-passed-to-connection-encrypters)
1818
- [The `.code` property has been removed from thrown errors, use `.name` instead](#the-code-property-has-been-removed-from-thrown-errors-use-name-instead)
1919
- [pubsub, identify, circuit-relay v2 and record envelope sealing use `privateKey` component](#pubsub-identify-circuit-relay-v2-and-record-envelope-sealing-use-privatekey-component)
20+
- [The `connectionEncryption` option has been renamed `connectionEncrypters`](#the-connectionencryption-option-has-been-renamed-connectionencrypters)
2021

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

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

485486
There are no migration instructions to take advantage of this other than
486487
ensuring you have upgraded to the latest version of all libp2p services.
488+
489+
## The `connectionEncryption` option has been renamed `connectionEncrypters`
490+
491+
This makes it consistent with other options such as `streamMuxers`,
492+
`transports`, etc.
493+
494+
**Before**
495+
496+
```ts
497+
import { noise } from '@chainsafe/libp2p-noise'
498+
import { tls } from '@libp2p/tls'
499+
import { createLibp2p } from 'libp2p'
500+
501+
const node = await createLibp2p({
502+
connectionEncryption: [
503+
noise(), tls()
504+
]
505+
})
506+
```
507+
508+
**After**
509+
510+
```ts
511+
import { noise } from '@chainsafe/libp2p-noise'
512+
import { tls } from '@libp2p/tls'
513+
import { createLibp2p } from 'libp2p'
514+
515+
const node = await createLibp2p({
516+
connectionEncrypters: [
517+
noise(), tls()
518+
]
519+
})
520+
```

interop/test/fixtures/get-libp2p.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export async function getLibp2p (): Promise<Libp2p<{ ping: PingService }>> {
9494
skipMuxer = true
9595
// Setup yamux and noise to connect to the relay node
9696
options.streamMuxers = [yamux()]
97-
options.connectionEncryption = [noise()]
97+
options.connectionEncrypters = [noise()]
9898
break
9999
default:
100100
// Do nothing
@@ -103,7 +103,7 @@ export async function getLibp2p (): Promise<Libp2p<{ ping: PingService }>> {
103103
if (!skipSecureChannel) {
104104
switch (SECURE_CHANNEL) {
105105
case 'noise':
106-
options.connectionEncryption = [noise()]
106+
options.connectionEncrypters = [noise()]
107107
break
108108
default:
109109
throw new Error(`Unknown secure channel: ${SECURE_CHANNEL ?? ''}`)

interop/test/fixtures/relay.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export async function createRelay (): Promise<Libp2p> {
1717
filter: filters.all
1818
})
1919
],
20-
connectionEncryption: [noise()],
20+
connectionEncrypters: [noise()],
2121
streamMuxers: [yamux()],
2222
services: {
2323
identify: identify(),

packages/connection-encrypter-plaintext/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { plaintext } from '@libp2p/plaintext'
3636

3737
const node = await createLibp2p({
3838
// ...other options
39-
connectionEncryption: [
39+
connectionEncrypters: [
4040
plaintext()
4141
]
4242
})

packages/connection-encrypter-plaintext/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* const node = await createLibp2p({
1515
* // ...other options
16-
* connectionEncryption: [
16+
* connectionEncrypters: [
1717
* plaintext()
1818
* ]
1919
* })

packages/connection-encrypter-tls/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { tls } from '@libp2p/tls'
3434

3535
const node = await createLibp2p({
3636
// ...other options
37-
connectionEncryption: [
37+
connectionEncrypters: [
3838
tls()
3939
]
4040
})

packages/connection-encrypter-tls/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
* const node = await createLibp2p({
1313
* // ...other options
14-
* connectionEncryption: [
14+
* connectionEncrypters: [
1515
* tls()
1616
* ]
1717
* })

packages/connection-encrypter-tls/src/tls.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
* const node = await createLibp2p({
1313
* // ...other options
14-
* connectionEncryption: [
14+
* connectionEncrypters: [
1515
* tls()
1616
* ]
1717
* })

packages/integration-tests/.aegir.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default {
3737
yamux(),
3838
mplex()
3939
],
40-
connectionEncryption: [
40+
connectionEncrypters: [
4141
noise(),
4242
plaintext()
4343
],

packages/integration-tests/test/bootstrap.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ describe('bootstrap', () => {
114114
]
115115

116116
libp2p = await createLibp2p({
117-
connectionEncryption: [
117+
connectionEncrypters: [
118118
plaintext()
119119
],
120120
transports: [

packages/integration-tests/test/circuit-relay-discovery.node.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('circuit-relay discovery', () => {
3333
streamMuxers: [
3434
yamux()
3535
],
36-
connectionEncryption: [
36+
connectionEncrypters: [
3737
plaintext()
3838
],
3939
services: {
@@ -61,7 +61,7 @@ describe('circuit-relay discovery', () => {
6161
streamMuxers: [
6262
yamux()
6363
],
64-
connectionEncryption: [
64+
connectionEncrypters: [
6565
plaintext()
6666
],
6767
services: {
@@ -103,7 +103,7 @@ describe('circuit-relay discovery', () => {
103103
streamMuxers: [
104104
yamux()
105105
],
106-
connectionEncryption: [
106+
connectionEncrypters: [
107107
plaintext()
108108
],
109109
services: {
@@ -128,7 +128,7 @@ describe('circuit-relay discovery', () => {
128128
streamMuxers: [
129129
yamux()
130130
],
131-
connectionEncryption: [
131+
connectionEncrypters: [
132132
plaintext()
133133
],
134134
services: {

packages/integration-tests/test/circuit-relay-discovery.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('circuit-relay discovery', () => {
3535
yamux(),
3636
mplex()
3737
],
38-
connectionEncryption: [
38+
connectionEncrypters: [
3939
plaintext(),
4040
noise()
4141
],

packages/integration-tests/test/circuit-relay.node.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async function createClient (options: Libp2pOptions = {}): Promise<Libp2p> {
3939
yamux(),
4040
mplex()
4141
],
42-
connectionEncryption: [
42+
connectionEncrypters: [
4343
plaintext()
4444
],
4545
services: {
@@ -62,7 +62,7 @@ async function createRelay (options: Libp2pOptions = {}): Promise<Libp2p<{ relay
6262
yamux(),
6363
mplex()
6464
],
65-
connectionEncryption: [
65+
connectionEncrypters: [
6666
plaintext()
6767
],
6868
...options,

packages/integration-tests/test/circuit-relay.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('circuit-relay', () => {
3232
yamux(),
3333
mplex()
3434
],
35-
connectionEncryption: [
35+
connectionEncrypters: [
3636
plaintext()
3737
],
3838
connectionGater: {
@@ -58,7 +58,7 @@ describe('circuit-relay', () => {
5858
yamux(),
5959
mplex()
6060
],
61-
connectionEncryption: [
61+
connectionEncrypters: [
6262
plaintext()
6363
],
6464
connectionGater: {

0 commit comments

Comments
 (0)