From 03459fb0a58aad1927e929063f1e6e5b6fad21c7 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Thu, 11 Jul 2019 11:16:06 +0100 Subject: [PATCH] chore: rebase branch --- package.json | 7 +++---- src/bin.js | 2 +- src/index.js | 10 +++++----- test/peer-id.spec.js | 8 ++++---- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index da3d393..f0beb49 100644 --- a/package.json +++ b/package.json @@ -34,15 +34,14 @@ }, "homepage": "https://github.com/libp2p/js-peer-id", "devDependencies": { - "aegir": "^18.2.2", - "bundlesize": "~0.17.1", + "aegir": "^19.0.5", + "bundlesize": "~0.18.0", "chai": "^4.2.0", "dirty-chai": "^2.0.1" }, "dependencies": { - "async": "^2.6.2", "class-is": "^1.1.0", - "libp2p-crypto": "~0.16.1", + "libp2p-crypto": "libp2p/js-libp2p-crypto", "multihashes": "~0.4.14" }, "repository": { diff --git a/src/bin.js b/src/bin.js index 87b74c3..cbf0602 100755 --- a/src/bin.js +++ b/src/bin.js @@ -6,7 +6,7 @@ const PeerId = require('./index.js') async function main () { const id = await PeerId.create() - console.log(JSON.stringify(id.toJSON(), null, 2)) + console.log(JSON.stringify(id.toJSON(), null, 2)) // eslint-disable-line no-console } main() diff --git a/src/index.js b/src/index.js index 7a65121..8ca1040 100644 --- a/src/index.js +++ b/src/index.js @@ -140,7 +140,7 @@ exports.create = async (opts) => { opts = opts || {} opts.bits = opts.bits || 2048 - const key = await crypto.keys.generateKeyPair('RSA', opts.bits) + const key = await cryptoKeys.generateKeyPair('RSA', opts.bits) const digest = await key.public.hash() return new PeerIdWithIs(digest, key) @@ -170,7 +170,7 @@ exports.createFromPubKey = async (key) => { throw new Error('Supplied key is neither a base64 string nor a buffer') } - const pubKey = await crypto.keys.unmarshalPublicKey(buf) + const pubKey = await cryptoKeys.unmarshalPublicKey(buf) const digest = await pubKey.hash() return new PeerIdWithIs(digest, null, pubKey) } @@ -187,7 +187,7 @@ exports.createFromPrivKey = async (key) => { throw new Error('Supplied key is neither a base64 string nor a buffer') } - const privKey = await crypto.keys.unmarshalPrivateKey(buf) + const privKey = await cryptoKeys.unmarshalPrivateKey(buf) const digest = await privKey.public.hash() return new PeerIdWithIs(digest, privKey, privKey.public) @@ -197,13 +197,13 @@ exports.createFromJSON = async (obj) => { let id = mh.fromB58String(obj.id) let rawPrivKey = obj.privKey && Buffer.from(obj.privKey, 'base64') let rawPubKey = obj.pubKey && Buffer.from(obj.pubKey, 'base64') - let pub = rawPubKey && await crypto.keys.unmarshalPublicKey(rawPubKey) + let pub = rawPubKey && await cryptoKeys.unmarshalPublicKey(rawPubKey) if (!rawPrivKey) { return new PeerIdWithIs(id, null, pub) } - const privKey = await crypto.keys.unmarshalPrivateKey(rawPrivKey) + const privKey = await cryptoKeys.unmarshalPrivateKey(rawPrivKey) const privDigest = await privKey.public.hash() let pubDigest diff --git a/test/peer-id.spec.js b/test/peer-id.spec.js index 93c68df..468273d 100644 --- a/test/peer-id.spec.js +++ b/test/peer-id.spec.js @@ -51,17 +51,17 @@ describe('PeerId', () => { }).to.throw(/immutable/) }) - it('recreate an Id from Hex string', async () => { + it('recreate an Id from Hex string', () => { const id = PeerId.createFromHexString(testIdHex) expect(testIdBytes).to.deep.equal(id.id) }) - it('Recreate an Id from a Buffer', async () => { + it('Recreate an Id from a Buffer', () => { const id = PeerId.createFromBytes(testIdBytes) expect(testId.id).to.equal(id.toHexString()) }) - it('Recreate a B58 String', async () => { + it('Recreate a B58 String', () => { const id = PeerId.createFromB58String(testIdB58String) expect(testIdB58String).to.equal(id.toB58String()) }) @@ -106,7 +106,7 @@ describe('PeerId', () => { expect(id1.toPrint()).to.equal('') }) - it('toBytes', async () => { + it('toBytes', () => { const id = PeerId.createFromHexString(testIdHex) expect(id.toBytes().toString('hex')).to.equal(testIdBytes.toString('hex')) })