From ccf36bc418bf07c676d4e3814a8954520e1ec9a0 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 3 Jan 2018 13:34:54 +0000 Subject: [PATCH 1/9] Update KEY.md --- SPEC/KEY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SPEC/KEY.md b/SPEC/KEY.md index 2cd78445..4825f576 100644 --- a/SPEC/KEY.md +++ b/SPEC/KEY.md @@ -30,8 +30,8 @@ ipfs.key.add( { - Name: 'my-key', - Id: 'Qmd4xC46Um6s24MradViGLFtMitvrR4SVexKUgPgFjMNzg' + name: 'my-key', + id: 'Qmd4xC46Um6s24MradViGLFtMitvrR4SVexKUgPgFjMNzg' } ``` From 30f75feb8b7694d64dc31cadfda2ec4f4e3d9ac4 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 3 Jan 2018 13:42:25 +0000 Subject: [PATCH 2/9] Update KEY.md --- SPEC/KEY.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/SPEC/KEY.md b/SPEC/KEY.md index 4825f576..e64f5ebc 100644 --- a/SPEC/KEY.md +++ b/SPEC/KEY.md @@ -43,7 +43,14 @@ ipfs.key.add( ##### `JavaScript` - ipfs.key.list([callback]) -`callback` must follow `function (err, keys) {}` signature, where `err` is an Error if the operation was not successful. `keys` is an object with the property `Keys` that is an array of `KeyInfo` (`name` and `id`) +`callback` must follow `function (err, keys) {}` signature, where `err` is an Error if the operation was not successful. `keys` is an array of: + +``` +{ + id: 'hash', // string - the hash of the key + name: 'self' // string - the name of the key +} +``` If no `callback` is passed, a promise is returned. @@ -52,14 +59,12 @@ If no `callback` is passed, a promise is returned. ```JavaScript ipfs.key.list((err, keys) => console.log(keys)) -{ - Keys: [ - { Name: 'self', - Id: 'QmRT6i9wXVSmxKi3MxVRduZqF3Wvv8DuV5utMXPN3BxPML' }, - { Name: 'my-key', - Id: 'Qmd4xC46Um6s24MradViGLFtMitvrR4SVexKUgPgFjMNzg' } - ] -} +// [ +// { id: 'QmTe4tuceM2sAmuZiFsJ9tmAopA8au71NabBDdpPYDjxAb', +// name: 'self' }, +// { id: 'QmWETF5QvzGnP7jKq5sPDiRjSM2fzwzNsna4wSBEzRzK6W', +// name: 'a-key' } +// ] ``` #### `rm` From 4205235d72016635836fe9fd835f23c5f4cb9484 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 3 Jan 2018 13:49:53 +0000 Subject: [PATCH 3/9] Update KEY.md --- SPEC/KEY.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/SPEC/KEY.md b/SPEC/KEY.md index e64f5ebc..0a3fbf5e 100644 --- a/SPEC/KEY.md +++ b/SPEC/KEY.md @@ -63,7 +63,7 @@ ipfs.key.list((err, keys) => console.log(keys)) // { id: 'QmTe4tuceM2sAmuZiFsJ9tmAopA8au71NabBDdpPYDjxAb', // name: 'self' }, // { id: 'QmWETF5QvzGnP7jKq5sPDiRjSM2fzwzNsna4wSBEzRzK6W', -// name: 'a-key' } +// name: 'my-key' } // ] ``` @@ -78,7 +78,14 @@ ipfs.key.list((err, keys) => console.log(keys)) Where: - `name` is the local name for the key -`callback` must follow `function (err, key) {}` signature, where `err` is an Error if the operation was not successful. `key` is an object that describes the removed key. +`callback` must follow `function (err, key) {}` signature, where `err` is an Error if the operation was not successful. `key` is an object that describes the removed key: + +``` +{ + id: 'hash', // string - the hash of the key + name: 'self' // string - the name of the key +} +``` If no `callback` is passed, a promise is returned. @@ -87,12 +94,8 @@ If no `callback` is passed, a promise is returned. ```JavaScript ipfs.key.rm('my-key', (err, key) => console.log(key)) -{ - Keys: [ - { Name: 'my-key', - Id: 'Qmd4xC46Um6s24MradViGLFtMitvrR4SVexKUgPgFjMNzg' } - ] -} +// { id: 'QmWETF5QvzGnP7jKq5sPDiRjSM2fzwzNsna4wSBEzRzK6W', +// name: 'my-key' } ``` #### `rename` From 949aa1eff36275a03d047a1dfffb135c75d21741 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 3 Jan 2018 13:57:10 +0000 Subject: [PATCH 4/9] Update KEY.md --- SPEC/KEY.md | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/SPEC/KEY.md b/SPEC/KEY.md index 0a3fbf5e..c96fc5d0 100644 --- a/SPEC/KEY.md +++ b/SPEC/KEY.md @@ -94,7 +94,8 @@ If no `callback` is passed, a promise is returned. ```JavaScript ipfs.key.rm('my-key', (err, key) => console.log(key)) -// { id: 'QmWETF5QvzGnP7jKq5sPDiRjSM2fzwzNsna4wSBEzRzK6W', +// { +// id: 'QmWETF5QvzGnP7jKq5sPDiRjSM2fzwzNsna4wSBEzRzK6W', // name: 'my-key' } ``` @@ -117,17 +118,12 @@ If no `callback` is passed, a promise is returned. **Example:** ```JavaScript -ipfs.key.rename( - 'my-key', - 'my-new-key', - (err, key) => console.log(key)) - -{ - Was: 'my-key', - Now: 'my-new-key', - Id: 'Qmd4xC46Um6s24MradViGLFtMitvrR4SVexKUgPgFjMNzg', - Overwrite: false -} +ipfs.key.rename('my-key', 'my-new-key', (err, key) => console.log(key)) + +// { id: 'Qmd4xC46Um6s24MradViGLFtMitvrR4SVexKUgPgFjMNzg', +// was: 'my-key', +// now: 'my-new-key', +// overwrite: false } ``` #### `export` From 01af76ba70801fabbd25bb98b88335d91c0a43cd Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 3 Jan 2018 13:57:25 +0000 Subject: [PATCH 5/9] Update KEY.md --- SPEC/KEY.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SPEC/KEY.md b/SPEC/KEY.md index c96fc5d0..a33b398f 100644 --- a/SPEC/KEY.md +++ b/SPEC/KEY.md @@ -94,8 +94,7 @@ If no `callback` is passed, a promise is returned. ```JavaScript ipfs.key.rm('my-key', (err, key) => console.log(key)) -// { -// id: 'QmWETF5QvzGnP7jKq5sPDiRjSM2fzwzNsna4wSBEzRzK6W', +// { id: 'QmWETF5QvzGnP7jKq5sPDiRjSM2fzwzNsna4wSBEzRzK6W', // name: 'my-key' } ``` From 2478597d8b3ead0d235d97bf0a580d8426ed84bb Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 3 Jan 2018 14:03:31 +0000 Subject: [PATCH 6/9] Update KEY.md --- SPEC/KEY.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/SPEC/KEY.md b/SPEC/KEY.md index a33b398f..4aaab724 100644 --- a/SPEC/KEY.md +++ b/SPEC/KEY.md @@ -137,7 +137,7 @@ Where: - `name` is the local name for the key - `password` is the password to protect the key -`callback` must follow `function (err, pem) {}` signature, where `err` is an Error if the operation was not successful. `pem` is the string representation of the key +`callback` must follow `function (err, pem) {}` signature, where `err` is an Error if the operation was not successful. `pem` is the string representation of the key. If no `callback` is passed, a promise is returned. @@ -146,12 +146,11 @@ If no `callback` is passed, a promise is returned. ```JavaScript ipfs.key.export('self', 'password', (err, pem) => console.log(pem)) ------BEGIN ENCRYPTED PRIVATE KEY----- -MIIFDTA/BgkqhkiG9w0BBQ0wMjAaBgkqhkiG9w0BBQwwDQQIpdO40RVyBwACAWQw -... -YA== ------END ENCRYPTED PRIVATE KEY----- - +// -----BEGIN ENCRYPTED PRIVATE KEY----- +// MIIFDTA/BgkqhkiG9w0BBQ0wMjAaBgkqhkiG9w0BBQwwDQQIpdO40RVyBwACAWQw +// ... +// YA== +// -----END ENCRYPTED PRIVATE KEY----- ``` #### `import` @@ -176,7 +175,6 @@ If no `callback` is passed, a promise is returned. ```JavaScript ipfs.key.import('clone', 'password', (err, key) => console.log(key)) -{ Name: 'clone', - Id: 'QmQRiays958UM7norGRQUG3tmrLq8pJdmJarwYSk2eLthQ' -} +// { id: 'QmQRiays958UM7norGRQUG3tmrLq8pJdmJarwYSk2eLthQ', +// name: 'clone' } ``` From b47b3500f89d452e5fe9453356775507443e052a Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 3 Jan 2018 14:07:03 +0000 Subject: [PATCH 7/9] Update KEY.md --- SPEC/KEY.md | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/SPEC/KEY.md b/SPEC/KEY.md index 4aaab724..f0342f1d 100644 --- a/SPEC/KEY.md +++ b/SPEC/KEY.md @@ -23,16 +23,13 @@ If no `callback` is passed, a promise is returned. **Example:** ```JavaScript -ipfs.key.add( - 'my-key', - { type: 'rsa', size: 2048 }, - (err, key) => console.log(key)) +ipfs.key.gen('my-key', { + type: 'rsa', + size: 2048 +}, (err, key) => console.log(key)) - -{ - name: 'my-key', - id: 'Qmd4xC46Um6s24MradViGLFtMitvrR4SVexKUgPgFjMNzg' -} +// { id: 'QmYWqAFvLWb2G5A69JGXui2JJXzaHXiUEmQkQgor6kNNcJ', +// name: 'my-key' } ``` #### `list` From f1ec94299d630fe287c09d0eaf986d7eba15631f Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 3 Jan 2018 14:11:25 +0000 Subject: [PATCH 8/9] Update key.js --- src/key.js | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/key.js b/src/key.js index 48daa2d7..1d437f25 100644 --- a/src/key.js +++ b/src/key.js @@ -47,8 +47,8 @@ module.exports = (common) => { ipfs.key.gen(name, kt, (err, key) => { expect(err).to.not.exist() expect(key).to.exist() - expect(key).to.have.property('Name', name) - expect(key).to.have.property('Id') + expect(key).to.have.property('name', name) + expect(key).to.have.property('id') keys.push(key) done() }) @@ -62,8 +62,8 @@ module.exports = (common) => { ipfs.key.list((err, res) => { expect(err).to.not.exist() expect(res).to.exist() - expect(res.Keys).to.exist() - expect(res.Keys.length).to.be.above(keys.length - 1) + expect(res).to.be.an('array') + expect(res.length).to.be.above(keys.length - 1) listedKeys = res.Keys done() }) @@ -71,7 +71,7 @@ module.exports = (common) => { it('contains the created keys', () => { keys.forEach(ki => { - const found = listedKeys.filter(lk => ki.Name === lk.Name && ki.Id === lk.Id) + const found = listedKeys.filter(lk => ki.name === lk.name && ki.id === lk.id) expect(found).to.have.length(1) }) }) @@ -82,7 +82,7 @@ module.exports = (common) => { let newName before(() => { - oldName = keys[0].Name + oldName = keys[0].name newName = 'x' + oldName }) @@ -90,10 +90,10 @@ module.exports = (common) => { ipfs.key.rename(oldName, newName, (err, res) => { expect(err).to.not.exist() expect(res).to.exist() - expect(res).to.have.property('Was', oldName) - expect(res).to.have.property('Now', newName) - expect(res).to.have.property('Id', keys[0].Id) - keys[0].Name = newName + expect(res).to.have.property('was', oldName) + expect(res).to.have.property('now', newName) + expect(res).to.have.property('id', keys[0].id) + keys[0].name = newName done() }) }) @@ -101,7 +101,7 @@ module.exports = (common) => { it('contains the new name', (done) => { ipfs.key.list((err, res) => { expect(err).to.not.exist() - const found = res.Keys.filter(k => k.Name === newName) + const found = res.filter(k => k.name === newName) expect(found).to.have.length(1) done() }) @@ -110,7 +110,7 @@ module.exports = (common) => { it('does not contain the old name', (done) => { ipfs.key.list((err, res) => { expect(err).to.not.exist() - const found = res.Keys.filter(k => k.Name === oldName) + const found = res.filter(k => k.name === oldName) expect(found).to.have.length(0) done() }) @@ -127,10 +127,8 @@ module.exports = (common) => { ipfs.key.rm(key.Name, (err, res) => { expect(err).to.not.exist() expect(res).to.exist() - expect(res).to.have.property('Keys') - expect(res.Keys).to.have.length(1) - expect(res.Keys[0]).to.have.property('Name', key.Name) - expect(res.Keys[0]).to.have.property('Id', key.Id) + expect(res).to.have.property('name', key.name) + expect(res).to.have.property('id', key.id) done() }) }) @@ -138,7 +136,7 @@ module.exports = (common) => { it('does not contain the removed name', (done) => { ipfs.key.list((err, res) => { expect(err).to.not.exist() - const found = res.Keys.filter(k => k.Name === key.Name) + const found = res.filter(k => k.name === key.name) expect(found).to.have.length(0) done() }) @@ -170,8 +168,8 @@ module.exports = (common) => { ipfs.key.import('clone', selfPem, passwordPem, (err, key) => { expect(err).to.not.exist() expect(key).to.exist() - expect(key).to.have.property('Name', 'clone') - expect(key).to.have.property('Id') + expect(key).to.have.property('name', 'clone') + expect(key).to.have.property('id') done() }) }) From 2b44a6dd7734c9cef171d3ebcb05362750df3bb2 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 3 Jan 2018 14:12:24 +0000 Subject: [PATCH 9/9] Update key.js --- src/key.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/key.js b/src/key.js index 1d437f25..4e60f72e 100644 --- a/src/key.js +++ b/src/key.js @@ -64,7 +64,7 @@ module.exports = (common) => { expect(res).to.exist() expect(res).to.be.an('array') expect(res.length).to.be.above(keys.length - 1) - listedKeys = res.Keys + listedKeys = res done() }) }) @@ -124,7 +124,7 @@ module.exports = (common) => { }) it('removes a key', function (done) { - ipfs.key.rm(key.Name, (err, res) => { + ipfs.key.rm(key.name, (err, res) => { expect(err).to.not.exist() expect(res).to.exist() expect(res).to.have.property('name', key.name)