From b58decf5db2403cc96d3152f54999a8f3ddaff28 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Wed, 18 Dec 2019 00:05:31 +0000 Subject: [PATCH 1/2] chore: update deps --- package.json | 7 +++---- src/index.js | 11 +++-------- test/index.spec.js | 10 +++------- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index bd7c5ad..73ebea2 100644 --- a/package.json +++ b/package.json @@ -36,11 +36,10 @@ "base32-encode": "^1.1.0", "debug": "^4.1.1", "err-code": "^2.0.0", - "interface-datastore": "~0.7.0", - "libp2p-crypto": "^0.16.2", + "interface-datastore": "^0.8.0", + "libp2p-crypto": "^0.17.1", "multihashes": "~0.4.14", - "peer-id": "^0.12.2", - "promisify-es6": "^1.0.3", + "peer-id": "^0.13.5", "protons": "^1.0.1", "timestamp-nano": "^1.0.0" }, diff --git a/src/index.js b/src/index.js index dd1738a..41fefab 100644 --- a/src/index.js +++ b/src/index.js @@ -7,7 +7,6 @@ const crypto = require('libp2p-crypto') const PeerId = require('peer-id') const multihash = require('multihashes') const errCode = require('err-code') -const promisify = require('promisify-es6') const debug = require('debug') const log = debug('jsipns') @@ -92,9 +91,7 @@ const validate = async (publicKey, entry) => { // Validate Signature let isValid try { - isValid = await promisify(publicKey.verify, { - context: publicKey - })(dataForSignature, entry.signature) + isValid = await publicKey.verify(dataForSignature, entry.signature) } catch (err) { isValid = false } @@ -149,7 +146,7 @@ const embedPublicKey = async (publicKey, entry) => { // Create a peer id from the public key. let peerId try { - peerId = await promisify(PeerId.createFromPubKey)(publicKey.bytes) + peerId = await PeerId.createFromPubKey(publicKey.bytes) } catch (err) { throw errCode(err, ERRORS.ERR_PEER_ID_FROM_PUBLIC_KEY) } @@ -245,9 +242,7 @@ const sign = (privateKey, value, validityType, validity) => { try { const dataForSignature = ipnsEntryDataForSig(value, validityType, validity) - return promisify(privateKey.sign, { - context: privateKey - })(dataForSignature) + return privateKey.sign(dataForSignature) } catch (error) { log.error('record signature creation failed') throw errCode(new Error('record signature creation failed: ' + error.message), ERRORS.ERR_SIGNATURE_CREATION) diff --git a/test/index.spec.js b/test/index.spec.js index 6f6151d..3aa738d 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -15,7 +15,6 @@ const ipfsHttpClient = require('ipfs-http-client') const DaemonFactory = require('ipfsd-ctl') const crypto = require('libp2p-crypto') const { fromB58String } = require('multihashes') -const promisify = require('promisify-es6') const ipns = require('../src') const ERRORS = require('../src/errors') @@ -37,9 +36,7 @@ describe('ipns', function () { let rsa = null before(async () => { - rsa = await promisify(crypto.keys.generateKeyPair, { - context: crypto.keys - })('RSA', 2048) + rsa = await crypto.keys.generateKeyPair('RSA', 2048) ipfsd = await df.spawn({ initOptions: { bits: 512 } }) ipfs = ipfsd.api ipfsId = await ipfs.id() @@ -180,9 +177,7 @@ describe('ipns', function () { const sequence = 0 const validity = 1000000 - const ed25519 = await promisify(crypto.keys.generateKeyPair, { - context: crypto.keys - })('ed25519', 2048) + const ed25519 = await crypto.keys.generateKeyPair('ed25519', 2048) const entry = await ipns.create(ed25519, cid, sequence, validity) const entryWithKey = ipns.embedPublicKey(ed25519.public, entry) expect(entryWithKey).to.not.exist() // Should be null @@ -200,6 +195,7 @@ describe('ipns', function () { try { await ipns.validator.validate(marshalledData, key) } catch (err) { + console.log(err) expect(err.code).to.eql(ERRORS.ERR_UNDEFINED_PARAMETER) return } From 3f2bf808431e1371e2c271fa6a568680950fc648 Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Wed, 18 Dec 2019 08:24:57 -0800 Subject: [PATCH 2/2] chore: bump peer-id version and fix lint --- package.json | 2 +- test/index.spec.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 73ebea2..8a06171 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "interface-datastore": "^0.8.0", "libp2p-crypto": "^0.17.1", "multihashes": "~0.4.14", - "peer-id": "^0.13.5", + "peer-id": "^0.13.6", "protons": "^1.0.1", "timestamp-nano": "^1.0.0" }, diff --git a/test/index.spec.js b/test/index.spec.js index 3aa738d..d644dea 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -195,7 +195,6 @@ describe('ipns', function () { try { await ipns.validator.validate(marshalledData, key) } catch (err) { - console.log(err) expect(err.code).to.eql(ERRORS.ERR_UNDEFINED_PARAMETER) return }