Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add passphrase to init options #197

Merged
merged 1 commit into from
Jan 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ Initialize a repo.
`initOpts` (optional) is an object with the following properties:
- `keysize` (default 2048) - The bit size of the identity key.
- `directory` (default IPFS_PATH if defined, or ~/.ipfs for go-ipfs and ~/.jsipfs for js-ipfs) - The location of the repo.
- `pass` (optional) - The passphrase of the key chain.

`callback` is a function with the signature `function (Error, ipfsd)` where `err` is an Error in case something goes wrong and `ipfsd` is the daemon controller instance.

Expand Down
10 changes: 7 additions & 3 deletions src/daemon-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class Node {
* @param {Object} [initOpts={}]
* @param {number} [initOpts.keysize=2048] - The bit size of the identiy key.
* @param {string} [initOpts.directory=IPFS_PATH] - The location of the repo.
* @param {string} [initOpts.pass] - The passphrase of the keychain.
* @param {function (Error, Node)} callback
* @returns {undefined}
*/
Expand All @@ -117,13 +118,16 @@ class Node {
initOpts = {}
}

const keySize = initOpts.keysize || 2048

if (initOpts.directory && initOpts.directory !== this.path) {
this.path = initOpts.directory
}

run(this, ['init', '-b', keySize], { env: this.env }, (err, result) => {
const args = ['init', '-b', initOpts.keysize || 2048]
if (initOpts.pass) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@richardschneider this should already happen since args just get forwarded to the daemon.

args.push('--pass')
args.push('"' + initOpts.pass + '"')
}
run(this, args, { env: this.env }, (err, result) => {
if (err) {
return callback(err)
}
Expand Down
1 change: 1 addition & 0 deletions src/in-proc-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class Node {
* @param {Object} [initOpts={}]
* @param {number} [initOpts.keysize=2048] - The bit size of the identiy key.
* @param {string} [initOpts.directory=IPFS_PATH] - The location of the repo.
* @param {string} [initOpts.pass] - The passphrase of the keychain.
* @param {function (Error, Node)} callback
* @returns {undefined}
*/
Expand Down