-
Notifications
You must be signed in to change notification settings - Fork 28
fix: peer-id privKey and pubKey can be undefined #126
fix: peer-id privKey and pubKey can be undefined #126
Conversation
TLDR: please use the v2.x.x release for the time being, tagged Longer version: The typescript version of libp2p-interfaces is trying to take the interface definitions in a new direction. For peer id, please see the changes in #117 - it makes peer ids essentially a place to store some It's all a bit in flux and will be until libp2p/js-libp2p#1021 lands. |
21d2aad
to
5799974
Compare
5799974
to
6b12aeb
Compare
@achingbrain Please review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch - thanks! Just a few changes needed in order for the tests to not cause unhanded promise rejections if they fail.
Also export CreateOptions and PeerIdJSON types Co-authored-by: Alex Potsides <alex@achingbrain.net>
In the PR #107 the
PeerId
interface was introduced. Later in the PR #111 that was refactored and some intentional changes introduced.The
privKey
andpubKey
both can be undefined depending on the data, more details can be found in the PR libp2p/js-peer-id#150.The
PeerId
object can be created with the following scenarios:new
in that case both keys are optionalPeerId.create
in that case if provided input is valid than both keys existsPeerId.createFromBytes
,PeerId.createFromB58String
,PeerId.createFromHexString
,PeerId.createFromCID
in these cases public key can be decoded but private key don't existsPeerId.createFromPubKey
in that case public key exists but not privatePeerId.createFromPrivKey
in that case both keys existPeerId.createFromJSON
in that case both keys existPeerId.createFromProtobuf
in that case both keys existConsidering all the above cases, both
privKey
andpubKey
were initially set was set to haveundefined
values. Seems the change in refactoring PR #111 was made unintended.