Skip to content

Commit

Permalink
chore: update deps (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Shaw authored and vasco-santos committed Dec 18, 2019
1 parent 2ab0fbd commit 6152692
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.6",
"protons": "^1.0.1",
"timestamp-nano": "^1.0.0"
},
Expand Down
11 changes: 3 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 2 additions & 7 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6152692

Please sign in to comment.