Skip to content

Commit 35faac2

Browse files
authoredJul 26, 2021
fix: use undefined instead of null privKey (#154)
Respect the `PeerId#privKey` typescript type, which is `PrivateKey | undefined`, not `PrivateKey | null`
1 parent 3330a26 commit 35faac2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎src/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ exports.createFromPubKey = async (key) => {
314314
}
315315

316316
const pubKey = await cryptoKeys.unmarshalPublicKey(buf)
317-
return computePeerId(null, pubKey)
317+
return computePeerId(undefined, pubKey)
318318
}
319319

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

340340
if (!rawPrivKey) {
341-
return new PeerIdWithIs(id, null, pub)
341+
return new PeerIdWithIs(id, undefined, pub)
342342
}
343343

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

396396
if (pubKey) {
397-
return new PeerIdWithIs(pubDigest, null, pubKey)
397+
return new PeerIdWithIs(pubDigest, undefined, pubKey)
398398
}
399399

400400
if (id) {

0 commit comments

Comments
 (0)
Please sign in to comment.