multiformats/js-multiaddr

getPeerId can return an unexpected peer id

achingbrain opened this issue ยท 1 comments

.getPeerId() returns the peer id from a multiaddr if one is present but it may not be the one we expect.

If the mulitaddr is a relay address but doesn't have the relay client's peer id in the address, the peer id returned is that of the relay.

I believe the intention of .getPeerId is to return the peer id of the remote peer that can be dialled using the peer id, not just any peer id that happens to be in the multiaddr.

We could fix this by treating p2p-circuit as a special case and returning the value part of the p2p-circuit tuple if found, or more generally by only returning a peer id if it's in the final tuple?

Refs: libp2p/js-libp2p#1680

๐ŸŽ‰ This issue has been resolved in version 12.1.5 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€