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

Feat/keys #17

Merged
merged 2 commits into from
Dec 15, 2015
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
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ js-ipfs-repo

> Implementation of the IPFS repo spec (https://github.com/ipfs/specs/tree/master/repo) in JavaScript

[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) [![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) [![Build Status](https://travis-ci.org/ipfs/js-ipfs-repo.svg)](https://travis-ci.org/ipfs/js-ipfs-repo) ![](https://img.shields.io/badge/coverage-53%25-yellow.svg?style=flat-square) [![Dependency Status](https://david-dm.org/diasdavid/js-peer-id.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-repo) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) [![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) [![Build Status](https://travis-ci.org/ipfs/js-ipfs-repo.svg)](https://travis-ci.org/ipfs/js-ipfs-repo) ![](https://img.shields.io/badge/coverage-86%25-yellow.svg?style=flat-square) [![Dependency Status](https://david-dm.org/diasdavid/js-peer-id.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-repo) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)

## Description

Expand Down Expand Up @@ -113,6 +113,14 @@ repo.config.write({foo: 'bar'}, function (err) {
})
```

### keys

Read/Write keys inside the repo. This feature will be expanded once [IPRS](https://github.com/ipfs/specs/tree/master/records) and [KeyChain](https://github.com/ipfs/specs/tree/master/keychain) are finalized and implemented on go-ipfs.

```js
repo.keys.get(function (err, privKey) {})
```

### datastore

Store data on the block store.
Expand Down
7 changes: 3 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ function Repo (repoPath, options) {
.config
.setUp(repoPath, options.stores.config, self.locks)

// TODO
// self.keys = stores
// .keys
// .setUp(repoPath, options.stores.keys, self.locks)
self.keys = stores
.keys
.setUp(repoPath, options.stores.keys, self.locks, self.config)

// TODO
// self.datastore = stores
Expand Down
6 changes: 3 additions & 3 deletions src/stores/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ exports = module.exports
exports.locks = require('./locks')
exports.version = require('./version')
exports.config = require('./config')
// exports.blocks = require('./blocks')
exports.keys = require('./keys')
// exports.datastore = require('./datastore')
// exports.datastoreLegacy = require('./datastore-legacy')
// exports.logs = require('./logs')
// exports.api = require('./api')
// exports.repo = require('./repo')

14 changes: 14 additions & 0 deletions src/stores/keys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
exports = module.exports

exports.setUp = function (basePath, blobStore, locks, config) {
return {
get: function (callback) {
config.get(function (err, config) {
if (err) {
return callback(err)
}
callback(null, config.Identity.PrivKey)
})
}
}
}
13 changes: 12 additions & 1 deletion tests/repo-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ describe('IPFS Repo Tests', function () {
})
})

describe('keys', function () {
it('get PrivKey', function (done) {
repo.keys.get(function (err, privKey) {
expect(err).to.equal(null)
expect(privKey).to.be.a('string')
done()
})
})
})

describe('config', function () {
it('get config', function (done) {
repo.config.get(function (err, config) {
Expand Down Expand Up @@ -127,5 +137,6 @@ describe('IPFS Repo Tests', function () {
})
})
})
describe('blocks', function () {})
describe('datastore', function () {})
describe('datastore-legacy', function () {})
})