diff --git a/.aegir.js b/.aegir.js
index 6effabad0..793c4eb13 100644
--- a/.aegir.js
+++ b/.aegir.js
@@ -1,11 +1,19 @@
'use strict'
const createServer = require('ipfsd-ctl').createServer
-
-const server = createServer()
+const EchoServer = require('interface-ipfs-core/src/utils/echo-http-server')
+const server = createServer({
+ host: '127.0.0.1',
+ port: 43134
+}, {
+ type: 'go',
+ ipfsHttpModule: require('./'),
+ ipfsBin: require('go-ipfs-dep').path()
+})
+const echoServer = EchoServer.createServer()
module.exports = {
- bundlesize: { maxSize: '231kB' },
+ bundlesize: { maxSize: '90kB' },
webpack: {
resolve: {
mainFields: ['browser', 'main']
@@ -22,7 +30,23 @@ module.exports = {
singleRun: true
},
hooks: {
- pre: server.start.bind(server),
- post: server.stop.bind(server)
+ node: {
+ pre: () => echoServer.start(),
+ post: () => echoServer.stop()
+ },
+ browser: {
+ pre: () => {
+ return Promise.all([
+ server.start(),
+ echoServer.start()
+ ])
+ },
+ post: () => {
+ return Promise.all([
+ server.stop(),
+ echoServer.stop()
+ ])
+ }
+ }
}
}
diff --git a/.eslintignore b/.eslintignore
deleted file mode 100644
index 499b34048..000000000
--- a/.eslintignore
+++ /dev/null
@@ -1 +0,0 @@
-test/test-folder/ipfs-add.js
\ No newline at end of file
diff --git a/.npmignore b/.npmignore
deleted file mode 100644
index e20403d47..000000000
--- a/.npmignore
+++ /dev/null
@@ -1,5 +0,0 @@
-node_modules
-*.log
-coverage
-.nyc_output
-test
diff --git a/.travis.yml b/.travis.yml
index 912ef7ac7..0509e5a96 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,44 +1,71 @@
language: node_js
cache: npm
+
+branches:
+ only:
+ - master
+ - /^release\/.*$/
+
stages:
- check
- test
- cov
node_js:
+ - '12'
- '10'
os:
- linux
- osx
+ - windows
script: npx nyc -s npm run test:node -- --bail
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov
jobs:
include:
- - os: windows
- filter_secrets: false
- cache: false
-
- stage: check
script:
- npx aegir build --bundlesize
- - npx aegir commitlint --travis
- - npx aegir dep-check
+ - npx aegir dependency-check
- npm run lint
- stage: test
name: chrome
addons:
chrome: stable
- script: npx aegir test -t browser -t webworker
+ script: npx aegir test -t browser
+
+ - stage: test
+ name: chrome webworker
+ addons:
+ chrome: stable
+ script: npx aegir test -t webworker
- stage: test
name: firefox
addons:
firefox: latest
- script: npx aegir test -t browser -t webworker -- --browsers FirefoxHeadless
+ script: npx aegir test -t browser -- --browsers FirefoxHeadless
+
+ - stage: test
+ name: firefox webworker
+ addons:
+ firefox: latest
+ script: npx aegir test -t webworker -- --browsers FirefoxHeadless
+
+ - stage: test
+ name: electron-main
+ os: osx
+ script:
+ - npx aegir test -t electron-main --bail
+
+ - stage: test
+ name: electron-renderer
+ os: osx
+ script:
+ - npx aegir test -t electron-renderer --bail
notifications:
email: false
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 04ae6cefa..a40976f0b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,575 @@
+
+# [42.0.0](https://github.com/ipfs/js-ipfs-http-client/compare/v42.0.0-pre.2...v42.0.0) (2020-02-04)
+
+There are significant and breaking API changes in this release. Please see the [migration guide](https://gist.github.com/alanshaw/04b2ddc35a6fff25c040c011ac6acf26).
+
+### Bug Fixes
+
+* interface tests ([#1233](https://github.com/ipfs/js-ipfs-http-client/issues/1233)) ([d3eee0d](https://github.com/ipfs/js-ipfs-http-client/commit/d3eee0d))
+
+### Features
+
+* `add` results now include `mode` and `mtime` properties if they were set.
+
+* `files.chmod` has been added. See the [core interface docs](https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#fileschmod) for info.
+
+* `files.flush` now returns the root CID for the path that was flushed (`/` by default)
+
+* `files.ls` results now include `mode` and `mtime` properties if they were set. See the [core interface docs](https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#ls) for more info.
+
+* `files.mkdir` now accepts `mode` and `mtime` options to allow setting mode and mtime metadata. See the [core interface docs](https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#filesmkdir) for more info.
+
+* `files.stat` result now includes `mode` and `mtime` properties if they were set. See the [core interface docs](https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#filesstat) for more info.
+
+* `files.touch` has been added. See the [core interface docs](https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#filestouch) for info.
+
+* `files.write` now accepts `mode` and `mtime` options to allow setting mode and mtime metadata. See the [core interface docs](https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#fileswrite) for more info.
+
+* `object.get` now accepts a `timeout` option. It will cause the method to throw with a `TimeoutError` if no data is received within the timeout window. It can be passed as a `number` or a `string`. If a `number` is passed it is interpreted as milliseconds, if a string is passed it is interpreted as a [human readable duration](https://www.npmjs.com/package/parse-duration).
+
+* `pin.add` now accepts a `timeout` option. It will cause the method to throw with a `TimeoutError` if no data is received within the timeout window. It can be passed as a `number` or a `string`. If a `number` is passed it is interpreted as milliseconds, if a string is passed it is interpreted as a [human readable duration](https://www.npmjs.com/package/parse-duration).
+
+* `refs` now accepts a `timeout` option. It will cause the method to throw with a `TimeoutError` if no data is received within the timeout window. It can be passed as a `number` or a `string`. If a `number` is passed it is interpreted as milliseconds, if a string is passed it is interpreted as a [human readable duration](https://www.npmjs.com/package/parse-duration).
+
+### BREAKING CHANGES
+
+* Callbacks are no longer supported on any API methods. Please use a utility such as [`callbackify`](https://www.npmjs.com/package/callbackify) on API methods that return Promises to emulate previous behaviour. See the [migration guide](https://gist.github.com/alanshaw/04b2ddc35a6fff25c040c011ac6acf26#migrating-from-callbacks) for more info.
+
+* `add` now returns an async iterable.
+
+* `add` now accepts `mode` and `mtime` options on inputs to allow setting mode and mtime metadata for added files. See the [core interface docs](https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#add) for more info.
+
+* `add` results now contain a `cid` property (a [CID instance](https://github.com/multiformats/js-cid)) instead of a string `hash` property.
+
+* `addReadableStream`, `addPullStream` have been removed. Please see the [migration guide](https://gist.github.com/alanshaw/04b2ddc35a6fff25c040c011ac6acf26#migrating-to-async-iterables) for more info.
+
+* `addFromStream` has been removed. Use `add` instead.
+
+* `addFromFs` has been removed. Please use the exported `globSource` utility and pass the result to `add`. See the [glob source documentation](https://github.com/ipfs/js-ipfs-http-client#glob-source) for more details and an example.
+
+* `addFromURL` has been removed. Please use the exported `urlSource` utility and pass the result to `add`. See the [URL source documentation](https://github.com/ipfs/js-ipfs-http-client#url-source) for more details and an example.
+
+* `bitswap.stat` result has changed - `wantlist` and values are now an array of [CID](https://github.com/multiformats/js-cid) instances and `peers` is now a `string[]` of peer IDs.
+
+* `bitswap.wantlist` now returns an array of [CID](https://github.com/multiformats/js-cid) instances.
+
+* `block.rm` now returns an async iterable.
+
+* `block.rm` now yields objects of `{ cid: CID, error: Error }`.
+
+* `block.stat` result now contains a `cid` property (whose value is a [CID instance](https://github.com/multiformats/js-cid)) instead of a `key` property.
+
+* `dht.findProvs`, `dht.provide`, `dht.put` and `dht.query` now all return an async iterable.
+
+* `dht.findPeer`, `dht.findProvs`, `dht.provide`, `dht.put` and `dht.query` now yield/return an object `{ id: string, addrs: Multiaddr[] }` instead of a `PeerInfo` instance(s).
+
+* `files.lsPullStream` and `files.lsReadableStream` have been removed. Please see the [migration guide](https://gist.github.com/alanshaw/04b2ddc35a6fff25c040c011ac6acf26#migrating-to-async-iterables) for more info.
+
+* `files.ls` now returns an async iterable.
+
+* `files.ls` results now contain a `cid` property (whose value is a [CID instance](https://github.com/multiformats/js-cid)) instead of a `hash` property.
+
+* `files.ls` no longer takes a `long` option (in core) - you will receive all data by default.
+
+* `files.readPullStream` and `files.readReadableStream` have been removed. Please see the [migration guide](https://gist.github.com/alanshaw/04b2ddc35a6fff25c040c011ac6acf26#migrating-to-async-iterables) for more info.
+
+* `files.read` now returns an async iterable.
+
+* `files.stat` result now contains a `cid` property (whose value is a [CID instance](https://github.com/multiformats/js-cid)) instead of a `hash` property.
+
+* `get` now returns an async iterable. The `content` property value for objects yielded from the iterator is now an async iterable that yields [`BufferList`](https://github.com/rvagg/bl) objects.
+
+* `id` result has changed, the `addresses` property is now a `Multiaddr[]`
+
+* `name.resolve` now returns an async iterable. It yields increasingly more accurate resolved values as they are discovered until the best value is selected from the quorum of 16. The "best" resolved value is the last item yielded from the iterator. If you are interested only in this best value you could use `it-last` to extract it like so:
+
+ ```js
+ const last = require('it-last')
+ await last(ipfs.name.resolve('/ipns/QmHash'))
+ ```
+
+* `ls` now returns an async iterable.
+
+* `ls` results now contain a `cid` property (whose value is a [CID instance](https://github.com/multiformats/js-cid)) instead of a `hash` property.
+
+* `ls` results now include `mode` and `mtime` properties if they were set. See the [core interface docs](https://github.com/ipfs/interface-js-ipfs-core/blob/master/SPEC/FILES.md#ls) for more info.
+
+* `pin.add` results now contain a `cid` property (a [CID instance](https://github.com/multiformats/js-cid)) instead of a string `hash` property.
+
+* `pin.ls` now returns an async iterable.
+
+* `pin.ls` results now contain a `cid` property (a [CID instance](https://github.com/multiformats/js-cid)) instead of a string `hash` property.
+
+* `pin.rm` results now contain a `cid` property (a [CID instance](https://github.com/multiformats/js-cid)) instead of a string `hash` property.
+
+* `ping` now returns an async iterable.
+
+* `refs` and `refs.local` now return an async iterable.
+
+* `repo.gc` now returns an async iterable.
+
+* `stats.bw` now returns an async iterable.
+
+* `swarm.peers` now returns an array of objects with a `peer` property that is a `string`, instead of a `PeerId` instance.
+
+* `swarm.addrs` now returns an array of objects `{ id: string, addrs: Multiaddr[] }` instead of `PeerInfo` instances.
+
+* The protocol _name_ for peer IDs in multiaddrs has changed from 'ipfs' to 'p2p'. There's no changes to data on the wire but this change is seen when multiaddrs are converted to strings.
+
+
+
+
+# [42.0.0-pre.0](https://github.com/ipfs/js-ipfs-http-client/compare/v41.0.1...v42.0.0-pre.0) (2020-01-23)
+
+
+
+
+## [41.0.1](https://github.com/ipfs/js-ipfs-http-client/compare/v41.0.0...v41.0.1) (2020-01-23)
+
+
+
+
+# [41.0.0](https://github.com/ipfs/js-ipfs-http-client/compare/v40.2.1...v41.0.0) (2020-01-12)
+
+
+### Bug Fixes
+
+* return CIDs from files.flush ([#1216](https://github.com/ipfs/js-ipfs-http-client/issues/1216)) ([13f8d7a](https://github.com/ipfs/js-ipfs-http-client/commit/13f8d7a))
+
+
+### Code Refactoring
+
+* removes format option ([#1218](https://github.com/ipfs/js-ipfs-http-client/issues/1218)) ([4ef26cd](https://github.com/ipfs/js-ipfs-http-client/commit/4ef26cd))
+
+
+### BREAKING CHANGES
+
+* `format` option is no longer supported as everything is `dag-pb` all
+of the time.
+
+Follows on from https://github.com/ipfs/js-ipfs-mfs/pull/69
+
+
+
+
+## [40.2.1](https://github.com/ipfs/js-ipfs-http-client/compare/v40.2.0...v40.2.1) (2020-01-09)
+
+
+
+
+# [40.2.0](https://github.com/ipfs/js-ipfs-http-client/compare/v40.1.0...v40.2.0) (2020-01-09)
+
+
+### Features
+
+* support UnixFSv1.5 metadata ([#1186](https://github.com/ipfs/js-ipfs-http-client/issues/1186)) ([da9d17a](https://github.com/ipfs/js-ipfs-http-client/commit/da9d17a))
+
+
+
+
+# [40.1.0](https://github.com/ipfs/js-ipfs-http-client/compare/v40.0.1...v40.1.0) (2019-12-10)
+
+
+### Features
+
+* expose import concurrency controls ([#1187](https://github.com/ipfs/js-ipfs-http-client/issues/1187)) ([47093d5](https://github.com/ipfs/js-ipfs-http-client/commit/47093d5))
+
+
+
+
+## [40.0.1](https://github.com/ipfs/js-ipfs-http-client/compare/v40.0.0...v40.0.1) (2019-11-27)
+
+
+### Bug Fixes
+
+* pin ls with multiple CIDs ([#1184](https://github.com/ipfs/js-ipfs-http-client/issues/1184)) ([2f3763f](https://github.com/ipfs/js-ipfs-http-client/commit/2f3763f))
+
+
+
+
+# [40.0.0](https://github.com/ipfs/js-ipfs-http-client/compare/v39.0.2...v40.0.0) (2019-11-22)
+
+
+### Code Refactoring
+
+* async await roundup ([#1173](https://github.com/ipfs/js-ipfs-http-client/issues/1173)) ([3e5967a](https://github.com/ipfs/js-ipfs-http-client/commit/3e5967a)), closes [#1103](https://github.com/ipfs/js-ipfs-http-client/issues/1103)
+* convert config API to async await ([#1155](https://github.com/ipfs/js-ipfs-http-client/issues/1155)) ([621973c](https://github.com/ipfs/js-ipfs-http-client/commit/621973c))
+* move files to root level ([#1150](https://github.com/ipfs/js-ipfs-http-client/issues/1150)) ([559a97d](https://github.com/ipfs/js-ipfs-http-client/commit/559a97d))
+
+
+### Features
+
+* support name.resolve of peerid as cid ([#1145](https://github.com/ipfs/js-ipfs-http-client/issues/1145)) ([2d9afc8](https://github.com/ipfs/js-ipfs-http-client/commit/2d9afc8))
+
+
+### Reverts
+
+* chore: update multiaddr to version 7.2.0 ([#1136](https://github.com/ipfs/js-ipfs-http-client/issues/1136)) ([#1143](https://github.com/ipfs/js-ipfs-http-client/issues/1143)) ([4131d09](https://github.com/ipfs/js-ipfs-http-client/commit/4131d09))
+
+
+### BREAKING CHANGES
+
+* The `log.tail` method now returns an async iterator that yields log messages. Use it like:
+ ```js
+ for await (const message of ipfs.log.tail()) {
+ console.log(message)
+ }
+ ```
+* The response to a call to `log.level` now returns an object that has camel cased keys. i.e. `Message` and `Error` properties have changed to `message` and `error`.
+* Dropped support for go-ipfs <= 0.4.4 in `swarm.peers` response.
+* The signature for `ipfs.mount` has changed from `ipfs.mount([ipfsPath], [ipnsPath])` to `ipfs.mount([options])`. Where `options` is an optional object that may contain two boolean properties `ipfsPath` and `ipnsPath`. The response object has also changed to be camel case. See https://docs.ipfs.io/reference/api/http/#api-v0-mount.
+* Default ping `count` of 1 in client has been removed. The default ping count is now whatever the IPFS node defaults it to (currently 10). If you specifically need 1 ping message then please pass `count: 1` in options for `ipfs.ping()`.
+* Multi parameter constructor options are no longer supported. To create a new IPFS HTTP client, pass a single parameter to the constructor. The parameter can be one of:
+ * String, formatted as one of:
+ * Multiaddr e.g. /ip4/127.0.0.1/tcp/5001
+ * URL e.g. http://127.0.0.1:5001
+ * [Multiaddr](https://www.npmjs.com/package/multiaddr) instance
+ * Object, in format of either:
+ * Address and path e.g. `{ apiAddr: '/ip4/127.0.0.1/tcp/5001': apiPath: '/api/v0' }` (Note: `apiAddr` can also be a string in URL form or a Multiaddr instance)
+ * Node.js style address e.g. `{ host: '127.0.0.1', port: 5001, protocol: 'http' }`
+* Errors returned from request failures are now all [`HTTPError`](https://github.com/sindresorhus/ky/blob/c0d9d2bb07e4c122a08f019b39e9c55a4c9324f3/index.js#L117-L123)s which carry a `response` property. This is a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) that can be used to inspect _all_ information relating to the HTTP response. This means that the `err.status` or `err.statusCode` property should now be accessed via `err.response.status`.
+* files in `src/files-regular` have moved to `src`. The `src/files-mfs` directory has been renamed to `src/files`. If you were previously requiring files from these directories e.g. `require('ipfs-http-client/src/files-regular/add')` then please be aware that they have moved.
+* Kebab case options are no longer supported. Please use camel case option names as defined in the [`interface-ipfs-core`](https://github.com/ipfs/interface-js-ipfs-core/tree/master/SPEC) docs. e.g. the `allow-offline` option to `name.publish` should be passed as `allowOffline`.
+ * Note that you can pass [additional query string parameters](https://github.com/ipfs/js-ipfs-http-client#additional-options) in the `searchParams` option available to all API methods.
+
+
+
+
+## [39.0.2](https://github.com/ipfs/js-ipfs-http-client/compare/v39.0.1...v39.0.2) (2019-10-23)
+
+
+### Bug Fixes
+
+* use non-strict equivalence for options.preload ([#1134](https://github.com/ipfs/js-ipfs-http-client/issues/1134)) ([432e1e8](https://github.com/ipfs/js-ipfs-http-client/commit/432e1e8))
+
+
+
+
+## [39.0.1](https://github.com/ipfs/js-ipfs-http-client/compare/v39.0.0...v39.0.1) (2019-10-21)
+
+
+### Bug Fixes
+
+* expose preload argument ([#1129](https://github.com/ipfs/js-ipfs-http-client/issues/1129)) ([c82b031](https://github.com/ipfs/js-ipfs-http-client/commit/c82b031))
+* increase default timeout and respect value passed to `ky.extend` ([#1130](https://github.com/ipfs/js-ipfs-http-client/issues/1130)) ([25b6043](https://github.com/ipfs/js-ipfs-http-client/commit/25b6043))
+
+
+
+
+# [39.0.0](https://github.com/ipfs/js-ipfs-http-client/compare/v38.2.0...v39.0.0) (2019-10-15)
+
+
+
+
+# [38.2.0](https://github.com/ipfs/js-ipfs-http-client/compare/v38.1.0...v38.2.0) (2019-10-06)
+
+
+### Features
+
+* adds ipfs.block.rm method ([#1123](https://github.com/ipfs/js-ipfs-http-client/issues/1123)) ([2f0eff7](https://github.com/ipfs/js-ipfs-http-client/commit/2f0eff7))
+
+
+
+
+# [38.1.0](https://github.com/ipfs/js-ipfs-http-client/compare/v38.0.1...v38.1.0) (2019-10-04)
+
+
+### Bug Fixes
+
+* get correct remote node config ([5b53e22](https://github.com/ipfs/js-ipfs-http-client/commit/5b53e22))
+* pull in preconfigured chai from interface tests ([93765c1](https://github.com/ipfs/js-ipfs-http-client/commit/93765c1))
+
+
+### Features
+
+* add methods for listing config profiles ([1c3d92a](https://github.com/ipfs/js-ipfs-http-client/commit/1c3d92a))
+
+
+### BREAKING CHANGES
+
+* Configuration profiles API has changed:
+ ```javascript
+ Promise<{oldCfg, newCfg}> ipfs.config.profile(name, opts)
+
+ // is now
+ Promise<{old, new}> ipfs.config.profiles.apply(name, opts)
+ ```
+
+* Possibly contentious; Adds `callbackify` as a dependency, see https://github.com/ipfs/js-ipfs/issues/2506
+for discussion.
+
+
+
+
+## [38.0.1](https://github.com/ipfs/js-ipfs-http-client/compare/v38.0.0...v38.0.1) (2019-10-04)
+
+
+### Bug Fixes
+
+* pull in preconfigured chai from interface tests ([6a7eb8a](https://github.com/ipfs/js-ipfs-http-client/commit/6a7eb8a))
+
+
+
+
+# [38.0.0](https://github.com/ipfs/js-ipfs-http-client/compare/v37.0.3...v38.0.0) (2019-09-25)
+
+
+
+
+## [37.0.3](https://github.com/ipfs/js-ipfs-http-client/compare/v37.0.2...v37.0.3) (2019-09-25)
+
+
+
+
+## [37.0.2](https://github.com/ipfs/js-ipfs-http-client/compare/v37.0.1...v37.0.2) (2019-09-20)
+
+
+### Bug Fixes
+
+* only do the big file workaround in node and electron main ([077c997](https://github.com/ipfs/js-ipfs-http-client/commit/077c997))
+
+
+
+
+## [37.0.1](https://github.com/ipfs/js-ipfs-http-client/compare/v37.0.0...v37.0.1) (2019-09-17)
+
+
+
+
+# [37.0.0](https://github.com/ipfs/js-ipfs-http-client/compare/v36.1.0...v37.0.0) (2019-09-17)
+
+
+### Bug Fixes
+
+* big downloads in electron ([9c9aac8](https://github.com/ipfs/js-ipfs-http-client/commit/9c9aac8))
+
+
+
+
+# [36.1.0](https://github.com/ipfs/js-ipfs-http-client/compare/v36.0.0...v36.1.0) (2019-09-17)
+
+
+### Bug Fixes
+
+* fix electron renderer tests and a couple more bugs ([#1105](https://github.com/ipfs/js-ipfs-http-client/issues/1105)) ([a631a21](https://github.com/ipfs/js-ipfs-http-client/commit/a631a21))
+
+
+
+
+# [36.0.0](https://github.com/ipfs/js-ipfs-http-client/compare/v35.1.0...v36.0.0) (2019-09-11)
+
+
+
+
+# [35.1.0](https://github.com/ipfs/js-ipfs-http-client/compare/v35.0.0...v35.1.0) (2019-09-04)
+
+
+### Features
+
+* add config profile endpoint ([#1030](https://github.com/ipfs/js-ipfs-http-client/issues/1030)) ([3aaa3ee](https://github.com/ipfs/js-ipfs-http-client/commit/3aaa3ee))
+
+
+
+
+# [35.0.0](https://github.com/ipfs/js-ipfs-http-client/compare/v34.0.0...v35.0.0) (2019-09-04)
+
+### BREAKING CHANGES
+
+Kebab case options (e.g. `wrap-with-directory`) are no longer supported in `ipfs.add`. Use camel case instead (e.g. `wrapWithDirectory`).
+
+
+# [34.0.0](https://github.com/ipfs/js-ipfs-http-client/compare/v33.1.1...v34.0.0) (2019-08-29)
+
+
+### Bug Fixes
+
+* **package:** update err-code to version 2.0.0 ([#1053](https://github.com/ipfs/js-ipfs-http-client/issues/1053)) ([3515070](https://github.com/ipfs/js-ipfs-http-client/commit/3515070))
+
+
+### Features
+
+* browser pubsub ([#1059](https://github.com/ipfs/js-ipfs-http-client/issues/1059)) ([3764d06](https://github.com/ipfs/js-ipfs-http-client/commit/3764d06))
+* expose pin and preload arguments ([#1079](https://github.com/ipfs/js-ipfs-http-client/issues/1079)) ([e3ed6e9](https://github.com/ipfs/js-ipfs-http-client/commit/e3ed6e9))
+* support adding files via async iterator ([#1078](https://github.com/ipfs/js-ipfs-http-client/issues/1078)) ([377042b](https://github.com/ipfs/js-ipfs-http-client/commit/377042b))
+
+
+
+
+## [33.1.1](https://github.com/ipfs/js-ipfs-http-client/compare/v33.1.0...v33.1.1) (2019-07-26)
+
+
+### Bug Fixes
+
+* allow passing timeout option to object stat ([#1055](https://github.com/ipfs/js-ipfs-http-client/issues/1055)) ([92b0594](https://github.com/ipfs/js-ipfs-http-client/commit/92b0594))
+
+
+
+
+# [33.1.0](https://github.com/ipfs/js-ipfs-http-client/compare/v33.0.2...v33.1.0) (2019-07-11)
+
+
+### Bug Fixes
+
+* changelog for 33.x does not include breaking change ([cd41a16](https://github.com/ipfs/js-ipfs-http-client/commit/cd41a16))
+* invalid multipart/form-data ([#948](https://github.com/ipfs/js-ipfs-http-client/issues/948)) ([9e6dfe7](https://github.com/ipfs/js-ipfs-http-client/commit/9e6dfe7)), closes [/tools.ietf.org/html/rfc7578#section-4](https://github.com//tools.ietf.org/html/rfc7578/issues/section-4)
+
+
+### Features
+
+* add support for js-ipfs dag api and also some tests ([#957](https://github.com/ipfs/js-ipfs-http-client/issues/957)) ([8f378a3](https://github.com/ipfs/js-ipfs-http-client/commit/8f378a3))
+
+
+
+
+## [33.0.2](https://github.com/ipfs/js-ipfs-http-client/compare/v33.0.1...v33.0.2) (2019-07-11)
+
+
+### Bug Fixes
+
+* make findprovs return all responses ([#1041](https://github.com/ipfs/js-ipfs-http-client/issues/1041)) ([63103bd](https://github.com/ipfs/js-ipfs-http-client/commit/63103bd))
+
+
+
+
+## [33.0.1](https://github.com/ipfs/js-ipfs-http-client/compare/v33.0.0...v33.0.1) (2019-07-10)
+
+
+### Bug Fixes
+
+* response for findpeer and findprovs ([#1039](https://github.com/ipfs/js-ipfs-http-client/issues/1039)) ([5252f50](https://github.com/ipfs/js-ipfs-http-client/commit/5252f50))
+
+
+
+
+# [33.0.0](https://github.com/ipfs/js-ipfs-http-client/compare/v32.0.1...v33.0.0) (2019-07-10)
+
+
+### Bug Fixes
+
+* link to ipfs.io ([70cdf25](https://github.com/ipfs/js-ipfs-http-client/commit/70cdf25))
+* prepare for aegir release ([#1021](https://github.com/ipfs/js-ipfs-http-client/issues/1021)) ([806b206](https://github.com/ipfs/js-ipfs-http-client/commit/806b206))
+* sometimes no Addrs element is present in the response ([#1037](https://github.com/ipfs/js-ipfs-http-client/issues/1037)) ([a74b8f7](https://github.com/ipfs/js-ipfs-http-client/commit/a74b8f7))
+* **package:** update bignumber.js to version 9.0.0 ([#1024](https://github.com/ipfs/js-ipfs-http-client/issues/1024)) ([a04edac](https://github.com/ipfs/js-ipfs-http-client/commit/a04edac))
+
+### BREAKING CHANGES
+
+`repo.gc` response objects have changed to `{ err, cid }`, where `err` is an `Error` instance and `cid` is a [`CID`](https://github.com/multiformats/js-cid) instance.
+
+
+
+
+## [32.0.1](https://github.com/ipfs/js-ipfs-http-client/compare/v32.0.0...v32.0.1) (2019-05-21)
+
+
+### Bug Fixes
+
+* error reporting for non-JSON responses ([#1016](https://github.com/ipfs/js-ipfs-http-client/issues/1016)) ([4251c88](https://github.com/ipfs/js-ipfs-http-client/commit/4251c88)), closes [#912](https://github.com/ipfs/js-ipfs-http-client/issues/912) [#1000](https://github.com/ipfs/js-ipfs-http-client/issues/1000) [#1001](https://github.com/ipfs/js-ipfs-http-client/issues/1001)
+* send trickle param to trigger trickle dag builder ([#1015](https://github.com/ipfs/js-ipfs-http-client/issues/1015)) ([a28b009](https://github.com/ipfs/js-ipfs-http-client/commit/a28b009))
+
+
+
+
+# [32.0.0](https://github.com/ipfs/js-ipfs-http-client/compare/v31.1.0...v32.0.0) (2019-05-21)
+
+
+### Bug Fixes
+
+* handle empty array return value in dht.findProvs ([#1003](https://github.com/ipfs/js-ipfs-http-client/issues/1003)) ([15ab7c5](https://github.com/ipfs/js-ipfs-http-client/commit/15ab7c5))
+
+
+### Chores
+
+* update ipld formats ([#1010](https://github.com/ipfs/js-ipfs-http-client/issues/1010)) ([a423d7f](https://github.com/ipfs/js-ipfs-http-client/commit/a423d7f))
+
+
+### BREAKING CHANGES
+
+* The default string encoding for version 1 CIDs has changed to `base32`.
+
+IPLD formats have been updated to the latest versions. IPLD nodes returned by `ipfs.dag` and `ipfs.object` commands have significant breaking changes. If you are using these commands in your application you are likely to encounter the following changes to `dag-pb` nodes (the default node type that IPFS creates):
+
+* `DAGNode` properties have been renamed as follows:
+ * `data` => `Data`
+ * `links` => `Links`
+ * `size` => `size` (Note: no change)
+* `DAGLink` properties have been renamed as follows:
+ * `cid` => `Hash`
+ * `name` => `Name`
+ * `size` => `Tsize`
+
+See CHANGELOGs for each IPLD format for it's respective changes, you can read more about the [`dag-pb` changes in the CHANGELOG](https://github.com/ipld/js-ipld-dag-pb/blob/master)
+
+License: MIT
+Signed-off-by: Alan Shaw
+
+
+
+
+# [31.1.0](https://github.com/ipfs/js-ipfs-http-client/compare/v31.0.2...v31.1.0) (2019-05-16)
+
+
+### Features
+
+* add support for File DOM API to files-regular ([#986](https://github.com/ipfs/js-ipfs-http-client/issues/986)) ([7b49f7e](https://github.com/ipfs/js-ipfs-http-client/commit/7b49f7e))
+
+
+
+
+## [31.0.2](https://github.com/ipfs/js-ipfs-http-client/compare/v31.0.1...v31.0.2) (2019-05-16)
+
+
+### Bug Fixes
+
+* error handling for refs/refs local ([#997](https://github.com/ipfs/js-ipfs-http-client/issues/997)) ([391351d](https://github.com/ipfs/js-ipfs-http-client/commit/391351d))
+
+
+
+
+## [31.0.1](https://github.com/ipfs/js-ipfs-http-client/compare/v31.0.0...v31.0.1) (2019-05-15)
+
+
+### Bug Fixes
+
+* config set with number ([#998](https://github.com/ipfs/js-ipfs-http-client/issues/998)) ([4f21bef](https://github.com/ipfs/js-ipfs-http-client/commit/4f21bef)), closes [#881](https://github.com/ipfs/js-ipfs-http-client/issues/881)
+
+
+
+
+# [31.0.0](https://github.com/ipfs/js-ipfs-http-client/compare/v30.1.4...v31.0.0) (2019-05-13)
+
+
+### Features
+
+* refs endpoint ([#978](https://github.com/ipfs/js-ipfs-http-client/issues/978)) ([a741e10](https://github.com/ipfs/js-ipfs-http-client/commit/a741e10))
+
+
+### BREAKING CHANGES
+
+* ipfs.refs now returns objects with camelCase properties not PascalCase properties. i.e. `{ ref, err }` not `{ Ref, Err }`
+
+
+
+
+## [30.1.4](https://github.com/ipfs/js-ipfs-http-client/compare/v30.1.3...v30.1.4) (2019-04-29)
+
+
+### Bug Fixes
+
+* uncaught error: stream.push() after EOF ([#980](https://github.com/ipfs/js-ipfs-http-client/issues/980)) ([cc677f0](https://github.com/ipfs/js-ipfs-http-client/commit/cc677f0)), closes [#967](https://github.com/ipfs/js-ipfs-http-client/issues/967)
+* update Babel in upload-file-via-browser example ([#968](https://github.com/ipfs/js-ipfs-http-client/issues/968)) ([#970](https://github.com/ipfs/js-ipfs-http-client/issues/970)) ([17d49de](https://github.com/ipfs/js-ipfs-http-client/commit/17d49de))
+
+
+
+
+## [30.1.3](https://github.com/ipfs/js-ipfs-http-client/compare/v30.1.2...v30.1.3) (2019-04-11)
+
+
+### Bug Fixes
+
+* fix missing buffer bundling with browserify ([#966](https://github.com/ipfs/js-ipfs-http-client/issues/966)) ([944a64b](https://github.com/ipfs/js-ipfs-http-client/commit/944a64b)), closes [#964](https://github.com/ipfs/js-ipfs-http-client/issues/964)
+
+
+
## [30.1.2](https://github.com/ipfs/js-ipfs-http-client/compare/v30.1.1...v30.1.2) (2019-04-09)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 33fe54e07..ba4ef9f8f 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -26,6 +26,32 @@ Tests in the browser
$ npm run test:browser
```
+### Writing a new core interface test
+
+The core interface tests are kept in a separate repo, because they are used by multiple other projects. To add a core interface test, follow this guide:
+
+1. Clone this project repo and the interface core tests repo:
+ * `git clone https://github.com/ipfs/js-ipfs-http-client.git`
+ * `git clone https://github.com/ipfs/interface-js-ipfs-core.git`
+1. Install dependencies and globally [link](https://docs.npmjs.com/cli/link) the interface core tests:
+ * `cd interface-js-ipfs-core`
+ * `npm install`
+ * `npm link`
+1. Write your test
+1. Install dependencies for this project and link to the interface core tests
+ * `cd ../js-ipfs-http-client`
+ * `npm install`
+ * `npm link interface-ipfs-core`
+1. Run the tests:
+ * `npm test`
+
+Next:
+
+1. Send a PR to `ipfs/interface-js-ipfs-core` (please also add to the documentation!)
+1. This will be reviewed by a core contributor and they will perform the same steps as above
+1. When merged, a new version of `interface-ipfs-core` will be released
+1. Finally, a PR needs to be created or updated to `ipfs/js-ipfs-http-client` to use the new version
+
## Building browser version
```bash
diff --git a/COPYRIGHT b/COPYRIGHT
new file mode 100644
index 000000000..b8b0a702d
--- /dev/null
+++ b/COPYRIGHT
@@ -0,0 +1,5 @@
+This project is transitioning from an MIT-only license to a dual MIT/Apache-2.0 license.
+Unless otherwise noted, all code contributed prior to 2019-11-26 and not contributed by
+a user listed in [this signoff issue](https://github.com/ipfs/js-ipfs-http-client/issues/1189) is
+licensed under MIT-only. All new contributions (and past contributions since 2019-11-29)
+are licensed under a dual MIT/Apache-2.0 license.
diff --git a/LICENSE-APACHE b/LICENSE-APACHE
new file mode 100644
index 000000000..14478a3b6
--- /dev/null
+++ b/LICENSE-APACHE
@@ -0,0 +1,5 @@
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
diff --git a/LICENSE b/LICENSE-MIT
similarity index 100%
rename from LICENSE
rename to LICENSE-MIT
diff --git a/README.md b/README.md
index a1ef73530..bd40851aa 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,11 @@
+# 🔒 Archived
+
+The contents of this repo have been merged into [ipfs/js-ipfs](https://github.com/ipfs/js-ipfs).
+
+Please open [issues](https://github.com/ipfs/js-ipfs/issues) or submit [PRs](https://github.com/ipfs/js-ipfs/pulls) there.
+
-
+
The JavaScript HTTP client library for IPFS implementations.
@@ -34,17 +40,35 @@
## Table of Contents
+- [Lead Maintainer](#lead-maintainer)
+- [Table of Contents](#table-of-contents)
- [Install](#install)
- [Running the daemon with the right port](#running-the-daemon-with-the-right-port)
- [Importing the module and usage](#importing-the-module-and-usage)
- [Importing a sub-module and usage](#importing-a-sub-module-and-usage)
- - [In a web browser through Browserify](#in-a-web-browser-through-browserify)
- - [In a web browser from CDN](#in-a-web-browser-from-cdn)
+ - [In a web browser](#in-a-web-browser)
- [CORS](#cors)
+ - [Custom Headers](#custom-headers)
+ - [Global Timeouts](#global-timeouts)
- [Usage](#usage)
- - [API Docs](#api)
- - [Callbacks and promises](#callbacks-and-promises)
+ - [API](#api)
+ - [Files](#files)
+ - [Graph](#graph)
+ - [Network](#network)
+ - [Node Management](#node-management)
+ - [Additional Options](#additional-options)
+ - [Instance Utils](#instance-utils)
+ - [Static Types and Utils](#static-types-and-utils)
+ - [Glob source](#glob-source)
+ - [`globSource(path, [options])`](#globsourcepath-options)
+ - [Example](#example)
+ - [URL source](#url-source)
+ - [`urlSource(url)`](#urlsourceurl)
+ - [Example](#example-1)
+- [Development](#development)
+ - [Testing](#testing)
- [Contribute](#contribute)
+- [Historical context](#historical-context)
- [License](#license)
## Install
@@ -76,19 +100,19 @@ To interact with the API, you need to have a local daemon running. It needs to b
### Importing the module and usage
```javascript
-var ipfsClient = require('ipfs-http-client')
+const ipfsClient = require('ipfs-http-client')
// connect to ipfs daemon API server
-var ipfs = ipfsClient('localhost', '5001', { protocol: 'http' }) // leaving out the arguments will default to these values
+const ipfs = ipfsClient('http://localhost:5001') // (the default in Node.js)
// or connect with multiaddr
-var ipfs = ipfsClient('/ip4/127.0.0.1/tcp/5001')
+const ipfs = ipfsClient('/ip4/127.0.0.1/tcp/5001')
// or using options
-var ipfs = ipfsClient({ host: 'localhost', port: '5001', protocol: 'http' })
+const ipfs = ipfsClient({ host: 'localhost', port: '5001', protocol: 'http' })
// or specifying a specific API path
-var ipfs = ipfsClient({ host: '1.1.1.1', port: '80', 'api-path': '/ipfs/api/v0' })
+const ipfs = ipfsClient({ host: '1.1.1.1', port: '80', apiPath: '/ipfs/api/v0' })
```
### Importing a sub-module and usage
@@ -96,9 +120,8 @@ var ipfs = ipfsClient({ host: '1.1.1.1', port: '80', 'api-path': '/ipfs/api/v0'
```javascript
const bitswap = require('ipfs-http-client/src/bitswap')('/ip4/127.0.0.1/tcp/5001')
-bitswap.wantlist(key, (err) => {
- // ...
-})
+const list = await bitswap.wantlist(key)
+// ...
```
### In a web browser
@@ -120,12 +143,11 @@ Instead of a local installation (and browserification) you may request a remote
To always request the latest version, use the following:
```html
-
-
-
```
+Note: remove the `.min` from the URL to get the human-readable (not minified) version.
+
For maximum security you may also decide to:
* reference a specific version of IPFS API (to prevent unexpected breaking changes when a newer latest version is published)
@@ -143,7 +165,7 @@ crossorigin="anonymous">
CDN-based IPFS API provides the `IpfsHttpClient` constructor as a method of the global `window` object. Example:
```js
-const ipfs = window.IpfsHttpClient('localhost', '5001')
+const ipfs = window.IpfsHttpClient({ host: 'localhost', port: 5001 })
```
If you omit the host and port, the client will parse `window.host`, and use this information. This also works, and can be useful if you want to write apps that can be run from multiple different gateways:
@@ -176,6 +198,18 @@ const ipfs = ipfsClient({
})
```
+### Global Timeouts
+
+To set a global timeout for _all_ requests pass a value for the `timeout` option:
+
+```js
+// Timeout after 10 seconds
+const ipfs = ipfsClient({ timeout: 10000 })
+// Timeout after 2 minutes
+const ipfs = ipfsClient({ timeout: '2m' })
+// see https://www.npmjs.com/package/parse-duration for valid string values
+```
+
## Usage
### API
@@ -187,187 +221,161 @@ const ipfs = ipfsClient({
#### Files
- [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)
+ - [`ipfs.add(data, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#add)
+ - [`ipfs.cat(ipfsPath, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#cat)
+ - [`ipfs.get(ipfsPath, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#get)
+ - [`ipfs.ls(ipfsPath)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#ls)
- [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)
+ - [`ipfs.files.cp([from, to])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filescp)
+ - [`ipfs.files.flush([path])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesflush)
+ - [`ipfs.files.ls([path], [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesls)
+ - [`ipfs.files.mkdir(path, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesmkdir)
+ - [`ipfs.files.mv([from, to])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesmv)
+ - [`ipfs.files.read(path, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesread)
+ - [`ipfs.files.rm(path, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesrm)
+ - [`ipfs.files.stat(path, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#filesstat)
+ - [`ipfs.files.write(path, content, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/FILES.md#fileswrite)
+ _Explore the Mutable File System through interactive coding challenges in our [ProtoSchool tutorial](https://proto.school/#/mutable-file-system/)._
- [block](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BLOCK.md)
- - [`ipfs.block.get(cid, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BLOCK.md#blockget)
- - [`ipfs.block.put(block, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BLOCK.md#blockput)
- - [`ipfs.block.stat(cid, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BLOCK.md#blockstat)
+ - [`ipfs.block.get(cid, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BLOCK.md#blockget)
+ - [`ipfs.block.put(block, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BLOCK.md#blockput)
+ - [`ipfs.block.stat(cid)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BLOCK.md#blockstat)
+
+- [refs](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/REFS.md)
+ - [`ipfs.refs(ipfsPath, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/REFS.md#refs)
+ - [`ipfs.refs.local()`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/REFS.md#refslocal)
#### Graph
- [dag](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md)
- - [`ipfs.dag.get(cid, [path], [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagget)
- - [`ipfs.dag.put(dagNode, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput)
- - [`ipfs.dag.tree(cid, [path], [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagtree)
+ - [`ipfs.dag.get(cid, [path], [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagget)
+ - [`ipfs.dag.put(dagNode, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput)
+ - [`ipfs.dag.tree(cid, [path], [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagtree)
+ _Explore the DAG API through interactive coding challenges in our [ProtoSchool tutorial](https://proto.school/#/basics)._
- [object](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md)
- - [`ipfs.object.data(multihash, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectdata)
- - [`ipfs.object.get(multihash, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectget)
- - [`ipfs.object.links(multihash, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectlinks)
- - [`ipfs.object.new([template], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectnew)
- - [`ipfs.object.patch.addLink(multihash, DAGLink, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectpatchaddlink)
- - [`ipfs.object.patch.appendData(multihash, data, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectpatchappenddata)
- - [`ipfs.object.patch.rmLink(multihash, DAGLink, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectpatchrmlink)
- - [`ipfs.object.patch.setData(multihash, data, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectpatchsetdata)
- - [`ipfs.object.put(obj, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectput)
- - [`ipfs.object.stat(multihash, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectstat)
+ - [`ipfs.object.data(multihash, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectdata)
+ - [`ipfs.object.get(multihash, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectget)
+ - [`ipfs.object.links(multihash, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectlinks)
+ - [`ipfs.object.new([template])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectnew)
+ - [`ipfs.object.patch.addLink(multihash, DAGLink, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectpatchaddlink)
+ - [`ipfs.object.patch.appendData(multihash, data, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectpatchappenddata)
+ - [`ipfs.object.patch.rmLink(multihash, DAGLink, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectpatchrmlink)
+ - [`ipfs.object.patch.setData(multihash, data, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectpatchsetdata)
+ - [`ipfs.object.put(obj, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectput)
+ - [`ipfs.object.stat(multihash, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/OBJECT.md#objectstat)
- [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)
-
-- refs
- - `ipfs.refs.local()`
+ - [`ipfs.pin.add(hash, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PIN.md#pinadd)
+ - [`ipfs.pin.ls([hash], [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PIN.md#pinls)
+ - [`ipfs.pin.rm(hash, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PIN.md#pinrm)
#### Network
- [bootstrap](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BOOTSTRAP.md)
- - [`ipfs.bootstrap.add(addr, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BOOTSTRAP.md#bootstrapadd)
- - [`ipfs.bootstrap.list([callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BOOTSTRAP.md#bootstraplist)
- - [`ipfs.bootstrap.rm(addr, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BOOTSTRAP.md#bootstraprm)
+ - [`ipfs.bootstrap.add(addr, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BOOTSTRAP.md#bootstrapadd)
+ - [`ipfs.bootstrap.list()`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BOOTSTRAP.md#bootstraplist)
+ - [`ipfs.bootstrap.rm(addr, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BOOTSTRAP.md#bootstraprm)
- [bitswap](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BITSWAP.md)
- - [`ipfs.bitswap.stat([callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BITSWAP.md#bitswapstat)
+ - [`ipfs.bitswap.stat()`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BITSWAP.md#bitswapstat)
- [`ipfs.bitswap.wantlist([peerId])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BITSWAP.md#bitswapwantlist)
- [`ipfs.bitswap.unwant(cid)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/BITSWAP.md#bitswapunwant)
- [dht](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DHT.md)
- - [`ipfs.dht.findPeer(peerId, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DHT.md#dhtfindpeer)
- - [`ipfs.dht.findProvs(hash, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DHT.md#dhtfindprovs)
- - [`ipfs.dht.get(key, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DHT.md#dhtget)
- - [`ipfs.dht.provide(cid, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DHT.md#dhtprovide)
- - [`ipfs.dht.put(key, value, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DHT.md#dhtput)
+ - [`ipfs.dht.findPeer(peerId)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DHT.md#dhtfindpeer)
+ - [`ipfs.dht.findProvs(hash)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DHT.md#dhtfindprovs)
+ - [`ipfs.dht.get(key)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DHT.md#dhtget)
+ - [`ipfs.dht.provide(cid)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DHT.md#dhtprovide)
+ - [`ipfs.dht.put(key, value)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DHT.md#dhtput)
- [pubsub](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PUBSUB.md)
- - [`ipfs.pubsub.ls(topic, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PUBSUB.md#pubsubls)
- - [`ipfs.pubsub.peers(topic, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PUBSUB.md#pubsubpeers)
- - [`ipfs.pubsub.publish(topic, data, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PUBSUB.md#pubsubpublish)
- - [`ipfs.pubsub.subscribe(topic, handler, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PUBSUB.md#pubsubsubscribe)
- - [`ipfs.pubsub.unsubscribe(topic, handler, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PUBSUB.md#pubsubunsubscribe)
+ - [`ipfs.pubsub.ls(topic)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PUBSUB.md#pubsubls)
+ - [`ipfs.pubsub.peers(topic)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PUBSUB.md#pubsubpeers)
+ - [`ipfs.pubsub.publish(topic, data)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PUBSUB.md#pubsubpublish)
+ - [`ipfs.pubsub.subscribe(topic, handler, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PUBSUB.md#pubsubsubscribe)
+ - [`ipfs.pubsub.unsubscribe(topic, handler)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/PUBSUB.md#pubsubunsubscribe)
- [swarm](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/SWARM.md)
- - [`ipfs.swarm.addrs([callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/SWARM.md#swarmaddrs)
- - [`ipfs.swarm.connect(addr, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/SWARM.md#swarmconnect)
- - [`ipfs.swarm.disconnect(addr, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/SWARM.md#swarmdisconnect)
- - [`ipfs.swarm.peers([options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/SWARM.md#swarmpeers)
+ - [`ipfs.swarm.addrs()`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/SWARM.md#swarmaddrs)
+ - [`ipfs.swarm.connect(addr)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/SWARM.md#swarmconnect)
+ - [`ipfs.swarm.disconnect(addr)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/SWARM.md#swarmdisconnect)
+ - [`ipfs.swarm.peers([options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/SWARM.md#swarmpeers)
- [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)
+ - [`ipfs.name.publish(addr, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/NAME.md#namepublish)
+ - [`ipfs.name.pubsub.cancel(arg)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/NAME.md#namepubsubcancel)
+ - [`ipfs.name.pubsub.state()`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/NAME.md#namepubsubstate)
+ - [`ipfs.name.pubsub.subs()`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/NAME.md#namepubsubsubs)
+ - [`ipfs.name.resolve(addr, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/NAME.md#nameresolve)
#### Node Management
- [miscellaneous operations](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/MISCELLANEOUS.md)
- - [`ipfs.dns(domain, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/MISCELLANEOUS.md#dns)
- - [`ipfs.id([callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/MISCELLANEOUS.md#id)
- - [`ipfs.ping(id, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/MISCELLANEOUS.md#ping)
- - [`ipfs.pingPullStream(id, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/MISCELLANEOUS.md#pingpullstream)
- - [`ipfs.pingReadableStream(id, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/MISCELLANEOUS.md#pingreadablestream)
- - [`ipfs.stop([callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/MISCELLANEOUS.md#stop). Alias to `ipfs.shutdown`.
- - [`ipfs.version([callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/MISCELLANEOUS.md#version)
+ - [`ipfs.dns(domain)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/MISCELLANEOUS.md#dns)
+ - [`ipfs.id()`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/MISCELLANEOUS.md#id)
+ - [`ipfs.ping(id, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/MISCELLANEOUS.md#ping)
+ - [`ipfs.stop()`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/MISCELLANEOUS.md#stop). Alias to `ipfs.shutdown`.
+ - [`ipfs.version()`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/MISCELLANEOUS.md#version)
- [config](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/CONFIG.md)
- - [`ipfs.config.get([key], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/CONFIG.md#configget)
- - [`ipfs.config.replace(config, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/CONFIG.md#configreplace)
- - [`ipfs.config.set(key, value, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/CONFIG.md#configset)
+ - [`ipfs.config.get([key])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/CONFIG.md#configget)
+ - [`ipfs.config.replace(config)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/CONFIG.md#configreplace)
+ - [`ipfs.config.set(key, value)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/CONFIG.md#configset)
+ - [`ipfs.config.profiles.list()`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/CONFIG.md#configprofileslist)
+ - [`ipfs.config.profiles.apply(name, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/CONFIG.md#configprofilesapply)
- [stats](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/STATS.md)
- - [`ipfs.stats.bitswap([callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/STATS.md#statsbitswap)
- - [`ipfs.stats.bw([options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/STATS.md#statsbw)
- - [`ipfs.stats.bwPullStream([options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/STATS.md#statsbwpullstream)
- - [`ipfs.stats.bwReadableStream([options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/STATS.md#statsbwreadablestream)
- - [`ipfs.stats.repo([options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/STATS.md#statsrepo)
+ - [`ipfs.stats.bitswap()`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/STATS.md#statsbitswap)
+ - [`ipfs.stats.bw([options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/STATS.md#statsbw)
+ - [`ipfs.stats.repo([options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/STATS.md#statsrepo)
- log
- - `ipfs.log.level(subsystem, level, [options], [callback])`
- - `ipfs.log.ls([callback])`
- - `ipfs.log.tail([callback])`
+ - `ipfs.log.level(subsystem, level, [options])`
+ - `ipfs.log.ls()`
+ - `ipfs.log.tail()`
- [repo](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/REPO.md)
- - [`ipfs.repo.gc([options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/REPO.md#repogc)
- - [`ipfs.repo.stat([options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/REPO.md#repostat)
- - [`ipfs.repo.version([callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/REPO.md#repoversion)
+ - [`ipfs.repo.gc([options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/REPO.md#repogc)
+ - [`ipfs.repo.stat([options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/REPO.md#repostat)
+ - [`ipfs.repo.version()`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/REPO.md#repoversion)
- [key](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/KEY.md)
- - [`ipfs.key.export(name, password, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/KEY.md#keyexport)
- - [`ipfs.key.gen(name, [options], [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/KEY.md#keygen)
- - [`ipfs.key.import(name, pem, password, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/KEY.md#keyimport)
- - [`ipfs.key.list([options, callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/KEY.md#keylist)
- - [`ipfs.key.rename(oldName, newName, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/KEY.md#keyrename)
- - [`ipfs.key.rm(name, [callback])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/KEY.md#keyrm)
+ - [`ipfs.key.export(name, password)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/KEY.md#keyexport)
+ - [`ipfs.key.gen(name, [options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/KEY.md#keygen)
+ - [`ipfs.key.import(name, pem, password)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/KEY.md#keyimport)
+ - [`ipfs.key.list([options])`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/KEY.md#keylist)
+ - [`ipfs.key.rename(oldName, newName)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/KEY.md#keyrename)
+ - [`ipfs.key.rm(name)`](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/KEY.md#keyrm)
-#### Pubsub Caveat
+#### Additional Options
-**Currently, the [PubSub API only works in Node.js environment](https://github.com/ipfs/js-ipfs-http-client/issues/518)**
+All core API methods take _additional_ `options` specific to the HTTP API:
-We currently don't support pubsub when run in the browser, and we test it with separate set of tests to make sure if it's being used in the browser, pubsub errors.
+* `headers` - An object or [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) instance that can be used to set custom HTTP headers. Note that this option can also be [configured globally](#custom-headers) via the constructor options.
+* `signal` - An [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) that can be used to abort the request on demand.
+* `timeout` - A number or string specifying a timeout for the request. If the timeout is reached before data is received a [`TimeoutError`](https://github.com/sindresorhus/ky/blob/2f37c3f999efb36db9108893b8b3d4b3a7f5ec45/index.js#L127-L132) is thrown. If a number is specified it is interpreted as milliseconds, if a string is passed, it is intepreted according to [`parse-duration`](https://www.npmjs.com/package/parse-duration). Note that this option can also be [configured globally](#global-timeouts) via the constructor options.
+* `searchParams` - An object or [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) instance that can be used to add additional query parameters to the query string sent with each request.
-More info: https://github.com/ipfs/js-ipfs-http-client/issues/518
-
-This means:
-- You can use pubsub from js-ipfs-http-client in Node.js
-- You can use pubsub from js-ipfs-http-client in Electron
- (when js-ipfs-http-client is ran in the main process of Electron)
-- You can't use pubsub from js-ipfs-http-client in the browser
-- You can't use pubsub from js-ipfs-http-client in Electron's
- renderer process
-- You can use pubsub from js-ipfs in the browsers
-- You can use pubsub from js-ipfs in Node.js
-- You can use pubsub from js-ipfs in Electron
- (in both the main process and the renderer process)
-- See https://github.com/ipfs/js-ipfs for details on
- pubsub in js-ipfs
-
-#### Instance utils
+#### Instance Utils
- `ipfs.getEndpointConfig()`
Call this on your client instance to return an object containing the `host`, `port`, `protocol` and `api-path`.
-#### Static types and utils
+#### Static Types and Utils
Aside from the default export, `ipfs-http-client` exports various types and utilities that are included in the bundle:
-- [`isIPFS`](https://www.npmjs.com/package/is-ipfs)
- [`Buffer`](https://www.npmjs.com/package/buffer)
-- [`PeerId`](https://www.npmjs.com/package/peer-id)
-- [`PeerInfo`](https://www.npmjs.com/package/peer-info)
- [`multiaddr`](https://www.npmjs.com/package/multiaddr)
- [`multibase`](https://www.npmjs.com/package/multibase)
- [`multicodec`](https://www.npmjs.com/package/multicodec)
-- [`multihash`](https://www.npmjs.com/package/multihash)
+- [`multihash`](https://www.npmjs.com/package/multihashes)
- [`CID`](https://www.npmjs.com/package/cids)
+- [`globSource`](https://github.com/ipfs/js-ipfs-utils/blob/master/src/files/glob-source.js) (not available in the browser)
+- [`urlSource`](https://github.com/ipfs/js-ipfs-utils/blob/master/src/files/url-source.js)
These can be accessed like this, for example:
@@ -377,6 +385,74 @@ const { CID } = require('ipfs-http-client')
import { CID } from 'ipfs-http-client'
```
+##### Glob source
+
+A utility to allow files on the file system to be easily added to IPFS.
+
+###### `globSource(path, [options])`
+
+- `path`: A path to a single file or directory to glob from
+- `options`: Optional options
+- `options.recursive`: If `path` is a directory, use option `{ recursive: true }` to add the directory and all its sub-directories.
+- `options.ignore`: To exclude file globs from the directory, use option `{ ignore: ['ignore/this/folder/**', 'and/this/file'] }`.
+- `options.hidden`: Hidden/dot files (files or folders starting with a `.`, for example, `.git/`) are not included by default. To add them, use the option `{ hidden: true }`.
+
+Returns an async iterable that yields `{ path, content }` objects suitable for passing to `ipfs.add`.
+
+###### Example
+
+```js
+const IpfsHttpClient = require('ipfs-http-client')
+const { globSource } = IpfsHttpClient
+const ipfs = IpfsHttpClient()
+
+for await (const file of ipfs.add(globSource('./docs', { recursive: true }))) {
+ console.log(file)
+}
+/*
+{
+ path: 'docs/assets/anchor.js',
+ cid: CID('QmVHxRocoWgUChLEvfEyDuuD6qJ4PhdDL2dTLcpUy3dSC2'),
+ size: 15347
+}
+{
+ path: 'docs/assets/bass-addons.css',
+ cid: CID('QmPiLWKd6yseMWDTgHegb8T7wVS7zWGYgyvfj7dGNt2viQ'),
+ size: 232
+}
+...
+*/
+```
+
+##### URL source
+
+A utility to allow content from the internet to be easily added to IPFS.
+
+###### `urlSource(url)`
+
+- `url`: A string URL or [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) instance to send HTTP GET request to
+
+Returns an async iterable that yields `{ path, content }` objects suitable for passing to `ipfs.add`.
+
+###### Example
+
+```js
+const IpfsHttpClient = require('ipfs-http-client')
+const { urlSource } = IpfsHttpClient
+const ipfs = IpfsHttpClient()
+
+for await (const file of ipfs.add(urlSource('https://ipfs.io/images/ipfs-logo.svg'))) {
+ console.log(file)
+}
+/*
+{
+ path: 'ipfs-logo.svg',
+ cid: CID('QmTqZhR6f7jzdhLgPArDPnsbZpvvgxzCZycXK7ywkLxSyU'),
+ size: 3243
+}
+*/
+```
+
## Development
### Testing
@@ -390,7 +466,7 @@ The js-ipfs-http-client is a work in progress. As such, there's a few things you
- **[Check out the existing issues](https://github.com/ipfs/js-ipfs-http-client/issues)**!
- **Perform code reviews**. More eyes will help a) speed the project along b) ensure quality and c) reduce possible future bugs.
- **Add tests**. There can never be enough tests. Note that interface tests exist inside [`interface-ipfs-core`](https://github.com/ipfs/interface-ipfs-core/tree/master/js/src).
-- **Contribute to the [FAQ repository](https://github.com/ipfs/faq/issues)** with any questions you have about IPFS or any of the relevant technology. A good example would be asking, 'What is a merkledag tree?'. If you don't know a term, odds are, someone else doesn't either. Eventually, we should have a good understanding of where we need to improve communications and teaching together to make IPFS and IPN better.
+- **Contribute to the [FAQ repository](https://github.com/ipfs/faq/issues)** with any questions you have about IPFS or any of the relevant technology. A good example would be asking, 'What is a merkledag tree?'. If you don't know a term, odds are, someone else doesn't either. Eventually, we should have a good understanding of where we need to improve communications and teaching together to make IPFS and IPNS better.
**Want to hack on IPFS?**
diff --git a/examples/browser-pubsub/.gitignore b/examples/browser-pubsub/.gitignore
new file mode 100644
index 000000000..0e804e3a5
--- /dev/null
+++ b/examples/browser-pubsub/.gitignore
@@ -0,0 +1 @@
+bundle.js
diff --git a/examples/browser-pubsub/README.md b/examples/browser-pubsub/README.md
new file mode 100644
index 000000000..a74f77604
--- /dev/null
+++ b/examples/browser-pubsub/README.md
@@ -0,0 +1,94 @@
+# Pubsub in the browser
+
+> Use pubsub in the browser!
+
+This example is a demo web application that allows you to connect to an IPFS node, subscribe to a pubsub topic and send/receive messages. We'll start two IPFS nodes and two browsers and use the `ipfs-http-client` to instruct each node to listen to a pubsub topic and send/receive pubsub messages to/from each other. We're aiming for something like this:
+
+```
+ +-----------+ +-----------+
+ | +-------------------> |
+ | js-ipfs | pubsub | go-ipfs |
+ | <-------------------+ |
+ +-----^-----+ +-----^-----+
+ | |
+ | HTTP API | HTTP API
+ | |
++-------------------+ +-------------------+
++-------------------+ +-------------------+
+| | | |
+| | | |
+| Browser 1 | | Browser 2 |
+| | | |
+| | | |
+| | | |
++-------------------+ +-------------------+
+```
+
+## 1. Get started
+
+With Node.js and git installed, clone the repo and install the project dependencies:
+
+```sh
+git clone https://github.com/ipfs/js-ipfs-http-client.git
+cd js-ipfs-http-client
+npm install # Installs ipfs-http-client dependencies
+cd examples/browser-pubsub
+npm install # Installs browser-pubsub app dependencies
+```
+
+Start the example application:
+
+```sh
+npm start
+```
+
+You should see something similar to the following in your terminal and the web app should now be available if you navigate to http://127.0.0.1:8888 using your browser:
+
+```sh
+Starting up http-server, serving ./
+Available on:
+ http://127.0.0.1:8888
+```
+
+## 2. Start two IPFS nodes
+
+To demonstrate pubsub we need two nodes running so pubsub messages can be passed between them.
+
+Right now the easiest way to do this is to install and start a `js-ipfs` and `go-ipfs` node. There are other ways to do this, see [this document on running multiple nodes](https://github.com/ipfs/js-ipfs/tree/master/examples/running-multiple-nodes) for details.
+
+### Install and start the JS IPFS node
+
+```sh
+npm install -g ipfs
+jsipfs init
+# Configure CORS to allow ipfs-http-client to access this IPFS node
+jsipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://127.0.0.1:8888"]'
+# Start the IPFS node, enabling pubsub
+jsipfs daemon
+```
+
+### Install and start the Go IPFS node
+
+Head over to https://dist.ipfs.io/#go-ipfs and hit the "Download go-ipfs" button. Extract the archive and read the instructions to install.
+
+After installation:
+
+```sh
+ipfs init
+# Configure CORS to allow ipfs-http-client to access this IPFS node
+ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://127.0.0.1:8888"]'
+# Start the IPFS node, enabling pubsub
+ipfs daemon --enable-pubsub-experiment
+```
+
+## 3. Open two browsers and connect to each node
+
+Now, open up **two** browser windows. This could be two tabs in the same browser or two completely different browsers, it doesn't matter. Navigate to http://127.0.0.1:8888 in both.
+
+In the "API ADDR" field enter `/ip4/127.0.0.1/tcp/5001` in one browser and `/ip4/127.0.0.1/tcp/5002` in the other and hit the "Connect" button.
+
+This connects each browser to an IPFS node and now from the comfort of our browser we can instruct each node to listen to a pubsub topic and send/receive pubsub messages to each other.
+
+> N.B. Since our two IPFS nodes are running on the same network they should have already found each other by MDNS. So you probably won't need to use the "CONNECT TO PEER" field. If you find your pubsub messages aren't getting through, check the output from your `jsipfs daemon` command and find the first address listed in "Swarm listening on" - it'll look like `/ip4/127.0.0.1/tcp/4002/ipfs/Qm...`. Paste this address into the "CONNECT TO PEER" field for the browser that is connected to your go-ipfs node and hit connect.
+
+Finally, use the "SUBSCRIBE TO PUBSUB TOPIC" and "SEND MESSAGE" fields to do some pubsub-ing, you should see messages sent from one browser appear in the log of the other (provided they're both subscribed to the same topic).
diff --git a/examples/browser-pubsub/index.html b/examples/browser-pubsub/index.html
new file mode 100644
index 000000000..22a0d4765
--- /dev/null
+++ b/examples/browser-pubsub/index.html
@@ -0,0 +1,42 @@
+
+
+
+ Pubsub in the browser
+
+
+
+
+
+
+
+
+
Pubsub
+
+
+
API Addr
+
+
+
+
+
Connect to peer
+
+
+
+
+
Subscribe to pubsub topic
+
+
+
+
+
Send pubsub message
+
+
+
+
+
Console
+
+
+
+
+
+
diff --git a/examples/browser-pubsub/index.js b/examples/browser-pubsub/index.js
new file mode 100644
index 000000000..eae1dab17
--- /dev/null
+++ b/examples/browser-pubsub/index.js
@@ -0,0 +1,135 @@
+'use strict'
+
+const IpfsHttpClient = require('ipfs-http-client')
+const { sleep, Logger, onEnterPress, catchAndLog } = require('./util')
+
+async function main () {
+ const apiUrlInput = document.getElementById('api-url')
+ const nodeConnectBtn = document.getElementById('node-connect')
+
+ const peerAddrInput = document.getElementById('peer-addr')
+ const peerConnectBtn = document.getElementById('peer-connect')
+
+ const topicInput = document.getElementById('topic')
+ const subscribeBtn = document.getElementById('subscribe')
+
+ const messageInput = document.getElementById('message')
+ const sendBtn = document.getElementById('send')
+
+ let log = Logger(document.getElementById('console'))
+ let ipfs
+ let topic
+ let peerId
+
+ async function reset () {
+ if (ipfs && topic) {
+ log(`Unsubscribing from topic ${topic}`)
+ await ipfs.pubsub.unsubscribe(topic)
+ }
+ log = Logger(document.getElementById('console'))
+ topicInput.value = ''
+ topic = null
+ peerId = null
+ ipfs = null
+ }
+
+ async function nodeConnect (url) {
+ await reset()
+ log(`Connecting to ${url}`)
+ ipfs = IpfsHttpClient(url)
+ const { id, agentVersion } = await ipfs.id()
+ peerId = id
+ log(`Success!`)
+ log(`Version ${agentVersion}`)
+ log(`Peer ID ${id}`)
+ }
+
+ async function peerConnect (addr) {
+ if (!addr) throw new Error('Missing peer multiaddr')
+ if (!ipfs) throw new Error('Connect to a node first')
+ log(`Connecting to peer ${addr}`)
+ await ipfs.swarm.connect(addr)
+ log(`Success!`)
+ log('Listing swarm peers...')
+ await sleep()
+ const peers = await ipfs.swarm.peers()
+ peers.forEach(peer => {
+ const fullAddr = `${peer.addr}/ipfs/${peer.peer.toB58String()}`
+ log(`${fullAddr}`)
+ })
+ log(`(${peers.length} peers total)`)
+ }
+
+ async function subscribe (nextTopic) {
+ if (!nextTopic) throw new Error('Missing topic name')
+ if (!ipfs) throw new Error('Connect to a node first')
+
+ const lastTopic = topic
+
+ if (topic) {
+ topic = null
+ log(`Unsubscribing from topic ${lastTopic}`)
+ await ipfs.pubsub.unsubscribe(lastTopic)
+ }
+
+ log(`Subscribing to ${nextTopic}...`)
+
+ await ipfs.pubsub.subscribe(nextTopic, msg => {
+ const from = msg.from
+ const seqno = msg.seqno.toString('hex')
+ if (from === peerId) return log(`Ignoring message ${seqno} from self`)
+ log(`Message ${seqno} from ${from}:`)
+ try {
+ log(JSON.stringify(msg.data.toString(), null, 2))
+ } catch (_) {
+ log(msg.data.toString('hex'))
+ }
+ }, {
+ onError: (err, fatal) => {
+ if (fatal) {
+ console.error(err)
+ log(`${err.message}`)
+ topic = null
+ log('Resubscribing in 5s...')
+ setTimeout(catchAndLog(() => subscribe(nextTopic), log), 5000)
+ } else {
+ console.warn(err)
+ }
+ }
+ })
+
+ topic = nextTopic
+ log(`Success!`)
+ }
+
+ async function send (msg) {
+ if (!msg) throw new Error('Missing message')
+ if (!topic) throw new Error('Subscribe to a topic first')
+ if (!ipfs) throw new Error('Connect to a node first')
+
+ log(`Sending message to ${topic}...`)
+ await ipfs.pubsub.publish(topic, msg)
+ log(`Success!`)
+ }
+
+ const onNodeConnectClick = catchAndLog(() => nodeConnect(apiUrlInput.value), log)
+ apiUrlInput.addEventListener('keydown', onEnterPress(onNodeConnectClick))
+ nodeConnectBtn.addEventListener('click', onNodeConnectClick)
+
+ const onPeerConnectClick = catchAndLog(() => peerConnect(peerAddrInput.value), log)
+ peerAddrInput.addEventListener('keydown', onEnterPress(onPeerConnectClick))
+ peerConnectBtn.addEventListener('click', onPeerConnectClick)
+
+ const onSubscribeClick = catchAndLog(() => subscribe(topicInput.value), log)
+ topicInput.addEventListener('keydown', onEnterPress(onSubscribeClick))
+ subscribeBtn.addEventListener('click', onSubscribeClick)
+
+ const onSendClick = catchAndLog(async () => {
+ await send(messageInput.value)
+ messageInput.value = ''
+ }, log)
+ messageInput.addEventListener('keydown', onEnterPress(onSendClick))
+ sendBtn.addEventListener('click', onSendClick)
+}
+
+main()
diff --git a/examples/browser-pubsub/package.json b/examples/browser-pubsub/package.json
new file mode 100644
index 000000000..6e519bf9e
--- /dev/null
+++ b/examples/browser-pubsub/package.json
@@ -0,0 +1,21 @@
+{
+ "name": "browser-pubsub-example",
+ "version": "0.0.0",
+ "description": "An example demonstrating pubsub in the browser",
+ "private": true,
+ "main": "index.js",
+ "scripts": {
+ "start": "parcel index.html"
+ },
+ "author": "Alan Shaw",
+ "license": "MIT",
+ "dependencies": {
+ "ipfs-http-client": "../../"
+ },
+ "browserslist": [
+ "last 2 versions and not dead and > 2%"
+ ],
+ "devDependencies": {
+ "parcel-bundler": "^1.12.4"
+ }
+}
diff --git a/examples/browser-pubsub/util.js b/examples/browser-pubsub/util.js
new file mode 100644
index 000000000..e6aada61f
--- /dev/null
+++ b/examples/browser-pubsub/util.js
@@ -0,0 +1,31 @@
+exports.sleep = (ms = 1000) => new Promise(resolve => setTimeout(resolve, ms))
+
+exports.Logger = outEl => {
+ outEl.innerHTML = ''
+ return message => {
+ const container = document.createElement('div')
+ container.innerHTML = message
+ outEl.appendChild(container)
+ outEl.scrollTop = outEl.scrollHeight
+ }
+}
+
+exports.onEnterPress = fn => {
+ return e => {
+ if (event.which == 13 || event.keyCode == 13) {
+ e.preventDefault()
+ fn()
+ }
+ }
+}
+
+exports.catchAndLog = (fn, log) => {
+ return async (...args) => {
+ try {
+ await fn(...args)
+ } catch (err) {
+ console.error(err)
+ log(`${err.message}`)
+ }
+ }
+}
diff --git a/examples/bundle-browserify/.gitignore b/examples/bundle-browserify/.gitignore
deleted file mode 100644
index 4187d6774..000000000
--- a/examples/bundle-browserify/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-bundle.js
\ No newline at end of file
diff --git a/examples/bundle-browserify/README.md b/examples/bundle-browserify/README.md
deleted file mode 100644
index a185527e0..000000000
--- a/examples/bundle-browserify/README.md
+++ /dev/null
@@ -1,35 +0,0 @@
-# Bundle js-ipfs-http-client with Browserify!
-
-> In this example, you will find a boilerplate you can use to guide yourself into bundling js-ipfs-http-client with browserify, so that you can use it in your own web app!
-
-## Setup
-
-As for any js-ipfs-http-client example, **you need a running IPFS daemon**, you learn how to do that here:
-
-- [Spawn a go-ipfs daemon](https://ipfs.io/docs/getting-started/)
-- [Spawn a js-ipfs daemon](https://github.com/ipfs/js-ipfs#usage)
-
-**Note:** If you load your app from a different domain than the one the daemon is running (most probably), you will need to set up CORS, see https://github.com/ipfs/js-ipfs-http-client#cors to learn how to do that.
-
-A quick (and dirty way to get it done) is:
-
-```bash
-> ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\"*\"]"
-> ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials "[\"true\"]"
-```
-
-## Run this example
-
-Once the daemon is on, run the following commands within this folder:
-
-```bash
-> npm install
-> npm start
-```
-
-Now open your browser at `http://localhost:8888`
-
-You should see the following:
-
-
-
diff --git a/examples/bundle-browserify/img/1.png b/examples/bundle-browserify/img/1.png
deleted file mode 100644
index 580511dad..000000000
Binary files a/examples/bundle-browserify/img/1.png and /dev/null differ
diff --git a/examples/bundle-browserify/img/2.png b/examples/bundle-browserify/img/2.png
deleted file mode 100644
index 5c72fc0a3..000000000
Binary files a/examples/bundle-browserify/img/2.png and /dev/null differ
diff --git a/examples/bundle-browserify/index.html b/examples/bundle-browserify/index.html
deleted file mode 100644
index 77596e861..000000000
--- a/examples/bundle-browserify/index.html
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
- JS IPFS API - Example - Browser - Add
-
-
-
-
-
JS IPFS API - Add data to IPFS from the browser
-
-
-
-
found in ipfs:
-
[ipfs hash]
-
[ipfs content]
-
-
-
diff --git a/examples/bundle-browserify/index.js b/examples/bundle-browserify/index.js
deleted file mode 100644
index b0bc9f15e..000000000
--- a/examples/bundle-browserify/index.js
+++ /dev/null
@@ -1,36 +0,0 @@
-'use strict'
-
-var IPFS = require('ipfs-http-client')
-
-var ipfs = IPFS()
-
-function store () {
- var toStore = document.getElementById('source').value
- ipfs.add(Buffer.from(toStore), function (err, res) {
- if (err || !res) {
- return console.error('ipfs add error', err, res)
- }
-
- res.forEach(function (file) {
- if (file && file.hash) {
- console.log('successfully stored', file.hash)
- display(file.hash)
- }
- })
- })
-}
-
-function display (hash) {
- ipfs.cat(hash, function (err, res) {
- if (err || !res) {
- return console.error('ipfs cat error', err, res)
- }
-
- document.getElementById('hash').innerText = hash
- document.getElementById('content').innerText = res.toString()
- })
-}
-
-document.addEventListener('DOMContentLoaded', function () {
- document.getElementById('store').onclick = store
-})
diff --git a/examples/bundle-browserify/package.json b/examples/bundle-browserify/package.json
deleted file mode 100644
index 4e64ef8a5..000000000
--- a/examples/bundle-browserify/package.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "name": "bundle-browserify",
- "version": "1.0.0",
- "description": "Bundle js-ipfs-http-client with Browserify",
- "main": "index.js",
- "scripts": {
- "start": "browserify index.js > bundle.js && http-server -a 127.0.0.1 -p 8888"
- },
- "keywords": [],
- "author": "Friedel Ziegelmayer",
- "license": "MIT",
- "devDependencies": {
- "browserify": "^13.1.1",
- "ipfs-http-client": "../../",
- "http-server": "~0.9.0"
- },
- "dependencies": {}
-}
diff --git a/examples/bundle-webpack/README.md b/examples/bundle-webpack/README.md
index 3b894b7f5..c85543240 100644
--- a/examples/bundle-webpack/README.md
+++ b/examples/bundle-webpack/README.md
@@ -11,7 +11,7 @@ As for any js-ipfs-http-client example, **you need a running IPFS daemon**, you
**Note:** If you load your app from a different domain than the one the daemon is running (most probably), you will need to set up CORS, see https://github.com/ipfs/js-ipfs-http-client#cors to learn how to do that.
-A quick (and dirty way to get it done) is:
+A quick (and dirty) way to get it done is:
```bash
> ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\"*\"]"
diff --git a/examples/bundle-webpack/package.json b/examples/bundle-webpack/package.json
index 48ecb1ec5..7141efa03 100644
--- a/examples/bundle-webpack/package.json
+++ b/examples/bundle-webpack/package.json
@@ -14,16 +14,13 @@
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.5",
"ipfs-http-client": "../../",
- "react": "^16.8.1",
- "react-dom": "^16.8.1",
- "react-hot-loader": "^4.6.5",
- "webpack": "^4.29.3",
- "webpack-dev-server": "^3.1.14"
+ "react": "~16.8.6",
+ "react-dom": "~16.8.6",
+ "react-hot-loader": "~4.8.4",
+ "webpack": "~4.31.0",
+ "webpack-dev-server": "~3.3.1"
},
"browserslist": [
- ">1%",
- "not dead",
- "not ie <= 11",
- "not op_mini all"
+ "last 2 versions and not dead and > 2%"
]
}
diff --git a/examples/bundle-webpack/src/App.js b/examples/bundle-webpack/src/App.js
index 06bf81991..bc25b5b81 100644
--- a/examples/bundle-webpack/src/App.js
+++ b/examples/bundle-webpack/src/App.js
@@ -2,7 +2,7 @@
const React = require('react')
const ipfsClient = require('ipfs-http-client')
-const ipfs = ipfsClient('localhost', '5001')
+const ipfs = ipfsClient('/ip4/127.0.0.1/tcp/5001')
const stringToUse = 'hello world from webpacked IPFS'
class App extends React.Component {
@@ -16,24 +16,27 @@ class App extends React.Component {
added_file_contents: null
}
}
- componentDidMount () {
- ipfs.id((err, res) => {
- if (err) throw err
- this.setState({
- id: res.id,
- version: res.agentVersion,
- protocol_version: res.protocolVersion
- })
+ async componentDidMount () {
+ const id = await ipfs.id()
+ this.setState({
+ id: id.id,
+ version: id.agentVersion,
+ protocol_version: id.protocolVersion
})
- ipfs.add([Buffer.from(stringToUse)], (err, res) => {
- if (err) throw err
- const hash = res[0].hash
+
+ const source = ipfs.add(stringToUse)
+ for await (const file of source) {
+ console.log("TCL: App -> forawait -> file", file)
+ const hash = file.path
this.setState({ added_file_hash: hash })
- ipfs.cat(hash, (err, data) => {
- if (err) throw err
- this.setState({ added_file_contents: data.toString() })
- })
- })
+
+ const source = ipfs.cat(hash)
+ const data = []
+ for await (const chunk of source) {
+ data.push(chunk)
+ }
+ this.setState({ added_file_contents: Buffer.concat(data).toString() })
+ }
}
render () {
return
diff --git a/examples/files-api/files-api.js b/examples/files-api/files-api.js
index fefc957d6..308c3fc9e 100644
--- a/examples/files-api/files-api.js
+++ b/examples/files-api/files-api.js
@@ -1,14 +1,21 @@
+/* eslint-disable no-console */
'use strict'
-const ipfs = require('../../src')('localhost', 5001)
+// Run `ipfs daemon` in your terminal to start the IPFS daemon
+// Look for `API server listening on /ip4/127.0.0.1/tcp/5001`
+const ipfs = require('../../src')('/ip4/127.0.0.1/tcp/5001')
-ipfs.files.ls('/folder1', function (err, res) {
- if (err) {
- return console.log('got an error', err)
- }
- if (res.readable) {
- res.pipe(process.stdout)
- } else {
- console.log(res)
+const run = async () => {
+ await ipfs.files.write(
+ '/temp/hello-world',
+ Buffer.from('Hello, world!'),
+ { create: true, parents: true }
+ )
+ const source = ipfs.files.ls('/temp')
+
+ for await (const file of source) {
+ console.log(file)
}
-})
+}
+
+run()
diff --git a/examples/name-api/index.html b/examples/name-api/index.html
index 3e5fba013..54843d332 100644
--- a/examples/name-api/index.html
+++ b/examples/name-api/index.html
@@ -58,7 +58,6 @@