Skip to content

Commit

Permalink
refactor: necromancy to restore build
Browse files Browse the repository at this point in the history
- removed yarn and all the hackery around transitive dependency overrides
- bumped all dependencies
- switched to ipfs-core for less deps
- removed unused deps
- Firefox manifest fix to pass latest webext lint
- removed remaining window.ipfs code that was pulling dead dependencies
  (ipfs/in-web-browsers#172)

TODO:
- fix tests
- docker builds
- browserAction icon
  • Loading branch information
lidel committed Sep 26, 2022
1 parent 8a33b6c commit 05decab
Show file tree
Hide file tree
Showing 37 changed files with 36,014 additions and 17,105 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/vendor
/node_modules
/package-lock.json
/yarn.lock
/firefox
/cache
/build
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14.15.4
FROM node:16.13.1

ARG USER_ID
ARG GROUP_ID
Expand Down
12 changes: 0 additions & 12 deletions add-on/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -515,18 +515,6 @@
"message": "Load items with x-ipfs-path headers over IPFS (instead of HTTP) if the header value is an IPFS path. To redirect IPNS paths as well, enable DNSLink support.",
"description": "An option description on the Preferences screen (option_detectIpfsPathHeader_description)"
},
"option_ipfsProxy_title": {
"message": "Support for window.ipfs",
"description": "An option title for enabling/disabling the IPFS proxy (option_ipfsProxy_title)"
},
"option_ipfsProxy_description": {
"message": "IPFS is added to the window object on every page. Enable/disable access to the functions it exposes.",
"description": "An option description for the IPFS proxy (option_ipfsProxy_description)"
},
"option_ipfsProxy_link_manage_permissions": {
"message": "Manage permissions",
"description": "Link text for managing permissions"
},
"option_openViaWebUI_title": {
"message": "Open Imported Files in the Files Screen",
"description": "An option title on the Preferences screen (option_openViaWebUI_title)"
Expand Down
2 changes: 1 addition & 1 deletion add-on/manifest.firefox.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"applications": {
"gecko": {
"id": "ipfs-firefox-addon@lidel.org",
"strict_min_version": "68.0"
"strict_min_version": "91.1.0"
}
},
"permissions": [
Expand Down
51 changes: 0 additions & 51 deletions add-on/src/contentScripts/ipfs-proxy/content.js

This file was deleted.

15 changes: 0 additions & 15 deletions add-on/src/contentScripts/ipfs-proxy/inject-script.js

This file was deleted.

48 changes: 0 additions & 48 deletions add-on/src/contentScripts/ipfs-proxy/page.js

This file was deleted.

2 changes: 1 addition & 1 deletion add-on/src/lib/ipfs-client/embedded.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const log = debug('ipfs-companion:client:embedded')
log.error = debug('ipfs-companion:client:embedded:error')

const mergeOptions = require('merge-options')
const Ipfs = require('ipfs')
const Ipfs = require('ipfs-core')
const { optionDefaults } = require('../options')

let node = null
Expand Down
4 changes: 2 additions & 2 deletions add-on/src/lib/ipfs-client/external.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ const debug = require('debug')
const log = debug('ipfs-companion:client:external')
log.error = debug('ipfs-companion:client:external:error')

const httpClient = require('ipfs-http-client')
const { create } = require('ipfs-http-client')

exports.init = async function (browser, opts) {
log(`init with IPFS API at ${opts.apiURLString}`)
const clientConfig = opts.apiURLString
// https://github.com/ipfs/js-ipfs/tree/master/packages/ipfs-http-client#importing-the-module-and-usage
const api = httpClient(clientConfig)
const api = await create(clientConfig)
return api
}

Expand Down
61 changes: 0 additions & 61 deletions add-on/src/lib/ipfs-companion.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const createCopier = require('./copier')
const createInspector = require('./inspector')
const { createRuntimeChecks } = require('./runtime-checks')
const { createContextMenus, findValueForContext, contextMenuCopyAddressAtPublicGw, contextMenuCopyRawCid, contextMenuCopyCanonicalAddress, contextMenuViewOnGateway, contextMenuCopyPermalink, contextMenuCopyCidAddress } = require('./context-menus')
const createIpfsProxy = require('./ipfs-proxy')
const { registerSubdomainProxy } = require('./http-proxy')
const { runPendingOnInstallTasks } = require('./on-installed')

Expand All @@ -44,8 +43,6 @@ module.exports = async function init () {
let runtime
let contextMenus
let apiStatusUpdateInterval
let ipfsProxy
// TODO: window.ipfs var ipfsProxyContentScript
let ipfsImportHandler
const idleInSecs = 5 * 60
const browserActionPortName = 'browser-action-port'
Expand Down Expand Up @@ -84,8 +81,6 @@ module.exports = async function init () {
onCopyAddressAtPublicGw: copier.copyAddressAtPublicGw
})
modifyRequest = createRequestModifier(getState, dnslinkResolver, ipfsPathValidator, runtime)
ipfsProxy = createIpfsProxy(getIpfs, getState)
// TODO(window.ipfs) ipfsProxyContentScript = await registerIpfsProxyContentScript()
log('register all listeners')
registerListeners()
await registerSubdomainProxy(getState, runtime, notify)
Expand Down Expand Up @@ -137,43 +132,6 @@ module.exports = async function init () {
}
}

// Register Content Script responsible for loading window.ipfs (ipfsProxy)
//
// The key difference between tabs.executeScript and contentScripts API
// is the latter provides guarantee to execute before anything else.
// https://github.com/ipfs-shipyard/ipfs-companion/issues/451#issuecomment-382669093
/* TODO(window.ipfs)
async function registerIpfsProxyContentScript (previousHandle) {
previousHandle = previousHandle || ipfsProxyContentScript
if (previousHandle) {
previousHandle.unregister()
}
// TODO:
// No window.ipfs for now.
// We will restore when Migration to JS API with Async Await and Async Iterables
// is done:
// https://github.com/ipfs-shipyard/ipfs-companion/pull/777
// https://github.com/ipfs-shipyard/ipfs-companion/issues/843
// https://github.com/ipfs-shipyard/ipfs-companion/issues/852#issuecomment-594510819
const forceOff = true
if (forceOff || !state.active || !state.ipfsProxy || !browser.contentScripts) {
// no-op if global toggle is off, window.ipfs is disabled in Preferences
// or if runtime has no contentScript API
// (Chrome loads content script via manifest)
return
}
const newHandle = await browser.contentScripts.register({
matches: ['<all_urls>'],
js: [
{ file: '/dist/bundles/ipfsProxyContentScript.bundle.js' }
],
allFrames: true,
runAt: 'document_start'
})
return newHandle
}
*/

// HTTP Request Hooks
// ===================================================================

Expand Down Expand Up @@ -617,7 +575,6 @@ module.exports = async function init () {
switch (key) {
case 'active':
state[key] = change.newValue
// TODO(window.ipfs) ipfsProxyContentScript = await registerIpfsProxyContentScript()
await registerSubdomainProxy(getState, runtime)
shouldRestartIpfsClient = true
shouldStopIpfsClient = !state.active
Expand Down Expand Up @@ -672,12 +629,6 @@ module.exports = async function init () {
// Finally, update proxy settings based on the state
await registerSubdomainProxy(getState, runtime)
break
/* TODO(window.ipfs)
case 'ipfsProxy':
state[key] = change.newValue
// This is window.ipfs proxy, requires update of the content script:
ipfsProxyContentScript = await registerIpfsProxyContentScript()
break */
case 'dnslinkPolicy':
state.dnslinkPolicy = String(change.newValue) === 'false' ? false : change.newValue
if (state.dnslinkPolicy === 'best-effort' && !state.detectIpfsPathHeader) {
Expand Down Expand Up @@ -771,18 +722,6 @@ module.exports = async function init () {
apiStatusUpdateInterval = null
}

/* TODO(window.ipfs)
if (ipfsProxyContentScript) {
ipfsProxyContentScript.unregister()
ipfsProxyContentScript = null
}
*/

if (ipfsProxy) {
await ipfsProxy.destroy()
ipfsProxy = null
}

if (ipfs) {
await destroyIpfsClient(browser)
ipfs = null
Expand Down
Loading

0 comments on commit 05decab

Please sign in to comment.