diff --git a/add-on/manifest.firefox-libdweb.json b/add-on/manifest.firefox-libdweb.json index ebb66fd8f..82616217b 100644 --- a/add-on/manifest.firefox-libdweb.json +++ b/add-on/manifest.firefox-libdweb.json @@ -19,6 +19,19 @@ "paths": [["protocol"]], "script": "../node_modules/libdweb/src/protocol/host.js" } + }, + "ServiceDiscovery": { + "schema": "../node_modules/libdweb/src/ServiceDiscovery/ServiceDiscovery.json", + "child": { + "scopes": ["addon_child"], + "paths": [["ServiceDiscovery"]], + "script": "../node_modules/libdweb/src/ServiceDiscovery/client.js" + }, + "parent": { + "scopes": ["addon_parent"], + "paths": [["ServiceDiscovery"]], + "script": "../node_modules/libdweb/src/ServiceDiscovery/host.js" + } } } } diff --git a/add-on/src/background/background.js b/add-on/src/background/background.js index ce31f3c1f..7f5716286 100644 --- a/add-on/src/background/background.js +++ b/add-on/src/background/background.js @@ -1,6 +1,8 @@ 'use strict' /* eslint-env browser, webextensions */ +chrome.storage.local.debug = 'libp2p:webext-mdns*' + const createIpfsCompanion = require('../lib/ipfs-companion') // init add-on after all libs are loaded diff --git a/add-on/src/lib/ipfs-client/embedded.js b/add-on/src/lib/ipfs-client/embedded.js index b617eb1ea..eb65b22aa 100644 --- a/add-on/src/lib/ipfs-client/embedded.js +++ b/add-on/src/lib/ipfs-client/embedded.js @@ -1,6 +1,7 @@ 'use strict' const Ipfs = require('ipfs') +const WebExtMdns = require('libp2p-webext-mdns') const { optionDefaults } = require('../options') let node = null @@ -8,10 +9,19 @@ let node = null exports.init = function init (opts) { console.log('[ipfs-companion] Embedded ipfs init') - node = new Ipfs( - JSON.parse(opts.ipfsNodeConfig || optionDefaults.ipfsNodeConfig) + const ipfsOpts = Object.assign( + JSON.parse(opts.ipfsNodeConfig || optionDefaults.ipfsNodeConfig), + { + libp2p: { + modules: { + peerDiscovery: [WebExtMdns] + } + } + } ) + node = new Ipfs(ipfsOpts) + if (node.isOnline()) { return Promise.resolve(node) } diff --git a/package.json b/package.json index fd29fa7b5..2855c3850 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "cross-env": "5.2.0", "fakefile": "0.0.9", "fs-promise": "2.0.3", - "get-firefox": "2.1.1", + "get-firefox": "2.2.0", "husky": "0.14.3", "ignore-styles": "5.0.1", "json": "9.0.6", @@ -115,7 +115,8 @@ "is-ipfs": "0.4.2", "is-stream": "1.1.0", "is-svg": "3.0.0", - "libdweb": "mozilla/libdweb.git#fbff435b33542b02bc35c0bb8c27bc203e6d4e6e", + "libdweb": "mozilla/libdweb.git#1ee7977a2352950ecf7fa46a13ae45aa500c9b32", + "libp2p-webext-mdns": "github:alanshaw/js-libp2p-webext-mdns#661e03745450c3303e4fa0c2600c28dd0a4a3ba5", "lru_map": "0.3.3", "mime-types": "2.1.19", "p-queue": "2.4.2", diff --git a/yarn.lock b/yarn.lock index f8c3e0907..a448e3221 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4219,19 +4219,20 @@ get-caller-file@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a" -get-firefox@2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/get-firefox/-/get-firefox-2.1.1.tgz#1dbafe1e357fb292e816d4c64b6fc7a5153bf7a7" +get-firefox@2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/get-firefox/-/get-firefox-2.2.0.tgz#7ea8fc874bb952295de33705aea21db14ce2a55e" dependencies: chalk "^2.4.1" decompress "^4.2.0" + is-ci "^1.1.0" listr "^0.14.0" meow "^5.0.0" moz-download-url "^2.0.0" - node-fetch "^2.1.2" + node-fetch "^2.2.0" sha "^2.0.1" stream-to-promise "^2.2.0" - taskcluster-client "^11.0.0" + taskcluster-client "^11.0.3" get-folder-size@^2.0.0: version "2.0.0" @@ -5386,7 +5387,7 @@ is-callable@^1.1.1, is-callable@^1.1.3: version "1.1.4" resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75" -is-ci@^1.0.10: +is-ci@^1.0.10, is-ci@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-1.1.0.tgz#247e4162e7860cebbdaf30b774d6b0ac7dcfe7a5" dependencies: @@ -6134,9 +6135,9 @@ levn@^0.3.0, levn@~0.3.0: prelude-ls "~1.1.2" type-check "~0.3.2" -libdweb@mozilla/libdweb.git#fbff435b33542b02bc35c0bb8c27bc203e6d4e6e: +libdweb@mozilla/libdweb.git#1ee7977a2352950ecf7fa46a13ae45aa500c9b32: version "0.0.0" - resolved "https://codeload.github.com/mozilla/libdweb/tar.gz/fbff435b33542b02bc35c0bb8c27bc203e6d4e6e" + resolved "https://codeload.github.com/mozilla/libdweb/tar.gz/1ee7977a2352950ecf7fa46a13ae45aa500c9b32" libp2p-bootstrap@~0.9.3: version "0.9.3" @@ -6385,6 +6386,16 @@ libp2p-tcp@~0.12.0: once "^1.4.0" stream-to-pull-stream "^1.7.2" +"libp2p-webext-mdns@github:alanshaw/js-libp2p-webext-mdns#661e03745450c3303e4fa0c2600c28dd0a4a3ba5": + version "0.1.0" + resolved "https://codeload.github.com/alanshaw/js-libp2p-webext-mdns/tar.gz/661e03745450c3303e4fa0c2600c28dd0a4a3ba5" + dependencies: + async "^2.6.1" + libp2p-tcp "~0.12.0" + multiaddr "^5.0.0" + peer-id "~0.11.0" + peer-info "~0.14.1" + libp2p-webrtc-star@~0.15.3: version "0.15.3" resolved "https://registry.yarnpkg.com/libp2p-webrtc-star/-/libp2p-webrtc-star-0.15.3.tgz#370b09c2871a12dadc44ed66dfd31060af671b52" @@ -7601,7 +7612,7 @@ node-abi@^2.2.0: dependencies: semver "^5.4.1" -node-fetch@^2.1.2: +node-fetch@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.2.0.tgz#4ee79bde909262f9775f731e3656d0db55ced5b5" @@ -10384,7 +10395,7 @@ tar@^4: safe-buffer "^5.1.2" yallist "^3.0.2" -taskcluster-client@^11.0.0: +taskcluster-client@^11.0.3: version "11.0.3" resolved "https://registry.yarnpkg.com/taskcluster-client/-/taskcluster-client-11.0.3.tgz#f71fd2d75dc4912ecc6c69fc56994eae088265aa" dependencies: