This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Merged
Implement Key API #1133
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
5b5e890
feat: construct the keychain when starting up
richardschneider 5ac6be2
feat: key is a core component
richardschneider 21ae698
fix: the keychain is always available
richardschneider ba82f7f
feat: key is a cli command
richardschneider 67dd69b
feat: http api routes for key
richardschneider 9951dd2
fix: core and http api should agree on names
richardschneider 32aa3dc
fix: key gen options
richardschneider 7bcdbc3
fix: remove nasty CRLFs
richardschneider 6af95b1
test(commands): less brittle
richardschneider 50b1af7
fix: key/rm returns key info
richardschneider dfd9198
chore: disable the keychain
richardschneider aa1f7f3
fix: lint errors
richardschneider 9ac70d3
rebasing with master
richardschneider 788597e
test: add core/interface/key
richardschneider a60f47c
test: add http-api/interface/key
richardschneider bb0ac88
test: add cli/key
richardschneider 4db92ec
feat: add --pass to command line #1135
richardschneider 6b2d15e
docs(readme): mention --pass and ipfs.key...
richardschneider ccac973
docs(readme): review changes
richardschneider 9799d99
test: --pass is listed in options
richardschneider c54be1c
feat: init creates the keychain with --pass
richardschneider cffdc80
fix: initing without --pass
richardschneider 69e1889
test: remove debug code
richardschneider 2805b04
feat(core.key): export and import of a key
richardschneider bbba773
feat(cli.key): export and import of a key
richardschneider 9cd7b7c
feat(http.api.key): export and import of a key
richardschneider 27b1529
test(http-api): create a keychain for the tests
richardschneider 637b241
fix: if no --pass, then no key management
richardschneider f8d4812
feat: create the keychain on init #1135
richardschneider 9c7813c
feat: auto upgrade to keychain
richardschneider 300fb7d
feat: print key ID then name, its easier to read
richardschneider 694518e
docs(readme): review change
richardschneider 3a648cd
chore: key cli normalisation
richardschneider d65aac3
chore: key core normalisation
richardschneider d26d38d
test: key cli output has changed
richardschneider 14de389
test: use DaemonFactory
richardschneider 5874d22
test: key normalisation
richardschneider 5d31eba
test: get working
richardschneider ed497e4
feat: if missing, create the 'seff' key
richardschneider cc594dc
chore: linting
richardschneider 47bbc30
chore: use latest keychain
richardschneider bab526e
fix: call to daemon factory
richardschneider File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,6 +195,8 @@ const node = new IPFS({ | |
// }, | ||
start: true, // default | ||
// start: false, | ||
pass: undefined // default | ||
// pass: 'pass phrase for key access', | ||
EXPERIMENTAL: { // enable experimental features | ||
pubsub: true, | ||
sharding: true, // enable dir sharding | ||
|
@@ -275,6 +277,17 @@ A complete API definition is in the works. Meanwhile, you can learn how to you u | |
- [`ipfs.object.patch.setData(multihash, data, [options, callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/OBJECT.md#objectpatchsetdata) | ||
- [pin (not implemented, yet!)](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/) | ||
|
||
#### `Crypto and Key Management` | ||
|
||
- [key](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/KEY.md) | ||
- `ipfs.key.export(name, password, [callback])` | ||
- `ipfs.key.gen(name, options, [callback])` | ||
- `ipfs.key.import(name, pem, password, [callback])` | ||
- `ipfs.key.list([callback])` | ||
- `ipfs.key.rename(oldName, newName, [callback])` | ||
- `ipfs.key.rm(name, [callback])` | ||
- [crypto (not yet implemented)](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC) | ||
|
||
#### `Network` | ||
|
||
- [bootstrap](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/) | ||
|
@@ -523,6 +536,10 @@ If you find any other issue, please check the [`Electron Support` issue](https:/ | |
| [`is-ipfs`](https://github.com/ipfs/is-ipfs) | [![npm](https://img.shields.io/npm/v/is-ipfs.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/is-ipfs/releases) | [![Dep](https://david-dm.org/ipfs/is-ipfs.svg?style=flat-square)](https://david-dm.org/ipfs/is-ipfs) | [![devDep](https://david-dm.org/ipfs/is-ipfs/dev-status.svg?style=flat-square)](https://david-dm.org/ipfs/is-ipfs?type=dev) | [![Travis](https://travis-ci.org/ipfs/is-ipfs.svg?branch=master)](https://travis-ci.org/ipfs/is-ipfs) | | ![Appveyor CI](https://ci.appveyor.com/api/projects/status/github/ipfs/is-ipfs?svg=true) | [![Coverage Status](https://coveralls.io/repos/github/ipfs/is-ipfs/badge.svg?branch=master)](https://coveralls.io/github/ipfs/is-ipfs?branch=master) | | ||
| [`multihashing`](//github.com/multiformats/js-multihashing) | [![npm](https://img.shields.io/npm/v/multihashing.svg?maxAge=86400&style=flat-square)](//github.com/multiformats/js-multihashing/releases) | [![Dep](https://david-dm.org/multiformats/js-multihashing.svg?style=flat-square)](https://david-dm.org/multiformats/js-multihashing) | [![devDep](https://david-dm.org/multiformats/js-multihashing/dev-status.svg?style=flat-square)](https://david-dm.org/multiformats/js-multihashing?type=dev) | [![Travis](https://travis-ci.org/multiformats/js-multihashing.svg?branch=master)](https://travis-ci.org/multiformats/js-multihashing) | [![Circle CI](https://circleci.com/gh/multiformats/js-multihashing.svg?style=svg)](https://circleci.com/gh/jbenet/js-multihashing) | ![Appveyor CI](https://ci.appveyor.com/api/projects/status/github/multiformats/js-multihashing?svg=true) | [![Coverage Status](https://coveralls.io/repos/github/jbenet/js-multihashing/badge.svg?branch=master)](https://coveralls.io/github/jbenet/js-multihashing?branch=master) | | ||
| [`mafmt`](//github.com/whyrusleeping/js-mafmt) | [![npm](https://img.shields.io/npm/v/mafmt.svg?maxAge=86400&style=flat-square)](//github.com/whyrusleeping/js-mafmt/releases) | [![Dep](https://david-dm.org/whyrusleeping/js-mafmt.svg?style=flat-square)](https://david-dm.org/whyrusleeping/js-mafmt) | [![devDep](https://david-dm.org/whyrusleeping/js-mafmt/dev-status.svg?style=flat-square)](https://david-dm.org/whyrusleeping/js-mafmt?type=dev) | [![Travis](https://travis-ci.org/whyrusleeping/js-mafmt.svg?branch=master)](https://travis-ci.org/whyrusleeping/js-mafmt) | [![Circle CI](https://circleci.com/gh/whyrusleeping/js-mafmt.svg?style=svg)](https://circleci.com/gh/whyrusleeping/js-mafmt) | ![Appveyor CI](https://ci.appveyor.com/api/projects/status/github/whyrusleeping/js-mafmt?svg=true) | [![Coverage Status](https://coveralls.io/repos/github/whyrusleeping/js-mafmt/badge.svg?branch=master)](https://coveralls.io/github/whyrusleeping/js-mafmt?branch=master) | | ||
| **Crypto** | ||
| [`libp2p-crypto`](https://github.com/libp2p/js-libp2p-crypto) | [![npm](https://img.shields.io/npm/v/libp2p-crypto.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-crypto/releases) | [![Dep](https://david-dm.org/libp2p/js-libp2p-crypto.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-crypto) | [![devDep](https://david-dm.org/libp2p/js-libp2p-crypto/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-crypto?type=dev) | [![Travis](https://travis-ci.org/libp2p/js-libp2p-crypto.svg?branch=master)](https://travis-ci.org/libp2p/js-libp2p-crypto) | [![Circle CI](https://circleci.com/gh/libp2p/js-libp2p-crypto.svg?style=svg)](https://circleci.com/gh/libp2p/js-libp2p-crypto) | ![Appveyor CI](https://ci.appveyor.com/api/projects/status/github/libp2p/js-libp2p-crypto?svg=true) | [![Coverage Status](https://coveralls.io/repos/github/libp2p/js-libp2p-crypto/badge.svg?branch=master)](https://coveralls.io/github/libp2p/js-libp2p-crypto?branch=master) | | ||
| [`libp2p-keychain`](https://github.com/libp2p/js-libp2p-keychain) | [![npm](https://img.shields.io/npm/v/libp2p-keychain.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-keychain/releases) | [![Dep](https://david-dm.org/libp2p/js-libp2p-keychain.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-keychain) | [![devDep](https://david-dm.org/libp2p/js-libp2p-keychain/dev-status.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-keychain?type=dev) | [![Travis](https://travis-ci.org/libp2p/js-libp2p-keychain.svg?branch=master)](https://travis-ci.org/libp2p/js-libp2p-keychain) | [![Circle CI](https://circleci.com/gh/libp2p/js-libp2p-keychain.svg?style=svg)](https://circleci.com/gh/libp2p/js-libp2p-keychain) | ![Appveyor CI](https://ci.appveyor.com/api/projects/status/github/libp2p/js-libp2p-keychain?svg=true) | [![Coverage Status](https://coveralls.io/repos/github/libp2p/js-libp2p-keychain/badge.svg?branch=master)](https://coveralls.io/github/libp2p/js-libp2p-keychain?branch=master) | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
|
||
## Development | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
command: 'key', | ||
|
||
description: 'Manage your keys', | ||
|
||
builder (yargs) { | ||
return yargs | ||
.commandDir('key') | ||
}, | ||
|
||
handler (argv) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict' | ||
|
||
const fs = require('fs') | ||
|
||
module.exports = { | ||
command: 'export <name>', | ||
|
||
describe: 'Export the key as a password protected PKCS #8 PEM file', | ||
|
||
builder: { | ||
passout: { | ||
alias: 'p', | ||
describe: 'Password for the PEM', | ||
type: 'string', | ||
demandOption: true | ||
}, | ||
output: { | ||
alias: 'o', | ||
describe: 'Output file', | ||
type: 'string', | ||
default: 'stdout' | ||
} | ||
}, | ||
|
||
handler (argv) { | ||
argv.ipfs.key.export(argv.name, argv.passout, (err, pem) => { | ||
if (err) { | ||
throw err | ||
} | ||
if (argv.output === 'stdout') { | ||
process.stdout.write(pem) | ||
} else { | ||
fs.writeFileSync(argv.output, pem) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict' | ||
|
||
const print = require('../../utils').print | ||
|
||
module.exports = { | ||
command: 'gen <name>', | ||
|
||
describe: 'Create a new key', | ||
|
||
builder: { | ||
type: { | ||
alias: 't', | ||
describe: 'type of the key to create [rsa, ed25519].', | ||
default: 'rsa' | ||
}, | ||
size: { | ||
alias: 's', | ||
describe: 'size of the key to generate.', | ||
default: '2048' | ||
} | ||
}, | ||
|
||
handler (argv) { | ||
const opts = { | ||
type: argv.type, | ||
size: argv.size | ||
} | ||
argv.ipfs.key.gen(argv.name, opts, (err, key) => { | ||
if (err) { | ||
throw err | ||
} | ||
print(`generated ${key.id} ${key.name}`) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict' | ||
|
||
const fs = require('fs') | ||
const print = require('../../utils').print | ||
|
||
module.exports = { | ||
command: 'import <name>', | ||
|
||
describe: 'Import the key from a PKCS #8 PEM file', | ||
|
||
builder: { | ||
passin: { | ||
alias: 'p', | ||
describe: 'Password for the PEM', | ||
type: 'string' | ||
}, | ||
input: { | ||
alias: 'i', | ||
describe: 'Input PEM file', | ||
type: 'string', | ||
demandOption: true, | ||
coerce: ('input', input => fs.readFileSync(input, 'utf8')) | ||
} | ||
}, | ||
|
||
handler (argv) { | ||
argv.ipfs.key.import(argv.name, argv.input, argv.passin, (err, key) => { | ||
if (err) { | ||
throw err | ||
} | ||
print(`imported ${key.id} ${key.name}`) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict' | ||
|
||
const print = require('../../utils').print | ||
|
||
module.exports = { | ||
command: 'list', | ||
|
||
describe: 'List all local keys', | ||
|
||
builder: {}, | ||
|
||
handler (argv) { | ||
argv.ipfs.key.list((err, keys) => { | ||
if (err) { | ||
throw err | ||
} | ||
keys.forEach((ki) => print(`${ki.id} ${ki.name}`)) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict' | ||
|
||
const print = require('../../utils').print | ||
|
||
module.exports = { | ||
command: 'rename <name> <newName>', | ||
|
||
describe: 'Rename a key', | ||
|
||
builder: {}, | ||
|
||
handler (argv) { | ||
argv.ipfs.key.rename(argv.name, argv.newName, (err, res) => { | ||
if (err) { | ||
throw err | ||
} | ||
print(`renamed to ${res.id} ${res.now}`) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict' | ||
|
||
const print = require('../../utils').print | ||
|
||
module.exports = { | ||
command: 'rm <name>', | ||
|
||
describe: 'Remove a key', | ||
|
||
builder: {}, | ||
|
||
handler (argv) { | ||
argv.ipfs.key.rm(argv.name, (err, key) => { | ||
if (err) { | ||
throw err | ||
} | ||
print(`${key.id} ${key.name}`) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs, nice!