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

Awesome Async Crypto + Less magic to 'run in the browser' #485

Merged
merged 22 commits into from
Nov 12, 2016
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
26 changes: 8 additions & 18 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
'use strict'

const path = require('path')

module.exports = {
webpack: {
resolve: {
alias: {
'libp2p-ipfs': 'libp2p-ipfs-browser',
'node-forge': path.resolve(
path.dirname(require.resolve('libp2p-crypto')),
'../vendor/forge.bundle.js'
)
}
},
externals: {
mkdirp: '{}',
glob: '{}',
'simple-websocket-server': '{}'
}
karma: {
files: [{
pattern: 'node_modules/interface-ipfs-core/test/fixtures/**/*',
watched: false,
served: true,
included: false
}]
}
}
}
18 changes: 11 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
sudo: false
language: node_js
node_js:
- 4
- 5
- stable

matrix:
include:
- node_js: 4
env: CXX=g++-4.8
- node_js: 6
env:
- SAUCE=true
- CXX=g++-4.8
- node_js: stable
env: CXX=g++-4.8

# Make sure we have new NPM.
before_install:
Expand All @@ -22,9 +29,6 @@ before_script:
after_success:
- npm run coverage-publish

env:
- CXX=g++-4.8

addons:
firefox: 'latest'
apt:
Expand Down
1 change: 0 additions & 1 deletion QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o

