mirror of
https://github.com/fluencelabs/js-peer-id
synced 2025-07-04 15:21:48 +00:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
d2894bfa32 | |||
c3e3b70d09 | |||
f08866047d | |||
a3fe1a2f03 | |||
0acc572fd3 | |||
8c49610dff |
11
package.json
11
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "peer-id",
|
"name": "peer-id",
|
||||||
"version": "0.8.4",
|
"version": "0.8.5",
|
||||||
"description": "IPFS Peer Id implementation in Node.js",
|
"description": "IPFS Peer Id implementation in Node.js",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"bin": "src/bin.js",
|
"bin": "src/bin.js",
|
||||||
@ -34,15 +34,16 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/libp2p/js-peer-id",
|
"homepage": "https://github.com/libp2p/js-peer-id",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"aegir": "^11.0.0",
|
"aegir": "^11.0.1",
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
"dirty-chai": "^1.2.2",
|
"dirty-chai": "^1.2.2",
|
||||||
"pre-commit": "^1.2.2"
|
"pre-commit": "^1.2.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"libp2p-crypto": "~0.8.6",
|
"async": "^2.2.0",
|
||||||
"multihashes": "~0.4.4",
|
"libp2p-crypto": "~0.8.7",
|
||||||
"async": "^2.1.5"
|
"lodash": "^4.17.4",
|
||||||
|
"multihashes": "~0.4.5"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -91,7 +91,6 @@ class PeerId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exports = module.exports = PeerId
|
exports = module.exports = PeerId
|
||||||
exports.Buffer = Buffer
|
|
||||||
|
|
||||||
// generation
|
// generation
|
||||||
exports.create = function (opts, callback) {
|
exports.create = function (opts, callback) {
|
||||||
@ -219,6 +218,12 @@ exports.createFromJSON = function (obj, callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.isPeerId = function (peerId) {
|
||||||
|
return Boolean(typeof peerId === 'object' &&
|
||||||
|
peerId._id &&
|
||||||
|
peerId._idB58String)
|
||||||
|
}
|
||||||
|
|
||||||
function toB64Opt (val) {
|
function toB64Opt (val) {
|
||||||
if (val) {
|
if (val) {
|
||||||
return val.toString('base64')
|
return val.toString('base64')
|
||||||
|
@ -32,6 +32,16 @@ describe('PeerId', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('isPeerId', (done) => {
|
||||||
|
PeerId.create((err, id) => {
|
||||||
|
expect(err).to.not.exist()
|
||||||
|
expect(PeerId.isPeerId(id)).to.equal(true)
|
||||||
|
expect(PeerId.isPeerId('aaa')).to.equal(false)
|
||||||
|
expect(PeerId.isPeerId(new Buffer('batatas'))).to.equal(false)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it('throws on changing the id', (done) => {
|
it('throws on changing the id', (done) => {
|
||||||
PeerId.create((err, id) => {
|
PeerId.create((err, id) => {
|
||||||
expect(err).to.not.exist()
|
expect(err).to.not.exist()
|
||||||
|
Reference in New Issue
Block a user