Compare commits

..

6 Commits

Author SHA1 Message Date
9922f85693 chore: release version v0.12.5 2019-09-25 16:12:25 +02:00
843d35e1da chore: update contributors 2019-09-25 16:12:25 +02:00
ceeff130fa feat: inline public key handling for the 0.12.x line (#102) 2019-09-25 16:03:01 +02:00
8f4027b136 chore: release version v0.12.4 2019-07-23 14:38:20 +02:00
90835484fe chore: update contributors 2019-07-23 14:38:20 +02:00
8bcd9a880e chore: revert async dep change (#97)
* chore: revert async dep change

* chore: update async to 2.6.3
2019-07-23 13:32:46 +01:00
6 changed files with 38 additions and 4 deletions

View File

@ -22,7 +22,6 @@ jobs:
- stage: check
script:
- npx aegir commitlint --travis
- npx aegir dep-check
- npm run lint

View File

@ -1,3 +1,18 @@
<a name="0.12.5"></a>
## [0.12.5](https://github.com/libp2p/js-peer-id/compare/v0.12.4...v0.12.5) (2019-09-25)
### Features
* inline public key handling for the 0.12.x line ([#102](https://github.com/libp2p/js-peer-id/issues/102)) ([ceeff13](https://github.com/libp2p/js-peer-id/commit/ceeff13))
<a name="0.12.4"></a>
## [0.12.4](https://github.com/libp2p/js-peer-id/compare/v0.12.3...v0.12.4) (2019-07-23)
<a name="0.12.3"></a>
## [0.12.3](https://github.com/libp2p/js-peer-id/compare/v0.12.2...v0.12.3) (2019-07-11)

View File

@ -1,6 +1,6 @@
{
"name": "peer-id",
"version": "0.12.3",
"version": "0.12.5",
"description": "IPFS Peer Id implementation in Node.js",
"leadMaintainer": "Pedro Teixeira <i@pgte.me>",
"main": "src/index.js",
@ -34,14 +34,14 @@
},
"homepage": "https://github.com/libp2p/js-peer-id",
"devDependencies": {
"aegir": "^18.2.2",
"aegir": "^20.0.0",
"bundlesize": "~0.17.1",
"chai": "^4.2.0",
"dirty-chai": "^2.0.1"
},
"dependencies": {
"libp2p-crypto": "~0.16.1",
"async": "^3.0.1",
"async": "^2.6.3",
"class-is": "^1.1.0",
"multihashes": "~0.4.15"
},
@ -55,6 +55,7 @@
"David Dias <mail@daviddias.me>",
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
"Hugo Dias <hugomrdias@gmail.com>",
"Jacob Heun <jacobheun@gmail.com>",
"Maciej Krüger <mkg20001@gmail.com>",
"Michael Garvin <gar+gh@danger.computer>",
"Pedro Teixeira <i@pgte.me>",
@ -62,6 +63,7 @@
"Richard Littauer <richard.littauer@gmail.com>",
"Richard Schneider <makaretu@gmail.com>",
"Stephen Whitmore <stephen.whitmore@gmail.com>",
"Topper Bowers <topper@toppingdesign.com>",
"Vasco Santos <vasco.santos@ua.pt>",
"Vasco Santos <vasco.santos@moxy.studio>",
"Yahya <ya7yaz@gmail.com>",

View File

@ -9,5 +9,6 @@ PeerId.create((err, id) => {
throw err
}
// eslint-disable-next-line
console.log(JSON.stringify(id.toJSON(), null, 2))
})

View File

@ -48,6 +48,13 @@ class PeerId {
if (this._privKey) {
return this._privKey.public
}
const decoded = mh.decode(this.id)
if (decoded.name === 'identity') {
this._pubKey = cryptoKeys.unmarshalPublicKey(decoded.digest)
return this._pubKey
}
}
set pubKey (pubKey) {

View File

@ -50,6 +50,16 @@ describe('PeerId', () => {
})
})
it('can get the public key from a Secp256k1 key', (done) => {
PeerId.create({ keyType: 'secp256k1', bits: 256 }, (err, original) => {
expect(err).to.not.exist()
const newId = PeerId.createFromB58String(original.toB58String())
expect(original.pubKey.bytes).to.eql(newId.pubKey.bytes)
done()
})
})
it('isPeerId', (done) => {
PeerId.create(testOpts, (err, id) => {
expect(err).to.not.exist()