diff --git a/CHANGELOG.md b/CHANGELOG.md index 159d27d01..87ac8177a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,83 @@ + +# [26.0.0](https://github.com/ipfs/js-ipfs-api/compare/v25.0.0...v26.0.0) (2018-10-30) + + +### Bug Fixes + +* add missing and remove unused dependencies ([#879](https://github.com/ipfs/js-ipfs-api/issues/879)) ([979d8b5](https://github.com/ipfs/js-ipfs-api/commit/979d8b5)) + + +### Chores + +* remove ipld formats re-export ([#872](https://github.com/ipfs/js-ipfs-api/issues/872)) ([c534375](https://github.com/ipfs/js-ipfs-api/commit/c534375)) +* update to ipld-dag-cbor 0.13 ([0652ac0](https://github.com/ipfs/js-ipfs-api/commit/0652ac0)) + + +### Features + +* ipns over pubsub ([#846](https://github.com/ipfs/js-ipfs-api/issues/846)) ([ef49e95](https://github.com/ipfs/js-ipfs-api/commit/ef49e95)) + + +### BREAKING CHANGES + +* dag-cbor nodes now represent links as CID objects + +The API for [dag-cbor](https://github.com/ipld/js-ipld-dag-cbor) changed. +Links are no longer represented as JSON objects (`{"/": "base-encoded-cid"}`, +but as [CID objects](https://github.com/ipld/js-cid). `ipfs.dag.get()` and +now always return links as CID objects. `ipfs.dag.put()` also expects links +to be represented as CID objects. The old-style JSON objects representation +is still supported, but deprecated. + +Prior to this change: + +```js +const cid = new CID('QmXed8RihWcWFXRRmfSRG9yFjEbXNxu1bDwgCFAN8Dxcq5') +// Link as JSON object representation +const putCid = await ipfs.dag.put({link: {'/': cid.toBaseEncodedString()}}) +const result = await ipfs.dag.get(putCid) +console.log(result.value) + +``` + +Output: + +```js +{ link: + { '/': + } } +``` + +Now: + +```js +const cid = new CID('QmXed8RihWcWFXRRmfSRG9yFjEbXNxu1bDwgCFAN8Dxcq5') +// Link as CID object +const putCid = await ipfs.dag.put({link: cid}) +const result = await ipfs.dag.get(putCid) +console.log(result.value) +``` + +Output: + +```js +{ link: + CID { + codec: 'dag-pb', + version: 0, + multihash: + } } +``` + +See https://github.com/ipld/ipld/issues/44 for more information on why this +change was made. +* remove `types.dagCBOR` and `types.dagPB` from public API + +If you need the `ipld-dag-cbor` or `ipld-dag-pb` module in the Browser, +you need to bundle them yourself. + + + # [25.0.0](https://github.com/ipfs/js-ipfs-api/compare/v24.0.2...v25.0.0) (2018-10-15) diff --git a/README.md b/README.md index 914f9aac6..b50218380 100644 --- a/README.md +++ b/README.md @@ -277,6 +277,9 @@ const ipfs = IpfsApi({ - [name](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/NAME.md) - [`ipfs.name.publish(addr, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/NAME.md#namepublish) + - [`ipfs.name.pubsub.cancel(arg, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/NAME.md#namepubsubcancel) + - [`ipfs.name.pubsub.state([callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/NAME.md#namepubsubstate) + - [`ipfs.name.pubsub.subs([callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/NAME.md#namepubsubsubs) - [`ipfs.name.resolve(addr, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/NAME.md#nameresolve) #### Node Management diff --git a/package.json b/package.json index 77ec25ef2..4a6e79c40 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ipfs-api", - "version": "25.0.0", + "version": "26.0.0", "description": "A client library for the IPFS HTTP API", "leadMaintainer": "Alan Shaw ", "main": "src/index.js", @@ -23,47 +23,50 @@ "release-minor": "aegir release --type minor ", "release-major": "aegir release --type major ", "coverage": "aegir coverage --timeout 100000", - "coverage-publish": "aegir coverage --provider coveralls --timeout 100000" + "coverage-publish": "aegir coverage --provider coveralls --timeout 100000", + "dep-check": "npx dependency-check package.json './test/**/*.js' './src/**/*.js'" }, "dependencies": { "async": "^2.6.1", - "big.js": "^5.1.2", - "bl": "^2.0.1", + "big.js": "^5.2.2", + "bl": "^2.1.2", "bs58": "^4.0.1", - "cids": "~0.5.3", + "cids": "~0.5.5", "concat-stream": "^1.6.2", - "debug": "^3.1.0", - "detect-node": "^2.0.3", + "debug": "^4.1.0", + "detect-node": "^2.0.4", + "end-of-stream": "^1.4.1", "flatmap": "0.0.3", - "glob": "^7.1.2", - "ipfs-block": "~0.7.1", - "ipfs-unixfs": "~0.1.15", - "ipld-dag-cbor": "~0.12.1", - "ipld-dag-pb": "~0.14.6", - "is-ipfs": "~0.4.2", + "glob": "^7.1.3", + "ipfs-block": "~0.8.0", + "ipfs-unixfs": "~0.1.16", + "ipld-dag-cbor": "~0.13.0", + "ipld-dag-pb": "~0.14.11", + "is-ipfs": "~0.4.7", "is-pull-stream": "0.0.0", "is-stream": "^1.1.0", - "libp2p-crypto": "~0.13.0", + "libp2p-crypto": "~0.14.0", "lodash": "^4.17.11", "lru-cache": "^4.1.3", "multiaddr": "^5.0.0", - "multibase": "~0.4.0", - "multihashes": "~0.4.13", + "multibase": "~0.5.0", + "multihashes": "~0.4.14", "ndjson": "^1.5.0", "once": "^1.4.0", - "peer-id": "~0.11.0", + "peer-id": "~0.12.0", "peer-info": "~0.14.1", "promisify-es6": "^1.0.3", - "pull-defer": "~0.2.2", + "pull-defer": "~0.2.3", "pull-pushable": "^2.2.0", "pull-stream-to-stream": "^1.3.4", "pump": "^3.0.0", "qs": "^6.5.2", - "readable-stream": "^2.3.6", + "readable-stream": "^3.0.6", "stream-http": "^3.0.0", "stream-to-pull-stream": "^1.7.2", "streamifier": "~0.1.1", - "tar-stream": "^1.6.1" + "tar-stream": "^1.6.2", + "through2": "^2.0.3" }, "engines": { "node": ">=8.0.0", @@ -74,19 +77,17 @@ "url": "https://github.com/ipfs/js-ipfs-api" }, "devDependencies": { - "aegir": "^15.1.0", + "aegir": "^17.0.1", "browser-process-platform": "~0.1.1", - "chai": "^4.1.2", + "chai": "^4.2.0", "cross-env": "^5.2.0", "dirty-chai": "^2.0.1", - "eslint-plugin-react": "^7.10.0", + "eslint-plugin-react": "^7.11.1", "go-ipfs-dep": "~0.4.17", "gulp": "^3.9.1", - "interface-ipfs-core": "~0.78.0", - "ipfsd-ctl": "~0.39.0", - "pull-stream": "^3.6.8", - "socket.io": "^2.1.1", - "socket.io-client": "^2.1.1", + "interface-ipfs-core": "~0.83.0", + "ipfsd-ctl": "~0.39.5", + "pull-stream": "^3.6.9", "stream-equal": "^1.1.1" }, "keywords": [ @@ -119,6 +120,7 @@ "Harlan T Wood ", "Henrique Dias ", "Holodisc ", + "Hugo Dias ", "JGAntunes ", "Jacob Heun ", "James Halliday ", @@ -154,8 +156,8 @@ "Tara Vancil ", "Travis Person ", "Travis Person ", - "Vasco Santos ", "Vasco Santos ", + "Vasco Santos ", "Victor Bjelkholm ", "Volker Mische ", "dmitriy ryajov ", diff --git a/src/name/index.js b/src/name/index.js index 811357b7c..8f823311a 100644 --- a/src/name/index.js +++ b/src/name/index.js @@ -7,6 +7,7 @@ module.exports = (arg) => { return { publish: require('./publish')(send), - resolve: require('./resolve')(send) + resolve: require('./resolve')(send), + pubsub: require('./pubsub')(send) } } diff --git a/src/name/pubsub/cancel.js b/src/name/pubsub/cancel.js new file mode 100644 index 000000000..32dbbb3af --- /dev/null +++ b/src/name/pubsub/cancel.js @@ -0,0 +1,24 @@ +'use strict' + +const promisify = require('promisify-es6') + +const transform = function (res, callback) { + callback(null, { + canceled: res.Canceled === undefined || res.Canceled === true + }) +} + +module.exports = (send) => { + return promisify((args, opts, callback) => { + if (typeof (opts) === 'function') { + callback = opts + opts = {} + } + + send.andTransform({ + path: 'name/pubsub/cancel', + args: args, + qs: opts + }, transform, callback) + }) +} diff --git a/src/name/pubsub/index.js b/src/name/pubsub/index.js new file mode 100644 index 000000000..aefc0f880 --- /dev/null +++ b/src/name/pubsub/index.js @@ -0,0 +1,7 @@ +'use strict' + +module.exports = (send) => ({ + cancel: require('./cancel')(send), + state: require('./state')(send), + subs: require('./subs')(send) +}) diff --git a/src/name/pubsub/state.js b/src/name/pubsub/state.js new file mode 100644 index 000000000..cc9b0b369 --- /dev/null +++ b/src/name/pubsub/state.js @@ -0,0 +1,23 @@ +'use strict' + +const promisify = require('promisify-es6') + +const transform = function (res, callback) { + callback(null, { + enabled: res.Enabled + }) +} + +module.exports = (send) => { + return promisify((opts, callback) => { + if (typeof (opts) === 'function') { + callback = opts + opts = {} + } + + send.andTransform({ + path: 'name/pubsub/state', + qs: opts + }, transform, callback) + }) +} diff --git a/src/name/pubsub/subs.js b/src/name/pubsub/subs.js new file mode 100644 index 000000000..3a3a54c2a --- /dev/null +++ b/src/name/pubsub/subs.js @@ -0,0 +1,21 @@ +'use strict' + +const promisify = require('promisify-es6') + +const transform = function (res, callback) { + callback(null, res.Strings || []) +} + +module.exports = (send) => { + return promisify((opts, callback) => { + if (typeof (opts) === 'function') { + callback = opts + opts = {} + } + + send.andTransform({ + path: 'name/pubsub/subs', + qs: opts + }, transform, callback) + }) +} diff --git a/src/types.js b/src/types.js index a6ae650c4..39c80c50b 100644 --- a/src/types.js +++ b/src/types.js @@ -1,8 +1,6 @@ 'use strict' const CID = require('cids') -const dagCBOR = require('ipld-dag-cbor') -const dagPB = require('ipld-dag-pb') const multiaddr = require('multiaddr') const multibase = require('multibase') const multihash = require('multihashes') @@ -12,8 +10,6 @@ const PeerInfo = require('peer-info') module.exports = () => ({ Buffer: Buffer, CID: CID, - dagPB: dagPB, - dagCBOR: dagCBOR, multiaddr: multiaddr, multibase: multibase, multihash: multihash, diff --git a/test/interface.spec.js b/test/interface.spec.js index 30fe04a92..04e1dd303 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -183,6 +183,27 @@ describe('interface-ipfs-core tests', () => { ] }) + // TODO: uncomment after https://github.com/ipfs/interface-ipfs-core/pull/361 being merged and a new release + tests.namePubsub(CommonFactory.create({ + spawnOptions: { + args: ['--enable-namesys-pubsub'], + initOptions: { bits: 1024 } + } + }), { + skip: [ + // name.pubsub.cancel + { + name: 'should cancel a subscription correctly returning true', + reason: 'go-ipfs is really slow for publishing and resolving ipns records, unless in offline mode' + }, + // name.pubsub.subs + { + name: 'should get the list of subscriptions updated after a resolve', + reason: 'go-ipfs is really slow for publishing and resolving ipns records, unless in offline mode' + } + ] + }) + tests.object(defaultCommonFactory) tests.pin(defaultCommonFactory) diff --git a/test/types.spec.js b/test/types.spec.js index 49b68a5ef..b27adf6da 100644 --- a/test/types.spec.js +++ b/test/types.spec.js @@ -3,8 +3,6 @@ const PeerId = require('peer-id') const PeerInfo = require('peer-info') -const dagCBOR = require('ipld-dag-cbor') -const dagPB = require('ipld-dag-pb') const multiaddr = require('multiaddr') const multibase = require('multibase') const multihash = require('multihashes') @@ -47,9 +45,7 @@ describe('.types', function () { multiaddr: multiaddr, multibase: multibase, multihash: multihash, - CID: CID, - dagPB: dagPB, - dagCBOR: dagCBOR + CID: CID }) }) })