-
Notifications
You must be signed in to change notification settings - Fork 27
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
PeerIdinterface was introduced. Later in the PR #111 that was refactored and some intentional changes introduced.The
privKeyandpubKeyboth can be undefined depending on the data, more details can be found in the PR libp2p/js-peer-id#150.The
PeerIdobject can be created with the following scenarios:newin that case both keys are optionalPeerId.createin that case if provided input is valid than both keys existsPeerId.createFromBytes,PeerId.createFromB58String,PeerId.createFromHexString,PeerId.createFromCIDin these cases public key can be decoded but private key don't existsPeerId.createFromPubKeyin that case public key exists but not privatePeerId.createFromPrivKeyin that case both keys existPeerId.createFromJSONin that case both keys existPeerId.createFromProtobufin that case both keys existConsidering all the above cases, both
privKeyandpubKeywere initially set was set to haveundefinedvalues. Seems the change in refactoring PR #111 was made unintended.