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

Commit 721ccf2

Browse files
feat: add --pass to command line #1135
Allow the pass phrase to specified on the jsipfs command line.
1 parent 28f120b commit 721ccf2

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

src/cli/bin.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ const cli = yargs
2121
default: false,
2222
coerce: ('silent', silent => silent ? utils.disablePrinting() : silent)
2323
})
24+
.option('pass', {
25+
desc: 'Pass phrase for the keys',
26+
type: 'string',
27+
default: ''
28+
})
2429
.commandDir('commands')
2530
.demandCommand(1)
2631
.fail((msg, err, yargs) => {
@@ -59,7 +64,7 @@ if (args[0] === 'daemon' || args[0] === 'init') {
5964
if (err) {
6065
throw err
6166
}
62-
utils.getIPFS(argv.api, (err, ipfs, cleanup) => {
67+
utils.getIPFS(argv, (err, ipfs, cleanup) => {
6368
if (err) { throw err }
6469

6570
cli

src/cli/utils.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,16 @@ function getAPICtl (apiAddr) {
3838
return APIctl(apiAddr)
3939
}
4040

41-
exports.getIPFS = (apiAddr, callback) => {
42-
if (apiAddr || isDaemonOn()) {
43-
return callback(null, getAPICtl(apiAddr), (cb) => cb())
41+
exports.getIPFS = (argv, callback) => {
42+
if (argv.api || isDaemonOn()) {
43+
return callback(null, getAPICtl(argv.api), (cb) => cb())
4444
}
4545

4646
const node = new IPFS({
4747
repo: exports.getRepoPath(),
4848
init: false,
4949
start: false,
50+
pass: argv.pass,
5051
EXPERIMENTAL: {
5152
pubsub: true
5253
}

src/core/components/pre-start.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = function preStart (self) {
1313
return (callback) => {
1414
self.log('pre-start')
1515

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

1818
waterfall([
1919
(cb) => self._repo.config.get(cb),

src/http/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ function HttpApi (repo, config, cliArgs) {
6767
init: init,
6868
start: true,
6969
config: config,
70+
pass: cliArgs && cliArgs.pass,
7071
EXPERIMENTAL: {
7172
pubsub: cliArgs && cliArgs.enablePubsubExperiment,
7273
sharding: cliArgs && cliArgs.enableShardingExperiment

0 commit comments

Comments
 (0)