libp2p 0.43.4-eb31274d → 0.44.0

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.
@@ -150,7 +150,7 @@ export class AutonatService implements Startable {
150
150
 
151
151
  await pipe(
152
152
  source,
153
- lp.decode(),
153
+ (source) => lp.decode(source),
154
154
  async function * (stream) {
155
155
  const buf = await first(stream)
156
156
 
@@ -357,7 +357,7 @@ export class AutonatService implements Startable {
357
357
  }
358
358
  })
359
359
  },
360
- lp.encode(),
360
+ (source) => lp.encode(source),
361
361
  // pipe to the stream, not the abortable source other wise we
362
362
  // can't tell the remote when a dial timed out..
363
363
  data.stream
@@ -446,9 +446,9 @@ export class AutonatService implements Startable {
446
446
 
447
447
  const buf = await pipe(
448
448
  [request],
449
- lp.encode(),
449
+ (source) => lp.encode(source),
450
450
  source,
451
- lp.decode(),
451
+ (source) => lp.decode(source),
452
452
  async (stream) => await first(stream)
453
453
  )
454
454
  if (buf == null) {
@@ -337,7 +337,7 @@ export class DialQueue {
337
337
  throw new CodeError('dial with more addresses than allowed', codes.ERR_TOO_MANY_ADDRESSES)
338
338
  }
339
339
 
340
- // append peer id to multiaddrs if it is not already present
340
+ // ensure the peer id is appended to the multiaddr
341
341
  if (peerId != null) {
342
342
  const peerIdMultiaddr = `/p2p/${peerId.toString()}`
343
343
  dedupedMultiaddrs = dedupedMultiaddrs.map(addr => {
@@ -349,7 +349,8 @@ export class DialQueue {
349
349
  return addr
350
350
  }
351
351
 
352
- if (addressPeerId == null) {
352
+ // append peer id to multiaddr if it is not already present
353
+ if (addressPeerId !== peerId.toString()) {
353
354
  return {
354
355
  multiaddr: addr.multiaddr.encapsulate(peerIdMultiaddr),
355
356
  isCertified: addr.isCertified
@@ -363,7 +364,6 @@ export class DialQueue {
363
364
  const gatedAdrs: Address[] = []
364
365
 
365
366
  for (const addr of dedupedMultiaddrs) {
366
- // @ts-expect-error needs updating in the interface
367
367
  if (this.connectionGater.denyDialMultiaddr != null && await this.connectionGater.denyDialMultiaddr(addr.multiaddr)) {
368
368
  continue
369
369
  }
@@ -127,9 +127,9 @@ export class FetchService implements Startable {
127
127
 
128
128
  const result = await pipe(
129
129
  [FetchRequest.encode({ identifier: key })],
130
- lp.encode(),
130
+ (source) => lp.encode(source),
131
131
  source,
132
- lp.decode(),
132
+ (source) => lp.decode(source),
133
133
  async function (source) {
134
134
  const buf = await first(source)
135
135
 
@@ -184,7 +184,7 @@ export class FetchService implements Startable {
184
184
 
185
185
  await pipe(
186
186
  stream,
187
- lp.decode(),
187
+ (source) => lp.decode(source),
188
188
  async function * (source) {
189
189
  const buf = await first(source)
190
190
 
@@ -215,7 +215,7 @@ export class FetchService implements Startable {
215
215
 
216
216
  yield FetchResponse.encode(response)
217
217
  },
218
- lp.encode(),
218
+ (source) => lp.encode(source),
219
219
  stream
220
220
  )
221
221
  }
@@ -197,7 +197,7 @@ export class IdentifyService implements Startable {
197
197
  signedPeerRecord,
198
198
  protocols
199
199
  })],
200
- lp.encode()
200
+ (source) => lp.encode(source)
201
201
  ))
202
202
  } catch (err: any) {
203
203
  // Just log errors
@@ -266,7 +266,7 @@ export class IdentifyService implements Startable {
266
266
  const data = await pipe(
267
267
  [],
268
268
  source,
269
- lp.decode({
269
+ (source) => lp.decode(source, {
270
270
  maxDataLength: this.init.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE
271
271
  }),
272
272
  async (source) => await first(source)
@@ -431,7 +431,7 @@ export class IdentifyService implements Startable {
431
431
  // make stream abortable
432
432
  const source = abortableDuplex(stream, timeoutController.signal)
433
433
 
434
- const msgWithLenPrefix = pipe([message], lp.encode())
434
+ const msgWithLenPrefix = pipe([message], (source) => lp.encode(source))
435
435
  await source.sink(msgWithLenPrefix)
436
436
  } catch (err: any) {
437
437
  log.error('could not respond to identify request', err)
@@ -461,7 +461,7 @@ export class IdentifyService implements Startable {
461
461
  const data = await pipe(
462
462
  [],
463
463
  source,
464
- lp.decode({
464
+ (source) => lp.decode(source, {
465
465
  maxDataLength: this.init.maxIdentifyMessageSize ?? MAX_IDENTIFY_MESSAGE_SIZE
466
466
  }),
467
467
  async (source) => await first(source)
@@ -71,8 +71,12 @@ async function encrypt (localId: PeerId, conn: Duplex<Uint8Array>, remoteId?: Pe
71
71
  log('write pubkey exchange to peer %p', remoteId)
72
72
 
73
73
  // Get the Exchange message
74
- // @ts-expect-error needs to be generator
75
74
  const response = (await lp.decode.fromReader(shake.reader).next()).value
75
+
76
+ if (response == null) {
77
+ throw new Error('Did not read response')
78
+ }
79
+
76
80
  const id = Exchange.decode(response)
77
81
  log('read pubkey exchange from peer %p', remoteId)
78
82
 
package/src/libp2p.ts CHANGED
@@ -354,7 +354,6 @@ export class Libp2pNode extends EventEmitter<Libp2pEvents> implements Libp2p {
354
354
  }
355
355
 
356
356
  getDialQueue (): PendingDial[] {
357
- // @ts-expect-error needs adding to the API
358
357
  return this.components.connectionManager.getDialQueue()
359
358
  }
360
359
 
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
- export const version = '0.43.4-eb31274d'
1
+ export const version = '0.44.0'
2
2
  export const name = 'libp2p'