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

Commit 219ef2c

Browse files
authored
Merge pull request #485 from ipfs/fast-keys
Async Crypto + Less magic to 'run in the browser'
2 parents 6cc2d4a + 4aad341 commit 219ef2c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+686
-791
lines changed

.aegir.js

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
11
'use strict'
22

3-
const path = require('path')
4-
53
module.exports = {
6-
webpack: {
7-
resolve: {
8-
alias: {
9-
'libp2p-ipfs': 'libp2p-ipfs-browser',
10-
'node-forge': path.resolve(
11-
path.dirname(require.resolve('libp2p-crypto')),
12-
'../vendor/forge.bundle.js'
13-
)
14-
}
15-
},
16-
externals: {
17-
mkdirp: '{}',
18-
glob: '{}',
19-
'simple-websocket-server': '{}'
20-
}
4+
karma: {
5+
files: [{
6+
pattern: 'node_modules/interface-ipfs-core/test/fixtures/**/*',
7+
watched: false,
8+
served: true,
9+
included: false
10+
}]
2111
}
22-
}
12+
}

.travis.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
sudo: false
22
language: node_js
3-
node_js:
4-
- 4
5-
- 5
6-
- stable
3+
4+
matrix:
5+
include:
6+
- node_js: 4
7+
env: CXX=g++-4.8
8+
- node_js: 6
9+
env:
10+
- SAUCE=true
11+
- CXX=g++-4.8
12+
- node_js: stable
13+
env: CXX=g++-4.8
714

815
# Make sure we have new NPM.
916
before_install:
@@ -22,9 +29,6 @@ before_script:
2229
after_success:
2330
- npm run coverage-publish
2431

