From d884f05fbcdf370813611f1dab2ba8ae7606c916 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Wed, 4 Apr 2018 10:49:38 +0100 Subject: [PATCH] feat: Provide access to bundled libraries when in browser --- README.md | 5 +++++ package.json | 4 ++++ src/core/index.js | 12 +++++++++++- test/core/init.spec.js | 12 +++++++++++- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ade402ea68..f591df6b88 100644 --- a/README.md +++ b/README.md @@ -366,8 +366,13 @@ A set of data types are exposed directly from the IPFS instance under `ipfs.type - [`ipfs.types.PeerId`](https://github.com/libp2p/js-peer-id) - [`ipfs.types.PeerInfo`](https://github.com/libp2p/js-peer-info) - [`ipfs.types.multiaddr`](https://github.com/multiformats/js-multiaddr) +- [`ipfs.types.multibase`](https://github.com/multiformats/multibase) - [`ipfs.types.multihash`](https://github.com/multiformats/js-multihash) - [`ipfs.types.CID`](https://github.com/ipld/js-cid) +- [`ipfs.types.crypto`](https://github.com/libp2p/js-libp2p-crypto) +- [`ipfs.types.dagPB`](https://github.com/ipld/js-ipld-dag-pb) +- [`ipfs.types.dagCBOR`](https://github.com/ipld/js-ipld-dag-cbor) +- [`ipfs.types.isIPFS`](https://github.com/ipfs-shipyard/is-ipfs) ## FAQ diff --git a/package.json b/package.json index aa93799263..aab0fbce62 100644 --- a/package.json +++ b/package.json @@ -115,6 +115,8 @@ "ipfs-unixfs": "~0.1.14", "ipfs-unixfs-engine": "~0.27.0", "ipld": "^0.15.0", + "ipld-dag-cbor": "^0.12.0", + "ipld-dag-pb": "^0.13.1", "is-ipfs": "^0.3.2", "is-stream": "^1.1.0", "joi": "^13.1.2", @@ -122,6 +124,7 @@ "joi-multiaddr": "^1.0.1", "libp2p": "~0.19.2", "libp2p-circuit": "~0.1.5", + "libp2p-crypto": "^0.12.1", "libp2p-floodsub": "~0.14.1", "libp2p-kad-dht": "~0.9.0", "libp2p-keychain": "~0.3.1", @@ -141,6 +144,7 @@ "mime-types": "^2.1.18", "mkdirp": "~0.5.1", "multiaddr": "^3.1.0", + "multibase": "^0.4.0", "multihashes": "~0.4.13", "once": "^1.4.0", "path-exists": "^3.0.0", diff --git a/src/core/index.js b/src/core/index.js index d27d178f85..2921c06044 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -4,9 +4,14 @@ const BlockService = require('ipfs-block-service') const Ipld = require('ipld') const PeerId = require('peer-id') const PeerInfo = require('peer-info') +const dagCBOR = require('ipld-dag-cbor') +const dagPB = require('ipld-dag-pb') +const crypto = require('libp2p-crypto') +const isIPFS = require('is-ipfs') const multiaddr = require('multiaddr') const multihash = require('multihashes') const PeerBook = require('peer-book') +const multibase = require('multibase') const CID = require('cids') const debug = require('debug') const extend = require('deep-extend') @@ -58,8 +63,13 @@ class IPFS extends EventEmitter { PeerId: PeerId, PeerInfo: PeerInfo, multiaddr: multiaddr, + multibase: multibase, multihash: multihash, - CID: CID + CID: CID, + crypto: crypto, + dagPB: dagPB, + dagCBOR: dagCBOR, + isIPFS: isIPFS } // IPFS Core Internals diff --git a/test/core/init.spec.js b/test/core/init.spec.js index 58916ecbe4..e4e0580330 100644 --- a/test/core/init.spec.js +++ b/test/core/init.spec.js @@ -10,7 +10,12 @@ const isNode = require('detect-node') const hat = require('hat') const PeerId = require('peer-id') const PeerInfo = require('peer-info') +const dagCBOR = require('ipld-dag-cbor') +const dagPB = require('ipld-dag-pb') +const crypto = require('libp2p-crypto') +const isIPFS = require('is-ipfs') const multiaddr = require('multiaddr') +const multibase = require('multibase') const multihash = require('multihashes') const CID = require('cids') const IPFS = require('../../src/core') @@ -101,8 +106,13 @@ describe('init', () => { PeerId: PeerId, PeerInfo: PeerInfo, multiaddr: multiaddr, + multibase: multibase, multihash: multihash, - CID: CID + CID: CID, + crypto: crypto, + dagPB: dagPB, + dagCBOR: dagCBOR, + isIPFS: isIPFS }) }) })