Skip to content

Commit

Permalink
refactor: remove embedded:chromesockets experiment (#985)
Browse files Browse the repository at this point in the history
* refactor: migrate embedded:chromesockets

Migrate any users using embedded:chromesockets node type to brave native
one + remove unused code.

* chore: remove unused deps
* fix(ci): node 14.x
* chore: remove unused tests
* fix: tests on windows
  • Loading branch information
lidel authored Mar 10, 2021
1 parent 77a88c4 commit d83d30d
Show file tree
Hide file tree
Showing 18 changed files with 3,187 additions and 5,396 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 14.x

- name: Restore .cache
uses: actions/cache@v2
Expand Down
1 change: 0 additions & 1 deletion add-on/src/lib/dnslink.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ module.exports = function createDnslinkResolver (getState) {
readDnslinkFromTxtRecord (fqdn) {
const state = getState()
let apiProvider
// TODO: fix DNS resolver for ipfsNodeType='embedded:chromesockets', for now use ipfs.io
if (!state.ipfsNodeType.startsWith('embedded') && state.peerCount !== offlinePeerCount) {
// Use gw port so it can be a GET:
// Chromium does not execute onBeforeSendHeaders for synchronous calls
Expand Down
2 changes: 1 addition & 1 deletion add-on/src/lib/http-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async function registerSubdomainProxy (getState, runtime, notify) {
}

// storing listener for later
var onRequestProxyListener
let onRequestProxyListener

// registerSubdomainProxyFirefox sets proxy using API available in Firefox
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/proxy/onRequest
Expand Down
3 changes: 3 additions & 0 deletions add-on/src/lib/ipfs-client/brave.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ async function initBraveSettings (browser, brave) {
}

if (method !== 'local') {
// user picked remote gateway mode, turn Companion off for now
// (this way clicking power button in browser action menu will re-run activation flow)
await browser.storage.local.set({ active: false })
// close tab with temporary trigger URI
await closeIpfsTab(browser, braveIpfsUriTrigger)
await closeIpfsTab(browser, braveGatewayUrlTrigger)
Expand Down
223 changes: 0 additions & 223 deletions add-on/src/lib/ipfs-client/embedded-chromesockets/config.js

This file was deleted.

61 changes: 0 additions & 61 deletions add-on/src/lib/ipfs-client/embedded-chromesockets/index.js

This file was deleted.

17 changes: 13 additions & 4 deletions add-on/src/lib/ipfs-client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ log.error = debug('ipfs-companion:client:error')
const external = require('./external')
const embedded = require('./embedded')
const brave = require('./brave')
const embeddedWithChromeSockets = require('./embedded-chromesockets')
const { precache } = require('../precache')

// ensure single client at all times, and no overlap between init and destroy
Expand All @@ -20,12 +19,22 @@ async function initIpfsClient (browser, opts) {
if (client) return // await destroyIpfsClient()
let backend
switch (opts.ipfsNodeType) {
case 'embedded:chromesockets':
// TODO: remove this one-time migration after in second half of 2021
setTimeout(async () => {
log('converting embedded:chromesockets to native external:brave')
opts.ipfsNodeType = 'external:brave'
await browser.storage.local.set({
ipfsNodeType: 'external:brave',
ipfsNodeConfig: '{}' // remove chrome-apps config
})
await browser.tabs.create({ url: 'https://docs.ipfs.io/how-to/companion-node-types/#native' })
}, 0)
// Halt client init
throw new Error('Embedded + chrome.sockets is deprecated. Switching to Native IPFS in Brave.')
case 'embedded':
backend = embedded
break
case 'embedded:chromesockets':
backend = embeddedWithChromeSockets
break
case 'external:brave':
backend = brave
break
Expand Down
Loading

0 comments on commit d83d30d

Please sign in to comment.