libp2p 1.9.4-df330695a → 1.9.4-e1ca9cced

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/upgrader.ts CHANGED
@@ -32,8 +32,8 @@ export interface CryptoResult extends SecuredConnection<MultiaddrConnection> {
32
32
  }
33
33
 
34
34
  export interface UpgraderInit {
35
- connectionEncryption: ConnectionEncrypter[]
36
- muxers: StreamMuxerFactory[]
35
+ connectionEncrypters: ConnectionEncrypter[]
36
+ streamMuxers: StreamMuxerFactory[]
37
37
 
38
38
  /**
39
39
  * An amount of ms by which an inbound connection upgrade
@@ -100,23 +100,23 @@ type ConnectionDeniedType = keyof Pick<ConnectionGater, 'denyOutboundConnection'
100
100
 
101
101
  export class DefaultUpgrader implements Upgrader {
102
102
  private readonly components: DefaultUpgraderComponents
103
- private readonly connectionEncryption: Map<string, ConnectionEncrypter>
104
- private readonly muxers: Map<string, StreamMuxerFactory>
103
+ private readonly connectionEncrypters: Map<string, ConnectionEncrypter>
104
+ private readonly streamMuxers: Map<string, StreamMuxerFactory>
105
105
  private readonly inboundUpgradeTimeout: number
106
106
  private readonly events: TypedEventTarget<Libp2pEvents>
107
107
 
108
108
  constructor (components: DefaultUpgraderComponents, init: UpgraderInit) {
109
109
  this.components = components
110
- this.connectionEncryption = new Map()
110
+ this.connectionEncrypters = new Map()
111
111
 
112
- init.connectionEncryption.forEach(encrypter => {
113
- this.connectionEncryption.set(encrypter.protocol, encrypter)
112
+ init.connectionEncrypters.forEach(encrypter => {
113
+ this.connectionEncrypters.set(encrypter.protocol, encrypter)
114
114
  })
115
115
 
116
- this.muxers = new Map()
116
+ this.streamMuxers = new Map()
117
117
 
118
- init.muxers.forEach(muxer => {
119
- this.muxers.set(muxer.protocol, muxer)
118
+ init.streamMuxers.forEach(muxer => {
119
+ this.streamMuxers.set(muxer.protocol, muxer)
120
120
  })
121
121
 
122
122
  this.inboundUpgradeTimeout = init.inboundUpgradeTimeout ?? INBOUND_UPGRADE_TIMEOUT
@@ -216,14 +216,14 @@ export class DefaultUpgrader implements Upgrader {
216
216
  upgradedConn = encryptedConn
217
217
  if (opts?.muxerFactory != null) {
218
218
  muxerFactory = opts.muxerFactory
219
- } else if (this.muxers.size > 0) {
219
+ } else if (this.streamMuxers.size > 0) {
220
220
  opts?.onProgress?.(new CustomProgressEvent('upgrader:multiplex-inbound-connection'))
221
221
 
222
222
  // Multiplex the connection
223
223
  const multiplexed = await this._multiplexInbound({
224
224
  ...protectedConn,
225
225
  ...encryptedConn
226
- }, this.muxers)
226
+ }, this.streamMuxers)
227
227
  muxerFactory = multiplexed.muxerFactory
228
228
  upgradedConn = multiplexed.stream
229
229
  }
@@ -319,12 +319,12 @@ export class DefaultUpgrader implements Upgrader {
319
319
  upgradedConn = encryptedConn
320
320
  if (opts?.muxerFactory != null) {
321
321
  muxerFactory = opts.muxerFactory
322
- } else if (this.muxers.size > 0) {
322
+ } else if (this.streamMuxers.size > 0) {
323
323
  // Multiplex the connection
324
324
  const multiplexed = await this._multiplexOutbound({
325
325
  ...protectedConn,
326
326
  ...encryptedConn
327
- }, this.muxers)
327
+ }, this.streamMuxers)
328
328
  muxerFactory = multiplexed.muxerFactory
329
329
  upgradedConn = multiplexed.stream
330
330
  }
@@ -627,14 +627,14 @@ export class DefaultUpgrader implements Upgrader {
627
627
  * Attempts to encrypt the incoming `connection` with the provided `cryptos`
628
628
  */
629
629
  async _encryptInbound (connection: MultiaddrConnection, options?: AbortOptions): Promise<CryptoResult> {
630
- const protocols = Array.from(this.connectionEncryption.keys())
630
+ const protocols = Array.from(this.connectionEncrypters.keys())
631
631
  connection.log('handling inbound crypto protocol selection', protocols)
632
632
 
633
633
  try {
634
634
  const { stream, protocol } = await mss.handle(connection, protocols, {
635
635
  log: connection.log
636
636
  })
637
- const encrypter = this.connectionEncryption.get(protocol)
637
+ const encrypter = this.connectionEncrypters.get(protocol)
638
638
 
639
639
  if (encrypter == null) {
640
640
  throw new Error(`no crypto module found for ${protocol}`)
@@ -657,7 +657,7 @@ export class DefaultUpgrader implements Upgrader {
657
657
  * The first `ConnectionEncrypter` module to succeed will be used
658
658
  */
659
659
  async _encryptOutbound (connection: MultiaddrConnection, options?: SecureConnectionOptions): Promise<CryptoResult> {
660
- const protocols = Array.from(this.connectionEncryption.keys())
660
+ const protocols = Array.from(this.connectionEncrypters.keys())
661
661
  connection.log('selecting outbound crypto protocol', protocols)
662
662
 
663
663
  try {
@@ -671,7 +671,7 @@ export class DefaultUpgrader implements Upgrader {
671
671
  yieldBytes: true
672
672
  })
673
673
 
674
- const encrypter = this.connectionEncryption.get(protocol)
674
+ const encrypter = this.connectionEncrypters.get(protocol)
675
675
 
676
676
  if (encrypter == null) {
677
677
  throw new Error(`no crypto module found for ${protocol}`)
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
- export const version = '1.9.4-df330695a'
1
+ export const version = '1.9.4-e1ca9cced'
2
2
  export const name = 'libp2p'