Compare commits

...

4 Commits

4 changed files with 22 additions and 6 deletions

View File

@ -1,3 +1,13 @@
<a name="0.13.6"></a>
## [0.13.6](https://github.com/libp2p/js-peer-id/compare/v0.13.5...v0.13.6) (2019-12-18)
### Bug Fixes
* catch errors thrown by multihash decode ([#109](https://github.com/libp2p/js-peer-id/issues/109)) ([65e0b74](https://github.com/libp2p/js-peer-id/commit/65e0b74))
<a name="0.13.5"></a> <a name="0.13.5"></a>
## [0.13.5](https://github.com/libp2p/js-peer-id/compare/v0.13.4...v0.13.5) (2019-11-12) ## [0.13.5](https://github.com/libp2p/js-peer-id/compare/v0.13.4...v0.13.5) (2019-11-12)

View File

@ -127,7 +127,7 @@ const PeerId = require('peer-id')
### `new PeerId(id[, privKey, pubKey])` ### `new PeerId(id[, privKey, pubKey])`
- `id: Buffer` - The multihash of the publick key as `Buffer` - `id: Buffer` - The multihash of the public key as `Buffer`
- `privKey: RsaPrivateKey` - The private key - `privKey: RsaPrivateKey` - The private key
- `pubKey: RsaPublicKey` - The public key - `pubKey: RsaPublicKey` - The public key

View File

@ -1,6 +1,6 @@
{ {
"name": "peer-id", "name": "peer-id",
"version": "0.13.5", "version": "0.13.6",
"description": "IPFS Peer Id implementation in Node.js", "description": "IPFS Peer Id implementation in Node.js",
"leadMaintainer": "Vasco Santos <santos.vasco10@gmail.com>", "leadMaintainer": "Vasco Santos <santos.vasco10@gmail.com>",
"main": "src/index.js", "main": "src/index.js",
@ -52,6 +52,7 @@
}, },
"contributors": [ "contributors": [
"Arve Knudsen <arve.knudsen@gmail.com>", "Arve Knudsen <arve.knudsen@gmail.com>",
"Christian Paul <info@jaller.de>",
"David Dias <daviddias.p@gmail.com>", "David Dias <daviddias.p@gmail.com>",
"David Dias <mail@daviddias.me>", "David Dias <mail@daviddias.me>",
"Friedel Ziegelmayer <dignifiedquire@gmail.com>", "Friedel Ziegelmayer <dignifiedquire@gmail.com>",

View File

@ -50,12 +50,17 @@ class PeerId {
return this._privKey.public return this._privKey.public
} }
const decoded = mh.decode(this.id) try {
const decoded = mh.decode(this.id)
if (decoded.name === 'identity') { if (decoded.name === 'identity') {
this._pubKey = cryptoKeys.unmarshalPublicKey(decoded.digest) this._pubKey = cryptoKeys.unmarshalPublicKey(decoded.digest)
return this._pubKey }
} catch (_) {
// Ignore, there is no valid public key
} }
return this._pubKey
} }
set pubKey (pubKey) { set pubKey (pubKey) {