This file was deleted.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
[![](https://img.shields.io/badge/pm-waffle-yellow.svg?style=flat-square)](https://waffle.io/ipfs/js-ipfs)
[![](https://img.shields.io/badge/interface--ipfs--core-API%20Docs-blue.svg)](https://github.com/ipfs/interface-ipfs-core)
[![](https://img.shields.io/badge/interface--ipfs--core-Updates-blue.svg)](https://github.com/ipfs/interface-ipfs-core/issues/55)
![](https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square)
![](https://img.shields.io/badge/Node.js-%3E%3D4.0.0-orange.svg?style=flat-square)

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

> IPFS JavaScript implementation.

Expand Down
3 changes: 2 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let nodes = []
function startNode (num, done) {
createTempNode(num, (err, node) => {
if (err) {
throw err
return done(err)
}

const api = new API(node.repo.path())
Expand All @@ -25,6 +25,7 @@ gulp.task('libnode:start', (done) => {
parallel([
(cb) => startNode(7, cb),
(cb) => startNode(8, cb),
(cb) => startNode(12, cb),
(cb) => startNode(13, cb)
], done)
})
Expand Down
94 changes: 50 additions & 44 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,31 @@
"bin": {
"jsipfs": "src/cli/bin.js"
},
"main": "lib/core/index.js",
"jsnext:main": "src/core/index.js",
"main": "src/core/index.js",
"browser": {
"libp2p-ipfs": "libp2p-ipfs-browser",
"./src/core/default-repo.js": "./src/core/default-repo-browser.js",
"./src/core/components/init-assets.js": false,
"./test/utils/temp-repo.js": "./test/utils/temp-repo-browser.js",
"stream": "readable-stream"
},
"engines": {
"node": ">=4.0.0",
"npm": ">=3.0.0"
},
"scripts": {
"lint": "aegir-lint",
"coverage": "gulp coverage",
"test": "PHANTOM=off gulp test",
"test": "gulp test",
"test:node": "gulp test:node",
"test:node:core": "TEST=core npm run test:node",
"test:node:http": "TEST=http npm run test:node",
"test:node:cli": "TEST=cli npm run test:node",
"test:browser": "PHANTOM=off gulp test:browser",
"test:browser": "gulp test:browser",
"build": "gulp build",
"release": "PHANTOM=off gulp release",
"release-minor": "PHANTOM=off gulp release --type minor",
"release-major": "PHANTOM=off gulp release --type major",
"release": "gulp release",
"release-minor": "gulp release --type minor",
"release-major": "gulp release --type major",
"coverage-publish": "aegir-coverage publish"
},
"pre-commit": [
Expand All @@ -40,17 +50,18 @@
},
"homepage": "https://github.com/ipfs/js-ipfs#readme",
"devDependencies": {
"aegir": "^8.1.2",
"aegir": "^9.1.1",
"buffer-loader": "0.0.1",
"chai": "^3.5.0",
"detect-node": "^2.0.3",
"execa": "^0.5.0",
"expose-loader": "^0.7.1",
"form-data": "^2.0.0",
"form-data": "^2.1.2",
"fs-pull-blob-store": "^0.4.1",
"gulp": "^3.9.1",
"interface-ipfs-core": "^0.16.6",
"left-pad": "^1.1.1",
"lodash": "^4.15.0",
"interface-ipfs-core": "^0.18.4",
"left-pad": "^1.1.3",
"lodash": "^4.16.6",
"ncp": "^2.0.0",
"nexpect": "^0.5.0",
"pre-commit": "^1.1.3",
Expand All @@ -59,62 +70,57 @@
"transform-loader": "^0.2.3"
},
"dependencies": {
"async": "^2.0.1",
"babel-runtime": "^6.11.6",
"async": "^2.1.2",
"bl": "^1.1.2",
"boom": "^4.0.0",
"bs58": "^3.0.0",
"debug": "^2.2.0",
"detect-node": "^2.0.3",
"boom": "^4.2.0",
"debug": "^2.3.2",
"fs-pull-blob-store": "^0.3.0",
"glob": "^7.0.6",
"glob": "^7.1.1",
"hapi": "^15.2.0",
"hapi-set-header": "^1.0.2",
"idb-pull-blob-store": "^0.5.1",
"ipfs-api": "^10.0.0",
"ipfs-bitswap": "^0.7.0",
"ipfs-block": "^0.4.0",
"ipfs-block-service": "^0.6.0",
"ipfs-api": "^11.1.0",
"ipfs-bitswap": "^0.8.1",
"ipfs-block": "^0.5.0",
"ipfs-block-service": "^0.7.0",
"ipfs-multipart": "^0.1.0",
"ipfs-repo": "^0.10.0",
"ipfs-unixfs": "^0.1.4",
"ipfs-unixfs-engine": "^0.12.0",
"ipld-resolver": "^0.1.1",
"ipfs-repo": "^0.11.1",
"ipfs-unixfs": "^0.1.5",
"ipfs-unixfs-engine": "^0.13.0",
"ipld-resolver": "^0.2.0",
"isstream": "^0.1.2",
"joi": "^9.0.4",
"libp2p-ipfs": "^0.14.1",
"libp2p-ipfs-browser": "^0.15.1",
"joi": "^9.2.0",
"libp2p-ipfs": "^0.15.0",
"libp2p-ipfs-browser": "^0.16.0",
"lodash.flatmap": "^4.5.0",
"lodash.get": "^4.4.2",
"lodash.has": "^4.5.2",
"lodash.set": "^4.3.2",
"lodash.sortby": "^4.7.0",
"lodash.values": "^4.3.0",
"mafmt": "^2.1.2",
"map-limit": "0.0.1",
"multiaddr": "^2.0.3",
"multihashes": "^0.2.2",
"path-exists": "^3.0.0",
"peer-book": "^0.3.0",
"peer-id": "^0.7.0",
"peer-info": "^0.7.1",
"promisify-es6": "^1.0.1",
"peer-id": "^0.8.0",
"peer-info": "^0.8.0",
"promisify-es6": "^1.0.2",
"pull-file": "^1.0.0",
"pull-paramap": "^1.1.6",
"pull-paramap": "^1.2.1",
"pull-pushable": "^2.0.1",
"pull-sort": "^1.0.0",
"pull-stream": "^3.4.5",
"pull-stream": "^3.5.0",
"pull-stream-to-stream": "^1.3.3",
"pull-zip": "^2.0.0",
"read-pkg-up": "^1.0.1",
"run-parallel": "^1.1.6",
"run-parallel-limit": "^1.0.3",
"run-series": "^1.1.4",
"run-waterfall": "^1.1.3",
"stream-to-pull-stream": "^1.7.0",
"pull-zip": "^2.0.1",
"read-pkg-up": "^2.0.0",
"readable-stream": "^1.1.14",
"stream-to-pull-stream": "^1.7.2",
"tar-stream": "^1.5.2",
"temp": "^0.8.3",
"through2": "^2.0.1",
"update-notifier": "^1.0.2",
"yargs": "^6.0.0"
"yargs": "^6.3.0"
},
"contributors": [
"Andrew de Andrade <[email protected]>",
Expand Down
8 changes: 4 additions & 4 deletions src/cli/commands/block/get.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const utils = require('../../utils')
const bs58 = require('bs58')
const mh = require('multihashes')
const debug = require('debug')
const log = debug('cli:block')
log.error = debug('cli:block:error')
Expand All @@ -19,11 +19,11 @@ module.exports = {
throw err
}

const mh = utils.isDaemonOn()
const hash = utils.isDaemonOn()
? argv.key
: new Buffer(bs58.decode(argv.key))
: mh.fromB58String(argv.key)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, does this still apply? we have standardised the block API

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, tests will fail otherwise


ipfs.block.get(mh, (err, block) => {
ipfs.block.get(hash, (err, block) => {
if (err) {
throw err
}
Expand Down
12 changes: 7 additions & 5 deletions src/cli/commands/block/put.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
'use strict'

const utils = require('../../utils')
const bs58 = require('bs58')
const mh = require('multihashes')
const bl = require('bl')
const fs = require('fs')
const Block = require('ipfs-block')
const waterfall = require('async/waterfall')
const debug = require('debug')
const log = debug('cli:block')
log.error = debug('cli:block:error')
Expand All @@ -15,14 +16,15 @@ function addBlock (buf) {
throw err
}

const block = new Block(buf)

ipfs.block.put(block, (err, block) => {
waterfall([
(cb) => ipfs.block.put(new Block(buf), cb),
(block, cb) => block.key(cb)
], (err, key) => {
if (err) {
throw err
}

console.log(bs58.encode(block.key()).toString())
console.log(mh.toB58String(key))
})
})
}
Expand Down
6 changes: 2 additions & 4 deletions src/cli/commands/block/rm.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

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

const mh = new Buffer(bs58.decode(argv.key))

ipfs.block.del(mh, (err) => {
ipfs.block.del(mh.fromB58String(argv.key), (err) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

block.del should support multihash as strings

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's exactly what I'm doing here, decoding the multihash from a string

if (err) {
throw err
}
Expand Down
22 changes: 8 additions & 14 deletions src/cli/commands/object/get.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

const waterfall = require('async/waterfall')
const utils = require('../../utils')
const debug = require('debug')
const log = debug('cli:object')
Expand All @@ -13,24 +14,17 @@ module.exports = {
builder: {},

handler (argv) {
utils.getIPFS((err, ipfs) => {
waterfall([
(cb) => utils.getIPFS(cb),
(ipfs, cb) => ipfs.object.get(argv.key, {enc: 'base58'}, cb),
(node, cb) => node.toJSON(cb)
], (err, nodeJson) => {
if (err) {
throw err
}

ipfs.object.get(argv.key, {enc: 'base58'}, (err, node) => {
if (err) {
throw err
}

node.toJSON((err, nodeJSON) => {
if (err) {
throw err
}
nodeJSON.Data = nodeJSON.Data ? nodeJSON.Data.toString() : ''
console.log(JSON.stringify(nodeJSON))
})
})
nodeJson.Data = nodeJson.Data ? nodeJson.Data.toString() : ''
console.log(JSON.stringify(nodeJson))
})
}
}
20 changes: 7 additions & 13 deletions src/cli/commands/object/new.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

const waterfall = require('async/waterfall')
const utils = require('../../utils')
const debug = require('debug')
const log = debug('cli:object')
Expand All @@ -13,23 +14,16 @@ module.exports = {
builder: {},

handler (argv) {
utils.getIPFS((err, ipfs) => {
waterfall([
(cb) => utils.getIPFS(cb),
(ipfs, cb) => ipfs.object.new(cb),
(node, cb) => node.toJSON(cb)
], (err, node) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/node/nodeJSON

if (err) {
throw err
}

ipfs.object.new((err, node) => {
if (err) {
throw err
}

node.toJSON((err, nodeJSON) => {
if (err) {
throw err
}
console.log(nodeJSON.Hash)
})
})
console.log(node.Hash)
})
}
}
Loading