Skip to content

Commit

Permalink
fix: do not require connection encrypters (#1752)
Browse files Browse the repository at this point in the history
Because we now have transports that do their own encryption (e.g.
webrtc, webtransport) do not require additional connection encrypters
to be configured.
  • Loading branch information
achingbrain authored May 10, 2023
1 parent 08d4c26 commit 2417cda
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 30 deletions.
4 changes: 0 additions & 4 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ export function validateConfig <T extends ServiceMap = Record<string, unknown>>
throw new CodeError(messages.ERR_TRANSPORTS_REQUIRED, codes.ERR_TRANSPORTS_REQUIRED)
}

if (resultingOptions.connectionEncryption == null || resultingOptions.connectionEncryption.length === 0) {
throw new CodeError(messages.CONN_ENCRYPTION_REQUIRED, codes.CONN_ENCRYPTION_REQUIRED)
}

if (resultingOptions.connectionProtector === null && globalThis.process?.env?.LIBP2P_FORCE_PNET != null) { // eslint-disable-line no-undef
throw new CodeError(messages.ERR_PROTECTOR_REQUIRED, codes.ERR_PROTECTOR_REQUIRED)
}
Expand Down
26 changes: 0 additions & 26 deletions test/core/encryption.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* eslint-env mocha */

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

it('is required', async () => {
const config = {
peerId,
transports: [
webSockets()
]
}

await expect(createLibp2p(config)).to.eventually.be.rejected()
.and.to.have.property('code', ErrorCodes.CONN_ENCRYPTION_REQUIRED)
})

it('is required and needs at least one module', async () => {
const config = {
peerId,
transports: [
webSockets()
],
connectionEncryption: []
}
await expect(createLibp2p(config)).to.eventually.be.rejected()
.and.to.have.property('code', ErrorCodes.CONN_ENCRYPTION_REQUIRED)
})

it('can be created', async () => {
const config: Libp2pOptions = {
peerId,
Expand Down

0 comments on commit 2417cda

Please sign in to comment.