Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
feat: add --pass to command line #1135
Browse files Browse the repository at this point in the history
Allow the pass phrase to specified on the jsipfs command line.
  • Loading branch information
richardschneider committed Dec 21, 2017
1 parent 28f120b commit 721ccf2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/cli/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ const cli = yargs
default: false,
coerce: ('silent', silent => silent ? utils.disablePrinting() : silent)
})
.option('pass', {
desc: 'Pass phrase for the keys',
type: 'string',
default: ''
})
.commandDir('commands')
.demandCommand(1)
.fail((msg, err, yargs) => {
Expand Down Expand Up @@ -59,7 +64,7 @@ if (args[0] === 'daemon' || args[0] === 'init') {
if (err) {
throw err
}
utils.getIPFS(argv.api, (err, ipfs, cleanup) => {
utils.getIPFS(argv, (err, ipfs, cleanup) => {
if (err) { throw err }

cli
Expand Down
7 changes: 4 additions & 3 deletions src/cli/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,16 @@ function getAPICtl (apiAddr) {
return APIctl(apiAddr)
}

exports.getIPFS = (apiAddr, callback) => {
if (apiAddr || isDaemonOn()) {
return callback(null, getAPICtl(apiAddr), (cb) => cb())
exports.getIPFS = (argv, callback) => {
if (argv.api || isDaemonOn()) {
return callback(null, getAPICtl(argv.api), (cb) => cb())
}

const node = new IPFS({
repo: exports.getRepoPath(),
init: false,
start: false,
pass: argv.pass,
EXPERIMENTAL: {
pubsub: true
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/pre-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = function preStart (self) {
return (callback) => {
self.log('pre-start')

self._keychain = new Keychain(self._repo.keys, { passPhrase: 'todo do not hardcode the pass phrase' })
self._keychain = new Keychain(self._repo.keys, { passPhrase: self._options.pass || 'todo do not hardcode the pass phrase' })

waterfall([
(cb) => self._repo.config.get(cb),
Expand Down
1 change: 1 addition & 0 deletions src/http/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function HttpApi (repo, config, cliArgs) {
init: init,
start: true,
config: config,
pass: cliArgs && cliArgs.pass,
EXPERIMENTAL: {
pubsub: cliArgs && cliArgs.enablePubsubExperiment,
sharding: cliArgs && cliArgs.enableShardingExperiment
Expand Down

0 comments on commit 721ccf2

Please sign in to comment.