mirror of
https://github.com/fluencelabs/js-peer-id
synced 2025-07-31 21:22:09 +00:00
fix: catch errors thrown by multihash decode (#109)
This commit is contained in:
13
src/index.js
13
src/index.js
@@ -50,12 +50,17 @@ class PeerId {
|
||||
return this._privKey.public
|
||||
}
|
||||
|
||||
const decoded = mh.decode(this.id)
|
||||
try {
|
||||
const decoded = mh.decode(this.id)
|
||||
|
||||
if (decoded.name === 'identity') {
|
||||
this._pubKey = cryptoKeys.unmarshalPublicKey(decoded.digest)
|
||||
return this._pubKey
|
||||
if (decoded.name === 'identity') {
|
||||
this._pubKey = cryptoKeys.unmarshalPublicKey(decoded.digest)
|
||||
}
|
||||
} catch (_) {
|
||||
// Ignore, there is no valid public key
|
||||
}
|
||||
|
||||
return this._pubKey
|
||||
}
|
||||
|
||||
set pubKey (pubKey) {
|
||||
|
Reference in New Issue
Block a user