25-
env:
26-
- CXX=g++-4.8
27-
2832
addons:
2933
firefox: 'latest'
3034
apt:

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
[![](https://img.shields.io/badge/pm-waffle-yellow.svg?style=flat-square)](https://waffle.io/ipfs/js-ipfs)
1414
[![](https://img.shields.io/badge/interface--ipfs--core-API%20Docs-blue.svg)](https://github.com/ipfs/interface-ipfs-core)
1515
[![](https://img.shields.io/badge/interface--ipfs--core-Updates-blue.svg)](https://github.com/ipfs/interface-ipfs-core/issues/55)
16+
![](https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square)
17+
![](https://img.shields.io/badge/Node.js-%3E%3D4.0.0-orange.svg?style=flat-square)
1618

19+
[![Sauce Test Status](https://saucelabs.com/browser-matrix/js-ipfs.svg)](https://saucelabs.com/u/js-ipfs)
1720

1821
> IPFS JavaScript implementation.
1922

gulpfile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let nodes = []
1111
function startNode (num, done) {
1212
createTempNode(num, (err, node) => {
1313
if (err) {
14-
throw err
14+
return done(err)
1515
}
1616

1717
const api = new API(node.repo.path())
@@ -25,6 +25,7 @@ gulp.task('libnode:start', (done) => {
2525
parallel([
2626
(cb) => startNode(7, cb),
2727
(cb) => startNode(8, cb),
28+
(cb) => startNode(12, cb),
2829
(cb) => startNode(13, cb)
2930
], done)
3031
})

package.json

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,31 @@
55
"bin": {
66
"jsipfs": "src/cli/bin.js"
77
},
8-
"main": "lib/core/index.js",
9-
"jsnext:main": "src/core/index.js",
8+
"main": "src/core/index.js",
9+
"browser": {
10+
"libp2p-ipfs": "libp2p-ipfs-browser",
11+
"./src/core/default-repo.js": "./src/core/default-repo-browser.js",
12+
"./src/core/components/init-assets.js": false,
13+
"./test/utils/temp-repo.js": "./test/utils/temp-repo-browser.js",
14+
"stream": "readable-stream"
15+
},
16+
"engines": {
17+
"node": ">=4.0.0",
18+
"npm": ">=3.0.0"
19+
},
1020
"scripts": {
1121
"lint": "aegir-lint",
1222
"coverage": "gulp coverage",
13-
"test": "PHANTOM=off gulp test",
23+
"test": "gulp test",
1424
"test:node": "gulp test:node",
1525
"test:node:core": "TEST=core npm run test:node",
1626
"test:node:http": "TEST=http npm run test:node",
1727
"test:node:cli": "TEST=cli npm run test:node",
18-
"test:browser": "PHANTOM=off gulp test:browser",
28+
"test:browser": "gulp test:browser",
1929
"build": "gulp build",
20-
"release": "PHANTOM=off gulp release",
21-
"release-minor": "PHANTOM=off gulp release --type minor",
22-
"release-major": "PHANTOM=off gulp release --type major",
30+
"release": "gulp release",
31+
"release-minor": "gulp release --type minor",
32+
"release-major": "gulp release --type major",
2333
"coverage-publish": "aegir-coverage publish"
2434
},
2535
"pre-commit": [
@@ -40,17 +50,18 @@
4050
},
4151
"homepage": "https://github.com/ipfs/js-ipfs#readme",
4252
"devDependencies": {
43-
"aegir": "^8.1.2",
53+
"aegir": "^9.1.1",
4454
"buffer-loader": "0.0.1",
4555
"chai": "^3.5.0",
56+
"detect-node": "^2.0.3",
4657
"execa": "^0.5.0",
4758
"expose-loader": "^0.7.1",
48-
"form-data": "^2.0.0",
59+
"form-data": "^2.1.2",
4960
"fs-pull-blob-store": "^0.4.1",
5061
"gulp": "^3.9.1",
51-
"interface-ipfs-core": "^0.16.6",
52-
"left-pad": "^1.1.1",
53-
"lodash": "^4.15.0",
62+
"interface-ipfs-core": "^0.18.4",
63+
"left-pad": "^1.1.3",
64+
"lodash": "^4.16.6",
5465
"ncp": "^2.0.0",
5566
"nexpect": "^0.5.0",
5667
"pre-commit": "^1.1.3",
@@ -59,62 +70,57 @@
5970
"transform-loader": "^0.2.3"
6071
},
6172
"dependencies": {
62-
"async": "^2.0.1",
63-
"babel-runtime": "^6.11.6",
73+
"async": "^2.1.2",
6474
"bl": "^1.1.2",
65-
"boom": "^4.0.0",
66-
"bs58": "^3.0.0",
67-
"debug": "^2.2.0",
68-
"detect-node": "^2.0.3",
75+
"boom": "^4.2.0",
76+
"debug": "^2.3.2",
6977
"fs-pull-blob-store": "^0.3.0",
70-
"glob": "^7.0.6",
78+
"glob": "^7.1.1",
7179
"hapi": "^15.2.0",
80+
"hapi-set-header": "^1.0.2",
7281
"idb-pull-blob-store": "^0.5.1",
73-
"ipfs-api": "^10.0.0",
74-
"ipfs-bitswap": "^0.7.0",
75-
"ipfs-block": "^0.4.0",
76-
"ipfs-block-service": "^0.6.0",
82+
"ipfs-api": "^11.1.0",
83+
"ipfs-bitswap": "^0.8.1",
84+
"ipfs-block": "^0.5.0",
85+
"ipfs-block-service": "^0.7.0",
7786
"ipfs-multipart": "^0.1.0",
78-
"ipfs-repo": "^0.10.0",
79-
"ipfs-unixfs": "^0.1.4",
80-
"ipfs-unixfs-engine": "^0.12.0",
81-
"ipld-resolver": "^0.1.1",
87+
"ipfs-repo": "^0.11.1",
88+
"ipfs-unixfs": "^0.1.5",
89+
"ipfs-unixfs-engine": "^0.13.0",
90+
"ipld-resolver": "^0.2.0",
8291
"isstream": "^0.1.2",
83-
"joi": "^9.0.4",
84-
"libp2p-ipfs": "^0.14.1",
85-
"libp2p-ipfs-browser": "^0.15.1",
92+
"joi": "^9.2.0",
93+
"libp2p-ipfs": "^0.15.0",
94+
"libp2p-ipfs-browser": "^0.16.0",
8695
"lodash.flatmap": "^4.5.0",
8796
"lodash.get": "^4.4.2",
8897
"lodash.has": "^4.5.2",
8998
"lodash.set": "^4.3.2",
9099
"lodash.sortby": "^4.7.0",
91100
"lodash.values": "^4.3.0",
92101
"mafmt": "^2.1.2",
93-
"map-limit": "0.0.1",
94102
"multiaddr": "^2.0.3",
95103
"multihashes": "^0.2.2",
96104
"path-exists": "^3.0.0",
97105
"peer-book": "^0.3.0",
98-
"peer-id": "^0.7.0",
99-
"peer-info": "^0.7.1",
100-
"promisify-es6": "^1.0.1",
106+
"peer-id": "^0.8.0",
107+
"peer-info": "^0.8.0",
108+
"promisify-es6": "^1.0.2",
101109
"pull-file": "^1.0.0",
102-
"pull-paramap": "^1.1.6",
110+
"pull-paramap": "^1.2.1",
103111
"pull-pushable": "^2.0.1",
104112
"pull-sort": "^1.0.0",
105-
"pull-stream": "^3.4.5",
113+
"pull-stream": "^3.5.0",
106114
"pull-stream-to-stream": "^1.3.3",
107-
"pull-zip": "^2.0.0",
108-
"read-pkg-up": "^1.0.1",
109-
"run-parallel": "^1.1.6",
110-
"run-parallel-limit": "^1.0.3",
111-
"run-series": "^1.1.4",
112-
"run-waterfall": "^1.1.3",
113-
"stream-to-pull-stream": "^1.7.0",
115+
"pull-zip": "^2.0.1",
116+
"read-pkg-up": "^2.0.0",
117+
"readable-stream": "^1.1.14",
118+
"stream-to-pull-stream": "^1.7.2",
119+
"tar-stream": "^1.5.2",
114120
"temp": "^0.8.3",
115121
"through2": "^2.0.1",
116122
"update-notifier": "^1.0.2",
117-
"yargs": "^6.0.0"
123+
"yargs": "^6.3.0"
118124
},
119125
"contributors": [
120126
"Andrew de Andrade <andrew@deandrade.com.br>",

src/cli/commands/block/get.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
const utils = require('../../utils')
4-
const bs58 = require('bs58')
4+
const mh = require('multihashes')
55
const debug = require('debug')
66
const log = debug('cli:block')
77
log.error = debug('cli:block:error')
@@ -19,11 +19,11 @@ module.exports = {
1919
throw err
2020
}
2121

22-
const mh = utils.isDaemonOn()
22+
const hash = utils.isDaemonOn()
2323
? argv.key
24-
: new Buffer(bs58.decode(argv.key))
24+
: mh.fromB58String(argv.key)
2525

26-
ipfs.block.get(mh, (err, block) => {
26+
ipfs.block.get(hash, (err, block) => {
2727
if (err) {
2828
throw err
2929
}

src/cli/commands/block/put.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
'use strict'
22

33
const utils = require('../../utils')
4-
const bs58 = require('bs58')
4+
const mh = require('multihashes')
55
const bl = require('bl')
66
const fs = require('fs')
77
const Block = require('ipfs-block')
8+
const waterfall = require('async/waterfall')
89
const debug = require('debug')
910
const log = debug('cli:block')
1011
log.error = debug('cli:block:error')
@@ -15,14 +16,15 @@ function addBlock (buf) {
1516
throw err
1617
}
1718

18-
const block = new Block(buf)
19-
20-
ipfs.block.put(block, (err, block) => {
19+
waterfall([
20+
(cb) => ipfs.block.put(new Block(buf), cb),
21+
(block, cb) => block.key(cb)
22+
], (err, key) => {
2123
if (err) {
2224
throw err
2325
}
2426

25-
console.log(bs58.encode(block.key()).toString())
27+
console.log(mh.toB58String(key))
2628
})
2729
})
2830
}

src/cli/commands/block/rm.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
const utils = require('../../utils')
4-
const bs58 = require('bs58')
4+
const mh = require('multihashes')
55
const debug = require('debug')
66
const log = debug('cli:block')
77
log.error = debug('cli:block:error')
@@ -24,9 +24,7 @@ module.exports = {
2424
throw new Error('rm block with daemon running is not yet implemented')
2525
}
2626

27-
const mh = new Buffer(bs58.decode(argv.key))
28-
29-
ipfs.block.del(mh, (err) => {
27+
ipfs.block.del(mh.fromB58String(argv.key), (err) => {
3028
if (err) {
3129
throw err
3230
}

src/cli/commands/object/get.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict'
22

3+
const waterfall = require('async/waterfall')
34
const utils = require('../../utils')
45
const debug = require('debug')
56
const log = debug('cli:object')
@@ -13,24 +14,17 @@ module.exports = {
1314
builder: {},
1415

1516
handler (argv) {
16-
utils.getIPFS((err, ipfs) => {
17+
waterfall([
18+
(cb) => utils.getIPFS(cb),
19+
(ipfs, cb) => ipfs.object.get(argv.key, {enc: 'base58'}, cb),
20+
(node, cb) => node.toJSON(cb)
21+
], (err, nodeJson) => {
1722
if (err) {
1823
throw err
1924
}
2025

21-
ipfs.object.get(argv.key, {enc: 'base58'}, (err, node) => {
22-
if (err) {
23-
throw err
24-
}
25-
26-
node.toJSON((err, nodeJSON) => {
27-
if (err) {
28-
throw err
29-
}
30-
nodeJSON.Data = nodeJSON.Data ? nodeJSON.Data.toString() : ''
31-
console.log(JSON.stringify(nodeJSON))
32-
})
33-
})
26+
nodeJson.Data = nodeJson.Data ? nodeJson.Data.toString() : ''
27+
console.log(JSON.stringify(nodeJson))
3428
})
3529
}
3630
}

src/cli/commands/object/new.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict'
22

3+
const waterfall = require('async/waterfall')
34
const utils = require('../../utils')
45
const debug = require('debug')
56
const log = debug('cli:object')
@@ -13,23 +14,16 @@ module.exports = {
1314
builder: {},
1415

1516
handler (argv) {
16-
utils.getIPFS((err, ipfs) => {
17+
waterfall([
18+
(cb) => utils.getIPFS(cb),
19+
(ipfs, cb) => ipfs.object.new(cb),
20+
(node, cb) => node.toJSON(cb)
21+
], (err, node) => {
1722
if (err) {
1823
throw err
1924
}
2025

21-
ipfs.object.new((err, node) => {
22-
if (err) {
23-
throw err
24-
}
25-
26-
node.toJSON((err, nodeJSON) => {
27-
if (err) {
28-
throw err
29-
}
30-
console.log(nodeJSON.Hash)
31-
})
32-
})
26+
console.log(node.Hash)
3327
})
3428
}
3529
}

0 commit comments

Comments
 (0)