mirror of
https://github.com/fluencelabs/js-peer-id
synced 2025-07-05 16:21:54 +00:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
bd1dc9bda0 | |||
31cbb5d94c | |||
35556c3a37 | |||
e8ab1b9281 | |||
a786018528 | |||
417fd330b9 | |||
d74bdebcc8 | |||
ffed046595 | |||
1727a135aa | |||
466b3a030d |
15
CHANGELOG.md
15
CHANGELOG.md
@ -1,3 +1,18 @@
|
|||||||
|
<a name="0.11.0"></a>
|
||||||
|
# [0.11.0](https://github.com/libp2p/js-peer-id/compare/v0.10.7...v0.11.0) (2018-07-02)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* change toPrint output to match go implementation ([e8ab1b9](https://github.com/libp2p/js-peer-id/commit/e8ab1b9))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="0.10.7"></a>
|
||||||
|
## [0.10.7](https://github.com/libp2p/js-peer-id/compare/v0.10.6...v0.10.7) (2018-04-05)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="0.10.6"></a>
|
<a name="0.10.6"></a>
|
||||||
## [0.10.6](https://github.com/libp2p/js-peer-id/compare/v0.10.5...v0.10.6) (2018-02-12)
|
## [0.10.6](https://github.com/libp2p/js-peer-id/compare/v0.10.5...v0.10.6) (2018-02-12)
|
||||||
|
|
||||||
|
10
README.md
10
README.md
@ -11,6 +11,12 @@
|
|||||||
|
|
||||||
> [IPFS](https://github.com/ipfs/ipfs) Peer ID implementation in JavaScript.
|
> [IPFS](https://github.com/ipfs/ipfs) Peer ID implementation in JavaScript.
|
||||||
|
|
||||||
|
## Lead Maintainer
|
||||||
|
|
||||||
|
[Pedro Teixeira](https://github.com/pgte)
|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
|
||||||
- [Description](#description)
|
- [Description](#description)
|
||||||
- [Example](#example)
|
- [Example](#example)
|
||||||
- [Installation](#installation)
|
- [Installation](#installation)
|
||||||
@ -195,7 +201,9 @@ Returns an `obj` of the form
|
|||||||
|
|
||||||
### `toPrint()`
|
### `toPrint()`
|
||||||
|
|
||||||
Alias for `.toJSON()`.
|
Returns the Peer ID as a printable string.
|
||||||
|
|
||||||
|
Example: `<peer.ID xxxxxx>`
|
||||||
|
|
||||||
### `isEqual(id)`
|
### `isEqual(id)`
|
||||||
|
|
||||||
|
18
package.json
18
package.json
@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "peer-id",
|
"name": "peer-id",
|
||||||
"version": "0.10.6",
|
"version": "0.11.0",
|
||||||
"description": "IPFS Peer Id implementation in Node.js",
|
"description": "IPFS Peer Id implementation in Node.js",
|
||||||
|
"leadMaintainer": "Pedro Teixeira <i@pgte.me>",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"bin": "src/bin.js",
|
"bin": "src/bin.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -18,9 +19,8 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"IPFS"
|
"IPFS"
|
||||||
],
|
],
|
||||||
"author": "David Dias <daviddias@ipfs.io>",
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"pre-commit": [
|
"pre-push": [
|
||||||
"lint",
|
"lint",
|
||||||
"test"
|
"test"
|
||||||
],
|
],
|
||||||
@ -33,15 +33,14 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/libp2p/js-peer-id",
|
"homepage": "https://github.com/libp2p/js-peer-id",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"aegir": "^12.4.0",
|
"aegir": "^14.0.0",
|
||||||
"chai": "^4.1.2",
|
"chai": "^4.1.2",
|
||||||
"dirty-chai": "^2.0.1",
|
"dirty-chai": "^2.0.1"
|
||||||
"pre-commit": "^1.2.2"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "^2.6.0",
|
"async": "^2.6.1",
|
||||||
"libp2p-crypto": "~0.12.1",
|
"libp2p-crypto": "~0.13.0",
|
||||||
"lodash": "^4.17.5",
|
"lodash": "^4.17.10",
|
||||||
"multihashes": "~0.4.13"
|
"multihashes": "~0.4.13"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@ -53,6 +52,7 @@
|
|||||||
"David Dias <mail@daviddias.me>",
|
"David Dias <mail@daviddias.me>",
|
||||||
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
|
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
|
||||||
"Maciej Krüger <mkg20001@gmail.com>",
|
"Maciej Krüger <mkg20001@gmail.com>",
|
||||||
|
"Michael Garvin <gar+gh@danger.computer>",
|
||||||
"Prashanth Chandra <coolshanth94@gmail.com>",
|
"Prashanth Chandra <coolshanth94@gmail.com>",
|
||||||
"Richard Littauer <richard.littauer@gmail.com>",
|
"Richard Littauer <richard.littauer@gmail.com>",
|
||||||
"Richard Schneider <makaretu@gmail.com>",
|
"Richard Schneider <makaretu@gmail.com>",
|
||||||
|
14
src/index.js
14
src/index.js
@ -67,9 +67,19 @@ class PeerId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pretty print
|
|
||||||
toPrint () {
|
toPrint () {
|
||||||
return this.toJSON()
|
let pid = this.toB58String()
|
||||||
|
// All sha256 nodes start with Qm
|
||||||
|
// We can skip the Qm to make the peer.ID more useful
|
||||||
|
if (pid.startsWith('Qm')) {
|
||||||
|
pid = pid.slice(2)
|
||||||
|
}
|
||||||
|
let maxRunes = 6
|
||||||
|
if (pid.length < maxRunes) {
|
||||||
|
maxRunes = pid.length
|
||||||
|
}
|
||||||
|
|
||||||
|
return '<peer.ID ' + pid.substr(0, maxRunes) + '>'
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the jsonified version of the key, matching the formatting
|
// return the jsonified version of the key, matching the formatting
|
||||||
|
@ -136,9 +136,10 @@ describe('PeerId', () => {
|
|||||||
it('Pretty printing', (done) => {
|
it('Pretty printing', (done) => {
|
||||||
PeerId.create(testOpts, (err, id1) => {
|
PeerId.create(testOpts, (err, id1) => {
|
||||||
expect(err).to.not.exist()
|
expect(err).to.not.exist()
|
||||||
PeerId.createFromPrivKey(id1.toPrint().privKey, (err, id2) => {
|
PeerId.createFromPrivKey(id1.toJSON().privKey, (err, id2) => {
|
||||||
expect(err).to.not.exist()
|
expect(err).to.not.exist()
|
||||||
expect(id1.toPrint()).to.be.eql(id2.toPrint())
|
expect(id1.toPrint()).to.be.eql(id2.toPrint())
|
||||||
|
expect(id1.toPrint()).to.equal('<peer.ID ' + id1.toB58String().substr(2, 6) + '>')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user