Skip to content

Commit

Permalink
fix: use undefined instead of null privKey (#154)
Browse files Browse the repository at this point in the history
Respect the `PeerId#privKey` typescript type, which is `PrivateKey | undefined`, not `PrivateKey | null`
  • Loading branch information
wemeetagain authored Jul 26, 2021
1 parent 3330a26 commit 35faac2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ exports.createFromPubKey = async (key) => {
}

const pubKey = await cryptoKeys.unmarshalPublicKey(buf)
return computePeerId(null, pubKey)
return computePeerId(undefined, pubKey)
}

// Private key input will be a string
Expand All @@ -338,7 +338,7 @@ exports.createFromJSON = async (obj) => {
const pub = rawPubKey && await cryptoKeys.unmarshalPublicKey(rawPubKey)

if (!rawPrivKey) {
return new PeerIdWithIs(id, null, pub)
return new PeerIdWithIs(id, undefined, pub)
}

const privKey = await cryptoKeys.unmarshalPrivateKey(rawPrivKey)
Expand Down Expand Up @@ -394,7 +394,7 @@ exports.createFromProtobuf = async (buf) => {
// TODO: val id and pubDigest

if (pubKey) {
return new PeerIdWithIs(pubDigest, null, pubKey)
return new PeerIdWithIs(pubDigest, undefined, pubKey)
}

if (id) {
Expand Down

0 comments on commit 35faac2

Please sign in to comment.