diff --git a/README.md b/README.md index 5517a84f0e..9c24c327d5 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,13 @@

-### Project status +### Project status - `Alpha` We've come a long way, but this project is still in Alpha, lots of development is happening, API might change, beware of the Dragons 🐉.. **Want to get started?** Check our [examples folder](/examples) to learn how to spawn an IPFS node in Node.js and in the Browser. -You can check the development status at the [Waffle Board](https://waffle.io/ipfs/js-ipfs). +You can check the development status at the [Kanban Board](https://waffle.io/ipfs/js-ipfs). [![Throughput Graph](https://graphs.waffle.io/ipfs/js-ipfs/throughput.svg)](https://waffle.io/ipfs/js-ipfs/metrics/throughput) @@ -494,36 +494,35 @@ The core API is grouped into several areas: #### Files -- [files](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md) - - [`ipfs.files.add(data, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesadd). - - [`ipfs.files.addPullStream([options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesaddpullstream) - - [`ipfs.files.addReadableStream([options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesaddreadablestream) - - [`ipfs.files.cat(ipfsPath, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filescat). - - [`ipfs.files.catPullStream(ipfsPath, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filescatpullstream) - - [`ipfs.files.catReadableStream(ipfsPath, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filescatreadablestream) - - [`ipfs.files.get(ipfsPath, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesget). - - [`ipfs.files.getPullStream(ipfsPath, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesgetpullstream) - - [`ipfs.files.getReadableStream(ipfsPath, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesgetreadablestream) +- [Regular Files API](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md) + - [`ipfs.add(data, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#add) + - [`ipfs.addPullStream([options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#addpullstream) + - [`ipfs.addReadableStream([options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#addreadablestream) + - [`ipfs.addFromStream(stream, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#addfromstream) + - [`ipfs.addFromFs(path, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#addfromfs) + - [`ipfs.addFromUrl(url, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#addfromurl) + - [`ipfs.cat(ipfsPath, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#cat) + - [`ipfs.catPullStream(ipfsPath, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#catpullstream) + - [`ipfs.catReadableStream(ipfsPath, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#catreadablestream) + - [`ipfs.get(ipfsPath, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#get) + - [`ipfs.getPullStream(ipfsPath, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#getpullstream) + - [`ipfs.getReadableStream(ipfsPath, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#getreadablestream) - [`ipfs.ls(ipfsPath, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#ls) - [`ipfs.lsPullStream(ipfsPath)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#lspullstream) - [`ipfs.lsReadableStream(ipfsPath)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#lsreadablestream) - - [MFS (mutable file system) specific](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#mutable-file-system) - - [`ipfs.files.cp([from, to], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filescp) - - [`ipfs.files.flush([path], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesflush) - - [`ipfs.files.ls([path], [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesls) - - [`ipfs.files.mkdir(path, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesmkdir) - - [`ipfs.files.mv([from, to], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesmv) - - [`ipfs.files.read(path, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesread) - - [`ipfs.files.readPullStream(path, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesreadpullstream) - - [`ipfs.files.readReadableStream(path, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesreadreadablestream) - - [`ipfs.files.rm(path, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesrm) - - [`ipfs.files.stat(path, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesstat) - - [`ipfs.files.write(path, content, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#fileswrite) +- [MFS (mutable file system) specific](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#mutable-file-system) + - [`ipfs.files.cp([from, to], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filescp) + - [`ipfs.files.flush([path], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesflush) + - [`ipfs.files.ls([path], [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesls) + - [`ipfs.files.mkdir(path, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesmkdir) + - [`ipfs.files.mv([from, to], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesmv) + - [`ipfs.files.read(path, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesread) + - [`ipfs.files.readPullStream(path, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesreadpullstream) + - [`ipfs.files.readReadableStream(path, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesreadreadablestream) + - [`ipfs.files.rm(path, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesrm) + - [`ipfs.files.stat(path, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesstat) + - [`ipfs.files.write(path, content, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#fileswrite) -- [block](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/BLOCK.md) - - [`ipfs.block.get(cid, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/BLOCK.md#blockget) - - [`ipfs.block.put(block, cid, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/BLOCK.md#blockput) - - [`ipfs.block.stat(cid, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/BLOCK.md#blockstat) #### Graph @@ -532,7 +531,12 @@ The core API is grouped into several areas: - [`ipfs.dag.get(cid, [path], [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/DAG.md#dagget) - [`ipfs.dag.tree(cid, [path], [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/DAG.md#dagtree) -- [object](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/OBJECT.md) +- [pin](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PIN.md) + - [`ipfs.pin.add(hash, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PIN.md#pinadd) + - [`ipfs.pin.ls([hash], [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PIN.md#pinls) + - [`ipfs.pin.rm(hash, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PIN.md#pinrm) + +- [object (legacy)](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/OBJECT.md) - [`ipfs.object.new([template], [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/OBJECT.md#objectnew) - [`ipfs.object.put(obj, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/OBJECT.md#objectput) - [`ipfs.object.get(multihash, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/OBJECT.md#objectget) @@ -544,10 +548,15 @@ The core API is grouped into several areas: - [`ipfs.object.patch.appendData(multihash, data, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/OBJECT.md#objectpatchappenddata) - [`ipfs.object.patch.setData(multihash, data, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/OBJECT.md#objectpatchsetdata) -- [pin](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PIN.md) - - [`ipfs.pin.add(hash, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PIN.md#pinadd) - - [`ipfs.pin.ls([hash], [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PIN.md#pinls) - - [`ipfs.pin.rm(hash, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PIN.md#pinrm) +#### Block + +- [block](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/BLOCK.md) + - [`ipfs.block.get(cid, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/BLOCK.md#blockget) + - [`ipfs.block.put(block, cid, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/BLOCK.md#blockput) + - [`ipfs.block.stat(cid, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/BLOCK.md#blockstat) +- [bitswap](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/BITSWAP.md) + - [`ipfs.bitswap.wantlist([peerId], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BITSWAP.md#bitswapwantlist) + - [`ipfs.bitswap.stat([callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BITSWAP.md#bitswapstat) #### Name @@ -574,10 +583,6 @@ The core API is grouped into several areas: - [`ipfs.bootstrap.add(addr, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BOOTSTRAP.md#bootstrapadd) - [`ipfs.bootstrap.rm(peer, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BOOTSTRAP.md#bootstraprm) -- [bitswap](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/BITSWAP.md) - - [`ipfs.bitswap.wantlist([peerId], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BITSWAP.md#bitswapwantlist) - - [`ipfs.bitswap.stat([callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BITSWAP.md#bitswapstat) - - dht (not implemented yet) - [pubsub](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/PUBSUB.md) @@ -1007,10 +1012,10 @@ What does this image explain? IPFS implementation in JavaScript is a work in progress. As such, there's a few things you can do right now to help out: - * Go through the modules below and **check out existing issues**. This would be especially useful for modules in active development. Some knowledge of IPFS may be required, as well as the infrastructure behind it - for instance, you may need to read up on p2p and more complex operations like muxing to be able to help technically. - * **Perform code reviews**. More eyes will help (a) speed the project along, (b) ensure quality, and (c) reduce possible future bugs. - * Take a look at go-ipfs and some of the planning repositories or issues: for instance, the [libp2p spec](https://github.com/ipfs/specs/pull/19). Contributions here that would be most helpful are **top-level comments** about how it should look based on our understanding. Again, the more eyes the better. - * **Add tests**. There can never be enough tests. +- Go through the modules below and **check out existing issues**. This would be especially useful for modules in active development. Some knowledge of IPFS may be required, as well as the infrastructure behind it - for instance, you may need to read up on p2p and more complex operations like muxing to be able to help technically. +- **Perform code reviews**. More eyes will help (a) speed the project along, (b) ensure quality, and (c) reduce possible future bugs. +- Take a look at go-ipfs and some of the planning repositories or issues: for instance, the [libp2p spec](https://github.com/ipfs/specs/pull/19). Contributions here that would be most helpful are **top-level comments** about how it should look based on our understanding. Again, the more eyes the better. +- **Add tests**. There can never be enough tests. ### Want to hack on IPFS? diff --git a/package.json b/package.json index 288fb75911..4656f5a2f0 100644 --- a/package.json +++ b/package.json @@ -69,8 +69,8 @@ "execa": "^1.0.0", "form-data": "^2.3.3", "hat": "0.0.3", - "interface-ipfs-core": "~0.84.2", - "ipfsd-ctl": "~0.39.5", + "interface-ipfs-core": "~0.86.0", + "ipfsd-ctl": "ipfs/js-ipfsd-ctl#update-dag-pb-to-not-have-cid-property", "ncp": "^2.0.0", "qs": "^6.5.2", "rimraf": "^2.6.2", @@ -102,19 +102,19 @@ "hoek": "^5.0.4", "human-to-milliseconds": "^1.0.0", "interface-datastore": "~0.6.0", - "ipfs-api": "^26.1.0", + "ipfs-api": "ipfs/js-ipfs-api", "ipfs-bitswap": "~0.21.0", "ipfs-block": "~0.8.0", "ipfs-block-service": "~0.15.1", - "ipfs-http-response": "~0.2.0", - "ipfs-mfs": "~0.4.2", + "ipfs-http-response": "~0.2.1", + "ipfs-mfs": "~0.5.2", "ipfs-multipart": "~0.1.0", - "ipfs-repo": "~0.25.0", + "ipfs-repo": "0.25.0", "ipfs-unixfs": "~0.1.16", - "ipfs-unixfs-engine": "~0.33.0", - "ipld": "~0.19.3", + "ipfs-unixfs-engine": "~0.34.0", + "ipld": "~0.20.1", "ipld-bitcoin": "~0.1.8", - "ipld-dag-pb": "~0.14.11", + "ipld-dag-pb": "~0.15.0", "ipld-ethereum": "^2.0.1", "ipld-git": "~0.2.2", "ipld-zcash": "~0.1.6", diff --git a/src/cli/bin.js b/src/cli/bin.js index 49163d909e..401357ebf3 100755 --- a/src/cli/bin.js +++ b/src/cli/bin.js @@ -69,20 +69,9 @@ if (args[0] === 'daemon' || args[0] === 'init') { throw err } - // add mfs commands + // add MFS (Files API) commands mfs(cli) - // NOTE: This creates an alias of - // `jsipfs files {add, get, cat}` to `jsipfs {add, get, cat}`. - // This will stay until https://github.com/ipfs/specs/issues/98 is resolved. - const addCmd = require('./commands/files/add') - const catCmd = require('./commands/files/cat') - const getCmd = require('./commands/files/get') - const aliases = [addCmd, catCmd, getCmd] - aliases.forEach((alias) => { - cli.command(alias) - }) - cli .commandDir('commands') .help() diff --git a/src/cli/commands/files/add.js b/src/cli/commands/add.js similarity index 96% rename from src/cli/commands/files/add.js rename to src/cli/commands/add.js index 2ab492f27f..8b930434d6 100644 --- a/src/cli/commands/files/add.js +++ b/src/cli/commands/add.js @@ -11,9 +11,9 @@ const getFolderSize = require('get-folder-size') const byteman = require('byteman') const waterfall = require('async/waterfall') const mh = require('multihashes') -const utils = require('../../utils') -const print = require('../../utils').print -const createProgressBar = require('../../utils').createProgressBar +const utils = require('../utils') +const print = require('../utils').print +const createProgressBar = require('../utils').createProgressBar function checkPath (inPath, recursive) { // This function is to check for the following possible inputs @@ -231,7 +231,7 @@ module.exports = { } } - next(null, ipfs.files.addPullStream(options)) + next(null, ipfs.addPullStream(options)) } ], (err, addStream) => { if (err) throw err diff --git a/src/cli/commands/files/cat.js b/src/cli/commands/cat.js similarity index 91% rename from src/cli/commands/files/cat.js rename to src/cli/commands/cat.js index f68d6badfa..3a7548fea0 100644 --- a/src/cli/commands/files/cat.js +++ b/src/cli/commands/cat.js @@ -29,7 +29,7 @@ module.exports = { length: argv.length } - const stream = argv.ipfs.files.catReadableStream(path, options) + const stream = argv.ipfs.catReadableStream(path, options) stream.once('error', (err) => { throw err diff --git a/src/cli/commands/files/get.js b/src/cli/commands/get.js similarity index 94% rename from src/cli/commands/files/get.js rename to src/cli/commands/get.js index d9e0a39a67..1f571e175d 100644 --- a/src/cli/commands/files/get.js +++ b/src/cli/commands/get.js @@ -5,7 +5,7 @@ const path = require('path') const mkdirp = require('mkdirp') const pull = require('pull-stream') const toPull = require('stream-to-pull-stream') -const print = require('../../utils').print +const print = require('../utils').print function checkArgs (hash, outPath) { // format the output directory @@ -63,7 +63,7 @@ module.exports = { const dir = checkArgs(ipfsPath, argv.output) - const stream = argv.ipfs.files.getReadableStream(ipfsPath) + const stream = argv.ipfs.getReadableStream(ipfsPath) stream.once('error', (err) => { if (err) { throw err } diff --git a/src/cli/commands/object/get.js b/src/cli/commands/object/get.js index 80190d8d96..ccc4b466ab 100644 --- a/src/cli/commands/object/get.js +++ b/src/cli/commands/object/get.js @@ -1,6 +1,11 @@ 'use strict' const print = require('../../utils').print +const { + util: { + cid + } +} = require('ipld-dag-pb') module.exports = { command: 'get ', @@ -11,6 +16,10 @@ module.exports = { 'data-encoding': { type: 'string', default: 'base64' + }, + 'cid-base': { + default: 'base58btc', + describe: 'CID base to use.' } }, @@ -19,26 +28,33 @@ module.exports = { if (err) { throw err } - const nodeJSON = node.toJSON() - - if (Buffer.isBuffer(node.data)) { - nodeJSON.data = node.data.toString(argv['data-encoding'] || undefined) - } - - const answer = { - Data: nodeJSON.data, - Hash: nodeJSON.multihash, - Size: nodeJSON.size, - Links: nodeJSON.links.map((l) => { - return { - Name: l.name, - Size: l.size, - Hash: l.multihash - } - }) - } - print(JSON.stringify(answer)) + cid(node, (err, result) => { + if (err) { + throw err + } + + let data = node.data + + if (Buffer.isBuffer(data)) { + data = node.data.toString(argv.dataEncoding || undefined) + } + + const answer = { + Data: data, + Hash: result.toBaseEncodedString(argv.cidBase), + Size: node.size, + Links: node.links.map((l) => { + return { + Name: l.name, + Size: l.size, + Hash: l.cid.toBaseEncodedString(argv.cidBase) + } + }) + } + + print(JSON.stringify(answer)) + }) }) } } diff --git a/src/cli/commands/object/links.js b/src/cli/commands/object/links.js index d657820fb4..9a3a3e203e 100644 --- a/src/cli/commands/object/links.js +++ b/src/cli/commands/object/links.js @@ -7,7 +7,12 @@ module.exports = { describe: 'Outputs the links pointed to by the specified object', - builder: {}, + builder: { + 'cid-base': { + default: 'base58btc', + describe: 'CID base to use.' + } + }, handler (argv) { argv.ipfs.object.links(argv.key, { @@ -18,9 +23,7 @@ module.exports = { } links.forEach((link) => { - link = link.toJSON() - - print(`${link.multihash} ${link.size} ${link.name}`) + print(`${link.cid.toBaseEncodedString(argv.cidBase)} ${link.size} ${link.name}`) }) }) } diff --git a/src/cli/commands/object/new.js b/src/cli/commands/object/new.js index f96db85fb2..36ab5a3659 100644 --- a/src/cli/commands/object/new.js +++ b/src/cli/commands/object/new.js @@ -4,13 +4,23 @@ const debug = require('debug') const log = debug('cli:object') log.error = debug('cli:object:error') const print = require('../../utils').print +const { + util: { + cid + } +} = require('ipld-dag-pb') module.exports = { command: 'new [