Skip to content

Commit 2417cda

Browse files
authored
fix: do not require connection encrypters (#1752)
Because we now have transports that do their own encryption (e.g. webrtc, webtransport) do not require additional connection encrypters to be configured.
1 parent 08d4c26 commit 2417cda

File tree

2 files changed

+0
-30
lines changed

2 files changed

+0
-30
lines changed

src/config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ export function validateConfig <T extends ServiceMap = Record<string, unknown>>
3434
throw new CodeError(messages.ERR_TRANSPORTS_REQUIRED, codes.ERR_TRANSPORTS_REQUIRED)
3535
}
3636

37-
if (resultingOptions.connectionEncryption == null || resultingOptions.connectionEncryption.length === 0) {
38-
throw new CodeError(messages.CONN_ENCRYPTION_REQUIRED, codes.CONN_ENCRYPTION_REQUIRED)
39-
}
40-
4137
if (resultingOptions.connectionProtector === null && globalThis.process?.env?.LIBP2P_FORCE_PNET != null) { // eslint-disable-line no-undef
4238
throw new CodeError(messages.ERR_PROTECTOR_REQUIRED, codes.ERR_PROTECTOR_REQUIRED)
4339
}

test/core/encryption.spec.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/* eslint-env mocha */
22

33
import { webSockets } from '@libp2p/websockets'
4-
import { expect } from 'aegir/chai'
5-
import { codes as ErrorCodes } from '../../src/errors.js'
64
import { createLibp2p, type Libp2pOptions } from '../../src/index.js'
75
import { plaintext } from '../../src/insecure/index.js'
86
import { createPeerId } from '../utils/creators/peer.js'
@@ -15,30 +13,6 @@ describe('Connection encryption configuration', () => {
1513
peerId = await createPeerId()
1614
})
1715

18-
it('is required', async () => {
19-
const config = {
20-
peerId,
21-
transports: [
22-
webSockets()
23-
]
24-
}
25-
26-
await expect(createLibp2p(config)).to.eventually.be.rejected()
27-
.and.to.have.property('code', ErrorCodes.CONN_ENCRYPTION_REQUIRED)
28-
})
29-
30-
it('is required and needs at least one module', async () => {
31-
const config = {
32-
peerId,
33-
transports: [
34-
webSockets()
35-
],
36-
connectionEncryption: []
37-
}
38-
await expect(createLibp2p(config)).to.eventually.be.rejected()
39-
.and.to.have.property('code', ErrorCodes.CONN_ENCRYPTION_REQUIRED)
40-
})
41-
4216
it('can be created', async () => {
4317
const config: Libp2pOptions = {
4418
peerId,

0 commit comments

Comments
 (0)