Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
feat: support key/export and key/import (#653)
Browse files Browse the repository at this point in the history
* feat: support key/export and key/import

* chore: update deps

* chore
  • Loading branch information
richardschneider authored and daviddias committed Dec 28, 2017
1 parent b0eaa78 commit 496f08e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
"peer-id": "~0.10.4",
"peer-info": "~0.11.4",
"promisify-es6": "^1.0.3",
"pump": "^1.0.3",
"pull-defer": "^0.2.2",
"pull-pushable": "^2.1.1",
"pump": "^1.0.3",
"qs": "^6.5.1",
"readable-stream": "^2.3.3",
"stream-http": "^2.7.2",
Expand All @@ -66,7 +66,7 @@
"dirty-chai": "^2.0.1",
"eslint-plugin-react": "^7.5.1",
"gulp": "^3.9.1",
"interface-ipfs-core": "~0.36.16",
"interface-ipfs-core": "~0.37.0",
"hapi": "^16.6.2",
"ipfsd-ctl": "~0.26.0",
"pre-commit": "^1.2.2",
Expand Down
16 changes: 16 additions & 0 deletions src/key/export.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict'

const promisify = require('promisify-es6')

module.exports = (send) => {
return promisify((name, password, callback) => {
send({
path: 'key/export',
args: name,
qs: { password: password }
}, (err, pem) => {
if (err) return callback(err)
callback(null, pem.toString())
})
})
}
16 changes: 16 additions & 0 deletions src/key/import.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict'

const promisify = require('promisify-es6')

module.exports = (send) => {
return promisify((name, pem, password, callback) => {
send({
path: 'key/import',
args: name,
qs: {
pem: pem,
password: password
}
}, callback)
})
}
4 changes: 3 additions & 1 deletion src/key/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module.exports = (arg) => {
gen: require('./gen')(send),
list: require('./list')(send),
rename: require('./rename')(send),
rm: require('./rm')(send)
rm: require('./rm')(send),
export: require('./export')(send),
import: require('./import')(send)
}
}

0 comments on commit 496f08e

Please sign in to comment.