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

Commit de2ac26

Browse files
committed
Merge pull request #68 from nginnever/master
ID command now generates a public key for output
2 parents 70ed97b + 5c91527 commit de2ac26

File tree

8 files changed

+17
-9
lines changed

8 files changed

+17
-9
lines changed

karma.conf.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
module.exports = function (config) {
2+
var path = require('path')
3+
var nodeForgePath = path.resolve(__dirname, 'node_modules/peer-id/deps/forge.bundle.js')
4+
25
config.set({
36
basePath: '',
47
frameworks: ['mocha'],
58

69
files: [
10+
nodeForgePath,
711
'tests/test-core/browser.js'
812
],
913

@@ -16,7 +20,8 @@ module.exports = function (config) {
1620
extensions: ['', '.js', '.json']
1721
},
1822
externals: {
19-
fs: '{}'
23+
fs: '{}',
24+
'node-forge': 'forge'
2025
},
2126
node: {
2227
Buffer: true

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"brfs": "^1.4.3",
3939
"buffer-loader": "0.0.1",
4040
"chai": "^3.4.1",
41+
"expose-loader": "^0.7.1",
4142
"fs-blob-store": "^5.2.1",
4243
"idb-plus-blob-store": "^1.0.0",
4344
"istanbul": "^0.4.1",
@@ -58,7 +59,7 @@
5859
"rimraf": "^2.4.4",
5960
"standard": "^5.4.1",
6061
"transform-loader": "^0.2.3",
61-
"webpack": "^2.0.5-beta"
62+
"webpack": "^2.0.7-beta"
6263
},
6364
"dependencies": {
6465
"bl": "^1.0.0",
@@ -71,6 +72,7 @@
7172
"ipfs-repo": "^0.5.0",
7273
"lodash.get": "^4.0.0",
7374
"lodash.set": "^4.0.0",
75+
"peer-id": "^0.5.0",
7476
"ronin": "^0.3.11"
7577
}
7678
}

src/ipfs-core/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const Block = blocks.Block
88
const mDAG = require('ipfs-merkle-dag')
99
const DAGNode = mDAG.DAGNode
1010
const DAGService = mDAG.DAGService
11+
const peerId = require('peer-id')
1112

1213
exports = module.exports = IPFS
1314

@@ -55,10 +56,10 @@ function IPFS (repo) {
5556
if (err) {
5657
return callback(err)
5758
}
59+
var pid = peerId.createFromPrivKey(config.Identity.PrivKey)
5860
callback(null, {
5961
ID: config.Identity.PeerID,
60-
// TODO needs https://github.com/diasdavid/js-peer-id/blob/master/src/index.js#L76
61-
PublicKey: '',
62+
PublicKey: pid.pubKey,
6263
Addresses: config.Addresses,
6364
AgentVersion: 'js-ipfs',
6465
ProtocolVersion: '9000'

tests/test-api/test-id.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('id', function () {
1212
url: '/api/v0/id'
1313
}, res => {
1414
expect(res.result).to.deep.equal({ ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A',
15-
PublicKey: '',
15+
PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAE=',
1616
Addresses: { Swarm: [ '/ip4/0.0.0.0/tcp/4001', '/ip6/::/tcp/4001' ],
1717
API: '/ip4/127.0.0.1/tcp/5001',
1818
Gateway: '/ip4/127.0.0.1/tcp/8080' },

tests/test-cli-offline/test-id.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('id', () => {
1010
nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'id'])
1111
.run((err, stdout, exitcode) => {
1212
var expected = [ "{ ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A',",
13-
" PublicKey: '',",
13+
" PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAE=',",
1414
' Addresses: ',
1515
" { Swarm: [ '/ip4/0.0.0.0/tcp/4001', '/ip6/::/tcp/4001' ],",
1616
" API: '/ip4/127.0.0.1/tcp/5001',",

tests/test-cli/test-id.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('id', () => {
1010
nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'id'])
1111
.run((err, stdout, exitcode) => {
1212
var expected = [ "{ ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A',",
13-
" PublicKey: '',",
13+
" PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAE=',",
1414
' Addresses: ',
1515
" { Swarm: [ '/ip4/0.0.0.0/tcp/4001', '/ip6/::/tcp/4001' ],",
1616
" API: '/ip4/127.0.0.1/tcp/5001',",

tests/test-core/browser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ idb.deleteDatabase('ipfs')
1515
idb.deleteDatabase('ipfs/blocks')
1616

1717
describe('IPFS Repo Tests on the Browser', function () {
18+
this.timeout(10000)
1819
before(function (done) {
1920
var repoData = []
2021
repoContext.keys().forEach(function (key) {
@@ -34,7 +35,6 @@ describe('IPFS Repo Tests on the Browser', function () {
3435

3536
const blocks = _.startsWith(file.key, 'blocks/')
3637
const blob = blocks ? blocksBlob : mainBlob
37-
3838
const key = blocks ? file.key.replace(/^blocks\//, '') : file.key
3939

4040
blob.createWriteStream({

tests/test-core/test-id.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('id', () => {
1313
ipfs.id((err, id) => {
1414
expect(err).to.not.exist
1515
expect(id).to.deep.equal({ ID: 'QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A',
16-
PublicKey: '',
16+
PublicKey: 'CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC2SKo/HMFZeBml1AF3XijzrxrfQXdJzjePBZAbdxqKR1Mc6juRHXij6HXYPjlAk01BhF1S3Ll4Lwi0cAHhggf457sMg55UWyeGKeUv0ucgvCpBwlR5cQ020i0MgzjPWOLWq1rtvSbNcAi2ZEVn6+Q2EcHo3wUvWRtLeKz+DZSZfw2PEDC+DGPJPl7f8g7zl56YymmmzH9liZLNrzg/qidokUv5u1pdGrcpLuPNeTODk0cqKB+OUbuKj9GShYECCEjaybJDl9276oalL9ghBtSeEv20kugatTvYy590wFlJkkvyl+nPxIH0EEYMKK9XRWlu9XYnoSfboiwcv8M3SlsjAgMBAAE=',
1717
Addresses: { Swarm: [ '/ip4/0.0.0.0/tcp/4001', '/ip6/::/tcp/4001' ],
1818
API: '/ip4/127.0.0.1/tcp/5001',
1919
Gateway: '/ip4/127.0.0.1/tcp/8080' },

0 commit comments

Comments
 (0)